diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-cards.c | 138 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-core.c | 32 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx.h | 23 |
3 files changed, 116 insertions, 77 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 | { |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 97635abb916e..841c7c2c91b3 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -314,14 +314,36 @@ int em28xx_colorlevels_set_default(struct em28xx *dev) | |||
314 | 314 | ||
315 | int em28xx_capture_start(struct em28xx *dev, int start) | 315 | int em28xx_capture_start(struct em28xx *dev, int start) |
316 | { | 316 | { |
317 | int ret; | 317 | int rc; |
318 | /* FIXME: which is the best order? */ | 318 | /* FIXME: which is the best order? */ |
319 | /* video registers are sampled by VREF */ | 319 | /* video registers are sampled by VREF */ |
320 | if ((ret = em28xx_write_reg_bits(dev, USBSUSP_REG, start ? 0x10 : 0x00, | 320 | rc = em28xx_write_reg_bits(dev, USBSUSP_REG, |
321 | 0x10)) < 0) | 321 | start ? 0x10 : 0x00, 0x10); |
322 | return ret; | 322 | if (rc < 0) |
323 | return rc; | ||
324 | |||
325 | if (!start) { | ||
326 | /* disable video capture */ | ||
327 | rc = em28xx_write_regs(dev, VINENABLE_REG, "\x27", 1); | ||
328 | if (rc < 0) | ||
329 | return rc; | ||
330 | } | ||
331 | |||
323 | /* enable video capture */ | 332 | /* enable video capture */ |
324 | return em28xx_write_regs(dev, VINENABLE_REG, start ? "\x67" : "\x27", 1); | 333 | rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); |
334 | if (rc < 0) | ||
335 | return rc; | ||
336 | if (dev->mode == EM28XX_ANALOG_MODE) | ||
337 | rc = em28xx_write_regs(dev, VINENABLE_REG,"\x67", 1); | ||
338 | else | ||
339 | rc = em28xx_write_regs(dev, VINENABLE_REG,"\x37", 1); | ||
340 | |||
341 | if (rc < 0) | ||
342 | return rc; | ||
343 | |||
344 | msleep (6); | ||
345 | |||
346 | return rc; | ||
325 | } | 347 | } |
326 | 348 | ||
327 | int em28xx_outfmt_set_yuv422(struct em28xx *dev) | 349 | int em28xx_outfmt_set_yuv422(struct em28xx *dev) |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 96a56faeb77b..00d2f62142e3 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -218,6 +218,21 @@ enum em28xx_decoder { | |||
218 | EM28XX_SAA7114 | 218 | EM28XX_SAA7114 |
219 | }; | 219 | }; |
220 | 220 | ||
221 | #define MAX_GPIO 2 | ||
222 | struct gpio_ctl { | ||
223 | /* Register to be set */ | ||
224 | unsigned char reg; | ||
225 | /* Initial/final value */ | ||
226 | unsigned char val; | ||
227 | /* reset value - if set, it will do: | ||
228 | val1 - val2 - val1 | ||
229 | */ | ||
230 | unsigned char rst; | ||
231 | /* Sleep times | ||
232 | */ | ||
233 | unsigned int t1, t2, t3; | ||
234 | }; | ||
235 | |||
221 | struct em28xx_board { | 236 | struct em28xx_board { |
222 | char *name; | 237 | char *name; |
223 | int vchannels; | 238 | int vchannels; |
@@ -233,7 +248,8 @@ struct em28xx_board { | |||
233 | unsigned int max_range_640_480:1; | 248 | unsigned int max_range_640_480:1; |
234 | unsigned int has_dvb:1; | 249 | unsigned int has_dvb:1; |
235 | 250 | ||
236 | unsigned int analog_gpio; | 251 | struct gpio_ctl analog_gpio[MAX_GPIO]; |
252 | struct gpio_ctl digital_gpio[MAX_GPIO]; | ||
237 | 253 | ||
238 | enum em28xx_decoder decoder; | 254 | enum em28xx_decoder decoder; |
239 | 255 | ||
@@ -293,7 +309,6 @@ struct em28xx { | |||
293 | char name[30]; /* name (including minor) of the device */ | 309 | char name[30]; /* name (including minor) of the device */ |
294 | int model; /* index in the device_data struct */ | 310 | int model; /* index in the device_data struct */ |
295 | int devno; /* marks the number of this device */ | 311 | int devno; /* marks the number of this device */ |
296 | unsigned int analog_gpio; | ||
297 | unsigned int is_em2800:1; | 312 | unsigned int is_em2800:1; |
298 | unsigned int has_msp34xx:1; | 313 | unsigned int has_msp34xx:1; |
299 | unsigned int has_tda9887:1; | 314 | unsigned int has_tda9887:1; |
@@ -303,6 +318,9 @@ struct em28xx { | |||
303 | unsigned int max_range_640_480:1; | 318 | unsigned int max_range_640_480:1; |
304 | unsigned int has_dvb:1; | 319 | unsigned int has_dvb:1; |
305 | 320 | ||
321 | struct gpio_ctl (*analog_gpio)[MAX_GPIO]; | ||
322 | struct gpio_ctl (*digital_gpio)[MAX_GPIO]; | ||
323 | |||
306 | int video_inputs; /* number of video inputs */ | 324 | int video_inputs; /* number of video inputs */ |
307 | struct list_head devlist; | 325 | struct list_head devlist; |
308 | 326 | ||
@@ -443,6 +461,7 @@ extern struct em28xx_board em28xx_boards[]; | |||
443 | extern struct usb_device_id em28xx_id_table[]; | 461 | extern struct usb_device_id em28xx_id_table[]; |
444 | extern const unsigned int em28xx_bcount; | 462 | extern const unsigned int em28xx_bcount; |
445 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); | 463 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); |
464 | int em28xx_tuner_callback(void *ptr, int command, int arg); | ||
446 | 465 | ||
447 | /* Provided by em28xx-input.c */ | 466 | /* Provided by em28xx-input.c */ |
448 | /* TODO: Check if the standard get_key handlers on ir-common can be used */ | 467 | /* TODO: Check if the standard get_key handlers on ir-common can be used */ |