V4L/DVB: Rework for support xc5000
[safe/jmp/linux-2.6] / drivers / staging / tm6000 / tm6000.h
index 623e85c..b49c139 100644 (file)
@@ -1,8 +1,11 @@
 /*
-   tm6000.h - driver for TM5600/TM6000 USB video capture devices
+   tm6000.h - driver for TM5600/TM6000/TM6010 USB video capture devices
 
    Copyright (C) 2006-2007 Mauro Carvalho Chehab <mchehab@infradead.org>
 
+   Copyright (C) 2007 Michel Ludwig <michel.ludwig@gmail.com>
+       - DVB-T support
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation version 2
 #include "tm6000-usb-isoc.h"
 #include <linux/i2c.h>
 #include <linux/mutex.h>
+#include <media/v4l2-device.h>
+
 
-#define TM6000_VERSION KERNEL_VERSION(0, 0, 1)
+#include <linux/dvb/frontend.h>
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dmxdev.h"
+
+#define TM6000_VERSION KERNEL_VERSION(0, 0, 2)
 
 /* Inputs */
-#define TM6000_INPUT_TV                0
-#define TM6000_INPUT_COMPOSITE 1
-#define TM6000_INPUT_SVIDEO    2
+
+enum tm6000_itype {
+       TM6000_INPUT_TV = 0,
+       TM6000_INPUT_COMPOSITE,
+       TM6000_INPUT_SVIDEO,
+};
+
+enum tm6000_devtype {
+       TM6000 = 0,
+       TM5600,
+       TM6010,
+};
 
 /* ------------------------------------------------------------------
        Basic structures
@@ -55,7 +74,6 @@ struct tm6000_buffer {
 struct tm6000_dmaqueue {
        struct list_head       active;
        struct list_head       queued;
-       struct timer_list      timeout;
 
        /* thread for generating video stream*/
        struct task_struct         *kthread;
@@ -85,12 +103,40 @@ enum tm6000_mode {
        TM6000_MODE_DIGITAL,
 };
 
