diff options
Diffstat (limited to 'drivers/media/dvb/frontends/dvb-pll.c')
-rw-r--r-- | drivers/media/dvb/frontends/dvb-pll.c | 94 |
1 files changed, 43 insertions, 51 deletions
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 5f96ffda91ad..0e3195f95756 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c | |||
@@ -68,9 +68,10 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7610 = { | |||
68 | }; | 68 | }; |
69 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); | 69 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); |
70 | 70 | ||
71 | static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth) | 71 | static void thomson_dtt759x_bw(u8 *buf, |
72 | const struct dvb_frontend_parameters *params) | ||
72 | { | 73 | { |
73 | if (BANDWIDTH_7_MHZ == bandwidth) | 74 | if (BANDWIDTH_7_MHZ == params->u.ofdm.bandwidth) |
74 | buf[3] |= 0x10; | 75 | buf[3] |= 0x10; |
75 | } | 76 | } |
76 | 77 | ||
@@ -78,7 +79,7 @@ struct dvb_pll_desc dvb_pll_thomson_dtt759x = { | |||
78 | .name = "Thomson dtt759x", | 79 | .name = "Thomson dtt759x", |
79 | .min = 177000000, | 80 | .min = 177000000, |
80 | .max = 896000000, | 81 | .max = 896000000, |
81 | .setbw = thomson_dtt759x_bw, | 82 | .set = thomson_dtt759x_bw, |
82 | .iffreq= 36166667, | 83 | .iffreq= 36166667, |
83 | .sleepdata = (u8[]){ 2, 0x84, 0x03 }, | 84 | .sleepdata = (u8[]){ 2, 0x84, 0x03 }, |
84 | .count = 5, | 85 | .count = 5, |
@@ -195,9 +196,9 @@ EXPORT_SYMBOL(dvb_pll_env57h1xd5); | |||
195 | /* Philips TDA6650/TDA6651 | 196 | /* Philips TDA6650/TDA6651 |
196 | * used in Panasonic ENV77H11D5 | 197 | * used in Panasonic ENV77H11D5 |
197 | */ | 198 | */ |
198 | static void tda665x_bw(u8 *buf, u32 freq, int bandwidth) | 199 | static void tda665x_bw(u8 *buf, const struct dvb_frontend_parameters *params) |
199 | { | 200 | { |
200 | if (bandwidth == BANDWIDTH_8_MHZ) | 201 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) |
201 | buf[3] |= 0x08; | 202 | buf[3] |= 0x08; |
202 | } | 203 | } |
203 | 204 | ||
@@ -205,7 +206,7 @@ struct dvb_pll_desc dvb_pll_tda665x = { | |||
205 | .name = "Philips TDA6650/TDA6651", | 206 | .name = "Philips TDA6650/TDA6651", |
206 | .min = 44250000, | 207 | .min = 44250000, |
207 | .max = 858000000, | 208 | .max = 858000000, |
208 | .setbw = tda665x_bw, | 209 | .set = tda665x_bw, |
209 | .iffreq= 36166667, | 210 | .iffreq= 36166667, |
210 | .count = 12, | 211 | .count = 12, |
211 | .entries = { | 212 | .entries = { |
@@ -228,9 +229,9 @@ EXPORT_SYMBOL(dvb_pll_tda665x); | |||
228 | /* Infineon TUA6034 | 229 | /* Infineon TUA6034 |
229 | * used in LG TDTP E102P | 230 | * used in LG TDTP E102P |
230 | */ | 231 | */ |
231 | static void tua6034_bw(u8 *buf, u32 freq, int bandwidth) | 232 | static void tua6034_bw(u8 *buf, const struct dvb_frontend_parameters *params) |
232 | { | 233 | { |
233 | if (BANDWIDTH_7_MHZ != bandwidth) | 234 | if (BANDWIDTH_7_MHZ != params->u.ofdm.bandwidth) |
234 | buf[3] |= 0x08; | 235 | buf[3] |= 0x08; |
235 | } | 236 | } |
236 | 237 | ||
@@ -240,7 +241,7 @@ struct dvb_pll_desc dvb_pll_tua6034 = { | |||
240 | .max = 858000000, | 241 | .max = 858000000, |
241 | .iffreq= 36166667, | 242 | .iffreq= 36166667, |
242 | .count = 3, | 243 | .count = 3, |
243 | .setbw = tua6034_bw, | 244 | .set = tua6034_bw, |
244 | .entries = { | 245 | .entries = { |
245 | { 174500000, 62500, 0xce, 0x01 }, | 246 | { 174500000, 62500, 0xce, 0x01 }, |
246 | { 230000000, 62500, 0xce, 0x02 }, | 247 | { 230000000, 62500, 0xce, 0x02 }, |
@@ -270,9 +271,10 @@ EXPORT_SYMBOL(dvb_pll_lg_tdvs_h06xf); | |||
270 | /* Philips FMD1216ME | 271 | /* Philips FMD1216ME |
271 | * used in Medion Hybrid PCMCIA card and USB Box | 272 | * used in Medion Hybrid PCMCIA card and USB Box |
272 | */ | 273 | */ |
273 | static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth) | 274 | static void fmd1216me_bw(u8 *buf, const struct dvb_frontend_parameters *params) |
274 | { | 275 | { |
275 | if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000) | 276 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && |
277 | params->frequency >= 158870000) | ||
276 | buf[3] |= 0x08; | 278 | buf[3] |= 0x08; |
277 | } | 279 | } |
278 | 280 | ||
@@ -281,7 +283,7 @@ struct dvb_pll_desc dvb_pll_fmd1216me = { | |||
281 | .min = 50870000, | 283 | .min = 50870000, |
282 | .max = 858000000, | 284 | .max = 858000000, |
283 | .iffreq= 36125000, | 285 | .iffreq= 36125000, |
284 | .setbw = fmd1216me_bw, | 286 | .set = fmd1216me_bw, |
285 | .count = 7, | 287 | .count = 7, |
286 | .entries = { | 288 | .entries = { |
287 | { 143870000, 166667, 0xbc, 0x41 }, | 289 | { 143870000, 166667, 0xbc, 0x41 }, |
@@ -298,9 +300,9 @@ EXPORT_SYMBOL(dvb_pll_fmd1216me); | |||
298 | /* ALPS TDED4 | 300 | /* ALPS TDED4 |
299 | * used in Nebula-Cards and USB boxes | 301 | * used in Nebula-Cards and USB boxes |
300 | */ | 302 | */ |
301 | static void tded4_bw(u8 *buf, u32 freq, int bandwidth) | 303 | static void tded4_bw(u8 *buf, const struct dvb_frontend_parameters *params) |
302 | { | 304 | { |
303 | if (bandwidth == BANDWIDTH_8_MHZ) | 305 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) |
304 | buf[3] |= 0x04; | 306 | buf[3] |= 0x04; |
305 | } | 307 | } |
306 | 308 | ||
@@ -309,7 +311,7 @@ struct dvb_pll_desc dvb_pll_tded4 = { | |||
309 | .min = 47000000, | 311 | .min = 47000000, |
310 | .max = 863000000, | 312 | .max = 863000000, |
311 | .iffreq= 36166667, | 313 | .iffreq= 36166667, |
312 | .setbw = tded4_bw, | 314 | .set = tded4_bw, |
313 | .count = 4, | 315 | .count = 4, |
314 | .entries = { | 316 | .entries = { |
315 | { 153000000, 166667, 0x85, 0x01 }, | 317 | { 153000000, 166667, 0x85, 0x01 }, |
@@ -396,14 +398,14 @@ EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261); | |||
396 | /* | 398 | /* |
397 | * Philips TD1316 Tuner. | 399 | * Philips TD1316 Tuner. |
398 | */ | 400 | */ |
399 | static void td1316_bw(u8 *buf, u32 freq, int bandwidth) | 401 | static void td1316_bw(u8 *buf, const struct dvb_frontend_parameters *params) |
400 | { | 402 | { |
401 | u8 band; | 403 | u8 band; |
402 | 404 | ||
403 | /* determine band */ | 405 | /* determine band */ |
404 | if (freq < 161000000) | 406 | if (params->frequency < 161000000) |
405 | band = 1; | 407 | band = 1; |
406 | else if (freq < 444000000) | 408 | else if (params->frequency < 444000000) |
407 | band = 2; | 409 | band = 2; |
408 | else | 410 | else |
409 | band = 4; | 411 | band = 4; |
@@ -411,7 +413,7 @@ static void td1316_bw(u8 *buf, u32 freq, int bandwidth) | |||
411 | buf[3] |= band; | 413 | buf[3] |= band; |
412 | 414 | ||
413 | /* setup PLL filter */ | 415 | /* setup PLL filter */ |
414 | if (bandwidth == BANDWIDTH_8_MHZ) | 416 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) |
415 | buf[3] |= 1 << 3; | 417 | buf[3] |= 1 << 3; |
416 | } | 418 | } |
417 | 419 | ||
@@ -420,7 +422,7 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = { | |||
420 | .min = 87000000, | 422 | .min = 87000000, |
421 | .max = 895000000, | 423 | .max = 895000000, |
422 | .iffreq= 36166667, | 424 | .iffreq= 36166667, |
423 | .setbw = td1316_bw, | 425 | .set = td1316_bw, |
424 | .count = 9, | 426 | .count = 9, |
425 | .entries = { | 427 | .entries = { |
426 | { 93834000, 166667, 0xca, 0x60}, | 428 | { 93834000, 166667, 0xca, 0x60}, |
@@ -451,9 +453,9 @@ struct dvb_pll_desc dvb_pll_thomson_fe6600 = { | |||
451 | } | 453 | } |
452 | }; | 454 | }; |
453 | EXPORT_SYMBOL(dvb_pll_thomson_fe6600); | 455 | EXPORT_SYMBOL(dvb_pll_thomson_fe6600); |
454 | static void opera1_bw(u8 *buf, u32 freq, int bandwidth) | 456 | static void opera1_bw(u8 *buf, const struct dvb_frontend_parameters *params) |
455 | { | 457 | { |
456 | if (bandwidth == BANDWIDTH_8_MHZ) | 458 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) |
457 | buf[2] |= 0x08; | 459 | buf[2] |= 0x08; |
458 | } | 460 | } |
459 | 461 | ||
@@ -462,7 +464,7 @@ struct dvb_pll_desc dvb_pll_opera1 = { | |||
462 | .min = 900000, | 464 | .min = 900000, |
463 | .max = 2250000, | 465 | .max = 2250000, |
464 | .iffreq= 0, | 466 | .iffreq= 0, |
465 | .setbw = opera1_bw, | 467 | .set = opera1_bw, |
466 | .count = 8, | 468 | .count = 8, |
467 | .entries = { | 469 | .entries = { |
468 | { 1064000, 500, 0xe5, 0xc6 }, | 470 | { 1064000, 500, 0xe5, 0xc6 }, |
@@ -498,34 +500,36 @@ module_param(debug, int, 0644); | |||
498 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 500 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
499 | 501 | ||
500 | int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, | 502 | int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, |
501 | u32 freq, int bandwidth) | 503 | const struct dvb_frontend_parameters *params) |
502 | { | 504 | { |
503 | u32 div; | 505 | u32 div; |
504 | int i; | 506 | int i; |
505 | 507 | ||
506 | if (freq != 0 && (freq < desc->min || freq > desc->max)) | 508 | if (params->frequency != 0 && (params->frequency < desc->min || |
507 | return -EINVAL; | 509 | params->frequency > desc->max)) |
510 | return -EINVAL; | ||
508 | 511 | ||
509 | for (i = 0; i < desc->count; i++) { | 512 | for (i = 0; i < desc->count; i++) { |
510 | if (freq > desc->entries[i].limit) | 513 | if (params->frequency > desc->entries[i].limit) |
511 | continue; | 514 | continue; |
512 | break; | 515 | break; |
513 | } | 516 | } |
517 | |||
514 | if (debug) | 518 | if (debug) |
515 | printk("pll: %s: freq=%d bw=%d | i=%d/%d\n", | 519 | printk("pll: %s: freq=%d | i=%d/%d\n", desc->name, |
516 | desc->name, freq, bandwidth, i, desc->count); | 520 | params->frequency, i, desc->count); |
517 | if (i == desc->count) | 521 | if (i == desc->count) |
518 | return -EINVAL; | 522 | return -EINVAL; |
519 | 523 | ||
520 | div = (freq + desc->iffreq + desc->entries[i].stepsize/2) / | 524 | div = (params->frequency + desc->iffreq + |
521 | desc->entries[i].stepsize; | 525 | desc->entries[i].stepsize/2) / desc->entries[i].stepsize; |
522 | buf[0] = div >> 8; | 526 | buf[0] = div >> 8; |
523 | buf[1] = div & 0xff; | 527 | buf[1] = div & 0xff; |
524 | buf[2] = desc->entries[i].config; | 528 | buf[2] = desc->entries[i].config; |
525 | buf[3] = desc->entries[i].cb; | 529 | buf[3] = desc->entries[i].cb; |
526 | 530 | ||
527 | if (desc->setbw) | 531 | if (desc->set) |
528 | desc->setbw(buf, freq, bandwidth); | 532 | desc->set(buf, params); |
529 | 533 | ||
530 | if (debug) | 534 | if (debug) |
531 | printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", | 535 | printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", |
@@ -578,18 +582,12 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, | |||
578 | { .addr = priv->pll_i2c_address, .flags = 0, | 582 | { .addr = priv->pll_i2c_address, .flags = 0, |
579 | .buf = buf, .len = sizeof(buf) }; | 583 | .buf = buf, .len = sizeof(buf) }; |
580 | int result; | 584 | int result; |
581 | u32 bandwidth = 0, frequency = 0; | 585 | u32 frequency = 0; |
582 | 586 | ||
583 | if (priv->i2c == NULL) | 587 | if (priv->i2c == NULL) |
584 | return -EINVAL; | 588 | return -EINVAL; |
585 | 589 | ||
586 | // DVBT bandwidth only just now | 590 | if ((result = dvb_pll_configure(priv->pll_desc, buf, params)) < 0) |
587 | if (fe->ops.info.type == FE_OFDM) { | ||
588 | bandwidth = params->u.ofdm.bandwidth; | ||
589 | } | ||
590 | |||
591 | if ((result = dvb_pll_configure(priv->pll_desc, buf, | ||
592 | params->frequency, bandwidth)) < 0) | ||
593 | return result; | 591 | return result; |
594 | else | 592 | else |
595 | frequency = result; | 593 | frequency = result; |
@@ -601,7 +599,7 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, | |||
601 | } | 599 | } |
602 | 600 | ||
603 | priv->frequency = frequency; | 601 | priv->frequency = frequency; |
604 | priv->bandwidth = bandwidth; | 602 | priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; |
605 | 603 | ||
606 | return 0; | 604 | return 0; |
607 | } | 605 | } |
@@ -612,18 +610,12 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, | |||
612 | { | 610 | { |
613 | struct dvb_pll_priv *priv = fe->tuner_priv; | 611 | struct dvb_pll_priv *priv = fe->tuner_priv; |
614 | int result; | 612 | int result; |
615 | u32 bandwidth = 0, frequency = 0; | 613 | u32 frequency = 0; |
616 | 614 | ||
617 | if (buf_len < 5) | 615 | if (buf_len < 5) |
618 | return -EINVAL; | 616 | return -EINVAL; |
619 | 617 | ||
620 | // DVBT bandwidth only just now | 618 | if ((result = dvb_pll_configure(priv->pll_desc, buf+1, params)) < 0) |
621 | if (fe->ops.info.type == FE_OFDM) { | ||
622 | bandwidth = params->u.ofdm.bandwidth; | ||
623 | } | ||
624 | |||
625 | if ((result = dvb_pll_configure(priv->pll_desc, buf+1, | ||
626 | params->frequency, bandwidth)) < 0) | ||
627 | return result; | 619 | return result; |
628 | else | 620 | else |
629 | frequency = result; | 621 | frequency = result; |
@@ -631,7 +623,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, | |||
631 | buf[0] = priv->pll_i2c_address; | 623 | buf[0] = priv->pll_i2c_address; |
632 | 624 | ||
633 | priv->frequency = frequency; | 625 | priv->frequency = frequency; |
634 | priv->bandwidth = bandwidth; | 626 | priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; |
635 | 627 | ||
636 | return 5; | 628 | return 5; |
637 | } | 629 | } |