Merge branch 'for-jeff' of git://electric-eye.fr.zoreil.com/home/romieu/linux-2.6
[pandora-kernel.git] / include / media / tuner.h
index faa0f8e..a5beeac 100644 (file)
@@ -23,6 +23,7 @@
 #define _TUNER_H
 
 #include <linux/videodev2.h>
+#include <media/tuner-types.h>
 
 #define ADDR_UNSET (255)
 
@@ -82,9 +83,9 @@
 #define TUNER_PHILIPS_FM1236_MK3       43
 
 #define TUNER_PHILIPS_4IN1             44      /* ATI TV Wonder Pro - Conexant */
-/* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */
+/* Microtune merged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */
 #define TUNER_MICROTUNE_4049FM5        45
-#define TUNER_MICROTUNE_4042_FI5       46
+#define TUNER_PANASONIC_VP27           46
 #define TUNER_LG_NTSC_TAPE             47
 
 #define TUNER_TNF_8831BGFF             48
 #define TUNER_YMEC_TVF_8531MF          58
 #define TUNER_YMEC_TVF_5533MF          59      /* Pixelview Pro Ultra NTSC */
 
-#define TUNER_THOMSON_DTT7611          60      /* DViCO FusionHDTV 3 Gold-T */
+#define TUNER_THOMSON_DTT761X          60      /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */
 #define TUNER_TENA_9533_DI             61
 #define TUNER_TEA5767                  62      /* Only FM Radio Tuner */
 #define TUNER_PHILIPS_FMD1216ME_MK3    63
 
 #define TUNER_PHILIPS_TUV1236D         68      /* ATI HDTV Wonder */
 #define TUNER_TNF_5335MF                69     /* Sabrent Bt848   */
-
-#define NOTUNER 0
-#define PAL     1      /* PAL_BG */
-#define PAL_I   2
-#define NTSC    3
-#define SECAM   4
-#define ATSC    5
-#define RADIO   6
-
-#define NoTuner 0
-#define Philips 1
-#define TEMIC   2
-#define Sony    3
-#define Alps    4
-#define LGINNOTEK 5
-#define SHARP   6
-#define Samsung 7
-#define Microtune 8
-#define HITACHI 9
-#define Panasonic 10
-#define TCL     11
-#define THOMSON 12
-
-#define TUNER_SET_TYPE_ADDR          _IOW('T',3,int)
-#define TUNER_SET_STANDBY            _IOW('T',4,int)
-#define TDA9887_SET_CONFIG           _IOW('t',5,int)
+#define TUNER_SAMSUNG_TCPN_2121P30A     70     /* Hauppauge PVR-500MCE NTSC */
 
 /* tv card specific */
-# define TDA9887_PRESENT             (1<<0)
-# define TDA9887_PORT1_INACTIVE      (1<<1)
-# define TDA9887_PORT2_INACTIVE      (1<<2)
-# define TDA9887_QSS                 (1<<3)
-# define TDA9887_INTERCARRIER        (1<<4)
-# define TDA9887_PORT1_ACTIVE        (1<<5)
-# define TDA9887_PORT2_ACTIVE        (1<<6)
-# define TDA9887_INTERCARRIER_NTSC   (1<<7)
+#define TDA9887_PRESENT                (1<<0)
+#define TDA9887_PORT1_INACTIVE                 (1<<1)
+#define TDA9887_PORT2_INACTIVE                 (1<<2)
+#define TDA9887_QSS                    (1<<3)
+#define TDA9887_INTERCARRIER           (1<<4)
+#define TDA9887_PORT1_ACTIVE           (1<<5)
+#define TDA9887_PORT2_ACTIVE           (1<<6)
+#define TDA9887_INTERCARRIER_NTSC      (1<<7)
+/* Tuner takeover point adjustment, in dB, -16 <= top <= 15 */
+#define TDA9887_TOP_MASK               (0x3f << 8)
+#define TDA9887_TOP_SET                (1 << 13)
+#define TDA9887_TOP(top)               (TDA9887_TOP_SET | (((16 + (top)) & 0x1f) << 8))
+
 /* config options */
