This source file includes following definitions.
- isl6405_set_voltage
- isl6405_enable_high_lnb_voltage
- isl6405_release
- isl6405_attach
1
2
3
4
5
6
7
8
9
10 #include <linux/delay.h>
11 #include <linux/errno.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/string.h>
16 #include <linux/slab.h>
17
18 #include <media/dvb_frontend.h>
19 #include "isl6405.h"
20
21 struct isl6405 {
22 u8 config;
23 u8 override_or;
24 u8 override_and;
25 struct i2c_adapter *i2c;
26 u8 i2c_addr;
27 };
28
29 static int isl6405_set_voltage(struct dvb_frontend *fe,
30 enum fe_sec_voltage voltage)
31 {
32 struct isl6405 *isl6405 = (struct isl6405 *) fe->sec_priv;
33 struct i2c_msg msg = { .addr = isl6405->i2c_addr, .flags = 0,
34 .buf = &isl6405->config,
35 .len = sizeof(isl6405->config) };
36
37 if (isl6405->override_or & 0x80) {
38 isl6405->config &= ~(ISL6405_VSEL2 | ISL6405_EN2);
39 switch (voltage) {
40 case SEC_VOLTAGE_OFF:
41 break;
42 case SEC_VOLTAGE_13:
43 isl6405->config |= ISL6405_EN2;
44 break;
45 case SEC_VOLTAGE_18:
46 isl6405->config |= (ISL6405_EN2 | ISL6405_VSEL2);
47 break;
48 default:
49 return -EINVAL;
50 }
51 } else {
52 isl6405->config &= ~(ISL6405_VSEL1 | ISL6405_EN1);
53 switch (voltage) {
54 case SEC_VOLTAGE_OFF:
55 break;
56 case SEC_VOLTAGE_13:
57 isl6405->config |= ISL6405_EN1;
58 break;
59 case SEC_VOLTAGE_18:
60 isl6405->config |= (ISL6405_EN1 | ISL6405_VSEL1);
61 break;
62 default:
63 return -EINVAL;
64 }
65 }
66 isl6405->config |= isl6405->override_or;
67 isl6405->config &= isl6405->override_and;
68
69 return (i2c_transfer(isl6405->i2c, &msg, 1) == 1) ? 0 : -EIO;
70 }
71
72 static int isl6405_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
73 {
74 struct isl6405 *isl6405 = (struct isl6405 *) fe->sec_priv;
75 struct i2c_msg msg = { .addr = isl6405->i2c_addr, .flags = 0,
76 .buf = &isl6405->config,
77 .len = sizeof(isl6405->config) };
78
79 if (isl6405->override_or & 0x80) {
80 if (arg)
81 isl6405->config |= ISL6405_LLC2;
82 else
83 isl6405->config &= ~ISL6405_LLC2;
84 } else {
85 if (arg)
86 isl6405->config |= ISL6405_LLC1;
87 else
88 isl6405->config &= ~ISL6405_LLC1;
89 }
90 isl6405->config |= isl6405->override_or;
91 isl6405->config &= isl6405->override_and;
92
93 return (i2c_transfer(isl6405->i2c, &msg, 1) == 1) ? 0 : -EIO;
94 }
95
96 static void isl6405_release(struct dvb_frontend *fe)
97 {
98
99 isl6405_set_voltage(fe, SEC_VOLTAGE_OFF);
100
101
102 kfree(fe->sec_priv);
103 fe->sec_priv = NULL;
104 }
105
106 struct dvb_frontend *isl6405_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c,
107 u8 i2c_addr, u8 override_set, u8 override_clear)
108 {
109 struct isl6405 *isl6405 = kmalloc(sizeof(struct isl6405), GFP_KERNEL);
110 if (!isl6405)
111 return NULL;
112
113
114 if (override_set & 0x80)
115 isl6405->config = ISL6405_ISEL2;
116 else
117 isl6405->config = ISL6405_ISEL1;
118 isl6405->i2c = i2c;
119 isl6405->i2c_addr = i2c_addr;
120 fe->sec_priv = isl6405;
121
122
123 isl6405->override_or = override_set;
124
125
126 isl6405->override_and = ~override_clear;
127
128
129 if (isl6405_set_voltage(fe, SEC_VOLTAGE_OFF)) {
130 kfree(isl6405);
131 fe->sec_priv = NULL;
132 return NULL;
133 }
134
135
136 fe->ops.release_sec = isl6405_release;
137
138
139 fe->ops.set_voltage = isl6405_set_voltage;
140 fe->ops.enable_high_lnb_voltage = isl6405_enable_high_lnb_voltage;
141
142 return fe;
143 }
144 EXPORT_SYMBOL(isl6405_attach);
145
146 MODULE_DESCRIPTION("Driver for lnb supply and control ic isl6405");
147 MODULE_AUTHOR("Hartmut Hackmann & Oliver Endriss");
148 MODULE_LICENSE("GPL");