Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / media / video / cx88 / cx88.h
index 88eaaab..326a25f 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: cx88.h,v 1.56 2005/03/04 09:12:23 kraxel Exp $
  *
  * v4l2 device driver for cx2388x based TV cards
  *
 #include <linux/pci.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
-#include <linux/videodev.h>
+#include <linux/videodev2.h>
 #include <linux/kdev_t.h>
 
 #include <media/tuner.h>
 #include <media/tveeprom.h>
-#include <media/audiochip.h>
 #include <media/video-buf.h>
 #include <media/video-buf-dvb.h>
 
@@ -36,7 +34,8 @@
 #include "cx88-reg.h"
 
 #include <linux/version.h>
-#define CX88_VERSION_CODE KERNEL_VERSION(0,0,4)
+#include <linux/mutex.h>
+#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5)
 
 #ifndef TRUE
 # define TRUE (1==1)
 
 #define CX88_MAXBOARDS 8
 
+/* Max number of inputs by card */
+#define MAX_CX88_INPUT 8
+
 /* ----------------------------------------------------------- */
 /* defines and enums                                           */
 
-#define V4L2_I2C_CLIENTS 1
-
 #define FORMAT_FLAGS_PACKED       0x01
 #define FORMAT_FLAGS_PLANAR       0x02
 
 /* need "shadow" registers for some write-only ones ... */
 #define SHADOW_AUD_VOL_CTL           1
 #define SHADOW_AUD_BAL_CTL           2
-#define SHADOW_MAX                   2
+#define SHADOW_MAX                   3
+
+/* FM Radio deemphasis type */
+enum cx88_deemph_type {
+       FM_NO_DEEMPH = 0,
+       FM_DEEMPH_50,
+       FM_DEEMPH_75
+};
 
 /* ----------------------------------------------------------- */
 /* tv norms                                                    */
