diff options
Diffstat (limited to 'drivers/media/dvb')
22 files changed, 2104 insertions, 389 deletions
diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c index 131b938e9e81..ebf3f05839d2 100644 --- a/drivers/media/dvb/ddbridge/ddbridge-core.c +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c | |||
@@ -578,6 +578,7 @@ static int demod_attach_drxk(struct ddb_input *input) | |||
578 | 578 | ||
579 | memset(&config, 0, sizeof(config)); | 579 | memset(&config, 0, sizeof(config)); |
580 | config.microcode_name = "drxk_a3.mc"; | 580 | config.microcode_name = "drxk_a3.mc"; |
581 | config.qam_demod_parameter_count = 4; | ||
581 | config.adr = 0x29 + (input->nr & 1); | 582 | config.adr = 0x29 + (input->nr & 1); |
582 | 583 | ||
583 | fe = input->fe = dvb_attach(drxk_attach, &config, i2c); | 584 | fe = input->fe = dvb_attach(drxk_attach, &config, i2c); |
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h index e929d5697b87..7c64c09103a9 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/drivers/media/dvb/dvb-core/dvb_frontend.h | |||
@@ -220,6 +220,7 @@ struct dvb_tuner_ops { | |||
220 | #define TUNER_STATUS_STEREO 2 | 220 | #define TUNER_STATUS_STEREO 2 |
221 | int (*get_status)(struct dvb_frontend *fe, u32 *status); | 221 | int (*get_status)(struct dvb_frontend *fe, u32 *status); |
222 | int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); | 222 | int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); |
223 | int (*get_afc)(struct dvb_frontend *fe, s32 *afc); | ||
223 | 224 | ||
224 | /** These are provided separately from set_params in order to facilitate silicon | 225 | /** These are provided separately from set_params in order to facilitate silicon |
225 | * tuners which require sophisticated tuning loops, controlling each parameter separately. */ | 226 | * tuners which require sophisticated tuning loops, controlling each parameter separately. */ |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index a26949336b3d..c2161565023a 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -418,9 +418,12 @@ config DVB_USB_RTL28XXU | |||
418 | tristate "Realtek RTL28xxU DVB USB support" | 418 | tristate "Realtek RTL28xxU DVB USB support" |
419 | depends on DVB_USB && EXPERIMENTAL | 419 | depends on DVB_USB && EXPERIMENTAL |
420 | select DVB_RTL2830 | 420 | select DVB_RTL2830 |
421 | select DVB_RTL2832 | ||
421 | select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE | 422 | select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE |
422 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE | 423 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE |
423 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE | 424 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE |
425 | select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE | ||
426 | select MEDIA_TUNER_FC0013 if !MEDIA_TUNER_CUSTOMISE | ||
424 | help | 427 | help |
425 | Say Y here to support the Realtek RTL28xxU DVB USB receiver. | 428 | Say Y here to support the Realtek RTL28xxU DVB USB receiver. |
426 | 429 | ||
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c index 4008b9c50fbd..8ffcad000ad3 100644 --- a/drivers/media/dvb/dvb-usb/az6007.c +++ b/drivers/media/dvb/dvb-usb/az6007.c | |||
@@ -593,9 +593,7 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6]) | |||
593 | memcpy(mac, st->data, sizeof(mac)); | 593 | memcpy(mac, st->data, sizeof(mac)); |
594 | 594 | ||
595 | if (ret > 0) | 595 | if (ret > 0) |
596 | deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n", | 596 | deb_info("%s: mac is %pM\n", __func__, mac); |
597 | __func__, mac[0], mac[1], mac[2], | ||
598 | mac[3], mac[4], mac[5]); | ||
599 | 597 | ||
600 | return ret; | 598 | return ret; |
601 | } | 599 | } |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 7a6160bf54ba..26c44818a5ab 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -100,6 +100,7 @@ | |||
100 | #define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397 | 100 | #define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397 |
101 | #define USB_PID_CONEXANT_D680_DMB 0x86d6 | 101 | #define USB_PID_CONEXANT_D680_DMB 0x86d6 |
102 | #define USB_PID_CREATIX_CTX1921 0x1921 | 102 | #define USB_PID_CREATIX_CTX1921 0x1921 |
103 | #define USB_PID_DELOCK_USB2_DVBT 0xb803 | ||
103 | #define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 | 104 | #define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 |
104 | #define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 | 105 | #define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 |
105 | #define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 | 106 | #define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 |
@@ -160,6 +161,7 @@ | |||
160 | #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 | 161 | #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 |
161 | #define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 | 162 | #define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 |
162 | #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 | 163 | #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 |
164 | #define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1 0x00a9 | ||
163 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 | 165 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 |
164 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 | 166 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 |
165 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 | 167 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 |
@@ -245,6 +247,7 @@ | |||
245 | #define USB_PID_TERRATEC_H7_2 0x10a3 | 247 | #define USB_PID_TERRATEC_H7_2 0x10a3 |
246 | #define USB_PID_TERRATEC_T3 0x10a0 | 248 | #define USB_PID_TERRATEC_T3 0x10a0 |
247 | #define USB_PID_TERRATEC_T5 0x10a1 | 249 | #define USB_PID_TERRATEC_T5 0x10a1 |
250 | #define USB_PID_NOXON_DAB_STICK 0x00b3 | ||
248 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e | 251 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e |
249 | #define USB_PID_PINNACLE_PCTV2000E 0x022c | 252 | #define USB_PID_PINNACLE_PCTV2000E 0x022c |
250 | #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 | 253 | #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 |
diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 41e1f5537f44..6bd0bd792437 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> |
5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> | 5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> |
6 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com> | ||
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -22,10 +23,13 @@ | |||
22 | #include "rtl28xxu.h" | 23 | #include "rtl28xxu.h" |
23 | 24 | ||
24 | #include "rtl2830.h" | 25 | #include "rtl2830.h" |
26 | #include "rtl2832.h" | ||
25 | 27 | ||
26 | #include "qt1010.h" | 28 | #include "qt1010.h" |
27 | #include "mt2060.h" | 29 | #include "mt2060.h" |
28 | #include "mxl5005s.h" | 30 | #include "mxl5005s.h" |
31 | #include "fc0012.h" | ||
32 | #include "fc0013.h" | ||
29 | 33 | ||
30 | /* debug */ | 34 | /* debug */ |
31 | static int dvb_usb_rtl28xxu_debug; | 35 | static int dvb_usb_rtl28xxu_debug; |
@@ -80,7 +84,7 @@ err: | |||
80 | return ret; | 84 | return ret; |
81 | } | 85 | } |
82 | 86 | ||
83 | static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) | 87 | static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) |
84 | { | 88 | { |
85 | struct rtl28xxu_req req; | 89 | struct rtl28xxu_req req; |
86 | 90 | ||
@@ -116,12 +120,12 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) | |||
116 | return rtl28xxu_ctrl_msg(d, &req); | 120 | return rtl28xxu_ctrl_msg(d, &req); |
117 | } | 121 | } |
118 | 122 | ||
119 | static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) | 123 | static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) |
120 | { | 124 | { |
121 | return rtl2831_wr_regs(d, reg, &val, 1); | 125 | return rtl28xx_wr_regs(d, reg, &val, 1); |
122 | } | 126 | } |
123 | 127 | ||
124 | static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) | 128 | static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) |
125 | { | 129 | { |
126 | return rtl2831_rd_regs(d, reg, val, 1); | 130 | return rtl2831_rd_regs(d, reg, val, 1); |
127 | } | 131 | } |
@@ -308,12 +312,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) | |||
308 | */ | 312 | */ |
309 | 313 | ||
310 | /* GPIO direction */ | 314 | /* GPIO direction */ |
311 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); | 315 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); |
312 | if (ret) | 316 | if (ret) |
313 | goto err; | 317 | goto err; |
314 | 318 | ||
315 | /* enable as output GPIO0, GPIO2, GPIO4 */ | 319 | /* enable as output GPIO0, GPIO2, GPIO4 */ |
316 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); | 320 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); |
317 | if (ret) | 321 | if (ret) |
318 | goto err; | 322 | goto err; |
319 | 323 | ||
@@ -381,34 +385,159 @@ err: | |||
381 | return ret; | 385 | return ret; |
382 | } | 386 | } |
383 | 387 | ||
388 | static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { | ||
389 | .i2c_addr = 0x10, /* 0x20 */ | ||
390 | .xtal = 28800000, | ||
391 | .if_dvbt = 0, | ||
392 | .tuner = TUNER_RTL2832_FC0012 | ||
393 | }; | ||
394 | |||
395 | static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { | ||
396 | .i2c_addr = 0x10, /* 0x20 */ | ||
397 | .xtal = 28800000, | ||
398 | .if_dvbt = 0, | ||
399 | .tuner = TUNER_RTL2832_FC0013 | ||
400 | }; | ||
401 | |||
402 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, | ||
403 | int cmd, int arg) | ||
404 | { | ||
405 | int ret; | ||
406 | u8 val; | ||
407 | |||
408 | deb_info("%s cmd=%d arg=%d\n", __func__, cmd, arg); | ||
409 | switch (cmd) { | ||
410 | case FC_FE_CALLBACK_VHF_ENABLE: | ||
411 | /* set output values */ | ||
412 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
413 | if (ret) | ||
414 | goto err; | ||
415 | |||
416 | if (arg) | ||
417 | val &= 0xbf; /* set GPIO6 low */ | ||
418 | else | ||
419 | val |= 0x40; /* set GPIO6 high */ | ||
420 | |||
421 | |||
422 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
423 | if (ret) | ||
424 | goto err; | ||
425 | break; | ||
426 | default: | ||
427 | ret = -EINVAL; | ||
428 | goto err; | ||
429 | } | ||
430 | return 0; | ||
431 | |||
432 | err: | ||
433 | err("%s: failed=%d\n", __func__, ret); | ||
434 | |||
435 | return ret; | ||
436 | } | ||
437 | |||
438 | |||
439 | static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, | ||
440 | int cmd, int arg) | ||
441 | { | ||
442 | /* TODO implement*/ | ||
443 | return 0; | ||
444 | } | ||
445 | |||
446 | static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) | ||
447 | { | ||
448 | struct rtl28xxu_priv *priv = d->priv; | ||
449 | |||
450 | switch (priv->tuner) { | ||
451 | case TUNER_RTL2832_FC0012: | ||
452 | return rtl2832u_fc0012_tuner_callback(d, cmd, arg); | ||
453 | |||
454 | case TUNER_RTL2832_FC0013: | ||
455 | return rtl2832u_fc0013_tuner_callback(d, cmd, arg); | ||
456 | default: | ||
457 | break; | ||
458 | } | ||
459 | |||
460 | return -ENODEV; | ||
461 | } | ||
462 | |||
463 | static int rtl2832u_frontend_callback(void *adapter_priv, int component, | ||
464 | int cmd, int arg) | ||
465 | { | ||
466 | struct i2c_adapter *adap = adapter_priv; | ||
467 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | ||
468 | |||
469 | switch (component) { | ||
470 | case DVB_FRONTEND_COMPONENT_TUNER: | ||
471 | return rtl2832u_tuner_callback(d, cmd, arg); | ||
472 | default: | ||
473 | break; | ||
474 | } | ||
475 | |||
476 | return -EINVAL; | ||
477 | } | ||
478 | |||
479 | |||
480 | |||
481 | |||
384 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | 482 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) |
385 | { | 483 | { |
386 | int ret; | 484 | int ret; |
387 | struct rtl28xxu_priv *priv = adap->dev->priv; | 485 | struct rtl28xxu_priv *priv = adap->dev->priv; |
388 | u8 buf[1]; | 486 | struct rtl2832_config *rtl2832_config; |
487 | |||
488 | u8 buf[2], val; | ||
389 | /* open RTL2832U/RTL2832 I2C gate */ | 489 | /* open RTL2832U/RTL2832 I2C gate */ |
390 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; | 490 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; |
391 | /* close RTL2832U/RTL2832 I2C gate */ | 491 | /* close RTL2832U/RTL2832 I2C gate */ |
392 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; | 492 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; |
493 | /* for FC0012 tuner probe */ | ||
494 | struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf}; | ||
495 | /* for FC0013 tuner probe */ | ||
496 | struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf}; | ||
497 | /* for MT2266 tuner probe */ | ||
498 | struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
393 | /* for FC2580 tuner probe */ | 499 | /* for FC2580 tuner probe */ |
394 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; | 500 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; |
501 | /* for MT2063 tuner probe */ | ||
502 | struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
503 | /* for MAX3543 tuner probe */ | ||
504 | struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
505 | /* for TUA9001 tuner probe */ | ||
506 | struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf}; | ||
507 | /* for MXL5007T tuner probe */ | ||
508 | struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf}; | ||
509 | /* for E4000 tuner probe */ | ||
510 | struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; | ||
511 | /* for TDA18272 tuner probe */ | ||
512 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; | ||
395 | 513 | ||
396 | deb_info("%s:\n", __func__); | 514 | deb_info("%s:\n", __func__); |
397 | 515 | ||
398 | /* GPIO direction */ | 516 | |
399 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); | 517 | ret = rtl28xx_rd_reg(adap->dev, SYS_GPIO_DIR, &val); |
400 | if (ret) | 518 | if (ret) |
401 | goto err; | 519 | goto err; |
402 | 520 | ||
403 | /* enable as output GPIO0, GPIO2, GPIO4 */ | 521 | val &= 0xbf; |
404 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); | 522 | |
523 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_DIR, val); | ||
405 | if (ret) | 524 | if (ret) |
406 | goto err; | 525 | goto err; |
407 | 526 | ||
408 | ret = rtl2831_wr_reg(adap->dev, SYS_DEMOD_CTL, 0xe8); | 527 | |
528 | /* enable as output GPIO3 and GPIO6*/ | ||
529 | ret = rtl28xx_rd_reg(adap->dev, SYS_GPIO_OUT_EN, &val); | ||
409 | if (ret) | 530 | if (ret) |
410 | goto err; | 531 | goto err; |
411 | 532 | ||
533 | val |= 0x48; | ||
534 | |||
535 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_OUT_EN, val); | ||
536 | if (ret) | ||
537 | goto err; | ||
538 | |||
539 | |||
540 | |||
412 | /* | 541 | /* |
413 | * Probe used tuner. We need to know used tuner before demod attach | 542 | * Probe used tuner. We need to know used tuner before demod attach |
414 | * since there is some demod params needed to set according to tuner. | 543 | * since there is some demod params needed to set according to tuner. |
@@ -419,25 +548,108 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | |||
419 | if (ret) | 548 | if (ret) |
420 | goto err; | 549 | goto err; |
421 | 550 | ||
551 | priv->tuner = TUNER_NONE; | ||
552 | |||
553 | /* check FC0012 ID register; reg=00 val=a1 */ | ||
554 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc0012); | ||
555 | if (ret == 0 && buf[0] == 0xa1) { | ||
556 | priv->tuner = TUNER_RTL2832_FC0012; | ||
557 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; | ||
558 | info("%s: FC0012 tuner found", __func__); | ||
559 | goto found; | ||
560 | } | ||
561 | |||
562 | /* check FC0013 ID register; reg=00 val=a3 */ | ||
563 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc0013); | ||
564 | if (ret == 0 && buf[0] == 0xa3) { | ||
565 | priv->tuner = TUNER_RTL2832_FC0013; | ||
566 | rtl2832_config = &rtl28xxu_rtl2832_fc0013_config; | ||
567 | info("%s: FC0013 tuner found", __func__); | ||
568 | goto found; | ||
569 | } | ||
570 | |||
571 | /* check MT2266 ID register; reg=00 val=85 */ | ||
572 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mt2266); | ||
573 | if (ret == 0 && buf[0] == 0x85) { | ||
574 | priv->tuner = TUNER_RTL2832_MT2266; | ||
575 | /* TODO implement tuner */ | ||
576 | info("%s: MT2266 tuner found", __func__); | ||
577 | goto unsupported; | ||
578 | } | ||
579 | |||
422 | /* check FC2580 ID register; reg=01 val=56 */ | 580 | /* check FC2580 ID register; reg=01 val=56 */ |
423 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc2580); | 581 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc2580); |
424 | if (ret == 0 && buf[0] == 0x56) { | 582 | if (ret == 0 && buf[0] == 0x56) { |
425 | priv->tuner = TUNER_RTL2832_FC2580; | 583 | priv->tuner = TUNER_RTL2832_FC2580; |
426 | deb_info("%s: FC2580\n", __func__); | 584 | /* TODO implement tuner */ |
427 | goto found; | 585 | info("%s: FC2580 tuner found", __func__); |
428 | } else { | 586 | goto unsupported; |
429 | deb_info("%s: FC2580 probe failed=%d - %02x\n", | ||
430 | __func__, ret, buf[0]); | ||
431 | } | 587 | } |
432 | 588 | ||
589 | /* check MT2063 ID register; reg=00 val=9e || 9c */ | ||
590 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mt2063); | ||
591 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { | ||
592 | priv->tuner = TUNER_RTL2832_MT2063; | ||
593 | /* TODO implement tuner */ | ||
594 | info("%s: MT2063 tuner found", __func__); | ||
595 | goto unsupported; | ||
596 | } | ||
597 | |||
598 | /* check MAX3543 ID register; reg=00 val=38 */ | ||
599 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_max3543); | ||
600 | if (ret == 0 && buf[0] == 0x38) { | ||
601 | priv->tuner = TUNER_RTL2832_MAX3543; | ||
602 | /* TODO implement tuner */ | ||
603 | info("%s: MAX3534 tuner found", __func__); | ||
604 | goto unsupported; | ||
605 | } | ||
606 | |||
607 | /* check TUA9001 ID register; reg=7e val=2328 */ | ||
608 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_tua9001); | ||
609 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { | ||
610 | priv->tuner = TUNER_RTL2832_TUA9001; | ||
611 | /* TODO implement tuner */ | ||
612 | info("%s: TUA9001 tuner found", __func__); | ||
613 | goto unsupported; | ||
614 | } | ||
615 | |||
616 | /* check MXL5007R ID register; reg=d9 val=14 */ | ||
617 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mxl5007t); | ||
618 | if (ret == 0 && buf[0] == 0x14) { | ||
619 | priv->tuner = TUNER_RTL2832_MXL5007T; | ||
620 | /* TODO implement tuner */ | ||
621 | info("%s: MXL5007T tuner found", __func__); | ||
622 | goto unsupported; | ||
623 | } | ||
624 | |||
625 | /* check E4000 ID register; reg=02 val=40 */ | ||
626 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_e4000); | ||
627 | if (ret == 0 && buf[0] == 0x40) { | ||
628 | priv->tuner = TUNER_RTL2832_E4000; | ||
629 | /* TODO implement tuner */ | ||
630 | info("%s: E4000 tuner found", __func__); | ||
631 | goto unsupported; | ||
632 | } | ||
633 | |||
634 | /* check TDA18272 ID register; reg=00 val=c760 */ | ||
635 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_tda18272); | ||
636 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { | ||
637 | priv->tuner = TUNER_RTL2832_TDA18272; | ||
638 | /* TODO implement tuner */ | ||
639 | info("%s: TDA18272 tuner found", __func__); | ||
640 | goto unsupported; | ||
641 | } | ||
642 | |||
643 | unsupported: | ||
433 | /* close demod I2C gate */ | 644 | /* close demod I2C gate */ |
434 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate_close); | 645 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate_close); |
435 | if (ret) | 646 | if (ret) |
436 | goto err; | 647 | goto err; |
437 | 648 | ||
438 | /* tuner not found */ | 649 | /* tuner not found */ |
650 | deb_info("No compatible tuner found"); | ||
439 | ret = -ENODEV; | 651 | ret = -ENODEV; |
440 | goto err; | 652 | return ret; |
441 | 653 | ||
442 | found: | 654 | found: |
443 | /* close demod I2C gate */ | 655 | /* close demod I2C gate */ |
@@ -446,9 +658,18 @@ found: | |||
446 | goto err; | 658 | goto err; |
447 | 659 | ||
448 | /* attach demodulator */ | 660 | /* attach demodulator */ |
449 | /* TODO: */ | 661 | adap->fe_adap[0].fe = dvb_attach(rtl2832_attach, rtl2832_config, |
662 | &adap->dev->i2c_adap); | ||
663 | if (adap->fe_adap[0].fe == NULL) { | ||
664 | ret = -ENODEV; | ||
665 | goto err; | ||
666 | } | ||
667 | |||
668 | /* set fe callbacks */ | ||
669 | adap->fe_adap[0].fe->callback = rtl2832u_frontend_callback; | ||
450 | 670 | ||
451 | return ret; | 671 | return ret; |
672 | |||
452 | err: | 673 | err: |
453 | deb_info("%s: failed=%d\n", __func__, ret); | 674 | deb_info("%s: failed=%d\n", __func__, ret); |
454 | return ret; | 675 | return ret; |
@@ -531,10 +752,24 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
531 | deb_info("%s:\n", __func__); | 752 | deb_info("%s:\n", __func__); |
532 | 753 | ||
533 | switch (priv->tuner) { | 754 | switch (priv->tuner) { |
534 | case TUNER_RTL2832_FC2580: | 755 | case TUNER_RTL2832_FC0012: |
535 | /* TODO: */ | 756 | fe = dvb_attach(fc0012_attach, adap->fe_adap[0].fe, |
536 | fe = NULL; | 757 | &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); |
758 | |||
759 | /* since fc0012 includs reading the signal strength delegate | ||
760 | * that to the tuner driver */ | ||
761 | adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0]. | ||
762 | fe->ops.tuner_ops.get_rf_strength; | ||
763 | return 0; | ||
537 | break; | 764 | break; |
765 | case TUNER_RTL2832_FC0013: | ||
766 | fe = dvb_attach(fc0013_attach, adap->fe_adap[0].fe, | ||
767 | &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); | ||
768 | |||
769 | /* fc0013 also supports signal strength reading */ | ||
770 | adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0] | ||
771 | .fe->ops.tuner_ops.get_rf_strength; | ||
772 | return 0; | ||
538 | default: | 773 | default: |
539 | fe = NULL; | 774 | fe = NULL; |
540 | err("unknown tuner=%d", priv->tuner); | 775 | err("unknown tuner=%d", priv->tuner); |
@@ -551,14 +786,14 @@ err: | |||
551 | return ret; | 786 | return ret; |
552 | } | 787 | } |
553 | 788 | ||
554 | static int rtl28xxu_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | 789 | static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) |
555 | { | 790 | { |
556 | int ret; | 791 | int ret; |
557 | u8 buf[2], gpio; | 792 | u8 buf[2], gpio; |
558 | 793 | ||
559 | deb_info("%s: onoff=%d\n", __func__, onoff); | 794 | deb_info("%s: onoff=%d\n", __func__, onoff); |
560 | 795 | ||
561 | ret = rtl2831_rd_reg(adap->dev, SYS_GPIO_OUT_VAL, &gpio); | 796 | ret = rtl28xx_rd_reg(adap->dev, SYS_GPIO_OUT_VAL, &gpio); |
562 | if (ret) | 797 | if (ret) |
563 | goto err; | 798 | goto err; |
564 | 799 | ||
@@ -572,11 +807,37 @@ static int rtl28xxu_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | |||
572 | gpio &= (~0x04); /* LED off */ | 807 | gpio &= (~0x04); /* LED off */ |
573 | } | 808 | } |
574 | 809 | ||
575 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_VAL, gpio); | 810 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_OUT_VAL, gpio); |
576 | if (ret) | 811 | if (ret) |
577 | goto err; | 812 | goto err; |
578 | 813 | ||
579 | ret = rtl2831_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); | 814 | ret = rtl28xx_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); |
815 | if (ret) | ||
816 | goto err; | ||
817 | |||
818 | return ret; | ||
819 | err: | ||
820 | deb_info("%s: failed=%d\n", __func__, ret); | ||
821 | return ret; | ||
822 | } | ||
823 | |||
824 | static int rtl2832u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | ||
825 | { | ||
826 | int ret; | ||
827 | u8 buf[2]; | ||
828 | |||
829 | deb_info("%s: onoff=%d\n", __func__, onoff); | ||
830 | |||
831 | |||
832 | if (onoff) { | ||
833 | buf[0] = 0x00; | ||
834 | buf[1] = 0x00; | ||
835 | } else { | ||
836 | buf[0] = 0x10; /* stall EPA */ | ||
837 | buf[1] = 0x02; /* reset EPA */ | ||
838 | } | ||
839 | |||
840 | ret = rtl28xx_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); | ||
580 | if (ret) | 841 | if (ret) |
581 | goto err; | 842 | goto err; |
582 | 843 | ||
@@ -586,7 +847,7 @@ err: | |||
586 | return ret; | 847 | return ret; |
587 | } | 848 | } |
588 | 849 | ||
589 | static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | 850 | static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) |
590 | { | 851 | { |
591 | int ret; | 852 | int ret; |
592 | u8 gpio, sys0; | 853 | u8 gpio, sys0; |
@@ -594,12 +855,12 @@ static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
594 | deb_info("%s: onoff=%d\n", __func__, onoff); | 855 | deb_info("%s: onoff=%d\n", __func__, onoff); |
595 | 856 | ||
596 | /* demod adc */ | 857 | /* demod adc */ |
597 | ret = rtl2831_rd_reg(d, SYS_SYS0, &sys0); | 858 | ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0); |
598 | if (ret) | 859 | if (ret) |
599 | goto err; | 860 | goto err; |
600 | 861 | ||
601 | /* tuner power, read GPIOs */ | 862 | /* tuner power, read GPIOs */ |
602 | ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio); | 863 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio); |
603 | if (ret) | 864 | if (ret) |
604 | goto err; | 865 | goto err; |
605 | 866 | ||
@@ -619,12 +880,12 @@ static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
619 | deb_info("%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, sys0, gpio); | 880 | deb_info("%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, sys0, gpio); |
620 | 881 | ||
621 | /* demod adc */ | 882 | /* demod adc */ |
622 | ret = rtl2831_wr_reg(d, SYS_SYS0, sys0); | 883 | ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0); |
623 | if (ret) | 884 | if (ret) |
624 | goto err; | 885 | goto err; |
625 | 886 | ||
626 | /* tuner power, write GPIOs */ | 887 | /* tuner power, write GPIOs */ |
627 | ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, gpio); | 888 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio); |
628 | if (ret) | 889 | if (ret) |
629 | goto err; | 890 | goto err; |
630 | 891 | ||
@@ -634,6 +895,128 @@ err: | |||
634 | return ret; | 895 | return ret; |
635 | } | 896 | } |
636 | 897 | ||
898 | static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
899 | { | ||
900 | int ret; | ||
901 | u8 val; | ||
902 | |||
903 | deb_info("%s: onoff=%d\n", __func__, onoff); | ||
904 | |||
905 | if (onoff) { | ||
906 | /* set output values */ | ||
907 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
908 | if (ret) | ||
909 | goto err; | ||
910 | |||
911 | val |= 0x08; | ||
912 | val &= 0xef; | ||
913 | |||
914 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
915 | if (ret) | ||
916 | goto err; | ||
917 | |||
918 | /* demod_ctl_1 */ | ||
919 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); | ||
920 | if (ret) | ||
921 | goto err; | ||
922 | |||
923 | val &= 0xef; | ||
924 | |||
925 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); | ||
926 | if (ret) | ||
927 | goto err; | ||
928 | |||
929 | /* demod control */ | ||
930 | /* PLL enable */ | ||
931 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
932 | if (ret) | ||
933 | goto err; | ||
934 | |||
935 | /* bit 7 to 1 */ | ||
936 | val |= 0x80; | ||
937 | |||
938 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
939 | if (ret) | ||
940 | goto err; | ||
941 | |||
942 | /* demod HW reset */ | ||
943 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
944 | if (ret) | ||
945 | goto err; | ||
946 | /* bit 5 to 0 */ | ||
947 | val &= 0xdf; | ||
948 | |||
949 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
950 | if (ret) | ||
951 | goto err; | ||
952 | |||
953 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
954 | if (ret) | ||
955 | goto err; | ||
956 | |||
957 | val |= 0x20; | ||
958 | |||
959 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
960 | if (ret) | ||
961 | goto err; | ||
962 | |||
963 | mdelay(5); | ||
964 | |||
965 | /*enable ADC_Q and ADC_I */ | ||
966 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
967 | if (ret) | ||
968 | goto err; | ||
969 | |||
970 | val |= 0x48; | ||
971 | |||
972 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
973 | if (ret) | ||
974 | goto err; | ||
975 | |||
976 | |||
977 | } else { | ||
978 | /* demod_ctl_1 */ | ||
979 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); | ||
980 | if (ret) | ||
981 | goto err; | ||
982 | |||
983 | val |= 0x0c; | ||
984 | |||
985 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); | ||
986 | if (ret) | ||
987 | goto err; | ||
988 | |||
989 | /* set output values */ | ||
990 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
991 | if (ret) | ||
992 | goto err; | ||
993 | |||
994 | val |= 0x10; | ||
995 | |||
996 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
997 | if (ret) | ||
998 | goto err; | ||
999 | |||
1000 | /* demod control */ | ||
1001 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
1002 | if (ret) | ||
1003 | goto err; | ||
1004 | |||
1005 | val &= 0x37; | ||
1006 | |||
1007 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
1008 | if (ret) | ||
1009 | goto err; | ||
1010 | |||
1011 | } | ||
1012 | |||
1013 | return ret; | ||
1014 | err: | ||
1015 | deb_info("%s: failed=%d\n", __func__, ret); | ||
1016 | return ret; | ||
1017 | } | ||
1018 | |||
1019 | |||
637 | static int rtl2831u_rc_query(struct dvb_usb_device *d) | 1020 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
638 | { | 1021 | { |
639 | int ret, i; | 1022 | int ret, i; |
@@ -660,7 +1043,7 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) | |||
660 | /* init remote controller */ | 1043 | /* init remote controller */ |
661 | if (!priv->rc_active) { | 1044 | if (!priv->rc_active) { |
662 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { | 1045 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
663 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, | 1046 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
664 | rc_nec_tab[i].val); | 1047 | rc_nec_tab[i].val); |
665 | if (ret) | 1048 | if (ret) |
666 | goto err; | 1049 | goto err; |
@@ -690,12 +1073,12 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) | |||
690 | 1073 | ||
691 | rc_keydown(d->rc_dev, rc_code, 0); | 1074 | rc_keydown(d->rc_dev, rc_code, 0); |
692 | 1075 | ||
693 | ret = rtl2831_wr_reg(d, SYS_IRRC_SR, 1); | 1076 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
694 | if (ret) | 1077 | if (ret) |
695 | goto err; | 1078 | goto err; |
696 | 1079 | ||
697 | /* repeated intentionally to avoid extra keypress */ | 1080 | /* repeated intentionally to avoid extra keypress */ |
698 | ret = rtl2831_wr_reg(d, SYS_IRRC_SR, 1); | 1081 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
699 | if (ret) | 1082 | if (ret) |
700 | goto err; | 1083 | goto err; |
701 | } | 1084 | } |
@@ -732,7 +1115,7 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
732 | /* init remote controller */ | 1115 | /* init remote controller */ |
733 | if (!priv->rc_active) { | 1116 | if (!priv->rc_active) { |
734 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { | 1117 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
735 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, | 1118 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
736 | rc_nec_tab[i].val); | 1119 | rc_nec_tab[i].val); |
737 | if (ret) | 1120 | if (ret) |
738 | goto err; | 1121 | goto err; |
@@ -740,14 +1123,14 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
740 | priv->rc_active = true; | 1123 | priv->rc_active = true; |
741 | } | 1124 | } |
742 | 1125 | ||
743 | ret = rtl2831_rd_reg(d, IR_RX_IF, &buf[0]); | 1126 | ret = rtl28xx_rd_reg(d, IR_RX_IF, &buf[0]); |
744 | if (ret) | 1127 | if (ret) |
745 | goto err; | 1128 | goto err; |
746 | 1129 | ||
747 | if (buf[0] != 0x83) | 1130 | if (buf[0] != 0x83) |
748 | goto exit; | 1131 | goto exit; |
749 | 1132 | ||
750 | ret = rtl2831_rd_reg(d, IR_RX_BC, &buf[0]); | 1133 | ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]); |
751 | if (ret) | 1134 | if (ret) |
752 | goto err; | 1135 | goto err; |
753 | 1136 | ||
@@ -756,9 +1139,9 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
756 | 1139 | ||
757 | /* TODO: pass raw IR to Kernel IR decoder */ | 1140 | /* TODO: pass raw IR to Kernel IR decoder */ |
758 | 1141 | ||
759 | ret = rtl2831_wr_reg(d, IR_RX_IF, 0x03); | 1142 | ret = rtl28xx_wr_reg(d, IR_RX_IF, 0x03); |
760 | ret = rtl2831_wr_reg(d, IR_RX_BUF_CTRL, 0x80); | 1143 | ret = rtl28xx_wr_reg(d, IR_RX_BUF_CTRL, 0x80); |
761 | ret = rtl2831_wr_reg(d, IR_RX_CTRL, 0x80); | 1144 | ret = rtl28xx_wr_reg(d, IR_RX_CTRL, 0x80); |
762 | 1145 | ||
763 | exit: | 1146 | exit: |
764 | return ret; | 1147 | return ret; |
@@ -771,6 +1154,9 @@ enum rtl28xxu_usb_table_entry { | |||
771 | RTL2831U_0BDA_2831, | 1154 | RTL2831U_0BDA_2831, |
772 | RTL2831U_14AA_0160, | 1155 | RTL2831U_14AA_0160, |
773 | RTL2831U_14AA_0161, | 1156 | RTL2831U_14AA_0161, |
1157 | RTL2832U_0CCD_00A9, | ||
1158 | RTL2832U_1F4D_B803, | ||
1159 | RTL2832U_0CCD_00B3, | ||
774 | }; | 1160 | }; |
775 | 1161 | ||
776 | static struct usb_device_id rtl28xxu_table[] = { | 1162 | static struct usb_device_id rtl28xxu_table[] = { |
@@ -783,6 +1169,12 @@ static struct usb_device_id rtl28xxu_table[] = { | |||
783 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2)}, | 1169 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2)}, |
784 | 1170 | ||
785 | /* RTL2832U */ | 1171 | /* RTL2832U */ |
1172 | [RTL2832U_0CCD_00A9] = { | ||
1173 | USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, | ||
1174 | [RTL2832U_1F4D_B803] = { | ||
1175 | USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT)}, | ||
1176 | [RTL2832U_0CCD_00B3] = { | ||
1177 | USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK)}, | ||
786 | {} /* terminating entry */ | 1178 | {} /* terminating entry */ |
787 | }; | 1179 | }; |
788 | 1180 | ||
@@ -805,7 +1197,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
805 | { | 1197 | { |
806 | .frontend_attach = rtl2831u_frontend_attach, | 1198 | .frontend_attach = rtl2831u_frontend_attach, |
807 | .tuner_attach = rtl2831u_tuner_attach, | 1199 | .tuner_attach = rtl2831u_tuner_attach, |
808 | .streaming_ctrl = rtl28xxu_streaming_ctrl, | 1200 | .streaming_ctrl = rtl2831u_streaming_ctrl, |
809 | .stream = { | 1201 | .stream = { |
810 | .type = USB_BULK, | 1202 | .type = USB_BULK, |
811 | .count = 6, | 1203 | .count = 6, |
@@ -821,7 +1213,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
821 | } | 1213 | } |
822 | }, | 1214 | }, |
823 | 1215 | ||
824 | .power_ctrl = rtl28xxu_power_ctrl, | 1216 | .power_ctrl = rtl2831u_power_ctrl, |
825 | 1217 | ||
826 | .rc.core = { | 1218 | .rc.core = { |
827 | .protocol = RC_TYPE_NEC, | 1219 | .protocol = RC_TYPE_NEC, |
@@ -867,7 +1259,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
867 | { | 1259 | { |
868 | .frontend_attach = rtl2832u_frontend_attach, | 1260 | .frontend_attach = rtl2832u_frontend_attach, |
869 | .tuner_attach = rtl2832u_tuner_attach, | 1261 | .tuner_attach = rtl2832u_tuner_attach, |
870 | .streaming_ctrl = rtl28xxu_streaming_ctrl, | 1262 | .streaming_ctrl = rtl2832u_streaming_ctrl, |
871 | .stream = { | 1263 | .stream = { |
872 | .type = USB_BULK, | 1264 | .type = USB_BULK, |
873 | .count = 6, | 1265 | .count = 6, |
@@ -883,7 +1275,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
883 | } | 1275 | } |
884 | }, | 1276 | }, |
885 | 1277 | ||
886 | .power_ctrl = rtl28xxu_power_ctrl, | 1278 | .power_ctrl = rtl2832u_power_ctrl, |
887 | 1279 | ||
888 | .rc.core = { | 1280 | .rc.core = { |
889 | .protocol = RC_TYPE_NEC, | 1281 | .protocol = RC_TYPE_NEC, |
@@ -896,10 +1288,25 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
896 | 1288 | ||
897 | .i2c_algo = &rtl28xxu_i2c_algo, | 1289 | .i2c_algo = &rtl28xxu_i2c_algo, |
898 | 1290 | ||
899 | .num_device_descs = 0, /* disabled as no support for RTL2832 */ | 1291 | .num_device_descs = 3, |
900 | .devices = { | 1292 | .devices = { |
901 | { | 1293 | { |
902 | .name = "Realtek RTL2832U reference design", | 1294 | .name = "Terratec Cinergy T Stick Black", |
1295 | .warm_ids = { | ||
1296 | &rtl28xxu_table[RTL2832U_0CCD_00A9], | ||
1297 | }, | ||
1298 | }, | ||
1299 | { | ||
1300 | .name = "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", | ||
1301 | .warm_ids = { | ||
1302 | &rtl28xxu_table[RTL2832U_1F4D_B803], | ||
1303 | }, | ||
1304 | }, | ||
1305 | { | ||
1306 | .name = "NOXON DAB/DAB+ USB dongle", | ||
1307 | .warm_ids = { | ||
1308 | &rtl28xxu_table[RTL2832U_0CCD_00B3], | ||
1309 | }, | ||
903 | }, | 1310 | }, |
904 | } | 1311 | } |
905 | }, | 1312 | }, |
@@ -910,6 +1317,7 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
910 | const struct usb_device_id *id) | 1317 | const struct usb_device_id *id) |
911 | { | 1318 | { |
912 | int ret, i; | 1319 | int ret, i; |
1320 | u8 val; | ||
913 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); | 1321 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); |
914 | struct dvb_usb_device *d; | 1322 | struct dvb_usb_device *d; |
915 | struct usb_device *udev; | 1323 | struct usb_device *udev; |
@@ -954,16 +1362,25 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
954 | if (ret) | 1362 | if (ret) |
955 | goto err; | 1363 | goto err; |
956 | 1364 | ||
1365 | |||
957 | /* init USB endpoints */ | 1366 | /* init USB endpoints */ |
958 | ret = rtl2831_wr_reg(d, USB_SYSCTL_0, 0x09); | 1367 | ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val); |
1368 | if (ret) | ||
1369 | goto err; | ||
1370 | |||
1371 | /* enable DMA and Full Packet Mode*/ | ||
1372 | val |= 0x09; | ||
1373 | ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val); | ||
959 | if (ret) | 1374 | if (ret) |
960 | goto err; | 1375 | goto err; |
961 | 1376 | ||
962 | ret = rtl2831_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); | 1377 | /* set EPA maximum packet size to 0x0200 */ |
1378 | ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); | ||
963 | if (ret) | 1379 | if (ret) |
964 | goto err; | 1380 | goto err; |
965 | 1381 | ||
966 | ret = rtl2831_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); | 1382 | /* change EPA FIFO length */ |
1383 | ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); | ||
967 | if (ret) | 1384 | if (ret) |
968 | goto err; | 1385 | goto err; |
969 | 1386 | ||
@@ -1007,4 +1424,5 @@ module_exit(rtl28xxu_module_exit); | |||
1007 | 1424 | ||
1008 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); | 1425 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); |
1009 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | 1426 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
1427 | MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>"); | ||
1010 | MODULE_LICENSE("GPL"); | 1428 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index b98ebb264e29..a08c2152d0ee 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config DVB_FE_CUSTOMISE | 1 | config DVB_FE_CUSTOMISE |
2 | bool "Customise the frontend modules to build" | 2 | bool "Customise the frontend modules to build" |
3 | depends on DVB_CORE | 3 | depends on DVB_CORE |
4 | depends on EXPERT | ||
4 | default y if EXPERT | 5 | default y if EXPERT |
5 | help | 6 | help |
6 | This allows the user to select/deselect frontend drivers for their | 7 | This allows the user to select/deselect frontend drivers for their |
@@ -432,6 +433,13 @@ config DVB_RTL2830 | |||
432 | help | 433 | help |
433 | Say Y when you want to support this frontend. | 434 | Say Y when you want to support this frontend. |
434 | 435 | ||
436 | config DVB_RTL2832 | ||
437 | tristate "Realtek RTL2832 DVB-T" | ||
438 | depends on DVB_CORE && I2C | ||
439 | default m if DVB_FE_CUSTOMISE | ||
440 | help | ||
441 | Say Y when you want to support this frontend. | ||
442 | |||
435 | comment "DVB-C (cable) frontends" | 443 | comment "DVB-C (cable) frontends" |
436 | depends on DVB_CORE | 444 | depends on DVB_CORE |
437 | 445 | ||
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index cd1ac2fd5774..185bb8b51952 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
@@ -99,6 +99,7 @@ obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o | |||
99 | obj-$(CONFIG_DVB_A8293) += a8293.o | 99 | obj-$(CONFIG_DVB_A8293) += a8293.o |
100 | obj-$(CONFIG_DVB_TDA10071) += tda10071.o | 100 | obj-$(CONFIG_DVB_TDA10071) += tda10071.o |
101 | obj-$(CONFIG_DVB_RTL2830) += rtl2830.o | 101 | obj-$(CONFIG_DVB_RTL2830) += rtl2830.o |
102 | obj-$(CONFIG_DVB_RTL2832) += rtl2832.o | ||
102 | obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o | 103 | obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o |
103 | obj-$(CONFIG_DVB_AF9033) += af9033.o | 104 | obj-$(CONFIG_DVB_AF9033) += af9033.o |
104 | 105 | ||
diff --git a/drivers/media/dvb/frontends/a8293.c b/drivers/media/dvb/frontends/a8293.c index bb56497e940a..cff44a389b40 100644 --- a/drivers/media/dvb/frontends/a8293.c +++ b/drivers/media/dvb/frontends/a8293.c | |||
@@ -21,24 +21,6 @@ | |||
21 | #include "dvb_frontend.h" | 21 | #include "dvb_frontend.h" |
22 | #include "a8293.h" | 22 | #include "a8293.h" |
23 | 23 | ||
24 | static int debug; | ||
25 | module_param(debug, int, 0644); | ||
26 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | ||
27 | |||
28 | #define LOG_PREFIX "a8293" | ||
29 | |||
30 | #undef dbg | ||
31 | #define dbg(f, arg...) \ | ||
32 | if (debug) \ | ||
33 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
34 | #undef err | ||
35 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) | ||
36 | #undef info | ||
37 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
38 | #undef warn | ||
39 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) | ||
40 | |||
41 | |||
42 | struct a8293_priv { | 24 | struct a8293_priv { |
43 | struct i2c_adapter *i2c; | 25 | struct i2c_adapter *i2c; |
44 | const struct a8293_config *cfg; | 26 | const struct a8293_config *cfg; |
@@ -65,7 +47,8 @@ static int a8293_i2c(struct a8293_priv *priv, u8 *val, int len, bool rd) | |||
65 | if (ret == 1) { | 47 | if (ret == 1) { |
66 | ret = 0; | 48 | ret = 0; |
67 | } else { | 49 | } else { |
68 | warn("i2c failed=%d rd=%d", ret, rd); | 50 | dev_warn(&priv->i2c->dev, "%s: i2c failed=%d rd=%d\n", |
51 | KBUILD_MODNAME, ret, rd); | ||
69 | ret = -EREMOTEIO; | 52 | ret = -EREMOTEIO; |
70 | } | 53 | } |
71 | 54 | ||
@@ -88,7 +71,8 @@ static int a8293_set_voltage(struct dvb_frontend *fe, | |||
88 | struct a8293_priv *priv = fe->sec_priv; | 71 | struct a8293_priv *priv = fe->sec_priv; |
89 | int ret; | 72 | int ret; |
90 | 73 | ||
91 | dbg("%s: fe_sec_voltage=%d", __func__, fe_sec_voltage); | 74 | dev_dbg(&priv->i2c->dev, "%s: fe_sec_voltage=%d\n", __func__, |
75 | fe_sec_voltage); | ||
92 | 76 | ||
93 | switch (fe_sec_voltage) { | 77 | switch (fe_sec_voltage) { |
94 | case SEC_VOLTAGE_OFF: | 78 | case SEC_VOLTAGE_OFF: |
@@ -114,14 +98,12 @@ static int a8293_set_voltage(struct dvb_frontend *fe, | |||
114 | 98 | ||
115 | return ret; | 99 | return ret; |
116 | err: | 100 | err: |
117 | dbg("%s: failed=%d", __func__, ret); | 101 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
118 | return ret; | 102 | return ret; |
119 | } | 103 | } |
120 | 104 | ||
121 | static void a8293_release_sec(struct dvb_frontend *fe) | 105 | static void a8293_release_sec(struct dvb_frontend *fe) |
122 | { | 106 | { |
123 | dbg("%s:", __func__); | ||
124 | |||
125 | a8293_set_voltage(fe, SEC_VOLTAGE_OFF); | 107 | a8293_set_voltage(fe, SEC_VOLTAGE_OFF); |
126 | 108 | ||
127 | kfree(fe->sec_priv); | 109 | kfree(fe->sec_priv); |
@@ -154,7 +136,7 @@ struct dvb_frontend *a8293_attach(struct dvb_frontend *fe, | |||
154 | 136 | ||
155 | /* ENB=0 */ | 137 | /* ENB=0 */ |
156 | priv->reg[0] = 0x10; | 138 | priv->reg[0] = 0x10; |
157 | ret = a8293_wr(priv, &priv->reg[1], 1); | 139 | ret = a8293_wr(priv, &priv->reg[0], 1); |
158 | if (ret) | 140 | if (ret) |
159 | goto err; | 141 | goto err; |
160 | 142 | ||
@@ -164,16 +146,17 @@ struct dvb_frontend *a8293_attach(struct dvb_frontend *fe, | |||
164 | if (ret) | 146 | if (ret) |
165 | goto err; | 147 | goto err; |
166 | 148 | ||
167 | info("Allegro A8293 SEC attached."); | ||
168 | |||
169 | fe->ops.release_sec = a8293_release_sec; | 149 | fe->ops.release_sec = a8293_release_sec; |
170 | 150 | ||
171 | /* override frontend ops */ | 151 | /* override frontend ops */ |
172 | fe->ops.set_voltage = a8293_set_voltage; | 152 | fe->ops.set_voltage = a8293_set_voltage; |
173 | 153 | ||
154 | dev_info(&priv->i2c->dev, "%s: Allegro A8293 SEC attached\n", | ||
155 | KBUILD_MODNAME); | ||
156 | |||
174 | return fe; | 157 | return fe; |
175 | err: | 158 | err: |
176 | dbg("%s: failed=%d", __func__, ret); | 159 | dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); |
177 | kfree(priv); | 160 | kfree(priv); |
178 | return NULL; | 161 | return NULL; |
179 | } | 162 | } |
diff --git a/drivers/media/dvb/frontends/drxk.h b/drivers/media/dvb/frontends/drxk.h index 9d64e4fea066..d615d7d055a2 100644 --- a/drivers/media/dvb/frontends/drxk.h +++ b/drivers/media/dvb/frontends/drxk.h | |||
@@ -20,6 +20,14 @@ | |||
20 | * means that 1=DVBC, 0 = DVBT. Zero means the opposite. | 20 | * means that 1=DVBC, 0 = DVBT. Zero means the opposite. |
21 | * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength. | 21 | * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength. |
22 | * @microcode_name: Name of the firmware file with the microcode | 22 | * @microcode_name: Name of the firmware file with the microcode |
23 | * @qam_demod_parameter_count: The number of parameters used for the command | ||
24 | * to set the demodulator parameters. All | ||
25 | * firmwares are using the 2-parameter commmand. | ||
26 | * An exception is the "drxk_a3.mc" firmware, | ||
27 | * which uses the 4-parameter command. | ||
28 | * A value of 0 (default) or lower indicates that | ||
29 | * the correct number of parameters will be | ||
30 | * automatically detected. | ||
23 | * | 31 | * |
24 | * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is | 32 | * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is |
25 | * UIO-3. | 33 | * UIO-3. |
@@ -38,7 +46,8 @@ struct drxk_config { | |||
38 | u8 mpeg_out_clk_strength; | 46 | u8 mpeg_out_clk_strength; |
39 | int chunk_size; | 47 | int chunk_size; |
40 | 48 | ||
41 | const char *microcode_name; | 49 | const char *microcode_name; |
50 | int qam_demod_parameter_count; | ||
42 | }; | 51 | }; |
43 | 52 | ||
44 | #if defined(CONFIG_DVB_DRXK) || (defined(CONFIG_DVB_DRXK_MODULE) \ | 53 | #if defined(CONFIG_DVB_DRXK) || (defined(CONFIG_DVB_DRXK_MODULE) \ |
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c index 60b868faeacf..1ab8154542da 100644 --- a/drivers/media/dvb/frontends/drxk_hard.c +++ b/drivers/media/dvb/frontends/drxk_hard.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/firmware.h> | 29 | #include <linux/firmware.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/hardirq.h> | ||
31 | #include <asm/div64.h> | 32 | #include <asm/div64.h> |
32 | 33 | ||
33 | #include "dvb_frontend.h" | 34 | #include "dvb_frontend.h" |
@@ -308,16 +309,42 @@ static u32 Log10Times100(u32 x) | |||
308 | /* I2C **********************************************************************/ | 309 | /* I2C **********************************************************************/ |
309 | /****************************************************************************/ | 310 | /****************************************************************************/ |
310 | 311 | ||
311 | static int i2c_read1(struct i2c_adapter *adapter, u8 adr, u8 *val) | 312 | static int drxk_i2c_lock(struct drxk_state *state) |
313 | { | ||
314 | i2c_lock_adapter(state->i2c); | ||
315 | state->drxk_i2c_exclusive_lock = true; | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | static void drxk_i2c_unlock(struct drxk_state *state) | ||
321 | { | ||
322 | if (!state->drxk_i2c_exclusive_lock) | ||
323 | return; | ||
324 | |||
325 | i2c_unlock_adapter(state->i2c); | ||
326 | state->drxk_i2c_exclusive_lock = false; | ||
327 | } | ||
328 | |||
329 | static int drxk_i2c_transfer(struct drxk_state *state, struct i2c_msg *msgs, | ||
330 | unsigned len) | ||
331 | { | ||
332 | if (state->drxk_i2c_exclusive_lock) | ||
333 | return __i2c_transfer(state->i2c, msgs, len); | ||
334 | else | ||
335 | return i2c_transfer(state->i2c, msgs, len); | ||
336 | } | ||
337 | |||
338 | static int i2c_read1(struct drxk_state *state, u8 adr, u8 *val) | ||
312 | { | 339 | { |
313 | struct i2c_msg msgs[1] = { {.addr = adr, .flags = I2C_M_RD, | 340 | struct i2c_msg msgs[1] = { {.addr = adr, .flags = I2C_M_RD, |
314 | .buf = val, .len = 1} | 341 | .buf = val, .len = 1} |
315 | }; | 342 | }; |
316 | 343 | ||
317 | return i2c_transfer(adapter, msgs, 1); | 344 | return drxk_i2c_transfer(state, msgs, 1); |
318 | } | 345 | } |
319 | 346 | ||
320 | static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) | 347 | static int i2c_write(struct drxk_state *state, u8 adr, u8 *data, int len) |
321 | { | 348 | { |
322 | int status; | 349 | int status; |
323 | struct i2c_msg msg = { | 350 | struct i2c_msg msg = { |
@@ -330,7 +357,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) | |||
330 | printk(KERN_CONT " %02x", data[i]); | 357 | printk(KERN_CONT " %02x", data[i]); |
331 | printk(KERN_CONT "\n"); | 358 | printk(KERN_CONT "\n"); |
332 | } | 359 | } |
333 | status = i2c_transfer(adap, &msg, 1); | 360 | status = drxk_i2c_transfer(state, &msg, 1); |
334 | if (status >= 0 && status != 1) | 361 | if (status >= 0 && status != 1) |
335 | status = -EIO; | 362 | status = -EIO; |
336 | 363 | ||
@@ -340,7 +367,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) | |||
340 | return status; | 367 | return status; |
341 | } | 368 | } |
342 | 369 | ||
343 | static int i2c_read(struct i2c_adapter *adap, | 370 | static int i2c_read(struct drxk_state *state, |
344 | u8 adr, u8 *msg, int len, u8 *answ, int alen) | 371 | u8 adr, u8 *msg, int len, u8 *answ, int alen) |
345 | { | 372 | { |
346 | int status; | 373 | int status; |
@@ -351,7 +378,7 @@ static int i2c_read(struct i2c_adapter *adap, | |||
351 | .buf = answ, .len = alen} | 378 | .buf = answ, .len = alen} |
352 | }; | 379 | }; |
353 | 380 | ||
354 | status = i2c_transfer(adap, msgs, 2); | 381 | status = drxk_i2c_transfer(state, msgs, 2); |
355 | if (status != 2) { | 382 | if (status != 2) { |
356 | if (debug > 2) | 383 | if (debug > 2) |
357 | printk(KERN_CONT ": ERROR!\n"); | 384 | printk(KERN_CONT ": ERROR!\n"); |
@@ -394,7 +421,7 @@ static int read16_flags(struct drxk_state *state, u32 reg, u16 *data, u8 flags) | |||
394 | len = 2; | 421 | len = 2; |
395 | } | 422 | } |
396 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); | 423 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); |
397 | status = i2c_read(state->i2c, adr, mm1, len, mm2, 2); | 424 | status = i2c_read(state, adr, mm1, len, mm2, 2); |
398 | if (status < 0) | 425 | if (status < 0) |
399 | return status; | 426 | return status; |
400 | if (data) | 427 | if (data) |
@@ -428,7 +455,7 @@ static int read32_flags(struct drxk_state *state, u32 reg, u32 *data, u8 flags) | |||
428 | len = 2; | 455 | len = 2; |
429 | } | 456 | } |
430 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); | 457 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); |
431 | status = i2c_read(state->i2c, adr, mm1, len, mm2, 4); | 458 | status = i2c_read(state, adr, mm1, len, mm2, 4); |
432 | if (status < 0) | 459 | if (status < 0) |
433 | return status; | 460 | return status; |
434 | if (data) | 461 | if (data) |
@@ -464,7 +491,7 @@ static int write16_flags(struct drxk_state *state, u32 reg, u16 data, u8 flags) | |||
464 | mm[len + 1] = (data >> 8) & 0xff; | 491 | mm[len + 1] = (data >> 8) & 0xff; |
465 | 492 | ||
466 | dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags); | 493 | dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags); |
467 | return i2c_write(state->i2c, adr, mm, len + 2); | 494 | return i2c_write(state, adr, mm, len + 2); |
468 | } | 495 | } |
469 | 496 | ||
470 | static int write16(struct drxk_state *state, u32 reg, u16 data) | 497 | static int write16(struct drxk_state *state, u32 reg, u16 data) |
@@ -495,7 +522,7 @@ static int write32_flags(struct drxk_state *state, u32 reg, u32 data, u8 flags) | |||
495 | mm[len + 3] = (data >> 24) & 0xff; | 522 | mm[len + 3] = (data >> 24) & 0xff; |
496 | dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags); | 523 | dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags); |
497 | 524 | ||
498 | return i2c_write(state->i2c, adr, mm, len + 4); | 525 | return i2c_write(state, adr, mm, len + 4); |
499 | } | 526 | } |
500 | 527 | ||
501 | static int write32(struct drxk_state *state, u32 reg, u32 data) | 528 | static int write32(struct drxk_state *state, u32 reg, u32 data) |
@@ -542,7 +569,7 @@ static int write_block(struct drxk_state *state, u32 Address, | |||
542 | printk(KERN_CONT " %02x", pBlock[i]); | 569 | printk(KERN_CONT " %02x", pBlock[i]); |
543 | printk(KERN_CONT "\n"); | 570 | printk(KERN_CONT "\n"); |
544 | } | 571 | } |
545 | status = i2c_write(state->i2c, state->demod_address, | 572 | status = i2c_write(state, state->demod_address, |
546 | &state->Chunk[0], Chunk + AdrLength); | 573 | &state->Chunk[0], Chunk + AdrLength); |
547 | if (status < 0) { | 574 | if (status < 0) { |
548 | printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", | 575 | printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", |
@@ -568,17 +595,17 @@ int PowerUpDevice(struct drxk_state *state) | |||
568 | 595 | ||
569 | dprintk(1, "\n"); | 596 | dprintk(1, "\n"); |
570 | 597 | ||
571 | status = i2c_read1(state->i2c, state->demod_address, &data); | 598 | status = i2c_read1(state, state->demod_address, &data); |
572 | if (status < 0) { | 599 | if (status < 0) { |
573 | do { | 600 | do { |
574 | data = 0; | 601 | data = 0; |
575 | status = i2c_write(state->i2c, state->demod_address, | 602 | status = i2c_write(state, state->demod_address, |
576 | &data, 1); | 603 | &data, 1); |
577 | msleep(10); | 604 | msleep(10); |
578 | retryCount++; | 605 | retryCount++; |
579 | if (status < 0) | 606 | if (status < 0) |
580 | continue; | 607 | continue; |
581 | status = i2c_read1(state->i2c, state->demod_address, | 608 | status = i2c_read1(state, state->demod_address, |
582 | &data); | 609 | &data); |
583 | } while (status < 0 && | 610 | } while (status < 0 && |
584 | (retryCount < DRXK_MAX_RETRIES_POWERUP)); | 611 | (retryCount < DRXK_MAX_RETRIES_POWERUP)); |
@@ -932,7 +959,7 @@ static int GetDeviceCapabilities(struct drxk_state *state) | |||
932 | if (status < 0) | 959 | if (status < 0) |
933 | goto error; | 960 | goto error; |
934 | 961 | ||
935 | printk(KERN_ERR "drxk: status = 0x%08x\n", sioTopJtagidLo); | 962 | printk(KERN_INFO "drxk: status = 0x%08x\n", sioTopJtagidLo); |
936 | 963 | ||
937 | /* driver 0.9.0 */ | 964 | /* driver 0.9.0 */ |
938 | switch ((sioTopJtagidLo >> 29) & 0xF) { | 965 | switch ((sioTopJtagidLo >> 29) & 0xF) { |
@@ -2824,7 +2851,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge) | |||
2824 | dprintk(1, "\n"); | 2851 | dprintk(1, "\n"); |
2825 | 2852 | ||
2826 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | 2853 | if (state->m_DrxkState == DRXK_UNINITIALIZED) |
2827 | goto error; | 2854 | return 0; |
2828 | if (state->m_DrxkState == DRXK_POWERED_DOWN) | 2855 | if (state->m_DrxkState == DRXK_POWERED_DOWN) |
2829 | goto error; | 2856 | goto error; |
2830 | 2857 | ||
@@ -2977,7 +3004,7 @@ static int ADCSynchronization(struct drxk_state *state) | |||
2977 | status = read16(state, IQM_AF_CLKNEG__A, &clkNeg); | 3004 | status = read16(state, IQM_AF_CLKNEG__A, &clkNeg); |
2978 | if (status < 0) | 3005 | if (status < 0) |
2979 | goto error; | 3006 | goto error; |
2980 | if ((clkNeg | IQM_AF_CLKNEG_CLKNEGDATA__M) == | 3007 | if ((clkNeg & IQM_AF_CLKNEG_CLKNEGDATA__M) == |
2981 | IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS) { | 3008 | IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS) { |
2982 | clkNeg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); | 3009 | clkNeg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); |
2983 | clkNeg |= | 3010 | clkNeg |= |
@@ -5361,7 +5388,7 @@ static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus) | |||
5361 | SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK, 0, NULL, 2, | 5388 | SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK, 0, NULL, 2, |
5362 | Result); | 5389 | Result); |
5363 | if (status < 0) | 5390 | if (status < 0) |
5364 | printk(KERN_ERR "drxk: %s status = %08x\n", __func__, status); | 5391 | printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); |
5365 | 5392 | ||
5366 | if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { | 5393 | if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { |
5367 | /* 0x0000 NOT LOCKED */ | 5394 | /* 0x0000 NOT LOCKED */ |
@@ -5388,12 +5415,67 @@ static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus) | |||
5388 | #define QAM_LOCKRANGE__M 0x10 | 5415 | #define QAM_LOCKRANGE__M 0x10 |
5389 | #define QAM_LOCKRANGE_NORMAL 0x10 | 5416 | #define QAM_LOCKRANGE_NORMAL 0x10 |
5390 | 5417 | ||
5418 | static int QAMDemodulatorCommand(struct drxk_state *state, | ||
5419 | int numberOfParameters) | ||
5420 | { | ||
5421 | int status; | ||
5422 | u16 cmdResult; | ||
5423 | u16 setParamParameters[4] = { 0, 0, 0, 0 }; | ||
5424 | |||
5425 | setParamParameters[0] = state->m_Constellation; /* modulation */ | ||
5426 | setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ | ||
5427 | |||
5428 | if (numberOfParameters == 2) { | ||
5429 | u16 setEnvParameters[1] = { 0 }; | ||
5430 | |||
5431 | if (state->m_OperationMode == OM_QAM_ITU_C) | ||
5432 | setEnvParameters[0] = QAM_TOP_ANNEX_C; | ||
5433 | else | ||
5434 | setEnvParameters[0] = QAM_TOP_ANNEX_A; | ||
5435 | |||
5436 | status = scu_command(state, | ||
5437 | SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, | ||
5438 | 1, setEnvParameters, 1, &cmdResult); | ||
5439 | if (status < 0) | ||
5440 | goto error; | ||
5441 | |||
5442 | status = scu_command(state, | ||
5443 | SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, | ||
5444 | numberOfParameters, setParamParameters, | ||
5445 | 1, &cmdResult); | ||
5446 | } else if (numberOfParameters == 4) { | ||
5447 | if (state->m_OperationMode == OM_QAM_ITU_C) | ||
5448 | setParamParameters[2] = QAM_TOP_ANNEX_C; | ||
5449 | else | ||
5450 | setParamParameters[2] = QAM_TOP_ANNEX_A; | ||
5451 | |||
5452 | setParamParameters[3] |= (QAM_MIRROR_AUTO_ON); | ||
5453 | /* Env parameters */ | ||
5454 | /* check for LOCKRANGE Extented */ | ||
5455 | /* setParamParameters[3] |= QAM_LOCKRANGE_NORMAL; */ | ||
5456 | |||
5457 | status = scu_command(state, | ||
5458 | SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, | ||
5459 | numberOfParameters, setParamParameters, | ||
5460 | 1, &cmdResult); | ||
5461 | } else { | ||
5462 | printk(KERN_WARNING "drxk: Unknown QAM demodulator parameter " | ||
5463 | "count %d\n", numberOfParameters); | ||
5464 | } | ||
5465 | |||
5466 | error: | ||
5467 | if (status < 0) | ||
5468 | printk(KERN_WARNING "drxk: Warning %d on %s\n", | ||
5469 | status, __func__); | ||
5470 | return status; | ||
5471 | } | ||
5472 | |||
5391 | static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, | 5473 | static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, |
5392 | s32 tunerFreqOffset) | 5474 | s32 tunerFreqOffset) |
5393 | { | 5475 | { |
5394 | int status; | 5476 | int status; |
5395 | u16 setParamParameters[4] = { 0, 0, 0, 0 }; | ||
5396 | u16 cmdResult; | 5477 | u16 cmdResult; |
5478 | int qamDemodParamCount = state->qam_demod_parameter_count; | ||
5397 | 5479 | ||
5398 | dprintk(1, "\n"); | 5480 | dprintk(1, "\n"); |
5399 | /* | 5481 | /* |
@@ -5445,34 +5527,42 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, | |||
5445 | } | 5527 | } |
5446 | if (status < 0) | 5528 | if (status < 0) |
5447 | goto error; | 5529 | goto error; |
5448 | setParamParameters[0] = state->m_Constellation; /* modulation */ | ||
5449 | setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ | ||
5450 | if (state->m_OperationMode == OM_QAM_ITU_C) | ||
5451 | setParamParameters[2] = QAM_TOP_ANNEX_C; | ||
5452 | else | ||
5453 | setParamParameters[2] = QAM_TOP_ANNEX_A; | ||
5454 | setParamParameters[3] |= (QAM_MIRROR_AUTO_ON); | ||
5455 | /* Env parameters */ | ||
5456 | /* check for LOCKRANGE Extented */ | ||
5457 | /* setParamParameters[3] |= QAM_LOCKRANGE_NORMAL; */ | ||
5458 | 5530 | ||
5459 | status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, 4, setParamParameters, 1, &cmdResult); | 5531 | /* Use the 4-parameter if it's requested or we're probing for |
5460 | if (status < 0) { | 5532 | * the correct command. */ |
5461 | /* Fall-back to the simpler call */ | 5533 | if (state->qam_demod_parameter_count == 4 |
5462 | if (state->m_OperationMode == OM_QAM_ITU_C) | 5534 | || !state->qam_demod_parameter_count) { |
5463 | setParamParameters[0] = QAM_TOP_ANNEX_C; | 5535 | qamDemodParamCount = 4; |
5464 | else | 5536 | status = QAMDemodulatorCommand(state, qamDemodParamCount); |
5465 | setParamParameters[0] = QAM_TOP_ANNEX_A; | 5537 | } |
5466 | status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, 1, setParamParameters, 1, &cmdResult); | ||
5467 | if (status < 0) | ||
5468 | goto error; | ||
5469 | 5538 | ||
5470 | setParamParameters[0] = state->m_Constellation; /* modulation */ | 5539 | /* Use the 2-parameter command if it was requested or if we're |
5471 | setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ | 5540 | * probing for the correct command and the 4-parameter command |
5472 | status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, 2, setParamParameters, 1, &cmdResult); | 5541 | * failed. */ |
5542 | if (state->qam_demod_parameter_count == 2 | ||
5543 | || (!state->qam_demod_parameter_count && status < 0)) { | ||
5544 | qamDemodParamCount = 2; | ||
5545 | status = QAMDemodulatorCommand(state, qamDemodParamCount); | ||
5473 | } | 5546 | } |
5474 | if (status < 0) | 5547 | |
5548 | if (status < 0) { | ||
5549 | dprintk(1, "Could not set demodulator parameters. Make " | ||
5550 | "sure qam_demod_parameter_count (%d) is correct for " | ||
5551 | "your firmware (%s).\n", | ||
5552 | state->qam_demod_parameter_count, | ||
5553 | state->microcode_name); | ||
5475 | goto error; | 5554 | goto error; |
5555 | } else if (!state->qam_demod_parameter_count) { | ||
5556 | dprintk(1, "Auto-probing the correct QAM demodulator command " | ||
5557 | "parameters was successful - using %d parameters.\n", | ||
5558 | qamDemodParamCount); | ||
5559 | |||
5560 | /* | ||
5561 | * One of our commands was successful. We don't need to | ||
5562 | * auto-probe anymore, now that we got the correct command. | ||
5563 | */ | ||
5564 | state->qam_demod_parameter_count = qamDemodParamCount; | ||
5565 | } | ||
5476 | 5566 | ||
5477 | /* | 5567 | /* |
5478 | * STEP 3: enable the system in a mode where the ADC provides valid | 5568 | * STEP 3: enable the system in a mode where the ADC provides valid |
@@ -5968,34 +6058,15 @@ error: | |||
5968 | return status; | 6058 | return status; |
5969 | } | 6059 | } |
5970 | 6060 | ||
5971 | static int load_microcode(struct drxk_state *state, const char *mc_name) | ||
5972 | { | ||
5973 | const struct firmware *fw = NULL; | ||
5974 | int err = 0; | ||
5975 | |||
5976 | dprintk(1, "\n"); | ||
5977 | |||
5978 | err = request_firmware(&fw, mc_name, state->i2c->dev.parent); | ||
5979 | if (err < 0) { | ||
5980 | printk(KERN_ERR | ||
5981 | "drxk: Could not load firmware file %s.\n", mc_name); | ||
5982 | printk(KERN_INFO | ||
5983 | "drxk: Copy %s to your hotplug directory!\n", mc_name); | ||
5984 | return err; | ||
5985 | } | ||
5986 | err = DownloadMicrocode(state, fw->data, fw->size); | ||
5987 | release_firmware(fw); | ||
5988 | return err; | ||
5989 | } | ||
5990 | |||
5991 | static int init_drxk(struct drxk_state *state) | 6061 | static int init_drxk(struct drxk_state *state) |
5992 | { | 6062 | { |
5993 | int status = 0; | 6063 | int status = 0, n = 0; |
5994 | enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; | 6064 | enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; |
5995 | u16 driverVersion; | 6065 | u16 driverVersion; |
5996 | 6066 | ||
5997 | dprintk(1, "\n"); | 6067 | dprintk(1, "\n"); |
5998 | if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { | 6068 | if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { |
6069 | drxk_i2c_lock(state); | ||
5999 | status = PowerUpDevice(state); | 6070 | status = PowerUpDevice(state); |
6000 | if (status < 0) | 6071 | if (status < 0) |
6001 | goto error; | 6072 | goto error; |
@@ -6073,8 +6144,12 @@ static int init_drxk(struct drxk_state *state) | |||
6073 | if (status < 0) | 6144 | if (status < 0) |
6074 | goto error; | 6145 | goto error; |
6075 | 6146 | ||
6076 | if (state->microcode_name) | 6147 | if (state->fw) { |
6077 | load_microcode(state, state->microcode_name); | 6148 | status = DownloadMicrocode(state, state->fw->data, |
6149 | state->fw->size); | ||
6150 | if (status < 0) | ||
6151 | goto error; | ||
6152 | } | ||
6078 | 6153 | ||
6079 | /* disable token-ring bus through OFDM block for possible ucode upload */ | 6154 | /* disable token-ring bus through OFDM block for possible ucode upload */ |
6080 | status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, SIO_OFDM_SH_OFDM_RING_ENABLE_OFF); | 6155 | status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, SIO_OFDM_SH_OFDM_RING_ENABLE_OFF); |
@@ -6167,19 +6242,71 @@ static int init_drxk(struct drxk_state *state) | |||
6167 | state->m_DrxkState = DRXK_POWERED_DOWN; | 6242 | state->m_DrxkState = DRXK_POWERED_DOWN; |
6168 | } else | 6243 | } else |
6169 | state->m_DrxkState = DRXK_STOPPED; | 6244 | state->m_DrxkState = DRXK_STOPPED; |
6245 | |||
6246 | /* Initialize the supported delivery systems */ | ||
6247 | n = 0; | ||
6248 | if (state->m_hasDVBC) { | ||
6249 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A; | ||
6250 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_C; | ||
6251 | strlcat(state->frontend.ops.info.name, " DVB-C", | ||
6252 | sizeof(state->frontend.ops.info.name)); | ||
6253 | } | ||
6254 | if (state->m_hasDVBT) { | ||
6255 | state->frontend.ops.delsys[n++] = SYS_DVBT; | ||
6256 | strlcat(state->frontend.ops.info.name, " DVB-T", | ||
6257 | sizeof(state->frontend.ops.info.name)); | ||
6258 | } | ||
6259 | drxk_i2c_unlock(state); | ||
6170 | } | 6260 | } |
6171 | error: | 6261 | error: |
6172 | if (status < 0) | 6262 | if (status < 0) { |
6263 | state->m_DrxkState = DRXK_NO_DEV; | ||
6264 | drxk_i2c_unlock(state); | ||
6173 | printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); | 6265 | printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); |
6266 | } | ||
6174 | 6267 | ||
6175 | return status; | 6268 | return status; |
6176 | } | 6269 | } |
6177 | 6270 | ||
6271 | static void load_firmware_cb(const struct firmware *fw, | ||
6272 | void *context) | ||
6273 | { | ||
6274 | struct drxk_state *state = context; | ||
6275 | |||
6276 | dprintk(1, ": %s\n", fw ? "firmware loaded" : "firmware not loaded"); | ||
6277 | if (!fw) { | ||
6278 | printk(KERN_ERR | ||
6279 | "drxk: Could not load firmware file %s.\n", | ||
6280 | state->microcode_name); | ||
6281 | printk(KERN_INFO | ||
6282 | "drxk: Copy %s to your hotplug directory!\n", | ||
6283 | state->microcode_name); | ||
6284 | state->microcode_name = NULL; | ||
6285 | |||
6286 | /* | ||
6287 | * As firmware is now load asynchronous, it is not possible | ||
6288 | * anymore to fail at frontend attach. We might silently | ||
6289 | * return here, and hope that the driver won't crash. | ||
6290 | * We might also change all DVB callbacks to return -ENODEV | ||
6291 | * if the device is not initialized. | ||
6292 | * As the DRX-K devices have their own internal firmware, | ||
6293 | * let's just hope that it will match a firmware revision | ||
6294 | * compatible with this driver and proceed. | ||
6295 | */ | ||
6296 | } | ||
6297 | state->fw = fw; | ||
6298 | |||
6299 | init_drxk(state); | ||
6300 | } | ||
6301 | |||
6178 | static void drxk_release(struct dvb_frontend *fe) | 6302 | static void drxk_release(struct dvb_frontend *fe) |
6179 | { | 6303 | { |
6180 | struct drxk_state *state = fe->demodulator_priv; | 6304 | struct drxk_state *state = fe->demodulator_priv; |
6181 | 6305 | ||
6182 | dprintk(1, "\n"); | 6306 | dprintk(1, "\n"); |
6307 | if (state->fw) | ||
6308 | release_firmware(state->fw); | ||
6309 | |||
6183 | kfree(state); | 6310 | kfree(state); |
6184 | } | 6311 | } |
6185 | 6312 | ||
@@ -6188,6 +6315,12 @@ static int drxk_sleep(struct dvb_frontend *fe) | |||
6188 | struct drxk_state *state = fe->demodulator_priv; | 6315 | struct drxk_state *state = fe->demodulator_priv; |
6189 | 6316 | ||
6190 | dprintk(1, "\n"); | 6317 | dprintk(1, "\n"); |
6318 | |||
6319 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6320 | return -ENODEV; | ||
6321 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6322 | return 0; | ||
6323 | |||
6191 | ShutDown(state); | 6324 | ShutDown(state); |
6192 | return 0; | 6325 | return 0; |
6193 | } | 6326 | } |
@@ -6196,7 +6329,11 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) | |||
6196 | { | 6329 | { |
6197 | struct drxk_state *state = fe->demodulator_priv; | 6330 | struct drxk_state *state = fe->demodulator_priv; |
6198 | 6331 | ||
6199 | dprintk(1, "%s\n", enable ? "enable" : "disable"); | 6332 | dprintk(1, ": %s\n", enable ? "enable" : "disable"); |
6333 | |||
6334 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6335 | return -ENODEV; | ||
6336 | |||
6200 | return ConfigureI2CBridge(state, enable ? true : false); | 6337 | return ConfigureI2CBridge(state, enable ? true : false); |
6201 | } | 6338 | } |
6202 | 6339 | ||
@@ -6209,6 +6346,12 @@ static int drxk_set_parameters(struct dvb_frontend *fe) | |||
6209 | 6346 | ||
6210 | dprintk(1, "\n"); | 6347 | dprintk(1, "\n"); |
6211 | 6348 | ||
6349 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6350 | return -ENODEV; | ||
6351 | |||
6352 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6353 | return -EAGAIN; | ||
6354 | |||
6212 | if (!fe->ops.tuner_ops.get_if_frequency) { | 6355 | if (!fe->ops.tuner_ops.get_if_frequency) { |
6213 | printk(KERN_ERR | 6356 | printk(KERN_ERR |
6214 | "drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); | 6357 | "drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); |
@@ -6262,6 +6405,12 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
6262 | u32 stat; | 6405 | u32 stat; |
6263 | 6406 | ||
6264 | dprintk(1, "\n"); | 6407 | dprintk(1, "\n"); |
6408 | |||
6409 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6410 | return -ENODEV; | ||
6411 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6412 | return -EAGAIN; | ||
6413 | |||
6265 | *status = 0; | 6414 | *status = 0; |
6266 | GetLockStatus(state, &stat, 0); | 6415 | GetLockStatus(state, &stat, 0); |
6267 | if (stat == MPEG_LOCK) | 6416 | if (stat == MPEG_LOCK) |
@@ -6275,8 +6424,15 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
6275 | 6424 | ||
6276 | static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber) | 6425 | static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber) |
6277 | { | 6426 | { |
6427 | struct drxk_state *state = fe->demodulator_priv; | ||
6428 | |||
6278 | dprintk(1, "\n"); | 6429 | dprintk(1, "\n"); |
6279 | 6430 | ||
6431 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6432 | return -ENODEV; | ||
6433 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6434 | return -EAGAIN; | ||
6435 | |||
6280 | *ber = 0; | 6436 | *ber = 0; |
6281 | return 0; | 6437 | return 0; |
6282 | } | 6438 | } |
@@ -6288,6 +6444,12 @@ static int drxk_read_signal_strength(struct dvb_frontend *fe, | |||
6288 | u32 val = 0; | 6444 | u32 val = 0; |
6289 | 6445 | ||
6290 | dprintk(1, "\n"); | 6446 | dprintk(1, "\n"); |
6447 | |||
6448 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6449 | return -ENODEV; | ||
6450 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6451 | return -EAGAIN; | ||
6452 | |||
6291 | ReadIFAgc(state, &val); | 6453 | ReadIFAgc(state, &val); |
6292 | *strength = val & 0xffff; | 6454 | *strength = val & 0xffff; |
6293 | return 0; | 6455 | return 0; |
@@ -6299,6 +6461,12 @@ static int drxk_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
6299 | s32 snr2; | 6461 | s32 snr2; |
6300 | 6462 | ||
6301 | dprintk(1, "\n"); | 6463 | dprintk(1, "\n"); |
6464 | |||
6465 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6466 | return -ENODEV; | ||
6467 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6468 | return -EAGAIN; | ||
6469 | |||
6302 | GetSignalToNoise(state, &snr2); | 6470 | GetSignalToNoise(state, &snr2); |
6303 | *snr = snr2 & 0xffff; | 6471 | *snr = snr2 & 0xffff; |
6304 | return 0; | 6472 | return 0; |
@@ -6310,6 +6478,12 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
6310 | u16 err; | 6478 | u16 err; |
6311 | 6479 | ||
6312 | dprintk(1, "\n"); | 6480 | dprintk(1, "\n"); |
6481 | |||
6482 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6483 | return -ENODEV; | ||
6484 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6485 | return -EAGAIN; | ||
6486 | |||
6313 | DVBTQAMGetAccPktErr(state, &err); | 6487 | DVBTQAMGetAccPktErr(state, &err); |
6314 | *ucblocks = (u32) err; | 6488 | *ucblocks = (u32) err; |
6315 | return 0; | 6489 | return 0; |
@@ -6318,9 +6492,16 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
6318 | static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings | 6492 | static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings |
6319 | *sets) | 6493 | *sets) |
6320 | { | 6494 | { |
6495 | struct drxk_state *state = fe->demodulator_priv; | ||
6321 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; | 6496 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; |
6322 | 6497 | ||
6323 | dprintk(1, "\n"); | 6498 | dprintk(1, "\n"); |
6499 | |||
6500 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6501 | return -ENODEV; | ||
6502 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6503 | return -EAGAIN; | ||
6504 | |||
6324 | switch (p->delivery_system) { | 6505 | switch (p->delivery_system) { |
6325 | case SYS_DVBC_ANNEX_A: | 6506 | case SYS_DVBC_ANNEX_A: |
6326 | case SYS_DVBC_ANNEX_C: | 6507 | case SYS_DVBC_ANNEX_C: |
@@ -6371,10 +6552,9 @@ static struct dvb_frontend_ops drxk_ops = { | |||
6371 | struct dvb_frontend *drxk_attach(const struct drxk_config *config, | 6552 | struct dvb_frontend *drxk_attach(const struct drxk_config *config, |
6372 | struct i2c_adapter *i2c) | 6553 | struct i2c_adapter *i2c) |
6373 | { | 6554 | { |
6374 | int n; | ||
6375 | |||
6376 | struct drxk_state *state = NULL; | 6555 | struct drxk_state *state = NULL; |
6377 | u8 adr = config->adr; | 6556 | u8 adr = config->adr; |
6557 | int status; | ||
6378 | 6558 | ||
6379 | dprintk(1, "\n"); | 6559 | dprintk(1, "\n"); |
6380 | state = kzalloc(sizeof(struct drxk_state), GFP_KERNEL); | 6560 | state = kzalloc(sizeof(struct drxk_state), GFP_KERNEL); |
@@ -6385,6 +6565,7 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, | |||
6385 | state->demod_address = adr; | 6565 | state->demod_address = adr; |
6386 | state->single_master = config->single_master; | 6566 | state->single_master = config->single_master; |
6387 | state->microcode_name = config->microcode_name; | 6567 | state->microcode_name = config->microcode_name; |
6568 | state->qam_demod_parameter_count = config->qam_demod_parameter_count; | ||
6388 | state->no_i2c_bridge = config->no_i2c_bridge; | 6569 | state->no_i2c_bridge = config->no_i2c_bridge; |
6389 | state->antenna_gpio = config->antenna_gpio; | 6570 | state->antenna_gpio = config->antenna_gpio; |
6390 | state->antenna_dvbt = config->antenna_dvbt; | 6571 | state->antenna_dvbt = config->antenna_dvbt; |
@@ -6425,22 +6606,21 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, | |||
6425 | state->frontend.demodulator_priv = state; | 6606 | state->frontend.demodulator_priv = state; |
6426 | 6607 | ||
6427 | init_state(state); | 6608 | init_state(state); |
6428 | if (init_drxk(state) < 0) | ||
6429 | goto error; | ||
6430 | 6609 | ||
6431 | /* Initialize the supported delivery systems */ | 6610 | /* Load firmware and initialize DRX-K */ |
6432 | n = 0; | 6611 | if (state->microcode_name) { |
6433 | if (state->m_hasDVBC) { | 6612 | status = request_firmware_nowait(THIS_MODULE, 1, |
6434 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A; | 6613 | state->microcode_name, |
6435 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_C; | 6614 | state->i2c->dev.parent, |
6436 | strlcat(state->frontend.ops.info.name, " DVB-C", | 6615 | GFP_KERNEL, |
6437 | sizeof(state->frontend.ops.info.name)); | 6616 | state, load_firmware_cb); |
6438 | } | 6617 | if (status < 0) { |
6439 | if (state->m_hasDVBT) { | 6618 | printk(KERN_ERR |
6440 | state->frontend.ops.delsys[n++] = SYS_DVBT; | 6619 | "drxk: failed to request a firmware\n"); |
6441 | strlcat(state->frontend.ops.info.name, " DVB-T", | 6620 | return NULL; |
6442 | sizeof(state->frontend.ops.info.name)); | 6621 | } |
6443 | } | 6622 | } else if (init_drxk(state) < 0) |
6623 | goto error; | ||
6444 | 6624 | ||
6445 | printk(KERN_INFO "drxk: frontend initialized.\n"); | 6625 | printk(KERN_INFO "drxk: frontend initialized.\n"); |
6446 | return &state->frontend; | 6626 | return &state->frontend; |
diff --git a/drivers/media/dvb/frontends/drxk_hard.h b/drivers/media/dvb/frontends/drxk_hard.h index 4bbf841de83a..6bb9fc4a7b96 100644 --- a/drivers/media/dvb/frontends/drxk_hard.h +++ b/drivers/media/dvb/frontends/drxk_hard.h | |||
@@ -94,7 +94,15 @@ enum DRXPowerMode { | |||
94 | 94 | ||
95 | 95 | ||
96 | enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; | 96 | enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; |
97 | enum EDrxkState { DRXK_UNINITIALIZED = 0, DRXK_STOPPED, DRXK_DTV_STARTED, DRXK_ATV_STARTED, DRXK_POWERED_DOWN }; | 97 | enum EDrxkState { |
98 | DRXK_UNINITIALIZED = 0, | ||
99 | DRXK_STOPPED, | ||
100 | DRXK_DTV_STARTED, | ||
101 | DRXK_ATV_STARTED, | ||
102 | DRXK_POWERED_DOWN, | ||
103 | DRXK_NO_DEV /* If drxk init failed */ | ||
104 | }; | ||
105 | |||
98 | enum EDrxkCoefArrayIndex { | 106 | enum EDrxkCoefArrayIndex { |
99 | DRXK_COEF_IDX_MN = 0, | 107 | DRXK_COEF_IDX_MN = 0, |
100 | DRXK_COEF_IDX_FM , | 108 | DRXK_COEF_IDX_FM , |
@@ -325,6 +333,9 @@ struct drxk_state { | |||
325 | 333 | ||
326 | enum DRXPowerMode m_currentPowerMode; | 334 | enum DRXPowerMode m_currentPowerMode; |
327 | 335 | ||
336 | /* when true, avoids other devices to use the I2C bus */ | ||
337 | bool drxk_i2c_exclusive_lock; | ||
338 | |||
328 | /* | 339 | /* |
329 | * Configurable parameters at the driver. They stores the values found | 340 | * Configurable parameters at the driver. They stores the values found |
330 | * at struct drxk_config. | 341 | * at struct drxk_config. |
@@ -338,7 +349,11 @@ struct drxk_state { | |||
338 | bool antenna_dvbt; | 349 | bool antenna_dvbt; |
339 | u16 antenna_gpio; | 350 | u16 antenna_gpio; |
340 | 351 | ||
352 | /* Firmware */ | ||
341 | const char *microcode_name; | 353 | const char *microcode_name; |
354 | struct completion fw_wait_load; | ||
355 | const struct firmware *fw; | ||
356 | int qam_demod_parameter_count; | ||
342 | }; | 357 | }; |
343 | 358 | ||
344 | #define NEVER_LOCK 0 | 359 | #define NEVER_LOCK 0 |
diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000000000000..2da592fb38ad --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c | |||
@@ -0,0 +1,789 @@ | |||
1 | /* | ||
2 | * Realtek RTL2832 DVB-T demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include "rtl2832_priv.h" | ||
22 | #include <linux/bitops.h> | ||
23 | |||
24 | int rtl2832_debug; | ||
25 | module_param_named(debug, rtl2832_debug, int, 0644); | ||
26 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
27 | |||
28 | #define REG_MASK(b) (BIT(b + 1) - 1) | ||
29 | |||
30 | static const struct rtl2832_reg_entry registers[] = { | ||
31 | [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, | ||
32 | [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, | ||
33 | [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, | ||
34 | [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, | ||
35 | [DVBT_EN_BK_TRK] = {0x1, 0xa6, 7, 7}, | ||
36 | [DVBT_AD_EN_REG] = {0x0, 0x8, 7, 7}, | ||
37 | [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, | ||
38 | [DVBT_EN_BBIN] = {0x1, 0xb1, 0, 0}, | ||
39 | [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, | ||
40 | [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, | ||
41 | [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, | ||
42 | [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, | ||
43 | [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, | ||
44 | [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, | ||
45 | [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, | ||
46 | [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, | ||
47 | [DVBT_EN_CACQ_NOTCH] = {0x1, 0x61, 4, 4}, | ||
48 | [DVBT_AD_AV_REF] = {0x0, 0x9, 6, 0}, | ||
49 | [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, | ||
50 | [DVBT_PIP_ON] = {0x0, 0x21, 3, 3}, | ||
51 | [DVBT_SCALE1_B92] = {0x2, 0x92, 7, 0}, | ||
52 | [DVBT_SCALE1_B93] = {0x2, 0x93, 7, 0}, | ||
53 | [DVBT_SCALE1_BA7] = {0x2, 0xa7, 7, 0}, | ||
54 | [DVBT_SCALE1_BA9] = {0x2, 0xa9, 7, 0}, | ||
55 | [DVBT_SCALE1_BAA] = {0x2, 0xaa, 7, 0}, | ||
56 | [DVBT_SCALE1_BAB] = {0x2, 0xab, 7, 0}, | ||
57 | [DVBT_SCALE1_BAC] = {0x2, 0xac, 7, 0}, | ||
58 | [DVBT_SCALE1_BB0] = {0x2, 0xb0, 7, 0}, | ||
59 | [DVBT_SCALE1_BB1] = {0x2, 0xb1, 7, 0}, | ||
60 | [DVBT_KB_P1] = {0x1, 0x64, 3, 1}, | ||
61 | [DVBT_KB_P2] = {0x1, 0x64, 6, 4}, | ||
62 | [DVBT_KB_P3] = {0x1, 0x65, 2, 0}, | ||
63 | [DVBT_OPT_ADC_IQ] = {0x0, 0x6, 5, 4}, | ||
64 | [DVBT_AD_AVI] = {0x0, 0x9, 1, 0}, | ||
65 | [DVBT_AD_AVQ] = {0x0, 0x9, 3, 2}, | ||
66 | [DVBT_K1_CR_STEP12] = {0x2, 0xad, 9, 4}, | ||
67 | [DVBT_TRK_KS_P2] = {0x1, 0x6f, 2, 0}, | ||
68 | [DVBT_TRK_KS_I2] = {0x1, 0x70, 5, 3}, | ||
69 | [DVBT_TR_THD_SET2] = {0x1, 0x72, 3, 0}, | ||
70 | [DVBT_TRK_KC_P2] = {0x1, 0x73, 5, 3}, | ||
71 | [DVBT_TRK_KC_I2] = {0x1, 0x75, 2, 0}, | ||
72 | [DVBT_CR_THD_SET2] = {0x1, 0x76, 7, 6}, | ||
73 | [DVBT_PSET_IFFREQ] = {0x1, 0x19, 21, 0}, | ||
74 | [DVBT_SPEC_INV] = {0x1, 0x15, 0, 0}, | ||
75 | [DVBT_RSAMP_RATIO] = {0x1, 0x9f, 27, 2}, | ||
76 | [DVBT_CFREQ_OFF_RATIO] = {0x1, 0x9d, 23, 4}, | ||
77 | [DVBT_FSM_STAGE] = {0x3, 0x51, 6, 3}, | ||
78 | [DVBT_RX_CONSTEL] = {0x3, 0x3c, 3, 2}, | ||
79 | [DVBT_RX_HIER] = {0x3, 0x3c, 6, 4}, | ||
80 | [DVBT_RX_C_RATE_LP] = {0x3, 0x3d, 2, 0}, | ||
81 | [DVBT_RX_C_RATE_HP] = {0x3, 0x3d, 5, 3}, | ||
82 | [DVBT_GI_IDX] = {0x3, 0x51, 1, 0}, | ||
83 | [DVBT_FFT_MODE_IDX] = {0x3, 0x51, 2, 2}, | ||
84 | [DVBT_RSD_BER_EST] = {0x3, 0x4e, 15, 0}, | ||
85 | [DVBT_CE_EST_EVM] = {0x4, 0xc, 15, 0}, | ||
86 | [DVBT_RF_AGC_VAL] = {0x3, 0x5b, 13, 0}, | ||
87 | [DVBT_IF_AGC_VAL] = {0x3, 0x59, 13, 0}, | ||
88 | [DVBT_DAGC_VAL] = {0x3, 0x5, 7, 0}, | ||
89 | [DVBT_SFREQ_OFF] = {0x3, 0x18, 13, 0}, | ||
90 | [DVBT_CFREQ_OFF] = {0x3, 0x5f, 17, 0}, | ||
91 | [DVBT_POLAR_RF_AGC] = {0x0, 0xe, 1, 1}, | ||
92 | [DVBT_POLAR_IF_AGC] = {0x0, 0xe, 0, 0}, | ||
93 | [DVBT_AAGC_HOLD] = {0x1, 0x4, 5, 5}, | ||
94 | [DVBT_EN_RF_AGC] = {0x1, 0x4, 6, 6}, | ||
95 | [DVBT_EN_IF_AGC] = {0x1, 0x4, 7, 7}, | ||
96 | [DVBT_IF_AGC_MIN] = {0x1, 0x8, 7, 0}, | ||
97 | [DVBT_IF_AGC_MAX] = {0x1, 0x9, 7, 0}, | ||
98 | [DVBT_RF_AGC_MIN] = {0x1, 0xa, 7, 0}, | ||
99 | [DVBT_RF_AGC_MAX] = {0x1, 0xb, 7, 0}, | ||
100 | [DVBT_IF_AGC_MAN] = {0x1, 0xc, 6, 6}, | ||
101 | [DVBT_IF_AGC_MAN_VAL] = {0x1, 0xc, 13, 0}, | ||
102 | [DVBT_RF_AGC_MAN] = {0x1, 0xe, 6, 6}, | ||
103 | [DVBT_RF_AGC_MAN_VAL] = {0x1, 0xe, 13, 0}, | ||
104 | [DVBT_DAGC_TRG_VAL] = {0x1, 0x12, 7, 0}, | ||
105 | [DVBT_AGC_TARG_VAL_0] = {0x1, 0x2, 0, 0}, | ||
106 | [DVBT_AGC_TARG_VAL_8_1] = {0x1, 0x3, 7, 0}, | ||
107 | [DVBT_AAGC_LOOP_GAIN] = {0x1, 0xc7, 5, 1}, | ||
108 | [DVBT_LOOP_GAIN2_3_0] = {0x1, 0x4, 4, 1}, | ||
109 | [DVBT_LOOP_GAIN2_4] = {0x1, 0x5, 7, 7}, | ||
110 | [DVBT_LOOP_GAIN3] = {0x1, 0xc8, 4, 0}, | ||
111 | [DVBT_VTOP1] = {0x1, 0x6, 5, 0}, | ||
112 | [DVBT_VTOP2] = {0x1, 0xc9, 5, 0}, | ||
113 | [DVBT_VTOP3] = {0x1, 0xca, 5, 0}, | ||
114 | [DVBT_KRF1] = {0x1, 0xcb, 7, 0}, | ||
115 | [DVBT_KRF2] = {0x1, 0x7, 7, 0}, | ||
116 | [DVBT_KRF3] = {0x1, 0xcd, 7, 0}, | ||
117 | [DVBT_KRF4] = {0x1, 0xce, 7, 0}, | ||
118 | [DVBT_EN_GI_PGA] = {0x1, 0xe5, 0, 0}, | ||
119 | [DVBT_THD_LOCK_UP] = {0x1, 0xd9, 8, 0}, | ||
120 | [DVBT_THD_LOCK_DW] = {0x1, 0xdb, 8, 0}, | ||
121 | [DVBT_THD_UP1] = {0x1, 0xdd, 7, 0}, | ||
122 | [DVBT_THD_DW1] = {0x1, 0xde, 7, 0}, | ||
123 | [DVBT_INTER_CNT_LEN] = {0x1, 0xd8, 3, 0}, | ||
124 | [DVBT_GI_PGA_STATE] = {0x1, 0xe6, 3, 3}, | ||
125 | [DVBT_EN_AGC_PGA] = {0x1, 0xd7, 0, 0}, | ||
126 | [DVBT_CKOUTPAR] = {0x1, 0x7b, 5, 5}, | ||
127 | [DVBT_CKOUT_PWR] = {0x1, 0x7b, 6, 6}, | ||
128 | [DVBT_SYNC_DUR] = {0x1, 0x7b, 7, 7}, | ||
129 | [DVBT_ERR_DUR] = {0x1, 0x7c, 0, 0}, | ||
130 | [DVBT_SYNC_LVL] = {0x1, 0x7c, 1, 1}, | ||
131 | [DVBT_ERR_LVL] = {0x1, 0x7c, 2, 2}, | ||
132 | [DVBT_VAL_LVL] = {0x1, 0x7c, 3, 3}, | ||
133 | [DVBT_SERIAL] = {0x1, 0x7c, 4, 4}, | ||
134 | [DVBT_SER_LSB] = {0x1, 0x7c, 5, 5}, | ||
135 | [DVBT_CDIV_PH0] = {0x1, 0x7d, 3, 0}, | ||
136 | [DVBT_CDIV_PH1] = {0x1, 0x7d, 7, 4}, | ||
137 | [DVBT_MPEG_IO_OPT_2_2] = {0x0, 0x6, 7, 7}, | ||
138 | [DVBT_MPEG_IO_OPT_1_0] = {0x0, 0x7, 7, 6}, | ||
139 | [DVBT_CKOUTPAR_PIP] = {0x0, 0xb7, 4, 4}, | ||
140 | [DVBT_CKOUT_PWR_PIP] = {0x0, 0xb7, 3, 3}, | ||
141 | [DVBT_SYNC_LVL_PIP] = {0x0, 0xb7, 2, 2}, | ||
142 | [DVBT_ERR_LVL_PIP] = {0x0, 0xb7, 1, 1}, | ||
143 | [DVBT_VAL_LVL_PIP] = {0x0, 0xb7, 0, 0}, | ||
144 | [DVBT_CKOUTPAR_PID] = {0x0, 0xb9, 4, 4}, | ||
145 | [DVBT_CKOUT_PWR_PID] = {0x0, 0xb9, 3, 3}, | ||
146 | [DVBT_SYNC_LVL_PID] = {0x0, 0xb9, 2, 2}, | ||
147 | [DVBT_ERR_LVL_PID] = {0x0, 0xb9, 1, 1}, | ||
148 | [DVBT_VAL_LVL_PID] = {0x0, 0xb9, 0, 0}, | ||
149 | [DVBT_SM_PASS] = {0x1, 0x93, 11, 0}, | ||
150 | [DVBT_AD7_SETTING] = {0x0, 0x11, 15, 0}, | ||
151 | [DVBT_RSSI_R] = {0x3, 0x1, 6, 0}, | ||
152 | [DVBT_ACI_DET_IND] = {0x3, 0x12, 0, 0}, | ||
153 | [DVBT_REG_MON] = {0x0, 0xd, 1, 0}, | ||
154 | [DVBT_REG_MONSEL] = {0x0, 0xd, 2, 2}, | ||
155 | [DVBT_REG_GPE] = {0x0, 0xd, 7, 7}, | ||
156 | [DVBT_REG_GPO] = {0x0, 0x10, 0, 0}, | ||
157 | [DVBT_REG_4MSEL] = {0x0, 0x13, 0, 0}, | ||
158 | }; | ||
159 | |||
160 | /* write multiple hardware registers */ | ||
161 | static int rtl2832_wr(struct rtl2832_priv *priv, u8 reg, u8 *val, int len) | ||
162 | { | ||
163 | int ret; | ||
164 | u8 buf[1+len]; | ||
165 | struct i2c_msg msg[1] = { | ||
166 | { | ||
167 | .addr = priv->cfg.i2c_addr, | ||
168 | .flags = 0, | ||
169 | .len = 1+len, | ||
170 | .buf = buf, | ||
171 | } | ||
172 | }; | ||
173 | |||
174 | buf[0] = reg; | ||
175 | memcpy(&buf[1], val, len); | ||
176 | |||
177 | ret = i2c_transfer(priv->i2c, msg, 1); | ||
178 | if (ret == 1) { | ||
179 | ret = 0; | ||
180 | } else { | ||
181 | warn("i2c wr failed=%d reg=%02x len=%d", ret, reg, len); | ||
182 | ret = -EREMOTEIO; | ||
183 | } | ||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | /* read multiple hardware registers */ | ||
188 | static int rtl2832_rd(struct rtl2832_priv *priv, u8 reg, u8 *val, int len) | ||
189 | { | ||
190 | int ret; | ||
191 | struct i2c_msg msg[2] = { | ||
192 | { | ||
193 | .addr = priv->cfg.i2c_addr, | ||
194 | .flags = 0, | ||
195 | .len = 1, | ||
196 | .buf = ®, | ||
197 | }, { | ||
198 | .addr = priv->cfg.i2c_addr, | ||
199 | .flags = I2C_M_RD, | ||
200 | .len = len, | ||
201 | .buf = val, | ||
202 | } | ||
203 | }; | ||
204 | |||
205 | ret = i2c_transfer(priv->i2c, msg, 2); | ||
206 | if (ret == 2) { | ||
207 | ret = 0; | ||
208 | } else { | ||
209 | warn("i2c rd failed=%d reg=%02x len=%d", ret, reg, len); | ||
210 | ret = -EREMOTEIO; | ||
211 | } | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | /* write multiple registers */ | ||
216 | static int rtl2832_wr_regs(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val, | ||
217 | int len) | ||
218 | { | ||
219 | int ret; | ||
220 | |||
221 | |||
222 | /* switch bank if needed */ | ||
223 | if (page != priv->page) { | ||
224 | ret = rtl2832_wr(priv, 0x00, &page, 1); | ||
225 | if (ret) | ||
226 | return ret; | ||
227 | |||
228 | priv->page = page; | ||
229 | } | ||
230 | |||
231 | return rtl2832_wr(priv, reg, val, len); | ||
232 | } | ||
233 | |||
234 | /* read multiple registers */ | ||
235 | static int rtl2832_rd_regs(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val, | ||
236 | int len) | ||
237 | { | ||
238 | int ret; | ||
239 | |||
240 | /* switch bank if needed */ | ||
241 | if (page != priv->page) { | ||
242 | ret = rtl2832_wr(priv, 0x00, &page, 1); | ||
243 | if (ret) | ||
244 | return ret; | ||
245 | |||
246 | priv->page = page; | ||
247 | } | ||
248 | |||
249 | return rtl2832_rd(priv, reg, val, len); | ||
250 | } | ||
251 | |||
252 | #if 0 /* currently not used */ | ||
253 | /* write single register */ | ||
254 | static int rtl2832_wr_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 val) | ||
255 | { | ||
256 | return rtl2832_wr_regs(priv, reg, page, &val, 1); | ||
257 | } | ||
258 | #endif | ||
259 | |||
260 | /* read single register */ | ||
261 | static int rtl2832_rd_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val) | ||
262 | { | ||
263 | return rtl2832_rd_regs(priv, reg, page, val, 1); | ||
264 | } | ||
265 | |||
266 | int rtl2832_rd_demod_reg(struct rtl2832_priv *priv, int reg, u32 *val) | ||
267 | { | ||
268 | int ret; | ||
269 | |||
270 | u8 reg_start_addr; | ||
271 | u8 msb, lsb; | ||
272 | u8 page; | ||
273 | u8 reading[4]; | ||
274 | u32 reading_tmp; | ||
275 | int i; | ||
276 | |||
277 | u8 len; | ||
278 | u32 mask; | ||
279 | |||
280 | reg_start_addr = registers[reg].start_address; | ||
281 | msb = registers[reg].msb; | ||
282 | lsb = registers[reg].lsb; | ||
283 | page = registers[reg].page; | ||
284 | |||
285 | len = (msb >> 3) + 1; | ||
286 | mask = REG_MASK(msb - lsb); | ||
287 | |||
288 | ret = rtl2832_rd_regs(priv, reg_start_addr, page, &reading[0], len); | ||
289 | if (ret) | ||
290 | goto err; | ||
291 | |||
292 | reading_tmp = 0; | ||
293 | for (i = 0; i < len; i++) | ||
294 | reading_tmp |= reading[i] << ((len - 1 - i) * 8); | ||
295 | |||
296 | *val = (reading_tmp >> lsb) & mask; | ||
297 | |||
298 | return ret; | ||
299 | |||
300 | err: | ||
301 | dbg("%s: failed=%d", __func__, ret); | ||
302 | return ret; | ||
303 | |||
304 | } | ||
305 | |||
306 | int rtl2832_wr_demod_reg(struct rtl2832_priv *priv, int reg, u32 val) | ||
307 | { | ||
308 | int ret, i; | ||
309 | u8 len; | ||
310 | u8 reg_start_addr; | ||
311 | u8 msb, lsb; | ||
312 | u8 page; | ||
313 | u32 mask; | ||
314 | |||
315 | |||
316 | u8 reading[4]; | ||
317 | u8 writing[4]; | ||
318 | u32 reading_tmp; | ||
319 | u32 writing_tmp; | ||
320 | |||
321 | |||
322 | reg_start_addr = registers[reg].start_address; | ||
323 | msb = registers[reg].msb; | ||
324 | lsb = registers[reg].lsb; | ||
325 | page = registers[reg].page; | ||
326 | |||
327 | len = (msb >> 3) + 1; | ||
328 | mask = REG_MASK(msb - lsb); | ||
329 | |||
330 | |||
331 | ret = rtl2832_rd_regs(priv, reg_start_addr, page, &reading[0], len); | ||
332 | if (ret) | ||
333 | goto err; | ||
334 | |||
335 | reading_tmp = 0; | ||
336 | for (i = 0; i < len; i++) | ||
337 | reading_tmp |= reading[i] << ((len - 1 - i) * 8); | ||
338 | |||
339 | writing_tmp = reading_tmp & ~(mask << lsb); | ||
340 | writing_tmp |= ((val & mask) << lsb); | ||
341 | |||
342 | |||
343 | for (i = 0; i < len; i++) | ||
344 | writing[i] = (writing_tmp >> ((len - 1 - i) * 8)) & 0xff; | ||
345 | |||
346 | ret = rtl2832_wr_regs(priv, reg_start_addr, page, &writing[0], len); | ||
347 | if (ret) | ||
348 | goto err; | ||
349 | |||
350 | return ret; | ||
351 | |||
352 | err: | ||
353 | dbg("%s: failed=%d", __func__, ret); | ||
354 | return ret; | ||
355 | |||
356 | } | ||
357 | |||
358 | |||
359 | static int rtl2832_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | ||
360 | { | ||
361 | int ret; | ||
362 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
363 | |||
364 | dbg("%s: enable=%d", __func__, enable); | ||
365 | |||
366 | /* gate already open or close */ | ||
367 | if (priv->i2c_gate_state == enable) | ||
368 | return 0; | ||
369 | |||
370 | ret = rtl2832_wr_demod_reg(priv, DVBT_IIC_REPEAT, (enable ? 0x1 : 0x0)); | ||
371 | if (ret) | ||
372 | goto err; | ||
373 | |||
374 | priv->i2c_gate_state = enable; | ||
375 | |||
376 | return ret; | ||
377 | err: | ||
378 | dbg("%s: failed=%d", __func__, ret); | ||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | |||
383 | |||
384 | static int rtl2832_init(struct dvb_frontend *fe) | ||
385 | { | ||
386 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
387 | int i, ret; | ||
388 | |||
389 | u8 en_bbin; | ||
390 | u64 pset_iffreq; | ||
391 | |||
392 | /* initialization values for the demodulator registers */ | ||
393 | struct rtl2832_reg_value rtl2832_initial_regs[] = { | ||
394 | {DVBT_AD_EN_REG, 0x1}, | ||
395 | {DVBT_AD_EN_REG1, 0x1}, | ||
396 | {DVBT_RSD_BER_FAIL_VAL, 0x2800}, | ||
397 | {DVBT_MGD_THD0, 0x10}, | ||
398 | {DVBT_MGD_THD1, 0x20}, | ||
399 | {DVBT_MGD_THD2, 0x20}, | ||
400 | {DVBT_MGD_THD3, 0x40}, | ||
401 | {DVBT_MGD_THD4, 0x22}, | ||
402 | {DVBT_MGD_THD5, 0x32}, | ||
403 | {DVBT_MGD_THD6, 0x37}, | ||
404 | {DVBT_MGD_THD7, 0x39}, | ||
405 | {DVBT_EN_BK_TRK, 0x0}, | ||
406 | {DVBT_EN_CACQ_NOTCH, 0x0}, | ||
407 | {DVBT_AD_AV_REF, 0x2a}, | ||
408 | {DVBT_REG_PI, 0x6}, | ||
409 | {DVBT_PIP_ON, 0x0}, | ||
410 | {DVBT_CDIV_PH0, 0x8}, | ||
411 | {DVBT_CDIV_PH1, 0x8}, | ||
412 | {DVBT_SCALE1_B92, 0x4}, | ||
413 | {DVBT_SCALE1_B93, 0xb0}, | ||
414 | {DVBT_SCALE1_BA7, 0x78}, | ||
415 | {DVBT_SCALE1_BA9, 0x28}, | ||
416 | {DVBT_SCALE1_BAA, 0x59}, | ||
417 | {DVBT_SCALE1_BAB, 0x83}, | ||
418 | {DVBT_SCALE1_BAC, 0xd4}, | ||
419 | {DVBT_SCALE1_BB0, 0x65}, | ||
420 | {DVBT_SCALE1_BB1, 0x43}, | ||
421 | {DVBT_KB_P1, 0x1}, | ||
422 | {DVBT_KB_P2, 0x4}, | ||
423 | {DVBT_KB_P3, 0x7}, | ||
424 | {DVBT_K1_CR_STEP12, 0xa}, | ||
425 | {DVBT_REG_GPE, 0x1}, | ||
426 | {DVBT_SERIAL, 0x0}, | ||
427 | {DVBT_CDIV_PH0, 0x9}, | ||
428 | {DVBT_CDIV_PH1, 0x9}, | ||
429 | {DVBT_MPEG_IO_OPT_2_2, 0x0}, | ||
430 | {DVBT_MPEG_IO_OPT_1_0, 0x0}, | ||
431 | {DVBT_TRK_KS_P2, 0x4}, | ||
432 | {DVBT_TRK_KS_I2, 0x7}, | ||
433 | {DVBT_TR_THD_SET2, 0x6}, | ||
434 | {DVBT_TRK_KC_I2, 0x5}, | ||
435 | {DVBT_CR_THD_SET2, 0x1}, | ||
436 | {DVBT_SPEC_INV, 0x0}, | ||
437 | {DVBT_DAGC_TRG_VAL, 0x5a}, | ||
438 | {DVBT_AGC_TARG_VAL_0, 0x0}, | ||
439 | {DVBT_AGC_TARG_VAL_8_1, 0x5a}, | ||
440 | {DVBT_AAGC_LOOP_GAIN, 0x16}, | ||
441 | {DVBT_LOOP_GAIN2_3_0, 0x6}, | ||
442 | {DVBT_LOOP_GAIN2_4, 0x1}, | ||
443 | {DVBT_LOOP_GAIN3, 0x16}, | ||
444 | {DVBT_VTOP1, 0x35}, | ||
445 | {DVBT_VTOP2, 0x21}, | ||
446 | {DVBT_VTOP3, 0x21}, | ||
447 | {DVBT_KRF1, 0x0}, | ||
448 | {DVBT_KRF2, 0x40}, | ||
449 | {DVBT_KRF3, 0x10}, | ||
450 | {DVBT_KRF4, 0x10}, | ||
451 | {DVBT_IF_AGC_MIN, 0x80}, | ||
452 | {DVBT_IF_AGC_MAX, 0x7f}, | ||
453 | {DVBT_RF_AGC_MIN, 0x80}, | ||
454 | {DVBT_RF_AGC_MAX, 0x7f}, | ||
455 | {DVBT_POLAR_RF_AGC, 0x0}, | ||
456 | {DVBT_POLAR_IF_AGC, 0x0}, | ||
457 | {DVBT_AD7_SETTING, 0xe9bf}, | ||
458 | {DVBT_EN_GI_PGA, 0x0}, | ||
459 | {DVBT_THD_LOCK_UP, 0x0}, | ||
460 | {DVBT_THD_LOCK_DW, 0x0}, | ||
461 | {DVBT_THD_UP1, 0x11}, | ||
462 | {DVBT_THD_DW1, 0xef}, | ||
463 | {DVBT_INTER_CNT_LEN, 0xc}, | ||
464 | {DVBT_GI_PGA_STATE, 0x0}, | ||
465 | {DVBT_EN_AGC_PGA, 0x1}, | ||
466 | {DVBT_IF_AGC_MAN, 0x0}, | ||
467 | }; | ||
468 | |||
469 | |||
470 | dbg("%s", __func__); | ||
471 | |||
472 | en_bbin = (priv->cfg.if_dvbt == 0 ? 0x1 : 0x0); | ||
473 | |||
474 | /* | ||
475 | * PSET_IFFREQ = - floor((IfFreqHz % CrystalFreqHz) * pow(2, 22) | ||
476 | * / CrystalFreqHz) | ||
477 | */ | ||
478 | pset_iffreq = priv->cfg.if_dvbt % priv->cfg.xtal; | ||
479 | pset_iffreq *= 0x400000; | ||
480 | pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal); | ||
481 | pset_iffreq = pset_iffreq & 0x3fffff; | ||
482 | |||
483 | |||
484 | |||
485 | for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) { | ||
486 | ret = rtl2832_wr_demod_reg(priv, rtl2832_initial_regs[i].reg, | ||
487 | rtl2832_initial_regs[i].value); | ||
488 | if (ret) | ||
489 | goto err; | ||
490 | } | ||
491 | |||
492 | /* if frequency settings */ | ||
493 | ret = rtl2832_wr_demod_reg(priv, DVBT_EN_BBIN, en_bbin); | ||
494 | if (ret) | ||
495 | goto err; | ||
496 | |||
497 | ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq); | ||
498 | if (ret) | ||
499 | goto err; | ||
500 | |||
501 | priv->sleeping = false; | ||
502 | |||
503 | return ret; | ||
504 | |||
505 | err: | ||
506 | dbg("%s: failed=%d", __func__, ret); | ||
507 | return ret; | ||
508 | } | ||
509 | |||
510 | static int rtl2832_sleep(struct dvb_frontend *fe) | ||
511 | { | ||
512 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
513 | |||
514 | dbg("%s", __func__); | ||
515 | priv->sleeping = true; | ||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | int rtl2832_get_tune_settings(struct dvb_frontend *fe, | ||
520 | struct dvb_frontend_tune_settings *s) | ||
521 | { | ||
522 | dbg("%s", __func__); | ||
523 | s->min_delay_ms = 1000; | ||
524 | s->step_size = fe->ops.info.frequency_stepsize * 2; | ||
525 | s->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1; | ||
526 | return 0; | ||
527 | } | ||
528 | |||
529 | static int rtl2832_set_frontend(struct dvb_frontend *fe) | ||
530 | { | ||
531 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
532 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
533 | int ret, i, j; | ||
534 | u64 bw_mode, num, num2; | ||
535 | u32 resamp_ratio, cfreq_off_ratio; | ||
536 | |||
537 | |||
538 | static u8 bw_params[3][32] = { | ||
539 | /* 6 MHz bandwidth */ | ||
540 | { | ||
541 | 0xf5, 0xff, 0x15, 0x38, 0x5d, 0x6d, 0x52, 0x07, 0xfa, 0x2f, | ||
542 | 0x53, 0xf5, 0x3f, 0xca, 0x0b, 0x91, 0xea, 0x30, 0x63, 0xb2, | ||
543 | 0x13, 0xda, 0x0b, 0xc4, 0x18, 0x7e, 0x16, 0x66, 0x08, 0x67, | ||
544 | 0x19, 0xe0, | ||
545 | }, | ||
546 | |||
547 | /* 7 MHz bandwidth */ | ||
548 | { | ||
549 | 0xe7, 0xcc, 0xb5, 0xba, 0xe8, 0x2f, 0x67, 0x61, 0x00, 0xaf, | ||
550 | 0x86, 0xf2, 0xbf, 0x59, 0x04, 0x11, 0xb6, 0x33, 0xa4, 0x30, | ||
551 | 0x15, 0x10, 0x0a, 0x42, 0x18, 0xf8, 0x17, 0xd9, 0x07, 0x22, | ||
552 | 0x19, 0x10, | ||
553 | }, | ||
554 | |||
555 | /* 8 MHz bandwidth */ | ||
556 | { | ||
557 | 0x09, 0xf6, 0xd2, 0xa7, 0x9a, 0xc9, 0x27, 0x77, 0x06, 0xbf, | ||
558 | 0xec, 0xf4, 0x4f, 0x0b, 0xfc, 0x01, 0x63, 0x35, 0x54, 0xa7, | ||
559 | 0x16, 0x66, 0x08, 0xb4, 0x19, 0x6e, 0x19, 0x65, 0x05, 0xc8, | ||
560 | 0x19, 0xe0, | ||
561 | }, | ||
562 | }; | ||
563 | |||
564 | |||
565 | dbg("%s: frequency=%d bandwidth_hz=%d inversion=%d", __func__, | ||
566 | c->frequency, c->bandwidth_hz, c->inversion); | ||
567 | |||
568 | |||
569 | /* program tuner */ | ||
570 | if (fe->ops.tuner_ops.set_params) | ||
571 | fe->ops.tuner_ops.set_params(fe); | ||
572 | |||
573 | |||
574 | switch (c->bandwidth_hz) { | ||
575 | case 6000000: | ||
576 | i = 0; | ||
577 | bw_mode = 48000000; | ||
578 | break; | ||
579 | case 7000000: | ||
580 | i = 1; | ||
581 | bw_mode = 56000000; | ||
582 | break; | ||
583 | case 8000000: | ||
584 | i = 2; | ||
585 | bw_mode = 64000000; | ||
586 | break; | ||
587 | default: | ||
588 | dbg("invalid bandwidth"); | ||
589 | return -EINVAL; | ||
590 | } | ||
591 | |||
592 | for (j = 0; j < sizeof(bw_params[j]); j++) { | ||
593 | ret = rtl2832_wr_regs(priv, 0x1c+j, 1, &bw_params[i][j], 1); | ||
594 | if (ret) | ||
595 | goto err; | ||
596 | } | ||
597 | |||
598 | /* calculate and set resample ratio | ||
599 | * RSAMP_RATIO = floor(CrystalFreqHz * 7 * pow(2, 22) | ||
600 | * / ConstWithBandwidthMode) | ||
601 | */ | ||
602 | num = priv->cfg.xtal * 7; | ||
603 | num *= 0x400000; | ||
604 | num = div_u64(num, bw_mode); | ||
605 | resamp_ratio = num & 0x3ffffff; | ||
606 | ret = rtl2832_wr_demod_reg(priv, DVBT_RSAMP_RATIO, resamp_ratio); | ||
607 | if (ret) | ||
608 | goto err; | ||
609 | |||
610 | /* calculate and set cfreq off ratio | ||
611 | * CFREQ_OFF_RATIO = - floor(ConstWithBandwidthMode * pow(2, 20) | ||
612 | * / (CrystalFreqHz * 7)) | ||
613 | */ | ||
614 | num = bw_mode << 20; | ||
615 | num2 = priv->cfg.xtal * 7; | ||
616 | num = div_u64(num, num2); | ||
617 | num = -num; | ||
618 | cfreq_off_ratio = num & 0xfffff; | ||
619 | ret = rtl2832_wr_demod_reg(priv, DVBT_CFREQ_OFF_RATIO, cfreq_off_ratio); | ||
620 | if (ret) | ||
621 | goto err; | ||
622 | |||
623 | |||
624 | /* soft reset */ | ||
625 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x1); | ||
626 | if (ret) | ||
627 | goto err; | ||
628 | |||
629 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x0); | ||
630 | if (ret) | ||
631 | goto err; | ||
632 | |||
633 | return ret; | ||
634 | err: | ||
635 | info("%s: failed=%d", __func__, ret); | ||
636 | return ret; | ||
637 | } | ||
638 | |||
639 | static int rtl2832_read_status(struct dvb_frontend *fe, fe_status_t *status) | ||
640 | { | ||
641 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
642 | int ret; | ||
643 | u32 tmp; | ||
644 | *status = 0; | ||
645 | |||
646 | |||
647 | dbg("%s", __func__); | ||
648 | if (priv->sleeping) | ||
649 | return 0; | ||
650 | |||
651 | ret = rtl2832_rd_demod_reg(priv, DVBT_FSM_STAGE, &tmp); | ||
652 | if (ret) | ||
653 | goto err; | ||
654 | |||
655 | if (tmp == 11) { | ||
656 | *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | | ||
657 | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; | ||
658 | } | ||
659 | /* TODO find out if this is also true for rtl2832? */ | ||
660 | /*else if (tmp == 10) { | ||
661 | *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | | ||
662 | FE_HAS_VITERBI; | ||
663 | }*/ | ||
664 | |||
665 | return ret; | ||
666 | err: | ||
667 | info("%s: failed=%d", __func__, ret); | ||
668 | return ret; | ||
669 | } | ||
670 | |||
671 | static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr) | ||
672 | { | ||
673 | *snr = 0; | ||
674 | return 0; | ||
675 | } | ||
676 | |||
677 | static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber) | ||
678 | { | ||
679 | *ber = 0; | ||
680 | return 0; | ||
681 | } | ||
682 | |||
683 | static int rtl2832_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | ||
684 | { | ||
685 | *ucblocks = 0; | ||
686 | return 0; | ||
687 | } | ||
688 | |||
689 | |||
690 | static int rtl2832_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | ||
691 | { | ||
692 | *strength = 0; | ||
693 | return 0; | ||
694 | } | ||
695 | |||
696 | static struct dvb_frontend_ops rtl2832_ops; | ||
697 | |||
698 | static void rtl2832_release(struct dvb_frontend *fe) | ||
699 | { | ||
700 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
701 | |||
702 | dbg("%s", __func__); | ||
703 | kfree(priv); | ||
704 | } | ||
705 | |||
706 | struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg, | ||
707 | struct i2c_adapter *i2c) | ||
708 | { | ||
709 | struct rtl2832_priv *priv = NULL; | ||
710 | int ret = 0; | ||
711 | u8 tmp; | ||
712 | |||
713 | dbg("%s", __func__); | ||
714 | |||
715 | /* allocate memory for the internal state */ | ||
716 | priv = kzalloc(sizeof(struct rtl2832_priv), GFP_KERNEL); | ||
717 | if (priv == NULL) | ||
718 | goto err; | ||
719 | |||
720 | /* setup the priv */ | ||
721 | priv->i2c = i2c; | ||
722 | priv->tuner = cfg->tuner; | ||
723 | memcpy(&priv->cfg, cfg, sizeof(struct rtl2832_config)); | ||
724 | |||
725 | /* check if the demod is there */ | ||
726 | ret = rtl2832_rd_reg(priv, 0x00, 0x0, &tmp); | ||
727 | if (ret) | ||
728 | goto err; | ||
729 | |||
730 | /* create dvb_frontend */ | ||
731 | memcpy(&priv->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops)); | ||
732 | priv->fe.demodulator_priv = priv; | ||
733 | |||
734 | /* TODO implement sleep mode */ | ||
735 | priv->sleeping = true; | ||
736 | |||
737 | return &priv->fe; | ||
738 | err: | ||
739 | dbg("%s: failed=%d", __func__, ret); | ||
740 | kfree(priv); | ||
741 | return NULL; | ||
742 | } | ||
743 | EXPORT_SYMBOL(rtl2832_attach); | ||
744 | |||
745 | static struct dvb_frontend_ops rtl2832_ops = { | ||
746 | .delsys = { SYS_DVBT }, | ||
747 | .info = { | ||
748 | .name = "Realtek RTL2832 (DVB-T)", | ||
749 | .frequency_min = 174000000, | ||
750 | .frequency_max = 862000000, | ||
751 | .frequency_stepsize = 166667, | ||
752 | .caps = FE_CAN_FEC_1_2 | | ||
753 | FE_CAN_FEC_2_3 | | ||
754 | FE_CAN_FEC_3_4 | | ||
755 | FE_CAN_FEC_5_6 | | ||
756 | FE_CAN_FEC_7_8 | | ||
757 | FE_CAN_FEC_AUTO | | ||
758 | FE_CAN_QPSK | | ||
759 | FE_CAN_QAM_16 | | ||
760 | FE_CAN_QAM_64 | | ||
761 | FE_CAN_QAM_AUTO | | ||
762 | FE_CAN_TRANSMISSION_MODE_AUTO | | ||
763 | FE_CAN_GUARD_INTERVAL_AUTO | | ||
764 | FE_CAN_HIERARCHY_AUTO | | ||
765 | FE_CAN_RECOVER | | ||
766 | FE_CAN_MUTE_TS | ||
767 | }, | ||
768 | |||
769 | .release = rtl2832_release, | ||
770 | |||
771 | .init = rtl2832_init, | ||
772 | .sleep = rtl2832_sleep, | ||
773 | |||
774 | .get_tune_settings = rtl2832_get_tune_settings, | ||
775 | |||
776 | .set_frontend = rtl2832_set_frontend, | ||
777 | |||
778 | .read_status = rtl2832_read_status, | ||
779 | .read_snr = rtl2832_read_snr, | ||
780 | .read_ber = rtl2832_read_ber, | ||
781 | .read_ucblocks = rtl2832_read_ucblocks, | ||
782 | .read_signal_strength = rtl2832_read_signal_strength, | ||
783 | .i2c_gate_ctrl = rtl2832_i2c_gate_ctrl, | ||
784 | }; | ||
785 | |||
786 | MODULE_AUTHOR("Thomas Mair <mair.thomas86@gmail.com>"); | ||
787 | MODULE_DESCRIPTION("Realtek RTL2832 DVB-T demodulator driver"); | ||
788 | MODULE_LICENSE("GPL"); | ||
789 | MODULE_VERSION("0.5"); | ||
diff --git a/drivers/media/dvb/frontends/rtl2832.h b/drivers/media/dvb/frontends/rtl2832.h new file mode 100644 index 000000000000..d94dc9a3fa62 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Realtek RTL2832 DVB-T demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef RTL2832_H | ||
22 | #define RTL2832_H | ||
23 | |||
24 | #include <linux/dvb/frontend.h> | ||
25 | |||
26 | struct rtl2832_config { | ||
27 | /* | ||
28 | * Demodulator I2C address. | ||
29 | */ | ||
30 | u8 i2c_addr; | ||
31 | |||
32 | /* | ||
33 | * Xtal frequency. | ||
34 | * Hz | ||
35 | * 4000000, 16000000, 25000000, 28800000 | ||
36 | */ | ||
37 | u32 xtal; | ||
38 | |||
39 | /* | ||
40 | * IFs for all used modes. | ||
41 | * Hz | ||
42 | * 4570000, 4571429, 36000000, 36125000, 36166667, 44000000 | ||
43 | */ | ||
44 | u32 if_dvbt; | ||
45 | |||
46 | /* | ||
47 | */ | ||
48 | u8 tuner; | ||
49 | }; | ||
50 | |||
51 | |||
52 | #if defined(CONFIG_DVB_RTL2832) || \ | ||
53 | (defined(CONFIG_DVB_RTL2832_MODULE) && defined(MODULE)) | ||
54 | extern struct dvb_frontend *rtl2832_attach( | ||
55 | const struct rtl2832_config *cfg, | ||
56 | struct i2c_adapter *i2c | ||
57 | ); | ||
58 | |||
59 | extern struct i2c_adapter *rtl2832_get_tuner_i2c_adapter( | ||
60 | struct dvb_frontend *fe | ||
61 | ); | ||
62 | #else | ||
63 | static inline struct dvb_frontend *rtl2832_attach( | ||
64 | const struct rtl2832_config *config, | ||
65 | struct i2c_adapter *i2c | ||
66 | ) | ||
67 | { | ||
68 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
69 | return NULL; | ||
70 | } | ||
71 | #endif | ||
72 | |||
73 | |||
74 | #endif /* RTL2832_H */ | ||
diff --git a/drivers/media/dvb/frontends/rtl2832_priv.h b/drivers/media/dvb/frontends/rtl2832_priv.h new file mode 100644 index 000000000000..0ce9502da8ba --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832_priv.h | |||
@@ -0,0 +1,260 @@ | |||
1 | /* | ||
2 | * Realtek RTL2832 DVB-T demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef RTL2832_PRIV_H | ||
22 | #define RTL2832_PRIV_H | ||
23 | |||
24 | #include "dvb_frontend.h" | ||
25 | #include "rtl2832.h" | ||
26 | |||
27 | #define LOG_PREFIX "rtl2832" | ||
28 | |||
29 | #undef dbg | ||
30 | #define dbg(f, arg...) \ | ||
31 | do { \ | ||
32 | if (rtl2832_debug) \ | ||
33 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg); \ | ||
34 | } while (0) | ||
35 | #undef err | ||
36 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) | ||
37 | #undef info | ||
38 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
39 | #undef warn | ||
40 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) | ||
41 | |||
42 | struct rtl2832_priv { | ||
43 | struct i2c_adapter *i2c; | ||
44 | struct dvb_frontend fe; | ||
45 | struct rtl2832_config cfg; | ||
46 | |||
47 | bool i2c_gate_state; | ||
48 | bool sleeping; | ||
49 | |||
50 | u8 tuner; | ||
51 | u8 page; /* active register page */ | ||
52 | }; | ||
53 | |||
54 | struct rtl2832_reg_entry { | ||
55 | u8 page; | ||
56 | u8 start_address; | ||
57 | u8 msb; | ||
58 | u8 lsb; | ||
59 | }; | ||
60 | |||
61 | struct rtl2832_reg_value { | ||
62 | int reg; | ||
63 | u32 value; | ||
64 | }; | ||
65 | |||
66 | |||
67 | /* Demod register bit names */ | ||
68 | enum DVBT_REG_BIT_NAME { | ||
69 | DVBT_SOFT_RST, | ||
70 | DVBT_IIC_REPEAT, | ||
71 | DVBT_TR_WAIT_MIN_8K, | ||
72 | DVBT_RSD_BER_FAIL_VAL, | ||
73 | DVBT_EN_BK_TRK, | ||
74 | DVBT_REG_PI, | ||
75 | DVBT_REG_PFREQ_1_0, | ||
76 | DVBT_PD_DA8, | ||
77 | DVBT_LOCK_TH, | ||
78 | DVBT_BER_PASS_SCAL, | ||
79 | DVBT_CE_FFSM_BYPASS, | ||
80 | DVBT_ALPHAIIR_N, | ||
81 | DVBT_ALPHAIIR_DIF, | ||
82 | DVBT_EN_TRK_SPAN, | ||
83 | DVBT_LOCK_TH_LEN, | ||
84 | DVBT_CCI_THRE, | ||
85 | DVBT_CCI_MON_SCAL, | ||
86 | DVBT_CCI_M0, | ||
87 | DVBT_CCI_M1, | ||
88 | DVBT_CCI_M2, | ||
89 | DVBT_CCI_M3, | ||
90 | DVBT_SPEC_INIT_0, | ||
91 | DVBT_SPEC_INIT_1, | ||
92 | DVBT_SPEC_INIT_2, | ||
93 | DVBT_AD_EN_REG, | ||
94 | DVBT_AD_EN_REG1, | ||
95 | DVBT_EN_BBIN, | ||
96 | DVBT_MGD_THD0, | ||
97 | DVBT_MGD_THD1, | ||
98 | DVBT_MGD_THD2, | ||
99 | DVBT_MGD_THD3, | ||
100 | DVBT_MGD_THD4, | ||
101 | DVBT_MGD_THD5, | ||
102 | DVBT_MGD_THD6, | ||
103 | DVBT_MGD_THD7, | ||
104 | DVBT_EN_CACQ_NOTCH, | ||
105 | DVBT_AD_AV_REF, | ||
106 | DVBT_PIP_ON, | ||
107 | DVBT_SCALE1_B92, | ||
108 | DVBT_SCALE1_B93, | ||
109 | DVBT_SCALE1_BA7, | ||
110 | DVBT_SCALE1_BA9, | ||
111 | DVBT_SCALE1_BAA, | ||
112 | DVBT_SCALE1_BAB, | ||
113 | DVBT_SCALE1_BAC, | ||
114 | DVBT_SCALE1_BB0, | ||
115 | DVBT_SCALE1_BB1, | ||
116 | DVBT_KB_P1, | ||
117 | DVBT_KB_P2, | ||
118 | DVBT_KB_P3, | ||
119 | DVBT_OPT_ADC_IQ, | ||
120 | DVBT_AD_AVI, | ||
121 | DVBT_AD_AVQ, | ||
122 | DVBT_K1_CR_STEP12, | ||
123 | DVBT_TRK_KS_P2, | ||
124 | DVBT_TRK_KS_I2, | ||
125 | DVBT_TR_THD_SET2, | ||
126 | DVBT_TRK_KC_P2, | ||
127 | DVBT_TRK_KC_I2, | ||
128 | DVBT_CR_THD_SET2, | ||
129 | DVBT_PSET_IFFREQ, | ||
130 | DVBT_SPEC_INV, | ||
131 | DVBT_BW_INDEX, | ||
132 | DVBT_RSAMP_RATIO, | ||
133 | DVBT_CFREQ_OFF_RATIO, | ||
134 | DVBT_FSM_STAGE, | ||
135 | DVBT_RX_CONSTEL, | ||
136 | DVBT_RX_HIER, | ||
137 | DVBT_RX_C_RATE_LP, | ||
138 | DVBT_RX_C_RATE_HP, | ||
139 | DVBT_GI_IDX, | ||
140 | DVBT_FFT_MODE_IDX, | ||
141 | DVBT_RSD_BER_EST, | ||
142 | DVBT_CE_EST_EVM, | ||
143 | DVBT_RF_AGC_VAL, | ||
144 | DVBT_IF_AGC_VAL, | ||
145 | DVBT_DAGC_VAL, | ||
146 | DVBT_SFREQ_OFF, | ||
147 | DVBT_CFREQ_OFF, | ||
148 | DVBT_POLAR_RF_AGC, | ||
149 | DVBT_POLAR_IF_AGC, | ||
150 | DVBT_AAGC_HOLD, | ||
151 | DVBT_EN_RF_AGC, | ||
152 | DVBT_EN_IF_AGC, | ||
153 | DVBT_IF_AGC_MIN, | ||
154 | DVBT_IF_AGC_MAX, | ||
155 | DVBT_RF_AGC_MIN, | ||
156 | DVBT_RF_AGC_MAX, | ||
157 | DVBT_IF_AGC_MAN, | ||
158 | DVBT_IF_AGC_MAN_VAL, | ||
159 | DVBT_RF_AGC_MAN, | ||
160 | DVBT_RF_AGC_MAN_VAL, | ||
161 | DVBT_DAGC_TRG_VAL, | ||
162 | DVBT_AGC_TARG_VAL, | ||
163 | DVBT_LOOP_GAIN_3_0, | ||
164 | DVBT_LOOP_GAIN_4, | ||
165 | DVBT_VTOP, | ||
166 | DVBT_KRF, | ||
167 | DVBT_AGC_TARG_VAL_0, | ||
168 | DVBT_AGC_TARG_VAL_8_1, | ||
169 | DVBT_AAGC_LOOP_GAIN, | ||
170 | DVBT_LOOP_GAIN2_3_0, | ||
171 | DVBT_LOOP_GAIN2_4, | ||
172 | DVBT_LOOP_GAIN3, | ||
173 | DVBT_VTOP1, | ||
174 | DVBT_VTOP2, | ||
175 | DVBT_VTOP3, | ||
176 | DVBT_KRF1, | ||
177 | DVBT_KRF2, | ||
178 | DVBT_KRF3, | ||
179 | DVBT_KRF4, | ||
180 | DVBT_EN_GI_PGA, | ||
181 | DVBT_THD_LOCK_UP, | ||
182 | DVBT_THD_LOCK_DW, | ||
183 | DVBT_THD_UP1, | ||
184 | DVBT_THD_DW1, | ||
185 | DVBT_INTER_CNT_LEN, | ||
186 | DVBT_GI_PGA_STATE, | ||
187 | DVBT_EN_AGC_PGA, | ||
188 | DVBT_CKOUTPAR, | ||
189 | DVBT_CKOUT_PWR, | ||
190 | DVBT_SYNC_DUR, | ||
191 | DVBT_ERR_DUR, | ||
192 | DVBT_SYNC_LVL, | ||
193 | DVBT_ERR_LVL, | ||
194 | DVBT_VAL_LVL, | ||
195 | DVBT_SERIAL, | ||
196 | DVBT_SER_LSB, | ||
197 | DVBT_CDIV_PH0, | ||
198 | DVBT_CDIV_PH1, | ||
199 | DVBT_MPEG_IO_OPT_2_2, | ||
200 | DVBT_MPEG_IO_OPT_1_0, | ||
201 | DVBT_CKOUTPAR_PIP, | ||
202 | DVBT_CKOUT_PWR_PIP, | ||
203 | DVBT_SYNC_LVL_PIP, | ||
204 | DVBT_ERR_LVL_PIP, | ||
205 | DVBT_VAL_LVL_PIP, | ||
206 | DVBT_CKOUTPAR_PID, | ||
207 | DVBT_CKOUT_PWR_PID, | ||
208 | DVBT_SYNC_LVL_PID, | ||
209 | DVBT_ERR_LVL_PID, | ||
210 | DVBT_VAL_LVL_PID, | ||
211 | DVBT_SM_PASS, | ||
212 | DVBT_UPDATE_REG_2, | ||
213 | DVBT_BTHD_P3, | ||
214 | DVBT_BTHD_D3, | ||
215 | DVBT_FUNC4_REG0, | ||
216 | DVBT_FUNC4_REG1, | ||
217 | DVBT_FUNC4_REG2, | ||
218 | DVBT_FUNC4_REG3, | ||
219 | DVBT_FUNC4_REG4, | ||
220 | DVBT_FUNC4_REG5, | ||
221 | DVBT_FUNC4_REG6, | ||
222 | DVBT_FUNC4_REG7, | ||
223 | DVBT_FUNC4_REG8, | ||
224 | DVBT_FUNC4_REG9, | ||
225 | DVBT_FUNC4_REG10, | ||
226 | DVBT_FUNC5_REG0, | ||
227 | DVBT_FUNC5_REG1, | ||
228 | DVBT_FUNC5_REG2, | ||
229 | DVBT_FUNC5_REG3, | ||
230 | DVBT_FUNC5_REG4, | ||
231 | DVBT_FUNC5_REG5, | ||
232 | DVBT_FUNC5_REG6, | ||
233 | DVBT_FUNC5_REG7, | ||
234 | DVBT_FUNC5_REG8, | ||
235 | DVBT_FUNC5_REG9, | ||
236 | DVBT_FUNC5_REG10, | ||
237 | DVBT_FUNC5_REG11, | ||
238 | DVBT_FUNC5_REG12, | ||
239 | DVBT_FUNC5_REG13, | ||
240 | DVBT_FUNC5_REG14, | ||
241 | DVBT_FUNC5_REG15, | ||
242 | DVBT_FUNC5_REG16, | ||
243 | DVBT_FUNC5_REG17, | ||
244 | DVBT_FUNC5_REG18, | ||
245 | DVBT_AD7_SETTING, | ||
246 | DVBT_RSSI_R, | ||
247 | DVBT_ACI_DET_IND, | ||
248 | DVBT_REG_MON, | ||
249 | DVBT_REG_MONSEL, | ||
250 | DVBT_REG_GPE, | ||
251 | DVBT_REG_GPO, | ||
252 | DVBT_REG_4MSEL, | ||
253 | DVBT_TEST_REG_1, | ||
254 | DVBT_TEST_REG_2, | ||
255 | DVBT_TEST_REG_3, | ||
256 | DVBT_TEST_REG_4, | ||
257 | DVBT_REG_BIT_NAME_ITEM_TERMINATOR, | ||
258 | }; | ||
259 | |||
260 | #endif /* RTL2832_PRIV_H */ | ||
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 2322257c69ae..e2fec9ebf947 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c | |||
@@ -634,7 +634,6 @@ static int s5h1420_set_frontend(struct dvb_frontend *fe) | |||
634 | struct s5h1420_state* state = fe->demodulator_priv; | 634 | struct s5h1420_state* state = fe->demodulator_priv; |
635 | int frequency_delta; | 635 | int frequency_delta; |
636 | struct dvb_frontend_tune_settings fesettings; | 636 | struct dvb_frontend_tune_settings fesettings; |
637 | uint8_t clock_setting; | ||
638 | 637 | ||
639 | dprintk("enter %s\n", __func__); | 638 | dprintk("enter %s\n", __func__); |
640 | 639 | ||
@@ -679,25 +678,6 @@ static int s5h1420_set_frontend(struct dvb_frontend *fe) | |||
679 | else | 678 | else |
680 | state->fclk = 44000000; | 679 | state->fclk = 44000000; |
681 | 680 | ||
682 | /* Clock */ | ||
683 | switch (state->fclk) { | ||
684 | default: | ||
685 | case 88000000: | ||
686 | clock_setting = 80; | ||
687 | break; | ||
688 | case 86000000: | ||
689 | clock_setting = 78; | ||
690 | break; | ||
691 | case 80000000: | ||
692 | clock_setting = 72; | ||
693 | break; | ||
694 | case 59000000: | ||
695 | clock_setting = 51; | ||
696 | break; | ||
697 | case 44000000: | ||
698 | clock_setting = 36; | ||
699 | break; | ||
700 | } | ||
701 | dprintk("pll01: %d, ToneFreq: %d\n", state->fclk/1000000 - 8, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); | 681 | dprintk("pll01: %d, ToneFreq: %d\n", state->fclk/1000000 - 8, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); |
702 | s5h1420_writereg(state, PLL01, state->fclk/1000000 - 8); | 682 | s5h1420_writereg(state, PLL01, state->fclk/1000000 - 8); |
703 | s5h1420_writereg(state, PLL02, 0x40); | 683 | s5h1420_writereg(state, PLL02, 0x40); |
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index 8b0dc74a3298..5d7f8a9b451b 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c | |||
@@ -1129,7 +1129,6 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
1129 | struct stb0899_internal *internal = &state->internal; | 1129 | struct stb0899_internal *internal = &state->internal; |
1130 | 1130 | ||
1131 | u8 lsb, msb; | 1131 | u8 lsb, msb; |
1132 | u32 i; | ||
1133 | 1132 | ||
1134 | *ber = 0; | 1133 | *ber = 0; |
1135 | 1134 | ||
@@ -1137,14 +1136,9 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
1137 | case SYS_DVBS: | 1136 | case SYS_DVBS: |
1138 | case SYS_DSS: | 1137 | case SYS_DSS: |
1139 | if (internal->lock) { | 1138 | if (internal->lock) { |
1140 | /* average 5 BER values */ | 1139 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); |
1141 | for (i = 0; i < 5; i++) { | 1140 | msb = stb0899_read_reg(state, STB0899_ECNT1M); |
1142 | msleep(100); | 1141 | *ber = MAKEWORD16(msb, lsb); |
1143 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); | ||
1144 | msb = stb0899_read_reg(state, STB0899_ECNT1M); | ||
1145 | *ber += MAKEWORD16(msb, lsb); | ||
1146 | } | ||
1147 | *ber /= 5; | ||
1148 | /* Viterbi Check */ | 1142 | /* Viterbi Check */ |
1149 | if (STB0899_GETFIELD(VSTATUS_PRFVIT, internal->v_status)) { | 1143 | if (STB0899_GETFIELD(VSTATUS_PRFVIT, internal->v_status)) { |
1150 | /* Error Rate */ | 1144 | /* Error Rate */ |
@@ -1157,13 +1151,9 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
1157 | break; | 1151 | break; |
1158 | case SYS_DVBS2: | 1152 | case SYS_DVBS2: |
1159 | if (internal->lock) { | 1153 | if (internal->lock) { |
1160 | /* Average 5 PER values */ | 1154 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); |
1161 | for (i = 0; i < 5; i++) { | 1155 | msb = stb0899_read_reg(state, STB0899_ECNT1M); |
1162 | msleep(100); | 1156 | *ber = MAKEWORD16(msb, lsb); |
1163 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); | ||
1164 | msb = stb0899_read_reg(state, STB0899_ECNT1M); | ||
1165 | *ber += MAKEWORD16(msb, lsb); | ||
1166 | } | ||
1167 | /* ber = ber * 10 ^ 7 */ | 1157 | /* ber = ber * 10 ^ 7 */ |
1168 | *ber *= 10000000; | 1158 | *ber *= 10000000; |
1169 | *ber /= (-1 + (1 << (4 + 2 * STB0899_GETFIELD(NOE, internal->err_ctrl)))); | 1159 | *ber /= (-1 + (1 << (4 + 2 * STB0899_GETFIELD(NOE, internal->err_ctrl)))); |
diff --git a/drivers/media/dvb/frontends/stv0367.c b/drivers/media/dvb/frontends/stv0367.c index fdd20c7737b5..2a8aaeb1112d 100644 --- a/drivers/media/dvb/frontends/stv0367.c +++ b/drivers/media/dvb/frontends/stv0367.c | |||
@@ -1584,7 +1584,7 @@ static int stv0367ter_algo(struct dvb_frontend *fe) | |||
1584 | struct stv0367ter_state *ter_state = state->ter_state; | 1584 | struct stv0367ter_state *ter_state = state->ter_state; |
1585 | int offset = 0, tempo = 0; | 1585 | int offset = 0, tempo = 0; |
1586 | u8 u_var; | 1586 | u8 u_var; |
1587 | u8 /*constell,*/ counter, tps_rcvd[2]; | 1587 | u8 /*constell,*/ counter; |
1588 | s8 step; | 1588 | s8 step; |
1589 | s32 timing_offset = 0; | 1589 | s32 timing_offset = 0; |
1590 | u32 trl_nomrate = 0, InternalFreq = 0, temp = 0; | 1590 | u32 trl_nomrate = 0, InternalFreq = 0, temp = 0; |
@@ -1709,9 +1709,6 @@ static int stv0367ter_algo(struct dvb_frontend *fe) | |||
1709 | return 0; | 1709 | return 0; |
1710 | 1710 | ||
1711 | ter_state->state = FE_TER_LOCKOK; | 1711 | ter_state->state = FE_TER_LOCKOK; |
1712 | /* update results */ | ||
1713 | tps_rcvd[0] = stv0367_readreg(state, R367TER_TPS_RCVD2); | ||
1714 | tps_rcvd[1] = stv0367_readreg(state, R367TER_TPS_RCVD3); | ||
1715 | 1712 | ||
1716 | ter_state->mode = stv0367_readbits(state, F367TER_SYR_MODE); | 1713 | ter_state->mode = stv0367_readbits(state, F367TER_SYR_MODE); |
1717 | ter_state->guard = stv0367_readbits(state, F367TER_SYR_GUARD); | 1714 | ter_state->guard = stv0367_readbits(state, F367TER_SYR_GUARD); |
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index d79e69f65cbb..ea86a5603e57 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
@@ -3172,7 +3172,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3172 | enum stv090x_signal_state signal_state = STV090x_NOCARRIER; | 3172 | enum stv090x_signal_state signal_state = STV090x_NOCARRIER; |
3173 | u32 reg; | 3173 | u32 reg; |
3174 | s32 agc1_power, power_iq = 0, i; | 3174 | s32 agc1_power, power_iq = 0, i; |
3175 | int lock = 0, low_sr = 0, no_signal = 0; | 3175 | int lock = 0, low_sr = 0; |
3176 | 3176 | ||
3177 | reg = STV090x_READ_DEMOD(state, TSCFGH); | 3177 | reg = STV090x_READ_DEMOD(state, TSCFGH); |
3178 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream merger */ | 3178 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream merger */ |
@@ -3413,7 +3413,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3413 | goto err; | 3413 | goto err; |
3414 | } else { | 3414 | } else { |
3415 | signal_state = STV090x_NODATA; | 3415 | signal_state = STV090x_NODATA; |
3416 | no_signal = stv090x_chk_signal(state); | 3416 | stv090x_chk_signal(state); |
3417 | } | 3417 | } |
3418 | } | 3418 | } |
3419 | return signal_state; | 3419 | return signal_state; |
diff --git a/drivers/media/dvb/frontends/tda10071.c b/drivers/media/dvb/frontends/tda10071.c index c21bc92d2811..703c3d05f9f4 100644 --- a/drivers/media/dvb/frontends/tda10071.c +++ b/drivers/media/dvb/frontends/tda10071.c | |||
@@ -20,10 +20,6 @@ | |||
20 | 20 | ||
21 | #include "tda10071_priv.h" | 21 | #include "tda10071_priv.h" |
22 | 22 | ||
23 | int tda10071_debug; | ||
24 | module_param_named(debug, tda10071_debug, int, 0644); | ||
25 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
26 | |||
27 | static struct dvb_frontend_ops tda10071_ops; | 23 | static struct dvb_frontend_ops tda10071_ops; |
28 | 24 | ||
29 | /* write multiple registers */ | 25 | /* write multiple registers */ |
@@ -48,7 +44,8 @@ static int tda10071_wr_regs(struct tda10071_priv *priv, u8 reg, u8 *val, | |||
48 | if (ret == 1) { | 44 | if (ret == 1) { |
49 | ret = 0; | 45 | ret = 0; |
50 | } else { | 46 | } else { |
51 | warn("i2c wr failed=%d reg=%02x len=%d", ret, reg, len); | 47 | dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ |
48 | "len=%d\n", KBUILD_MODNAME, ret, reg, len); | ||
52 | ret = -EREMOTEIO; | 49 | ret = -EREMOTEIO; |
53 | } | 50 | } |
54 | return ret; | 51 | return ret; |
@@ -79,7 +76,8 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val, | |||
79 | memcpy(val, buf, len); | 76 | memcpy(val, buf, len); |
80 | ret = 0; | 77 | ret = 0; |
81 | } else { | 78 | } else { |
82 | warn("i2c rd failed=%d reg=%02x len=%d", ret, reg, len); | 79 | dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ |
80 | "len=%d\n", KBUILD_MODNAME, ret, reg, len); | ||
83 | ret = -EREMOTEIO; | 81 | ret = -EREMOTEIO; |
84 | } | 82 | } |
85 | return ret; | 83 | return ret; |
@@ -170,7 +168,7 @@ static int tda10071_cmd_execute(struct tda10071_priv *priv, | |||
170 | usleep_range(200, 5000); | 168 | usleep_range(200, 5000); |
171 | } | 169 | } |
172 | 170 | ||
173 | dbg("%s: loop=%d", __func__, i); | 171 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
174 | 172 | ||
175 | if (i == 0) { | 173 | if (i == 0) { |
176 | ret = -ETIMEDOUT; | 174 | ret = -ETIMEDOUT; |
@@ -179,7 +177,7 @@ static int tda10071_cmd_execute(struct tda10071_priv *priv, | |||
179 | 177 | ||
180 | return ret; | 178 | return ret; |
181 | error: | 179 | error: |
182 | dbg("%s: failed=%d", __func__, ret); | 180 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
183 | return ret; | 181 | return ret; |
184 | } | 182 | } |
185 | 183 | ||
@@ -196,7 +194,8 @@ static int tda10071_set_tone(struct dvb_frontend *fe, | |||
196 | goto error; | 194 | goto error; |
197 | } | 195 | } |
198 | 196 | ||
199 | dbg("%s: tone_mode=%d", __func__, fe_sec_tone_mode); | 197 | dev_dbg(&priv->i2c->dev, "%s: tone_mode=%d\n", __func__, |
198 | fe_sec_tone_mode); | ||
200 | 199 | ||
201 | switch (fe_sec_tone_mode) { | 200 | switch (fe_sec_tone_mode) { |
202 | case SEC_TONE_ON: | 201 | case SEC_TONE_ON: |
@@ -206,24 +205,25 @@ static int tda10071_set_tone(struct dvb_frontend *fe, | |||
206 | tone = 0; | 205 | tone = 0; |
207 | break; | 206 | break; |
208 | default: | 207 | default: |
209 | dbg("%s: invalid fe_sec_tone_mode", __func__); | 208 | dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_tone_mode\n", |
209 | __func__); | ||
210 | ret = -EINVAL; | 210 | ret = -EINVAL; |
211 | goto error; | 211 | goto error; |
212 | } | 212 | } |
213 | 213 | ||
214 | cmd.args[0x00] = CMD_LNB_PCB_CONFIG; | 214 | cmd.args[0] = CMD_LNB_PCB_CONFIG; |
215 | cmd.args[0x01] = 0; | 215 | cmd.args[1] = 0; |
216 | cmd.args[0x02] = 0x00; | 216 | cmd.args[2] = 0x00; |
217 | cmd.args[0x03] = 0x00; | 217 | cmd.args[3] = 0x00; |
218 | cmd.args[0x04] = tone; | 218 | cmd.args[4] = tone; |
219 | cmd.len = 0x05; | 219 | cmd.len = 5; |
220 | ret = tda10071_cmd_execute(priv, &cmd); | 220 | ret = tda10071_cmd_execute(priv, &cmd); |
221 | if (ret) | 221 | if (ret) |
222 | goto error; | 222 | goto error; |
223 | 223 | ||
224 | return ret; | 224 | return ret; |
225 | error: | 225 | error: |
226 | dbg("%s: failed=%d", __func__, ret); | 226 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
227 | return ret; | 227 | return ret; |
228 | } | 228 | } |
229 | 229 | ||
@@ -240,7 +240,7 @@ static int tda10071_set_voltage(struct dvb_frontend *fe, | |||
240 | goto error; | 240 | goto error; |
241 | } | 241 | } |
242 | 242 | ||
243 | dbg("%s: voltage=%d", __func__, fe_sec_voltage); | 243 | dev_dbg(&priv->i2c->dev, "%s: voltage=%d\n", __func__, fe_sec_voltage); |
244 | 244 | ||
245 | switch (fe_sec_voltage) { | 245 | switch (fe_sec_voltage) { |
246 | case SEC_VOLTAGE_13: | 246 | case SEC_VOLTAGE_13: |
@@ -253,22 +253,23 @@ static int tda10071_set_voltage(struct dvb_frontend *fe, | |||
253 | voltage = 0; | 253 | voltage = 0; |
254 | break; | 254 | break; |
255 | default: | 255 | default: |
256 | dbg("%s: invalid fe_sec_voltage", __func__); | 256 | dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_voltage\n", |
257 | __func__); | ||
257 | ret = -EINVAL; | 258 | ret = -EINVAL; |
258 | goto error; | 259 | goto error; |
259 | }; | 260 | }; |
260 | 261 | ||
261 | cmd.args[0x00] = CMD_LNB_SET_DC_LEVEL; | 262 | cmd.args[0] = CMD_LNB_SET_DC_LEVEL; |
262 | cmd.args[0x01] = 0; | 263 | cmd.args[1] = 0; |
263 | cmd.args[0x02] = voltage; | 264 | cmd.args[2] = voltage; |
264 | cmd.len = 0x03; | 265 | cmd.len = 3; |
265 | ret = tda10071_cmd_execute(priv, &cmd); | 266 | ret = tda10071_cmd_execute(priv, &cmd); |
266 | if (ret) | 267 | if (ret) |
267 | goto error; | 268 | goto error; |
268 | 269 | ||
269 | return ret; | 270 | return ret; |
270 | error: | 271 | error: |
271 | dbg("%s: failed=%d", __func__, ret); | 272 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
272 | return ret; | 273 | return ret; |
273 | } | 274 | } |
274 | 275 | ||
@@ -285,9 +286,10 @@ static int tda10071_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
285 | goto error; | 286 | goto error; |
286 | } | 287 | } |
287 | 288 | ||
288 | dbg("%s: msg_len=%d", __func__, diseqc_cmd->msg_len); | 289 | dev_dbg(&priv->i2c->dev, "%s: msg_len=%d\n", __func__, |
290 | diseqc_cmd->msg_len); | ||
289 | 291 | ||
290 | if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 16) { | 292 | if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 6) { |
291 | ret = -EINVAL; | 293 | ret = -EINVAL; |
292 | goto error; | 294 | goto error; |
293 | } | 295 | } |
@@ -301,7 +303,7 @@ static int tda10071_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
301 | usleep_range(10000, 20000); | 303 | usleep_range(10000, 20000); |
302 | } | 304 | } |
303 | 305 | ||
304 | dbg("%s: loop=%d", __func__, i); | 306 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
305 | 307 | ||
306 | if (i == 0) { | 308 | if (i == 0) { |
307 | ret = -ETIMEDOUT; | 309 | ret = -ETIMEDOUT; |
@@ -312,22 +314,22 @@ static int tda10071_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
312 | if (ret) | 314 | if (ret) |
313 | goto error; | 315 | goto error; |
314 | 316 | ||
315 | cmd.args[0x00] = CMD_LNB_SEND_DISEQC; | 317 | cmd.args[0] = CMD_LNB_SEND_DISEQC; |
316 | cmd.args[0x01] = 0; | 318 | cmd.args[1] = 0; |
317 | cmd.args[0x02] = 0; | 319 | cmd.args[2] = 0; |
318 | cmd.args[0x03] = 0; | 320 | cmd.args[3] = 0; |
319 | cmd.args[0x04] = 2; | 321 | cmd.args[4] = 2; |
320 | cmd.args[0x05] = 0; | 322 | cmd.args[5] = 0; |
321 | cmd.args[0x06] = diseqc_cmd->msg_len; | 323 | cmd.args[6] = diseqc_cmd->msg_len; |
322 | memcpy(&cmd.args[0x07], diseqc_cmd->msg, diseqc_cmd->msg_len); | 324 | memcpy(&cmd.args[7], diseqc_cmd->msg, diseqc_cmd->msg_len); |
323 | cmd.len = 0x07 + diseqc_cmd->msg_len; | 325 | cmd.len = 7 + diseqc_cmd->msg_len; |
324 | ret = tda10071_cmd_execute(priv, &cmd); | 326 | ret = tda10071_cmd_execute(priv, &cmd); |
325 | if (ret) | 327 | if (ret) |
326 | goto error; | 328 | goto error; |
327 | 329 | ||
328 | return ret; | 330 | return ret; |
329 | error: | 331 | error: |
330 | dbg("%s: failed=%d", __func__, ret); | 332 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
331 | return ret; | 333 | return ret; |
332 | } | 334 | } |
333 | 335 | ||
@@ -344,7 +346,7 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
344 | goto error; | 346 | goto error; |
345 | } | 347 | } |
346 | 348 | ||
347 | dbg("%s:", __func__); | 349 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); |
348 | 350 | ||
349 | /* wait LNB RX */ | 351 | /* wait LNB RX */ |
350 | for (i = 500, tmp = 0; i && !tmp; i--) { | 352 | for (i = 500, tmp = 0; i && !tmp; i--) { |
@@ -355,7 +357,7 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
355 | usleep_range(10000, 20000); | 357 | usleep_range(10000, 20000); |
356 | } | 358 | } |
357 | 359 | ||
358 | dbg("%s: loop=%d", __func__, i); | 360 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
359 | 361 | ||
360 | if (i == 0) { | 362 | if (i == 0) { |
361 | ret = -ETIMEDOUT; | 363 | ret = -ETIMEDOUT; |
@@ -372,9 +374,9 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
372 | reply->msg_len = sizeof(reply->msg); /* truncate API max */ | 374 | reply->msg_len = sizeof(reply->msg); /* truncate API max */ |
373 | 375 | ||
374 | /* read reply */ | 376 | /* read reply */ |
375 | cmd.args[0x00] = CMD_LNB_UPDATE_REPLY; | 377 | cmd.args[0] = CMD_LNB_UPDATE_REPLY; |
376 | cmd.args[0x01] = 0; | 378 | cmd.args[1] = 0; |
377 | cmd.len = 0x02; | 379 | cmd.len = 2; |
378 | ret = tda10071_cmd_execute(priv, &cmd); | 380 | ret = tda10071_cmd_execute(priv, &cmd); |
379 | if (ret) | 381 | if (ret) |
380 | goto error; | 382 | goto error; |
@@ -385,7 +387,7 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
385 | 387 | ||
386 | return ret; | 388 | return ret; |
387 | error: | 389 | error: |
388 | dbg("%s: failed=%d", __func__, ret); | 390 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
389 | return ret; | 391 | return ret; |
390 | } | 392 | } |
391 | 393 | ||
@@ -402,7 +404,8 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
402 | goto error; | 404 | goto error; |
403 | } | 405 | } |
404 | 406 | ||
405 | dbg("%s: fe_sec_mini_cmd=%d", __func__, fe_sec_mini_cmd); | 407 | dev_dbg(&priv->i2c->dev, "%s: fe_sec_mini_cmd=%d\n", __func__, |
408 | fe_sec_mini_cmd); | ||
406 | 409 | ||
407 | switch (fe_sec_mini_cmd) { | 410 | switch (fe_sec_mini_cmd) { |
408 | case SEC_MINI_A: | 411 | case SEC_MINI_A: |
@@ -412,7 +415,8 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
412 | burst = 1; | 415 | burst = 1; |
413 | break; | 416 | break; |
414 | default: | 417 | default: |
415 | dbg("%s: invalid fe_sec_mini_cmd", __func__); | 418 | dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_mini_cmd\n", |
419 | __func__); | ||
416 | ret = -EINVAL; | 420 | ret = -EINVAL; |
417 | goto error; | 421 | goto error; |
418 | } | 422 | } |
@@ -426,7 +430,7 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
426 | usleep_range(10000, 20000); | 430 | usleep_range(10000, 20000); |
427 | } | 431 | } |
428 | 432 | ||
429 | dbg("%s: loop=%d", __func__, i); | 433 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
430 | 434 | ||
431 | if (i == 0) { | 435 | if (i == 0) { |
432 | ret = -ETIMEDOUT; | 436 | ret = -ETIMEDOUT; |
@@ -437,17 +441,17 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
437 | if (ret) | 441 | if (ret) |
438 | goto error; | 442 | goto error; |
439 | 443 | ||
440 | cmd.args[0x00] = CMD_LNB_SEND_TONEBURST; | 444 | cmd.args[0] = CMD_LNB_SEND_TONEBURST; |
441 | cmd.args[0x01] = 0; | 445 | cmd.args[1] = 0; |
442 | cmd.args[0x02] = burst; | 446 | cmd.args[2] = burst; |
443 | cmd.len = 0x03; | 447 | cmd.len = 3; |
444 | ret = tda10071_cmd_execute(priv, &cmd); | 448 | ret = tda10071_cmd_execute(priv, &cmd); |
445 | if (ret) | 449 | if (ret) |
446 | goto error; | 450 | goto error; |
447 | 451 | ||
448 | return ret; | 452 | return ret; |
449 | error: | 453 | error: |
450 | dbg("%s: failed=%d", __func__, ret); | 454 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
451 | return ret; | 455 | return ret; |
452 | } | 456 | } |
453 | 457 | ||
@@ -481,7 +485,7 @@ static int tda10071_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
481 | 485 | ||
482 | return ret; | 486 | return ret; |
483 | error: | 487 | error: |
484 | dbg("%s: failed=%d", __func__, ret); | 488 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
485 | return ret; | 489 | return ret; |
486 | } | 490 | } |
487 | 491 | ||
@@ -506,7 +510,7 @@ static int tda10071_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
506 | 510 | ||
507 | return ret; | 511 | return ret; |
508 | error: | 512 | error: |
509 | dbg("%s: failed=%d", __func__, ret); | 513 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
510 | return ret; | 514 | return ret; |
511 | } | 515 | } |
512 | 516 | ||
@@ -523,9 +527,9 @@ static int tda10071_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
523 | goto error; | 527 | goto error; |
524 | } | 528 | } |
525 | 529 | ||
526 | cmd.args[0x00] = CMD_GET_AGCACC; | 530 | cmd.args[0] = CMD_GET_AGCACC; |
527 | cmd.args[0x01] = 0; | 531 | cmd.args[1] = 0; |
528 | cmd.len = 0x02; | 532 | cmd.len = 2; |
529 | ret = tda10071_cmd_execute(priv, &cmd); | 533 | ret = tda10071_cmd_execute(priv, &cmd); |
530 | if (ret) | 534 | if (ret) |
531 | goto error; | 535 | goto error; |
@@ -545,7 +549,7 @@ static int tda10071_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
545 | 549 | ||
546 | return ret; | 550 | return ret; |
547 | error: | 551 | error: |
548 | dbg("%s: failed=%d", __func__, ret); | 552 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
549 | return ret; | 553 | return ret; |
550 | } | 554 | } |
551 | 555 | ||
@@ -583,17 +587,18 @@ static int tda10071_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
583 | goto error; | 587 | goto error; |
584 | 588 | ||
585 | if (priv->meas_count[i] == tmp) { | 589 | if (priv->meas_count[i] == tmp) { |
586 | dbg("%s: meas not ready=%02x", __func__, tmp); | 590 | dev_dbg(&priv->i2c->dev, "%s: meas not ready=%02x\n", __func__, |
591 | tmp); | ||
587 | *ber = priv->ber; | 592 | *ber = priv->ber; |
588 | return 0; | 593 | return 0; |
589 | } else { | 594 | } else { |
590 | priv->meas_count[i] = tmp; | 595 | priv->meas_count[i] = tmp; |
591 | } | 596 | } |
592 | 597 | ||
593 | cmd.args[0x00] = CMD_BER_UPDATE_COUNTERS; | 598 | cmd.args[0] = CMD_BER_UPDATE_COUNTERS; |
594 | cmd.args[0x01] = 0; | 599 | cmd.args[1] = 0; |
595 | cmd.args[0x02] = i; | 600 | cmd.args[2] = i; |
596 | cmd.len = 0x03; | 601 | cmd.len = 3; |
597 | ret = tda10071_cmd_execute(priv, &cmd); | 602 | ret = tda10071_cmd_execute(priv, &cmd); |
598 | if (ret) | 603 | if (ret) |
599 | goto error; | 604 | goto error; |
@@ -612,7 +617,7 @@ static int tda10071_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
612 | 617 | ||
613 | return ret; | 618 | return ret; |
614 | error: | 619 | error: |
615 | dbg("%s: failed=%d", __func__, ret); | 620 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
616 | return ret; | 621 | return ret; |
617 | } | 622 | } |
618 | 623 | ||
@@ -632,7 +637,7 @@ static int tda10071_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
632 | 637 | ||
633 | return ret; | 638 | return ret; |
634 | error: | 639 | error: |
635 | dbg("%s: failed=%d", __func__, ret); | 640 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
636 | return ret; | 641 | return ret; |
637 | } | 642 | } |
638 | 643 | ||
@@ -644,10 +649,11 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
644 | int ret, i; | 649 | int ret, i; |
645 | u8 mode, rolloff, pilot, inversion, div; | 650 | u8 mode, rolloff, pilot, inversion, div; |
646 | 651 | ||
647 | dbg("%s: delivery_system=%d modulation=%d frequency=%d " \ | 652 | dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d modulation=%d " \ |
648 | "symbol_rate=%d inversion=%d pilot=%d rolloff=%d", __func__, | 653 | "frequency=%d symbol_rate=%d inversion=%d pilot=%d " \ |
649 | c->delivery_system, c->modulation, c->frequency, | 654 | "rolloff=%d\n", __func__, c->delivery_system, c->modulation, |
650 | c->symbol_rate, c->inversion, c->pilot, c->rolloff); | 655 | c->frequency, c->symbol_rate, c->inversion, c->pilot, |
656 | c->rolloff); | ||
651 | 657 | ||
652 | priv->delivery_system = SYS_UNDEFINED; | 658 | priv->delivery_system = SYS_UNDEFINED; |
653 | 659 | ||
@@ -669,7 +675,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
669 | inversion = 3; | 675 | inversion = 3; |
670 | break; | 676 | break; |
671 | default: | 677 | default: |
672 | dbg("%s: invalid inversion", __func__); | 678 | dev_dbg(&priv->i2c->dev, "%s: invalid inversion\n", __func__); |
673 | ret = -EINVAL; | 679 | ret = -EINVAL; |
674 | goto error; | 680 | goto error; |
675 | } | 681 | } |
@@ -692,7 +698,8 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
692 | break; | 698 | break; |
693 | case ROLLOFF_AUTO: | 699 | case ROLLOFF_AUTO: |
694 | default: | 700 | default: |
695 | dbg("%s: invalid rolloff", __func__); | 701 | dev_dbg(&priv->i2c->dev, "%s: invalid rolloff\n", |
702 | __func__); | ||
696 | ret = -EINVAL; | 703 | ret = -EINVAL; |
697 | goto error; | 704 | goto error; |
698 | } | 705 | } |
@@ -708,13 +715,15 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
708 | pilot = 2; | 715 | pilot = 2; |
709 | break; | 716 | break; |
710 | default: | 717 | default: |
711 | dbg("%s: invalid pilot", __func__); | 718 | dev_dbg(&priv->i2c->dev, "%s: invalid pilot\n", |
719 | __func__); | ||
712 | ret = -EINVAL; | 720 | ret = -EINVAL; |
713 | goto error; | 721 | goto error; |
714 | } | 722 | } |
715 | break; | 723 | break; |
716 | default: | 724 | default: |
717 | dbg("%s: invalid delivery_system", __func__); | 725 | dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", |
726 | __func__); | ||
718 | ret = -EINVAL; | 727 | ret = -EINVAL; |
719 | goto error; | 728 | goto error; |
720 | } | 729 | } |
@@ -724,13 +733,15 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
724 | c->modulation == TDA10071_MODCOD[i].modulation && | 733 | c->modulation == TDA10071_MODCOD[i].modulation && |
725 | c->fec_inner == TDA10071_MODCOD[i].fec) { | 734 | c->fec_inner == TDA10071_MODCOD[i].fec) { |
726 | mode = TDA10071_MODCOD[i].val; | 735 | mode = TDA10071_MODCOD[i].val; |
727 | dbg("%s: mode found=%02x", __func__, mode); | 736 | dev_dbg(&priv->i2c->dev, "%s: mode found=%02x\n", |
737 | __func__, mode); | ||
728 | break; | 738 | break; |
729 | } | 739 | } |
730 | } | 740 | } |
731 | 741 | ||
732 | if (mode == 0xff) { | 742 | if (mode == 0xff) { |
733 | dbg("%s: invalid parameter combination", __func__); | 743 | dev_dbg(&priv->i2c->dev, "%s: invalid parameter combination\n", |
744 | __func__); | ||
734 | ret = -EINVAL; | 745 | ret = -EINVAL; |
735 | goto error; | 746 | goto error; |
736 | } | 747 | } |
@@ -748,22 +759,22 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
748 | if (ret) | 759 | if (ret) |
749 | goto error; | 760 | goto error; |
750 | 761 | ||
751 | cmd.args[0x00] = CMD_CHANGE_CHANNEL; | 762 | cmd.args[0] = CMD_CHANGE_CHANNEL; |
752 | cmd.args[0x01] = 0; | 763 | cmd.args[1] = 0; |
753 | cmd.args[0x02] = mode; | 764 | cmd.args[2] = mode; |
754 | cmd.args[0x03] = (c->frequency >> 16) & 0xff; | 765 | cmd.args[3] = (c->frequency >> 16) & 0xff; |
755 | cmd.args[0x04] = (c->frequency >> 8) & 0xff; | 766 | cmd.args[4] = (c->frequency >> 8) & 0xff; |
756 | cmd.args[0x05] = (c->frequency >> 0) & 0xff; | 767 | cmd.args[5] = (c->frequency >> 0) & 0xff; |
757 | cmd.args[0x06] = ((c->symbol_rate / 1000) >> 8) & 0xff; | 768 | cmd.args[6] = ((c->symbol_rate / 1000) >> 8) & 0xff; |
758 | cmd.args[0x07] = ((c->symbol_rate / 1000) >> 0) & 0xff; | 769 | cmd.args[7] = ((c->symbol_rate / 1000) >> 0) & 0xff; |
759 | cmd.args[0x08] = (tda10071_ops.info.frequency_tolerance >> 8) & 0xff; | 770 | cmd.args[8] = (tda10071_ops.info.frequency_tolerance >> 8) & 0xff; |
760 | cmd.args[0x09] = (tda10071_ops.info.frequency_tolerance >> 0) & 0xff; | 771 | cmd.args[9] = (tda10071_ops.info.frequency_tolerance >> 0) & 0xff; |
761 | cmd.args[0x0a] = rolloff; | 772 | cmd.args[10] = rolloff; |
762 | cmd.args[0x0b] = inversion; | 773 | cmd.args[11] = inversion; |
763 | cmd.args[0x0c] = pilot; | 774 | cmd.args[12] = pilot; |
764 | cmd.args[0x0d] = 0x00; | 775 | cmd.args[13] = 0x00; |
765 | cmd.args[0x0e] = 0x00; | 776 | cmd.args[14] = 0x00; |
766 | cmd.len = 0x0f; | 777 | cmd.len = 15; |
767 | ret = tda10071_cmd_execute(priv, &cmd); | 778 | ret = tda10071_cmd_execute(priv, &cmd); |
768 | if (ret) | 779 | if (ret) |
769 | goto error; | 780 | goto error; |
@@ -772,7 +783,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
772 | 783 | ||
773 | return ret; | 784 | return ret; |
774 | error: | 785 | error: |
775 | dbg("%s: failed=%d", __func__, ret); | 786 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
776 | return ret; | 787 | return ret; |
777 | } | 788 | } |
778 | 789 | ||
@@ -829,7 +840,7 @@ static int tda10071_get_frontend(struct dvb_frontend *fe) | |||
829 | 840 | ||
830 | return ret; | 841 | return ret; |
831 | error: | 842 | error: |
832 | dbg("%s: failed=%d", __func__, ret); | 843 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
833 | return ret; | 844 | return ret; |
834 | } | 845 | } |
835 | 846 | ||
@@ -915,10 +926,10 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
915 | goto error; | 926 | goto error; |
916 | } | 927 | } |
917 | 928 | ||
918 | cmd.args[0x00] = CMD_SET_SLEEP_MODE; | 929 | cmd.args[0] = CMD_SET_SLEEP_MODE; |
919 | cmd.args[0x01] = 0; | 930 | cmd.args[1] = 0; |
920 | cmd.args[0x02] = 0; | 931 | cmd.args[2] = 0; |
921 | cmd.len = 0x03; | 932 | cmd.len = 3; |
922 | ret = tda10071_cmd_execute(priv, &cmd); | 933 | ret = tda10071_cmd_execute(priv, &cmd); |
923 | if (ret) | 934 | if (ret) |
924 | goto error; | 935 | goto error; |
@@ -929,10 +940,11 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
929 | /* request the firmware, this will block and timeout */ | 940 | /* request the firmware, this will block and timeout */ |
930 | ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); | 941 | ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); |
931 | if (ret) { | 942 | if (ret) { |
932 | err("did not find the firmware file. (%s) " | 943 | dev_err(&priv->i2c->dev, "%s: did not find the " \ |
933 | "Please see linux/Documentation/dvb/ for more" \ | 944 | "firmware file. (%s) Please see " \ |
934 | " details on firmware-problems. (%d)", | 945 | "linux/Documentation/dvb/ for more " \ |
935 | fw_file, ret); | 946 | "details on firmware-problems. (%d)\n", |
947 | KBUILD_MODNAME, fw_file, ret); | ||
936 | goto error; | 948 | goto error; |
937 | } | 949 | } |
938 | 950 | ||
@@ -961,10 +973,11 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
961 | if (ret) | 973 | if (ret) |
962 | goto error_release_firmware; | 974 | goto error_release_firmware; |
963 | 975 | ||
964 | info("found a '%s' in cold state, will try to load a firmware", | 976 | dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state, " \ |
965 | tda10071_ops.info.name); | 977 | "will try to load a firmware\n", KBUILD_MODNAME, |
966 | 978 | tda10071_ops.info.name); | |
967 | info("downloading firmware from file '%s'", fw_file); | 979 | dev_info(&priv->i2c->dev, "%s: downloading firmware from " \ |
980 | "file '%s'\n", KBUILD_MODNAME, fw_file); | ||
968 | 981 | ||
969 | /* do not download last byte */ | 982 | /* do not download last byte */ |
970 | fw_size = fw->size - 1; | 983 | fw_size = fw->size - 1; |
@@ -978,7 +991,9 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
978 | ret = tda10071_wr_regs(priv, 0xfa, | 991 | ret = tda10071_wr_regs(priv, 0xfa, |
979 | (u8 *) &fw->data[fw_size - remaining], len); | 992 | (u8 *) &fw->data[fw_size - remaining], len); |
980 | if (ret) { | 993 | if (ret) { |
981 | err("firmware download failed=%d", ret); | 994 | dev_err(&priv->i2c->dev, "%s: firmware " \ |
995 | "download failed=%d\n", | ||
996 | KBUILD_MODNAME, ret); | ||
982 | if (ret) | 997 | if (ret) |
983 | goto error_release_firmware; | 998 | goto error_release_firmware; |
984 | } | 999 | } |
@@ -1002,15 +1017,16 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1002 | goto error; | 1017 | goto error; |
1003 | 1018 | ||
1004 | if (tmp) { | 1019 | if (tmp) { |
1005 | info("firmware did not run"); | 1020 | dev_info(&priv->i2c->dev, "%s: firmware did not run\n", |
1021 | KBUILD_MODNAME); | ||
1006 | ret = -EFAULT; | 1022 | ret = -EFAULT; |
1007 | goto error; | 1023 | goto error; |
1008 | } else { | 1024 | } else { |
1009 | priv->warm = 1; | 1025 | priv->warm = 1; |
1010 | } | 1026 | } |
1011 | 1027 | ||
1012 | cmd.args[0x00] = CMD_GET_FW_VERSION; | 1028 | cmd.args[0] = CMD_GET_FW_VERSION; |
1013 | cmd.len = 0x01; | 1029 | cmd.len = 1; |
1014 | ret = tda10071_cmd_execute(priv, &cmd); | 1030 | ret = tda10071_cmd_execute(priv, &cmd); |
1015 | if (ret) | 1031 | if (ret) |
1016 | goto error; | 1032 | goto error; |
@@ -1019,54 +1035,55 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1019 | if (ret) | 1035 | if (ret) |
1020 | goto error; | 1036 | goto error; |
1021 | 1037 | ||
1022 | info("firmware version %d.%d.%d.%d", | 1038 | dev_info(&priv->i2c->dev, "%s: firmware version %d.%d.%d.%d\n", |
1023 | buf[0], buf[1], buf[2], buf[3]); | 1039 | KBUILD_MODNAME, buf[0], buf[1], buf[2], buf[3]); |
1024 | info("found a '%s' in warm state.", tda10071_ops.info.name); | 1040 | dev_info(&priv->i2c->dev, "%s: found a '%s' in warm state\n", |
1041 | KBUILD_MODNAME, tda10071_ops.info.name); | ||
1025 | 1042 | ||
1026 | ret = tda10071_rd_regs(priv, 0x81, buf, 2); | 1043 | ret = tda10071_rd_regs(priv, 0x81, buf, 2); |
1027 | if (ret) | 1044 | if (ret) |
1028 | goto error; | 1045 | goto error; |
1029 | 1046 | ||
1030 | cmd.args[0x00] = CMD_DEMOD_INIT; | 1047 | cmd.args[0] = CMD_DEMOD_INIT; |
1031 | cmd.args[0x01] = ((priv->cfg.xtal / 1000) >> 8) & 0xff; | 1048 | cmd.args[1] = ((priv->cfg.xtal / 1000) >> 8) & 0xff; |
1032 | cmd.args[0x02] = ((priv->cfg.xtal / 1000) >> 0) & 0xff; | 1049 | cmd.args[2] = ((priv->cfg.xtal / 1000) >> 0) & 0xff; |
1033 | cmd.args[0x03] = buf[0]; | 1050 | cmd.args[3] = buf[0]; |
1034 | cmd.args[0x04] = buf[1]; | 1051 | cmd.args[4] = buf[1]; |
1035 | cmd.args[0x05] = priv->cfg.pll_multiplier; | 1052 | cmd.args[5] = priv->cfg.pll_multiplier; |
1036 | cmd.args[0x06] = priv->cfg.spec_inv; | 1053 | cmd.args[6] = priv->cfg.spec_inv; |
1037 | cmd.args[0x07] = 0x00; | 1054 | cmd.args[7] = 0x00; |
1038 | cmd.len = 0x08; | 1055 | cmd.len = 8; |
1039 | ret = tda10071_cmd_execute(priv, &cmd); | 1056 | ret = tda10071_cmd_execute(priv, &cmd); |
1040 | if (ret) | 1057 | if (ret) |
1041 | goto error; | 1058 | goto error; |
1042 | 1059 | ||
1043 | cmd.args[0x00] = CMD_TUNER_INIT; | 1060 | cmd.args[0] = CMD_TUNER_INIT; |
1044 | cmd.args[0x01] = 0x00; | 1061 | cmd.args[1] = 0x00; |
1045 | cmd.args[0x02] = 0x00; | 1062 | cmd.args[2] = 0x00; |
1046 | cmd.args[0x03] = 0x00; | 1063 | cmd.args[3] = 0x00; |
1047 | cmd.args[0x04] = 0x00; | 1064 | cmd.args[4] = 0x00; |
1048 | cmd.args[0x05] = 0x14; | 1065 | cmd.args[5] = 0x14; |
1049 | cmd.args[0x06] = 0x00; | 1066 | cmd.args[6] = 0x00; |
1050 | cmd.args[0x07] = 0x03; | 1067 | cmd.args[7] = 0x03; |
1051 | cmd.args[0x08] = 0x02; | 1068 | cmd.args[8] = 0x02; |
1052 | cmd.args[0x09] = 0x02; | 1069 | cmd.args[9] = 0x02; |
1053 | cmd.args[0x0a] = 0x00; | 1070 | cmd.args[10] = 0x00; |
1054 | cmd.args[0x0b] = 0x00; | 1071 | cmd.args[11] = 0x00; |
1055 | cmd.args[0x0c] = 0x00; | 1072 | cmd.args[12] = 0x00; |
1056 | cmd.args[0x0d] = 0x00; | 1073 | cmd.args[13] = 0x00; |
1057 | cmd.args[0x0e] = 0x00; | 1074 | cmd.args[14] = 0x00; |
1058 | cmd.len = 0x0f; | 1075 | cmd.len = 15; |
1059 | ret = tda10071_cmd_execute(priv, &cmd); | 1076 | ret = tda10071_cmd_execute(priv, &cmd); |
1060 | if (ret) | 1077 | if (ret) |
1061 | goto error; | 1078 | goto error; |
1062 | 1079 | ||
1063 | cmd.args[0x00] = CMD_MPEG_CONFIG; | 1080 | cmd.args[0] = CMD_MPEG_CONFIG; |
1064 | cmd.args[0x01] = 0; | 1081 | cmd.args[1] = 0; |
1065 | cmd.args[0x02] = priv->cfg.ts_mode; | 1082 | cmd.args[2] = priv->cfg.ts_mode; |
1066 | cmd.args[0x03] = 0x00; | 1083 | cmd.args[3] = 0x00; |
1067 | cmd.args[0x04] = 0x04; | 1084 | cmd.args[4] = 0x04; |
1068 | cmd.args[0x05] = 0x00; | 1085 | cmd.args[5] = 0x00; |
1069 | cmd.len = 0x06; | 1086 | cmd.len = 6; |
1070 | ret = tda10071_cmd_execute(priv, &cmd); | 1087 | ret = tda10071_cmd_execute(priv, &cmd); |
1071 | if (ret) | 1088 | if (ret) |
1072 | goto error; | 1089 | goto error; |
@@ -1075,27 +1092,27 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1075 | if (ret) | 1092 | if (ret) |
1076 | goto error; | 1093 | goto error; |
1077 | 1094 | ||
1078 | cmd.args[0x00] = CMD_LNB_CONFIG; | 1095 | cmd.args[0] = CMD_LNB_CONFIG; |
1079 | cmd.args[0x01] = 0; | 1096 | cmd.args[1] = 0; |
1080 | cmd.args[0x02] = 150; | 1097 | cmd.args[2] = 150; |
1081 | cmd.args[0x03] = 3; | 1098 | cmd.args[3] = 3; |
1082 | cmd.args[0x04] = 22; | 1099 | cmd.args[4] = 22; |
1083 | cmd.args[0x05] = 1; | 1100 | cmd.args[5] = 1; |
1084 | cmd.args[0x06] = 1; | 1101 | cmd.args[6] = 1; |
1085 | cmd.args[0x07] = 30; | 1102 | cmd.args[7] = 30; |
1086 | cmd.args[0x08] = 30; | 1103 | cmd.args[8] = 30; |
1087 | cmd.args[0x09] = 30; | 1104 | cmd.args[9] = 30; |
1088 | cmd.args[0x0a] = 30; | 1105 | cmd.args[10] = 30; |
1089 | cmd.len = 0x0b; | 1106 | cmd.len = 11; |
1090 | ret = tda10071_cmd_execute(priv, &cmd); | 1107 | ret = tda10071_cmd_execute(priv, &cmd); |
1091 | if (ret) | 1108 | if (ret) |
1092 | goto error; | 1109 | goto error; |
1093 | 1110 | ||
1094 | cmd.args[0x00] = CMD_BER_CONTROL; | 1111 | cmd.args[0] = CMD_BER_CONTROL; |
1095 | cmd.args[0x01] = 0; | 1112 | cmd.args[1] = 0; |
1096 | cmd.args[0x02] = 14; | 1113 | cmd.args[2] = 14; |
1097 | cmd.args[0x03] = 14; | 1114 | cmd.args[3] = 14; |
1098 | cmd.len = 0x04; | 1115 | cmd.len = 4; |
1099 | ret = tda10071_cmd_execute(priv, &cmd); | 1116 | ret = tda10071_cmd_execute(priv, &cmd); |
1100 | if (ret) | 1117 | if (ret) |
1101 | goto error; | 1118 | goto error; |
@@ -1105,7 +1122,7 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1105 | error_release_firmware: | 1122 | error_release_firmware: |
1106 | release_firmware(fw); | 1123 | release_firmware(fw); |
1107 | error: | 1124 | error: |
1108 | dbg("%s: failed=%d", __func__, ret); | 1125 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
1109 | return ret; | 1126 | return ret; |
1110 | } | 1127 | } |
1111 | 1128 | ||
@@ -1132,10 +1149,10 @@ static int tda10071_sleep(struct dvb_frontend *fe) | |||
1132 | goto error; | 1149 | goto error; |
1133 | } | 1150 | } |
1134 | 1151 | ||
1135 | cmd.args[0x00] = CMD_SET_SLEEP_MODE; | 1152 | cmd.args[0] = CMD_SET_SLEEP_MODE; |
1136 | cmd.args[0x01] = 0; | 1153 | cmd.args[1] = 0; |
1137 | cmd.args[0x02] = 1; | 1154 | cmd.args[2] = 1; |
1138 | cmd.len = 0x03; | 1155 | cmd.len = 3; |
1139 | ret = tda10071_cmd_execute(priv, &cmd); | 1156 | ret = tda10071_cmd_execute(priv, &cmd); |
1140 | if (ret) | 1157 | if (ret) |
1141 | goto error; | 1158 | goto error; |
@@ -1149,7 +1166,7 @@ static int tda10071_sleep(struct dvb_frontend *fe) | |||
1149 | 1166 | ||
1150 | return ret; | 1167 | return ret; |
1151 | error: | 1168 | error: |
1152 | dbg("%s: failed=%d", __func__, ret); | 1169 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
1153 | return ret; | 1170 | return ret; |
1154 | } | 1171 | } |
1155 | 1172 | ||
@@ -1208,7 +1225,7 @@ struct dvb_frontend *tda10071_attach(const struct tda10071_config *config, | |||
1208 | 1225 | ||
1209 | return &priv->fe; | 1226 | return &priv->fe; |
1210 | error: | 1227 | error: |
1211 | dbg("%s: failed=%d", __func__, ret); | 1228 | dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); |
1212 | kfree(priv); | 1229 | kfree(priv); |
1213 | return NULL; | 1230 | return NULL; |
1214 | } | 1231 | } |
diff --git a/drivers/media/dvb/frontends/tda10071_priv.h b/drivers/media/dvb/frontends/tda10071_priv.h index 93c5e6317f07..0fa85cfa70c2 100644 --- a/drivers/media/dvb/frontends/tda10071_priv.h +++ b/drivers/media/dvb/frontends/tda10071_priv.h | |||
@@ -25,19 +25,6 @@ | |||
25 | #include "tda10071.h" | 25 | #include "tda10071.h" |
26 | #include <linux/firmware.h> | 26 | #include <linux/firmware.h> |
27 | 27 | ||
28 | #define LOG_PREFIX "tda10071" | ||
29 | |||
30 | #undef dbg | ||
31 | #define dbg(f, arg...) \ | ||
32 | if (tda10071_debug) \ | ||
33 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
34 | #undef err | ||
35 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) | ||
36 | #undef info | ||
37 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
38 | #undef warn | ||
39 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) | ||
40 | |||
41 | struct tda10071_priv { | 28 | struct tda10071_priv { |
42 | struct i2c_adapter *i2c; | 29 | struct i2c_adapter *i2c; |
43 | struct dvb_frontend fe; | 30 | struct dvb_frontend fe; |
@@ -112,7 +99,7 @@ struct tda10071_reg_val_mask { | |||
112 | #define CMD_BER_UPDATE_COUNTERS 0x3f | 99 | #define CMD_BER_UPDATE_COUNTERS 0x3f |
113 | 100 | ||
114 | /* firmare command struct */ | 101 | /* firmare command struct */ |
115 | #define TDA10071_ARGLEN 0x1e | 102 | #define TDA10071_ARGLEN 30 |
116 | struct tda10071_cmd { | 103 | struct tda10071_cmd { |
117 | u8 args[TDA10071_ARGLEN]; | 104 | u8 args[TDA10071_ARGLEN]; |
118 | u8 len; | 105 | u8 len; |
diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c index 7539a5d71029..72ee8de02260 100644 --- a/drivers/media/dvb/ngene/ngene-cards.c +++ b/drivers/media/dvb/ngene/ngene-cards.c | |||
@@ -217,6 +217,7 @@ static int demod_attach_drxk(struct ngene_channel *chan, | |||
217 | 217 | ||
218 | memset(&config, 0, sizeof(config)); | 218 | memset(&config, 0, sizeof(config)); |
219 | config.microcode_name = "drxk_a3.mc"; | 219 | config.microcode_name = "drxk_a3.mc"; |
220 | config.qam_demod_parameter_count = 4; | ||
220 | config.adr = 0x29 + (chan->number ^ 2); | 221 | config.adr = 0x29 + (chan->number ^ 2); |
221 | 222 | ||
222 | chan->fe = dvb_attach(drxk_attach, &config, i2c); | 223 | chan->fe = dvb_attach(drxk_attach, &config, i2c); |