Skip to contentSkip to conversation

V4L I2C Tuner

PATCH New Mauro Carvalho Chehab 1 participant 1 message Jul 9, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 9/14 V4L I2C Tuner

- Fixed a trouble on tuner-core that generates erros on computers with more than one TV card.
- Rename tuner structures fields.
- Tail spaces removed.
- I2C cleanups and converged to a basic reference structure.
- Removed unused structures.
- Fix setting frequency on tda8290.
- Added code for TEA5767 autodetection.
- Standby mode support implemented. It is used to disable
a non used tuner. Currenlty implemented on tea5767.
- New macro: set_type disables other tuner when changing mode.
- Some cleanups.
- Use 50 kHz step when tunning radio for most tuners to improve precision.

 linux/drivers/media/video/mt20xx.c       |   16 
 linux/drivers/media/video/tda8290.c      |   13 
 linux/drivers/media/video/tda9887.c      |    9 
 linux/drivers/media/video/tea5767.c      |  158 ++---
 linux/drivers/media/video/tuner-core.c   |  701 +++++++++++++----------
 linux/drivers/media/video/tuner-simple.c |   85 +-
 linux/include/media/tuner.h              |   51 -
 7 files changed, 542 insertions(+), 491 deletions(-)
include/media/tuner.h +21 -30
diff -u linux-2.6.13/include/media/tuner.h linux/include/media/tuner.h
@@ -1,5 +1,5 @@
 
-/* $Id: tuner.h,v 1.33 2005/06/21 14:58:08 mkrufky Exp $
+/* $Id: tuner.h,v 1.42 2005/07/06 09:42:19 mchehab Exp $
  *
     tuner.h - definition for different tuners
 
@@ -26,8 +26,6 @@
 
 #include <linux/videodev2.h>
 
-#include "id.h"
-
 #define ADDR_UNSET (255)
 
 #define TUNER_TEMIC_PAL     0        /* 4002 FH5 (3X 7756, 9483) */
@@ -111,8 +109,6 @@
 #define TUNER_TEA5767         62	/* Only FM Radio Tuner */
 #define TUNER_PHILIPS_FMD1216ME_MK3 63
 
-#define TEA5767_TUNER_NAME "Philips TEA5767HN FM Radio"
-
 #define NOTUNER 0
 #define PAL     1	/* PAL_BG */
 #define PAL_I   2
@@ -135,19 +131,8 @@
 #define TCL     11
 #define THOMSON 12
 
-enum v4l_radio_tuner {
-        TEA5767_LOW_LO_32768    = 0,
-        TEA5767_HIGH_LO_32768   = 1,
-        TEA5767_LOW_LO_13MHz    = 2,
-        TEA5767_HIGH_LO_13MHz   = 3,
-};
-
-
-#define TUNER_SET_TYPE               _IOW('t',1,int)    /* set tuner type */
-#define TUNER_SET_TVFREQ             _IOW('t',2,int)    /* set tv freq */
-#define TUNER_SET_TYPE_ADDR          _IOW('T',3,int)	/* set tuner type and I2C addr */
-
-#define  TDA9887_SET_CONFIG          _IOW('t',5,int)
+#define TUNER_SET_TYPE_ADDR          _IOW('T',3,int)
+#define TDA9887_SET_CONFIG           _IOW('t',5,int)
 
 /* tv card specific */
 # define TDA9887_PRESENT             (1<<0)
@@ -169,25 +154,34 @@
 #define I2C_ADDR_TDA8290        0x4b
 #define I2C_ADDR_TDA8275        0x61
 
-struct tuner_addr {
-	enum v4l2_tuner_type	v4l2_tuner;
-	unsigned int		type;
+enum tuner_mode {
+	T_UNINITIALIZED = 0,
+	T_RADIO		= 1 << V4L2_TUNER_RADIO,
+	T_ANALOG_TV     = 1 << V4L2_TUNER_ANALOG_TV,
+	T_DIGITAL_TV    = 1 << V4L2_TUNER_DIGITAL_TV,
+	T_STANDBY	= 1 << 31
+};
+
+struct tuner_setup {
 	unsigned short		addr;
+	unsigned int		type;
+	unsigned int		mode_mask;
 };
 
 struct tuner {
 	/* device */
 	struct i2c_client i2c;
 
-	/* state + config */
-	unsigned int initialized;
 	unsigned int type;            /* chip type */
+
+	unsigned int          mode;
+	unsigned int          mode_mask; /* Combination of allowable modes */
+
 	unsigned int freq;            /* keep track of the current settings */
+	unsigned int audmode;
 	v4l2_std_id  std;
-	int          using_v4l2;
 
-	enum v4l2_tuner_type mode;
-	unsigned int input;
+	int          using_v4l2;
 
 	/* used by MT2032 */
 	unsigned int xogc;
@@ -197,15 +191,11 @@
 	unsigned char i2c_easy_mode[2];
 	unsigned char i2c_set_freq[8];
 
-	/* used to keep track of audmode */
-	unsigned int audmode;
-
 	/* function ptrs */
 	void (*tv_freq)(struct i2c_client *c, unsigned int freq);
 	void (*radio_freq)(struct i2c_client *c, unsigned int freq);
 	int  (*has_signal)(struct i2c_client *c);
 	int  (*is_stereo)(struct i2c_client *c);
-	int  (*set_tuner)(struct i2c_client *c, struct v4l2_tuner *v);
 };
 
 extern unsigned int tuner_debug;
@@ -215,6 +205,7 @@
 extern int tda8290_init(struct i2c_client *c);
 extern int tea5767_tuner_init(struct i2c_client *c);
 extern int default_tuner_init(struct i2c_client *c);
+extern int tea5767_autodetection(struct i2c_client *c);
 
 #define tuner_warn(fmt, arg...) \
 	dev_printk(KERN_WARNING , &t->i2c.dev , fmt , ## arg)
drivers/media/video/tuner-core.c +399 -302

942 lines not on this page · raw message

drivers/media/video/tuner-simple.c +36 -49

152 lines not on this page · raw message

drivers/media/video/mt20xx.c +0 -16
diff -u linux-2.6.13/drivers/media/video/mt20xx.c linux/drivers/media/video/mt20xx.c
@@ -511,22 +511,6 @@
 	tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n",
 		   company_code,buf[0x13],buf[0x14]);
 
-#if 0
-	/* seems to cause more problems than it solves ... */
-	switch (company_code) {
-	case 0x30bf:
-	case 0x3cbf:
-	case 0x3dbf:
-	case 0x4d54:
-	case 0x8e81:
-	case 0x8e91:
-		/* ok (?) */
-		break;
-	default:
-		tuner_warn("tuner: microtune: unknown companycode\n");
-		return 0;
-	}
-#endif
 
 	if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
 	    NULL != microtune_part[buf[0x13]])
drivers/media/video/tda8290.c +5 -8
diff -u linux-2.6.13/drivers/media/video/tda8290.c linux/drivers/media/video/tda8290.c
@@ -1,5 +1,5 @@
 /*
- * $Id: tda8290.c,v 1.11 2005/06/18 06:09:06 nsh Exp $
+ * $Id: tda8290.c,v 1.15 2005/07/08 20:21:33 mchehab Exp $
  *
  * i2c tv tuner chip device driver
  * controls the philips tda8290+75 tuner chip combo.
@@ -136,15 +136,12 @@
 	return 0;
 }
 
-static void set_frequency(struct tuner *t, u16 ifc)
+static void set_frequency(struct tuner *t, u16 ifc, unsigned int freq)
 {
-	u32 freq;
 	u32 N;
 
 	if (t->mode == V4L2_TUNER_RADIO)
-		freq = t->freq / 1000;
-	else
-		freq = t->freq;
+		freq = freq / 1000;
 
 	N = (((freq<<3)+ifc)&0x3fffc);
 
@@ -187,14 +184,14 @@
 	struct tuner *t = i2c_get_clientdata(c);
 
 	set_audio(t);
-	set_frequency(t, 864);
+	set_frequency(t, 864, freq);
 	tda8290_tune(c);
 }
 
 static void set_radio_freq(struct i2c_client *c, unsigned int freq)
 {
 	struct tuner *t = i2c_get_clientdata(c);
-	set_frequency(t, 704);
+	set_frequency(t, 704, freq);
 	tda8290_tune(c);
 }
 
drivers/media/video/tda9887.c +0 -9
diff -u linux-2.6.13/drivers/media/video/tda9887.c linux/drivers/media/video/tda9887.c
@@ -569,15 +569,6 @@
 	tda9887_set_config(t,buf);
 	tda9887_set_insmod(t,buf);
 
-#if 0
-	/* This as-is breaks some cards, must be fixed in a
-	 * card-specific way, probably using TDA9887_SET_CONFIG to
-	 * turn on/off port2 */
-	if (t->std & V4L2_STD_SECAM_L) {
-		/* secam fixup (FIXME: move this to tvnorms array?) */
-		buf[1] &= ~cOutputPort2Inactive;
-	}
-#endif
 
 	dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n",
 		buf[1],buf[2],buf[3]);
drivers/media/video/tea5767.c +81 -77

302 lines not on this page · raw message