-# define TDA9887_DEEMPHASIS_MASK     (3<<16)
-# define TDA9887_DEEMPHASIS_NONE     (1<<16)
-# define TDA9887_DEEMPHASIS_50       (2<<16)
-# define TDA9887_DEEMPHASIS_75       (3<<16)
-# define TDA9887_AUTOMUTE            (1<<18)
+#define TDA9887_DEEMPHASIS_MASK        (3<<16)
+#define TDA9887_DEEMPHASIS_NONE        (1<<16)
+#define TDA9887_DEEMPHASIS_50          (2<<16)
+#define TDA9887_DEEMPHASIS_75          (3<<16)
+#define TDA9887_AUTOMUTE               (1<<18)
 
 #ifdef __KERNEL__
 
@@ -167,10 +148,26 @@ enum tuner_mode {
        T_STANDBY       = 1 << 31
 };
 
+/* Older boards only had a single tuner device. Nowadays multiple tuner
+   devices may be present on a single board. Using TUNER_SET_TYPE_ADDR
+   to pass the tuner_setup structure it is possible to setup each tuner
+   device in turn.
+
+   Since multiple devices may be present it is no longer sufficient to
+   send a command to a single i2c device. Instead you should broadcast
+   the command to all i2c devices.
+
+   By setting the mode_mask correctly you can select which commands are
+   accepted by a specific tuner device. For example, set mode_mask to
+   T_RADIO if the device is a radio-only tuner. That specific tuner will
+   only accept commands when the tuner is in radio mode and ignore them
+   when the tuner is set to TV mode.
+ */
+
 struct tuner_setup {
-       unsigned short  addr;
-       unsigned int    type;
-       unsigned int    mode_mask;
+       unsigned short  addr;   /* I2C address */
+       unsigned int    type;   /* Tuner type */
+       unsigned int    mode_mask;  /* Allowed tuner modes */
 };
 
 struct tuner {
@@ -182,7 +179,9 @@ struct tuner {
        unsigned int mode;
        unsigned int mode_mask; /* Combination of allowable modes */
 
-       unsigned int freq;      /* keep track of the current settings */
+       unsigned int tv_freq;   /* keep track of the current settings */
+       unsigned int radio_freq;
+       u16          last_div;
        unsigned int audmode;
        v4l2_std_id  std;
 
@@ -200,14 +199,13 @@ struct tuner {
        unsigned int sgIF;
 
        /* function ptrs */
-       void (*tv_freq)(struct i2c_client *c, unsigned int freq);
-       void (*radio_freq)(struct i2c_client *c, unsigned int freq);
+       void (*set_tv_freq)(struct i2c_client *c, unsigned int freq);
+       void (*set_radio_freq)(struct i2c_client *c, unsigned int freq);
        int  (*has_signal)(struct i2c_client *c);
        int  (*is_stereo)(struct i2c_client *c);
        void (*standby)(struct i2c_client *c);
 };
 
-extern unsigned int tuner_debug;
 extern unsigned const int tuner_count;
 
 extern int microtune_init(struct i2c_client *c);
@@ -218,15 +216,16 @@ extern int default_tuner_init(struct i2c_client *c);
 extern int tea5767_autodetection(struct i2c_client *c);
 
 #define tuner_warn(fmt, arg...) do {\
-       printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->name, \
-                       t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0)
+       printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \
+                       i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
 #define tuner_info(fmt, arg...) do {\
-       printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->name, \
-                       t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0)
+       printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \
+                       i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
 #define tuner_dbg(fmt, arg...) do {\
+       extern int tuner_debug; \
        if (tuner_debug) \
-               printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->name, \
-                       t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0)
+               printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \
+                       i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
 
 #endif /* __KERNEL__ */