@@ -77,9 +84,9 @@ struct cx88_tvnorm {
 static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
 {
        return (norm->id & V4L2_STD_625_50) ? 768 : 640;
-//     return (norm->id & V4L2_STD_625_50) ? 720 : 640;
 }
 
+
 static unsigned int inline norm_maxh(struct cx88_tvnorm *norm)
 {
        return (norm->id & V4L2_STD_625_50) ? 576 : 480;
@@ -141,7 +148,7 @@ extern struct sram_channel cx88_sram_channels[];
 #define CX88_BOARD_PIXELVIEW                3
 #define CX88_BOARD_ATI_WONDER_PRO           4
 #define CX88_BOARD_WINFAST2000XP_EXPERT     5
-#define CX88_BOARD_AVERTV_303               6
+#define CX88_BOARD_AVERTV_STUDIO_303        6
 #define CX88_BOARD_MSI_TVANYWHERE_MASTER    7
 #define CX88_BOARD_WINFAST_DV2000           8
 #define CX88_BOARD_LEADTEK_PVR2000          9
@@ -152,7 +159,7 @@ extern struct sram_channel cx88_sram_channels[];
 #define CX88_BOARD_KWORLD_DVB_T            14
 #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15
 #define CX88_BOARD_KWORLD_LTV883           16
-#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD 17
+#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q  17
 #define CX88_BOARD_HAUPPAUGE_DVB_T1        18
 #define CX88_BOARD_CONEXANT_DVB_T1         19
 #define CX88_BOARD_PROVIDEO_PV259          20
@@ -160,8 +167,28 @@ extern struct sram_channel cx88_sram_channels[];
 #define CX88_BOARD_PCHDTV_HD3000           22
 #define CX88_BOARD_DNTV_LIVE_DVB_T         23
 #define CX88_BOARD_HAUPPAUGE_ROSLYN        24
-#define CX88_BOARD_DIGITALLOGIC_MEC           25
+#define CX88_BOARD_DIGITALLOGIC_MEC        25
 #define CX88_BOARD_IODATA_GVBCTV7E         26
+#define CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO 27
+#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T  28
+#define CX88_BOARD_ADSTECH_DVB_T_PCI          29
+#define CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1  30
+#define CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD 31
+#define CX88_BOARD_AVERMEDIA_ULTRATV_MC_550 32
+#define CX88_BOARD_KWORLD_VSTREAM_EXPERT_DVD 33
+#define CX88_BOARD_ATI_HDTVWONDER          34
+#define CX88_BOARD_WINFAST_DTV1000         35
+#define CX88_BOARD_AVERTV_303              36
+#define CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1  37
+#define CX88_BOARD_HAUPPAUGE_NOVASE2_S1    38
+#define CX88_BOARD_KWORLD_DVBS_100         39
+#define CX88_BOARD_HAUPPAUGE_HVR1100       40
+#define CX88_BOARD_HAUPPAUGE_HVR1100LP     41
+#define CX88_BOARD_DNTV_LIVE_DVB_T_PRO     42
+#define CX88_BOARD_KWORLD_DVB_T_CX22702    43
+#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44
+#define CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT 45
+#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID 46
 
 enum cx88_itype {
        CX88_VMUX_COMPOSITE1 = 1,
@@ -185,11 +212,14 @@ struct cx88_input {
 struct cx88_board {
        char                    *name;
        unsigned int            tuner_type;
+       unsigned int            radio_type;
+       unsigned char           tuner_addr;
+       unsigned char           radio_addr;
        int                     tda9887_conf;
-       struct cx88_input       input[8];
+       struct cx88_input       input[MAX_CX88_INPUT];
        struct cx88_input       radio;
-       int                     blackbird:1;
-       int                     dvb:1;
+       unsigned int            blackbird:1;
+       unsigned int            dvb:1;
 };
 
 struct cx88_subid {
@@ -208,7 +238,6 @@ struct cx88_subid {
 #define RESOURCE_VBI           4
 
 #define BUFFER_TIMEOUT     (HZ/2)  /* 0.5 seconds */
-//#define BUFFER_TIMEOUT     (HZ*2)
 
 /* buffer for one video frame */
 struct cx88_buffer {
@@ -241,8 +270,8 @@ struct cx88_core {
        /* pci stuff */
        int                        pci_bus;
        int                        pci_slot;
-        u32                        __iomem *lmmio;
-        u8                         __iomem *bmmio;
+       u32                        __iomem *lmmio;
+       u8                         __iomem *bmmio;
        u32                        shadow[SHADOW_MAX];
        int                        pci_irqmask;
 
@@ -255,9 +284,15 @@ struct cx88_core {
        /* config info -- analog */
        unsigned int               board;
        unsigned int               tuner_type;
+       unsigned int               radio_type;
+       unsigned char              tuner_addr;
+       unsigned char              radio_addr;
        unsigned int               tda9887_conf;
        unsigned int               has_radio;
 
+       /* Supported V4L _STD_ tuner formats */
+       unsigned int               tuner_formats;
+
        /* config info -- dvb */
        struct dvb_pll_desc        *pll_desc;
        unsigned int               pll_addr;
@@ -270,9 +305,17 @@ struct cx88_core {
        u32                        audiomode_current;
        u32                        input;
        u32                        astat;
+       u32                        use_nicam;
 
        /* IR remote control state */
        struct cx88_IR             *ir;
+
+       struct mutex               lock;
+       /* various v4l controls */
+       u32                        freq;
+
+       /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
+       struct cx8802_dev          *dvbdev;
 };
 
 struct cx8800_dev;
@@ -308,8 +351,7 @@ struct cx8800_suspend_state {
 struct cx8800_dev {
        struct cx88_core           *core;
        struct list_head           devlist;
-        struct semaphore           lock;
-               spinlock_t                 slock;
+       spinlock_t                 slock;
 
        /* various device info */
        unsigned int               resources;
@@ -321,18 +363,12 @@ struct cx8800_dev {
        struct pci_dev             *pci;
        unsigned char              pci_rev,pci_lat;
 
-#if 0
-       /* video overlay */
-       struct v4l2_framebuffer    fbuf;
-       struct cx88_buffer         *screen;
-#endif
 
        /* capture queues */
        struct cx88_dmaqueue       vidq;
        struct cx88_dmaqueue       vbiq;
 
        /* various v4l controls */
-       u32                        freq;
 
        /* other global state info */
        struct cx8800_suspend_state state;
@@ -340,14 +376,8 @@ struct cx8800_dev {
 
 /* ----------------------------------------------------------- */
 /* function 1: audio/alsa stuff                                */
+/* =============> moved to cx88-alsa.c <====================== */
 
-struct cx8801_dev {
-       struct cx88_core           *core;
-
-       /* pci i/o */
-       struct pci_dev             *pci;
-       unsigned char              pci_rev,pci_lat;
-};
 
 /* ----------------------------------------------------------- */
 /* function 2: mpeg stuff                                      */
@@ -361,10 +391,17 @@ struct cx8802_suspend_state {
        int                        disabled;
 };
 
+/* TODO: move this to struct v4l2_mpeg_compression ? */
+struct blackbird_dnr {
+       u32                       mode;
+       u32                       type;
+       u32                       spatial;
+       u32                       temporal;
+};
+
 struct cx8802_dev {
        struct cx88_core           *core;
-        struct semaphore           lock;
-               spinlock_t                 slock;
+       spinlock_t                 slock;
 
        /* pci i/o */
        struct pci_dev             *pci;
@@ -390,8 +427,13 @@ struct cx8802_dev {
        void*                      fe_handle;
        int                        (*fe_release)(void *handle);
 
+       void                       *card_priv;
        /* for switching modulation types */
        unsigned char              ts_gen_cntrl;
+
+       /* mpeg params */
+       struct v4l2_mpeg_compression params;
+       struct blackbird_dnr       dnr_params;
 };
 
 /* ----------------------------------------------------------- */
@@ -420,11 +462,8 @@ struct cx8802_dev {
 /* ----------------------------------------------------------- */
 /* cx88-core.c                                                 */
 
-extern char *cx88_vid_irqs[32];
-extern char *cx88_mpeg_irqs[32];
 extern void cx88_print_irqbits(char *name, char *tag, char **strings,
                               u32 bits, u32 mask);
-extern void cx88_print_ioctl(char *name, unsigned int cmd);
 
 extern int cx88_core_irq(struct cx88_core *core, u32 status);
 extern void cx88_wakeup(struct cx88_core *core,
@@ -445,7 +484,7 @@ extern int
 cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
                  u32 reg, u32 mask, u32 value);
 extern void
-cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
+cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf);
 
 extern void cx88_risc_disasm(struct cx88_core *core,
                             struct btcx_riscmem *risc);
@@ -467,10 +506,19 @@ extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
 extern void cx88_core_put(struct cx88_core *core,
                          struct pci_dev *pci);
 
+extern int cx88_start_audio_dma(struct cx88_core *core);
+extern int cx88_stop_audio_dma(struct cx88_core *core);
+
+
 /* ----------------------------------------------------------- */
 /* cx88-vbi.c                                                  */
 
 void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f);
+/*
+int cx8800_start_vbi_dma(struct cx8800_dev    *dev,
+                        struct cx88_dmaqueue *q,
+                        struct cx88_buffer   *buf);
+*/
 int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
 int cx8800_restart_vbi_queue(struct cx8800_dev    *dev,
                             struct cx88_dmaqueue *q);
@@ -503,22 +551,20 @@ extern void cx88_card_setup(struct cx88_core *core);
 
 #define WW_NONE                 1
 #define WW_BTSC                 2
-#define WW_NICAM_I      3
-#define WW_NICAM_BGDKL  4
-#define WW_A1           5
-#define WW_A2_BG        6
-#define WW_A2_DK        7
-#define WW_A2_M                 8
-#define WW_EIAJ                 9
-#define WW_SYSTEM_L_AM 10
-#define WW_I2SPT       11
-#define WW_FM          12
+#define WW_BG           3
+#define WW_DK           4
+#define WW_I            5
+#define WW_L            6
+#define WW_EIAJ                 7
+#define WW_I2SPT        8
+#define WW_FM           9
 
 void cx88_set_tvaudio(struct cx88_core *core);
 void cx88_newstation(struct cx88_core *core);
 void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
 void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual);
 int cx88_audio_thread(void *data);
+int cx88_detect_nicam(struct cx88_core *core);
 
 /* ----------------------------------------------------------- */
 /* cx88-input.c                                                */
@@ -530,7 +576,8 @@ void cx88_ir_irq(struct cx88_core *core);
 /* ----------------------------------------------------------- */
 /* cx88-mpeg.c                                                 */
 
-int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
+int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev,
+                       struct cx88_buffer *buf, enum v4l2_field field);
 void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
 void cx8802_cancel_buffers(struct cx8802_dev *dev);
 
@@ -540,8 +587,25 @@ void cx8802_fini_common(struct cx8802_dev *dev);
 int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state);
 int cx8802_resume_common(struct pci_dev *pci_dev);
 
+/* ----------------------------------------------------------- */
+/* cx88-video.c                                                */
+extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
+                               struct cx88_core *core, unsigned int cmd,
+                               void *arg, v4l2_kioctl driver_ioctl);
+
+/* ----------------------------------------------------------- */
+/* cx88-blackbird.c                                            */
+extern int (*cx88_ioctl_hook)(struct inode *inode, struct file *file,
+                               unsigned int cmd, void *arg);
+extern unsigned int (*cx88_ioctl_translator)(unsigned int cmd);
+void blackbird_set_params(struct cx8802_dev *dev,
+                               struct v4l2_mpeg_compression *params);
+void blackbird_set_dnr_params(struct cx8802_dev *dev,
+                               struct blackbird_dnr* dnr_params);
+
 /*
  * Local variables:
  * c-basic-offset: 8
  * End:
+ * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
  */