aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-05-05 11:05:39 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-07-18 13:23:12 -0400
commit77d675047062d514acdc1bbe9f84658b39f99abe (patch)
tree5b1026b1be33ef349152eedb091693900cf41b8e
parent900858ecb30c27ac94369052be650e25c0fd7d2a (diff)
V4L/DVB (5632): Dvb-pll: pass dvb_frontend_parameters to generic set() function
Rename dvb_pll_desc.setbw() to set(), and accept struct dvb_frontend_parameters instead of passing both freq and bandwidth, so that this may be used as a generic function. In order to do this, dvb_pll_configure must also be altered in the same manner, to take struct dvb_frontend_parameters instead of freq and bandwidth. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c2
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c94
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h4
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c3
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c4
6 files changed, 49 insertions, 62 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index 088b6dee3a7f..4c80823d8d07 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
@@ -90,7 +90,7 @@ int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_paramet
90 deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc); 90 deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc);
91 91
92 b[0] = adap->pll_addr; 92 b[0] = adap->pll_addr;
93 dvb_pll_configure(adap->pll_desc, &b[1], fep->frequency, fep->u.ofdm.bandwidth); 93 dvb_pll_configure(adap->pll_desc, &b[1], fep);
94 94
95 deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]); 95 deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]);
96 96
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};
69EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); 69EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
70 70
71static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth) 71static 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 */
198static void tda665x_bw(u8 *buf, u32 freq, int bandwidth) 199static 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 */
231static void tua6034_bw(u8 *buf, u32 freq, int bandwidth) 232static 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 */
273static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth) 274static 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 */
301static void tded4_bw(u8 *buf, u32 freq, int bandwidth) 303static 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 */
399static void td1316_bw(u8 *buf, u32 freq, int bandwidth) 401static 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};
453EXPORT_SYMBOL(dvb_pll_thomson_fe6600); 455EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
454static void opera1_bw(u8 *buf, u32 freq, int bandwidth) 456static 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);
498MODULE_PARM_DESC(debug, "enable verbose debug messages"); 500MODULE_PARM_DESC(debug, "enable verbose debug messages");
499 501
500int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, 502int 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}
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index 5209f46f0893..83f1279da77f 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -13,7 +13,7 @@ struct dvb_pll_desc {
13 u32 min; 13 u32 min;
14 u32 max; 14 u32 max;
15 u32 iffreq; 15 u32 iffreq;
16 void (*setbw)(u8 *buf, u32 freq, int bandwidth); 16 void (*set)(u8 *buf, const struct dvb_frontend_parameters *params);
17 u8 *initdata; 17 u8 *initdata;
18 u8 *sleepdata; 18 u8 *sleepdata;
19 int count; 19 int count;
@@ -51,7 +51,7 @@ extern struct dvb_pll_desc dvb_pll_thomson_fe6600;
51extern struct dvb_pll_desc dvb_pll_opera1; 51extern struct dvb_pll_desc dvb_pll_opera1;
52 52
53extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, 53extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
54 u32 freq, int bandwidth); 54 const struct dvb_frontend_parameters *params);
55 55
56/** 56/**
57 * Attach a dvb-pll to the supplied frontend structure. 57 * Attach a dvb-pll to the supplied frontend structure.
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 0e817d6f1ce5..8de19cefb24d 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -839,8 +839,7 @@ static int philips_sd1878_tda8261_tuner_set_params(struct dvb_frontend *fe,
839 if((params->frequency < 950000) || (params->frequency > 2150000)) 839 if((params->frequency < 950000) || (params->frequency > 2150000))
840 return -EINVAL; 840 return -EINVAL;
841 841
842 rc=dvb_pll_configure(&dvb_pll_philips_sd1878_tda8261, buf, 842 rc=dvb_pll_configure(&dvb_pll_philips_sd1878_tda8261, buf, params);
843 params->frequency, 0);
844 if(rc < 0) return rc; 843 if(rc < 0) return rc;
845 844
846 if (fe->ops.i2c_gate_ctrl) 845 if (fe->ops.i2c_gate_ctrl)
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 796083f00910..770ea64369ef 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -260,9 +260,7 @@ static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
260 return err; 260 return err;
261 261
262 /* Tune PLL */ 262 /* Tune PLL */
263 dvb_pll_configure(dev->core->pll_desc, buf, 263 dvb_pll_configure(dev->core->pll_desc, buf, params);
264 params->frequency,
265 params->u.ofdm.bandwidth);
266 if (fe->ops.i2c_gate_ctrl) 264 if (fe->ops.i2c_gate_ctrl)
267 fe->ops.i2c_gate_ctrl(fe, 1); 265 fe->ops.i2c_gate_ctrl(fe, 1);
268 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 266 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index e0eec80088c7..d6dd6d55b595 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -181,9 +181,7 @@ static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_fro
181 return -EINVAL; 181 return -EINVAL;
182 182
183 pllbuf[0] = 0x61; 183 pllbuf[0] = 0x61;
184 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, 184 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, params);
185 params->frequency,
186 params->u.ofdm.bandwidth);
187 return 5; 185 return 5;
188} 186}
189 187