V4L/DVB (7014): cx23885: dprintk macro cleanup
[safe/jmp/linux-2.6] / drivers / media / video / cx23885 / cx23885.h
index f58ab86..390f933 100644 (file)
@@ -27,8 +27,8 @@
 #include <media/v4l2-common.h>
 #include <media/tuner.h>
 #include <media/tveeprom.h>
-#include <media/video-buf.h>
-#include <media/video-buf-dvb.h>
+#include <media/videobuf-dma-sg.h>
+#include <media/videobuf-dvb.h>
 
 #include "btcx-risc.h"
 #include "cx23885-reg.h"
 #include <linux/version.h>
 #include <linux/mutex.h>
 
-#define CX88_VERSION_CODE KERNEL_VERSION(0,0,6)
+#define CX23885_VERSION_CODE KERNEL_VERSION(0,0,1)
 
 #define UNSET (-1U)
 
 #define CX23885_MAXBOARDS 8
 
-#define SRAM 0
-
 /* Max number of inputs by card */
 #define MAX_CX23885_INPUT 8
-
-//#define SHADOW_MAX 3
+#define INPUT(nr) (&cx23885_boards[dev->board].input[nr])
+#define RESOURCE_OVERLAY       1
+#define RESOURCE_VIDEO         2
+#define RESOURCE_VBI           4
 
 #define BUFFER_TIMEOUT     (HZ)  /* 0.5 seconds */
 
 #define CX23885_BOARD_UNKNOWN                  0
 #define CX23885_BOARD_HAUPPAUGE_HVR1800lp      1
 #define CX23885_BOARD_HAUPPAUGE_HVR1800        2
