aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorAndrew de Quincey <adq_dvb@lidskialf.net>2006-04-18 16:47:12 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-25 00:59:16 -0400
commit74aa7a29fea916cb40c98c38e885cc2087c78774 (patch)
tree1d09dc7d0142f674c6ef892837f63a8f4a08ddcb /drivers/media/dvb
parent272bc4db791bc49d50d5f77f24c688be6d1907f8 (diff)
V4L/DVB (3887): Convert bt8xx to refactored tuner code
Rename pll calls to appropriate tuner calls. Remove pll functions from demod structures. Hook tuner call into tuner_ops. Attach dvb-pll where possible. Add pll gate control calls where appropriate. Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c71
1 files changed, 44 insertions, 27 deletions
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index c56f26c93b7a..0f23ec04f7bc 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -147,12 +147,15 @@ static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
147 return 0; 147 return 0;
148} 148}
149 149
150static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) 150static int thomson_dtt7579_tuner_pllbuf(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len)
151{ 151{
152 u32 div; 152 u32 div;
153 unsigned char bs = 0; 153 unsigned char bs = 0;
154 unsigned char cp = 0; 154 unsigned char cp = 0;
155 155
156 if (buf_len < 5)
157 return -EINVAL;
158
156 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 159 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
157 160
158 if (params->frequency < 542000000) 161 if (params->frequency < 542000000)
@@ -169,27 +172,25 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_
169 else 172 else
170 bs = 0x08; 173 bs = 0x08;
171 174
172 pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address 175 pllbuf[0] = 0x60;
173 pllbuf[1] = div >> 8; 176 pllbuf[1] = div >> 8;
174 pllbuf[2] = div & 0xff; 177 pllbuf[2] = div & 0xff;
175 pllbuf[3] = cp; 178 pllbuf[3] = cp;
176 pllbuf[4] = bs; 179 pllbuf[4] = bs;
177 180
178 return 0; 181 return 5;
179} 182}
180 183
181static struct mt352_config thomson_dtt7579_config = { 184static struct mt352_config thomson_dtt7579_config = {
182 .demod_address = 0x0f, 185 .demod_address = 0x0f,
183 .demod_init = thomson_dtt7579_demod_init, 186 .demod_init = thomson_dtt7579_demod_init,
184 .pll_set = thomson_dtt7579_pll_set,
185}; 187};
186 188
187static struct zl10353_config thomson_dtt7579_zl10353_config = { 189static struct zl10353_config thomson_dtt7579_zl10353_config = {
188 .demod_address = 0x0f, 190 .demod_address = 0x0f,
189 .pll_set = thomson_dtt7579_pll_set,
190}; 191};
191 192
192static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 193static int cx24108_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
193{ 194{
194 u32 freq = params->frequency; 195 u32 freq = params->frequency;
195 196
@@ -242,7 +243,7 @@ static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete
242 return 0; 243 return 0;
243} 244}
244 245
245static int pinnsat_pll_init(struct dvb_frontend* fe) 246static int pinnsat_tuner_init(struct dvb_frontend* fe)
246{ 247{
247 struct dvb_bt8xx_card *card = fe->dvb->priv; 248 struct dvb_bt8xx_card *card = fe->dvb->priv;
248 249
@@ -252,7 +253,7 @@ static int pinnsat_pll_init(struct dvb_frontend* fe)
252 return 0; 253 return 0;
253} 254}
254 255
255static int pinnsat_pll_sleep(struct dvb_frontend* fe) 256static int pinnsat_tuner_sleep(struct dvb_frontend* fe)
256{ 257{
257 struct dvb_bt8xx_card *card = fe->dvb->priv; 258 struct dvb_bt8xx_card *card = fe->dvb->priv;
258 259
@@ -263,12 +264,9 @@ static int pinnsat_pll_sleep(struct dvb_frontend* fe)
263 264
264static struct cx24110_config pctvsat_config = { 265static struct cx24110_config pctvsat_config = {
265 .demod_address = 0x55, 266 .demod_address = 0x55,
266 .pll_init = pinnsat_pll_init,
267 .pll_set = cx24108_pll_set,
268 .pll_sleep = pinnsat_pll_sleep,
269}; 267};
270 268
271static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 269static int microtune_mt7202dtf_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
272{ 270{
273 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; 271 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
274 u8 cfg, cpump, band_select; 272 u8 cfg, cpump, band_select;
@@ -302,6 +300,8 @@ static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_front
302 data[2] = ((div >> 10) & 0x60) | cfg; 300 data[2] = ((div >> 10) & 0x60) | cfg;
303 data[3] = (cpump << 6) | band_select; 301 data[3] = (cpump << 6) | band_select;
304 302
303 if (fe->ops->i2c_gate_ctrl)
304 fe->ops->i2c_gate_ctrl(fe, 1);
305 i2c_transfer(card->i2c_adapter, &msg, 1); 305 i2c_transfer(card->i2c_adapter, &msg, 1);
306 return (div * 166666 - 36000000); 306 return (div * 166666 - 36000000);
307} 307}
@@ -315,7 +315,6 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s
315 315
316static struct sp887x_config microtune_mt7202dtf_config = { 316static struct sp887x_config microtune_mt7202dtf_config = {
317 .demod_address = 0x70, 317 .demod_address = 0x70,
318 .pll_set = microtune_mt7202dtf_pll_set,
319 .request_firmware = microtune_mt7202dtf_request_firmware, 318 .request_firmware = microtune_mt7202dtf_request_firmware,
320}; 319};
321 320
@@ -342,12 +341,14 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
342 return 0; 341 return 0;
343} 342}
344 343
345static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) 344static int advbt771_samsung_tdtc9251dh0_tuner_pllbuf(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len)
346{ 345{
347 u32 div; 346 u32 div;
348 unsigned char bs = 0; 347 unsigned char bs = 0;
349 unsigned char cp = 0; 348 unsigned char cp = 0;
350 349
350 if (buf_len < 5) return -EINVAL;
351
351 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 352 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
352 353
353 if (params->frequency < 150000000) 354 if (params->frequency < 150000000)
@@ -388,19 +389,18 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct
388 else 389 else
389 bs = 0x08; 390 bs = 0x08;
390 391
391 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address 392 pllbuf[0] = 0x61;
392 pllbuf[1] = div >> 8; 393 pllbuf[1] = div >> 8;
393 pllbuf[2] = div & 0xff; 394 pllbuf[2] = div & 0xff;
394 pllbuf[3] = cp; 395 pllbuf[3] = cp;
395 pllbuf[4] = bs; 396 pllbuf[4] = bs;
396 397
397 return 0; 398 return 5;
398} 399}
399 400
400static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { 401static struct mt352_config advbt771_samsung_tdtc9251dh0_config = {
401 .demod_address = 0x0f, 402 .demod_address = 0x0f,
402 .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, 403 .demod_init = advbt771_samsung_tdtc9251dh0_demod_init,
403 .pll_set = advbt771_samsung_tdtc9251dh0_pll_set,
404}; 404};
405 405
406static struct dst_config dst_config = { 406static struct dst_config dst_config = {
@@ -460,7 +460,7 @@ static struct or51211_config or51211_config = {
460 .sleep = or51211_sleep, 460 .sleep = or51211_sleep,
461}; 461};
462 462
463static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 463static int vp3021_alps_tded4_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
464{ 464{
465 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; 465 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
466 u8 buf[4]; 466 u8 buf[4];
@@ -483,6 +483,8 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten
483 else 483 else
484 return -EINVAL; 484 return -EINVAL;
485 485
486 if (fe->ops->i2c_gate_ctrl)
487 fe->ops->i2c_gate_ctrl(fe, 1);
486 i2c_transfer(card->i2c_adapter, &msg, 1); 488 i2c_transfer(card->i2c_adapter, &msg, 1);
487 return 0; 489 return 0;
488} 490}
@@ -490,7 +492,6 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten
490static struct nxt6000_config vp3021_alps_tded4_config = { 492static struct nxt6000_config vp3021_alps_tded4_config = {
491 .demod_address = 0x0a, 493 .demod_address = 0x0a,
492 .clock_inversion = 1, 494 .clock_inversion = 1,
493 .pll_set = vp3021_alps_tded4_pll_set,
494}; 495};
495 496
496static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe) 497static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
@@ -511,14 +512,17 @@ static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
511 return 0; 512 return 0;
512} 513}
513 514
514static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) 515static int digitv_alps_tded4_tuner_pllbuf(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len)
515{ 516{
516 u32 div; 517 u32 div;
517 struct dvb_ofdm_parameters *op = &params->u.ofdm; 518 struct dvb_ofdm_parameters *op = &params->u.ofdm;
518 519
520 if (buf_len < 5)
521 return -EINVAL;
522
519 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 523 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
520 524
521 pllbuf[0] = 0xc2; 525 pllbuf[0] = 0x61;
522 pllbuf[1] = (div >> 8) & 0x7F; 526 pllbuf[1] = (div >> 8) & 0x7F;
523 pllbuf[2] = div & 0xFF; 527 pllbuf[2] = div & 0xFF;
524 pllbuf[3] = 0x85; 528 pllbuf[3] = 0x85;
@@ -535,7 +539,7 @@ static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten
535 if (op->bandwidth == 8) 539 if (op->bandwidth == 8)
536 pllbuf[4] |= 0x04; 540 pllbuf[4] |= 0x04;
537 541
538 return 0; 542 return 5;
539} 543}
540 544
541static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt) 545static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
@@ -562,10 +566,9 @@ static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
562static struct mt352_config digitv_alps_tded4_config = { 566static struct mt352_config digitv_alps_tded4_config = {
563 .demod_address = 0x0a, 567 .demod_address = 0x0a,
564 .demod_init = digitv_alps_tded4_demod_init, 568 .demod_init = digitv_alps_tded4_demod_init,
565 .pll_set = digitv_alps_tded4_pll_set,
566}; 569};
567 570
568static int tdvs_tua6034_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 571static int tdvs_tua6034_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
569{ 572{
570 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; 573 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
571 return lg_h06xf_pll_set(fe, card->i2c_adapter, params); 574 return lg_h06xf_pll_set(fe, card->i2c_adapter, params);
@@ -575,7 +578,6 @@ static struct lgdt330x_config tdvs_tua6034_config = {
575 .demod_address = 0x0e, 578 .demod_address = 0x0e,
576 .demod_chip = LGDT3303, 579 .demod_chip = LGDT3303,
577 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ 580 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
578 .pll_set = tdvs_tua6034_pll_set,
579}; 581};
580 582
581static void lgdt330x_reset(struct dvb_bt8xx_card *bt) 583static void lgdt330x_reset(struct dvb_bt8xx_card *bt)
@@ -605,6 +607,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
605 card->i2c_adapter); 607 card->i2c_adapter);
606 608
607 if (card->fe != NULL) { 609 if (card->fe != NULL) {
610 card->fe->ops->tuner_ops.pllbuf = thomson_dtt7579_tuner_pllbuf;
608 card->fe->ops->info.frequency_min = 174000000; 611 card->fe->ops->info.frequency_min = 174000000;
609 card->fe->ops->info.frequency_max = 862000000; 612 card->fe->ops->info.frequency_max = 862000000;
610 } 613 }
@@ -613,8 +616,10 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
613 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE: 616 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
614 lgdt330x_reset(card); 617 lgdt330x_reset(card);
615 card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter); 618 card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter);
616 if (card->fe != NULL) 619 if (card->fe != NULL) {
620 card->fe->ops->tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
617 dprintk ("dvb_bt8xx: lgdt330x detected\n"); 621 dprintk ("dvb_bt8xx: lgdt330x detected\n");
622 }
618 break; 623 break;
619 624
620 case BTTV_BOARD_NEBULA_DIGITV: 625 case BTTV_BOARD_NEBULA_DIGITV:
@@ -627,6 +632,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
627 digitv_alps_tded4_reset(card); 632 digitv_alps_tded4_reset(card);
628 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); 633 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
629 if (card->fe != NULL) { 634 if (card->fe != NULL) {
635 card->fe->ops->tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
630 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); 636 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
631 break; 637 break;
632 } 638 }
@@ -635,17 +641,23 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
635 digitv_alps_tded4_reset(card); 641 digitv_alps_tded4_reset(card);
636 card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); 642 card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);
637 643
638 if (card->fe != NULL) 644 if (card->fe != NULL) {
645 card->fe->ops->tuner_ops.pllbuf = digitv_alps_tded4_tuner_pllbuf;
639 dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); 646 dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n");
647 }
640 break; 648 break;
641 649
642 case BTTV_BOARD_AVDVBT_761: 650 case BTTV_BOARD_AVDVBT_761:
643 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter); 651 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
652 if (card->fe) {
653 card->fe->ops->tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
654 }
644 break; 655 break;
645 656
646 case BTTV_BOARD_AVDVBT_771: 657 case BTTV_BOARD_AVDVBT_771:
647 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); 658 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
648 if (card->fe != NULL) { 659 if (card->fe != NULL) {
660 card->fe->ops->tuner_ops.pllbuf = advbt771_samsung_tdtc9251dh0_tuner_pllbuf;
649 card->fe->ops->info.frequency_min = 174000000; 661 card->fe->ops->info.frequency_min = 174000000;
650 card->fe->ops->info.frequency_max = 862000000; 662 card->fe->ops->info.frequency_max = 862000000;
651 } 663 }
@@ -674,6 +686,11 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
674 686
675 case BTTV_BOARD_PINNACLESAT: 687 case BTTV_BOARD_PINNACLESAT:
676 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); 688 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
689 if (card->fe) {
690 card->fe->ops->tuner_ops.init = pinnsat_tuner_init;
691 card->fe->ops->tuner_ops.sleep = pinnsat_tuner_sleep;
692 card->fe->ops->tuner_ops.set_params = cx24108_tuner_set_params;
693 }
677 break; 694 break;
678 695
679 case BTTV_BOARD_PC_HDTV: 696 case BTTV_BOARD_PC_HDTV: