V4L/DVB: em28xx: add em286x/tvp5150 reference design
[safe/jmp/linux-2.6] / drivers / media / video / em28xx / em28xx.h
index 217f948..eec1291 100644 (file)
@@ -68,6 +68,7 @@
 #define EM2820_BOARD_HERCULES_SMART_TV_USB2      26
 #define EM2820_BOARD_PINNACLE_USB_2_FM1216ME     27
 #define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE 28
+#define EM2860_BOARD_TVP5150_REFERENCE_DESIGN    29
 #define EM2820_BOARD_VIDEOLOGY_20K14XUSB         30
 #define EM2821_BOARD_USBGEAR_VD204               31
 #define EM2821_BOARD_SUPERCOMP_USB_2             32
 #define EM2882_BOARD_EVGA_INDTUBE                70
 #define EM2820_BOARD_SILVERCREST_WEBCAM           71
 #define EM2861_BOARD_GADMEI_UTV330PLUS           72
+#define EM2870_BOARD_REDDO_DVB_C_USB_BOX          73
+#define EM2800_BOARD_VC211A                      74
+#define EM2882_BOARD_DIKOM_DK300                 75
 
 /* Limits minimum and default number of buffers */
 #define EM28XX_MIN_BUF 4
 #define EM28XX_NUM_BUFS 5
 
 /* number of packets for each buffer
-   windows requests only 40 packets .. so we better do the same
+   windows requests only 64 packets .. so we better do the same
    this is what I found out for all alternate numbers there!
  */
-#define EM28XX_NUM_PACKETS 40
-
-/* default alternate; 0 means choose the best */
-#define EM28XX_PINOUT 0
+#define EM28XX_NUM_PACKETS 64
 
 #define EM28XX_INTERLACED_DEFAULT 1
 
@@ -214,7 +215,8 @@ struct em28xx_usb_isoc_ctl {
        int                             tmp_buf_len;
 
                /* Stores already requested buffers */
-       struct em28xx_buffer            *buf;
+       struct em28xx_buffer            *vid_buf;
+       struct em28xx_buffer            *vbi_buf;
 
                /* Stores the number of received fields */
        int                             nfields;
@@ -399,6 +401,7 @@ struct em28xx_board {
        unsigned int has_snapshot_button:1;
        unsigned int is_webcam:1;
        unsigned int valid:1;
+       unsigned int has_ir_i2c:1;
 
        unsigned char xclk, i2c_speed;
        unsigned char radio_addr;
@@ -442,6 +445,10 @@ enum em28xx_dev_state {
 #define EM28XX_AUDIO   0x10
 #define EM28XX_DVB     0x20
 
+/* em28xx resource types (used for res_get/res_lock etc */
+#define EM28XX_RESOURCE_VIDEO 0x01
+#define EM28XX_RESOURCE_VBI   0x02
+
 struct em28xx_audio {
        char name[50];
        char *transfer_buffer[EM28XX_AUDIO_BUFS];
@@ -462,10 +469,11 @@ struct em28xx;
 
 struct em28xx_fh {
        struct em28xx *dev;
-       unsigned int  stream_on:1;      /* Locks streams */
        int           radio;
+       unsigned int  resources;
 
        struct videobuf_queue        vb_vidq;
+       struct videobuf_queue        vb_vbiq;
 
        enum v4l2_buf_type           type;
 };
@@ -492,7 +500,6 @@ struct em28xx {
        /* Vinmode/Vinctl used at the driver */
        int vinmode, vinctl;
 
-       unsigned int stream_on:1;       /* Locks streams */
        unsigned int has_audio_class:1;
        unsigned int has_alsa_audio:1;
 
@@ -543,6 +550,13 @@ struct em28xx {
        enum em28xx_dev_state state;
        enum em28xx_io_method io;
 
+       /* vbi related state tracking */
+       int capture_type;
+       int vbi_read;
+       unsigned char cur_field;
+       unsigned int vbi_width;
+       unsigned int vbi_height; /* lines per field */
+
        struct work_struct         request_module_wk;
 
        /* locks */
@@ -554,10 +568,14 @@ struct em28xx {
        struct video_device *vbi_dev;
        struct video_device *radio_dev;
 
+       /* resources in use */
+       unsigned int resources;
+
        unsigned char eedata[256];
 
        /* Isoc control struct */
        struct em28xx_dmaqueue vidq;
+       struct em28xx_dmaqueue vbiq;
        struct em28xx_usb_isoc_ctl isoc_ctl;
        spinlock_t slock;
 
@@ -596,6 +614,9 @@ struct em28xx {
        struct delayed_work sbutton_query_work;
 
        struct em28xx_dvb *dvb;
+
+       /* I2C keyboard data */
+       struct IR_i2c_init_data init_data;
 };
 
 struct em28xx_ops {
@@ -625,6 +646,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
                          int len);
 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
 int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val);
+int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
+                                u8 bitmask);
 
 int em28xx_read_ac97(struct em28xx *dev, u8 reg);
 int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val);
@@ -634,6 +657,7 @@ int em28xx_audio_setup(struct em28xx *dev);
 
 int em28xx_colorlevels_set_default(struct em28xx *dev);
 int em28xx_capture_start(struct em28xx *dev, int start);
+int em28xx_vbi_supported(struct em28xx *dev);
 int em28xx_set_outfmt(struct em28xx *dev);
 int em28xx_resolution_set(struct em28xx *dev);
 int em28xx_set_alternate(struct em28xx *dev);
@@ -647,9 +671,6 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);
 void em28xx_wake_i2c(struct em28xx *dev);
 void em28xx_remove_from_devlist(struct em28xx *dev);
 void em28xx_add_into_devlist(struct em28xx *dev);
-struct em28xx *em28xx_get_device(int minor,
-                                enum v4l2_buf_type *fh_type,
-                                int *has_radio);
 int em28xx_register_extension(struct em28xx_ops *dev);
 void em28xx_unregister_extension(struct em28xx_ops *dev);
 void em28xx_init_extension(struct em28xx *dev);
@@ -675,12 +696,17 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
 int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
 int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
                                     u32 *ir_raw);
+int em28xx_get_key_winfast_usbii_deluxe(struct IR_i2c *ir, u32 *ir_key,
+                                    u32 *ir_raw);
 void em28xx_register_snapshot_button(struct em28xx *dev);
 void em28xx_deregister_snapshot_button(struct em28xx *dev);
 
 int em28xx_ir_init(struct em28xx *dev);
 int em28xx_ir_fini(struct em28xx *dev);
 
+/* Provided by em28xx-vbi.c */
+extern struct videobuf_queue_ops em28xx_vbi_qops;
+
 /* printk macros */
 
 #define em28xx_err(fmt, arg...) do {\
@@ -775,7 +801,7 @@ static inline unsigned int norm_maxw(struct em28xx *dev)
        if (dev->board.is_webcam)
                return dev->sensor_xres;
 
-       if (dev->board.max_range_640_480)
+       if (dev->board.max_range_640_480 || dev->board.is_em2800)
                return 640;
 
        return 720;