diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb/anysee.c')
| -rw-r--r-- | drivers/media/dvb/dvb-usb/anysee.c | 726 |
1 files changed, 554 insertions, 172 deletions
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c index 4685259e1614..7c327b54308e 100644 --- a/drivers/media/dvb/dvb-usb/anysee.c +++ b/drivers/media/dvb/dvb-usb/anysee.c | |||
| @@ -36,6 +36,11 @@ | |||
| 36 | #include "mt352.h" | 36 | #include "mt352.h" |
| 37 | #include "mt352_priv.h" | 37 | #include "mt352_priv.h" |
| 38 | #include "zl10353.h" | 38 | #include "zl10353.h" |
| 39 | #include "tda18212.h" | ||
| 40 | #include "cx24116.h" | ||
| 41 | #include "stv0900.h" | ||
| 42 | #include "stv6110.h" | ||
| 43 | #include "isl6423.h" | ||
| 39 | 44 | ||
| 40 | /* debug */ | 45 | /* debug */ |
| 41 | static int dvb_usb_anysee_debug; | 46 | static int dvb_usb_anysee_debug; |
| @@ -55,8 +60,6 @@ static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, | |||
| 55 | int act_len, ret; | 60 | int act_len, ret; |
| 56 | u8 buf[64]; | 61 | u8 buf[64]; |
| 57 | 62 | ||
| 58 | if (slen > sizeof(buf)) | ||
| 59 | slen = sizeof(buf); | ||
| 60 | memcpy(&buf[0], sbuf, slen); | 63 | memcpy(&buf[0], sbuf, slen); |
| 61 | buf[60] = state->seq++; | 64 | buf[60] = state->seq++; |
| 62 | 65 | ||
| @@ -105,6 +108,27 @@ static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val) | |||
| 105 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); | 108 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); |
| 106 | } | 109 | } |
| 107 | 110 | ||
| 111 | /* write single register with mask */ | ||
| 112 | static int anysee_wr_reg_mask(struct dvb_usb_device *d, u16 reg, u8 val, | ||
| 113 | u8 mask) | ||
| 114 | { | ||
| 115 | int ret; | ||
| 116 | u8 tmp; | ||
| 117 | |||
| 118 | /* no need for read if whole reg is written */ | ||
| 119 | if (mask != 0xff) { | ||
| 120 | ret = anysee_read_reg(d, reg, &tmp); | ||
| 121 | if (ret) | ||
| 122 | return ret; | ||
| 123 | |||
| 124 | val &= mask; | ||
| 125 | tmp &= ~mask; | ||
| 126 | val |= tmp; | ||
| 127 | } | ||
| 128 | |||
| 129 | return anysee_write_reg(d, reg, val); | ||
| 130 | } | ||
| 131 | |||
| 108 | static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id) | 132 | static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id) |
| 109 | { | 133 | { |
| 110 | u8 buf[] = {CMD_GET_HW_INFO}; | 134 | u8 buf[] = {CMD_GET_HW_INFO}; |
| @@ -154,30 +178,37 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, | |||
| 154 | { | 178 | { |
| 155 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | 179 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 156 | int ret = 0, inc, i = 0; | 180 | int ret = 0, inc, i = 0; |
| 181 | u8 buf[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */ | ||
| 157 | 182 | ||
| 158 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | 183 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 159 | return -EAGAIN; | 184 | return -EAGAIN; |
| 160 | 185 | ||
| 161 | while (i < num) { | 186 | while (i < num) { |
| 162 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { | 187 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { |
| 163 | u8 buf[6]; | 188 | if (msg[i].len > 2 || msg[i+1].len > 60) { |
| 189 | ret = -EOPNOTSUPP; | ||
| 190 | break; | ||
| 191 | } | ||
| 164 | buf[0] = CMD_I2C_READ; | 192 | buf[0] = CMD_I2C_READ; |
| 165 | buf[1] = msg[i].addr + 1; | 193 | buf[1] = (msg[i].addr << 1) | 0x01; |
| 166 | buf[2] = msg[i].buf[0]; | 194 | buf[2] = msg[i].buf[0]; |
| 167 | buf[3] = 0x00; | 195 | buf[3] = msg[i].buf[1]; |
| 168 | buf[4] = 0x00; | 196 | buf[4] = msg[i].len-1; |
| 169 | buf[5] = 0x01; | 197 | buf[5] = msg[i+1].len; |
| 170 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), msg[i+1].buf, | 198 | ret = anysee_ctrl_msg(d, buf, 6, msg[i+1].buf, |
| 171 | msg[i+1].len); | 199 | msg[i+1].len); |
| 172 | inc = 2; | 200 | inc = 2; |
| 173 | } else { | 201 | } else { |
| 174 | u8 buf[4+msg[i].len]; | 202 | if (msg[i].len > 48) { |
| 203 | ret = -EOPNOTSUPP; | ||
| 204 | break; | ||
| 205 | } | ||
| 175 | buf[0] = CMD_I2C_WRITE; | 206 | buf[0] = CMD_I2C_WRITE; |
| 176 | buf[1] = msg[i].addr; | 207 | buf[1] = (msg[i].addr << 1); |
| 177 | buf[2] = msg[i].len; | 208 | buf[2] = msg[i].len; |
| 178 | buf[3] = 0x01; | 209 | buf[3] = 0x01; |
| 179 | memcpy(&buf[4], msg[i].buf, msg[i].len); | 210 | memcpy(&buf[4], msg[i].buf, msg[i].len); |
| 180 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); | 211 | ret = anysee_ctrl_msg(d, buf, 4 + msg[i].len, NULL, 0); |
| 181 | inc = 1; | 212 | inc = 1; |
| 182 | } | 213 | } |
| 183 | if (ret) | 214 | if (ret) |
| @@ -224,7 +255,7 @@ static int anysee_mt352_demod_init(struct dvb_frontend *fe) | |||
| 224 | 255 | ||
| 225 | /* Callbacks for DVB USB */ | 256 | /* Callbacks for DVB USB */ |
| 226 | static struct tda10023_config anysee_tda10023_config = { | 257 | static struct tda10023_config anysee_tda10023_config = { |
| 227 | .demod_address = 0x1a, | 258 | .demod_address = (0x1a >> 1), |
| 228 | .invert = 0, | 259 | .invert = 0, |
| 229 | .xtal = 16000000, | 260 | .xtal = 16000000, |
| 230 | .pll_m = 11, | 261 | .pll_m = 11, |
| @@ -235,217 +266,567 @@ static struct tda10023_config anysee_tda10023_config = { | |||
| 235 | }; | 266 | }; |
| 236 | 267 | ||
| 237 | static struct mt352_config anysee_mt352_config = { | 268 | static struct mt352_config anysee_mt352_config = { |
| 238 | .demod_address = 0x1e, | 269 | .demod_address = (0x1e >> 1), |
| 239 | .demod_init = anysee_mt352_demod_init, | 270 | .demod_init = anysee_mt352_demod_init, |
| 240 | }; | 271 | }; |
| 241 | 272 | ||
| 242 | static struct zl10353_config anysee_zl10353_config = { | 273 | static struct zl10353_config anysee_zl10353_config = { |
| 243 | .demod_address = 0x1e, | 274 | .demod_address = (0x1e >> 1), |
| 244 | .parallel_ts = 1, | 275 | .parallel_ts = 1, |
| 245 | }; | 276 | }; |
| 246 | 277 | ||
| 278 | static struct zl10353_config anysee_zl10353_tda18212_config2 = { | ||
| 279 | .demod_address = (0x1e >> 1), | ||
| 280 | .parallel_ts = 1, | ||
| 281 | .disable_i2c_gate_ctrl = 1, | ||
| 282 | .no_tuner = 1, | ||
| 283 | .if2 = 41500, | ||
| 284 | }; | ||
| 285 | |||
| 286 | static struct zl10353_config anysee_zl10353_tda18212_config = { | ||
| 287 | .demod_address = (0x18 >> 1), | ||
| 288 | .parallel_ts = 1, | ||
| 289 | .disable_i2c_gate_ctrl = 1, | ||
| 290 | .no_tuner = 1, | ||
| 291 | .if2 = 41500, | ||
| 292 | }; | ||
| 293 | |||
| 294 | static struct tda10023_config anysee_tda10023_tda18212_config = { | ||
| 295 | .demod_address = (0x1a >> 1), | ||
| 296 | .xtal = 16000000, | ||
| 297 | .pll_m = 12, | ||
| 298 | .pll_p = 3, | ||
| 299 | .pll_n = 1, | ||
| 300 | .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_C, | ||
| 301 | .deltaf = 0xba02, | ||
| 302 | }; | ||
| 303 | |||
| 304 | static struct tda18212_config anysee_tda18212_config = { | ||
| 305 | .i2c_address = (0xc0 >> 1), | ||
| 306 | .if_dvbt_6 = 4150, | ||
| 307 | .if_dvbt_7 = 4150, | ||
| 308 | .if_dvbt_8 = 4150, | ||
| 309 | .if_dvbc = 5000, | ||
| 310 | }; | ||
| 311 | |||
| 312 | static struct cx24116_config anysee_cx24116_config = { | ||
| 313 | .demod_address = (0xaa >> 1), | ||
| 314 | .mpg_clk_pos_pol = 0x00, | ||
| 315 | .i2c_wr_max = 48, | ||
| 316 | }; | ||
| 317 | |||
| 318 | static struct stv0900_config anysee_stv0900_config = { | ||
| 319 | .demod_address = (0xd0 >> 1), | ||
| 320 | .demod_mode = 0, | ||
| 321 | .xtal = 8000000, | ||
| 322 | .clkmode = 3, | ||
| 323 | .diseqc_mode = 2, | ||
| 324 | .tun1_maddress = 0, | ||
| 325 | .tun1_adc = 1, /* 1 Vpp */ | ||
| 326 | .path1_mode = 3, | ||
| 327 | }; | ||
| 328 | |||
| 329 | static struct stv6110_config anysee_stv6110_config = { | ||
| 330 | .i2c_address = (0xc0 >> 1), | ||
| 331 | .mclk = 16000000, | ||
| 332 | .clk_div = 1, | ||
| 333 | }; | ||
| 334 | |||
| 335 | static struct isl6423_config anysee_isl6423_config = { | ||
| 336 | .current_max = SEC_CURRENT_800m, | ||
| 337 | .curlim = SEC_CURRENT_LIM_OFF, | ||
| 338 | .mod_extern = 1, | ||
| 339 | .addr = (0x10 >> 1), | ||
| 340 | }; | ||
| 341 | |||
| 342 | /* | ||
| 343 | * New USB device strings: Mfr=1, Product=2, SerialNumber=0 | ||
| 344 | * Manufacturer: AMT.CO.KR | ||
| 345 | * | ||
| 346 | * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=???????? | ||
| 347 | * PCB: ? | ||
| 348 | * parts: DNOS404ZH102A(MT352, DTT7579(?)) | ||
| 349 | * | ||
| 350 | * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=???????? | ||
| 351 | * PCB: ? | ||
| 352 | * parts: DNOS404ZH103A(ZL10353, DTT7579(?)) | ||
| 353 | * | ||
| 354 | * E30 Plus VID=04b4 PID=861f HW=6 FW=1.0 "anysee" | ||
| 355 | * PCB: 507CD (rev1.1) | ||
| 356 | * parts: DNOS404ZH103A(ZL10353, DTT7579(?)), CST56I01 | ||
| 357 | * OEA=80 OEB=00 OEC=00 OED=ff OEF=fe | ||
| 358 | * IOA=4f IOB=ff IOC=00 IOD=06 IOF=01 | ||
| 359 | * IOD[0] ZL10353 1=enabled | ||
| 360 | * IOA[7] TS 0=enabled | ||
| 361 | * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not) | ||
| 362 | * | ||
| 363 | * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)" | ||
| 364 | * PCB: 507DC (rev0.2) | ||
| 365 | * parts: TDA10023, DTOS403IH102B TM, CST56I01 | ||
| 366 | * OEA=80 OEB=00 OEC=00 OED=ff OEF=fe | ||
| 367 | * IOA=4f IOB=ff IOC=00 IOD=26 IOF=01 | ||
| 368 | * IOD[0] TDA10023 1=enabled | ||
| 369 | * | ||
| 370 | * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)" | ||
| 371 | * PCB: 507SI (rev2.1) | ||
| 372 | * parts: BS2N10WCC01(CX24116, CX24118), ISL6423, TDA8024 | ||
| 373 | * OEA=80 OEB=00 OEC=ff OED=ff OEF=fe | ||
| 374 | * IOA=4d IOB=ff IOC=00 IOD=26 IOF=01 | ||
| 375 | * IOD[0] CX24116 1=enabled | ||
| 376 | * | ||
| 377 | * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)" | ||
| 378 | * PCB: 507FA (rev0.4) | ||
| 379 | * parts: TDA10023, DTOS403IH102B TM, TDA8024 | ||
| 380 | * OEA=80 OEB=00 OEC=ff OED=ff OEF=ff | ||
| 381 | * IOA=4d IOB=ff IOC=00 IOD=00 IOF=c0 | ||
| 382 | * IOD[5] TDA10023 1=enabled | ||
| 383 | * IOE[0] tuner 1=enabled | ||
| 384 | * | ||
| 385 | * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)" | ||
| 386 | * PCB: 507FA (rev1.1) | ||
| 387 | * parts: ZL10353, TDA10023, DTOS403IH102B TM, TDA8024 | ||
| 388 | * OEA=80 OEB=00 OEC=ff OED=ff OEF=ff | ||
| 389 | * IOA=4d IOB=ff IOC=00 IOD=00 IOF=c0 | ||
| 390 | * DVB-C: | ||
| 391 | * IOD[5] TDA10023 1=enabled | ||
| 392 | * IOE[0] tuner 1=enabled | ||
| 393 | * DVB-T: | ||
| 394 | * IOD[0] ZL10353 1=enabled | ||
| 395 | * IOE[0] tuner 0=enabled | ||
| 396 | * tuner is behind ZL10353 I2C-gate | ||
| 397 | * | ||
| 398 | * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)" | ||
| 399 | * PCB: 508TC (rev0.6) | ||
| 400 | * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212) | ||
| 401 | * OEA=80 OEB=00 OEC=03 OED=f7 OEF=ff | ||
| 402 | * IOA=4d IOB=00 IOC=cc IOD=48 IOF=e4 | ||
| 403 | * IOA[7] TS 1=enabled | ||
| 404 | * IOE[4] TDA18212 1=enabled | ||
| 405 | * DVB-C: | ||
| 406 | * IOD[6] ZL10353 0=disabled | ||
| 407 | * IOD[5] TDA10023 1=enabled | ||
| 408 | * IOE[0] IF 1=enabled | ||
| 409 | * DVB-T: | ||
| 410 | * IOD[5] TDA10023 0=disabled | ||
| 411 | * IOD[6] ZL10353 1=enabled | ||
| 412 | * IOE[0] IF 0=enabled | ||
| 413 | * | ||
| 414 | * E7 S2 VID=1c73 PID=861f HW=19 FW=0.4 AMTCI=0.5 "anysee-E7S2(LP)" | ||
| 415 | * PCB: 508S2 (rev0.7) | ||
| 416 | * parts: DNBU10512IST(STV0903, STV6110), ISL6423 | ||
| 417 | * OEA=80 OEB=00 OEC=03 OED=f7 OEF=ff | ||
| 418 | * IOA=4d IOB=00 IOC=c4 IOD=08 IOF=e4 | ||
| 419 | * IOA[7] TS 1=enabled | ||
| 420 | * IOE[5] STV0903 1=enabled | ||
| 421 | * | ||
| 422 | */ | ||
| 423 | |||
| 247 | static int anysee_frontend_attach(struct dvb_usb_adapter *adap) | 424 | static int anysee_frontend_attach(struct dvb_usb_adapter *adap) |
| 248 | { | 425 | { |
| 249 | int ret; | 426 | int ret; |
| 250 | struct anysee_state *state = adap->dev->priv; | 427 | struct anysee_state *state = adap->dev->priv; |
| 251 | u8 hw_info[3]; | 428 | u8 hw_info[3]; |
| 252 | u8 io_d; /* IO port D */ | 429 | u8 tmp; |
| 430 | struct i2c_msg msg[2] = { | ||
| 431 | { | ||
| 432 | .addr = anysee_tda18212_config.i2c_address, | ||
| 433 | .flags = 0, | ||
| 434 | .len = 1, | ||
| 435 | .buf = "\x00", | ||
| 436 | }, { | ||
| 437 | .addr = anysee_tda18212_config.i2c_address, | ||
| 438 | .flags = I2C_M_RD, | ||
| 439 | .len = 1, | ||
| 440 | .buf = &tmp, | ||
| 441 | } | ||
| 442 | }; | ||
| 253 | 443 | ||
| 254 | /* check which hardware we have | 444 | /* Check which hardware we have. |
| 255 | We must do this call two times to get reliable values (hw bug). */ | 445 | * We must do this call two times to get reliable values (hw bug). |
| 446 | */ | ||
| 256 | ret = anysee_get_hw_info(adap->dev, hw_info); | 447 | ret = anysee_get_hw_info(adap->dev, hw_info); |
| 257 | if (ret) | 448 | if (ret) |
| 258 | return ret; | 449 | goto error; |
| 450 | |||
| 259 | ret = anysee_get_hw_info(adap->dev, hw_info); | 451 | ret = anysee_get_hw_info(adap->dev, hw_info); |
| 260 | if (ret) | 452 | if (ret) |
| 261 | return ret; | 453 | goto error; |
| 262 | 454 | ||
| 263 | /* Meaning of these info bytes are guessed. */ | 455 | /* Meaning of these info bytes are guessed. */ |
| 264 | info("firmware version:%d.%d.%d hardware id:%d", | 456 | info("firmware version:%d.%d hardware id:%d", |
| 265 | 0, hw_info[1], hw_info[2], hw_info[0]); | 457 | hw_info[1], hw_info[2], hw_info[0]); |
| 266 | 458 | ||
| 267 | ret = anysee_read_reg(adap->dev, 0xb0, &io_d); /* IO port D */ | 459 | state->hw = hw_info[0]; |
| 268 | if (ret) | ||
| 269 | return ret; | ||
| 270 | deb_info("%s: IO port D:%02x\n", __func__, io_d); | ||
| 271 | |||
| 272 | /* Select demod using trial and error method. */ | ||
| 273 | |||
| 274 | /* Try to attach demodulator in following order: | ||
| 275 | model demod hw firmware | ||
| 276 | 1. E30 MT352 02 0.2.1 | ||
| 277 | 2. E30 ZL10353 02 0.2.1 | ||
| 278 | 3. E30 Combo ZL10353 0f 0.1.2 DVB-T/C combo | ||
| 279 | 4. E30 Plus ZL10353 06 0.1.0 | ||
| 280 | 5. E30C Plus TDA10023 0a 0.1.0 rev 0.2 | ||
| 281 | E30C Plus TDA10023 0f 0.1.2 rev 0.4 | ||
| 282 | E30 Combo TDA10023 0f 0.1.2 DVB-T/C combo | ||
| 283 | */ | ||
| 284 | |||
| 285 | /* Zarlink MT352 DVB-T demod inside of Samsung DNOS404ZH102A NIM */ | ||
| 286 | adap->fe = dvb_attach(mt352_attach, &anysee_mt352_config, | ||
| 287 | &adap->dev->i2c_adap); | ||
| 288 | if (adap->fe != NULL) { | ||
| 289 | state->tuner = DVB_PLL_THOMSON_DTT7579; | ||
| 290 | return 0; | ||
| 291 | } | ||
| 292 | 460 | ||
| 293 | /* Zarlink ZL10353 DVB-T demod inside of Samsung DNOS404ZH103A NIM */ | 461 | switch (state->hw) { |
| 294 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, | 462 | case ANYSEE_HW_02: /* 2 */ |
| 295 | &adap->dev->i2c_adap); | 463 | /* E30 */ |
| 296 | if (adap->fe != NULL) { | ||
| 297 | state->tuner = DVB_PLL_THOMSON_DTT7579; | ||
| 298 | return 0; | ||
| 299 | } | ||
| 300 | 464 | ||
| 301 | /* for E30 Combo Plus DVB-T demodulator */ | 465 | /* attach demod */ |
| 302 | if (dvb_usb_anysee_delsys) { | 466 | adap->fe = dvb_attach(mt352_attach, &anysee_mt352_config, |
| 303 | ret = anysee_write_reg(adap->dev, 0xb0, 0x01); | 467 | &adap->dev->i2c_adap); |
| 468 | if (adap->fe) | ||
| 469 | break; | ||
| 470 | |||
| 471 | /* attach demod */ | ||
| 472 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, | ||
| 473 | &adap->dev->i2c_adap); | ||
| 474 | |||
| 475 | break; | ||
| 476 | case ANYSEE_HW_507CD: /* 6 */ | ||
| 477 | /* E30 Plus */ | ||
| 478 | |||
| 479 | /* enable DVB-T demod on IOD[0] */ | ||
| 480 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); | ||
| 304 | if (ret) | 481 | if (ret) |
| 305 | return ret; | 482 | goto error; |
| 483 | |||
| 484 | /* enable transport stream on IOA[7] */ | ||
| 485 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (0 << 7), 0x80); | ||
| 486 | if (ret) | ||
| 487 | goto error; | ||
| 306 | 488 | ||
| 307 | /* Zarlink ZL10353 DVB-T demod */ | 489 | /* attach demod */ |
| 308 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, | 490 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, |
| 309 | &adap->dev->i2c_adap); | 491 | &adap->dev->i2c_adap); |
| 310 | if (adap->fe != NULL) { | 492 | |
| 311 | state->tuner = DVB_PLL_SAMSUNG_DTOS403IH102A; | 493 | break; |
| 312 | return 0; | 494 | case ANYSEE_HW_507DC: /* 10 */ |
| 495 | /* E30 C Plus */ | ||
| 496 | |||
| 497 | /* enable DVB-C demod on IOD[0] */ | ||
| 498 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); | ||
| 499 | if (ret) | ||
| 500 | goto error; | ||
| 501 | |||
| 502 | /* attach demod */ | ||
| 503 | adap->fe = dvb_attach(tda10023_attach, &anysee_tda10023_config, | ||
| 504 | &adap->dev->i2c_adap, 0x48); | ||
| 505 | |||
| 506 | break; | ||
| 507 | case ANYSEE_HW_507SI: /* 11 */ | ||
| 508 | /* E30 S2 Plus */ | ||
| 509 | |||
| 510 | /* enable DVB-S/S2 demod on IOD[0] */ | ||
| 511 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); | ||
| 512 | if (ret) | ||
| 513 | goto error; | ||
| 514 | |||
| 515 | /* attach demod */ | ||
| 516 | adap->fe = dvb_attach(cx24116_attach, &anysee_cx24116_config, | ||
| 517 | &adap->dev->i2c_adap); | ||
| 518 | |||
| 519 | break; | ||
| 520 | case ANYSEE_HW_507FA: /* 15 */ | ||
| 521 | /* E30 Combo Plus */ | ||
| 522 | /* E30 C Plus */ | ||
| 523 | |||
| 524 | /* enable tuner on IOE[4] */ | ||
| 525 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); | ||
| 526 | if (ret) | ||
| 527 | goto error; | ||
| 528 | |||
| 529 | /* probe TDA18212 */ | ||
| 530 | tmp = 0; | ||
| 531 | ret = i2c_transfer(&adap->dev->i2c_adap, msg, 2); | ||
| 532 | if (ret == 2 && tmp == 0xc7) | ||
| 533 | deb_info("%s: TDA18212 found\n", __func__); | ||
| 534 | else | ||
| 535 | tmp = 0; | ||
| 536 | |||
| 537 | /* disable tuner on IOE[4] */ | ||
| 538 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 4), 0x10); | ||
| 539 | if (ret) | ||
| 540 | goto error; | ||
| 541 | |||
| 542 | if (dvb_usb_anysee_delsys) { | ||
| 543 | /* disable DVB-C demod on IOD[5] */ | ||
| 544 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), | ||
| 545 | 0x20); | ||
| 546 | if (ret) | ||
| 547 | goto error; | ||
| 548 | |||
| 549 | /* enable DVB-T demod on IOD[0] */ | ||
| 550 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), | ||
| 551 | 0x01); | ||
| 552 | if (ret) | ||
| 553 | goto error; | ||
| 554 | |||
| 555 | /* attach demod */ | ||
| 556 | if (tmp == 0xc7) { | ||
| 557 | /* TDA18212 config */ | ||
| 558 | adap->fe = dvb_attach(zl10353_attach, | ||
| 559 | &anysee_zl10353_tda18212_config2, | ||
| 560 | &adap->dev->i2c_adap); | ||
| 561 | } else { | ||
| 562 | /* PLL config */ | ||
| 563 | adap->fe = dvb_attach(zl10353_attach, | ||
| 564 | &anysee_zl10353_config, | ||
| 565 | &adap->dev->i2c_adap); | ||
| 566 | } | ||
| 567 | } else { | ||
| 568 | /* disable DVB-T demod on IOD[0] */ | ||
| 569 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0), | ||
| 570 | 0x01); | ||
| 571 | if (ret) | ||
| 572 | goto error; | ||
| 573 | |||
| 574 | /* enable DVB-C demod on IOD[5] */ | ||
| 575 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), | ||
| 576 | 0x20); | ||
| 577 | if (ret) | ||
| 578 | goto error; | ||
| 579 | |||
| 580 | /* attach demod */ | ||
| 581 | if (tmp == 0xc7) { | ||
| 582 | /* TDA18212 config */ | ||
| 583 | adap->fe = dvb_attach(tda10023_attach, | ||
| 584 | &anysee_tda10023_tda18212_config, | ||
| 585 | &adap->dev->i2c_adap, 0x48); | ||
| 586 | } else { | ||
| 587 | /* PLL config */ | ||
| 588 | adap->fe = dvb_attach(tda10023_attach, | ||
| 589 | &anysee_tda10023_config, | ||
| 590 | &adap->dev->i2c_adap, 0x48); | ||
| 591 | } | ||
| 313 | } | 592 | } |
| 314 | } | ||
| 315 | 593 | ||
| 316 | /* connect demod on IO port D for TDA10023 & ZL10353 */ | 594 | break; |
| 317 | ret = anysee_write_reg(adap->dev, 0xb0, 0x25); | 595 | case ANYSEE_HW_508TC: /* 18 */ |
| 318 | if (ret) | 596 | /* E7 TC */ |
| 319 | return ret; | ||
| 320 | 597 | ||
| 321 | /* Zarlink ZL10353 DVB-T demod inside of Samsung DNOS404ZH103A NIM */ | 598 | /* enable transport stream on IOA[7] */ |
| 322 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, | 599 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); |
| 323 | &adap->dev->i2c_adap); | 600 | if (ret) |
| 324 | if (adap->fe != NULL) { | 601 | goto error; |
| 325 | state->tuner = DVB_PLL_THOMSON_DTT7579; | 602 | |
| 326 | return 0; | 603 | if (dvb_usb_anysee_delsys) { |
| 327 | } | 604 | /* disable DVB-C demod on IOD[5] */ |
| 605 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), | ||
| 606 | 0x20); | ||
| 607 | if (ret) | ||
| 608 | goto error; | ||
| 609 | |||
| 610 | /* enable DVB-T demod on IOD[6] */ | ||
| 611 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6), | ||
| 612 | 0x40); | ||
| 613 | if (ret) | ||
| 614 | goto error; | ||
| 615 | |||
| 616 | /* enable IF route on IOE[0] */ | ||
| 617 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), | ||
| 618 | 0x01); | ||
| 619 | if (ret) | ||
| 620 | goto error; | ||
| 621 | |||
| 622 | /* attach demod */ | ||
| 623 | adap->fe = dvb_attach(zl10353_attach, | ||
| 624 | &anysee_zl10353_tda18212_config, | ||
| 625 | &adap->dev->i2c_adap); | ||
| 626 | } else { | ||
| 627 | /* disable DVB-T demod on IOD[6] */ | ||
| 628 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6), | ||
| 629 | 0x40); | ||
| 630 | if (ret) | ||
| 631 | goto error; | ||
| 632 | |||
| 633 | /* enable DVB-C demod on IOD[5] */ | ||
| 634 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), | ||
| 635 | 0x20); | ||
| 636 | if (ret) | ||
| 637 | goto error; | ||
| 638 | |||
| 639 | /* enable IF route on IOE[0] */ | ||
| 640 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), | ||
| 641 | 0x01); | ||
| 642 | if (ret) | ||
| 643 | goto error; | ||
| 644 | |||
| 645 | /* attach demod */ | ||
| 646 | adap->fe = dvb_attach(tda10023_attach, | ||
| 647 | &anysee_tda10023_tda18212_config, | ||
| 648 | &adap->dev->i2c_adap, 0x48); | ||
| 649 | } | ||
| 328 | 650 | ||
| 329 | /* IO port E - E30C rev 0.4 board requires this */ | 651 | break; |
| 330 | ret = anysee_write_reg(adap->dev, 0xb1, 0xa7); | 652 | case ANYSEE_HW_508S2: /* 19 */ |
| 331 | if (ret) | 653 | /* E7 S2 */ |
| 332 | return ret; | ||
| 333 | 654 | ||
| 334 | /* Philips TDA10023 DVB-C demod */ | 655 | /* enable transport stream on IOA[7] */ |
| 335 | adap->fe = dvb_attach(tda10023_attach, &anysee_tda10023_config, | 656 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); |
| 336 | &adap->dev->i2c_adap, 0x48); | 657 | if (ret) |
| 337 | if (adap->fe != NULL) { | 658 | goto error; |
| 338 | state->tuner = DVB_PLL_SAMSUNG_DTOS403IH102A; | ||
| 339 | return 0; | ||
| 340 | } | ||
| 341 | 659 | ||
| 342 | /* return IO port D to init value for safe */ | 660 | /* enable DVB-S/S2 demod on IOE[5] */ |
| 343 | ret = anysee_write_reg(adap->dev, 0xb0, io_d); | 661 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 5), 0x20); |
| 344 | if (ret) | 662 | if (ret) |
| 345 | return ret; | 663 | goto error; |
| 346 | 664 | ||
| 347 | err("Unknown Anysee version: %02x %02x %02x. "\ | 665 | /* attach demod */ |
| 348 | "Please report the <linux-dvb@linuxtv.org>.", | 666 | adap->fe = dvb_attach(stv0900_attach, &anysee_stv0900_config, |
| 349 | hw_info[0], hw_info[1], hw_info[2]); | 667 | &adap->dev->i2c_adap, 0); |
| 350 | 668 | ||
| 351 | return -ENODEV; | 669 | break; |
| 670 | } | ||
| 671 | |||
| 672 | if (!adap->fe) { | ||
| 673 | /* we have no frontend :-( */ | ||
| 674 | ret = -ENODEV; | ||
| 675 | err("Unsupported Anysee version. " \ | ||
| 676 | "Please report the <linux-media@vger.kernel.org>."); | ||
| 677 | } | ||
| 678 | error: | ||
| 679 | return ret; | ||
| 352 | } | 680 | } |
| 353 | 681 | ||
| 354 | static int anysee_tuner_attach(struct dvb_usb_adapter *adap) | 682 | static int anysee_tuner_attach(struct dvb_usb_adapter *adap) |
| 355 | { | 683 | { |
| 356 | struct anysee_state *state = adap->dev->priv; | 684 | struct anysee_state *state = adap->dev->priv; |
| 357 | deb_info("%s: \n", __func__); | 685 | struct dvb_frontend *fe; |
| 358 | 686 | int ret; | |
| 359 | switch (state->tuner) { | 687 | deb_info("%s:\n", __func__); |
| 360 | case DVB_PLL_THOMSON_DTT7579: | 688 | |
| 361 | /* Thomson dtt7579 (not sure) PLL inside of: | 689 | switch (state->hw) { |
| 362 | Samsung DNOS404ZH102A NIM | 690 | case ANYSEE_HW_02: /* 2 */ |
| 363 | Samsung DNOS404ZH103A NIM */ | 691 | /* E30 */ |
| 364 | dvb_attach(dvb_pll_attach, adap->fe, 0x61, | 692 | |
| 365 | NULL, DVB_PLL_THOMSON_DTT7579); | 693 | /* attach tuner */ |
| 694 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1), | ||
| 695 | NULL, DVB_PLL_THOMSON_DTT7579); | ||
| 696 | |||
| 697 | break; | ||
| 698 | case ANYSEE_HW_507CD: /* 6 */ | ||
| 699 | /* E30 Plus */ | ||
| 700 | |||
| 701 | /* attach tuner */ | ||
| 702 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1), | ||
| 703 | &adap->dev->i2c_adap, DVB_PLL_THOMSON_DTT7579); | ||
| 704 | |||
| 705 | break; | ||
| 706 | case ANYSEE_HW_507DC: /* 10 */ | ||
| 707 | /* E30 C Plus */ | ||
| 708 | |||
| 709 | /* attach tuner */ | ||
| 710 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1), | ||
| 711 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); | ||
| 712 | |||
| 713 | break; | ||
| 714 | case ANYSEE_HW_507SI: /* 11 */ | ||
| 715 | /* E30 S2 Plus */ | ||
| 716 | |||
| 717 | /* attach LNB controller */ | ||
| 718 | fe = dvb_attach(isl6423_attach, adap->fe, &adap->dev->i2c_adap, | ||
| 719 | &anysee_isl6423_config); | ||
| 720 | |||
| 721 | break; | ||
| 722 | case ANYSEE_HW_507FA: /* 15 */ | ||
| 723 | /* E30 Combo Plus */ | ||
| 724 | /* E30 C Plus */ | ||
| 725 | |||
| 726 | if (dvb_usb_anysee_delsys) { | ||
| 727 | /* enable DVB-T tuner on IOE[0] */ | ||
| 728 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), | ||
| 729 | 0x01); | ||
| 730 | if (ret) | ||
| 731 | goto error; | ||
| 732 | } else { | ||
| 733 | /* enable DVB-C tuner on IOE[0] */ | ||
| 734 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), | ||
| 735 | 0x01); | ||
| 736 | if (ret) | ||
| 737 | goto error; | ||
| 738 | } | ||
| 739 | |||
| 740 | /* Try first attach TDA18212 silicon tuner on IOE[4], if that | ||
| 741 | * fails attach old simple PLL. */ | ||
| 742 | |||
| 743 | /* enable tuner on IOE[4] */ | ||
| 744 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); | ||
| 745 | if (ret) | ||
| 746 | goto error; | ||
| 747 | |||
| 748 | /* attach tuner */ | ||
| 749 | fe = dvb_attach(tda18212_attach, adap->fe, &adap->dev->i2c_adap, | ||
| 750 | &anysee_tda18212_config); | ||
| 751 | if (fe) | ||
| 752 | break; | ||
| 753 | |||
| 754 | /* disable tuner on IOE[4] */ | ||
| 755 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 4), 0x10); | ||
| 756 | if (ret) | ||
| 757 | goto error; | ||
| 758 | |||
| 759 | /* attach tuner */ | ||
| 760 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1), | ||
| 761 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); | ||
| 762 | |||
| 763 | break; | ||
| 764 | case ANYSEE_HW_508TC: /* 18 */ | ||
| 765 | /* E7 TC */ | ||
| 766 | |||
| 767 | /* enable tuner on IOE[4] */ | ||
| 768 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); | ||
| 769 | if (ret) | ||
| 770 | goto error; | ||
| 771 | |||
| 772 | /* attach tuner */ | ||
| 773 | fe = dvb_attach(tda18212_attach, adap->fe, &adap->dev->i2c_adap, | ||
| 774 | &anysee_tda18212_config); | ||
| 775 | |||
| 366 | break; | 776 | break; |
| 367 | case DVB_PLL_SAMSUNG_DTOS403IH102A: | 777 | case ANYSEE_HW_508S2: /* 19 */ |
| 368 | /* Unknown PLL inside of Samsung DTOS403IH102A tuner module */ | 778 | /* E7 S2 */ |
| 369 | dvb_attach(dvb_pll_attach, adap->fe, 0xc0, | 779 | |
| 370 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); | 780 | /* attach tuner */ |
| 781 | fe = dvb_attach(stv6110_attach, adap->fe, | ||
| 782 | &anysee_stv6110_config, &adap->dev->i2c_adap); | ||
| 783 | |||
| 784 | if (fe) { | ||
| 785 | /* attach LNB controller */ | ||
| 786 | fe = dvb_attach(isl6423_attach, adap->fe, | ||
| 787 | &adap->dev->i2c_adap, &anysee_isl6423_config); | ||
| 788 | } | ||
| 789 | |||
| 371 | break; | 790 | break; |
| 791 | default: | ||
| 792 | fe = NULL; | ||
| 372 | } | 793 | } |
| 373 | 794 | ||
| 374 | return 0; | 795 | if (fe) |
| 796 | ret = 0; | ||
| 797 | else | ||
| 798 | ret = -ENODEV; | ||
| 799 | |||
| 800 | error: | ||
| 801 | return ret; | ||
| 375 | } | 802 | } |
| 376 | 803 | ||
| 377 | static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 804 | static int anysee_rc_query(struct dvb_usb_device *d) |
| 378 | { | 805 | { |
| 379 | u8 buf[] = {CMD_GET_IR_CODE}; | 806 | u8 buf[] = {CMD_GET_IR_CODE}; |
| 380 | struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map; | ||
| 381 | u8 ircode[2]; | 807 | u8 ircode[2]; |
| 382 | int i, ret; | 808 | int ret; |
| 383 | 809 | ||
| 384 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), &ircode[0], 2); | 810 | /* Remote controller is basic NEC using address byte 0x08. |
| 811 | Anysee device RC query returns only two bytes, status and code, | ||
| 812 | address byte is dropped. Also it does not return any value for | ||
| 813 | NEC RCs having address byte other than 0x08. Due to that, we | ||
| 814 | cannot use that device as standard NEC receiver. | ||
| 815 | It could be possible make hack which reads whole code directly | ||
| 816 | from device memory... */ | ||
| 817 | |||
| 818 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), ircode, sizeof(ircode)); | ||
| 385 | if (ret) | 819 | if (ret) |
| 386 | return ret; | 820 | return ret; |
| 387 | 821 | ||
| 388 | *event = 0; | 822 | if (ircode[0]) { |
| 389 | *state = REMOTE_NO_KEY_PRESSED; | 823 | deb_rc("%s: key pressed %02x\n", __func__, ircode[1]); |
| 390 | 824 | rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0); | |
| 391 | for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) { | ||
| 392 | if (rc5_custom(&keymap[i]) == ircode[0] && | ||
| 393 | rc5_data(&keymap[i]) == ircode[1]) { | ||
| 394 | *event = keymap[i].keycode; | ||
| 395 | *state = REMOTE_KEY_PRESSED; | ||
| 396 | return 0; | ||
| 397 | } | ||
| 398 | } | 825 | } |
| 826 | |||
| 399 | return 0; | 827 | return 0; |
| 400 | } | 828 | } |
| 401 | 829 | ||
| 402 | static struct ir_scancode ir_codes_anysee_table[] = { | ||
| 403 | { 0x0100, KEY_0 }, | ||
| 404 | { 0x0101, KEY_1 }, | ||
| 405 | { 0x0102, KEY_2 }, | ||
| 406 | { 0x0103, KEY_3 }, | ||
| 407 | { 0x0104, KEY_4 }, | ||
| 408 | { 0x0105, KEY_5 }, | ||
| 409 | { 0x0106, KEY_6 }, | ||
| 410 | { 0x0107, KEY_7 }, | ||
| 411 | { 0x0108, KEY_8 }, | ||
| 412 | { 0x0109, KEY_9 }, | ||
| 413 | { 0x010a, KEY_POWER }, | ||
| 414 | { 0x010b, KEY_DOCUMENTS }, /* * */ | ||
| 415 | { 0x0119, KEY_FAVORITES }, | ||
| 416 | { 0x0120, KEY_SLEEP }, | ||
| 417 | { 0x0121, KEY_MODE }, /* 4:3 / 16:9 select */ | ||
| 418 | { 0x0122, KEY_ZOOM }, | ||
| 419 | { 0x0147, KEY_TEXT }, | ||
| 420 | { 0x0116, KEY_TV }, /* TV / radio select */ | ||
| 421 | { 0x011e, KEY_LANGUAGE }, /* Second Audio Program */ | ||
| 422 | { 0x011a, KEY_SUBTITLE }, | ||
| 423 | { 0x011b, KEY_CAMERA }, /* screenshot */ | ||
| 424 | { 0x0142, KEY_MUTE }, | ||
| 425 | { 0x010e, KEY_MENU }, | ||
| 426 | { 0x010f, KEY_EPG }, | ||
| 427 | { 0x0117, KEY_INFO }, | ||
| 428 | { 0x0110, KEY_EXIT }, | ||
| 429 | { 0x0113, KEY_VOLUMEUP }, | ||
| 430 | { 0x0112, KEY_VOLUMEDOWN }, | ||
| 431 | { 0x0111, KEY_CHANNELUP }, | ||
| 432 | { 0x0114, KEY_CHANNELDOWN }, | ||
| 433 | { 0x0115, KEY_OK }, | ||
| 434 | { 0x011d, KEY_RED }, | ||
| 435 | { 0x011f, KEY_GREEN }, | ||
| 436 | { 0x011c, KEY_YELLOW }, | ||
| 437 | { 0x0144, KEY_BLUE }, | ||
| 438 | { 0x010c, KEY_SHUFFLE }, /* snapshot */ | ||
| 439 | { 0x0148, KEY_STOP }, | ||
| 440 | { 0x0150, KEY_PLAY }, | ||
| 441 | { 0x0151, KEY_PAUSE }, | ||
| 442 | { 0x0149, KEY_RECORD }, | ||
| 443 | { 0x0118, KEY_PREVIOUS }, /* |<< */ | ||
| 444 | { 0x010d, KEY_NEXT }, /* >>| */ | ||
| 445 | { 0x0124, KEY_PROG1 }, /* F1 */ | ||
| 446 | { 0x0125, KEY_PROG2 }, /* F2 */ | ||
| 447 | }; | ||
| 448 | |||
| 449 | /* DVB USB Driver stuff */ | 830 | /* DVB USB Driver stuff */ |
| 450 | static struct dvb_usb_device_properties anysee_properties; | 831 | static struct dvb_usb_device_properties anysee_properties; |
| 451 | 832 | ||
| @@ -520,11 +901,12 @@ static struct dvb_usb_device_properties anysee_properties = { | |||
| 520 | } | 901 | } |
| 521 | }, | 902 | }, |
| 522 | 903 | ||
| 523 | .rc.legacy = { | 904 | .rc.core = { |
| 524 | .rc_key_map = ir_codes_anysee_table, | 905 | .rc_codes = RC_MAP_ANYSEE, |
| 525 | .rc_key_map_size = ARRAY_SIZE(ir_codes_anysee_table), | 906 | .protocol = RC_TYPE_OTHER, |
| 907 | .module_name = "anysee", | ||
| 526 | .rc_query = anysee_rc_query, | 908 | .rc_query = anysee_rc_query, |
| 527 | .rc_interval = 200, /* windows driver uses 500ms */ | 909 | .rc_interval = 250, /* windows driver uses 500ms */ |
| 528 | }, | 910 | }, |
| 529 | 911 | ||
| 530 | .i2c_algo = &anysee_i2c_algo, | 912 | .i2c_algo = &anysee_i2c_algo, |