+#define CX23885_BOARD_HAUPPAUGE_HVR1250        3
+#define CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP   4
+#define CX23885_BOARD_HAUPPAUGE_HVR1500Q       5
+#define CX23885_BOARD_HAUPPAUGE_HVR1500        6
+
+/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */
+#define CX23885_NORMS (\
+       V4L2_STD_NTSC_M |  V4L2_STD_NTSC_M_JP |  V4L2_STD_NTSC_443 | \
+       V4L2_STD_PAL_BG |  V4L2_STD_PAL_DK    |  V4L2_STD_PAL_I    | \
+       V4L2_STD_PAL_M  |  V4L2_STD_PAL_N     |  V4L2_STD_PAL_Nc   | \
+       V4L2_STD_PAL_60 |  V4L2_STD_SECAM_L   |  V4L2_STD_SECAM_DK)
+
+struct cx23885_fmt {
+       char  *name;
+       u32   fourcc;          /* v4l2 format id */
+       int   depth;
+       int   flags;
+       u32   cxformat;
+};
+
+struct cx23885_ctrl {
+       struct v4l2_queryctrl v;
+       u32                   off;
+       u32                   reg;
+       u32                   mask;
+       u32                   shift;
+};
+
+struct cx23885_tvnorm {
+       char            *name;
+       v4l2_std_id     id;
+       u32             cxiformat;
+       u32             cxoformat;
+};
+
+struct cx23885_fh {
+       struct cx23885_dev         *dev;
+       enum v4l2_buf_type         type;
+       int                        radio;
+       u32                        resources;
+
+       /* video overlay */
+       struct v4l2_window         win;
+       struct v4l2_clip           *clips;
+       unsigned int               nclips;
+
+       /* video capture */
+       struct cx23885_fmt         *fmt;
+       unsigned int               width, height;
+
+       /* vbi capture */
+       struct videobuf_queue      vidq;
+       struct videobuf_queue      vbiq;
+
+       /* MPEG Encoder specifics ONLY */
+       struct videobuf_queue      mpegq;
+       atomic_t                   v4l_reading;
+};
 
 enum cx23885_itype {
        CX23885_VMUX_COMPOSITE1 = 1,
@@ -69,12 +127,9 @@ enum cx23885_itype {
        CX23885_RADIO,
 };
 
-struct cx23885_fmt {
-       char  *name;
-       u32   fourcc;          /* v4l2 format id */
-       int   depth;
-       int   flags;
-       u32   cxformat;
+enum cx23885_src_sel_type {
+       CX23885_SRC_SEL_EXT_656_VIDEO = 0,
+       CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO
 };
 
 /* buffer for one video frame */
@@ -95,17 +150,30 @@ struct cx23885_input {
        u32             gpio0, gpio1, gpio2, gpio3;
 };
 
+typedef enum {
+       CX23885_MPEG_UNDEFINED = 0,
+       CX23885_MPEG_DVB,
+       CX23885_ANALOG_VIDEO,
+} port_t;
+
 struct cx23885_board {
        char                    *name;
-       enum {
-               CX23885_MPEG_UNDEFINED = 0,
-               CX23885_MPEG_DVB
-       } portc;
-       enum {
-               CX23885_BRIDGE_UNDEFINED = 0,
-               CX23885_BRIDGE_885 = 885,
-               CX23885_BRIDGE_887 = 887,
-       } bridge;
+       port_t                  porta, portb, portc;
+       unsigned int            tuner_type;
+       unsigned int            radio_type;
+       unsigned char           tuner_addr;
+       unsigned char           radio_addr;
+
+       /* Vendors can and do run the PCIe bridge at different
+        * clock rates, driven physically by crystals on the PCBs.
+        * The core has to accomodate this. This allows the user
+        * to add new boards with new frequencys. The value is
+        * expressed in Hz.
+        *
+        * The core framework will default this value based on
+        * current designs, but it can vary.
+        */
+       u32                     clk_freq;
        struct cx23885_input    input[MAX_CX23885_INPUT];
 };
 
@@ -174,6 +242,8 @@ struct cx23885_tsport {
        u32                        reg_vld_misc;
        u32                        reg_ts_clk_en;
        u32                        reg_ts_int_msk;
+       u32                        reg_ts_int_stat;
+       u32                        reg_src_sel;
 
        /* Default register vals */
        int                        pci_irqmask;
@@ -181,6 +251,7 @@ struct cx23885_tsport {
        u32                        ts_int_msk_val;
        u32                        gen_ctrl_val;
        u32                        ts_clk_en_val;
+       u32                        src_sel_val;
 };
 
 struct cx23885_dev {
@@ -193,10 +264,14 @@ struct cx23885_dev {
        int                        pci_bus, pci_slot;
        u32                        __iomem *lmmio;
        u8                         __iomem *bmmio;
-       //u32                        shadow[SHADOW_MAX];
        int                        pci_irqmask;
+       int                        hwrevision;
+
+       /* This valud is board specific and is used to configure the
+        * AV core so we see nice clean and stable video and audio. */
+       u32                        clk_freq;
 
-       /* I2C adapters: Master 1 and 2 (External) and Master 3 (Internal only) */
+       /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
        struct cx23885_i2c         i2c_bus[3];
 
        int                        nr;
@@ -206,12 +281,41 @@ struct cx23885_dev {
        unsigned int               board;
        char                       name[32];
 
-       struct cx23885_tsport      ts2;
+       struct cx23885_tsport      ts1, ts2;
 
        /* sram configuration */
        struct sram_channel        *sram_channels;
+
+       enum {
+               CX23885_BRIDGE_UNDEFINED = 0,
+               CX23885_BRIDGE_885 = 885,
+               CX23885_BRIDGE_887 = 887,
+       } bridge;
+
+       /* Analog video */
+       u32                        resources;
+       unsigned int               input;
+       u32                        tvaudio;
+       v4l2_std_id                tvnorm;
+       unsigned int               tuner_type;
+       unsigned char              tuner_addr;
+       unsigned int               radio_type;
+       unsigned char              radio_addr;
+       unsigned int               has_radio;
+
+       /* V4l */
+       u32                        freq;
+       struct video_device        *video_dev;
+       struct video_device        *vbi_dev;
+       struct video_device        *radio_dev;
+
+       struct cx23885_dmaqueue    vidq;
+       struct cx23885_dmaqueue    vbiq;
+       spinlock_t                 slock;
 };
 
+extern struct list_head cx23885_devlist;
+
 #define SRAM_CH01  0 /* Video A */
 #define SRAM_CH02  1 /* VBI A */
 #define SRAM_CH03  2 /* Video B */
@@ -254,14 +358,35 @@ struct sram_channel {
 #define cx_set(reg,bit)          cx_andor((reg),(bit),(bit))
 #define cx_clear(reg,bit)        cx_andor((reg),(bit),0)
 
+/* ----------------------------------------------------------- */
+/* cx23885-core.c                                              */
 
 extern int cx23885_sram_channel_setup(struct cx23885_dev *dev,
        struct sram_channel *ch,
        unsigned int bpl, u32 risc);
 
-/* ----------------------------------------------------------- */
-/* cx23885-cards.c                                                */
+extern void cx23885_sram_channel_dump(struct cx23885_dev *dev,
+       struct sram_channel *ch);
 
+extern int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
+       u32 reg, u32 mask, u32 value);
+
+extern int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
+       struct scatterlist *sglist,
+       unsigned int top_offset, unsigned int bottom_offset,
+       unsigned int bpl, unsigned int padding, unsigned int lines);
+
+void cx23885_cancel_buffers(struct cx23885_tsport *port);
+
+extern int cx23885_restart_queue(struct cx23885_tsport *port,
+                               struct cx23885_dmaqueue *q);
+
+extern void cx23885_wakeup(struct cx23885_tsport *port,
+                          struct cx23885_dmaqueue *q, u32 count);
+
+
+/* ----------------------------------------------------------- */
+/* cx23885-cards.c                                             */
 extern struct cx23885_board cx23885_boards[];
 extern const unsigned int cx23885_bcount;
 
@@ -269,23 +394,61 @@ extern struct cx23885_subid cx23885_subids[];
 extern const unsigned int cx23885_idcount;
 
 extern void cx23885_card_list(struct cx23885_dev *dev);
+extern int  cx23885_ir_init(struct cx23885_dev *dev);
+extern void cx23885_gpio_setup(struct cx23885_dev *dev);
 extern void cx23885_card_setup(struct cx23885_dev *dev);
 extern void cx23885_card_setup_pre_i2c(struct cx23885_dev *dev);
 
 extern int cx23885_dvb_register(struct cx23885_tsport *port);
 extern int cx23885_dvb_unregister(struct cx23885_tsport *port);
 
-extern int cx23885_buf_prepare(struct videobuf_queue *q, struct cx23885_tsport *port,
-                       struct cx23885_buffer *buf, enum v4l2_field field);
+extern int cx23885_buf_prepare(struct videobuf_queue *q,
+                              struct cx23885_tsport *port,
+                              struct cx23885_buffer *buf,
+                              enum v4l2_field field);
+extern void cx23885_buf_queue(struct cx23885_tsport *port,
+                             struct cx23885_buffer *buf);
+extern void cx23885_free_buffer(struct videobuf_queue *q,
+                               struct cx23885_buffer *buf);
 
-extern void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf);
-extern void cx23885_free_buffer(struct videobuf_queue *q, struct cx23885_buffer *buf);
+/* ----------------------------------------------------------- */
+/* cx23885-video.c                                             */
+/* Video */
+extern int cx23885_video_register(struct cx23885_dev *dev);
+extern void cx23885_video_unregister(struct cx23885_dev *dev);
+extern int cx23885_video_irq(struct cx23885_dev *dev, u32 status);
 
 /* ----------------------------------------------------------- */
+/* cx23885-vbi.c                                               */
+extern int cx23885_vbi_fmt(struct file *file, void *priv,
+       struct v4l2_format *f);
+extern void cx23885_vbi_timeout(unsigned long data);
+extern struct videobuf_queue_ops cx23885_vbi_qops;
+
 /* cx23885-i2c.c                                                */
 extern int cx23885_i2c_register(struct cx23885_i2c *bus);
 extern int cx23885_i2c_unregister(struct cx23885_i2c *bus);
-extern void cx23885_call_i2c_clients(struct cx23885_i2c *bus, unsigned int cmd, void *arg);
+extern void cx23885_call_i2c_clients(struct cx23885_i2c *bus, unsigned int cmd,
+                                    void *arg);
+
+/* ----------------------------------------------------------- */
+/* tv norms                                                    */
+
+static inline unsigned int norm_maxw(v4l2_std_id norm)
+{
+       return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768;
+}
+
+static inline unsigned int norm_maxh(v4l2_std_id norm)
+{
+       return (norm & V4L2_STD_625_50) ? 576 : 480;
+}
+
+static inline unsigned int norm_swidth(v4l2_std_id norm)
+{
+       return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922;
+}
+
 
 /*
  * Local variables: