]> Pileus Git - ~andy/linux/blobdiff - drivers/media/video/em28xx/em28xx.h
V4L/DVB (9758): em28xx: replace some magic by register descriptions where known
[~andy/linux] / drivers / media / video / em28xx / em28xx.h
index 326208a9dd9ba216dab99ae66f6ee34d806df703..e41015d2e72202aa9ad3a5a918222c382c282adc 100644 (file)
@@ -97,6 +97,7 @@
 #define EM2882_BOARD_PINNACLE_HYBRID_PRO         56
 #define EM2883_BOARD_KWORLD_HYBRID_A316                  57
 #define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU     58
+#define EM2874_BOARD_PINNACLE_PCTV_80E           59
 
 /* Limits minimum and default number of buffers */
 #define EM28XX_MIN_BUF 4
@@ -255,17 +256,59 @@ enum enum28xx_itype {
        EM28XX_RADIO,
 };
 
+enum em28xx_ac97_mode {
+       EM28XX_NO_AC97 = 0,
+       EM28XX_AC97_EM202,
+       EM28XX_AC97_SIGMATEL,
+       EM28XX_AC97_OTHER,
+};
+
+struct em28xx_audio_mode {
+       enum em28xx_ac97_mode ac97;
+
+       u16 ac97_feat;
+       u32 ac97_vendor_id;
+
+       unsigned int has_audio:1;
+
+       unsigned int i2s_3rates:1;
+       unsigned int i2s_5rates:1;
+};
+
+/* em28xx has two audio inputs: tuner and line in.
+   However, on most devices, an auxiliary AC97 codec device is used.
+   The AC97 device may have several different inputs and outputs,
+   depending on their model. So, it is possible to use AC97 mixer to
+   address more than two different entries.
+ */
 enum em28xx_amux {
-       EM28XX_AMUX_VIDEO,
-       EM28XX_AMUX_LINE_IN,
-       EM28XX_AMUX_AC97_VIDEO,
-       EM28XX_AMUX_AC97_LINE_IN,
+       /* This is the only entry for em28xx tuner input */
+       EM28XX_AMUX_VIDEO,      /* em28xx tuner, AC97 mixer Video */
+
+       EM28XX_AMUX_LINE_IN,    /* AC97 mixer Line In */
+
+       /* Some less-common mixer setups */
+       EM28XX_AMUX_VIDEO2,     /* em28xx Line in, AC97 mixer Video */
+       EM28XX_AMUX_PHONE,
+       EM28XX_AMUX_MIC,
+       EM28XX_AMUX_CD,
+       EM28XX_AMUX_AUX,
+       EM28XX_AMUX_PCM_OUT,
+};
+
+enum em28xx_aout {
+       EM28XX_AOUT_MASTER = 1 << 0,
+       EM28XX_AOUT_LINE   = 1 << 1,
+       EM28XX_AOUT_MONO   = 1 << 2,
+       EM28XX_AOUT_LFE    = 1 << 3,
+       EM28XX_AOUT_SURR   = 1 << 4,
 };
 
 struct em28xx_input {
        enum enum28xx_itype type;
        unsigned int vmux;
        enum em28xx_amux amux;
+       enum em28xx_aout aout;
 };
 
 #define INPUT(nr) (&em28xx_boards[dev->model].input[nr])
@@ -273,8 +316,7 @@ struct em28xx_input {
 enum em28xx_decoder {
        EM28XX_NODECODER,
        EM28XX_TVP5150,
-       EM28XX_SAA7113,
-       EM28XX_SAA7114
+       EM28XX_SAA711X,
 };
 
 struct em28xx_reg_seq {
@@ -287,6 +329,7 @@ struct em28xx_board {
        char *name;
        int vchannels;
        int tuner_type;
+       int tuner_addr;
 
        /* i2c flags */
        unsigned int tda9887_conf;
@@ -294,16 +337,18 @@ struct em28xx_board {
        unsigned int is_em2800:1;
        unsigned int has_msp34xx:1;
        unsigned int mts_firmware:1;
-       unsigned int has_12mhz_i2s:1;
        unsigned int max_range_640_480:1;
        unsigned int has_dvb:1;
        unsigned int has_snapshot_button:1;
        unsigned int valid:1;
 
+       unsigned char xclk, i2c_speed;
+
        enum em28xx_decoder decoder;
 
        struct em28xx_input       input[MAX_EM28XX_INPUT];
        struct em28xx_input       radio;
+       IR_KEYTAB_TYPE            *ir_codes;
 };
 
 struct em28xx_eeprom {
@@ -371,16 +416,14 @@ struct em28xx {
        int model;              /* index in the device_data struct */
        int devno;              /* marks the number of this device */
        enum em28xx_chip_id chip_id;
-       unsigned int is_em2800:1;
-       unsigned int has_msp34xx:1;
-       unsigned int has_tda9887:1;
+
+       struct em28xx_board board;
+
        unsigned int stream_on:1;       /* Locks streams */
        unsigned int has_audio_class:1;
-       unsigned int has_12mhz_i2s:1;
-       unsigned int max_range_640_480:1;
-       unsigned int has_dvb:1;
-       unsigned int has_snapshot_button:1;
-       unsigned int valid:1;           /* report for validated boards */
+       unsigned int has_alsa_audio:1;
+
+       struct em28xx_IR *ir;
 
        /* Some older em28xx chips needs a waiting time after writing */
        unsigned int wait_after_write;
@@ -389,14 +432,13 @@ struct em28xx {
        struct em28xx_reg_seq *analog_gpio, *digital_gpio;
 
        /* GPIO sequences for tuner callbacks */
-       struct em28xx_reg_seq *tun_analog_gpio, *tun_digital_gpio;
+       struct em28xx_reg_seq *tuner_gpio;
 
-       int video_inputs;       /* number of video inputs */
        struct list_head        devlist;
 
        u32 i2s_speed;          /* I2S speed for audio digital stream */
 
-       enum em28xx_decoder decoder;
+       struct em28xx_audio_mode audio_mode;
 
        int tuner_type;         /* type of the tuner */
        int tuner_addr;         /* tuner address */
@@ -411,6 +453,7 @@ struct em28xx {
        int ctl_freq;           /* selected frequency */
        unsigned int ctl_input; /* selected input */
        unsigned int ctl_ainput;/* selected audio input */
+       unsigned int ctl_aoutput;/* selected audio output */
        int mute;
        int volume;
        /* frame properties */
@@ -513,7 +556,10 @@ int em28xx_read_reg(struct em28xx *dev, u16 reg);
 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_audio_analog_set(struct em28xx *dev);
+int em28xx_audio_setup(struct em28xx *dev);
 
 int em28xx_colorlevels_set_default(struct em28xx *dev);
 int em28xx_capture_start(struct em28xx *dev, int start);
@@ -542,7 +588,6 @@ void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir);
 int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
 
 /* Provided by em28xx-input.c */
-/* TODO: Check if the standard get_key handlers on ir-common can be used */
 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,
@@ -550,6 +595,9 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
 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);
+
 /* printk macros */
 
 #define em28xx_err(fmt, arg...) do {\
@@ -569,7 +617,7 @@ void em28xx_deregister_snapshot_button(struct em28xx *dev);
 static inline int em28xx_compression_disable(struct em28xx *dev)
 {
        /* side effect of disabling scaler and mixer */
-       return em28xx_write_regs(dev, EM28XX_R26_COMPR, "\x00", 1);
+       return em28xx_write_reg(dev, EM28XX_R26_COMPR, 0x00);
 }
 
 static inline int em28xx_contrast_get(struct em28xx *dev)
@@ -641,7 +689,7 @@ static inline int em28xx_gamma_set(struct em28xx *dev, s32 val)
 /*FIXME: maxw should be dependent of alt mode */
 static inline unsigned int norm_maxw(struct em28xx *dev)
 {
-       if (dev->max_range_640_480)
+       if (dev->board.max_range_640_480)
                return 640;
        else
                return 720;
@@ -649,7 +697,7 @@ static inline unsigned int norm_maxw(struct em28xx *dev)
 
 static inline unsigned int norm_maxh(struct em28xx *dev)
 {
-       if (dev->max_range_640_480)
+       if (dev->board.max_range_640_480)
                return 480;
        else
                return (dev->norm & V4L2_STD_625_50) ? 576 : 480;