Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (9176): Add support for DvbWorld USB cards with STV0288 demodulator.

Add support for DvbWorld USB cards with STV0288 demodulator.
Those cards use Earda EDS-1547 tuner.

Signed-off-by: Igor M. Liplianin <liplianin@me.by>
Signed-off-by: Steven Toth <stoth@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Igor M. Liplianin and committed by
Mauro Carvalho Chehab
8a4949b7 ceab2fe8

+254 -4
+2
drivers/media/dvb/dvb-usb/Kconfig
··· 253 253 depends on DVB_USB 254 254 select DVB_PLL if !DVB_FE_CUSTOMISE 255 255 select DVB_STV0299 if !DVB_FE_CUSTOMISE 256 + select DVB_STV0288 if !DVB_FE_CUSTOMISE 257 + select DVB_STB6000 if !DVB_FE_CUSTOMISE 256 258 select DVB_CX24116 if !DVB_FE_CUSTOMISE 257 259 select DVB_SI21XX if !DVB_FE_CUSTOMISE 258 260 help
+119 -4
drivers/media/dvb/dvb-usb/dw2102.c
··· 14 14 #include "si21xx.h" 15 15 #include "stv0299.h" 16 16 #include "z0194a.h" 17 + #include "stv0288.h" 18 + #include "stb6000.h" 19 + #include "eds1547.h" 17 20 #include "cx24116.h" 18 21 19 22 #ifndef USB_PID_DW2102 ··· 202 199 mutex_unlock(&d->i2c_mutex); 203 200 return num; 204 201 } 202 + static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 203 + { 204 + struct dvb_usb_device *d = i2c_get_adapdata(adap); 205 + int ret = 0; 206 + 207 + if (!d) 208 + return -ENODEV; 209 + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 210 + return -EAGAIN; 211 + 212 + switch (num) { 213 + case 2: { 214 + /* read */ 215 + /* first write first register number */ 216 + u8 ibuf [msg[1].len + 2], obuf[3]; 217 + obuf[0] = 0xd0; 218 + obuf[1] = msg[0].len; 219 + obuf[2] = msg[0].buf[0]; 220 + ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 221 + obuf, msg[0].len + 2, DW210X_WRITE_MSG); 222 + /* second read registers */ 223 + ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, 224 + ibuf, msg[1].len + 2, DW210X_READ_MSG); 225 + memcpy(msg[1].buf, ibuf + 2, msg[1].len); 226 + 227 + break; 228 + } 229 + case 1: 230 + switch (msg[0].addr) { 231 + case 0x68: { 232 + /* write to register */ 233 + u8 obuf[msg[0].len + 2]; 234 + obuf[0] = 0xd0; 235 + obuf[1] = msg[0].len; 236 + memcpy(obuf + 2, msg[0].buf, msg[0].len); 237 + ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 238 + obuf, msg[0].len + 2, DW210X_WRITE_MSG); 239 + break; 240 + } 241 + case 0x61: { 242 + /* write to tuner */ 243 + u8 obuf[msg[0].len + 2]; 244 + obuf[0] = 0xc2; 245 + obuf[1] = msg[0].len; 246 + memcpy(obuf + 2, msg[0].buf, msg[0].len); 247 + ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 248 + obuf, msg[0].len + 2, DW210X_WRITE_MSG); 249 + break; 250 + } 251 + case(DW2102_RC_QUERY): { 252 + u8 ibuf[2]; 253 + ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 254 + ibuf, 2, DW210X_READ_MSG); 255 + memcpy(msg[0].buf, ibuf , 2); 256 + break; 257 + } 258 + case(DW2102_VOLTAGE_CTRL): { 259 + u8 obuf[2]; 260 + obuf[0] = 0x30; 261 + obuf[1] = msg[0].buf[0]; 262 + ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 263 + obuf, 2, DW210X_WRITE_MSG); 264 + break; 265 + } 266 + } 267 + 268 + break; 269 + } 270 + 271 + mutex_unlock(&d->i2c_mutex); 272 + return num; 273 + } 205 274 206 275 static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 207 276 { ··· 372 297 .functionality = dw210x_i2c_func, 373 298 }; 374 299 300 + static struct i2c_algorithm dw2102_earda_i2c_algo = { 301 + .master_xfer = dw2102_earda_i2c_transfer, 302 + .functionality = dw210x_i2c_func, 303 + }; 304 + 375 305 static struct i2c_algorithm dw2104_i2c_algo = { 376 306 .master_xfer = dw2104_i2c_transfer, 377 307 .functionality = dw210x_i2c_func, ··· 458 378 return 0; 459 379 } 460 380 } 381 + if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { 382 + /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ 383 + d->fe = dvb_attach(stv0288_attach, &earda_config, 384 + &d->dev->i2c_adap); 385 + if (d->fe != NULL) { 386 + d->fe->ops.set_voltage = dw210x_set_voltage; 387 + info("Attached stv0288!\n"); 388 + return 0; 389 + } 390 + } 391 + 461 392 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { 462 393 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ 463 394 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, ··· 486 395 { 487 396 dvb_attach(dvb_pll_attach, adap->fe, 0x60, 488 397 &adap->dev->i2c_adap, DVB_PLL_OPERA1); 398 + return 0; 399 + } 400 + 401 + static int dw2102_earda_tuner_attach(struct dvb_usb_adapter *adap) 402 + { 403 + dvb_attach(stb6000_attach, adap->fe, 0x61, 404 + &adap->dev->i2c_adap); 405 + 489 406 return 0; 490 407 } 491 408 ··· 577 478 u8 *b, *p; 578 479 int ret = 0, i; 579 480 u8 reset; 580 - u8 reset16 [] = {0, 0, 0, 0, 0, 0, 0}; 481 + u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; 581 482 const struct firmware *fw; 582 483 const char *filename = "dvb-usb-dw2101.fw"; 583 484 switch (dev->descriptor.idProduct) { ··· 643 544 /* check STV0299 frontend */ 644 545 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, 645 546 DW210X_READ_MSG); 646 - if (reset16[0] == 0xa1) 547 + if (reset16[0] == 0xa1) { 647 548 dw2102_properties.i2c_algo = &dw2102_i2c_algo; 648 - break; 549 + dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach; 550 + break; 551 + } else { 552 + /* check STV0288 frontend */ 553 + reset16[0] = 0xd0; 554 + reset16[1] = 1; 555 + reset16[2] = 0; 556 + dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, 557 + DW210X_WRITE_MSG); 558 + dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, 559 + DW210X_READ_MSG); 560 + if (reset16[2] == 0x11) { 561 + dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; 562 + dw2102_properties.adapter->tuner_attach = &dw2102_earda_tuner_attach; 563 + break; 564 + } 565 + } 649 566 case 0x2101: 650 567 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, 651 568 DW210X_READ_MSG); ··· 701 586 { 702 587 .frontend_attach = dw2102_frontend_attach, 703 588 .streaming_ctrl = NULL, 704 - .tuner_attach = dw2102_tuner_attach, 589 + .tuner_attach = NULL, 705 590 .stream = { 706 591 .type = USB_BULK, 707 592 .count = 8,
+133
drivers/media/dvb/frontends/eds1547.h
··· 1 + /* eds1547.h Earda EDS-1547 tuner support 2 + * 3 + * Copyright (C) 2008 Igor M. Liplianin (liplianin@me.by) 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License as published by the 7 + * Free Software Foundation, version 2. 8 + * 9 + * see Documentation/dvb/README.dvb-usb for more information 10 + */ 11 + 12 + #ifndef EDS1547 13 + #define EDS1547 14 + 15 + static u8 stv0288_earda_inittab[] = { 16 + 0x01, 0x57, 17 + 0x02, 0x20, 18 + 0x03, 0x8e, 19 + 0x04, 0x8e, 20 + 0x05, 0x12, 21 + 0x06, 0x00, 22 + 0x07, 0x00, 23 + 0x09, 0x00, 24 + 0x0a, 0x04, 25 + 0x0b, 0x00, 26 + 0x0c, 0x00, 27 + 0x0d, 0x00, 28 + 0x0e, 0xd4, 29 + 0x0f, 0x30, 30 + 0x11, 0x44, 31 + 0x12, 0x03, 32 + 0x13, 0x48, 33 + 0x14, 0x84, 34 + 0x15, 0x45, 35 + 0x16, 0xb7, 36 + 0x17, 0x9c, 37 + 0x18, 0x00, 38 + 0x19, 0xa6, 39 + 0x1a, 0x88, 40 + 0x1b, 0x8f, 41 + 0x1c, 0xf0, 42 + 0x20, 0x0b, 43 + 0x21, 0x54, 44 + 0x22, 0x00, 45 + 0x23, 0x00, 46 + 0x2b, 0xff, 47 + 0x2c, 0xf7, 48 + 0x30, 0x00, 49 + 0x31, 0x1e, 50 + 0x32, 0x14, 51 + 0x33, 0x0f, 52 + 0x34, 0x09, 53 + 0x35, 0x0c, 54 + 0x36, 0x05, 55 + 0x37, 0x2f, 56 + 0x38, 0x16, 57 + 0x39, 0xbd, 58 + 0x3a, 0x00, 59 + 0x3b, 0x13, 60 + 0x3c, 0x11, 61 + 0x3d, 0x30, 62 + 0x40, 0x63, 63 + 0x41, 0x04, 64 + 0x42, 0x60, 65 + 0x43, 0x00, 66 + 0x44, 0x00, 67 + 0x45, 0x00, 68 + 0x46, 0x00, 69 + 0x47, 0x00, 70 + 0x4a, 0x00, 71 + 0x50, 0x10, 72 + 0x51, 0x36, 73 + 0x52, 0x09, 74 + 0x53, 0x94, 75 + 0x54, 0x62, 76 + 0x55, 0x29, 77 + 0x56, 0x64, 78 + 0x57, 0x2b, 79 + 0x58, 0x54, 80 + 0x59, 0x86, 81 + 0x5a, 0x00, 82 + 0x5b, 0x9b, 83 + 0x5c, 0x08, 84 + 0x5d, 0x7f, 85 + 0x5e, 0x00, 86 + 0x5f, 0xff, 87 + 0x70, 0x00, 88 + 0x71, 0x00, 89 + 0x72, 0x00, 90 + 0x74, 0x00, 91 + 0x75, 0x00, 92 + 0x76, 0x00, 93 + 0x81, 0x00, 94 + 0x82, 0x3f, 95 + 0x83, 0x3f, 96 + 0x84, 0x00, 97 + 0x85, 0x00, 98 + 0x88, 0x00, 99 + 0x89, 0x00, 100 + 0x8a, 0x00, 101 + 0x8b, 0x00, 102 + 0x8c, 0x00, 103 + 0x90, 0x00, 104 + 0x91, 0x00, 105 + 0x92, 0x00, 106 + 0x93, 0x00, 107 + 0x94, 0x1c, 108 + 0x97, 0x00, 109 + 0xa0, 0x48, 110 + 0xa1, 0x00, 111 + 0xb0, 0xb8, 112 + 0xb1, 0x3a, 113 + 0xb2, 0x10, 114 + 0xb3, 0x82, 115 + 0xb4, 0x80, 116 + 0xb5, 0x82, 117 + 0xb6, 0x82, 118 + 0xb7, 0x82, 119 + 0xb8, 0x20, 120 + 0xb9, 0x00, 121 + 0xf0, 0x00, 122 + 0xf1, 0x00, 123 + 0xf2, 0xc0, 124 + 0xff,0xff, 125 + }; 126 + 127 + static struct stv0288_config earda_config = { 128 + .demod_address = 0x68, 129 + .min_delay_ms = 100, 130 + .inittab = stv0288_earda_inittab, 131 + }; 132 + 133 + #endif