aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorIgor M. Liplianin <liplianin@me.by>2008-09-17 18:19:19 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:37:06 -0400
commit21b007b94c714cda3ebf0fa5b4e40342d2444f79 (patch)
tree4a08a74d510bba61dd241426b46378e66c585ac0 /drivers/media
parent04ad28c9916da709f38b1d43817892142c2c3508 (diff)
V4L/DVB (9018): Add support for USB card modification with SI2109/2110 demodulator.
Add support for USB card modification with SI2109/2110 demodulator. Signed-off-by: Igor M. Liplianin <liplianin@me.by> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c260
1 files changed, 173 insertions, 87 deletions
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index ad3d6fca9ab8..20ba3f129001 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -11,6 +11,7 @@
11*/ 11*/
12#include <linux/version.h> 12#include <linux/version.h>
13#include "dw2102.h" 13#include "dw2102.h"
14#include "si21xx.h"
14#include "stv0299.h" 15#include "stv0299.h"
15#include "z0194a.h" 16#include "z0194a.h"
16#include "cx24116.h" 17#include "cx24116.h"
@@ -23,8 +24,8 @@
23#define USB_PID_DW2104 0x2104 24#define USB_PID_DW2104 0x2104
24#endif 25#endif
25 26
26#define DW2102_READ_MSG 0 27#define DW210X_READ_MSG 0
27#define DW2102_WRITE_MSG 1 28#define DW210X_WRITE_MSG 1
28 29
29#define REG_1F_SYMBOLRATE_BYTE0 0x1f 30#define REG_1F_SYMBOLRATE_BYTE0 0x1f
30#define REG_20_SYMBOLRATE_BYTE1 0x20 31#define REG_20_SYMBOLRATE_BYTE1 0x20
@@ -33,10 +34,10 @@
33#define DW2102_VOLTAGE_CTRL (0x1800) 34#define DW2102_VOLTAGE_CTRL (0x1800)
34#define DW2102_RC_QUERY (0x1a00) 35#define DW2102_RC_QUERY (0x1a00)
35 36
36struct dw2102_state { 37struct dw210x_state {
37 u32 last_key_pressed; 38 u32 last_key_pressed;
38}; 39};
39struct dw2102_rc_keys { 40struct dw210x_rc_keys {
40 u32 keycode; 41 u32 keycode;
41 u32 event; 42 u32 event;
42}; 43};
@@ -48,28 +49,27 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer (or-able))." DVB_USB
48 49
49DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 50DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
50 51
51static int dw2102_op_rw(struct usb_device *dev, u8 request, u16 value, 52static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
52 u16 index, u8 * data, u16 len, int flags) 53 u16 index, u8 * data, u16 len, int flags)
53{ 54{
54 int ret; 55 int ret;
55 u8 u8buf[len]; 56 u8 u8buf[len];
56 57
57 unsigned int pipe = (flags == DW2102_READ_MSG) ? 58 unsigned int pipe = (flags == DW210X_READ_MSG) ?
58 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); 59 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
59 u8 request_type = (flags == DW2102_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; 60 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
60 61
61 if (flags == DW2102_WRITE_MSG) 62 if (flags == DW210X_WRITE_MSG)
62 memcpy(u8buf, data, len); 63 memcpy(u8buf, data, len);
63 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, 64 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
64 value, index , u8buf, len, 2000); 65 value, index , u8buf, len, 2000);
65 66
66 if (flags == DW2102_READ_MSG) 67 if (flags == DW210X_READ_MSG)
67 memcpy(data, u8buf, len); 68 memcpy(data, u8buf, len);
68 return ret; 69 return ret;
69} 70}
70 71
71/* I2C */ 72/* I2C */
72
73static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 73static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
74 int num) 74 int num)
75{ 75{
@@ -89,10 +89,9 @@ struct dvb_usb_device *d = i2c_get_adapdata(adap);
89 value = msg[0].buf[0];/* register */ 89 value = msg[0].buf[0];/* register */
90 for (i = 0; i < msg[1].len; i++) { 90 for (i = 0; i < msg[1].len; i++) {
91 value = value + i; 91 value = value + i;
92 ret = dw2102_op_rw(d->udev, 0xb5, value, 0, 92 ret = dw210x_op_rw(d->udev, 0xb5, value, 0,
93 buf6, 2, DW2102_READ_MSG); 93 buf6, 2, DW210X_READ_MSG);
94 msg[1].buf[i] = buf6[0]; 94 msg[1].buf[i] = buf6[0];
95
96 } 95 }
97 break; 96 break;
98 case 1: 97 case 1:
@@ -102,8 +101,8 @@ struct dvb_usb_device *d = i2c_get_adapdata(adap);
102 buf6[0] = 0x2a; 101 buf6[0] = 0x2a;
103 buf6[1] = msg[0].buf[0]; 102 buf6[1] = msg[0].buf[0];
104 buf6[2] = msg[0].buf[1]; 103 buf6[2] = msg[0].buf[1];
105 ret = dw2102_op_rw(d->udev, 0xb2, 0, 0, 104 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
106 buf6, 3, DW2102_WRITE_MSG); 105 buf6, 3, DW210X_WRITE_MSG);
107 break; 106 break;
108 case 0x60: 107 case 0x60:
109 if (msg[0].flags == 0) { 108 if (msg[0].flags == 0) {
@@ -115,26 +114,26 @@ struct dvb_usb_device *d = i2c_get_adapdata(adap);
115 buf6[4] = msg[0].buf[1]; 114 buf6[4] = msg[0].buf[1];
116 buf6[5] = msg[0].buf[2]; 115 buf6[5] = msg[0].buf[2];
117 buf6[6] = msg[0].buf[3]; 116 buf6[6] = msg[0].buf[3];
118 ret = dw2102_op_rw(d->udev, 0xb2, 0, 0, 117 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
119 buf6, 7, DW2102_WRITE_MSG); 118 buf6, 7, DW210X_WRITE_MSG);
120 } else { 119 } else {
121 /* read from tuner */ 120 /* read from tuner */
122 ret = dw2102_op_rw(d->udev, 0xb5, 0,0, 121 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
123 buf6, 1, DW2102_READ_MSG); 122 buf6, 1, DW210X_READ_MSG);
124 msg[0].buf[0] = buf6[0]; 123 msg[0].buf[0] = buf6[0];
125 } 124 }
126 break; 125 break;
127 case (DW2102_RC_QUERY): 126 case (DW2102_RC_QUERY):
128 ret = dw2102_op_rw(d->udev, 0xb8, 0, 0, 127 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
129 buf6, 2, DW2102_READ_MSG); 128 buf6, 2, DW210X_READ_MSG);
130 msg[0].buf[0] = buf6[0]; 129 msg[0].buf[0] = buf6[0];
131 msg[0].buf[1] = buf6[1]; 130 msg[0].buf[1] = buf6[1];
132 break; 131 break;
133 case (DW2102_VOLTAGE_CTRL): 132 case (DW2102_VOLTAGE_CTRL):
134 buf6[0] = 0x30; 133 buf6[0] = 0x30;
135 buf6[1] = msg[0].buf[0]; 134 buf6[1] = msg[0].buf[0];
136 ret = dw2102_op_rw(d->udev, 0xb2, 0, 0, 135 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
137 buf6, 2, DW2102_WRITE_MSG); 136 buf6, 2, DW210X_WRITE_MSG);
138 break; 137 break;
139 } 138 }
140 139
@@ -145,6 +144,62 @@ struct dvb_usb_device *d = i2c_get_adapdata(adap);
145 return num; 144 return num;
146} 145}
147 146
147static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
148 struct i2c_msg msg[], int num)
149{
150 struct dvb_usb_device *d = i2c_get_adapdata(adap);
151 int ret = 0;
152 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
153
154 if (!d)
155 return -ENODEV;
156 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
157 return -EAGAIN;
158
159 switch (num) {
160 case 2:
161 /* read si2109 register by number */
162 buf6[0] = 0xd0;
163 buf6[1] = msg[0].len;
164 buf6[2] = msg[0].buf[0];
165 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
166 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
167 /* read si2109 register */
168 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
169 buf6, msg[1].len + 2, DW210X_READ_MSG);
170 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
171
172 break;
173 case 1:
174 switch (msg[0].addr) {
175 case 0x68:
176 /* write to si2109 register */
177 buf6[0] = 0xd0;
178 buf6[1] = msg[0].len;
179 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
180 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
181 msg[0].len + 2, DW210X_WRITE_MSG);
182 break;
183 case(DW2102_RC_QUERY):
184 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
185 buf6, 2, DW210X_READ_MSG);
186 msg[0].buf[0] = buf6[0];
187 msg[0].buf[1] = buf6[1];
188 break;
189 case(DW2102_VOLTAGE_CTRL):
190 buf6[0] = 0x30;
191 buf6[1] = msg[0].buf[0];
192 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
193 buf6, 2, DW210X_WRITE_MSG);
194 break;
195 }
196 break;
197 }
198
199 mutex_unlock(&d->i2c_mutex);
200 return num;
201}
202
148static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 203static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
149{ 204{
150 struct dvb_usb_device *d = i2c_get_adapdata(adap); 205 struct dvb_usb_device *d = i2c_get_adapdata(adap);
@@ -164,11 +219,11 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
164 obuf[0] = 0xaa; 219 obuf[0] = 0xaa;
165 obuf[1] = msg[0].len; 220 obuf[1] = msg[0].len;
166 obuf[2] = msg[0].buf[0]; 221 obuf[2] = msg[0].buf[0];
167 ret = dw2102_op_rw(d->udev, 0xc2, 0, 0, 222 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
168 obuf, msg[0].len + 2, DW2102_WRITE_MSG); 223 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
169 /* second read registers */ 224 /* second read registers */
170 ret = dw2102_op_rw(d->udev, 0xc3, 0xab , 0, 225 ret = dw210x_op_rw(d->udev, 0xc3, 0xab , 0,
171 ibuf, msg[1].len + 2, DW2102_READ_MSG); 226 ibuf, msg[1].len + 2, DW210X_READ_MSG);
172 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 227 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
173 228
174 break; 229 break;
@@ -187,8 +242,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
187 i = 1; 242 i = 1;
188 do { 243 do {
189 memcpy(obuf + 3, msg[0].buf + i, (len > 16 ? 16 : len)); 244 memcpy(obuf + 3, msg[0].buf + i, (len > 16 ? 16 : len));
190 ret = dw2102_op_rw(d->udev, 0xc2, 0, 0, 245 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
191 obuf, (len > 16 ? 16 : len) + 3, DW2102_WRITE_MSG); 246 obuf, (len > 16 ? 16 : len) + 3, DW210X_WRITE_MSG);
192 i += 16; 247 i += 16;
193 len -= 16; 248 len -= 16;
194 } while (len > 0); 249 } while (len > 0);
@@ -198,15 +253,15 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
198 obuf[0] = 0xaa; 253 obuf[0] = 0xaa;
199 obuf[1] = msg[0].len; 254 obuf[1] = msg[0].len;
200 memcpy(obuf + 2, msg[0].buf, msg[0].len); 255 memcpy(obuf + 2, msg[0].buf, msg[0].len);
201 ret = dw2102_op_rw(d->udev, 0xc2, 0, 0, 256 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
202 obuf, msg[0].len + 2, DW2102_WRITE_MSG); 257 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
203 } 258 }
204 break; 259 break;
205 } 260 }
206 case(DW2102_RC_QUERY): { 261 case(DW2102_RC_QUERY): {
207 u8 ibuf[2]; 262 u8 ibuf[2];
208 ret = dw2102_op_rw(d->udev, 0xb8, 0, 0, 263 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
209 ibuf, 2, DW2102_READ_MSG); 264 ibuf, 2, DW210X_READ_MSG);
210 memcpy(msg[0].buf, ibuf , 2); 265 memcpy(msg[0].buf, ibuf , 2);
211 break; 266 break;
212 } 267 }
@@ -214,8 +269,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
214 u8 obuf[2]; 269 u8 obuf[2];
215 obuf[0] = 0x30; 270 obuf[0] = 0x30;
216 obuf[1] = msg[0].buf[0]; 271 obuf[1] = msg[0].buf[0];
217 ret = dw2102_op_rw(d->udev, 0xb2, 0, 0, 272 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
218 obuf, 2, DW2102_WRITE_MSG); 273 obuf, 2, DW210X_WRITE_MSG);
219 break; 274 break;
220 } 275 }
221 } 276 }
@@ -227,29 +282,34 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
227 return num; 282 return num;
228} 283}
229 284
230static u32 dw2102_i2c_func(struct i2c_adapter *adapter) 285static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
231{ 286{
232 return I2C_FUNC_I2C; 287 return I2C_FUNC_I2C;
233} 288}
234 289
235static struct i2c_algorithm dw2102_i2c_algo = { 290static struct i2c_algorithm dw2102_i2c_algo = {
236 .master_xfer = dw2102_i2c_transfer, 291 .master_xfer = dw2102_i2c_transfer,
237 .functionality = dw2102_i2c_func, 292 .functionality = dw210x_i2c_func,
293};
294
295static struct i2c_algorithm dw2102_serit_i2c_algo = {
296 .master_xfer = dw2102_serit_i2c_transfer,
297 .functionality = dw210x_i2c_func,
238}; 298};
239 299
240static struct i2c_algorithm dw2104_i2c_algo = { 300static struct i2c_algorithm dw2104_i2c_algo = {
241 .master_xfer = dw2104_i2c_transfer, 301 .master_xfer = dw2104_i2c_transfer,
242 .functionality = dw2102_i2c_func, 302 .functionality = dw210x_i2c_func,
243}; 303};
244 304
245static int dw2102_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 305static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
246{ 306{
247 int i; 307 int i;
248 u8 ibuf[] = {0, 0}; 308 u8 ibuf[] = {0, 0};
249 u8 eeprom[256], eepromline[16]; 309 u8 eeprom[256], eepromline[16];
250 310
251 for (i = 0; i < 256; i++) { 311 for (i = 0; i < 256; i++) {
252 if (dw2102_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW2102_READ_MSG) < 0) { 312 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
253 err("read eeprom failed."); 313 err("read eeprom failed.");
254 return -1; 314 return -1;
255 } else { 315 } else {
@@ -265,7 +325,7 @@ static int dw2102_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
265 return 0; 325 return 0;
266}; 326};
267 327
268static int dw2102_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 328static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
269{ 329{
270 static u8 command_13v[1] = {0x00}; 330 static u8 command_13v[1] = {0x00};
271 static u8 command_18v[1] = {0x01}; 331 static u8 command_18v[1] = {0x01};
@@ -287,25 +347,46 @@ static struct cx24116_config dw2104_config = {
287 .mpg_clk_pos_pol = 0x01, 347 .mpg_clk_pos_pol = 0x01,
288}; 348};
289 349
350static struct si21xx_config serit_sp1511lhb_config = {
351 .demod_address = 0x68,
352 .min_delay_ms = 100,
353
354};
355
290static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 356static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
291{ 357{
292 if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config, 358 if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config,
293 &d->dev->i2c_adap)) != NULL) { 359 &d->dev->i2c_adap)) != NULL) {
294 d->fe->ops.set_voltage = dw2102_set_voltage; 360 d->fe->ops.set_voltage = dw210x_set_voltage;
295 info("Attached cx24116!\n"); 361 info("Attached cx24116!\n");
296 return 0; 362 return 0;
297 } 363 }
298 return -EIO; 364 return -EIO;
299} 365}
300 366
367static struct dvb_usb_device_properties dw2102_properties;
368
301static int dw2102_frontend_attach(struct dvb_usb_adapter *d) 369static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
302{ 370{
303 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, 371 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
304 &d->dev->i2c_adap); 372 /*dw2102_properties.adapter->tuner_attach = NULL;*/
305 if (d->fe != NULL) { 373 d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
306 d->fe->ops.set_voltage = dw2102_set_voltage; 374 &d->dev->i2c_adap);
307 info("Attached stv0299!\n"); 375 if (d->fe != NULL) {
308 return 0; 376 d->fe->ops.set_voltage = dw210x_set_voltage;
377 info("Attached si21xx!\n");
378 return 0;
379 }
380 }
381 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
382 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
383 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
384 &d->dev->i2c_adap);
385 if (d->fe != NULL) {
386 d->fe->ops.set_voltage = dw210x_set_voltage;
387 info("Attached stv0299!\n");
388 return 0;
389 }
309 } 390 }
310 return -EIO; 391 return -EIO;
311} 392}
@@ -317,7 +398,7 @@ static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
317 return 0; 398 return 0;
318} 399}
319 400
320static struct dvb_usb_rc_key dw2102_rc_keys[] = { 401static struct dvb_usb_rc_key dw210x_rc_keys[] = {
321 { 0xf8, 0x0a, KEY_Q }, /*power*/ 402 { 0xf8, 0x0a, KEY_Q }, /*power*/
322 { 0xf8, 0x0c, KEY_M }, /*mute*/ 403 { 0xf8, 0x0c, KEY_M }, /*mute*/
323 { 0xf8, 0x11, KEY_1 }, 404 { 0xf8, 0x11, KEY_1 },
@@ -356,7 +437,7 @@ static struct dvb_usb_rc_key dw2102_rc_keys[] = {
356 437
357static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 438static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
358{ 439{
359 struct dw2102_state *st = d->priv; 440 struct dw210x_state *st = d->priv;
360 u8 key[2]; 441 u8 key[2];
361 struct i2c_msg msg[] = { 442 struct i2c_msg msg[] = {
362 {.addr = DW2102_RC_QUERY, .flags = I2C_M_RD, .buf = key, 443 {.addr = DW2102_RC_QUERY, .flags = I2C_M_RD, .buf = key,
@@ -366,12 +447,12 @@ static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
366 447
367 *state = REMOTE_NO_KEY_PRESSED; 448 *state = REMOTE_NO_KEY_PRESSED;
368 if (dw2102_i2c_transfer(&d->i2c_adap, msg, 1) == 1) { 449 if (dw2102_i2c_transfer(&d->i2c_adap, msg, 1) == 1) {
369 for (i = 0; i < ARRAY_SIZE(dw2102_rc_keys); i++) { 450 for (i = 0; i < ARRAY_SIZE(dw210x_rc_keys); i++) {
370 if (dw2102_rc_keys[i].data == msg[0].buf[0]) { 451 if (dw210x_rc_keys[i].data == msg[0].buf[0]) {
371 *state = REMOTE_KEY_PRESSED; 452 *state = REMOTE_KEY_PRESSED;
372 *event = dw2102_rc_keys[i].event; 453 *event = dw210x_rc_keys[i].event;
373 st->last_key_pressed = 454 st->last_key_pressed =
374 dw2102_rc_keys[i].event; 455 dw210x_rc_keys[i].event;
375 break; 456 break;
376 } 457 }
377 st->last_key_pressed = 0; 458 st->last_key_pressed = 0;
@@ -418,15 +499,15 @@ static int dw2102_load_firmware(struct usb_device *dev,
418 p = kmalloc(fw->size, GFP_KERNEL); 499 p = kmalloc(fw->size, GFP_KERNEL);
419 reset = 1; 500 reset = 1;
420 /*stop the CPU*/ 501 /*stop the CPU*/
421 dw2102_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW2102_WRITE_MSG); 502 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
422 dw2102_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW2102_WRITE_MSG); 503 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
423 504
424 if (p != NULL) { 505 if (p != NULL) {
425 memcpy(p, fw->data, fw->size); 506 memcpy(p, fw->data, fw->size);
426 for (i = 0; i < fw->size; i += 0x40) { 507 for (i = 0; i < fw->size; i += 0x40) {
427 b = (u8 *) p + i; 508 b = (u8 *) p + i;
428 if (dw2102_op_rw(dev, 0xa0, i, 0, b , 0x40, 509 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
429 DW2102_WRITE_MSG) != 0x40) { 510 DW210X_WRITE_MSG) != 0x40) {
430 err("error while transferring firmware"); 511 err("error while transferring firmware");
431 ret = -EINVAL; 512 ret = -EINVAL;
432 break; 513 break;
@@ -434,13 +515,13 @@ static int dw2102_load_firmware(struct usb_device *dev,
434 } 515 }
435 /* restart the CPU */ 516 /* restart the CPU */
436 reset = 0; 517 reset = 0;
437 if (ret || dw2102_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, 518 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
438 DW2102_WRITE_MSG) != 1) { 519 DW210X_WRITE_MSG) != 1) {
439 err("could not restart the USB controller CPU."); 520 err("could not restart the USB controller CPU.");
440 ret = -EINVAL; 521 ret = -EINVAL;
441 } 522 }
442 if (ret || dw2102_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, 523 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
443 DW2102_WRITE_MSG) != 1) { 524 DW210X_WRITE_MSG) != 1) {
444 err("could not restart the USB controller CPU."); 525 err("could not restart the USB controller CPU.");
445 ret = -EINVAL; 526 ret = -EINVAL;
446 } 527 }
@@ -449,27 +530,32 @@ static int dw2102_load_firmware(struct usb_device *dev,
449 case USB_PID_DW2104: 530 case USB_PID_DW2104:
450 case 0xd650: 531 case 0xd650:
451 reset = 1; 532 reset = 1;
452 dw2102_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, 533 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
453 DW2102_WRITE_MSG); 534 DW210X_WRITE_MSG);
454 reset = 0; 535 reset = 0;
455 dw2102_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 536 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
456 DW2102_WRITE_MSG); 537 DW210X_WRITE_MSG);
457 break; 538 break;
458 case USB_PID_DW2102: 539 case USB_PID_DW2102:
459 dw2102_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 540 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
460 DW2102_WRITE_MSG); 541 DW210X_WRITE_MSG);
461 dw2102_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 542 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
462 DW2102_READ_MSG); 543 DW210X_READ_MSG);
544 /* check STV0299 frontend */
545 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
546 DW210X_READ_MSG);
547 if (reset16[0] == 0xa1)
548 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
463 break; 549 break;
464 case 0x2101: 550 case 0x2101:
465 dw2102_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, 551 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
466 DW2102_READ_MSG); 552 DW210X_READ_MSG);
467 dw2102_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 553 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
468 DW2102_READ_MSG); 554 DW210X_READ_MSG);
469 dw2102_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 555 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
470 DW2102_READ_MSG); 556 DW210X_READ_MSG);
471 dw2102_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 557 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
472 DW2102_READ_MSG); 558 DW210X_READ_MSG);
473 break; 559 break;
474 } 560 }
475 msleep(100); 561 msleep(100);
@@ -482,12 +568,12 @@ static struct dvb_usb_device_properties dw2102_properties = {
482 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 568 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
483 .usb_ctrl = DEVICE_SPECIFIC, 569 .usb_ctrl = DEVICE_SPECIFIC,
484 .firmware = "dvb-usb-dw2102.fw", 570 .firmware = "dvb-usb-dw2102.fw",
485 .size_of_priv = sizeof(struct dw2102_state), 571 .size_of_priv = sizeof(struct dw210x_state),
486 .no_reconnect = 1, 572 .no_reconnect = 1,
487 573
488 .i2c_algo = &dw2102_i2c_algo, 574 .i2c_algo = &dw2102_serit_i2c_algo,
489 .rc_key_map = dw2102_rc_keys, 575 .rc_key_map = dw210x_rc_keys,
490 .rc_key_map_size = ARRAY_SIZE(dw2102_rc_keys), 576 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
491 .rc_interval = 150, 577 .rc_interval = 150,
492 .rc_query = dw2102_rc_query, 578 .rc_query = dw2102_rc_query,
493 579
@@ -495,7 +581,7 @@ static struct dvb_usb_device_properties dw2102_properties = {
495 /* parameter for the MPEG2-data transfer */ 581 /* parameter for the MPEG2-data transfer */
496 .num_adapters = 1, 582 .num_adapters = 1,
497 .download_firmware = dw2102_load_firmware, 583 .download_firmware = dw2102_load_firmware,
498 .read_mac_address = dw2102_read_mac_address, 584 .read_mac_address = dw210x_read_mac_address,
499 .adapter = { 585 .adapter = {
500 { 586 {
501 .frontend_attach = dw2102_frontend_attach, 587 .frontend_attach = dw2102_frontend_attach,
@@ -530,12 +616,12 @@ static struct dvb_usb_device_properties dw2104_properties = {
530 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 616 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
531 .usb_ctrl = DEVICE_SPECIFIC, 617 .usb_ctrl = DEVICE_SPECIFIC,
532 .firmware = "dvb-usb-dw2104.fw", 618 .firmware = "dvb-usb-dw2104.fw",
533 .size_of_priv = sizeof(struct dw2102_state), 619 .size_of_priv = sizeof(struct dw210x_state),
534 .no_reconnect = 1, 620 .no_reconnect = 1,
535 621
536 .i2c_algo = &dw2104_i2c_algo, 622 .i2c_algo = &dw2104_i2c_algo,
537 .rc_key_map = dw2102_rc_keys, 623 .rc_key_map = dw210x_rc_keys,
538 .rc_key_map_size = ARRAY_SIZE(dw2102_rc_keys), 624 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys),
539 .rc_interval = 150, 625 .rc_interval = 150,
540 .rc_query = dw2102_rc_query, 626 .rc_query = dw2102_rc_query,
541 627
@@ -543,7 +629,7 @@ static struct dvb_usb_device_properties dw2104_properties = {
543 /* parameter for the MPEG2-data transfer */ 629 /* parameter for the MPEG2-data transfer */
544 .num_adapters = 1, 630 .num_adapters = 1,
545 .download_firmware = dw2102_load_firmware, 631 .download_firmware = dw2102_load_firmware,
546 .read_mac_address = dw2102_read_mac_address, 632 .read_mac_address = dw210x_read_mac_address,
547 .adapter = { 633 .adapter = {
548 { 634 {
549 .frontend_attach = dw2104_frontend_attach, 635 .frontend_attach = dw2104_frontend_attach,