aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/dvb-pll.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2011-12-21 09:16:39 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-12-31 05:42:33 -0500
commit80d8d4985f280dca3c395286d13b49f910a029e7 (patch)
tree35acc46be8a9baea881caf3cde385db05789cbe8 /drivers/media/dvb/frontends/dvb-pll.c
parentcba3f88a6f61fdb03183e98920457e770a9bf887 (diff)
[media] dvb-pll: 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>
Diffstat (limited to 'drivers/media/dvb/frontends/dvb-pll.c')
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 62a65efdf8d6..c19d6bbc68ce 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -61,8 +61,7 @@ struct dvb_pll_desc {
61 u32 min; 61 u32 min;
62 u32 max; 62 u32 max;
63 u32 iffreq; 63 u32 iffreq;
64 void (*set)(struct dvb_frontend *fe, u8 *buf, 64 void (*set)(struct dvb_frontend *fe, u8 *buf);
65 const struct dvb_frontend_parameters *params);
66 u8 *initdata; 65 u8 *initdata;
67 u8 *initdata2; 66 u8 *initdata2;
68 u8 *sleepdata; 67 u8 *sleepdata;
@@ -93,10 +92,10 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
93 }, 92 },
94}; 93};
95 94
96static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf, 95static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf)
97 const struct dvb_frontend_parameters *params)
98{ 96{
99 if (BANDWIDTH_7_MHZ == params->u.ofdm.bandwidth) 97 u32 bw = fe->dtv_property_cache.bandwidth_hz;
98 if (bw == 7000000)
100 buf[3] |= 0x10; 99 buf[3] |= 0x10;
101} 100}
102 101
@@ -186,10 +185,10 @@ static struct dvb_pll_desc dvb_pll_env57h1xd5 = {
186/* Philips TDA6650/TDA6651 185/* Philips TDA6650/TDA6651
187 * used in Panasonic ENV77H11D5 186 * used in Panasonic ENV77H11D5
188 */ 187 */
189static void tda665x_bw(struct dvb_frontend *fe, u8 *buf, 188static void tda665x_bw(struct dvb_frontend *fe, u8 *buf)
190 const struct dvb_frontend_parameters *params)
191{ 189{
192 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) 190 u32 bw = fe->dtv_property_cache.bandwidth_hz;
191 if (bw == 8000000)
193 buf[3] |= 0x08; 192 buf[3] |= 0x08;
194} 193}
195 194
@@ -220,10 +219,10 @@ static struct dvb_pll_desc dvb_pll_tda665x = {
220/* Infineon TUA6034 219/* Infineon TUA6034
221 * used in LG TDTP E102P 220 * used in LG TDTP E102P
222 */ 221 */
223static void tua6034_bw(struct dvb_frontend *fe, u8 *buf, 222static void tua6034_bw(struct dvb_frontend *fe, u8 *buf)
224 const struct dvb_frontend_parameters *params)
225{ 223{
226 if (BANDWIDTH_7_MHZ != params->u.ofdm.bandwidth) 224 u32 bw = fe->dtv_property_cache.bandwidth_hz;
225 if (bw == 7000000)
227 buf[3] |= 0x08; 226 buf[3] |= 0x08;
228} 227}
229 228
@@ -244,10 +243,10 @@ static struct dvb_pll_desc dvb_pll_tua6034 = {
244/* ALPS TDED4 243/* ALPS TDED4
245 * used in Nebula-Cards and USB boxes 244 * used in Nebula-Cards and USB boxes
246 */ 245 */
247static void tded4_bw(struct dvb_frontend *fe, u8 *buf, 246static void tded4_bw(struct dvb_frontend *fe, u8 *buf)
248 const struct dvb_frontend_parameters *params)
249{ 247{
250 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) 248 u32 bw = fe->dtv_property_cache.bandwidth_hz;
249 if (bw == 8000000)
251 buf[3] |= 0x04; 250 buf[3] |= 0x04;
252} 251}
253 252
@@ -319,11 +318,11 @@ static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
319 }, 318 },
320}; 319};
321 320
322static void opera1_bw(struct dvb_frontend *fe, u8 *buf, 321static void opera1_bw(struct dvb_frontend *fe, u8 *buf)
323 const struct dvb_frontend_parameters *params)
324{ 322{
323 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
325 struct dvb_pll_priv *priv = fe->tuner_priv; 324 struct dvb_pll_priv *priv = fe->tuner_priv;
326 u32 b_w = (params->u.qpsk.symbol_rate * 27) / 32000; 325 u32 b_w = (c->symbol_rate * 27) / 32000;
327 struct i2c_msg msg = { 326 struct i2c_msg msg = {
328 .addr = priv->pll_i2c_address, 327 .addr = priv->pll_i2c_address,
329 .flags = 0, 328 .flags = 0,
@@ -392,8 +391,7 @@ static struct dvb_pll_desc dvb_pll_opera1 = {
392 } 391 }
393}; 392};
394 393
395static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf, 394static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf)
396 const struct dvb_frontend_parameters *params)
397{ 395{
398 struct dvb_pll_priv *priv = fe->tuner_priv; 396 struct dvb_pll_priv *priv = fe->tuner_priv;
399 struct i2c_msg msg = { 397 struct i2c_msg msg = {
@@ -537,30 +535,29 @@ static struct dvb_pll_desc *pll_list[] = {
537/* code */ 535/* code */
538 536
539static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, 537static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
540 const struct dvb_frontend_parameters *params) 538 const u32 frequency)
541{ 539{
542 struct dvb_pll_priv *priv = fe->tuner_priv; 540 struct dvb_pll_priv *priv = fe->tuner_priv;
543 struct dvb_pll_desc *desc = priv->pll_desc; 541 struct dvb_pll_desc *desc = priv->pll_desc;
544 u32 div; 542 u32 div;
545 int i; 543 int i;
546 544
547 if (params->frequency != 0 && (params->frequency < desc->min || 545 if (frequency && (frequency < desc->min || frequency > desc->max))
548 params->frequency > desc->max))
549 return -EINVAL; 546 return -EINVAL;
550 547
551 for (i = 0; i < desc->count; i++) { 548 for (i = 0; i < desc->count; i++) {
552 if (params->frequency > desc->entries[i].limit) 549 if (frequency > desc->entries[i].limit)
553 continue; 550 continue;
554 break; 551 break;
555 } 552 }
556 553
557 if (debug) 554 if (debug)
558 printk("pll: %s: freq=%d | i=%d/%d\n", desc->name, 555 printk("pll: %s: freq=%d | i=%d/%d\n", desc->name,
559 params->frequency, i, desc->count); 556 frequency, i, desc->count);
560 if (i == desc->count) 557 if (i == desc->count)
561 return -EINVAL; 558 return -EINVAL;
562 559
563 div = (params->frequency + desc->iffreq + 560 div = (frequency + desc->iffreq +
564 desc->entries[i].stepsize/2) / desc->entries[i].stepsize; 561 desc->entries[i].stepsize/2) / desc->entries[i].stepsize;
565 buf[0] = div >> 8; 562 buf[0] = div >> 8;
566 buf[1] = div & 0xff; 563 buf[1] = div & 0xff;
@@ -568,7 +565,7 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
568 buf[3] = desc->entries[i].cb; 565 buf[3] = desc->entries[i].cb;
569 566
570 if (desc->set) 567 if (desc->set)
571 desc->set(fe, buf, params); 568 desc->set(fe, buf);
572 569
573 if (debug) 570 if (debug)
574 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", 571 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
@@ -614,6 +611,7 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
614static int dvb_pll_set_params(struct dvb_frontend *fe, 611static int dvb_pll_set_params(struct dvb_frontend *fe,
615 struct dvb_frontend_parameters *params) 612 struct dvb_frontend_parameters *params)
616{ 613{
614 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
617 struct dvb_pll_priv *priv = fe->tuner_priv; 615 struct dvb_pll_priv *priv = fe->tuner_priv;
618 u8 buf[4]; 616 u8 buf[4];
619 struct i2c_msg msg = 617 struct i2c_msg msg =
@@ -625,7 +623,8 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
625 if (priv->i2c == NULL) 623 if (priv->i2c == NULL)
626 return -EINVAL; 624 return -EINVAL;
627 625
628 if ((result = dvb_pll_configure(fe, buf, params)) < 0) 626 result = dvb_pll_configure(fe, buf, c->frequency);
627 if (result < 0)
629 return result; 628 return result;
630 else 629 else
631 frequency = result; 630 frequency = result;
@@ -637,7 +636,12 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
637 } 636 }
638 637
639 priv->frequency = frequency; 638 priv->frequency = frequency;
640 priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; 639 if (c->bandwidth_hz <= 6000000)
640 priv->bandwidth = BANDWIDTH_6_MHZ;
641 else if (c->bandwidth_hz <= 7000000)
642 priv->bandwidth = BANDWIDTH_7_MHZ;
643 if (c->bandwidth_hz <= 8000000)
644 priv->bandwidth = BANDWIDTH_8_MHZ;
641 645
642 return 0; 646 return 0;
643} 647}
@@ -653,7 +657,8 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
653 if (buf_len < 5) 657 if (buf_len < 5)
654 return -EINVAL; 658 return -EINVAL;
655 659
656 if ((result = dvb_pll_configure(fe, buf+1, params)) < 0) 660 result = dvb_pll_configure(fe, buf + 1, params->frequency);
661 if (result < 0)
657 return result; 662 return result;
658 else 663 else
659 frequency = result; 664 frequency = result;