Skip to contentSkip to conversation

v4l tuner improvements

PATCH New Mauro Carvalho Chehab 1 participant 1 message Jun 22, 2005

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

PATCH 1/1 v4l tuner improvements

*tuner-core.c:
- some tuner_info msgs will be generated only if insmod opt tuner_debug enabled.
- Implemented tuner-core support for VIDIO_S_TUNER to allow changing mono/stereo mode
- Remove unneeded config options.
- I2C_CLIENT_MULTI option removed.
- support for Philips FMD12ME hybrid tuner
- allow to initialize with another tuner
- Move PHILIPS_FMD initialization code to set_type function,

* tda8290:

- Fix dumb error in tda8290 tunning.
- Radio tuner uses high-precision step instead of 62.5 KHz.

*tea5767.c:
- tuner_info msgs will be generated only if insmod tuner option tuner_debug enabled.
- some cleanups for better reading.
- Radio tuner uses high-precision step instead of 62.5 KHz.
- Changing radio mode stereo/mono for tea5767 working.

*tuner-simple.c:
- TNF9533-D/IF UHF fixup.
- Radio tuners now uses high-precision step instead of 62.5 KHz.

*mt20xx.c:
- Radio tuner uses high-precision step instead of 62.5 KHz.

*tda9887.c:
- tab and blank spaces corrections.

Obs.: Patch also available at
http://www.linuxtv.org/downloads/video4linux/patches/2.6.12-mm1/v4l_patch01_i2c-tuner.patch

include/media/tuner.h +14 -6
diff -u linux-2.6.12-mm1/include/media/tuner.h linux/include/media/tuner.h
@@ -1,5 +1,6 @@
 
-/*
+/* $Id: tuner.h,v 1.33 2005/06/21 14:58:08 mkrufky Exp $
+ *
     tuner.h - definition for different tuners
 
     Copyright (C) 1997 Markus Schroeder ([email protected])
@@ -23,6 +24,8 @@
 #ifndef _TUNER_H
 #define _TUNER_H
 
+#include <linux/videodev2.h>
+
 #include "id.h"
 
 #define ADDR_UNSET (255)
@@ -88,7 +91,7 @@
 #define TUNER_LG_NTSC_TAPE       47
 
 #define TUNER_TNF_8831BGFF       48
-#define TUNER_MICROTUNE_4042FI5  49	/* FusionHDTV 3 Gold - 4042 FI5 (3X 8147) */
+#define TUNER_MICROTUNE_4042FI5  49	/* DViCO FusionHDTV 3 Gold-Q - 4042 FI5 (3X 8147) */
 #define TUNER_TCL_2002N          50
 #define TUNER_PHILIPS_FM1256_IH3   51
 
@@ -98,18 +101,18 @@
 #define TUNER_LG_PAL_TAPE        55    /* Hauppauge PVR-150 PAL */
 
 #define TUNER_PHILIPS_FQ1216AME_MK4 56 /* Hauppauge PVR-150 PAL */
-#define TUNER_PHILIPS_FQ1236A_MK4 57   /* Hauppauge PVR-500MCE NTSC */
+#define TUNER_PHILIPS_FQ1236A_MK4   57   /* Hauppauge PVR-500MCE NTSC */
 
 #define TUNER_YMEC_TVF_8531MF 58
 #define TUNER_YMEC_TVF_5533MF 59	/* Pixelview Pro Ultra NTSC */
-#define TUNER_THOMSON_DTT7611 60
+#define TUNER_THOMSON_DTT7611 60	/* DViCO FusionHDTV 3 Gold-T */
 #define TUNER_TENA_9533_DI    61
+
 #define TUNER_TEA5767         62	/* Only FM Radio Tuner */
+#define TUNER_PHILIPS_FMD1216ME_MK3 63
 
 #define TEA5767_TUNER_NAME "Philips TEA5767HN FM Radio"
 
-#define TUNER_THOMSON_DTT7611    60
-
 #define NOTUNER 0
 #define PAL     1	/* PAL_BG */
 #define PAL_I   2
@@ -194,11 +197,15 @@
 	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;
@@ -206,6 +213,7 @@
 
 extern int microtune_init(struct i2c_client *c);
 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);
 
 #define tuner_warn(fmt, arg...) \
drivers/media/video/tuner-core.c +90 -83

319 lines not on this page · raw message

drivers/media/video/tuner-simple.c +21 -21

105 lines not on this page · raw message

