aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2011-12-23 05:15:40 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-12-31 05:38:22 -0500
commit57605c9680bf2c57cb2ff3ad737fefd9c82bc012 (patch)
treec1dd028a6ada97f64c4d4341b6f6d06bc1def1be
parent2f786bbefc2f1cab6e9560476ea69003d19ee5cb (diff)
[media] dvb-ttusb-budget: use DVBv5 parameters on set_params()
Instead of using DVBv3 parameters, rely on DVBv5 parameters to set the tuner Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 420bb42d5233..2379f387c50c 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1019,17 +1019,18 @@ static u32 functionality(struct i2c_adapter *adapter)
1019 1019
1020static int alps_tdmb7_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1020static int alps_tdmb7_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1021{ 1021{
1022 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1022 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; 1023 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1023 u8 data[4]; 1024 u8 data[4];
1024 struct i2c_msg msg = {.addr=0x61, .flags=0, .buf=data, .len=sizeof(data) }; 1025 struct i2c_msg msg = {.addr=0x61, .flags=0, .buf=data, .len=sizeof(data) };
1025 u32 div; 1026 u32 div;
1026 1027
1027 div = (params->frequency + 36166667) / 166667; 1028 div = (p->frequency + 36166667) / 166667;
1028 1029
1029 data[0] = (div >> 8) & 0x7f; 1030 data[0] = (div >> 8) & 0x7f;
1030 data[1] = div & 0xff; 1031 data[1] = div & 0xff;
1031 data[2] = ((div >> 10) & 0x60) | 0x85; 1032 data[2] = ((div >> 10) & 0x60) | 0x85;
1032 data[3] = params->frequency < 592000000 ? 0x40 : 0x80; 1033 data[3] = p->frequency < 592000000 ? 0x40 : 0x80;
1033 1034
1034 if (fe->ops.i2c_gate_ctrl) 1035 if (fe->ops.i2c_gate_ctrl)
1035 fe->ops.i2c_gate_ctrl(fe, 1); 1036 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -1073,6 +1074,7 @@ static int philips_tdm1316l_tuner_init(struct dvb_frontend* fe)
1073 1074
1074static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1075static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1075{ 1076{
1077 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1076 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; 1078 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1077 u8 tuner_buf[4]; 1079 u8 tuner_buf[4];
1078 struct i2c_msg tuner_msg = {.addr=0x60, .flags=0, .buf=tuner_buf, .len=sizeof(tuner_buf) }; 1080 struct i2c_msg tuner_msg = {.addr=0x60, .flags=0, .buf=tuner_buf, .len=sizeof(tuner_buf) };
@@ -1080,7 +1082,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb
1080 u8 band, cp, filter; 1082 u8 band, cp, filter;
1081 1083
1082 // determine charge pump 1084 // determine charge pump
1083 tuner_frequency = params->frequency + 36130000; 1085 tuner_frequency = p->frequency + 36130000;
1084 if (tuner_frequency < 87000000) return -EINVAL; 1086 if (tuner_frequency < 87000000) return -EINVAL;
1085 else if (tuner_frequency < 130000000) cp = 3; 1087 else if (tuner_frequency < 130000000) cp = 3;
1086 else if (tuner_frequency < 160000000) cp = 5; 1088 else if (tuner_frequency < 160000000) cp = 5;
@@ -1094,25 +1096,29 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb
1094 else return -EINVAL; 1096 else return -EINVAL;
1095 1097
1096 // determine band 1098 // determine band
1097 if (params->frequency < 49000000) return -EINVAL; 1099 if (p->frequency < 49000000)
1098 else if (params->frequency < 159000000) band = 1; 1100 return -EINVAL;
1099 else if (params->frequency < 444000000) band = 2; 1101 else if (p->frequency < 159000000)
1100 else if (params->frequency < 861000000) band = 4; 1102 band = 1;
1103 else if (p->frequency < 444000000)
1104 band = 2;
1105 else if (p->frequency < 861000000)
1106 band = 4;
1101 else return -EINVAL; 1107 else return -EINVAL;
1102 1108
1103 // setup PLL filter 1109 // setup PLL filter
1104 switch (params->u.ofdm.bandwidth) { 1110 switch (p->bandwidth_hz) {
1105 case BANDWIDTH_6_MHZ: 1111 case 6000000:
1106 tda1004x_writereg(fe, 0x0C, 0); 1112 tda1004x_writereg(fe, 0x0C, 0);
1107 filter = 0; 1113 filter = 0;
1108 break; 1114 break;
1109 1115
1110 case BANDWIDTH_7_MHZ: 1116 case 7000000:
1111 tda1004x_writereg(fe, 0x0C, 0); 1117 tda1004x_writereg(fe, 0x0C, 0);
1112 filter = 0; 1118 filter = 0;
1113 break; 1119 break;
1114 1120
1115 case BANDWIDTH_8_MHZ: 1121 case 8000000:
1116 tda1004x_writereg(fe, 0x0C, 0xFF); 1122 tda1004x_writereg(fe, 0x0C, 0xFF);
1117 filter = 1; 1123 filter = 1;
1118 break; 1124 break;
@@ -1123,7 +1129,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb
1123 1129
1124 // calculate divisor 1130 // calculate divisor
1125 // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6) 1131 // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
1126 tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000; 1132 tuner_frequency = (((p->frequency / 1000) * 6) + 217280) / 1000;
1127 1133
1128 // setup tuner buffer 1134 // setup tuner buffer
1129 tuner_buf[0] = tuner_frequency >> 8; 1135 tuner_buf[0] = tuner_frequency >> 8;
@@ -1275,21 +1281,22 @@ static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32
1275 1281
1276static int philips_tsa5059_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 1282static int philips_tsa5059_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1277{ 1283{
1284 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1278 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; 1285 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1279 u8 buf[4]; 1286 u8 buf[4];
1280 u32 div; 1287 u32 div;
1281 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; 1288 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
1282 1289
1283 if ((params->frequency < 950000) || (params->frequency > 2150000)) 1290 if ((p->frequency < 950000) || (p->frequency > 2150000))
1284 return -EINVAL; 1291 return -EINVAL;
1285 1292
1286 div = (params->frequency + (125 - 1)) / 125; // round correctly 1293 div = (p->frequency + (125 - 1)) / 125; /* round correctly */
1287 buf[0] = (div >> 8) & 0x7f; 1294 buf[0] = (div >> 8) & 0x7f;
1288 buf[1] = div & 0xff; 1295 buf[1] = div & 0xff;
1289 buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4; 1296 buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1290 buf[3] = 0xC4; 1297 buf[3] = 0xC4;
1291 1298
1292 if (params->frequency > 1530000) 1299 if (p->frequency > 1530000)
1293 buf[3] = 0xC0; 1300 buf[3] = 0xC0;
1294 1301
1295 /* BSBE1 wants XCE bit set */ 1302 /* BSBE1 wants XCE bit set */
@@ -1318,12 +1325,13 @@ static struct stv0299_config alps_stv0299_config = {
1318 1325
1319static int ttusb_novas_grundig_29504_491_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 1326static int ttusb_novas_grundig_29504_491_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1320{ 1327{
1328 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1321 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; 1329 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
1322 u8 buf[4]; 1330 u8 buf[4];
1323 u32 div; 1331 u32 div;
1324 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; 1332 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
1325 1333
1326 div = params->frequency / 125; 1334 div = p->frequency / 125;
1327 1335
1328 buf[0] = (div >> 8) & 0x7f; 1336 buf[0] = (div >> 8) & 0x7f;
1329 buf[1] = div & 0xff; 1337 buf[1] = div & 0xff;
@@ -1345,17 +1353,18 @@ static struct tda8083_config ttusb_novas_grundig_29504_491_config = {
1345 1353
1346static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1354static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1347{ 1355{
1356 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1348 struct ttusb* ttusb = fe->dvb->priv; 1357 struct ttusb* ttusb = fe->dvb->priv;
1349 u32 div; 1358 u32 div;
1350 u8 data[4]; 1359 u8 data[4];
1351 struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; 1360 struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
1352 1361
1353 div = (params->frequency + 35937500 + 31250) / 62500; 1362 div = (p->frequency + 35937500 + 31250) / 62500;
1354 1363
1355 data[0] = (div >> 8) & 0x7f; 1364 data[0] = (div >> 8) & 0x7f;
1356 data[1] = div & 0xff; 1365 data[1] = div & 0xff;
1357 data[2] = 0x85 | ((div >> 10) & 0x60); 1366 data[2] = 0x85 | ((div >> 10) & 0x60);
1358 data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); 1367 data[3] = (p->frequency < 174000000 ? 0x88 : p->frequency < 470000000 ? 0x84 : 0x81);
1359 1368
1360 if (fe->ops.i2c_gate_ctrl) 1369 if (fe->ops.i2c_gate_ctrl)
1361 fe->ops.i2c_gate_ctrl(fe, 1); 1370 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -1389,6 +1398,7 @@ static u8 read_pwm(struct ttusb* ttusb)
1389 1398
1390static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 1399static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1391{ 1400{
1401 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1392 struct ttusb *ttusb = (struct ttusb *) fe->dvb->priv; 1402 struct ttusb *ttusb = (struct ttusb *) fe->dvb->priv;
1393 u8 tuner_buf[5]; 1403 u8 tuner_buf[5];
1394 struct i2c_msg tuner_msg = {.addr = 0x60, 1404 struct i2c_msg tuner_msg = {.addr = 0x60,
@@ -1399,7 +1409,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc
1399 u8 band, cp, filter; 1409 u8 band, cp, filter;
1400 1410
1401 // determine charge pump 1411 // determine charge pump
1402 tuner_frequency = params->frequency; 1412 tuner_frequency = p->frequency;
1403 if (tuner_frequency < 87000000) {return -EINVAL;} 1413 if (tuner_frequency < 87000000) {return -EINVAL;}
1404 else if (tuner_frequency < 130000000) {cp = 3; band = 1;} 1414 else if (tuner_frequency < 130000000) {cp = 3; band = 1;}
1405 else if (tuner_frequency < 160000000) {cp = 5; band = 1;} 1415 else if (tuner_frequency < 160000000) {cp = 5; band = 1;}
@@ -1417,7 +1427,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc
1417 1427
1418 // calculate divisor 1428 // calculate divisor
1419 // (Finput + Fif)/Fref; Fif = 36125000 Hz, Fref = 62500 Hz 1429 // (Finput + Fif)/Fref; Fif = 36125000 Hz, Fref = 62500 Hz
1420 tuner_frequency = ((params->frequency + 36125000) / 62500); 1430 tuner_frequency = ((p->frequency + 36125000) / 62500);
1421 1431
1422 // setup tuner buffer 1432 // setup tuner buffer
1423 tuner_buf[0] = tuner_frequency >> 8; 1433 tuner_buf[0] = tuner_frequency >> 8;