diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-17 20:37:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:40 -0400 |
commit | ee6e3a865a469c78daa93a1e6cdbaca3a102f9c8 (patch) | |
tree | 43de64b3158e8ca9d4d1f580a985478b30d106fe /drivers/media/video/em28xx/em28xx-cards.c | |
parent | acaa4b609fbab25e09459cd8e842e292b27f5ecb (diff) |
V4L/DVB (7595): Improve generic support for setting gpio values
em28xx based devices with xc3028 may require some specific gpio values.
This patch adds a generic handling for such values.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-cards.c')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-cards.c | 138 |
1 files changed, 68 insertions, 70 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index bbd75bd3ff1a..c907d6a5a056 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -194,9 +194,6 @@ struct em28xx_board em28xx_boards[] = { | |||
194 | .vmux = TVP5150_SVIDEO, | 194 | .vmux = TVP5150_SVIDEO, |
195 | .amux = 1, | 195 | .amux = 1, |
196 | } }, | 196 | } }, |
197 | |||
198 | /* gpio's 4, 1, 0 */ | ||
199 | .analog_gpio = 0x003d2d, | ||
200 | }, | 197 | }, |
201 | [EM2880_BOARD_TERRATEC_HYBRID_XS] = { | 198 | [EM2880_BOARD_TERRATEC_HYBRID_XS] = { |
202 | .name = "Terratec Hybrid XS", | 199 | .name = "Terratec Hybrid XS", |
@@ -445,73 +442,88 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { | |||
445 | {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC}, | 442 | {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC}, |
446 | }; | 443 | }; |
447 | 444 | ||
445 | int em28xx_tuner_callback(void *ptr, int command, int arg) | ||
446 | { | ||
447 | int rc = 0, i; | ||
448 | struct em28xx *dev = ptr; | ||
449 | struct gpio_ctl (*gpio_ctl)[MAX_GPIO]; | ||
450 | |||
451 | if (dev->tuner_type != TUNER_XC2028) | ||
452 | return 0; | ||
453 | |||
454 | if (command != XC2028_TUNER_RESET) | ||
455 | return 0; | ||
456 | |||
457 | if (dev->mode == EM28XX_ANALOG_MODE) | ||
458 | gpio_ctl = dev->analog_gpio; | ||
459 | else | ||
460 | gpio_ctl = dev->digital_gpio; | ||
461 | |||
462 | /* Send GPIO reset sequences specified at board entry */ | ||
463 | for (i = 0; i < MAX_GPIO; i++) { | ||
464 | if (!gpio_ctl[i]->val) | ||
465 | break; | ||
466 | |||
467 | dev->em28xx_write_regs(dev, | ||
468 | gpio_ctl[i]->reg, | ||
469 | &gpio_ctl[i]->val, 1); | ||
470 | if (gpio_ctl[i]->t1) | ||
471 | msleep(gpio_ctl[i]->t1); | ||
472 | |||
473 | if (!gpio_ctl[i]->rst) | ||
474 | continue; | ||
475 | dev->em28xx_write_regs(dev, | ||
476 | gpio_ctl[i]->reg, | ||
477 | &gpio_ctl[i]->rst, 1); | ||
478 | if (gpio_ctl[i]->t2) | ||
479 | msleep(gpio_ctl[i]->t2); | ||
480 | |||
481 | dev->em28xx_write_regs(dev, | ||
482 | gpio_ctl[i]->reg, | ||
483 | &gpio_ctl[i]->val, 1); | ||
484 | if (gpio_ctl[i]->t3) | ||
485 | msleep(gpio_ctl[i]->t3); | ||
486 | } | ||
487 | return rc; | ||
488 | } | ||
489 | EXPORT_SYMBOL_GPL(em28xx_tuner_callback); | ||
490 | |||
491 | static void em28xx_set_model(struct em28xx *dev) | ||
492 | { | ||
493 | dev->is_em2800 = em28xx_boards[dev->model].is_em2800; | ||
494 | dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx; | ||
495 | dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf; | ||
496 | dev->decoder = em28xx_boards[dev->model].decoder; | ||
497 | dev->video_inputs = em28xx_boards[dev->model].vchannels; | ||
498 | dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s; | ||
499 | dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; | ||
500 | dev->has_dvb = em28xx_boards[dev->model].has_dvb; | ||
501 | dev->analog_gpio = &em28xx_boards[dev->model].analog_gpio; | ||
502 | dev->digital_gpio = &em28xx_boards[dev->model].digital_gpio; | ||
503 | } | ||
504 | |||
448 | /* Since em28xx_pre_card_setup() requires a proper dev->model, | 505 | /* Since em28xx_pre_card_setup() requires a proper dev->model, |
449 | * this won't work for boards with generic PCI IDs | 506 | * this won't work for boards with generic PCI IDs |
450 | */ | 507 | */ |
451 | void em28xx_pre_card_setup(struct em28xx *dev) | 508 | void em28xx_pre_card_setup(struct em28xx *dev) |
452 | { | 509 | { |
510 | em28xx_set_model(dev); | ||
511 | |||
453 | /* request some modules */ | 512 | /* request some modules */ |
454 | switch (dev->model) { | 513 | switch (dev->model) { |
455 | case EM2880_BOARD_TERRATEC_PRODIGY_XS: | 514 | case EM2880_BOARD_TERRATEC_PRODIGY_XS: |
456 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: | 515 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: |
457 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: | ||
458 | case EM2880_BOARD_TERRATEC_HYBRID_XS: | 516 | case EM2880_BOARD_TERRATEC_HYBRID_XS: |
517 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: | ||
459 | em28xx_write_regs(dev, XCLK_REG, "\x27", 1); | 518 | em28xx_write_regs(dev, XCLK_REG, "\x27", 1); |
460 | em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1); | 519 | em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1); |
461 | em28xx_write_regs(dev, 0x08, "\xff", 1); | ||
462 | em28xx_write_regs(dev, 0x04, "\x00", 1); | ||
463 | msleep(100); | ||
464 | em28xx_write_regs(dev, 0x04, "\x08", 1); | ||
465 | msleep(100); | ||
466 | em28xx_write_regs(dev, 0x08, "\xff", 1); | ||
467 | msleep(50); | ||
468 | em28xx_write_regs(dev, 0x08, "\x2d", 1); | ||
469 | msleep(50); | ||
470 | em28xx_write_regs(dev, 0x08, "\x3d", 1); | ||
471 | break; | ||
472 | } | 520 | } |
473 | } | ||
474 | |||
475 | static int em28xx_tuner_callback(void *ptr, int command, int arg) | ||
476 | { | ||
477 | int rc = 0; | ||
478 | struct em28xx *dev = ptr; | ||
479 | |||
480 | if (dev->tuner_type != TUNER_XC2028) | ||
481 | return 0; | ||
482 | 521 | ||
483 | switch (command) { | 522 | /* Put xc2028 tuners and demods into a sane state */ |
484 | case XC2028_TUNER_RESET: | 523 | if (dev->tuner_type == TUNER_XC2028) { |
485 | { | 524 | dev->mode = EM28XX_DIGITAL_MODE; |
486 | /* GPIO and initialization codes for analog TV and radio | 525 | em28xx_tuner_callback(dev, XC2028_TUNER_RESET, 0); |
487 | This code should be complemented for DTV, since reset | 526 | }; |
488 | codes are different. | ||
489 | */ | ||
490 | |||
491 | dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); | ||
492 | dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1); | ||
493 | |||
494 | if (dev->analog_gpio) { | ||
495 | char gpio0 = dev->analog_gpio & 0xff; | ||
496 | char gpio1 = (dev->analog_gpio >> 8) & 0xff; | ||
497 | char gpio4 = dev->analog_gpio >> 24; | ||
498 | |||
499 | if (gpio4) { | ||
500 | dev->em28xx_write_regs(dev, 0x04, &gpio4, 1); | ||
501 | msleep(140); | ||
502 | } | ||
503 | |||
504 | msleep(6); | ||
505 | dev->em28xx_write_regs(dev, 0x08, &gpio0, 1); | ||
506 | msleep(10); | ||
507 | dev->em28xx_write_regs(dev, 0x08, &gpio1, 1); | ||
508 | msleep(5); | ||
509 | } | ||
510 | |||
511 | break; | ||
512 | } | ||
513 | } | ||
514 | return rc; | ||
515 | } | 527 | } |
516 | 528 | ||
517 | static void em28xx_config_tuner(struct em28xx *dev) | 529 | static void em28xx_config_tuner(struct em28xx *dev) |
@@ -634,20 +646,6 @@ static int em28xx_hint_board(struct em28xx *dev) | |||
634 | return -1; | 646 | return -1; |
635 | } | 647 | } |
636 | 648 | ||
637 | |||
638 | static void em28xx_set_model(struct em28xx *dev) | ||
639 | { | ||
640 | dev->is_em2800 = em28xx_boards[dev->model].is_em2800; | ||
641 | dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx; | ||
642 | dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf; | ||
643 | dev->decoder = em28xx_boards[dev->model].decoder; | ||
644 | dev->video_inputs = em28xx_boards[dev->model].vchannels; | ||
645 | dev->analog_gpio = em28xx_boards[dev->model].analog_gpio; | ||
646 | dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s; | ||
647 | dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; | ||
648 | dev->has_dvb = em28xx_boards[dev->model].has_dvb; | ||
649 | } | ||
650 | |||
651 | /* ----------------------------------------------------------------------- */ | 649 | /* ----------------------------------------------------------------------- */ |
652 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir) | 650 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir) |
653 | { | 651 | { |