+struct tm6000_gpio {
+       int             tuner_reset;
+       int             tuner_on;
+       int             demod_reset;
+       int             demod_on;
+       int             power_led;
+       int             dvb_led;
+       int             ir;
+};
+
 struct tm6000_capabilities {
        unsigned int    has_tuner:1;
        unsigned int    has_tda9874:1;
        unsigned int    has_dvb:1;
        unsigned int    has_zl10353:1;
        unsigned int    has_eeprom:1;
+       unsigned int    has_remote:1;
+};
+
+struct tm6000_dvb {
+       struct dvb_adapter      adapter;
+       struct dvb_demux        demux;
+       struct dvb_frontend     *frontend;
+       struct dmxdev           dmxdev;
+       unsigned int            streams;
+       struct urb              *bulk_urb;
+       struct mutex            mutex;
+};
+
+struct tm6000_endpoint {
+       struct usb_host_endpoint        *endp;
+       __u8                            bInterfaceNumber;
+       __u8                            bAlternateSetting;
+       unsigned                        maxsize;
 };
 
 struct tm6000_core {
@@ -98,7 +144,10 @@ struct tm6000_core {
        char                            name[30];       /* name (including minor) of the device */
        int                             model;          /* index in the device_data struct */
        int                             devno;          /* marks the number of this device */
-       v4l2_std_id                     norm;           /* Current norm */
+       enum tm6000_devtype             dev_type;       /* type of device */
+
+       v4l2_std_id                     norm;           /* Current norm */
+       int                             width,height;   /* Selected resolution */
 
        enum tm6000_core_state          state;
 
@@ -106,9 +155,15 @@ struct tm6000_core {
        struct tm6000_capabilities      caps;
 
        /* Tuner configuration */
-       int                             tuner_type;     /* type of the tuner */
-       int                             tuner_addr;     /* tuner address */
+       int                             tuner_type;             /* type of the tuner */
+       int                             tuner_addr;             /* tuner address */
+
+       struct tm6000_gpio              gpio;
+
+       /* Demodulator configuration */
+       int                             demod_addr;     /* demodulator address */
 
+       int                             audio_bitrate;
        /* i2c i/o */
        struct i2c_adapter              i2c_adap;
        struct i2c_client               i2c_client;
@@ -119,8 +174,9 @@ struct tm6000_core {
 
        /* various device info */
        unsigned int                    resources;
-       struct video_device             vfd;
+       struct video_device             *vfd;
        struct tm6000_dmaqueue          vidq;
+       struct v4l2_device              v4l2_dev;
 
        int                             input;
        int                             freq;
@@ -128,15 +184,16 @@ struct tm6000_core {
 
        enum tm6000_mode                mode;
 
+       /* DVB-T support */
+       struct tm6000_dvb               *dvb;
+
        /* locks */
        struct mutex                    lock;
 
        /* usb transfer */
        struct usb_device               *udev;          /* the usb device */
 
-       struct usb_host_endpoint        *bulk_in, *bulk_out, *isoc_in, *isoc_out;
-       unsigned int                    max_bulk_in, max_bulk_out;
-       unsigned int                    max_isoc_in, max_isoc_out;
+       struct tm6000_endpoint          bulk_in, bulk_out, isoc_in, isoc_out;
 
        /* scaler!=0 if scaler is active*/
        int                             scaler;
@@ -162,30 +219,41 @@ struct tm6000_fh {
                        V4L2_STD_PAL_M|V4L2_STD_PAL_60|V4L2_STD_NTSC_M| \
                        V4L2_STD_NTSC_M_JP|V4L2_STD_SECAM
 
+/* In tm6000-cards.c */
+
+int tm6000_tuner_callback (void *ptr, int component, int command, int arg);
+int tm6000_xc5000_callback (void *ptr, int component, int command, int arg);
+int tm6000_cards_setup(struct tm6000_core *dev);
+
 /* In tm6000-core.c */
-extern unsigned long tm6000_devused;
 
 int tm6000_read_write_usb (struct tm6000_core *dev, u8 reqtype, u8 req,
                           u16 value, u16 index, u8 *buf, u16 len);
 int tm6000_get_reg (struct tm6000_core *dev, u8 req, u16 value, u16 index);
+int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index);
+int tm6000_get_reg32(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_set_reg (struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_init (struct tm6000_core *dev);
-int tm6000_init_after_firmware (struct tm6000_core *dev);
 
 int tm6000_init_analog_mode (struct tm6000_core *dev);
-int tm6000_set_standard (struct tm6000_core *dev, v4l2_std_id *norm);
+int tm6000_init_digital_mode (struct tm6000_core *dev);
 int tm6000_set_audio_bitrate (struct tm6000_core *dev, int bitrate);
 
+int tm6000_dvb_register(struct tm6000_core *dev);
+void tm6000_dvb_unregister(struct tm6000_core *dev);
+
 int tm6000_v4l2_register(struct tm6000_core *dev);
 int tm6000_v4l2_unregister(struct tm6000_core *dev);
 int tm6000_v4l2_exit(void);
 void tm6000_set_fourcc_format(struct tm6000_core *dev);
 
+/* In tm6000-stds.c */
+void tm6000_get_std_res(struct tm6000_core *dev);
+int tm6000_set_standard (struct tm6000_core *dev, v4l2_std_id *norm);
+
 /* In tm6000-i2c.c */
 int tm6000_i2c_register(struct tm6000_core *dev);
 int tm6000_i2c_unregister(struct tm6000_core *dev);
-void tm6000_i2c_call_clients(struct tm6000_core *dev, unsigned int cmd,
-                            void *arg);
 
 /* In tm6000-queue.c */
 
@@ -207,6 +275,10 @@ unsigned int tm6000_v4l2_poll(struct file *file,
                              struct poll_table_struct *wait);
 int tm6000_queue_init(struct tm6000_core *dev);
 
+/* In tm6000-alsa.c */
+int tm6000_audio_init(struct tm6000_core *dev, int idx);
+
+
 /* Debug stuff */
 
 extern int tm6000_debug;