aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorIgor M. Liplianin <liplianin@me.by>2011-02-25 16:41:24 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:32:27 -0400
commitcb8f74da107cf593eb50ac4968faaa5f49fbad4a (patch)
tree77789631eb3c80e4cca0983e5a7abc22e7a8878c /drivers/media/dvb
parent18a73f36a2109563beee00f8be3f19f6c1fe2ff6 (diff)
[media] ds3000: remove unnecessary dnxt, dcur structures
All necessary parameters already stored in frontend cache. Signed-off-by: Igor M. Liplianin <liplianin@me.by> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/ds3000.c108
1 files changed, 13 insertions, 95 deletions
diff --git a/drivers/media/dvb/frontends/ds3000.c b/drivers/media/dvb/frontends/ds3000.c
index 882be672f5d2..13f9193d4f4a 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -229,31 +229,11 @@ static u8 ds3000_dvbs2_init_tab[] = {
229 0xb8, 0x00, 229 0xb8, 0x00,
230}; 230};
231 231
232/* DS3000 doesn't need some parameters as input and auto-detects them */
233/* save input from the application of those parameters */
234struct ds3000_tuning {
235 u32 frequency;
236 u32 symbol_rate;
237 fe_spectral_inversion_t inversion;
238 enum fe_code_rate fec;
239
240 /* input values */
241 u8 inversion_val;
242 fe_modulation_t delivery;
243 u8 rolloff;
244};
245
246struct ds3000_state { 232struct ds3000_state {
247 struct i2c_adapter *i2c; 233 struct i2c_adapter *i2c;
248 const struct ds3000_config *config; 234 const struct ds3000_config *config;
249
250 struct dvb_frontend frontend; 235 struct dvb_frontend frontend;
251
252 struct ds3000_tuning dcur;
253 struct ds3000_tuning dnxt;
254
255 u8 skip_fw_load; 236 u8 skip_fw_load;
256
257 /* previous uncorrected block counter for DVB-S2 */ 237 /* previous uncorrected block counter for DVB-S2 */
258 u16 prevUCBS2; 238 u16 prevUCBS2;
259}; 239};
@@ -401,45 +381,6 @@ static int ds3000_tuner_readreg(struct ds3000_state *state, u8 reg)
401 return b1[0]; 381 return b1[0];
402} 382}
403 383
404static int ds3000_set_inversion(struct ds3000_state *state,
405 fe_spectral_inversion_t inversion)
406{
407 dprintk("%s(%d)\n", __func__, inversion);
408
409 switch (inversion) {
410 case INVERSION_OFF:
411 case INVERSION_ON:
412 case INVERSION_AUTO:
413 break;
414 default:
415 return -EINVAL;
416 }
417
418 state->dnxt.inversion = inversion;
419
420 return 0;
421}
422
423static int ds3000_set_symbolrate(struct ds3000_state *state, u32 rate)
424{
425 int ret = 0;
426
427 dprintk("%s()\n", __func__);
428
429 dprintk("%s() symbol_rate = %d\n", __func__, state->dnxt.symbol_rate);
430
431 /* check if symbol rate is within limits */
432 if ((state->dnxt.symbol_rate >
433 state->frontend.ops.info.symbol_rate_max) ||
434 (state->dnxt.symbol_rate <
435 state->frontend.ops.info.symbol_rate_min))
436 ret = -EOPNOTSUPP;
437
438 state->dnxt.symbol_rate = rate;
439
440 return ret;
441}
442
443static int ds3000_load_firmware(struct dvb_frontend *fe, 384static int ds3000_load_firmware(struct dvb_frontend *fe,
444 const struct firmware *fw); 385 const struct firmware *fw);
445 386
@@ -790,13 +731,6 @@ static int ds3000_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
790 return 0; 731 return 0;
791} 732}
792 733
793/* Overwrite the current tuning params, we are about to tune */
794static void ds3000_clone_params(struct dvb_frontend *fe)
795{
796 struct ds3000_state *state = fe->demodulator_priv;
797 memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur));
798}
799
800static int ds3000_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) 734static int ds3000_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
801{ 735{
802 struct ds3000_state *state = fe->demodulator_priv; 736 struct ds3000_state *state = fe->demodulator_priv;
@@ -1027,22 +961,6 @@ static int ds3000_tune(struct dvb_frontend *fe,
1027 961
1028 dprintk("%s() ", __func__); 962 dprintk("%s() ", __func__);
1029 963
1030 state->dnxt.delivery = c->modulation;
1031 state->dnxt.frequency = c->frequency;
1032 state->dnxt.rolloff = 2; /* fixme */
1033 state->dnxt.fec = c->fec_inner;
1034
1035 ret = ds3000_set_inversion(state, p->inversion);
1036 if (ret != 0)
1037 return ret;
1038
1039 ret = ds3000_set_symbolrate(state, c->symbol_rate);
1040 if (ret != 0)
1041 return ret;
1042
1043 /* discard the 'current' tuning parameters and prepare to tune */
1044 ds3000_clone_params(fe);
1045
1046 /* Reset status register */ 964 /* Reset status register */
1047 status = 0; 965 status = 0;
1048 /* Tune */ 966 /* Tune */
@@ -1053,14 +971,14 @@ static int ds3000_tune(struct dvb_frontend *fe,
1053 ds3000_tuner_writereg(state, 0x08, 0x01); 971 ds3000_tuner_writereg(state, 0x08, 0x01);
1054 ds3000_tuner_writereg(state, 0x00, 0x01); 972 ds3000_tuner_writereg(state, 0x00, 0x01);
1055 /* calculate and set freq divider */ 973 /* calculate and set freq divider */
1056 if (state->dcur.frequency < 1146000) { 974 if (p->frequency < 1146000) {
1057 ds3000_tuner_writereg(state, 0x10, 0x11); 975 ds3000_tuner_writereg(state, 0x10, 0x11);
1058 ndiv = ((state->dcur.frequency * (6 + 8) * 4) + 976 ndiv = ((p->frequency * (6 + 8) * 4) +
1059 (DS3000_XTAL_FREQ / 2)) / 977 (DS3000_XTAL_FREQ / 2)) /
1060 DS3000_XTAL_FREQ - 1024; 978 DS3000_XTAL_FREQ - 1024;
1061 } else { 979 } else {
1062 ds3000_tuner_writereg(state, 0x10, 0x01); 980 ds3000_tuner_writereg(state, 0x10, 0x01);
1063 ndiv = ((state->dcur.frequency * (6 + 8) * 2) + 981 ndiv = ((p->frequency * (6 + 8) * 2) +
1064 (DS3000_XTAL_FREQ / 2)) / 982 (DS3000_XTAL_FREQ / 2)) /
1065 DS3000_XTAL_FREQ - 1024; 983 DS3000_XTAL_FREQ - 1024;
1066 } 984 }
@@ -1106,8 +1024,8 @@ static int ds3000_tune(struct dvb_frontend *fe,
1106 ds3000_tuner_writereg(state, 0x50, 0x00); 1024 ds3000_tuner_writereg(state, 0x50, 0x00);
1107 msleep(5); 1025 msleep(5);
1108 1026
1109 f3db = ((state->dcur.symbol_rate / 1000) << 2) / 5 + 2000; 1027 f3db = ((c->symbol_rate / 1000) << 2) / 5 + 2000;
1110 if ((state->dcur.symbol_rate / 1000) < 5000) 1028 if ((c->symbol_rate / 1000) < 5000)
1111 f3db += 3000; 1029 f3db += 3000;
1112 if (f3db < 7000) 1030 if (f3db < 7000)
1113 f3db = 7000; 1031 f3db = 7000;
@@ -1196,30 +1114,30 @@ static int ds3000_tune(struct dvb_frontend *fe,
1196 ds3000_writereg(state, 0x25, 0x8a); 1114 ds3000_writereg(state, 0x25, 0x8a);
1197 1115
1198 /* enhance symbol rate performance */ 1116 /* enhance symbol rate performance */
1199 if ((state->dcur.symbol_rate / 1000) <= 5000) { 1117 if ((c->symbol_rate / 1000) <= 5000) {
1200 value = 29777 / (state->dcur.symbol_rate / 1000) + 1; 1118 value = 29777 / (c->symbol_rate / 1000) + 1;
1201 if (value % 2 != 0) 1119 if (value % 2 != 0)
1202 value++; 1120 value++;
1203 ds3000_writereg(state, 0xc3, 0x0d); 1121 ds3000_writereg(state, 0xc3, 0x0d);
1204 ds3000_writereg(state, 0xc8, value); 1122 ds3000_writereg(state, 0xc8, value);
1205 ds3000_writereg(state, 0xc4, 0x10); 1123 ds3000_writereg(state, 0xc4, 0x10);
1206 ds3000_writereg(state, 0xc7, 0x0e); 1124 ds3000_writereg(state, 0xc7, 0x0e);
1207 } else if ((state->dcur.symbol_rate / 1000) <= 10000) { 1125 } else if ((c->symbol_rate / 1000) <= 10000) {
1208 value = 92166 / (state->dcur.symbol_rate / 1000) + 1; 1126 value = 92166 / (c->symbol_rate / 1000) + 1;
1209 if (value % 2 != 0) 1127 if (value % 2 != 0)
1210 value++; 1128 value++;
1211 ds3000_writereg(state, 0xc3, 0x07); 1129 ds3000_writereg(state, 0xc3, 0x07);
1212 ds3000_writereg(state, 0xc8, value); 1130 ds3000_writereg(state, 0xc8, value);
1213 ds3000_writereg(state, 0xc4, 0x09); 1131 ds3000_writereg(state, 0xc4, 0x09);
1214 ds3000_writereg(state, 0xc7, 0x12); 1132 ds3000_writereg(state, 0xc7, 0x12);
1215 } else if ((state->dcur.symbol_rate / 1000) <= 20000) { 1133 } else if ((c->symbol_rate / 1000) <= 20000) {
1216 value = 64516 / (state->dcur.symbol_rate / 1000) + 1; 1134 value = 64516 / (c->symbol_rate / 1000) + 1;
1217 ds3000_writereg(state, 0xc3, value); 1135 ds3000_writereg(state, 0xc3, value);
1218 ds3000_writereg(state, 0xc8, 0x0e); 1136 ds3000_writereg(state, 0xc8, 0x0e);
1219 ds3000_writereg(state, 0xc4, 0x07); 1137 ds3000_writereg(state, 0xc4, 0x07);
1220 ds3000_writereg(state, 0xc7, 0x18); 1138 ds3000_writereg(state, 0xc7, 0x18);
1221 } else { 1139 } else {
1222 value = 129032 / (state->dcur.symbol_rate / 1000) + 1; 1140 value = 129032 / (c->symbol_rate / 1000) + 1;
1223 ds3000_writereg(state, 0xc3, value); 1141 ds3000_writereg(state, 0xc3, value);
1224 ds3000_writereg(state, 0xc8, 0x0a); 1142 ds3000_writereg(state, 0xc8, 0x0a);
1225 ds3000_writereg(state, 0xc4, 0x05); 1143 ds3000_writereg(state, 0xc4, 0x05);
@@ -1227,7 +1145,7 @@ static int ds3000_tune(struct dvb_frontend *fe,
1227 } 1145 }
1228 1146
1229 /* normalized symbol rate rounded to the closest integer */ 1147 /* normalized symbol rate rounded to the closest integer */
1230 value = (((state->dcur.symbol_rate / 1000) << 16) + 1148 value = (((c->symbol_rate / 1000) << 16) +
1231 (DS3000_SAMPLE_RATE / 2)) / DS3000_SAMPLE_RATE; 1149 (DS3000_SAMPLE_RATE / 2)) / DS3000_SAMPLE_RATE;
1232 ds3000_writereg(state, 0x61, value & 0x00ff); 1150 ds3000_writereg(state, 0x61, value & 0x00ff);
1233 ds3000_writereg(state, 0x62, (value & 0xff00) >> 8); 1151 ds3000_writereg(state, 0x62, (value & 0xff00) >> 8);