drivers/media/video/mt20xx.c +3 -3
diff -u linux-2.6.12-mm1/drivers/media/video/mt20xx.c linux/drivers/media/video/mt20xx.c
@@ -1,5 +1,5 @@
 /*
- * $Id: mt20xx.c,v 1.4 2005/03/04 09:24:56 kraxel Exp $
+ * $Id: mt20xx.c,v 1.5 2005/06/16 08:29:49 nsh Exp $
  *
  * i2c tv tuner chip device driver
  * controls microtune tuners, mt2032 + mt2050 at the moment.
@@ -295,8 +295,8 @@
 	int if2 = t->radio_if2;
 
 	// per Manual for FM tuning: first if center freq. 1085 MHz
-        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
-			   1085*1000*1000,if2,if2,if2);
+        mt2032_set_if_freq(c, freq * 1000 / 16,
+			      1085*1000*1000,if2,if2,if2);
 }
 
 // Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
drivers/media/video/tda8290.c +18 -10
diff -u linux-2.6.12-mm1/drivers/media/video/tda8290.c linux/drivers/media/video/tda8290.c
@@ -1,5 +1,5 @@
 /*
- * $Id: tda8290.c,v 1.7 2005/03/07 12:01:51 kraxel Exp $
+ * $Id: tda8290.c,v 1.11 2005/06/18 06:09:06 nsh Exp $
  *
  * i2c tv tuner chip device driver
  * controls the philips tda8290+75 tuner chip combo.
@@ -69,7 +69,7 @@
 static unsigned char i2c_enable_bridge[2] = 	{ 0x21, 0xC0 };
 static unsigned char i2c_disable_bridge[2] = 	{ 0x21, 0x80 };
 static unsigned char i2c_init_tda8275[14] = 	{ 0x00, 0x00, 0x00, 0x00,
-						  0x7C, 0x04, 0xA3, 0x3F,
+						  0xfC, 0x04, 0xA3, 0x3F,
 						  0x2A, 0x04, 0xFF, 0x00,
 						  0x00, 0x40 };
 static unsigned char i2c_set_VS[2] = 		{ 0x30, 0x6F };
@@ -137,17 +137,25 @@
 }
 
 static void set_frequency(struct tuner *t, u16 ifc)
-{
-	u32 N = (((t->freq<<3)+ifc)&0x3fffc);
-
-	N = N >> get_freq_entry(div_table, t->freq);
+{	
+	u32 freq;
+	u32 N;
+
+	if (t->mode == V4L2_TUNER_RADIO)
+		freq = t->freq / 1000;
+	else 
+		freq = t->freq;
+
+	N = (((freq<<3)+ifc)&0x3fffc);
+	
+	N = N >> get_freq_entry(div_table, freq);
 	t->i2c_set_freq[0] = 0;
 	t->i2c_set_freq[1] = (unsigned char)(N>>8);
 	t->i2c_set_freq[2] = (unsigned char) N;
 	t->i2c_set_freq[3] = 0x40;
 	t->i2c_set_freq[4] = 0x52;
-	t->i2c_set_freq[5] = get_freq_entry(band_table, t->freq);
-	t->i2c_set_freq[6] = get_freq_entry(agc_table,  t->freq);
+	t->i2c_set_freq[5] = get_freq_entry(band_table, freq);
+	t->i2c_set_freq[6] = get_freq_entry(agc_table,  freq);
 	t->i2c_set_freq[7] = 0x8f;
 }
 
@@ -194,12 +202,12 @@
 {
 	unsigned char i2c_get_afc[1] = { 0x1B };
 	unsigned char afc = 0;
-
+	
 	i2c_master_send(c, i2c_get_afc, ARRAY_SIZE(i2c_get_afc));
 	i2c_master_recv(c, &afc, 1);
 	return (afc & 0x80)? 65535:0;
 }
-
+	
 int tda8290_init(struct i2c_client *c)
 {
 	struct tuner *t = i2c_get_clientdata(c);
drivers/media/video/tda9887.c +3 -4
diff -u linux-2.6.12-mm1/drivers/media/video/tda9887.c linux/drivers/media/video/tda9887.c
@@ -368,7 +368,7 @@
 		if (t->radio_mode == V4L2_TUNER_MODE_MONO)
 			norm = &radio_mono;
 		else
-		        norm = &radio_stereo;
+			norm = &radio_stereo;
 	} else {
 		for (i = 0; i < ARRAY_SIZE(tvnorms); i++) {
 			if (tvnorms[i].std & t->std) {
@@ -566,7 +566,6 @@
 	if (UNSET != t->pinnacle_id) {
 		tda9887_set_pinnacle(t,buf);
 	}
-
 	tda9887_set_config(t,buf);
 	tda9887_set_insmod(t,buf);
 
@@ -615,8 +614,8 @@
 	t->pinnacle_id = UNSET;
 	t->radio_mode = V4L2_TUNER_MODE_STEREO;
 
-        i2c_set_clientdata(&t->client, t);
-        i2c_attach_client(&t->client);
+	i2c_set_clientdata(&t->client, t);
+	i2c_attach_client(&t->client);
 
 	return 0;
 }
drivers/media/video/tea5767.c +334 -0

334 lines not on this page · raw message

drivers/media/video/Makefile +1 -2
diff -u linux-2.6.12-mm1/include/media/Makefile linux-2.6.12-mm1/linux/include/media/Makefile
@@ -7,8 +7,7 @@
 zoran-objs      :=	zr36120.o zr36120_i2c.o zr36120_mem.o
 zr36067-objs	:=	zoran_procfs.o zoran_device.o \
 			zoran_driver.o zoran_card.o
-tuner-objs	:=	tuner-core.o tuner-simple.o mt20xx.o tda8290.o
-
+tuner-objs	:=	tuner-core.o tuner-simple.o mt20xx.o tda8290.o tea5767.o
 obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o
 
 obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \
drivers/media/video/Kconfig +0 -13
diff -u linux-2.6.12-mm1/drivers/media/video/Kconfig linux-2.6.12-mm1/drivers/media/video/Kconfig
@@ -7,19 +7,6 @@
 
 comment "Video Adapters"
 
-config CONFIG_TUNER_MULTI_I2C
-	bool "Enable support for multiple I2C devices on Video Adapters (EXPERIMENTAL)"
-	depends on VIDEO_DEV && EXPERIMENTAL
-	---help---
-	  Some video adapters have more than one tuner inside. This patch
-	  enables support for using more than one tuner. This is required
-	  for some cards to allow tunning  both video and radio.
-	  It also improves I2C autodetection for these cards.
-
-	  Only few tuners currently is supporting this. More to come.
-
-	  It is safe to say 'Y' here even if your card has only one I2C tuner.
-
 config VIDEO_BT848
 	tristate "BT848 Video For Linux"
 	depends on VIDEO_DEV && PCI && I2C