diff options
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx.h')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx.h | 120 |
1 files changed, 83 insertions, 37 deletions
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index f8726ad5d0a8..32d8a4bb7961 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h | |||
@@ -26,6 +26,9 @@ | |||
26 | #ifndef _EM28XX_H | 26 | #ifndef _EM28XX_H |
27 | #define _EM28XX_H | 27 | #define _EM28XX_H |
28 | 28 | ||
29 | #define EM28XX_VERSION "0.2.1" | ||
30 | #define DRIVER_DESC "Empia em28xx device driver" | ||
31 | |||
29 | #include <linux/workqueue.h> | 32 | #include <linux/workqueue.h> |
30 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
31 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
@@ -132,6 +135,8 @@ | |||
132 | #define EM2884_BOARD_C3TECH_DIGITAL_DUO 88 | 135 | #define EM2884_BOARD_C3TECH_DIGITAL_DUO 88 |
133 | #define EM2874_BOARD_DELOCK_61959 89 | 136 | #define EM2874_BOARD_DELOCK_61959 89 |
134 | #define EM2874_BOARD_KWORLD_UB435Q_V2 90 | 137 | #define EM2874_BOARD_KWORLD_UB435Q_V2 90 |
138 | #define EM2765_BOARD_SPEEDLINK_VAD_LAPLACE 91 | ||
139 | #define EM28178_BOARD_PCTV_461E 92 | ||
135 | 140 | ||
136 | /* Limits minimum and default number of buffers */ | 141 | /* Limits minimum and default number of buffers */ |
137 | #define EM28XX_MIN_BUF 4 | 142 | #define EM28XX_MIN_BUF 4 |
@@ -178,8 +183,27 @@ | |||
178 | 183 | ||
179 | #define EM28XX_INTERLACED_DEFAULT 1 | 184 | #define EM28XX_INTERLACED_DEFAULT 1 |
180 | 185 | ||
181 | /* time in msecs to wait for i2c writes to finish */ | 186 | /* |
182 | #define EM2800_I2C_XFER_TIMEOUT 20 | 187 | * Time in msecs to wait for i2c xfers to finish. |
188 | * 35ms is the maximum time a SMBUS device could wait when | ||
189 | * clock stretching is used. As the transfer itself will take | ||
190 | * some time to happen, set it to 35 ms. | ||
191 | * | ||
192 | * Ok, I2C doesn't specify any limit. So, eventually, we may need | ||
193 | * to increase this timeout. | ||
194 | * | ||
195 | * FIXME: this assumes that an I2C message is not longer than 1ms. | ||
196 | * This is actually dependent on the I2C bus speed, although most | ||
197 | * devices use a 100kHz clock. So, this assumtion is true most of | ||
198 | * the time. | ||
199 | */ | ||
200 | #define EM28XX_I2C_XFER_TIMEOUT 36 | ||
201 | |||
202 | /* time in msecs to wait for AC97 xfers to finish */ | ||
203 | #define EM28XX_AC97_XFER_TIMEOUT 100 | ||
204 | |||
205 | /* max. number of button state polling addresses */ | ||
206 | #define EM28XX_NUM_BUTTON_ADDRESSES_MAX 5 | ||
183 | 207 | ||
184 | enum em28xx_mode { | 208 | enum em28xx_mode { |
185 | EM28XX_SUSPEND, | 209 | EM28XX_SUSPEND, |
@@ -287,8 +311,7 @@ struct em28xx_audio_mode { | |||
287 | 311 | ||
288 | unsigned int has_audio:1; | 312 | unsigned int has_audio:1; |
289 | 313 | ||
290 | unsigned int i2s_3rates:1; | 314 | u8 i2s_samplerates; |
291 | unsigned int i2s_5rates:1; | ||
292 | }; | 315 | }; |
293 | 316 | ||
294 | /* em28xx has two audio inputs: tuner and line in. | 317 | /* em28xx has two audio inputs: tuner and line in. |
@@ -374,6 +397,33 @@ enum em28xx_adecoder { | |||
374 | EM28XX_TVAUDIO, | 397 | EM28XX_TVAUDIO, |
375 | }; | 398 | }; |
376 | 399 | ||
400 | enum em28xx_led_role { | ||
401 | EM28XX_LED_ANALOG_CAPTURING = 0, | ||
402 | EM28XX_LED_ILLUMINATION, | ||
403 | EM28XX_NUM_LED_ROLES, /* must be the last */ | ||
404 | }; | ||
405 | |||
406 | struct em28xx_led { | ||
407 | enum em28xx_led_role role; | ||
408 | u8 gpio_reg; | ||
409 | u8 gpio_mask; | ||
410 | bool inverted; | ||
411 | }; | ||
412 | |||
413 | enum em28xx_button_role { | ||
414 | EM28XX_BUTTON_SNAPSHOT = 0, | ||
415 | EM28XX_BUTTON_ILLUMINATION, | ||
416 | EM28XX_NUM_BUTTON_ROLES, /* must be the last */ | ||
417 | }; | ||
418 | |||
419 | struct em28xx_button { | ||
420 | enum em28xx_button_role role; | ||
421 | u8 reg_r; | ||
422 | u8 reg_clearing; | ||
423 | u8 mask; | ||
424 | bool inverted; | ||
425 | }; | ||
426 | |||
377 | struct em28xx_board { | 427 | struct em28xx_board { |
378 | char *name; | 428 | char *name; |
379 | int vchannels; | 429 | int vchannels; |
@@ -395,7 +445,6 @@ struct em28xx_board { | |||
395 | unsigned int mts_firmware:1; | 445 | unsigned int mts_firmware:1; |
396 | unsigned int max_range_640_480:1; | 446 | unsigned int max_range_640_480:1; |
397 | unsigned int has_dvb:1; | 447 | unsigned int has_dvb:1; |
398 | unsigned int has_snapshot_button:1; | ||
399 | unsigned int is_webcam:1; | 448 | unsigned int is_webcam:1; |
400 | unsigned int valid:1; | 449 | unsigned int valid:1; |
401 | unsigned int has_ir_i2c:1; | 450 | unsigned int has_ir_i2c:1; |
@@ -410,6 +459,12 @@ struct em28xx_board { | |||
410 | struct em28xx_input input[MAX_EM28XX_INPUT]; | 459 | struct em28xx_input input[MAX_EM28XX_INPUT]; |
411 | struct em28xx_input radio; | 460 | struct em28xx_input radio; |
412 | char *ir_codes; | 461 | char *ir_codes; |
462 | |||
463 | /* LEDs that need to be controlled explicitly */ | ||
464 | struct em28xx_led *leds; | ||
465 | |||
466 | /* Buttons */ | ||
467 | struct em28xx_button *buttons; | ||
413 | }; | 468 | }; |
414 | 469 | ||
415 | struct em28xx_eeprom { | 470 | struct em28xx_eeprom { |
@@ -426,15 +481,13 @@ struct em28xx_eeprom { | |||
426 | u8 string_idx_table; | 481 | u8 string_idx_table; |
427 | }; | 482 | }; |
428 | 483 | ||
429 | #define EM28XX_AUDIO_BUFS 5 | ||
430 | #define EM28XX_NUM_AUDIO_PACKETS 64 | ||
431 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ | ||
432 | #define EM28XX_CAPTURE_STREAM_EN 1 | 484 | #define EM28XX_CAPTURE_STREAM_EN 1 |
433 | 485 | ||
434 | /* em28xx extensions */ | 486 | /* em28xx extensions */ |
435 | #define EM28XX_AUDIO 0x10 | 487 | #define EM28XX_AUDIO 0x10 |
436 | #define EM28XX_DVB 0x20 | 488 | #define EM28XX_DVB 0x20 |
437 | #define EM28XX_RC 0x30 | 489 | #define EM28XX_RC 0x30 |
490 | #define EM28XX_V4L2 0x40 | ||
438 | 491 | ||
439 | /* em28xx resource types (used for res_get/res_lock etc */ | 492 | /* em28xx resource types (used for res_get/res_lock etc */ |
440 | #define EM28XX_RESOURCE_VIDEO 0x01 | 493 | #define EM28XX_RESOURCE_VIDEO 0x01 |
@@ -442,8 +495,9 @@ struct em28xx_eeprom { | |||
442 | 495 | ||
443 | struct em28xx_audio { | 496 | struct em28xx_audio { |
444 | char name[50]; | 497 | char name[50]; |
445 | char *transfer_buffer[EM28XX_AUDIO_BUFS]; | 498 | unsigned num_urb; |
446 | struct urb *urb[EM28XX_AUDIO_BUFS]; | 499 | char **transfer_buffer; |
500 | struct urb **urb; | ||
447 | struct usb_device *udev; | 501 | struct usb_device *udev; |
448 | unsigned int capture_transfer_done; | 502 | unsigned int capture_transfer_done; |
449 | struct snd_pcm_substream *capture_pcm_substream; | 503 | struct snd_pcm_substream *capture_pcm_substream; |
@@ -451,6 +505,8 @@ struct em28xx_audio { | |||
451 | unsigned int hwptr_done_capture; | 505 | unsigned int hwptr_done_capture; |
452 | struct snd_card *sndcard; | 506 | struct snd_card *sndcard; |
453 | 507 | ||
508 | size_t period; | ||
509 | |||
454 | int users; | 510 | int users; |
455 | spinlock_t slock; | 511 | spinlock_t slock; |
456 | }; | 512 | }; |
@@ -485,11 +541,13 @@ struct em28xx { | |||
485 | int model; /* index in the device_data struct */ | 541 | int model; /* index in the device_data struct */ |
486 | int devno; /* marks the number of this device */ | 542 | int devno; /* marks the number of this device */ |
487 | enum em28xx_chip_id chip_id; | 543 | enum em28xx_chip_id chip_id; |
488 | unsigned int is_em25xx:1; /* em25xx/em276x/7x/8x family bridge */ | ||
489 | 544 | ||
545 | unsigned int is_em25xx:1; /* em25xx/em276x/7x/8x family bridge */ | ||
490 | unsigned char disconnected:1; /* device has been diconnected */ | 546 | unsigned char disconnected:1; /* device has been diconnected */ |
491 | 547 | unsigned int has_video:1; | |
492 | int audio_ifnum; | 548 | unsigned int has_audio_class:1; |
549 | unsigned int has_alsa_audio:1; | ||
550 | unsigned int is_audio_only:1; | ||
493 | 551 | ||
494 | struct v4l2_device v4l2_dev; | 552 | struct v4l2_device v4l2_dev; |
495 | struct v4l2_ctrl_handler ctrl_handler; | 553 | struct v4l2_ctrl_handler ctrl_handler; |
@@ -507,10 +565,6 @@ struct em28xx { | |||
507 | /* Vinmode/Vinctl used at the driver */ | 565 | /* Vinmode/Vinctl used at the driver */ |
508 | int vinmode, vinctl; | 566 | int vinmode, vinctl; |
509 | 567 | ||
510 | unsigned int has_audio_class:1; | ||
511 | unsigned int has_alsa_audio:1; | ||
512 | unsigned int is_audio_only:1; | ||
513 | |||
514 | /* Controls audio streaming */ | 568 | /* Controls audio streaming */ |
515 | struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */ | 569 | struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */ |
516 | atomic_t stream_started; /* stream should be running if true */ | 570 | atomic_t stream_started; /* stream should be running if true */ |
@@ -608,6 +662,7 @@ struct em28xx { | |||
608 | 662 | ||
609 | /* usb transfer */ | 663 | /* usb transfer */ |
610 | struct usb_device *udev; /* the usb device */ | 664 | struct usb_device *udev; /* the usb device */ |
665 | u8 ifnum; /* number of the assigned usb interface */ | ||
611 | u8 analog_ep_isoc; /* address of isoc endpoint for analog */ | 666 | u8 analog_ep_isoc; /* address of isoc endpoint for analog */ |
612 | u8 analog_ep_bulk; /* address of bulk endpoint for analog */ | 667 | u8 analog_ep_bulk; /* address of bulk endpoint for analog */ |
613 | u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */ | 668 | u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */ |
@@ -639,10 +694,15 @@ struct em28xx { | |||
639 | 694 | ||
640 | enum em28xx_mode mode; | 695 | enum em28xx_mode mode; |
641 | 696 | ||
642 | /* Snapshot button */ | 697 | /* Button state polling */ |
698 | struct delayed_work buttons_query_work; | ||
699 | u8 button_polling_addresses[EM28XX_NUM_BUTTON_ADDRESSES_MAX]; | ||
700 | u8 button_polling_last_values[EM28XX_NUM_BUTTON_ADDRESSES_MAX]; | ||
701 | u8 num_button_polling_addresses; | ||
702 | u16 button_polling_interval; /* [ms] */ | ||
703 | /* Snapshot button input device */ | ||
643 | char snapshot_button_path[30]; /* path of the input dev */ | 704 | char snapshot_button_path[30]; /* path of the input dev */ |
644 | struct input_dev *sbutton_input_dev; | 705 | struct input_dev *sbutton_input_dev; |
645 | struct delayed_work sbutton_query_work; | ||
646 | 706 | ||
647 | struct em28xx_dvb *dvb; | 707 | struct em28xx_dvb *dvb; |
648 | }; | 708 | }; |
@@ -672,6 +732,7 @@ int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); | |||
672 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); | 732 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); |
673 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | 733 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, |
674 | u8 bitmask); | 734 | u8 bitmask); |
735 | int em28xx_toggle_reg_bits(struct em28xx *dev, u16 reg, u8 bitmask); | ||
675 | 736 | ||
676 | int em28xx_read_ac97(struct em28xx *dev, u8 reg); | 737 | int em28xx_read_ac97(struct em28xx *dev, u8 reg); |
677 | int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); | 738 | int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); |
@@ -679,12 +740,9 @@ int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); | |||
679 | int em28xx_audio_analog_set(struct em28xx *dev); | 740 | int em28xx_audio_analog_set(struct em28xx *dev); |
680 | int em28xx_audio_setup(struct em28xx *dev); | 741 | int em28xx_audio_setup(struct em28xx *dev); |
681 | 742 | ||
682 | int em28xx_colorlevels_set_default(struct em28xx *dev); | 743 | const struct em28xx_led *em28xx_find_led(struct em28xx *dev, |
744 | enum em28xx_led_role role); | ||
683 | int em28xx_capture_start(struct em28xx *dev, int start); | 745 | int em28xx_capture_start(struct em28xx *dev, int start); |
684 | int em28xx_vbi_supported(struct em28xx *dev); | ||
685 | int em28xx_set_outfmt(struct em28xx *dev); | ||
686 | int em28xx_resolution_set(struct em28xx *dev); | ||
687 | int em28xx_set_alternate(struct em28xx *dev); | ||
688 | int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, | 746 | int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, |
689 | int num_bufs, int max_pkt_size, int packet_multiplier); | 747 | int num_bufs, int max_pkt_size, int packet_multiplier); |
690 | int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, | 748 | int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, |
@@ -696,30 +754,18 @@ void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode); | |||
696 | void em28xx_stop_urbs(struct em28xx *dev); | 754 | void em28xx_stop_urbs(struct em28xx *dev); |
697 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); | 755 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); |
698 | int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); | 756 | int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); |
699 | void em28xx_wake_i2c(struct em28xx *dev); | ||
700 | int em28xx_register_extension(struct em28xx_ops *dev); | 757 | int em28xx_register_extension(struct em28xx_ops *dev); |
701 | void em28xx_unregister_extension(struct em28xx_ops *dev); | 758 | void em28xx_unregister_extension(struct em28xx_ops *dev); |
702 | void em28xx_init_extension(struct em28xx *dev); | 759 | void em28xx_init_extension(struct em28xx *dev); |
703 | void em28xx_close_extension(struct em28xx *dev); | 760 | void em28xx_close_extension(struct em28xx *dev); |
704 | 761 | ||
705 | /* Provided by em28xx-video.c */ | ||
706 | int em28xx_vb2_setup(struct em28xx *dev); | ||
707 | int em28xx_register_analog_devices(struct em28xx *dev); | ||
708 | void em28xx_release_analog_resources(struct em28xx *dev); | ||
709 | void em28xx_ctrl_notify(struct v4l2_ctrl *ctrl, void *priv); | ||
710 | int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count); | ||
711 | int em28xx_stop_vbi_streaming(struct vb2_queue *vq); | ||
712 | extern const struct v4l2_ctrl_ops em28xx_ctrl_ops; | ||
713 | |||
714 | /* Provided by em28xx-cards.c */ | 762 | /* Provided by em28xx-cards.c */ |
715 | extern struct em28xx_board em28xx_boards[]; | 763 | extern struct em28xx_board em28xx_boards[]; |
716 | extern struct usb_device_id em28xx_id_table[]; | 764 | extern struct usb_device_id em28xx_id_table[]; |
717 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg); | 765 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg); |
766 | void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl); | ||
718 | void em28xx_release_resources(struct em28xx *dev); | 767 | void em28xx_release_resources(struct em28xx *dev); |
719 | 768 | ||
720 | /* Provided by em28xx-vbi.c */ | ||
721 | extern struct vb2_ops em28xx_vbi_qops; | ||
722 | |||
723 | /* Provided by em28xx-camera.c */ | 769 | /* Provided by em28xx-camera.c */ |
724 | int em28xx_detect_sensor(struct em28xx *dev); | 770 | int em28xx_detect_sensor(struct em28xx *dev); |
725 | int em28xx_init_camera(struct em28xx *dev); | 771 | int em28xx_init_camera(struct em28xx *dev); |