aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/cx24117.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb-frontends/cx24117.c')
-rw-r--r--drivers/media/dvb-frontends/cx24117.c121
1 files changed, 71 insertions, 50 deletions
diff --git a/drivers/media/dvb-frontends/cx24117.c b/drivers/media/dvb-frontends/cx24117.c
index 476b422ccf19..68f768a5422d 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -135,15 +135,33 @@
135 135
136 136
137enum cmds { 137enum cmds {
138 CMD_SET_VCO = 0x10, 138 CMD_SET_VCOFREQ = 0x10,
139 CMD_TUNEREQUEST = 0x11, 139 CMD_TUNEREQUEST = 0x11,
140 CMD_MPEGCONFIG = 0x13, 140 CMD_GLOBAL_MPEGCFG = 0x13,
141 CMD_TUNERINIT = 0x14, 141 CMD_MPEGCFG = 0x14,
142 CMD_LNBSEND = 0x21, /* Formerly CMD_SEND_DISEQC */ 142 CMD_TUNERINIT = 0x15,
143 CMD_LNBDCLEVEL = 0x22, 143 CMD_GET_SRATE = 0x18,
144 CMD_SET_TONE = 0x23, 144 CMD_SET_GOLDCODE = 0x19,
145 CMD_UPDFWVERS = 0x35, 145 CMD_GET_AGCACC = 0x1a,
146 CMD_TUNERSLEEP = 0x36, 146 CMD_DEMODINIT = 0x1b,
147 CMD_GETCTLACC = 0x1c,
148
149 CMD_LNBCONFIG = 0x20,
150 CMD_LNBSEND = 0x21,
151 CMD_LNBDCLEVEL = 0x22,
152 CMD_LNBPCBCONFIG = 0x23,
153 CMD_LNBSENDTONEBST = 0x24,
154 CMD_LNBUPDREPLY = 0x25,
155
156 CMD_SET_GPIOMODE = 0x30,
157 CMD_SET_GPIOEN = 0x31,
158 CMD_SET_GPIODIR = 0x32,
159 CMD_SET_GPIOOUT = 0x33,
160 CMD_ENABLERSCORR = 0x34,
161 CMD_FWVERSION = 0x35,
162 CMD_SET_SLEEPMODE = 0x36,
163 CMD_BERCTRL = 0x3c,
164 CMD_EVENTCTRL = 0x3d,
147}; 165};
148 166
149static LIST_HEAD(hybrid_tuner_instance_list); 167static LIST_HEAD(hybrid_tuner_instance_list);
@@ -619,8 +637,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
619 cx24117_writereg(state, 0xf7, 0x0c); 637 cx24117_writereg(state, 0xf7, 0x0c);
620 cx24117_writereg(state, 0xe0, 0x00); 638 cx24117_writereg(state, 0xe0, 0x00);
621 639
622 /* CMD 1B */ 640 /* Init demodulator */
623 cmd.args[0] = 0x1b; 641 cmd.args[0] = CMD_DEMODINIT;
624 cmd.args[1] = 0x00; 642 cmd.args[1] = 0x00;
625 cmd.args[2] = 0x01; 643 cmd.args[2] = 0x01;
626 cmd.args[3] = 0x00; 644 cmd.args[3] = 0x00;
@@ -629,8 +647,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
629 if (ret != 0) 647 if (ret != 0)
630 goto error; 648 goto error;
631 649
632 /* CMD 10 */ 650 /* Set VCO frequency */
633 cmd.args[0] = CMD_SET_VCO; 651 cmd.args[0] = CMD_SET_VCOFREQ;
634 cmd.args[1] = 0x06; 652 cmd.args[1] = 0x06;
635 cmd.args[2] = 0x2b; 653 cmd.args[2] = 0x2b;
636 cmd.args[3] = 0xd8; 654 cmd.args[3] = 0xd8;
@@ -648,8 +666,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
648 if (ret != 0) 666 if (ret != 0)
649 goto error; 667 goto error;
650 668
651 /* CMD 15 */ 669 /* Tuner init */
652 cmd.args[0] = 0x15; 670 cmd.args[0] = CMD_TUNERINIT;
653 cmd.args[1] = 0x00; 671 cmd.args[1] = 0x00;
654 cmd.args[2] = 0x01; 672 cmd.args[2] = 0x01;
655 cmd.args[3] = 0x00; 673 cmd.args[3] = 0x00;
@@ -667,8 +685,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
667 if (ret != 0) 685 if (ret != 0)
668 goto error; 686 goto error;
669 687
670 /* CMD 13 */ 688 /* Global MPEG config */
671 cmd.args[0] = CMD_MPEGCONFIG; 689 cmd.args[0] = CMD_GLOBAL_MPEGCFG;
672 cmd.args[1] = 0x00; 690 cmd.args[1] = 0x00;
673 cmd.args[2] = 0x00; 691 cmd.args[2] = 0x00;
674 cmd.args[3] = 0x00; 692 cmd.args[3] = 0x00;
@@ -679,9 +697,9 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
679 if (ret != 0) 697 if (ret != 0)
680 goto error; 698 goto error;
681 699
682 /* CMD 14 */ 700 /* MPEG config for each demod */
683 for (i = 0; i < 2; i++) { 701 for (i = 0; i < 2; i++) {
684 cmd.args[0] = CMD_TUNERINIT; 702 cmd.args[0] = CMD_MPEGCFG;
685 cmd.args[1] = (u8) i; 703 cmd.args[1] = (u8) i;
686 cmd.args[2] = 0x00; 704 cmd.args[2] = 0x00;
687 cmd.args[3] = 0x05; 705 cmd.args[3] = 0x05;
@@ -699,8 +717,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
699 cx24117_writereg(state, 0xcf, 0x00); 717 cx24117_writereg(state, 0xcf, 0x00);
700 cx24117_writereg(state, 0xe5, 0x04); 718 cx24117_writereg(state, 0xe5, 0x04);
701 719
702 /* Firmware CMD 35: Get firmware version */ 720 /* Get firmware version */
703 cmd.args[0] = CMD_UPDFWVERS; 721 cmd.args[0] = CMD_FWVERSION;
704 cmd.len = 2; 722 cmd.len = 2;
705 for (i = 0; i < 4; i++) { 723 for (i = 0; i < 4; i++) {
706 cmd.args[1] = i; 724 cmd.args[1] = i;
@@ -779,8 +797,8 @@ static int cx24117_read_signal_strength(struct dvb_frontend *fe,
779 u8 reg = (state->demod == 0) ? 797 u8 reg = (state->demod == 0) ?
780 CX24117_REG_SSTATUS0 : CX24117_REG_SSTATUS1; 798 CX24117_REG_SSTATUS0 : CX24117_REG_SSTATUS1;
781 799
782 /* Firmware CMD 1A */ 800 /* Read AGC accumulator register */
783 cmd.args[0] = 0x1a; 801 cmd.args[0] = CMD_GET_AGCACC;
784 cmd.args[1] = (u8) state->demod; 802 cmd.args[1] = (u8) state->demod;
785 cmd.len = 2; 803 cmd.len = 2;
786 ret = cx24117_cmd_execute(fe, &cmd); 804 ret = cx24117_cmd_execute(fe, &cmd);
@@ -899,22 +917,15 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
899 voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : 917 voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" :
900 "SEC_VOLTAGE_OFF"); 918 "SEC_VOLTAGE_OFF");
901 919
902 /* CMD 32 */ 920 /* Prepare a set GPIO logic level CMD */
903 cmd.args[0] = 0x32; 921 cmd.args[0] = CMD_SET_GPIOOUT;
904 cmd.args[1] = reg; 922 cmd.args[2] = reg; /* mask */
905 cmd.args[2] = reg;
906 cmd.len = 3; 923 cmd.len = 3;
907 ret = cx24117_cmd_execute(fe, &cmd);
908 if (ret)
909 return ret;
910 924
911 if ((voltage == SEC_VOLTAGE_13) || 925 if ((voltage == SEC_VOLTAGE_13) ||
912 (voltage == SEC_VOLTAGE_18)) { 926 (voltage == SEC_VOLTAGE_18)) {
913 /* CMD 33 */ 927 /* power on LNB */
914 cmd.args[0] = 0x33;
915 cmd.args[1] = reg; 928 cmd.args[1] = reg;
916 cmd.args[2] = reg;
917 cmd.len = 3;
918 ret = cx24117_cmd_execute(fe, &cmd); 929 ret = cx24117_cmd_execute(fe, &cmd);
919 if (ret != 0) 930 if (ret != 0)
920 return ret; 931 return ret;
@@ -926,22 +937,22 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
926 /* Wait for voltage/min repeat delay */ 937 /* Wait for voltage/min repeat delay */
927 msleep(100); 938 msleep(100);
928 939
929 /* CMD 22 - CMD_LNBDCLEVEL */ 940 /* Set 13V/18V select pin */
930 cmd.args[0] = CMD_LNBDCLEVEL; 941 cmd.args[0] = CMD_LNBDCLEVEL;
931 cmd.args[1] = state->demod ? 0 : 1; 942 cmd.args[1] = state->demod ? 0 : 1;
932 cmd.args[2] = (voltage == SEC_VOLTAGE_18 ? 0x01 : 0x00); 943 cmd.args[2] = (voltage == SEC_VOLTAGE_18 ? 0x01 : 0x00);
933 cmd.len = 3; 944 cmd.len = 3;
945 ret = cx24117_cmd_execute(fe, &cmd);
934 946
935 /* Min delay time before DiSEqC send */ 947 /* Min delay time before DiSEqC send */
936 msleep(20); 948 msleep(20);
937 } else { 949 } else {
938 cmd.args[0] = 0x33; 950 /* power off LNB */
939 cmd.args[1] = 0x00; 951 cmd.args[1] = 0x00;
940 cmd.args[2] = reg; 952 ret = cx24117_cmd_execute(fe, &cmd);
941 cmd.len = 3;
942 } 953 }
943 954
944 return cx24117_cmd_execute(fe, &cmd); 955 return ret;
945} 956}
946 957
947static int cx24117_set_tone(struct dvb_frontend *fe, 958static int cx24117_set_tone(struct dvb_frontend *fe,
@@ -968,8 +979,7 @@ static int cx24117_set_tone(struct dvb_frontend *fe,
968 msleep(20); 979 msleep(20);
969 980
970 /* Set the tone */ 981 /* Set the tone */
971 /* CMD 23 - CMD_SET_TONE */ 982 cmd.args[0] = CMD_LNBPCBCONFIG;
972 cmd.args[0] = CMD_SET_TONE;
973 cmd.args[1] = (state->demod ? 0 : 1); 983 cmd.args[1] = (state->demod ? 0 : 1);
974 cmd.args[2] = 0x00; 984 cmd.args[2] = 0x00;
975 cmd.args[3] = 0x00; 985 cmd.args[3] = 0x00;
@@ -1231,8 +1241,8 @@ static int cx24117_initfe(struct dvb_frontend *fe)
1231 1241
1232 mutex_lock(&state->priv->fe_lock); 1242 mutex_lock(&state->priv->fe_lock);
1233 1243
1234 /* Firmware CMD 36: Power config */ 1244 /* Set sleep mode off */
1235 cmd.args[0] = CMD_TUNERSLEEP; 1245 cmd.args[0] = CMD_SET_SLEEPMODE;
1236 cmd.args[1] = (state->demod ? 1 : 0); 1246 cmd.args[1] = (state->demod ? 1 : 0);
1237 cmd.args[2] = 0; 1247 cmd.args[2] = 0;
1238 cmd.len = 3; 1248 cmd.len = 3;
@@ -1244,8 +1254,8 @@ static int cx24117_initfe(struct dvb_frontend *fe)
1244 if (ret != 0) 1254 if (ret != 0)
1245 goto exit; 1255 goto exit;
1246 1256
1247 /* CMD 3C */ 1257 /* Set BER control */
1248 cmd.args[0] = 0x3c; 1258 cmd.args[0] = CMD_BERCTRL;
1249 cmd.args[1] = (state->demod ? 1 : 0); 1259 cmd.args[1] = (state->demod ? 1 : 0);
1250 cmd.args[2] = 0x10; 1260 cmd.args[2] = 0x10;
1251 cmd.args[3] = 0x10; 1261 cmd.args[3] = 0x10;
@@ -1254,12 +1264,22 @@ static int cx24117_initfe(struct dvb_frontend *fe)
1254 if (ret != 0) 1264 if (ret != 0)
1255 goto exit; 1265 goto exit;
1256 1266
1257 /* CMD 34 */ 1267 /* Set RS correction (enable/disable) */
1258 cmd.args[0] = 0x34; 1268 cmd.args[0] = CMD_ENABLERSCORR;
1259 cmd.args[1] = (state->demod ? 1 : 0); 1269 cmd.args[1] = (state->demod ? 1 : 0);
1260 cmd.args[2] = CX24117_OCC; 1270 cmd.args[2] = CX24117_OCC;
1261 cmd.len = 3; 1271 cmd.len = 3;
1262 ret = cx24117_cmd_execute_nolock(fe, &cmd); 1272 ret = cx24117_cmd_execute_nolock(fe, &cmd);
1273 if (ret != 0)
1274 goto exit;
1275
1276 /* Set GPIO direction */
1277 /* Set as output - controls LNB power on/off */
1278 cmd.args[0] = CMD_SET_GPIODIR;
1279 cmd.args[1] = 0x30;
1280 cmd.args[2] = 0x30;
1281 cmd.len = 3;
1282 ret = cx24117_cmd_execute_nolock(fe, &cmd);
1263 1283
1264exit: 1284exit:
1265 mutex_unlock(&state->priv->fe_lock); 1285 mutex_unlock(&state->priv->fe_lock);
@@ -1278,8 +1298,8 @@ static int cx24117_sleep(struct dvb_frontend *fe)
1278 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n", 1298 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n",
1279 __func__, state->demod); 1299 __func__, state->demod);
1280 1300
1281 /* Firmware CMD 36: Power config */ 1301 /* Set sleep mode on */
1282 cmd.args[0] = CMD_TUNERSLEEP; 1302 cmd.args[0] = CMD_SET_SLEEPMODE;
1283 cmd.args[1] = (state->demod ? 1 : 0); 1303 cmd.args[1] = (state->demod ? 1 : 0);
1284 cmd.args[2] = 1; 1304 cmd.args[2] = 1;
1285 cmd.len = 3; 1305 cmd.len = 3;
@@ -1558,7 +1578,8 @@ static int cx24117_get_frontend(struct dvb_frontend *fe)
1558 1578
1559 u8 buf[0x1f-4]; 1579 u8 buf[0x1f-4];
1560 1580
1561 cmd.args[0] = 0x1c; 1581 /* Read current tune parameters */
1582 cmd.args[0] = CMD_GETCTLACC;
1562 cmd.args[1] = (u8) state->demod; 1583 cmd.args[1] = (u8) state->demod;
1563 cmd.len = 2; 1584 cmd.len = 2;
1564 ret = cx24117_cmd_execute(fe, &cmd); 1585 ret = cx24117_cmd_execute(fe, &cmd);