aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/lmedm04.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb/lmedm04.c')
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.c235
1 files changed, 173 insertions, 62 deletions
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c
index 9eea4188303b..cd26e7c1536a 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -2,7 +2,9 @@
2 * 2 *
3 * DM04/QQBOX DVB-S USB BOX LME2510C + SHARP:BS2F7HZ7395 3 * DM04/QQBOX DVB-S USB BOX LME2510C + SHARP:BS2F7HZ7395
4 * LME2510C + LG TDQY-P001F 4 * LME2510C + LG TDQY-P001F
5 * LME2510C + BS2F7HZ0194
5 * LME2510 + LG TDQY-P001F 6 * LME2510 + LG TDQY-P001F
7 * LME2510 + BS2F7HZ0194
6 * 8 *
7 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395) 9 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
8 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V) 10 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
@@ -12,20 +14,22 @@
12 * 14 *
13 * MVB0001F (LME2510C+LGTDQT-P001F) 15 * MVB0001F (LME2510C+LGTDQT-P001F)
14 * 16 *
17 * MV0194 (LME2510+SHARP:BS2F7HZ0194)
18 * SHARP:BS2F7HZ0194 = (STV0299+IX2410)
19 *
20 * MVB0194 (LME2510C+SHARP0194)
21 *
15 * For firmware see Documentation/dvb/lmedm04.txt 22 * For firmware see Documentation/dvb/lmedm04.txt
16 * 23 *
17 * I2C addresses: 24 * I2C addresses:
18 * 0xd0 - STV0288 - Demodulator 25 * 0xd0 - STV0288 - Demodulator
19 * 0xc0 - Sharp IX2505V - Tuner 26 * 0xc0 - Sharp IX2505V - Tuner
20 * --or-- 27 * --
21 * 0x1c - TDA10086 - Demodulator 28 * 0x1c - TDA10086 - Demodulator
22 * 0xc0 - TDA8263 - Tuner 29 * 0xc0 - TDA8263 - Tuner
23 * 30 * --
24 * ***Please Note*** 31 * 0xd0 - STV0299 - Demodulator
25 * There are other variants of the DM04 32 * 0xc0 - IX2410 - Tuner
26 * ***NOT SUPPORTED***
27 * MV0194 (LME2510+SHARP0194)
28 * MVB0194 (LME2510C+SHARP0194)
29 * 33 *
30 * 34 *
31 * VID = 3344 PID LME2510=1122 LME2510C=1120 35 * VID = 3344 PID LME2510=1122 LME2510C=1120
@@ -55,6 +59,9 @@
55 * 59 *
56 * QQbox suffers from noise on LNB voltage. 60 * QQbox suffers from noise on LNB voltage.
57 * 61 *
62 * LME2510: SHARP:BS2F7HZ0194(MV0194) cannot cold reset and share system
63 * with other tuners. After a cold reset streaming will not start.
64 *
58 * PID functions have been removed from this driver version due to 65 * PID functions have been removed from this driver version due to
59 * problems with different firmware and application versions. 66 * problems with different firmware and application versions.
60 */ 67 */
@@ -69,6 +76,9 @@
69#include "tda10086.h" 76#include "tda10086.h"
70#include "stv0288.h" 77#include "stv0288.h"
71#include "ix2505v.h" 78#include "ix2505v.h"
79#include "stv0299.h"
80#include "dvb-pll.h"
81#include "z0194a.h"
72 82
73 83
74 84
@@ -96,8 +106,11 @@ MODULE_PARM_DESC(firmware, "set default firmware 0=Sharp7395 1=LG");
96 106
97 107
98DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 108DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
109
110#define TUNER_DEFAULT 0x0
99#define TUNER_LG 0x1 111#define TUNER_LG 0x1
100#define TUNER_S7395 0x2 112#define TUNER_S7395 0x2
113#define TUNER_S0194 0x3
101 114
102struct lme2510_state { 115struct lme2510_state {
103 u8 id; 116 u8 id;
@@ -191,7 +204,7 @@ static int lme2510_stream_restart(struct dvb_usb_device *d)
191 rbuff, sizeof(rbuff)); 204 rbuff, sizeof(rbuff));
192 return ret; 205 return ret;
193} 206}
194static int lme2510_remote_keypress(struct dvb_usb_adapter *adap, u16 keypress) 207static int lme2510_remote_keypress(struct dvb_usb_adapter *adap, u32 keypress)
195{ 208{
196 struct dvb_usb_device *d = adap->dev; 209 struct dvb_usb_device *d = adap->dev;
197 210
@@ -237,7 +250,8 @@ static void lme2510_int_response(struct urb *lme_urb)
237 case 0xaa: 250 case 0xaa:
238 debug_data_snipet(1, "INT Remote data snipet in", ibuf); 251 debug_data_snipet(1, "INT Remote data snipet in", ibuf);
239 lme2510_remote_keypress(adap, 252 lme2510_remote_keypress(adap,
240 (u16)(ibuf[4]<<8)+ibuf[5]); 253 (u32)(ibuf[2] << 24) + (ibuf[3] << 16) +
254 (ibuf[4] << 8) + ibuf[5]);
241 break; 255 break;
242 case 0xbb: 256 case 0xbb:
243 switch (st->tuner_config) { 257 switch (st->tuner_config) {
@@ -249,6 +263,7 @@ static void lme2510_int_response(struct urb *lme_urb)
249 st->time_key = ibuf[7]; 263 st->time_key = ibuf[7];
250 break; 264 break;
251 case TUNER_S7395: 265 case TUNER_S7395:
266 case TUNER_S0194:
252 /* Tweak for earlier firmware*/ 267 /* Tweak for earlier firmware*/
253 if (ibuf[1] == 0x03) { 268 if (ibuf[1] == 0x03) {
254 if (ibuf[2] > 1) 269 if (ibuf[2] > 1)
@@ -364,6 +379,18 @@ static int lme2510_msg(struct dvb_usb_device *d,
364 msleep(5); 379 msleep(5);
365 } 380 }
366 break; 381 break;
382 case TUNER_S0194:
383 if (wbuf[2] == 0xd0) {
384 if (wbuf[3] == 0x1b) {
385 st->signal_lock = rbuf[1];
386 if ((st->stream_on & 1) &&
387 (st->signal_lock & 0x8)) {
388 lme2510_stream_restart(d);
389 st->i2c_talk_onoff = 0;
390 }
391 }
392 }
393 break;
367 default: 394 default:
368 break; 395 break;
369 } 396 }
@@ -423,6 +450,34 @@ static int lme2510_msg(struct dvb_usb_device *d,
423 break; 450 break;
424 } 451 }
425 break; 452 break;
453 case TUNER_S0194:
454 switch (wbuf[3]) {
455 case 0x18:
456 rbuf[0] = 0x55;
457 rbuf[1] = (st->signal_level & 0x80)
458 ? 0 : (st->signal_level * 2);
459 break;
460 case 0x24:
461 rbuf[0] = 0x55;
462 rbuf[1] = st->signal_sn;
463 break;
464 case 0x1b:
465 rbuf[0] = 0x55;
466 rbuf[1] = st->signal_lock;
467 break;
468 case 0x19:
469 case 0x25:
470 case 0x1e:
471 case 0x1d:
472 rbuf[0] = 0x55;
473 rbuf[1] = 0x00;
474 break;
475 default:
476 lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
477 st->i2c_talk_onoff = 1;
478 break;
479 }
480 break;
426 default: 481 default:
427 break; 482 break;
428 } 483 }
@@ -517,17 +572,14 @@ static int lme2510_identify_state(struct usb_device *udev,
517 struct dvb_usb_device_description **desc, 572 struct dvb_usb_device_description **desc,
518 int *cold) 573 int *cold)
519{ 574{
520 if (lme2510_return_status(udev) == 0x44) 575 *cold = 0;
521 *cold = 1;
522 else
523 *cold = 0;
524 return 0; 576 return 0;
525} 577}
526 578
527static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 579static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
528{ 580{
529 struct lme2510_state *st = adap->dev->priv; 581 struct lme2510_state *st = adap->dev->priv;
530 static u8 clear_reg_3[] = LME_CLEAR_PID; 582 static u8 clear_reg_3[] = LME_CLEAR_PID;
531 static u8 rbuf[1]; 583 static u8 rbuf[1];
532 int ret = 0, rlen = sizeof(rbuf); 584 int ret = 0, rlen = sizeof(rbuf);
533 585
@@ -658,9 +710,6 @@ static int lme2510_download_firmware(struct usb_device *dev,
658 return (ret < 0) ? -ENODEV : 0; 710 return (ret < 0) ? -ENODEV : 0;
659} 711}
660 712
661/* Default firmware for LME2510C */
662const char lme_firmware[50] = "dvb-usb-lme2510c-s7395.fw";
663
664static void lme_coldreset(struct usb_device *dev) 713static void lme_coldreset(struct usb_device *dev)
665{ 714{
666 int ret = 0, len_in; 715 int ret = 0, len_in;
@@ -678,49 +727,83 @@ static void lme_coldreset(struct usb_device *dev)
678static int lme_firmware_switch(struct usb_device *udev, int cold) 727static int lme_firmware_switch(struct usb_device *udev, int cold)
679{ 728{
680 const struct firmware *fw = NULL; 729 const struct firmware *fw = NULL;
681 char lme2510c_s7395[] = "dvb-usb-lme2510c-s7395.fw"; 730 const char fw_c_s7395[] = "dvb-usb-lme2510c-s7395.fw";
682 char lme2510c_lg[] = "dvb-usb-lme2510c-lg.fw"; 731 const char fw_c_lg[] = "dvb-usb-lme2510c-lg.fw";
683 char *firm_msg[] = {"Loading", "Switching to"}; 732 const char fw_c_s0194[] = "dvb-usb-lme2510c-s0194.fw";
684 int ret; 733 const char fw_lg[] = "dvb-usb-lme2510-lg.fw";
734 const char fw_s0194[] = "dvb-usb-lme2510-s0194.fw";
735 const char *fw_lme;
736 int ret, cold_fw;
685 737
686 cold = (cold > 0) ? (cold & 1) : 0; 738 cold = (cold > 0) ? (cold & 1) : 0;
687 739
688 if (udev->descriptor.idProduct == 0x1122) 740 cold_fw = !cold;
689 return 0;
690 741
691 switch (dvb_usb_lme2510_firmware) { 742 if (udev->descriptor.idProduct == 0x1122) {
692 case 0: 743 switch (dvb_usb_lme2510_firmware) {
693 default: 744 default:
694 memcpy(&lme_firmware, lme2510c_s7395, sizeof(lme2510c_s7395)); 745 dvb_usb_lme2510_firmware = TUNER_S0194;
695 ret = request_firmware(&fw, lme_firmware, &udev->dev); 746 case TUNER_S0194:
696 if (ret == 0) { 747 fw_lme = fw_s0194;
697 info("FRM %s S7395 Firmware", firm_msg[cold]); 748 ret = request_firmware(&fw, fw_lme, &udev->dev);
749 if (ret == 0) {
750 cold = 0;/*lme2510-s0194 cannot cold reset*/
751 break;
752 }
753 dvb_usb_lme2510_firmware = TUNER_LG;
754 case TUNER_LG:
755 fw_lme = fw_lg;
756 ret = request_firmware(&fw, fw_lme, &udev->dev);
757 if (ret == 0)
758 break;
759 info("FRM No Firmware Found - please install");
760 dvb_usb_lme2510_firmware = TUNER_DEFAULT;
761 cold = 0;
762 cold_fw = 0;
698 break; 763 break;
699 } 764 }
700 if (cold == 0) 765 } else {
701 dvb_usb_lme2510_firmware = 1; 766 switch (dvb_usb_lme2510_firmware) {
702 else 767 default:
768 dvb_usb_lme2510_firmware = TUNER_S7395;
769 case TUNER_S7395:
770 fw_lme = fw_c_s7395;
771 ret = request_firmware(&fw, fw_lme, &udev->dev);
772 if (ret == 0)
773 break;
774 dvb_usb_lme2510_firmware = TUNER_LG;
775 case TUNER_LG:
776 fw_lme = fw_c_lg;
777 ret = request_firmware(&fw, fw_lme, &udev->dev);
778 if (ret == 0)
779 break;
780 dvb_usb_lme2510_firmware = TUNER_S0194;
781 case TUNER_S0194:
782 fw_lme = fw_c_s0194;
783 ret = request_firmware(&fw, fw_lme, &udev->dev);
784 if (ret == 0)
785 break;
786 info("FRM No Firmware Found - please install");
787 dvb_usb_lme2510_firmware = TUNER_DEFAULT;
703 cold = 0; 788 cold = 0;
704 case 1: 789 cold_fw = 0;
705 memcpy(&lme_firmware, lme2510c_lg, sizeof(lme2510c_lg));
706 ret = request_firmware(&fw, lme_firmware, &udev->dev);
707 if (ret == 0) {
708 info("FRM %s LG Firmware", firm_msg[cold]);
709 break; 790 break;
710 } 791 }
711 info("FRM No Firmware Found - please install");
712 dvb_usb_lme2510_firmware = 0;
713 cold = 0;
714 break;
715 } 792 }
716 793
717 release_firmware(fw); 794 if (cold_fw) {
795 info("FRM Loading %s file", fw_lme);
796 ret = lme2510_download_firmware(udev, fw);
797 }
718 798
719 if (cold) { 799 if (cold) {
800 info("FRM Changing to %s firmware", fw_lme);
720 lme_coldreset(udev); 801 lme_coldreset(udev);
721 return -ENODEV; 802 return -ENODEV;
722 } 803 }
723 804
805 release_firmware(fw);
806
724 return ret; 807 return ret;
725} 808}
726 809
@@ -758,6 +841,18 @@ static struct ix2505v_config lme_tuner = {
758 .tuner_chargepump = 0x3, 841 .tuner_chargepump = 0x3,
759}; 842};
760 843
844static struct stv0299_config sharp_z0194_config = {
845 .demod_address = 0xd0,
846 .inittab = sharp_z0194a_inittab,
847 .mclk = 88000000UL,
848 .invert = 0,
849 .skip_reinit = 0,
850 .lock_output = STV0299_LOCKOUTPUT_1,
851 .volt13_op0_op1 = STV0299_VOLT13_OP1,
852 .min_delay_ms = 100,
853 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
854};
855
761static int dm04_lme2510_set_voltage(struct dvb_frontend *fe, 856static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
762 fe_sec_voltage_t voltage) 857 fe_sec_voltage_t voltage)
763{ 858{
@@ -793,7 +888,8 @@ static int lme_name(struct dvb_usb_adapter *adap)
793{ 888{
794 struct lme2510_state *st = adap->dev->priv; 889 struct lme2510_state *st = adap->dev->priv;
795 const char *desc = adap->dev->desc->name; 890 const char *desc = adap->dev->desc->name;
796 char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395"}; 891 char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
892 " SHARP:BS2F7HZ0194"};
797 char *name = adap->fe->ops.info.name; 893 char *name = adap->fe->ops.info.name;
798 894
799 strlcpy(name, desc, 128); 895 strlcpy(name, desc, 128);
@@ -820,26 +916,40 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
820 st->i2c_tuner_gate_r = 4; 916 st->i2c_tuner_gate_r = 4;
821 st->i2c_tuner_addr = 0xc0; 917 st->i2c_tuner_addr = 0xc0;
822 st->tuner_config = TUNER_LG; 918 st->tuner_config = TUNER_LG;
823 if (dvb_usb_lme2510_firmware != 1) { 919 if (dvb_usb_lme2510_firmware != TUNER_LG) {
824 dvb_usb_lme2510_firmware = 1; 920 dvb_usb_lme2510_firmware = TUNER_LG;
825 ret = lme_firmware_switch(adap->dev->udev, 1); 921 ret = lme_firmware_switch(adap->dev->udev, 1);
826 } else /*stops LG/Sharp multi tuner problems*/ 922 }
827 dvb_usb_lme2510_firmware = 0; 923 goto end;
924 }
925
926 st->i2c_gate = 4;
927 adap->fe = dvb_attach(stv0299_attach, &sharp_z0194_config,
928 &adap->dev->i2c_adap);
929 if (adap->fe) {
930 info("FE Found Stv0299");
931 st->i2c_tuner_gate_w = 4;
932 st->i2c_tuner_gate_r = 5;
933 st->i2c_tuner_addr = 0xc0;
934 st->tuner_config = TUNER_S0194;
935 if (dvb_usb_lme2510_firmware != TUNER_S0194) {
936 dvb_usb_lme2510_firmware = TUNER_S0194;
937 ret = lme_firmware_switch(adap->dev->udev, 1);
938 }
828 goto end; 939 goto end;
829 } 940 }
830 941
831 st->i2c_gate = 5; 942 st->i2c_gate = 5;
832 adap->fe = dvb_attach(stv0288_attach, &lme_config, 943 adap->fe = dvb_attach(stv0288_attach, &lme_config,
833 &adap->dev->i2c_adap); 944 &adap->dev->i2c_adap);
834
835 if (adap->fe) { 945 if (adap->fe) {
836 info("FE Found Stv0288"); 946 info("FE Found Stv0288");
837 st->i2c_tuner_gate_w = 4; 947 st->i2c_tuner_gate_w = 4;
838 st->i2c_tuner_gate_r = 5; 948 st->i2c_tuner_gate_r = 5;
839 st->i2c_tuner_addr = 0xc0; 949 st->i2c_tuner_addr = 0xc0;
840 st->tuner_config = TUNER_S7395; 950 st->tuner_config = TUNER_S7395;
841 if (dvb_usb_lme2510_firmware != 0) { 951 if (dvb_usb_lme2510_firmware != TUNER_S7395) {
842 dvb_usb_lme2510_firmware = 0; 952 dvb_usb_lme2510_firmware = TUNER_S7395;
843 ret = lme_firmware_switch(adap->dev->udev, 1); 953 ret = lme_firmware_switch(adap->dev->udev, 1);
844 } 954 }
845 } else { 955 } else {
@@ -847,6 +957,7 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
847 return -ENODEV; 957 return -ENODEV;
848 } 958 }
849 959
960
850end: if (ret) { 961end: if (ret) {
851 kfree(adap->fe); 962 kfree(adap->fe);
852 adap->fe = NULL; 963 adap->fe = NULL;
@@ -855,14 +966,13 @@ end: if (ret) {
855 966
856 adap->fe->ops.set_voltage = dm04_lme2510_set_voltage; 967 adap->fe->ops.set_voltage = dm04_lme2510_set_voltage;
857 ret = lme_name(adap); 968 ret = lme_name(adap);
858
859 return ret; 969 return ret;
860} 970}
861 971
862static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap) 972static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
863{ 973{
864 struct lme2510_state *st = adap->dev->priv; 974 struct lme2510_state *st = adap->dev->priv;
865 char *tun_msg[] = {"", "TDA8263", "IX2505V"}; 975 char *tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA"};
866 int ret = 0; 976 int ret = 0;
867 977
868 switch (st->tuner_config) { 978 switch (st->tuner_config) {
@@ -876,6 +986,11 @@ static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
876 &adap->dev->i2c_adap)) 986 &adap->dev->i2c_adap))
877 ret = st->tuner_config; 987 ret = st->tuner_config;
878 break; 988 break;
989 case TUNER_S0194:
990 if (dvb_attach(dvb_pll_attach , adap->fe, 0xc0,
991 &adap->dev->i2c_adap, DVB_PLL_OPERA1))
992 ret = st->tuner_config;
993 break;
879 default: 994 default:
880 break; 995 break;
881 } 996 }
@@ -936,7 +1051,10 @@ static int lme2510_probe(struct usb_interface *intf,
936 return -ENODEV; 1051 return -ENODEV;
937 } 1052 }
938 1053
939 lme_firmware_switch(udev, 0); 1054 if (lme2510_return_status(udev) == 0x44) {
1055 lme_firmware_switch(udev, 0);
1056 return -ENODEV;
1057 }
940 1058
941 if (0 == dvb_usb_device_init(intf, &lme2510_properties, 1059 if (0 == dvb_usb_device_init(intf, &lme2510_properties,
942 THIS_MODULE, NULL, adapter_nr)) { 1060 THIS_MODULE, NULL, adapter_nr)) {
@@ -964,10 +1082,6 @@ MODULE_DEVICE_TABLE(usb, lme2510_table);
964 1082
965static struct dvb_usb_device_properties lme2510_properties = { 1083static struct dvb_usb_device_properties lme2510_properties = {
966 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1084 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
967 .usb_ctrl = DEVICE_SPECIFIC,
968 .download_firmware = lme2510_download_firmware,
969 .firmware = "dvb-usb-lme2510-lg.fw",
970
971 .size_of_priv = sizeof(struct lme2510_state), 1085 .size_of_priv = sizeof(struct lme2510_state),
972 .num_adapters = 1, 1086 .num_adapters = 1,
973 .adapter = { 1087 .adapter = {
@@ -1004,9 +1118,6 @@ static struct dvb_usb_device_properties lme2510_properties = {
1004 1118
1005static struct dvb_usb_device_properties lme2510c_properties = { 1119static struct dvb_usb_device_properties lme2510c_properties = {
1006 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1120 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1007 .usb_ctrl = DEVICE_SPECIFIC,
1008 .download_firmware = lme2510_download_firmware,
1009 .firmware = lme_firmware,
1010 .size_of_priv = sizeof(struct lme2510_state), 1121 .size_of_priv = sizeof(struct lme2510_state),
1011 .num_adapters = 1, 1122 .num_adapters = 1,
1012 .adapter = { 1123 .adapter = {
@@ -1109,5 +1220,5 @@ module_exit(lme2510_module_exit);
1109 1220
1110MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); 1221MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1111MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0"); 1222MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1112MODULE_VERSION("1.74"); 1223MODULE_VERSION("1.80");
1113MODULE_LICENSE("GPL"); 1224MODULE_LICENSE("GPL");