aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitri Belimov <d.belimov@gmail.com>2010-05-04 18:53:50 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:58:41 -0400
commit1b0e48ad5530881d11d3caba62e59b82646c5e64 (patch)
treebbf5ccf3cbf0ca1936c0ee1b20db532894e93553 /drivers
parent9b558434136138edc79710385aaf613cb4b30459 (diff)
V4L/DVB: Rework for support xc5000
Set correct GPIO number for BEHOLD_WANDER/VOYAGER Add xc5000 callback function Small rework tm6000_cards_setup function Small rework tm6000_config_tuner, build mode_mask by config information Rework for support xc5000 silicon tuner Add some information messages for more better understand an errors. [mchehab@redhat.com: Fix CodingStyle and merge conflicts] Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/tm6000/tm6000-cards.c146
-rw-r--r--drivers/staging/tm6000/tm6000.h1
2 files changed, 110 insertions, 37 deletions
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 00d46ab185a1..160b4d714898 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -231,7 +231,9 @@ struct tm6000_board tm6000_boards[] = {
231 .has_remote = 1, 231 .has_remote = 1,
232 }, 232 },
233 .gpio = { 233 .gpio = {
234 .tuner_reset = TM6000_GPIO_2, 234 .tuner_reset = TM6010_GPIO_0,
235 .demod_reset = TM6010_GPIO_1,
236 .power_led = TM6010_GPIO_6,
235 }, 237 },
236 }, 238 },
237 [TM6010_BOARD_BEHOLD_VOYAGER] = { 239 [TM6010_BOARD_BEHOLD_VOYAGER] = {
@@ -247,7 +249,8 @@ struct tm6000_board tm6000_boards[] = {
247 .has_remote = 1, 249 .has_remote = 1,
248 }, 250 },
249 .gpio = { 251 .gpio = {
250 .tuner_reset = TM6000_GPIO_2, 252 .tuner_reset = TM6010_GPIO_0,
253 .power_led = TM6010_GPIO_6,
251 }, 254 },
252 }, 255 },
253 [TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE] = { 256 [TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE] = {
@@ -320,6 +323,31 @@ struct usb_device_id tm6000_id_table[] = {
320 { }, 323 { },
321}; 324};
322 325
326/* Tuner callback to provide the proper gpio changes needed for xc5000 */
327int tm6000_xc5000_callback(void *ptr, int component, int command, int arg)
328{
329 int rc = 0;
330 struct tm6000_core *dev = ptr;
331
332 if (dev->tuner_type != TUNER_XC5000)
333 return 0;
334
335 switch (command) {
336 case XC5000_TUNER_RESET:
337 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
338 dev->gpio.tuner_reset, 0x01);
339 msleep(15);
340 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
341 dev->gpio.tuner_reset, 0x00);
342 msleep(15);
343 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
344 dev->gpio.tuner_reset, 0x01);
345 break;
346 }
347 return (rc);
348}
349
350
323/* Tuner callback to provide the proper gpio changes needed for xc2028 */ 351/* Tuner callback to provide the proper gpio changes needed for xc2028 */
324 352
325int tm6000_tuner_callback(void *ptr, int component, int command, int arg) 353int tm6000_tuner_callback(void *ptr, int component, int command, int arg)
@@ -454,6 +482,21 @@ int tm6000_cards_setup(struct tm6000_core *dev)
454 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_on, 0x00); 482 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_on, 0x00);
455 msleep(15); 483 msleep(15);
456 break; 484 break;
485 case TM6010_BOARD_BEHOLD_WANDER:
486 /* Power led on (blue) */
487 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.power_led, 0x01);
488 msleep(15);
489 /* Reset zarlink zl10353 */
490 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_reset, 0x00);
491 msleep(50);
492 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_reset, 0x01);
493 msleep(15);
494 break;
495 case TM6010_BOARD_BEHOLD_VOYAGER:
496 /* Power led on (blue) */
497 tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.power_led, 0x01);
498 msleep(15);
499 break;
457 default: 500 default:
458 break; 501 break;
459 } 502 }
@@ -465,41 +508,34 @@ int tm6000_cards_setup(struct tm6000_core *dev)
465 * If a device uses a different sequence or different GPIO pins for 508 * If a device uses a different sequence or different GPIO pins for
466 * reset, just add the code at the board-specific part 509 * reset, just add the code at the board-specific part
467 */ 510 */
468 for (i = 0; i < 2; i++) {
469 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
470 dev->gpio.tuner_reset, 0x00);
471 if (rc < 0) {
472 printk(KERN_ERR "Error %i doing GPIO1 reset\n", rc);
473 return rc;
474 }
475
476 msleep(10); /* Just to be conservative */
477 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
478 dev->gpio.tuner_reset, 0x01);
479 if (rc < 0) {
480 printk(KERN_ERR "Error %i doing GPIO1 reset\n", rc);
481 return rc;
482 }
483 511
484 msleep(10); 512 if (dev->gpio.tuner_reset) {
485 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_4, 0); 513 for (i = 0; i < 2; i++) {
486 if (rc < 0) { 514 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
487 printk(KERN_ERR "Error %i doing GPIO4 reset\n", rc); 515 dev->gpio.tuner_reset, 0x00);
488 return rc; 516 if (rc < 0) {
489 } 517 printk(KERN_ERR "Error %i doing tuner reset\n", rc);
518 return rc;
519 }
490 520
491 msleep(10); 521 msleep(10); /* Just to be conservative */
492 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_4, 1); 522 rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
493 if (rc < 0) { 523 dev->gpio.tuner_reset, 0x01);
494 printk(KERN_ERR "Error %i doing GPIO4 reset\n", rc); 524 if (rc < 0) {
495 return rc; 525 printk(KERN_ERR "Error %i doing tuner reset\n", rc);
496 } 526 return rc;
527 }
528 msleep(10);
497 529
498 if (!i) { 530 if (!i) {
499 rc = tm6000_get_reg32(dev, REQ_40_GET_VERSION, 0, 0); 531 rc = tm6000_get_reg32(dev, REQ_40_GET_VERSION, 0, 0);
500 if (rc >= 0) 532 if (rc >= 0)
501 printk(KERN_DEBUG "board=0x%08x\n", rc); 533 printk(KERN_DEBUG "board=0x%08x\n", rc);
534 }
502 } 535 }
536 } else {
537 printk(KERN_ERR "Tuner reset is not configured\n");
538 return -1;
503 } 539 }
504 540
505 msleep(50); 541 msleep(50);
@@ -518,12 +554,26 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
518 memset(&tun_setup, 0, sizeof(tun_setup)); 554 memset(&tun_setup, 0, sizeof(tun_setup));
519 tun_setup.type = dev->tuner_type; 555 tun_setup.type = dev->tuner_type;
520 tun_setup.addr = dev->tuner_addr; 556 tun_setup.addr = dev->tuner_addr;
521 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO | T_DIGITAL_TV; 557
522 tun_setup.tuner_callback = tm6000_tuner_callback; 558 tun_setup.mode_mask = 0;
559 if (dev->caps.has_tuner)
560 tun_setup.mode_mask |= (T_ANALOG_TV | T_RADIO);
561 if (dev->caps.has_dvb)
562 tun_setup.mode_mask |= T_DIGITAL_TV;
563
564 switch (dev->tuner_type) {
565 case TUNER_XC2028:
566 tun_setup.tuner_callback = tm6000_tuner_callback;;
567 break;
568 case TUNER_XC5000:
569 tun_setup.tuner_callback = tm6000_xc5000_callback;
570 break;
571 }
523 572
524 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup); 573 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
525 574
526 if (dev->tuner_type == TUNER_XC2028) { 575 switch (dev->tuner_type) {
576 case TUNER_XC2028: {
527 struct v4l2_priv_tun_config xc2028_cfg; 577 struct v4l2_priv_tun_config xc2028_cfg;
528 struct xc2028_ctrl ctl; 578 struct xc2028_ctrl ctl;
529 579
@@ -553,9 +603,31 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
553 } 603 }
554 604
555 printk(KERN_INFO "Setting firmware parameters for xc2028\n"); 605 printk(KERN_INFO "Setting firmware parameters for xc2028\n");
556
557 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, 606 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
558 &xc2028_cfg); 607 &xc2028_cfg);
608
609 }
610 break;
611 case TUNER_XC5000:
612 {
613 struct v4l2_priv_tun_config xc5000_cfg;
614 struct xc5000_config ctl = {
615 .i2c_address = dev->tuner_addr,
616 .if_khz = 4570,
617 .radio_input = XC5000_RADIO_FM1,
618 };
619
620 xc5000_cfg.tuner = TUNER_XC5000;
621 xc5000_cfg.priv = &ctl;
622
623
624 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
625 &xc5000_cfg);
626 }
627 break;
628 default:
629 printk(KERN_INFO "Unknown tuner type. Tuner is not configured.\n");
630 break;
559 } 631 }
560} 632}
561 633
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 5a587f7de6a1..b49c139c6b55 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -222,6 +222,7 @@ struct tm6000_fh {
222/* In tm6000-cards.c */ 222/* In tm6000-cards.c */
223 223
224int tm6000_tuner_callback (void *ptr, int component, int command, int arg); 224int tm6000_tuner_callback (void *ptr, int component, int command, int arg);
225int tm6000_xc5000_callback (void *ptr, int component, int command, int arg);
225int tm6000_cards_setup(struct tm6000_core *dev); 226int tm6000_cards_setup(struct tm6000_core *dev);
226 227
227/* In tm6000-core.c */ 228/* In tm6000-core.c */