All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] Audio standards on tm6000
@ 2010-10-07  5:28 Mauro Carvalho Chehab
  2010-10-08 19:03 ` Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Mauro Carvalho Chehab @ 2010-10-07  5:28 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Felipe Sanches, Stefan Ringel, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi Dmitri,

IMO, the better is to remove the audio init from tm6000-core and add a separate
per-standard set of tables.

I'm enclosing the patch for it. Please check if this won't break for your device.

On all tests I did here with a tm6010 device (HVR 900H), I was only able to listen to
white noise.

I'm suspecting that this device uses XC3028 MTS mode (e. g. uses xc3028 to decode audio,
and just inputs the audio stream from some line IN. As the driver is not able yet to
handle an audio mux, this may explain why I'm not able to receive any audio at all.

Maybe tm5600 devices may also require (or use) line input entries, instead of I2S.

Could you please check those issues?

PS.: the PAL/M hunk will probably fail, as I likely applied some patches before
this one, in order to try to fix it. It should be trivial to solve the conflicts.

---

tm6000: Implement audio standard tables

Implement separate tables for audio standards, associating them with the
video standards.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 57cb69e..9cb2901 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -200,6 +200,10 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 		val &= ~0x40;
 		tm6000_set_reg(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE, val);
 
+		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+
+#if 0		/* FIXME: VBI is standard-dependent */
+
 		/* Init teletext */
 		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
 		tm6000_set_reg(dev, TM6010_REQ07_R41_TELETEXT_VBI_CODE1, 0x27);
@@ -249,44 +253,7 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 		tm6000_set_reg(dev, TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c);
 		tm6000_set_reg(dev, TM6010_REQ07_R40_TELETEXT_VBI_CODE0, 0x01);
 		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
-
-
-		/* Init audio */
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
-		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
-		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
-		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
-		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
-		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
-		tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
-		tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
-		tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
-		tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
-		tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
-		tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
-		tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-		tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
-
+#endif
 	} else {
 		/* Enables soft reset */
 		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
@@ -360,7 +327,6 @@ int tm6000_init_digital_mode(struct tm6000_core *dev)
 		tm6000_set_reg(dev, TM6010_REQ07_RFE_POWER_DOWN, 0x28);
 		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xfc);
 		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0xff);
-		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe);
 		tm6000_read_write_usb(dev, 0xc0, 0x0e, 0x00c2, 0x0008, buf, 2);
 		printk(KERN_INFO"buf %#x %#x\n", buf[0], buf[1]);
 	} else  {
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index 33adf6c..e79a72e 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -28,8 +28,22 @@ struct tm6000_reg_settings {
 	unsigned char value;
 };
 
+enum tm6000_audio_std {
+	BG_NICAM,
+	BTSC,
+	BG_A2,
+	DK_NICAM,
+	EIAJ,
+	FM_RADIO,
+	I_NICAM,
+	KOREA_A2,
+	L_NICAM,
+};
+
 struct tm6000_std_tv_settings {
 	v4l2_std_id id;
+	enum tm6000_audio_std audio_default_std;
+
 	struct tm6000_reg_settings sif[12];
 	struct tm6000_reg_settings nosif[12];
 	struct tm6000_reg_settings common[26];
@@ -37,12 +51,14 @@ struct tm6000_std_tv_settings {
 
 struct tm6000_std_settings {
 	v4l2_std_id id;
+	enum tm6000_audio_std audio_default_std;
 	struct tm6000_reg_settings common[37];
 };
 
 static struct tm6000_std_tv_settings tv_stds[] = {
 	{
 		.id = V4L2_STD_PAL_M,
+		.audio_default_std = BTSC,
 		.sif = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
@@ -96,12 +112,14 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 
 			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
 			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ08_R05_A_STANDARD_MOD, 0x22},
+
 			{TM6010_REQ07_R3F_RESET, 0x00},
+
 			{0, 0, 0},
 		},
 	}, {
 		.id = V4L2_STD_PAL_Nc,
+		.audio_default_std = BTSC,
 		.sif = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
@@ -161,6 +179,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_PAL,
+		.audio_default_std = BG_A2,
 		.sif = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
@@ -220,6 +239,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_SECAM,
+		.audio_default_std = BG_NICAM,
 		.sif = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
@@ -278,6 +298,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_NTSC,
+		.audio_default_std = BTSC,
 		.sif = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
@@ -341,6 +362,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 static struct tm6000_std_settings composite_stds[] = {
 	{
 		.id = V4L2_STD_PAL_M,
+		.audio_default_std = BTSC,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
@@ -383,6 +405,7 @@ static struct tm6000_std_settings composite_stds[] = {
 		},
 	 }, {
 		.id = V4L2_STD_PAL_Nc,
+		.audio_default_std = BTSC,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
@@ -425,6 +448,7 @@ static struct tm6000_std_settings composite_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_PAL,
+		.audio_default_std = BG_A2,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
@@ -467,6 +491,7 @@ static struct tm6000_std_settings composite_stds[] = {
 		},
 	 }, {
 		.id = V4L2_STD_SECAM,
+		.audio_default_std = BG_NICAM,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
@@ -508,6 +533,7 @@ static struct tm6000_std_settings composite_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_NTSC,
+		.audio_default_std = BTSC,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
@@ -554,6 +580,7 @@ static struct tm6000_std_settings composite_stds[] = {
 static struct tm6000_std_settings svideo_stds[] = {
 	{
 		.id = V4L2_STD_PAL_M,
+		.audio_default_std = BTSC,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
@@ -596,6 +623,7 @@ static struct tm6000_std_settings svideo_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_PAL_Nc,
+		.audio_default_std = BTSC,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
@@ -638,6 +666,7 @@ static struct tm6000_std_settings svideo_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_PAL,
+		.audio_default_std = BG_A2,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
@@ -680,6 +709,7 @@ static struct tm6000_std_settings svideo_stds[] = {
 		},
 	 }, {
 		.id = V4L2_STD_SECAM,
+		.audio_default_std = BG_NICAM,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
@@ -721,6 +751,7 @@ static struct tm6000_std_settings svideo_stds[] = {
 		},
 	}, {
 		.id = V4L2_STD_NTSC,
+		.audio_default_std = BTSC,
 		.common = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
 			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
@@ -765,6 +796,136 @@ static struct tm6000_std_settings svideo_stds[] = {
 	},
 };
 
+
+static int tm6000_set_audio_std(struct tm6000_core *dev,
+				enum tm6000_audio_std std)
+{
+	switch (std) {
+	case BG_NICAM:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x11);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case BTSC:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x02);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
+		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
+		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case BG_A2:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x05);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
+		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
+		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case DK_NICAM:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case EIAJ:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x03);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case FM_RADIO:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x10);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case I_NICAM:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case KOREA_A2:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
+		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
+		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0xf0);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	case L_NICAM:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x02);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		break;
+	}
+	return 0;
+}
+
 void tm6000_get_std_res(struct tm6000_core *dev)
 {
 	/* Currently, those are the only supported resoltions */
@@ -825,6 +986,8 @@ static int tm6000_set_tv(struct tm6000_core *dev, int pos)
 	rc = tm6000_load_std(dev, tv_stds[pos].common,
 			     sizeof(tv_stds[pos].common));
 
+	tm6000_set_audio_std(dev, tv_stds[pos].audio_default_std);
+
 	return rc;
 }
 
@@ -850,6 +1013,8 @@ int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
 				rc = tm6000_load_std(dev, svideo_stds[i].common,
 						     sizeof(svideo_stds[i].
 							    common));
+				tm6000_set_audio_std(dev, svideo_stds[i].audio_default_std);
+
 				goto ret;
 			}
 		}
@@ -861,6 +1026,7 @@ int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
 						     composite_stds[i].common,
 						     sizeof(composite_stds[i].
 							    common));
+				tm6000_set_audio_std(dev, composite_stds[i].audio_default_std);
 				goto ret;
 			}
 		}
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index a45b012..9304158 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1015,7 +1015,8 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *norm)
 	struct tm6000_fh   *fh=priv;
 	struct tm6000_core *dev = fh->dev;
 
-	rc=tm6000_set_standard (dev, norm);
+	rc = tm6000_set_standard(dev, norm);
+	rc = tm6000_init_analog_mode(dev);
 
 	fh->width  = dev->width;
 	fh->height = dev->height;
@@ -1292,9 +1293,10 @@ static int tm6000_open(struct file *file)
 				"active=%d\n",list_empty(&dev->vidq.active));
 
 	/* initialize hardware on analog mode */
-	if (dev->mode!=TM6000_MODE_ANALOG) {
-		rc=tm6000_init_analog_mode (dev);
-		if (rc<0)
+//	if (dev->mode!=TM6000_MODE_ANALOG) {
+//		rc = tm6000_set_standard(dev, dev->norm);
+		rc += tm6000_init_analog_mode(dev);
+		if (rc < 0)
 			return rc;
 
 		/* Put all controls at a sane state */
@@ -1302,7 +1304,7 @@ static int tm6000_open(struct file *file)
 			qctl_regs[i] =tm6000_qctrl[i].default_value;
 
 		dev->mode=TM6000_MODE_ANALOG;
-	}
+//	}
 
 	videobuf_queue_vmalloc_init(&fh->vb_vidq, &tm6000_video_qops,
 			NULL, &dev->slock,

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [RFC PATCH] Audio standards on tm6000
  2010-10-08 19:03 ` Dmitri Belimov
@ 2010-10-08 11:52   ` Mauro Carvalho Chehab
  2010-10-12 18:28     ` Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Mauro Carvalho Chehab @ 2010-10-08 11:52 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Felipe Sanches, Stefan Ringel, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Em 08-10-2010 16:03, Dmitri Belimov escreveu:
> Hi Mauro
> 
> Not so good. Audio with this patch has bad white noise sometimes and
> bad quality. I try found better configuration for SECAM-DK.

Ok. Well, feel free to modify it. I think that this approach may be better,
especially if we need to add later some sort of code to detect and change
audio standard for some standards that have more than one audio standard
associated (we needed do to it on other drivers, in order to work in Russia
and other Countries that use different variants of the audio standard).

The association between video and audio standard is not complete. For example,
it misses NTSC-Kr and NTSC-Jp.

Cheers,
Mauro.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [RFC PATCH] Audio standards on tm6000
  2010-10-07  5:28 [RFC PATCH] Audio standards on tm6000 Mauro Carvalho Chehab
@ 2010-10-08 19:03 ` Dmitri Belimov
  2010-10-08 11:52   ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-10-08 19:03 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Felipe Sanches, Stefan Ringel, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi Mauro

Not so good. Audio with this patch has bad white noise sometimes and
bad quality. I try found better configuration for SECAM-DK.

With my best regards, Dmitry.

> Hi Dmitri,
> 
> IMO, the better is to remove the audio init from tm6000-core and add
> a separate per-standard set of tables.
> 
> I'm enclosing the patch for it. Please check if this won't break for
> your device.
> 
> On all tests I did here with a tm6010 device (HVR 900H), I was only
> able to listen to white noise.
> 
> I'm suspecting that this device uses XC3028 MTS mode (e. g. uses
> xc3028 to decode audio, and just inputs the audio stream from some
> line IN. As the driver is not able yet to handle an audio mux, this
> may explain why I'm not able to receive any audio at all.
> 
> Maybe tm5600 devices may also require (or use) line input entries,
> instead of I2S.
> 
> Could you please check those issues?
> 
> PS.: the PAL/M hunk will probably fail, as I likely applied some
> patches before this one, in order to try to fix it. It should be
> trivial to solve the conflicts.
> 
> ---
> 
> tm6000: Implement audio standard tables
> 
> Implement separate tables for audio standards, associating them with
> the video standards.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> 
> diff --git a/drivers/staging/tm6000/tm6000-core.c
> b/drivers/staging/tm6000/tm6000-core.c index 57cb69e..9cb2901 100644
> --- a/drivers/staging/tm6000/tm6000-core.c
> +++ b/drivers/staging/tm6000/tm6000-core.c
> @@ -200,6 +200,10 @@ int tm6000_init_analog_mode(struct tm6000_core
> *dev) val &= ~0x40;
>  		tm6000_set_reg(dev,
> TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE, val); 
> +		tm6000_set_reg(dev,
> TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc); +
> +#if 0		/* FIXME: VBI is standard-dependent */
> +
>  		/* Init teletext */
>  		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
>  		tm6000_set_reg(dev,
> TM6010_REQ07_R41_TELETEXT_VBI_CODE1, 0x27); @@ -249,44 +253,7 @@ int
> tm6000_init_analog_mode(struct tm6000_core *dev) tm6000_set_reg(dev,
> TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c); tm6000_set_reg(dev,
> TM6010_REQ07_R40_TELETEXT_VBI_CODE0, 0x01); tm6000_set_reg(dev,
> TM6010_REQ07_R3F_RESET, 0x00); -
> -
> -		/* Init audio */
> -		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL,
> 0xa0);
> -		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> -		tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL,
> 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL,
> 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1,
> 0x20);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2,
> 0x12);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES,
> 0x20);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1,
> 0xf0);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2,
> 0x80);
> -		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1,
> 0xc0);
> -		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2,
> 0x80);
> -		tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
> -		tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T,
> 0xfe);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
> -		tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR,
> 0x14);
> -		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> -		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> -		tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL,
> 0xa0);
> -		tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN,
> 0x32);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
> -		tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c,
> 0x00);
> -		tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d,
> 0x00);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL,
> 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL,
> 0xf3);
> -		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> -
> +#endif
>  	} else {
>  		/* Enables soft reset */
>  		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
> @@ -360,7 +327,6 @@ int tm6000_init_digital_mode(struct tm6000_core
> *dev) tm6000_set_reg(dev, TM6010_REQ07_RFE_POWER_DOWN, 0x28);
>  		tm6000_set_reg(dev,
> TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xfc); tm6000_set_reg(dev,
> TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0xff);
> -		tm6000_set_reg(dev,
> TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe); tm6000_read_write_usb(dev,
> 0xc0, 0x0e, 0x00c2, 0x0008, buf, 2); printk(KERN_INFO"buf %#x %#x\n",
> buf[0], buf[1]); } else  {
> diff --git a/drivers/staging/tm6000/tm6000-stds.c
> b/drivers/staging/tm6000/tm6000-stds.c index 33adf6c..e79a72e 100644
> --- a/drivers/staging/tm6000/tm6000-stds.c
> +++ b/drivers/staging/tm6000/tm6000-stds.c
> @@ -28,8 +28,22 @@ struct tm6000_reg_settings {
>  	unsigned char value;
>  };
>  
> +enum tm6000_audio_std {
> +	BG_NICAM,
> +	BTSC,
> +	BG_A2,
> +	DK_NICAM,
> +	EIAJ,
> +	FM_RADIO,
> +	I_NICAM,
> +	KOREA_A2,
> +	L_NICAM,
> +};
> +
>  struct tm6000_std_tv_settings {
>  	v4l2_std_id id;
> +	enum tm6000_audio_std audio_default_std;
> +
>  	struct tm6000_reg_settings sif[12];
>  	struct tm6000_reg_settings nosif[12];
>  	struct tm6000_reg_settings common[26];
> @@ -37,12 +51,14 @@ struct tm6000_std_tv_settings {
>  
>  struct tm6000_std_settings {
>  	v4l2_std_id id;
> +	enum tm6000_audio_std audio_default_std;
>  	struct tm6000_reg_settings common[37];
>  };
>  
>  static struct tm6000_std_tv_settings tv_stds[] = {
>  	{
>  		.id = V4L2_STD_PAL_M,
> +		.audio_default_std = BTSC,
>  		.sif = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> @@ -96,12 +112,14 @@ static struct tm6000_std_tv_settings tv_stds[] =
> { 
>  			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
>  			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ08_R05_A_STANDARD_MOD, 0x22},
> +
>  			{TM6010_REQ07_R3F_RESET, 0x00},
> +
>  			{0, 0, 0},
>  		},
>  	}, {
>  		.id = V4L2_STD_PAL_Nc,
> +		.audio_default_std = BTSC,
>  		.sif = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> @@ -161,6 +179,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
>  		},
>  	}, {
>  		.id = V4L2_STD_PAL,
> +		.audio_default_std = BG_A2,
>  		.sif = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> @@ -220,6 +239,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
>  		},
>  	}, {
>  		.id = V4L2_STD_SECAM,
> +		.audio_default_std = BG_NICAM,
>  		.sif = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> @@ -278,6 +298,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
>  		},
>  	}, {
>  		.id = V4L2_STD_NTSC,
> +		.audio_default_std = BTSC,
>  		.sif = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> @@ -341,6 +362,7 @@ static struct tm6000_std_tv_settings tv_stds[] = {
>  static struct tm6000_std_settings composite_stds[] = {
>  	{
>  		.id = V4L2_STD_PAL_M,
> +		.audio_default_std = BTSC,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> @@ -383,6 +405,7 @@ static struct tm6000_std_settings
> composite_stds[] = { },
>  	 }, {
>  		.id = V4L2_STD_PAL_Nc,
> +		.audio_default_std = BTSC,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> @@ -425,6 +448,7 @@ static struct tm6000_std_settings
> composite_stds[] = { },
>  	}, {
>  		.id = V4L2_STD_PAL,
> +		.audio_default_std = BG_A2,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> @@ -467,6 +491,7 @@ static struct tm6000_std_settings
> composite_stds[] = { },
>  	 }, {
>  		.id = V4L2_STD_SECAM,
> +		.audio_default_std = BG_NICAM,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> @@ -508,6 +533,7 @@ static struct tm6000_std_settings
> composite_stds[] = { },
>  	}, {
>  		.id = V4L2_STD_NTSC,
> +		.audio_default_std = BTSC,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> @@ -554,6 +580,7 @@ static struct tm6000_std_settings
> composite_stds[] = { static struct tm6000_std_settings svideo_stds[]
> = { {
>  		.id = V4L2_STD_PAL_M,
> +		.audio_default_std = BTSC,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> @@ -596,6 +623,7 @@ static struct tm6000_std_settings svideo_stds[] =
> { },
>  	}, {
>  		.id = V4L2_STD_PAL_Nc,
> +		.audio_default_std = BTSC,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> @@ -638,6 +666,7 @@ static struct tm6000_std_settings svideo_stds[] =
> { },
>  	}, {
>  		.id = V4L2_STD_PAL,
> +		.audio_default_std = BG_A2,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> @@ -680,6 +709,7 @@ static struct tm6000_std_settings svideo_stds[] =
> { },
>  	 }, {
>  		.id = V4L2_STD_SECAM,
> +		.audio_default_std = BG_NICAM,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> @@ -721,6 +751,7 @@ static struct tm6000_std_settings svideo_stds[] =
> { },
>  	}, {
>  		.id = V4L2_STD_NTSC,
> +		.audio_default_std = BTSC,
>  		.common = {
>  			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
>  			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> @@ -765,6 +796,136 @@ static struct tm6000_std_settings svideo_stds[]
> = { },
>  };
>  
> +
> +static int tm6000_set_audio_std(struct tm6000_core *dev,
> +				enum tm6000_audio_std std)
> +{
> +	switch (std) {
> +	case BG_NICAM:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x11);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case BTSC:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x02);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1,
> 0xf0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2,
> 0x80);
> +		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1,
> 0xc0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2,
> 0x80);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case BG_A2:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x05);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1,
> 0xf0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2,
> 0x80);
> +		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1,
> 0xc0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2,
> 0x80);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case DK_NICAM:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2,
> 0x0a);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case EIAJ:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x03);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case FM_RADIO:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x01);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x0c);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x10);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case I_NICAM:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2,
> 0x0a);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case KOREA_A2:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x04);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1,
> 0xf0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2,
> 0x80);
> +		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1,
> 0xc0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2,
> 0xf0);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	case L_NICAM:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x02);
> +		tm6000_set_reg(dev,
> TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD,
> 0x0a);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD,
> 0x06);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL,
> 0x08);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD,
> 0x91);
> +		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX,
> 0xfe);
> +		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN,
> 0x01);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		break;
> +	}
> +	return 0;
> +}
> +
>  void tm6000_get_std_res(struct tm6000_core *dev)
>  {
>  	/* Currently, those are the only supported resoltions */
> @@ -825,6 +986,8 @@ static int tm6000_set_tv(struct tm6000_core *dev,
> int pos) rc = tm6000_load_std(dev, tv_stds[pos].common,
>  			     sizeof(tv_stds[pos].common));
>  
> +	tm6000_set_audio_std(dev, tv_stds[pos].audio_default_std);
> +
>  	return rc;
>  }
>  
> @@ -850,6 +1013,8 @@ int tm6000_set_standard(struct tm6000_core *dev,
> v4l2_std_id * norm) rc = tm6000_load_std(dev, svideo_stds[i].common,
>  						     sizeof(svideo_stds[i].
>  							    common));
> +				tm6000_set_audio_std(dev,
> svideo_stds[i].audio_default_std); +
>  				goto ret;
>  			}
>  		}
> @@ -861,6 +1026,7 @@ int tm6000_set_standard(struct tm6000_core *dev,
> v4l2_std_id * norm) composite_stds[i].common,
>  						     sizeof(composite_stds[i].
>  							    common));
> +				tm6000_set_audio_std(dev,
> composite_stds[i].audio_default_std); goto ret;
>  			}
>  		}
> diff --git a/drivers/staging/tm6000/tm6000-video.c
> b/drivers/staging/tm6000/tm6000-video.c index a45b012..9304158 100644
> --- a/drivers/staging/tm6000/tm6000-video.c
> +++ b/drivers/staging/tm6000/tm6000-video.c
> @@ -1015,7 +1015,8 @@ static int vidioc_s_std (struct file *file,
> void *priv, v4l2_std_id *norm) struct tm6000_fh   *fh=priv;
>  	struct tm6000_core *dev = fh->dev;
>  
> -	rc=tm6000_set_standard (dev, norm);
> +	rc = tm6000_set_standard(dev, norm);
> +	rc = tm6000_init_analog_mode(dev);
>  
>  	fh->width  = dev->width;
>  	fh->height = dev->height;
> @@ -1292,9 +1293,10 @@ static int tm6000_open(struct file *file)
>  				"active=%d\n",list_empty(&dev->vidq.active));
>  
>  	/* initialize hardware on analog mode */
> -	if (dev->mode!=TM6000_MODE_ANALOG) {
> -		rc=tm6000_init_analog_mode (dev);
> -		if (rc<0)
> +//	if (dev->mode!=TM6000_MODE_ANALOG) {
> +//		rc = tm6000_set_standard(dev, dev->norm);
> +		rc += tm6000_init_analog_mode(dev);
> +		if (rc < 0)
>  			return rc;
>  
>  		/* Put all controls at a sane state */
> @@ -1302,7 +1304,7 @@ static int tm6000_open(struct file *file)
>  			qctl_regs[i] =tm6000_qctrl[i].default_value;
>  
>  		dev->mode=TM6000_MODE_ANALOG;
> -	}
> +//	}
>  
>  	videobuf_queue_vmalloc_init(&fh->vb_vidq, &tm6000_video_qops,
>  			NULL, &dev->slock,

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [RFC PATCH] Audio standards on tm6000
  2010-10-12 18:28     ` Dmitri Belimov
@ 2010-10-12 16:54       ` Stefan Ringel
  2010-10-13 14:13         ` Dmitri Belimov
       [not found]         ` <20101129174412.08f2001c@glory.local>
  0 siblings, 2 replies; 36+ messages in thread
From: Stefan Ringel @ 2010-10-12 16:54 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Am 12.10.2010 20:28, schrieb Dmitri Belimov:
> Hi
>
>> Em 08-10-2010 16:03, Dmitri Belimov escreveu:
>>> Hi Mauro
>>>
>>> Not so good. Audio with this patch has bad white noise
>>> sometimes and bad quality. I try found better configuration for
>>> SECAM-DK.
>>
>> Ok. Well, feel free to modify it. I think that this approach may
>> be better, especially if we need to add later some sort of code
>> to detect and change audio standard for some standards that have
>> more than one audio standard associated (we needed do to it on
>> other drivers, in order to work in Russia and other Countries
>> that use different variants of the audio standard).
>>
>> The association between video and audio standard is not complete.
>> For example, it misses NTSC-Kr and NTSC-Jp.
>
> Rework audio. Add SECAM-DK, move SECAM to SECAM-B | SECAM-G. Add
> some new audio standards and tricks for future, see
> tm6000_set_audio_std For SECAM-DK it works. Try on your standards.
>
>
> Two files in attach. Patch after latest patch from Mauro and full
> file tm6000-std.c
>
>> Cheers, Mauro.
>>
>
> With my best regards, Dmitry.
Where is defined "tv_audio_mode"?
Stefan Ringel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iQEcBAEBAgAGBQJMtJLTAAoJEAWtPFjxMvFGnFAH/Rrk274byzL8IvQd6fjAIl4D
izk31/k4CY1Y2EdHvygef4ZQxIGE4PGDaOogWEIBLtlHTx6XHUASpiZ8aJW1z7oF
YQk9rtfC3ZChmaGQDBzwLI+EUg9t7TzeQ8BpC11WxiOapyKLXFv0SdMNs2Y0WHOz
BNlQkL+9kZ+Hq6nSdJJxOihu+tiwbmvvSd7b/Cz9kdLpSNGr99F+ELbM0g3oU2Ts
ue7r3FnvHFnpNlV7Ceiuj7jF5ozeo3jSdWJI3S8ph4Wdi3CkPxTnTQXJAU09JU1k
we8+/TdplP+3Rdf206r/SL4RlI5wiZr/jm4IdLcwLOm/9yHthb89qyuW5upvV6k=
=LQiB
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [RFC PATCH] Audio standards on tm6000
  2010-10-08 11:52   ` Mauro Carvalho Chehab
@ 2010-10-12 18:28     ` Dmitri Belimov
  2010-10-12 16:54       ` Stefan Ringel
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-10-12 18:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Felipe Sanches, Stefan Ringel, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

[-- Attachment #1: Type: text/plain, Size: 1037 bytes --]

Hi

> Em 08-10-2010 16:03, Dmitri Belimov escreveu:
> > Hi Mauro
> > 
> > Not so good. Audio with this patch has bad white noise sometimes and
> > bad quality. I try found better configuration for SECAM-DK.
> 
> Ok. Well, feel free to modify it. I think that this approach may be
> better, especially if we need to add later some sort of code to
> detect and change audio standard for some standards that have more
> than one audio standard associated (we needed do to it on other
> drivers, in order to work in Russia and other Countries that use
> different variants of the audio standard).
> 
> The association between video and audio standard is not complete. For
> example, it misses NTSC-Kr and NTSC-Jp.

Rework audio. Add SECAM-DK, move SECAM to SECAM-B | SECAM-G. 
Add some new audio standards and tricks for future, see tm6000_set_audio_std
For SECAM-DK it works. Try on your standards. 

Two files in attach. Patch after latest patch from Mauro and full file tm6000-std.c 

> Cheers,
> Mauro.
> 

With my best regards, Dmitry.

[-- Attachment #2: tm6000-stds.c --]
[-- Type: text/x-c++src, Size: 41640 bytes --]

/*
   tm6000-stds.c - driver for TM5600/TM6000/TM6010 USB video capture devices

   Copyright (C) 2007 Mauro Carvalho Chehab <mchehab@redhat.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation version 2

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include "tm6000.h"
#include "tm6000-regs.h"

struct tm6000_reg_settings {
	unsigned char req;
	unsigned char reg;
	unsigned char value;
};

enum tm6000_audio_std {
	BG_NICAM,
	BTSC,
	BG_A2,
	DK_NICAM,
	EIAJ,
	FM_RADIO,
	I_NICAM,
	KOREA_A2,
	L_NICAM,
};

struct tm6000_std_tv_settings {
	v4l2_std_id id;
	enum tm6000_audio_std audio_default_std;

	struct tm6000_reg_settings sif[12];
	struct tm6000_reg_settings nosif[12];
	struct tm6000_reg_settings common[26];
};

struct tm6000_std_settings {
	v4l2_std_id id;
	enum tm6000_audio_std audio_default_std;
	struct tm6000_reg_settings common[37];
};

static struct tm6000_std_tv_settings tv_stds[] = {
	{
		.id = V4L2_STD_PAL_M,
		.audio_default_std = BTSC,
		.sif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
			{0, 0, 0},
		},
		.nosif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
			{0, 0, 0},
		},
		.common = {
			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},

			{TM6010_REQ07_R3F_RESET, 0x00},

			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_PAL_Nc,
		.audio_default_std = BTSC,
		.sif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
			{0, 0, 0},
		},
		.nosif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
			{0, 0, 0},
		},
		.common = {
			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},

			{TM6010_REQ07_R3F_RESET, 0x00},

			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_PAL,
		.audio_default_std = BG_A2,
		.sif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
			{0, 0, 0}
		},
		.nosif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
			{0, 0, 0},
		},
		.common = {
			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},

			{TM6010_REQ07_R3F_RESET, 0x00},

			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
		.audio_default_std = BG_NICAM,
		.sif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
			{0, 0, 0},
		},
		.nosif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
			{0, 0, 0},
		},
		.common = {
			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},

			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},

			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_SECAM_DK,
		.audio_default_std = DK_NICAM,
		.sif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
			{0, 0, 0},
		},
		.nosif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
			{0, 0, 0},
		},
		.common = {
			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},

			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},

			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_NTSC,
		.audio_default_std = BTSC,
		.sif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
			{0, 0, 0},
		},
		.nosif = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
			{0, 0, 0},
		},
		.common = {
			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},

			{TM6010_REQ07_R3F_RESET, 0x00},

			{0, 0, 0},
		},
	},
};

static struct tm6000_std_settings composite_stds[] = {
	{
		.id = V4L2_STD_PAL_M,
		.audio_default_std = BTSC,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	 }, {
		.id = V4L2_STD_PAL_Nc,
		.audio_default_std = BTSC,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_PAL,
		.audio_default_std = BG_A2,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	 }, {
		.id = V4L2_STD_SECAM,
		.audio_default_std = BG_NICAM,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},

			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_SECAM_DK,
		.audio_default_std = DK_NICAM,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},

			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_NTSC,
		.audio_default_std = BTSC,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	},
};

static struct tm6000_std_settings svideo_stds[] = {
	{
		.id = V4L2_STD_PAL_M,
		.audio_default_std = BTSC,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x05},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_PAL_Nc,
		.audio_default_std = BTSC,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x37},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_PAL,
		.audio_default_std = BG_A2,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x33},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	 }, {
		.id = V4L2_STD_SECAM,
		.audio_default_std = BG_NICAM,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},

			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_SECAM_DK,
		.audio_default_std = DK_NICAM,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},

			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	}, {
		.id = V4L2_STD_NTSC,
		.audio_default_std = BTSC,
		.common = {
			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},

			{TM6010_REQ07_R3F_RESET, 0x01},
			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x01},
			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
			{TM6010_REQ07_R17_HLOOP_MAXSTATE, 0x8b},
			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},

			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
			{TM6010_REQ07_R3F_RESET, 0x00},
			{0, 0, 0},
		},
	},
};


static int tm6000_set_audio_std(struct tm6000_core *dev,
				enum tm6000_audio_std std)
{
	uint8_t areg_02 = 0x04; /* GC1 Fixed gain 0dB */
	uint8_t areg_05 = 0x09; /* Auto 4.5 = M Japan, Auto 6.5 = DK */
	uint8_t areg_06 = 0x02; /* Auto de-emphasis, mannual channel mode */
	uint8_t mono_flag = 0;  /* No mono */
	uint8_t nicam_flag = 0; /* No NICAM */

	switch (std) {
#if 0
	case DK_MONO:
		mono_flag = 1;
		break;
	case DK_A2_1:
		break;
	case DK_A2_3:
		areg_05 = 0x0b;
		break;
	case BG_MONO:
		mono_flag = 1;
		areg_05 = 0x05;
		break;
#endif
	case BG_NICAM:
		areg_05 = 0x07;
		nicam_flag = 1;
		break;
	case BTSC:
		areg_05 = 0x02;
		break;
	case BG_A2:
		areg_05 = 0x05;
		break;
	case DK_NICAM:
		areg_05 = 0x06;
		nicam_flag = 1;
		break;
	case EIAJ:
		areg_05 = 0x02;
		break;
	case FM_RADIO:
		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
		return 0;
		break;
	case I_NICAM:
		areg_05 = 0x08;
		nicam_flag = 1;
		break;
	case KOREA_A2:
		areg_05 = 0x04;
		break;
	case L_NICAM:
		areg_02 = 0x02; /* GC1 Fixed gain +12dB */
		areg_05 = 0x0a;
		nicam_flag = 1;
		break;
	}

#if 0
	switch (tv_audio_mode) {
	case TV_MONO:
		areg_06 = (nicam_flag) ? 0x03 : 0x00;
		break;
	case TV_LANG_A:
		areg_06 = 0x00;
		break;
	case TV_LANG_B:
		areg_06 = 0x01;
		break;
	}
#endif

	if (mono_flag)
		areg_06 = 0x00;

	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
	tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, areg_05);
	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, areg_06);
	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
	tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
	tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
	tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
	tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
	tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
	tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
	tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
	tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
	tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
	tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
	tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
	tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
	tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);

	return 0;
}

void tm6000_get_std_res(struct tm6000_core *dev)
{
	/* Currently, those are the only supported resoltions */
	if (dev->norm & V4L2_STD_525_60)
		dev->height = 480;
	else
		dev->height = 576;

	dev->width = 720;
}

static int tm6000_load_std(struct tm6000_core *dev,
			   struct tm6000_reg_settings *set, int max_size)
{
	int i, rc;

	/* Load board's initialization table */
	for (i = 0; max_size; i++) {
		if (!set[i].req)
			return 0;

		if ((dev->dev_type != TM6010) &&
		    (set[i].req == REQ_08_SET_GET_AVREG_BIT))
				continue;

		rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value);
		if (rc < 0) {
			printk(KERN_ERR "Error %i while setting "
			       "req %d, reg %d to value %d\n",
			       rc, set[i].req, set[i].reg, set[i].value);
			return rc;
		}
	}

	return 0;
}

static int tm6000_set_tv(struct tm6000_core *dev, int pos)
{
	int rc;

	/* FIXME: This code is for tm6010 - not tested yet - doesn't work with
	   tm5600
	 */

	/* FIXME: This is tuner-dependent */
	int nosif = 0;

	if (nosif) {
		rc = tm6000_load_std(dev, tv_stds[pos].nosif,
				     sizeof(tv_stds[pos].nosif));
	} else {
		rc = tm6000_load_std(dev, tv_stds[pos].sif,
				     sizeof(tv_stds[pos].sif));
	}
	if (rc < 0)
		return rc;
	rc = tm6000_load_std(dev, tv_stds[pos].common,
			     sizeof(tv_stds[pos].common));

	tm6000_set_audio_std(dev, tv_stds[pos].audio_default_std);

	return rc;
}

int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
{
	int i, rc = 0;

	dev->norm = *norm;
	tm6000_get_std_res(dev);

	switch (dev->input) {
	case TM6000_INPUT_TV:
		for (i = 0; i < ARRAY_SIZE(tv_stds); i++) {
			if (*norm & tv_stds[i].id) {
				rc = tm6000_set_tv(dev, i);
				goto ret;
			}
		}
		return -EINVAL;
	case TM6000_INPUT_SVIDEO:
		for (i = 0; i < ARRAY_SIZE(svideo_stds); i++) {
			if (*norm & svideo_stds[i].id) {
				rc = tm6000_load_std(dev, svideo_stds[i].common,
						     sizeof(svideo_stds[i].
							    common));
				tm6000_set_audio_std(dev, svideo_stds[i].audio_default_std);

				goto ret;
			}
		}
		return -EINVAL;
	case TM6000_INPUT_COMPOSITE:
		for (i = 0; i < ARRAY_SIZE(composite_stds); i++) {
			if (*norm & composite_stds[i].id) {
				rc = tm6000_load_std(dev,
						     composite_stds[i].common,
						     sizeof(composite_stds[i].
							    common));
				tm6000_set_audio_std(dev, composite_stds[i].audio_default_std);
				goto ret;
			}
		}
		return -EINVAL;
	}

ret:
	if (rc < 0)
		return rc;

	msleep(40);


	return 0;
}

[-- Attachment #3: tm6000-std_audio.patch --]
[-- Type: text/x-patch, Size: 17636 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index e79a72e..6a571f0 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -173,8 +173,9 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 
 			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
 			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ08_R05_A_STANDARD_MOD, 0x21}, /* FIXME */
+
 			{TM6010_REQ07_R3F_RESET, 0x00},
+
 			{0, 0, 0},
 		},
 	}, {
@@ -233,12 +234,13 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 
 			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
 			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ08_R05_A_STANDARD_MOD, 0x76}, /* FIXME */
+
 			{TM6010_REQ07_R3F_RESET, 0x00},
+
 			{0, 0, 0},
 		},
 	}, {
-		.id = V4L2_STD_SECAM,
+		.id = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
 		.audio_default_std = BG_NICAM,
 		.sif = {
 			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
@@ -292,7 +294,66 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
 
 			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ08_R05_A_STANDARD_MOD, 0x79},
+
+			{TM6010_REQ07_R3F_RESET, 0x00},
+			{0, 0, 0},
+		},
+	}, {
+		.id = V4L2_STD_SECAM_DK,
+		.audio_default_std = DK_NICAM,
+		.sif = {
+			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
+			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
+			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
+			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
+			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
+			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
+			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
+			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
+			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
+			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
+			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
+			{0, 0, 0},
+		},
+		.nosif = {
+			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
+			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
+			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
+			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
+			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
+			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
+			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
+			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
+			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
+			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
+			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
+			{0, 0, 0},
+		},
+		.common = {
+			{TM6010_REQ07_R3F_RESET, 0x01},
+			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
+			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
+			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
+			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
+			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
+			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
+			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
+			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
+			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
+			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
+			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
+			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
+			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
+			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
+			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
+			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
+			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
+			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
+			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
+			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
+
+			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
+
 			{TM6010_REQ07_R3F_RESET, 0x00},
 			{0, 0, 0},
 		},
@@ -352,8 +413,9 @@ static struct tm6000_std_tv_settings tv_stds[] = {
 
 			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
 			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ08_R05_A_STANDARD_MOD, 0x22}, /* FIXME */
+
 			{TM6010_REQ07_R3F_RESET, 0x00},
+
 			{0, 0, 0},
 		},
 	},
@@ -532,6 +594,48 @@ static struct tm6000_std_settings composite_stds[] = {
 			{0, 0, 0},
 		},
 	}, {
+		.id = V4L2_STD_SECAM_DK,
+		.audio_default_std = DK_NICAM,
+		.common = {
+			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
+			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
+			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
+			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
+			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
+			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
+			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
+			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
+			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
+			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
+			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
+
+			{TM6010_REQ07_R3F_RESET, 0x01},
+			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
+			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
+			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
+			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
+			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
+			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
+			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
+			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
+			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
+			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
+			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
+			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
+			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
+			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
+			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
+			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
+			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
+			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
+			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
+			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
+
+			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
+			{TM6010_REQ07_R3F_RESET, 0x00},
+			{0, 0, 0},
+		},
+	}, {
 		.id = V4L2_STD_NTSC,
 		.audio_default_std = BTSC,
 		.common = {
@@ -750,6 +854,48 @@ static struct tm6000_std_settings svideo_stds[] = {
 			{0, 0, 0},
 		},
 	}, {
+		.id = V4L2_STD_SECAM_DK,
+		.audio_default_std = DK_NICAM,
+		.common = {
+			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
+			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
+			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
+			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
+			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
+			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
+			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
+			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
+			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
+			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
+			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
+
+			{TM6010_REQ07_R3F_RESET, 0x01},
+			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
+			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
+			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
+			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
+			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
+			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
+			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
+			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
+			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
+			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
+			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
+			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
+			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
+			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
+			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
+			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
+			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
+			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
+			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
+			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
+
+			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
+			{TM6010_REQ07_R3F_RESET, 0x00},
+			{0, 0, 0},
+		},
+	}, {
 		.id = V4L2_STD_NTSC,
 		.audio_default_std = BTSC,
 		.common = {
@@ -800,129 +946,126 @@ static struct tm6000_std_settings svideo_stds[] = {
 static int tm6000_set_audio_std(struct tm6000_core *dev,
 				enum tm6000_audio_std std)
 {
+	uint8_t areg_02 = 0x04; /* GC1 Fixed gain 0dB */
+	uint8_t areg_05 = 0x09; /* Auto 4.5 = M Japan, Auto 6.5 = DK */
+	uint8_t areg_06 = 0x02; /* Auto de-emphasis, mannual channel mode */
+	uint8_t mono_flag = 0;  /* No mono */
+	uint8_t nicam_flag = 0; /* No NICAM */
+
 	switch (std) {
+#if 0
+	case DK_MONO:
+		mono_flag = 1;
+		break;
+	case DK_A2_1:
+		break;
+	case DK_A2_3:
+		areg_05 = 0x0b;
+		break;
+	case BG_MONO:
+		mono_flag = 1;
+		areg_05 = 0x05;
+		break;
+#endif
 	case BG_NICAM:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x11);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x07;
+		nicam_flag = 1;
 		break;
 	case BTSC:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x02);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
-		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
-		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x02;
 		break;
 	case BG_A2:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x05);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
-		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
-		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x05;
 		break;
 	case DK_NICAM:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x06;
+		nicam_flag = 1;
 		break;
 	case EIAJ:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x03);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x02;
 		break;
 	case FM_RADIO:
 		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
 		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
 		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
 		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x10);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
 		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
 		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
 		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
 		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		return 0;
 		break;
 	case I_NICAM:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x08;
+		nicam_flag = 1;
 		break;
 	case KOREA_A2:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
-		tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
-		tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0xf0);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_05 = 0x04;
 		break;
 	case L_NICAM:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x02);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0a);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x06);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		areg_02 = 0x02; /* GC1 Fixed gain +12dB */
+		areg_05 = 0x0a;
+		nicam_flag = 1;
 		break;
 	}
+
+#if 0
+	switch (tv_audio_mode) {
+	case TV_MONO:
+		areg_06 = (nicam_flag) ? 0x03 : 0x00;
+		break;
+	case TV_LANG_A:
+		areg_06 = 0x00;
+		break;
+	case TV_LANG_B:
+		areg_06 = 0x01;
+		break;
+	}
+#endif
+
+	if (mono_flag)
+		areg_06 = 0x00;
+
+	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
+	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
+	tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, areg_05);
+	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, areg_06);
+	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
+	tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
+	tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
+	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
+	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
+	tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
+	tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
+	tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
+	tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
+	tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
+	tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
+	tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
+	tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
+	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+	tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
+	tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
+	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
+	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
+	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
+	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
+	tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
+	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
+	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+
 	return 0;
 }
 

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [RFC PATCH] Audio standards on tm6000
  2010-10-12 16:54       ` Stefan Ringel
@ 2010-10-13 14:13         ` Dmitri Belimov
       [not found]         ` <20101129174412.08f2001c@glory.local>
  1 sibling, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2010-10-13 14:13 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi Stefan

> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>  
> Am 12.10.2010 20:28, schrieb Dmitri Belimov:
> > Hi
> >
> >> Em 08-10-2010 16:03, Dmitri Belimov escreveu:
> >>> Hi Mauro
> >>>
> >>> Not so good. Audio with this patch has bad white noise
> >>> sometimes and bad quality. I try found better configuration for
> >>> SECAM-DK.
> >>
> >> Ok. Well, feel free to modify it. I think that this approach may
> >> be better, especially if we need to add later some sort of code
> >> to detect and change audio standard for some standards that have
> >> more than one audio standard associated (we needed do to it on
> >> other drivers, in order to work in Russia and other Countries
> >> that use different variants of the audio standard).
> >>
> >> The association between video and audio standard is not complete.
> >> For example, it misses NTSC-Kr and NTSC-Jp.
> >
> > Rework audio. Add SECAM-DK, move SECAM to SECAM-B | SECAM-G. Add
> > some new audio standards and tricks for future, see
> > tm6000_set_audio_std For SECAM-DK it works. Try on your standards.
> >
> >
> > Two files in attach. Patch after latest patch from Mauro and full
> > file tm6000-std.c
> >
> >> Cheers, Mauro.
> >>
> >
> > With my best regards, Dmitry.
> Where is defined "tv_audio_mode"?

This is concept only for future. I didn't understand how to do it.
When audio was working use this for set MONO or audio languige channel.

With my best regards, Dmitry.

> Stefan Ringel
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.12 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>  
> iQEcBAEBAgAGBQJMtJLTAAoJEAWtPFjxMvFGnFAH/Rrk274byzL8IvQd6fjAIl4D
> izk31/k4CY1Y2EdHvygef4ZQxIGE4PGDaOogWEIBLtlHTx6XHUASpiZ8aJW1z7oF
> YQk9rtfC3ZChmaGQDBzwLI+EUg9t7TzeQ8BpC11WxiOapyKLXFv0SdMNs2Y0WHOz
> BNlQkL+9kZ+Hq6nSdJJxOihu+tiwbmvvSd7b/Cz9kdLpSNGr99F+ELbM0g3oU2Ts
> ue7r3FnvHFnpNlV7Ceiuj7jF5ozeo3jSdWJI3S8ph4Wdi3CkPxTnTQXJAU09JU1k
> we8+/TdplP+3Rdf206r/SL4RlI5wiZr/jm4IdLcwLOm/9yHthb89qyuW5upvV6k=
> =LQiB
> -----END PGP SIGNATURE-----
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
       [not found]                               ` <4CFFAD1E.7040004@arcor.de>
@ 2010-12-14  3:23                                 ` Dmitri Belimov
  2010-12-14 16:27                                   ` Stefan Ringel
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-14  3:23 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi

What about my last patch?? This is OK or bad?
Our customers kick me every day with IR remotes.

With my best regards, Dmitry.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-14  3:23                                 ` tm6000 and IR Dmitri Belimov
@ 2010-12-14 16:27                                   ` Stefan Ringel
  2010-12-15  7:46                                     ` Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Ringel @ 2010-12-14 16:27 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Am 14.12.2010 04:23, schrieb Dmitri Belimov:
> Hi
>
> What about my last patch?? This is OK or bad?
> Our customers kick me every day with IR remotes.
>
> With my best regards, Dmitry.
I think, you use the second variant, Dmitry.
Why you doesn't use this key map - RCMAP_BEHOLD.
The power led we can change to a separate function, right. The nec 
initiation looks right and must adding code for tm5600/6000 (going over 
message pipe). rc5 need some code for tm6010 (for tm5600/6000 are the 
hack). And the logic for your remote control is unused  for the second 
variant, but ir->rc_type = rc_type are o.k..
Then the function call usb_set_interface in tm6000_video, can write for 
example:

stop_ir_pipe
usb_set_interface
start_ir_pipe

I will adding vbi_buffer and device in the next, and isoc calculating 
without video_buffer size.

Stefan Ringel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-14 16:27                                   ` Stefan Ringel
@ 2010-12-15  7:46                                     ` Dmitri Belimov
  2010-12-15 15:52                                       ` Stefan Ringel
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-15  7:46 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi Stefan

> Am 14.12.2010 04:23, schrieb Dmitri Belimov:
> > Hi
> >
> > What about my last patch?? This is OK or bad?
> > Our customers kick me every day with IR remotes.
> >
> > With my best regards, Dmitry.
> I think, you use the second variant, Dmitry.
> Why you doesn't use this key map - RCMAP_BEHOLD.

No this remotes is different. RCMAP_BEHOLD has more buttons and some other scancodes.
People from linux community who was made this keymap and function for reading data from
IR decoder has error with scancode. 
Our true address of scancode is
0x86 0x6B
They wrote 
0x6B 0x86
Need fix some code of the saa7134-input and RCMAP_BEHOLD keytable.

RCMAP_BEHOLD_WANDER same as RCMAP_BEHOLD_COLUMBUS but
from IR decoder the saa7134 received only one byte of scancode.
Need rework saa7134-input too for get address and restore full scancodes for extended NEC full
scancodes.

I'll make it after some time.

> The power led we can change to a separate function, right. 

Ok

> The nec initiation looks right and must adding code for tm5600/6000 (going
> over message pipe).

I haven't USB stick with tm5600/6000 for test. Need people with this TV cards.

> rc5 need some code for tm6010 (for tm5600/6000 are the hack).

I didn't touch this code because I haven't RC5 remotes and tm5600/6000

> And the logic for your remote control is unused  for
> the second variant, but ir->rc_type = rc_type are o.k..

I think your mean is wrong. Our IR remotes send extended NEC it is 4 bytes.
We removed inverted 4 byte and now we have 3 bytes from remotes. I think we
must have full RCMAP with this 3 bytes from remotes. And use this remotes with some
different IR recievers like some TV cards and LIRC-hardware and other.
No need different RCMAP for the same remotes to different IR recievers like now.

If we use second variant I can't use RCMAP_BEHOLD because it has full 3 bytes scancodes. 
As you wrote.

> Then the function call usb_set_interface in tm6000_video, can write
> for example:
> 
> stop_ir_pipe
> usb_set_interface
> start_ir_pipe

Ok, I'll try.

> I will adding vbi_buffer and device in the next, and isoc calculating 
> without video_buffer size.

I try add radio.
 
With my best regards, Dmitry.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-15  7:46                                     ` Dmitri Belimov
@ 2010-12-15 15:52                                       ` Stefan Ringel
  2010-12-16  3:26                                         ` Dmitri Belimov
  2010-12-16  9:38                                         ` Dmitri Belimov
  0 siblings, 2 replies; 36+ messages in thread
From: Stefan Ringel @ 2010-12-15 15:52 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Am 15.12.2010 08:46, schrieb Dmitri Belimov:
> Hi Stefan
>
>> Am 14.12.2010 04:23, schrieb Dmitri Belimov:
>>> Hi
>>>
>>> What about my last patch?? This is OK or bad?
>>> Our customers kick me every day with IR remotes.
>>>
>>> With my best regards, Dmitry.
>> I think, you use the second variant, Dmitry.
>> Why you doesn't use this key map - RCMAP_BEHOLD.
> No this remotes is different. RCMAP_BEHOLD has more buttons and some other scancodes.
> People from linux community who was made this keymap and function for reading data from
> IR decoder has error with scancode.
> Our true address of scancode is
> 0x86 0x6B
> They wrote
> 0x6B 0x86
> Need fix some code of the saa7134-input and RCMAP_BEHOLD keytable.
>
> RCMAP_BEHOLD_WANDER same as RCMAP_BEHOLD_COLUMBUS but
> from IR decoder the saa7134 received only one byte of scancode.
> Need rework saa7134-input too for get address and restore full scancodes for extended NEC full
> scancodes.
>
> I'll make it after some time.
>
>> The power led we can change to a separate function, right.
> Ok
>
>> The nec initiation looks right and must adding code for tm5600/6000 (going
>> over message pipe).
> I haven't USB stick with tm5600/6000 for test. Need people with this TV cards.
>
then add a todo line.
>> rc5 need some code for tm6010 (for tm5600/6000 are the hack).
> I didn't touch this code because I haven't RC5 remotes and tm5600/6000
>
>> And the logic for your remote control is unused  for
>> the second variant, but ir->rc_type = rc_type are o.k.
but the line ir->rc_type = rc_type; are o.k.

> I think your mean is wrong. Our IR remotes send extended NEC it is 4 bytes.
> We removed inverted 4 byte and now we have 3 bytes from remotes. I think we
> must have full RCMAP with this 3 bytes from remotes. And use this remotes with some
> different IR recievers like some TV cards and LIRC-hardware and other.
> No need different RCMAP for the same remotes to different IR recievers like now.
Your change doesn't work with my terratec remote control !!
> If we use second variant I can't use RCMAP_BEHOLD because it has full 3 bytes scancodes.
> As you wrote.
>
And if you use two bytes rc map table. We have add filter for address 
and commands to pass all. With an external tool can change the map ( 
ir_keytable). Why you will use more than two bytes.
>> Then the function call usb_set_interface in tm6000_video, can write
>> for example:
>>
>> stop_ir_pipe
>> usb_set_interface
>> start_ir_pipe
> Ok, I'll try.
>
>> I will adding vbi_buffer and device in the next, and isoc calculating
>> without video_buffer size.
> I try add radio.
>
> With my best regards, Dmitry.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-15 15:52                                       ` Stefan Ringel
@ 2010-12-16  3:26                                         ` Dmitri Belimov
  2010-12-16  9:38                                         ` Dmitri Belimov
  1 sibling, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-16  3:26 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi Stefan

> >> The nec initiation looks right and must adding code for
> >> tm5600/6000 (going over message pipe).
> > I haven't USB stick with tm5600/6000 for test. Need people with
> > this TV cards.
> >
> then add a todo line.

I'll do it.

> >> rc5 need some code for tm6010 (for tm5600/6000 are the hack).
> > I didn't touch this code because I haven't RC5 remotes and
> > tm5600/6000
> >
> >> And the logic for your remote control is unused  for
> >> the second variant, but ir->rc_type = rc_type are o.k.
> but the line ir->rc_type = rc_type; are o.k.
> 
> > I think your mean is wrong. Our IR remotes send extended NEC it is
> > 4 bytes. We removed inverted 4 byte and now we have 3 bytes from
> > remotes. I think we must have full RCMAP with this 3 bytes from
> > remotes. And use this remotes with some different IR recievers like
> > some TV cards and LIRC-hardware and other. No need different RCMAP
> > for the same remotes to different IR recievers like now.
> Your change doesn't work with my terratec remote control !!

I'll try solve this problem don't worry.

> > If we use second variant I can't use RCMAP_BEHOLD because it has
> > full 3 bytes scancodes. As you wrote.
> >
> And if you use two bytes rc map table. We have add filter for address 
> and commands to pass all. With an external tool can change the map ( 
> ir_keytable). Why you will use more than two bytes.

With my last code this tool is working. When you call change_protocol new
value of address stored. But if a keytable of remotes hasn't full scancodes it
doesn't work

How to main IR core search scancodes in RCMAP keytable?
I think it search full equal scancode value with returned from tm6000.

Example:
defined keytable:
0x86 0x6B 0x00

tm6000 read IR data
0x86 0x00

When return 0x86 0x00 to IR core a key is unknown because
0x86 0x6B 0x00 != 0x86 0x00

I think we can have two different solutions:

1. My variant. When init IR tm6000, get full address from a keytable, store it. After key filtering
restore full scancode and return it to IR core -> 0x86 0x6B 0x00. A keytable must has really full scancodes.

2. More simple. A keytable has only data byte. Get IR data and return only data byte without filtering because
a keytable hasn't this information. This is bad the TV card can do some task by other IR remotes. Or add some place where 
stored filter information and update filter when keytable replaced.

With my best regards, Dmitry.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-15 15:52                                       ` Stefan Ringel
  2010-12-16  3:26                                         ` Dmitri Belimov
@ 2010-12-16  9:38                                         ` Dmitri Belimov
  2010-12-16 17:12                                           ` Stefan Ringel
  1 sibling, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-16  9:38 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]

Hi

> > I think your mean is wrong. Our IR remotes send extended NEC it is
> > 4 bytes. We removed inverted 4 byte and now we have 3 bytes from
> > remotes. I think we must have full RCMAP with this 3 bytes from
> > remotes. And use this remotes with some different IR recievers like
> > some TV cards and LIRC-hardware and other. No need different RCMAP
> > for the same remotes to different IR recievers like now.
> Your change doesn't work with my terratec remote control !!

I found what happens. Try my new patch.

What about NEC. Original NEC send
address (inverted address) key (inverted key)
this is realy old standart now all remotes use extended NEC 
(adress high) (address low) key (inverted key)
The trident 5600/6000/6010 use old protocol but didn't test inverted address byte.

I think much better discover really address value and write it to keytable.
For your remotes I add low address byte. This value is incorrent but usefull for tm6000.
When you found correct value update keytable.

> >> Then the function call usb_set_interface in tm6000_video, can write
> >> for example:
> >>
> >> stop_ir_pipe
> >> usb_set_interface
> >> start_ir_pipe
> > Ok, I'll try.

See dmesg. I was add function for start/stop interrupt urbs
All works well.

With my best regards, Dmitry.

[-- Attachment #2: rc-behold-wander.c --]
[-- Type: text/x-c++src, Size: 3028 bytes --]

/* behold-wander.h - Keytable for behold_wander Remote Controller
 *
 * keymap imported from ir-keymaps.c
 *
 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include <media/rc-map.h>

/* Beholder Intl. Ltd. 2010
 * Dmitry Belimov d.belimov@google.com
 * Keytable is used by BeholdTV Wander/Voyage
 * The "ascii-art picture" below (in comments, first row
 * is the keycode in hex, and subsequent row(s) shows
 * the button labels (several variants when appropriate)
 * helps to descide which keycodes to assign to the buttons.
 */

static struct rc_map_table behold_wander[] = {

	/*  0x13   0x11   0x1C   0x12  *
	 *  Mute  Source  TV/FM  Power *
	 *                             */

	{ 0x866b13, KEY_MUTE },
	{ 0x866b11, KEY_PROPS },
	{ 0x866b1C, KEY_TUNER },	/* KEY_TV/KEY_RADIO	*/
	{ 0x866b12, KEY_POWER },

	/*  0x01    0x02    0x03  0x0D    *
	 *   1       2       3   Stereo   *
	 *                        	  *
	 *  0x04    0x05    0x06  0x19    *
	 *   4       5       6   Snapshot *
	 *                        	  *
	 *  0x07    0x08    0x09  0x10    *
	 *   7       8       9    Zoom 	  *
	 *                                */
	{ 0x866b01, KEY_1 },
	{ 0x866b02, KEY_2 },
	{ 0x866b03, KEY_3 },
	{ 0x866b0D, KEY_SETUP },	  /* Setup key */
	{ 0x866b04, KEY_4 },
	{ 0x866b05, KEY_5 },
	{ 0x866b06, KEY_6 },
	{ 0x866b19, KEY_CAMERA },	/* Snapshot key */
	{ 0x866b07, KEY_7 },
	{ 0x866b08, KEY_8 },
	{ 0x866b09, KEY_9 },
	{ 0x866b10, KEY_ZOOM },

	/*  0x0A    0x00    0x0B       0x0C   *
	 * RECALL    0    ChannelUp  VolumeUp *
	 *                                    */
	{ 0x866b0A, KEY_AGAIN },
	{ 0x866b00, KEY_0 },
	{ 0x866b0B, KEY_CHANNELUP },
	{ 0x866b0C, KEY_VOLUMEUP },

	/*   0x1B      0x1D      0x15        0x18     *
	 * Timeshift  Record  ChannelDown  VolumeDown *
	 *                                            */

	{ 0x866b1B, KEY_TIME },
	{ 0x866b1D, KEY_RECORD },
	{ 0x866b15, KEY_CHANNELDOWN },
	{ 0x866b18, KEY_VOLUMEDOWN },

	/*   0x0E   0x1E     0x0F     0x1A  *
	 *   Stop   Pause  Previouse  Next  *
	 *                                  */

	{ 0x866b0E, KEY_STOP },
	{ 0x866b1E, KEY_PAUSE },
	{ 0x866b0F, KEY_PREVIOUS },
	{ 0x866b1A, KEY_NEXT },

};

static struct rc_map_list behold_wander_map = {
	.map = {
		.scan    = behold_wander,
		.size    = ARRAY_SIZE(behold_wander),
		.rc_type = RC_TYPE_NEC,	/* Legacy IR type */
		.name    = RC_MAP_BEHOLD_WANDER,
	}
};

static int __init init_rc_map_behold_wander(void)
{
	return rc_map_register(&behold_wander_map);
}

static void __exit exit_rc_map_behold_wander(void)
{
	rc_map_unregister(&behold_wander_map);
}

module_init(init_rc_map_behold_wander)
module_exit(exit_rc_map_behold_wander)

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");

[-- Attachment #3: tm6000_ir_behold_04.diff --]
[-- Type: text/x-patch, Size: 16096 bytes --]

diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile
index 3194d39..cf7622f 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
 			rc-azurewave-ad-tu700.o \
 			rc-behold.o \
 			rc-behold-columbus.o \
+			rc-behold-wander.o \
 			rc-budget-ci-old.o \
 			rc-cinergy-1400.o \
 			rc-cinergy.o \
diff --git a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
index 26f114c..bbcb698 100644
--- a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
@@ -14,69 +14,76 @@
 
 /* Terratec Cinergy Hybrid T USB XS FM
    Mauro Carvalho Chehab <mchehab@redhat.com>
+
+   TODO: This IR remote use extended NEC protocol
+         the tm6000 can read only 1 and 3 bytes of them
+         the 4 byte is invert of the 3 byte. We unknown the 2 byte.
+         Need test this remotes with much better IR receiver
+         and determine the 2 byte. Now the 2 byte is 0xff for compatibility.
+                             Dmitry Belimov <d.belimov@gmail.com>
  */
 
 static struct rc_map_table nec_terratec_cinergy_xs[] = {
-	{ 0x1441, KEY_HOME},
-	{ 0x1401, KEY_POWER2},
-
-	{ 0x1442, KEY_MENU},		/* DVD menu */
-	{ 0x1443, KEY_SUBTITLE},
-	{ 0x1444, KEY_TEXT},		/* Teletext */
-	{ 0x1445, KEY_DELETE},
-
-	{ 0x1402, KEY_1},
-	{ 0x1403, KEY_2},
-	{ 0x1404, KEY_3},
-	{ 0x1405, KEY_4},
-	{ 0x1406, KEY_5},
-	{ 0x1407, KEY_6},
-	{ 0x1408, KEY_7},
-	{ 0x1409, KEY_8},
-	{ 0x140a, KEY_9},
-	{ 0x140c, KEY_0},
-
-	{ 0x140b, KEY_TUNER},		/* AV */
-	{ 0x140d, KEY_MODE},		/* A.B */
-
-	{ 0x1446, KEY_TV},
-	{ 0x1447, KEY_DVD},
-	{ 0x1449, KEY_VIDEO},
-	{ 0x144a, KEY_RADIO},		/* Music */
-	{ 0x144b, KEY_CAMERA},		/* PIC */
-
-	{ 0x1410, KEY_UP},
-	{ 0x1411, KEY_LEFT},
-	{ 0x1412, KEY_OK},
-	{ 0x1413, KEY_RIGHT},
-	{ 0x1414, KEY_DOWN},
-
-	{ 0x140f, KEY_EPG},
-	{ 0x1416, KEY_INFO},
-	{ 0x144d, KEY_BACKSPACE},
-
-	{ 0x141c, KEY_VOLUMEUP},
-	{ 0x141e, KEY_VOLUMEDOWN},
-
-	{ 0x144c, KEY_PLAY},
-	{ 0x141d, KEY_MUTE},
-
-	{ 0x141b, KEY_CHANNELUP},
-	{ 0x141f, KEY_CHANNELDOWN},
-
-	{ 0x1417, KEY_RED},
-	{ 0x1418, KEY_GREEN},
-	{ 0x1419, KEY_YELLOW},
-	{ 0x141a, KEY_BLUE},
-
-	{ 0x1458, KEY_RECORD},
-	{ 0x1448, KEY_STOP},
-	{ 0x1440, KEY_PAUSE},
-
-	{ 0x1454, KEY_LAST},
-	{ 0x144e, KEY_REWIND},
-	{ 0x144f, KEY_FASTFORWARD},
-	{ 0x145c, KEY_NEXT},
+	{ 0x14ff41, KEY_HOME},
+	{ 0x14ff01, KEY_POWER2},
+
+	{ 0x14ff42, KEY_MENU},		/* DVD menu */
+	{ 0x14ff43, KEY_SUBTITLE},
+	{ 0x14ff44, KEY_TEXT},		/* Teletext */
+	{ 0x14ff45, KEY_DELETE},
+
+	{ 0x14ff02, KEY_1},
+	{ 0x14ff03, KEY_2},
+	{ 0x14ff04, KEY_3},
+	{ 0x14ff05, KEY_4},
+	{ 0x14ff06, KEY_5},
+	{ 0x14ff07, KEY_6},
+	{ 0x14ff08, KEY_7},
+	{ 0x14ff09, KEY_8},
+	{ 0x14ff0a, KEY_9},
+	{ 0x14ff0c, KEY_0},
+
+	{ 0x14ff0b, KEY_TUNER},		/* AV */
+	{ 0x14ff0d, KEY_MODE},		/* A.B */
+
+	{ 0x14ff46, KEY_TV},
+	{ 0x14ff47, KEY_DVD},
+	{ 0x14ff49, KEY_VIDEO},
+	{ 0x14ff4a, KEY_RADIO},		/* Music */
+	{ 0x14ff4b, KEY_CAMERA},		/* PIC */
+
+	{ 0x14ff10, KEY_UP},
+	{ 0x14ff11, KEY_LEFT},
+	{ 0x14ff12, KEY_OK},
+	{ 0x14ff13, KEY_RIGHT},
+	{ 0x14ff14, KEY_DOWN},
+
+	{ 0x14ff0f, KEY_EPG},
+	{ 0x14ff16, KEY_INFO},
+	{ 0x14ff4d, KEY_BACKSPACE},
+
+	{ 0x14ff1c, KEY_VOLUMEUP},
+	{ 0x14ff1e, KEY_VOLUMEDOWN},
+
+	{ 0x14ff4c, KEY_PLAY},
+	{ 0x14ff1d, KEY_MUTE},
+
+	{ 0x14ff1b, KEY_CHANNELUP},
+	{ 0x14ff1f, KEY_CHANNELDOWN},
+
+	{ 0x14ff17, KEY_RED},
+	{ 0x14ff18, KEY_GREEN},
+	{ 0x14ff19, KEY_YELLOW},
+	{ 0x14ff1a, KEY_BLUE},
+
+	{ 0x14ff58, KEY_RECORD},
+	{ 0x14ff48, KEY_STOP},
+	{ 0x14ff40, KEY_PAUSE},
+
+	{ 0x14ff54, KEY_LAST},
+	{ 0x14ff4e, KEY_REWIND},
+	{ 0x14ff4f, KEY_FASTFORWARD},
+	{ 0x14ff5c, KEY_NEXT},
 };
 
 static struct rc_map_list nec_terratec_cinergy_xs_map = {
diff --git a/drivers/staging/tm6000/TODO b/drivers/staging/tm6000/TODO
index 34780fc..135d0ea 100644
--- a/drivers/staging/tm6000/TODO
+++ b/drivers/staging/tm6000/TODO
@@ -1,4 +1,6 @@
 There a few things to do before putting this driver in production:
+	- IR NEC with tm5600/6000 TV cards
+	- IR RC5 with tm5600/6000/6010 TV cards
 	- CodingStyle;
 	- Fix audio;
 	- Fix some panic/OOPS conditions.
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 1c9374a..59ee241 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -239,6 +239,7 @@ struct tm6000_board tm6000_boards[] = {
 			.demod_reset	= TM6010_GPIO_1,
 			.power_led	= TM6010_GPIO_6,
 		},
+		.ir_codes = RC_MAP_BEHOLD_WANDER,
 	},
 	[TM6010_BOARD_BEHOLD_VOYAGER] = {
 		.name         = "Beholder Voyager TV/FM USB2.0",
@@ -256,6 +257,7 @@ struct tm6000_board tm6000_boards[] = {
 			.tuner_reset	= TM6010_GPIO_0,
 			.power_led	= TM6010_GPIO_6,
 		},
+		.ir_codes = RC_MAP_BEHOLD_WANDER,
 	},
 	[TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE] = {
 		.name         = "Terratec Cinergy Hybrid XE / Cinergy Hybrid-Stick",
@@ -328,6 +330,47 @@ struct usb_device_id tm6000_id_table[] = {
 	{ },
 };
 
+/* Control power led for show some activity */
+void tm6000_flash_led(struct tm6000_core *dev, u8 state)
+{
+	/* Power LED unconfigured */
+	if (!dev->gpio.power_led)
+		return;
+
+	/* ON Power LED */
+	if (state) {
+		switch (dev->model) {
+		case TM6010_BOARD_HAUPPAUGE_900H:
+		case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+		case TM6010_BOARD_TWINHAN_TU501:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x00);
+			break;
+		case TM6010_BOARD_BEHOLD_WANDER:
+		case TM6010_BOARD_BEHOLD_VOYAGER:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x01);
+			break;
+		}
+	}
+	/* OFF Power LED */
+	else {
+		switch (dev->model) {
+		case TM6010_BOARD_HAUPPAUGE_900H:
+		case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+		case TM6010_BOARD_TWINHAN_TU501:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x01);
+			break;
+		case TM6010_BOARD_BEHOLD_WANDER:
+		case TM6010_BOARD_BEHOLD_VOYAGER:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x00);
+			break;
+		}
+	}
+}
+
 /* Tuner callback to provide the proper gpio changes needed for xc5000 */
 int tm6000_xc5000_callback(void *ptr, int component, int command, int arg)
 {
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c
index e02ea67..cae1f96 100644
--- a/drivers/staging/tm6000/tm6000-input.c
+++ b/drivers/staging/tm6000/tm6000-input.c
@@ -37,6 +37,10 @@ static unsigned int enable_ir = 1;
 module_param(enable_ir, int, 0644);
 MODULE_PARM_DESC(enable_ir, "enable ir (default is enable)");
 
+/* number of 50ms for ON-OFF-ON power led */
+/* show IR activity */
+#define PWLED_OFF 2
+
 #undef dprintk
 
 #define dprintk(fmt, arg...) \
@@ -45,7 +49,7 @@ MODULE_PARM_DESC(enable_ir, "enable ir (default is enable)");
 	}
 
 struct tm6000_ir_poll_result {
-	u16 rc_data;
+	u32 rc_data;
 };
 
 struct tm6000_IR {
@@ -59,6 +63,9 @@ struct tm6000_IR {
 	struct delayed_work	work;
 	u8			wait:1;
 	u8			key:1;
+	u8			pwled:1;
+	u8			pwledcnt;
+	u16			key_addr;
 	struct urb		*int_urb;
 	u8			*urb_data;
 
@@ -89,26 +96,49 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
 	u8 buf[10];
 	int rc;
 
-	/* hack */
-	buf[0] = 0xff;
-	buf[1] = 0xff;
-	buf[2] = 0xf2;
-	buf[3] = 0x2b;
-	buf[4] = 0x20;
-	buf[5] = 0x35;
-	buf[6] = 0x60;
-	buf[7] = 0x04;
-	buf[8] = 0xc0;
-	buf[9] = 0x08;
-
-	rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
-		USB_RECIP_DEVICE, REQ_00_SET_IR_VALUE, 0, 0, buf, 0x0a);
-	msleep(100);
-
-	if (rc < 0) {
-		printk(KERN_INFO "IR configuration failed");
-		return rc;
+	switch (ir->rc_type) {
+	case RC_TYPE_NEC:
+		/* Setup IR decoder for NEC standard 12MHz system clock */
+		/* IR_LEADER_CNT = 0.9ms             */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_LEADER1, 0xaa);
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_LEADER0, 0x30);
+		/* IR_PULSE_CNT = 0.7ms              */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_PULSE_CNT1, 0x20);
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_PULSE_CNT0, 0xd0);
+		/* Remote WAKEUP = enable */
+		tm6000_set_reg(dev, TM6010_REQ07_RE5_REMOTE_WAKEUP, 0xfe);
+		/* IR_WKUP_SEL = Low byte in decoded IR data */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_WAKEUP_SEL, 0xff);
+		/* IR_WKU_ADD code */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_WAKEUP_ADD, 0xff);
+		tm6000_flash_led(dev, 0);
+		msleep(100);
+		tm6000_flash_led(dev, 1);
+		break;
+	default:
+		/* hack */
+		buf[0] = 0xff;
+		buf[1] = 0xff;
+		buf[2] = 0xf2;
+		buf[3] = 0x2b;
+		buf[4] = 0x20;
+		buf[5] = 0x35;
+		buf[6] = 0x60;
+		buf[7] = 0x04;
+		buf[8] = 0xc0;
+		buf[9] = 0x08;
+
+		rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
+			USB_RECIP_DEVICE, REQ_00_SET_IR_VALUE, 0, 0, buf, 0x0a);
+		msleep(100);
+
+		if (rc < 0) {
+			printk(KERN_INFO "IR configuration failed");
+			return rc;
+		}
+		break;
 	}
+
 	return 0;
 }
 
@@ -143,10 +173,21 @@ static int default_polling_getkey(struct tm6000_IR *ir,
 		return 0;
 
 	if (&dev->int_in) {
-		if (ir->rc_type == RC_TYPE_RC5)
+		switch (ir->rc_type) {
+		case RC_TYPE_RC5:
 			poll_result->rc_data = ir->urb_data[0];
-		else
-			poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8;
+			break;
+		case RC_TYPE_NEC:
+			if (ir->urb_data[1] == ((ir->key_addr >> 8) & 0xff)) {
+				poll_result->rc_data = ir->urb_data[0]
+							| ir->key_addr << 8;
+			}
+			break;
+		default:
+			poll_result->rc_data = ir->urb_data[0]
+					| ir->urb_data[1] << 8;
+			break;
+		}
 	} else {
 		tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 0);
 		msleep(10);
@@ -186,6 +227,7 @@ static int default_polling_getkey(struct tm6000_IR *ir,
 
 static void tm6000_ir_handle_key(struct tm6000_IR *ir)
 {
+	struct tm6000_core *dev = ir->dev;
 	int result;
 	struct tm6000_ir_poll_result poll_result;
 
@@ -198,9 +240,22 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir)
 
 	dprintk("ir->get_key result data=%04x\n", poll_result.rc_data);
 
+	if (ir->pwled) {
+		if (ir->pwledcnt >= PWLED_OFF) {
+			ir->pwled = 0;
+			ir->pwledcnt = 0;
+			tm6000_flash_led(dev, 1);
+		}
+		else
+			ir->pwledcnt += 1;
+	}
+
 	if (ir->key) {
 		rc_keydown(ir->rc, poll_result.rc_data, 0);
 		ir->key = 0;
+		ir->pwled = 1;
+		ir->pwledcnt = 0;
+		tm6000_flash_led(dev, 0);
 	}
 	return;
 }
@@ -234,19 +289,80 @@ int tm6000_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
 {
 	struct tm6000_IR *ir = rc->priv;
 
+	if (!ir)
+		return 0;
+
+	if ((rc->rc_map.scan) && (rc_type == RC_TYPE_NEC))
+		ir->key_addr = ((rc->rc_map.scan[0].scancode >> 8) & 0xffff);
+
 	ir->get_key = default_polling_getkey;
+	ir->rc_type = rc_type;
 
 	tm6000_ir_config(ir);
 	/* TODO */
 	return 0;
 }
 
+int tm6000_ir_int_start(struct tm6000_core *dev)
+{
+	struct tm6000_IR *ir = dev->ir;
+	int pipe, size;
+	int err = -ENOMEM;
+
+
+	if (!ir)
+		return -ENODEV;
+
+	ir->int_urb = usb_alloc_urb(0, GFP_KERNEL);
+
+	pipe = usb_rcvintpipe(dev->udev,
+		dev->int_in.endp->desc.bEndpointAddress
+		& USB_ENDPOINT_NUMBER_MASK);
+
+	size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
+	dprintk("IR max size: %d\n", size);
+
+	ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
+	if (ir->int_urb->transfer_buffer == NULL) {
+		usb_free_urb(ir->int_urb);
+		return err;
+	}
+	dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
+	usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
+		ir->int_urb->transfer_buffer, size,
+		tm6000_ir_urb_received, dev,
+		dev->int_in.endp->desc.bInterval);
+	err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
+	if (err) {
+		kfree(ir->int_urb->transfer_buffer);
+		usb_free_urb(ir->int_urb);
+		return err;
+	}
+	ir->urb_data = kzalloc(size, GFP_KERNEL);
+
+	return 0;
+}
+
+void tm6000_ir_int_stop(struct tm6000_core *dev)
+{
+	struct tm6000_IR *ir = dev->ir;
+
+	if (!ir)
+		return;
+
+	usb_kill_urb(ir->int_urb);
+	kfree(ir->int_urb->transfer_buffer);
+	usb_free_urb(ir->int_urb);
+	ir->int_urb = NULL;
+	kfree(ir->urb_data);
+	ir->urb_data = NULL;
+}
+
 int tm6000_ir_init(struct tm6000_core *dev)
 {
 	struct tm6000_IR *ir;
 	struct rc_dev *rc;
 	int err = -ENOMEM;
-	int pipe, size;
 
 	if (!enable_ir)
 		return -ENODEV;
@@ -276,6 +392,9 @@ int tm6000_ir_init(struct tm6000_core *dev)
 	rc->driver_type = RC_DRIVER_SCANCODE;
 
 	ir->polling = 50;
+	ir->pwled = 0;
+	ir->pwledcnt = 0;
+
 
 	snprintf(ir->name, sizeof(ir->name), "tm5600/60x0 IR (%s)",
 						dev->name);
@@ -298,32 +417,10 @@ int tm6000_ir_init(struct tm6000_core *dev)
 	if (&dev->int_in) {
 		dprintk("IR over int\n");
 
-		ir->int_urb = usb_alloc_urb(0, GFP_KERNEL);
-
-		pipe = usb_rcvintpipe(dev->udev,
-			dev->int_in.endp->desc.bEndpointAddress
-			& USB_ENDPOINT_NUMBER_MASK);
+		err = tm6000_ir_int_start(dev);
 
-		size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
-		dprintk("IR max size: %d\n", size);
-
-		ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
-		if (ir->int_urb->transfer_buffer == NULL) {
-			usb_free_urb(ir->int_urb);
-			goto out;
-		}
-		dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
-		usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
-			ir->int_urb->transfer_buffer, size,
-			tm6000_ir_urb_received, dev,
-			dev->int_in.endp->desc.bInterval);
-		err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
-		if (err) {
-			kfree(ir->int_urb->transfer_buffer);
-			usb_free_urb(ir->int_urb);
+		if (err)
 			goto out;
-		}
-		ir->urb_data = kzalloc(size, GFP_KERNEL);
 	}
 
 	/* ir register */
@@ -352,12 +449,7 @@ int tm6000_ir_fini(struct tm6000_core *dev)
 	rc_unregister_device(ir->rc);
 
 	if (ir->int_urb) {
-		usb_kill_urb(ir->int_urb);
-		kfree(ir->int_urb->transfer_buffer);
-		usb_free_urb(ir->int_urb);
-		ir->int_urb = NULL;
-		kfree(ir->urb_data);
-		ir->urb_data = NULL;
+		tm6000_ir_int_stop(dev);
 	}
 
 	kfree(ir);
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index c5690b2..b06701b 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -545,11 +545,16 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
 
 	/* De-allocates all pending stuff */
 	tm6000_uninit_isoc(dev);
+	/* Stop interrupt USB pipe */
+	tm6000_ir_int_stop(dev);
 
 	usb_set_interface(dev->udev,
 			  dev->isoc_in.bInterfaceNumber,
 			  dev->isoc_in.bAlternateSetting);
 
+	/* Start interrupt USB pipe */
+	tm6000_ir_int_start(dev);
+
 	pipe = usb_rcvisocpipe(dev->udev,
 			       dev->isoc_in.endp->desc.bEndpointAddress &
 			       USB_ENDPOINT_NUMBER_MASK);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 46017b6..bf11eee 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -266,6 +266,7 @@ struct tm6000_fh {
 int tm6000_tuner_callback(void *ptr, int component, int command, int arg);
 int tm6000_xc5000_callback(void *ptr, int component, int command, int arg);
 int tm6000_cards_setup(struct tm6000_core *dev);
+void tm6000_flash_led(struct tm6000_core *dev, u8 state);
 
 /* In tm6000-core.c */
 
@@ -332,6 +333,8 @@ int tm6000_queue_init(struct tm6000_core *dev);
 int tm6000_ir_init(struct tm6000_core *dev);
 int tm6000_ir_fini(struct tm6000_core *dev);
 void tm6000_ir_wait(struct tm6000_core *dev, u8 state);
+int tm6000_ir_int_start(struct tm6000_core *dev);
+void tm6000_ir_int_stop(struct tm6000_core *dev);
 
 /* Debug stuff */
 
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 1a3d51d..239a309 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -70,6 +70,7 @@ void rc_map_init(void);
 #define RC_MAP_AVERTV_303                "rc-avertv-303"
 #define RC_MAP_AZUREWAVE_AD_TU700        "rc-azurewave-ad-tu700"
 #define RC_MAP_BEHOLD_COLUMBUS           "rc-behold-columbus"
+#define RC_MAP_BEHOLD_WANDER             "rc-behold-wander"
 #define RC_MAP_BEHOLD                    "rc-behold"
 #define RC_MAP_BUDGET_CI_OLD             "rc-budget-ci-old"
 #define RC_MAP_CINERGY_1400              "rc-cinergy-1400"

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-16  9:38                                         ` Dmitri Belimov
@ 2010-12-16 17:12                                           ` Stefan Ringel
  2010-12-17  1:46                                             ` Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Ringel @ 2010-12-16 17:12 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Am 16.12.2010 10:38, schrieb Dmitri Belimov:
> Hi
>
>>> I think your mean is wrong. Our IR remotes send extended NEC it is
>>> 4 bytes. We removed inverted 4 byte and now we have 3 bytes from
>>> remotes. I think we must have full RCMAP with this 3 bytes from
>>> remotes. And use this remotes with some different IR recievers like
>>> some TV cards and LIRC-hardware and other. No need different RCMAP
>>> for the same remotes to different IR recievers like now.
>> Your change doesn't work with my terratec remote control !!
> I found what happens. Try my new patch.
>
> What about NEC. Original NEC send
> address (inverted address) key (inverted key)
> this is realy old standart now all remotes use extended NEC
> (adress high) (address low) key (inverted key)
> The trident 5600/6000/6010 use old protocol but didn't test inverted address byte.
>
> I think much better discover really address value and write it to keytable.
> For your remotes I add low address byte. This value is incorrent but usefull for tm6000.
> When you found correct value update keytable.
>
That is not acceptable. Have you forgotten what Mauro have written? The 
Terratec rc map are use from other devices. The best are only the 
received data without additional data. And I think the Trident chip send 
only compatibly data (send all extended data like standard data). The 
device decoded the protocols not the driver.
>>>> Then the function call usb_set_interface in tm6000_video, can write
>>>> for example:
>>>>
>>>> stop_ir_pipe
>>>> usb_set_interface
>>>> start_ir_pipe
>>> Ok, I'll try.
> See dmesg. I was add function for start/stop interrupt urbs
> All works well.
>
> With my best regards, Dmitry.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-16 17:12                                           ` Stefan Ringel
@ 2010-12-17  1:46                                             ` Dmitri Belimov
  2010-12-17  5:18                                               ` Stefan Ringel
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-17  1:46 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Hi Stefan

> Am 16.12.2010 10:38, schrieb Dmitri Belimov:
> > Hi
> >
> >>> I think your mean is wrong. Our IR remotes send extended NEC it is
> >>> 4 bytes. We removed inverted 4 byte and now we have 3 bytes from
> >>> remotes. I think we must have full RCMAP with this 3 bytes from
> >>> remotes. And use this remotes with some different IR recievers
> >>> like some TV cards and LIRC-hardware and other. No need different
> >>> RCMAP for the same remotes to different IR recievers like now.
> >> Your change doesn't work with my terratec remote control !!
> > I found what happens. Try my new patch.
> >
> > What about NEC. Original NEC send
> > address (inverted address) key (inverted key)
> > this is realy old standart now all remotes use extended NEC
> > (adress high) (address low) key (inverted key)
> > The trident 5600/6000/6010 use old protocol but didn't test
> > inverted address byte.
> >
> > I think much better discover really address value and write it to
> > keytable. For your remotes I add low address byte. This value is
> > incorrent but usefull for tm6000. When you found correct value
> > update keytable.
> >
> That is not acceptable. Have you forgotten what Mauro have written?
> The Terratec rc map are use from other devices.

NO
The RC_MAP_NEC_TERRATEC_CINERGY_XS used only in tm6000 module.
My patch didn't kill support any other devices.

> The best are only the 
> received data without additional data. And I think the Trident chip
> send only compatibly data (send all extended data like standard
> data). The device decoded the protocols not the driver.

You can't use this remotes with normal working IR receivers because this receivers
returned FULL scancodes. Need add one more keytable.

1. With my variant we have one keytable of remote and some workaround in device drivers. 
    And can switch keytable and remotes on the fly (of course when keytable has really value and device driver has workaround)
    
2. With your variant we have some keytables for one remote for different IR recevers. 
    Can't use incompatible keytable with other IR recievers. It is black magic for understanding what remotes is working with this hardware.

I think my variant much better.

With my best regards, Dmitry.

> >>>> Then the function call usb_set_interface in tm6000_video, can
> >>>> write for example:
> >>>>
> >>>> stop_ir_pipe
> >>>> usb_set_interface
> >>>> start_ir_pipe
> >>> Ok, I'll try.
> > See dmesg. I was add function for start/stop interrupt urbs
> > All works well.
> >
> > With my best regards, Dmitry.
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-17  1:46                                             ` Dmitri Belimov
@ 2010-12-17  5:18                                               ` Stefan Ringel
  2010-12-17  7:08                                                 ` Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Ringel @ 2010-12-17  5:18 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

Am 17.12.2010 02:46, schrieb Dmitri Belimov:
> Hi Stefan
>
>> Am 16.12.2010 10:38, schrieb Dmitri Belimov:
>>> Hi
>>>
>>>>> I think your mean is wrong. Our IR remotes send extended NEC it is
>>>>> 4 bytes. We removed inverted 4 byte and now we have 3 bytes from
>>>>> remotes. I think we must have full RCMAP with this 3 bytes from
>>>>> remotes. And use this remotes with some different IR recievers
>>>>> like some TV cards and LIRC-hardware and other. No need different
>>>>> RCMAP for the same remotes to different IR recievers like now.
>>>> Your change doesn't work with my terratec remote control !!
>>> I found what happens. Try my new patch.
>>>
>>> What about NEC. Original NEC send
>>> address (inverted address) key (inverted key)
>>> this is realy old standart now all remotes use extended NEC
>>> (adress high) (address low) key (inverted key)
>>> The trident 5600/6000/6010 use old protocol but didn't test
>>> inverted address byte.
>>>
>>> I think much better discover really address value and write it to
>>> keytable. For your remotes I add low address byte. This value is
>>> incorrent but usefull for tm6000. When you found correct value
>>> update keytable.
>>>
>> That is not acceptable. Have you forgotten what Mauro have written?
>> The Terratec rc map are use from other devices.
> NO
> The RC_MAP_NEC_TERRATEC_CINERGY_XS used only in tm6000 module.
> My patch didn't kill support any other devices.
That is not true.
>> The best are only the
>> received data without additional data. And I think the Trident chip
>> send only compatibly data (send all extended data like standard
>> data). The device decoded the protocols not the driver.
> You can't use this remotes with normal working IR receivers because this receivers
> returned FULL scancodes. Need add one more keytable.
>
> 1. With my variant we have one keytable of remote and some workaround in device drivers.
>      And can switch keytable and remotes on the fly (of course when keytable has really value and device driver has workaround)
>
> 2. With your variant we have some keytables for one remote for different IR recevers.
>      Can't use incompatible keytable with other IR recievers. It is black magic for understanding what remotes is working with this hardware.
>
> I think my variant much better.
>
> With my best regards, Dmitry.
>
I think your variant is bad.
>>>>>> Then the function call usb_set_interface in tm6000_video, can
>>>>>> write for example:
>>>>>>
>>>>>> stop_ir_pipe
>>>>>> usb_set_interface
>>>>>> start_ir_pipe
>>>>> Ok, I'll try.
>>> See dmesg. I was add function for start/stop interrupt urbs
>>> All works well.
>>>
>>> With my best regards, Dmitry.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-17  5:18                                               ` Stefan Ringel
@ 2010-12-17  7:08                                                 ` Dmitri Belimov
  2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-17  7:08 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List

On Fri, 17 Dec 2010 06:18:31 +0100
Stefan Ringel <stefan.ringel@arcor.de> wrote:

> Am 17.12.2010 02:46, schrieb Dmitri Belimov:
> > Hi Stefan
> >
> >> Am 16.12.2010 10:38, schrieb Dmitri Belimov:
> >>> Hi
> >>>
> >>>>> I think your mean is wrong. Our IR remotes send extended NEC it
> >>>>> is 4 bytes. We removed inverted 4 byte and now we have 3 bytes
> >>>>> from remotes. I think we must have full RCMAP with this 3 bytes
> >>>>> from remotes. And use this remotes with some different IR
> >>>>> recievers like some TV cards and LIRC-hardware and other. No
> >>>>> need different RCMAP for the same remotes to different IR
> >>>>> recievers like now.
> >>>> Your change doesn't work with my terratec remote control !!
> >>> I found what happens. Try my new patch.
> >>>
> >>> What about NEC. Original NEC send
> >>> address (inverted address) key (inverted key)
> >>> this is realy old standart now all remotes use extended NEC
> >>> (adress high) (address low) key (inverted key)
> >>> The trident 5600/6000/6010 use old protocol but didn't test
> >>> inverted address byte.
> >>>
> >>> I think much better discover really address value and write it to
> >>> keytable. For your remotes I add low address byte. This value is
> >>> incorrent but usefull for tm6000. When you found correct value
> >>> update keytable.
> >>>
> >> That is not acceptable. Have you forgotten what Mauro have written?
> >> The Terratec rc map are use from other devices.
> > NO
> > The RC_MAP_NEC_TERRATEC_CINERGY_XS used only in tm6000 module.
> > My patch didn't kill support any other devices.
> That is not true.

I search "RC_MAP_NEC_TERRATEC_CINERGY_XS" on FULL linux kernel sources.
And found this string in:
include/media/rc-map.h
drivers/staging//tm6000/tm6000-cards.c
drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c

No any other devices didn't use this keymap.

> >> The best are only the
> >> received data without additional data. And I think the Trident chip
> >> send only compatibly data (send all extended data like standard
> >> data). The device decoded the protocols not the driver.
> > You can't use this remotes with normal working IR receivers because
> > this receivers returned FULL scancodes. Need add one more keytable.
> >
> > 1. With my variant we have one keytable of remote and some
> > workaround in device drivers. And can switch keytable and remotes
> > on the fly (of course when keytable has really value and device
> > driver has workaround)
> >
> > 2. With your variant we have some keytables for one remote for
> > different IR recevers. Can't use incompatible keytable with other
> > IR recievers. It is black magic for understanding what remotes is
> > working with this hardware.
> >
> > I think my variant much better.
> >
> > With my best regards, Dmitry.
> >
> I think your variant is bad.

Mauro we need your opinion about this question.

With my best regards, Dmitry.

> >>>>>> Then the function call usb_set_interface in tm6000_video, can
> >>>>>> write for example:
> >>>>>>
> >>>>>> stop_ir_pipe
> >>>>>> usb_set_interface
> >>>>>> start_ir_pipe
> >>>>> Ok, I'll try.
> >>> See dmesg. I was add function for start/stop interrupt urbs
> >>> All works well.
> >>>
> >>> With my best regards, Dmitry.
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-17  7:08                                                 ` Dmitri Belimov
@ 2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
  2010-12-18 13:56                                                     ` Andy Walls
                                                                       ` (3 more replies)
  0 siblings, 4 replies; 36+ messages in thread
From: Mauro Carvalho Chehab @ 2010-12-18  0:24 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

Hi Dmitri/Stefan,

Em 17-12-2010 05:08, Dmitri Belimov escreveu:
> On Fri, 17 Dec 2010 06:18:31 +0100
> Stefan Ringel <stefan.ringel@arcor.de> wrote:
> 
>> Am 17.12.2010 02:46, schrieb Dmitri Belimov:
>>> Hi Stefan
>>>
>>>> Am 16.12.2010 10:38, schrieb Dmitri Belimov:
>>>>> Hi
>>>>>
>>>>>>> I think your mean is wrong. Our IR remotes send extended NEC it
>>>>>>> is 4 bytes. We removed inverted 4 byte and now we have 3 bytes
>>>>>>> from remotes. I think we must have full RCMAP with this 3 bytes
>>>>>>> from remotes. And use this remotes with some different IR
>>>>>>> recievers like some TV cards and LIRC-hardware and other. No
>>>>>>> need different RCMAP for the same remotes to different IR
>>>>>>> recievers like now.
>>>>>> Your change doesn't work with my terratec remote control !!
>>>>> I found what happens. Try my new patch.
>>>>>
>>>>> What about NEC. Original NEC send
>>>>> address (inverted address) key (inverted key)
>>>>> this is realy old standart now all remotes use extended NEC
>>>>> (adress high) (address low) key (inverted key)
>>>>> The trident 5600/6000/6010 use old protocol but didn't test
>>>>> inverted address byte.
>>>>>
>>>>> I think much better discover really address value and write it to
>>>>> keytable. For your remotes I add low address byte. This value is
>>>>> incorrent but usefull for tm6000. When you found correct value
>>>>> update keytable.
>>>>>
>>>> That is not acceptable. Have you forgotten what Mauro have written?
>>>> The Terratec rc map are use from other devices.
>>> NO
>>> The RC_MAP_NEC_TERRATEC_CINERGY_XS used only in tm6000 module.
>>> My patch didn't kill support any other devices.
>> That is not true.
> 
> I search "RC_MAP_NEC_TERRATEC_CINERGY_XS" on FULL linux kernel sources.
> And found this string in:
> include/media/rc-map.h
> drivers/staging//tm6000/tm6000-cards.c
> drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
> 
> No any other devices didn't use this keymap.
> 
>>>> The best are only the
>>>> received data without additional data. And I think the Trident chip
>>>> send only compatibly data (send all extended data like standard
>>>> data). The device decoded the protocols not the driver.
>>> You can't use this remotes with normal working IR receivers because
>>> this receivers returned FULL scancodes. Need add one more keytable.
>>>
>>> 1. With my variant we have one keytable of remote and some
>>> workaround in device drivers. And can switch keytable and remotes
>>> on the fly (of course when keytable has really value and device
>>> driver has workaround)
>>>
>>> 2. With your variant we have some keytables for one remote for
>>> different IR recevers. Can't use incompatible keytable with other
>>> IR recievers. It is black magic for understanding what remotes is
>>> working with this hardware.
>>>
>>> I think my variant much better.
>>>
>>> With my best regards, Dmitry.
>>>
>> I think your variant is bad.
> 
> Mauro we need your opinion about this question.

I'm c/c Jarod, as he has a similar issue with some NEC-based boards 
(Apple "variant").

I also have experienced some cases where the NEC protocol in-hardware
decoder can provide only part of the NEC "extended" range.

I don't have a clear opinion about this issue, but I think that putting
all our brains to think about that, we may have a solution for it.

Let me summarize the issues. Please complete/correct me if is there anything
else.

1) NEC original format is 16 bits. However, some variants use 24 bits for it
(it is called, currently, NEC extended). A few other manufacturers, like Apple,
defines NEC protocol with 32 bits, removing both address and command checksums.

2) NEC raw decoder is capable of decoding the entire NEC code, but it only
accepts 16 or 24 bits, returning the scan code as:

	scancode = address << 8 | command;

for 16 bits, and:

	scancode = address << 16 | not_address <<  8 | command;

for 24 bits. There were some proposals to extend it to something like:

	scancode = address << 24 | not_address << 16 | not_command << 8 | command;
	(or some other bit order)

Or just return the complete 32 bits even for the original NEC protocol. However,
changing it will break the existing userspace decoding tables.

Another way would be to store the length of the scancode, using it as well during
the scancode->keycode translation.

But no patches were merged yet.

3) Some hardware decoders can't return the complete NEC address. There are variants
that returns 8 bits, others that returns 16 bits, and others that return the complete
code.

For hardware that returns only 8 bits, we currently address the issue by using a 
scancode mask. When "scanmask" is set at the rc structs, the scancode->keycode
logic will consider only the bits that are in the mask.

4) Some hardware filters the NEC address, returning only the codes for
some specific vendors.

Despite all discussions, we didn't reach an agreement yet.

There are some points to consider whatever solution we do:

1) A keycode table should be able to work with a generic raw decoder. So, on all
drivers, the bit order and the number of bits for a given protocol should be the same;

2) we should avoid to cause regressions on the existing definitions.

That's said, suggestions to meet the needs are welcome.

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
@ 2010-12-18 13:56                                                     ` Andy Walls
  2010-12-18 15:55                                                       ` Stefan Ringel
  2010-12-20  5:41                                                     ` Dmitri Belimov
                                                                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 36+ messages in thread
From: Andy Walls @ 2010-12-18 13:56 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Dmitri Belimov, Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

On Fri, 2010-12-17 at 22:24 -0200, Mauro Carvalho Chehab wrote:


> Despite all discussions, we didn't reach an agreement yet.
> 
> There are some points to consider whatever solution we do:
> 
> 1) A keycode table should be able to work with a generic raw decoder. So, on all
> drivers, the bit order and the number of bits for a given protocol should be the same;
> 
> 2) we should avoid to cause regressions on the existing definitions.
> 
> That's said, suggestions to meet the needs are welcome.

Just to throw out some ideas:

It appears to me that what you are looking at are communications
protocols with

a. a common Physical layer (PHY): a pulse distance protocol with a
common carrier freq, bit symbol encoding, leader pulse, trailer pulse,
and repeat sequence.  The number of bits (and the leader pulse length?)
is allowed to vary.  

b. differing Data Link layers (LL): the data link address can be
different lengths and in different places; so can the data payload, so
can the checks on address and data payload.

For the end user, I would present each PHY/LL combination a different
protocol.  How the kernel implements it internally doesn't matter much.
It could be one raw decoder handling all the PHY/LL combinations that it
can, or one PHY decoder and several LL decoders.

The keytables should probably be working on cooked LL output from the
raw decoder.  I think that will handle a lot of the issues you mention.
The output from a LL could include

	destination address (from the transmitted code),
	source address (useful if different remotes can be detected),
	payload length,
	payload, and
	maybe button up/down.

The LL could swallow the automatic repeats, since they are just part of
the button up/down scheme.

Aside from backward compatibility with existing keytables, I don't see
much point in a decoder trying to flip bits from the PHY layer around to
present a pseudo-PHY layer output.  Don't keytables get updated with the
kernel release anyway, or did they all move to userspace utils?


Anyway, just some thoughts.

Regards,
Andy


> Thanks,
> Mauro



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-18 13:56                                                     ` Andy Walls
@ 2010-12-18 15:55                                                       ` Stefan Ringel
  0 siblings, 0 replies; 36+ messages in thread
From: Stefan Ringel @ 2010-12-18 15:55 UTC (permalink / raw)
  To: Andy Walls
  Cc: Mauro Carvalho Chehab, Dmitri Belimov, Felipe Sanches,
	Bee Hock Goh, Luis Henrique Fagundes, Linux Media Mailing List,
	Jarod Wilson

Am 18.12.2010 14:56, schrieb Andy Walls:
> On Fri, 2010-12-17 at 22:24 -0200, Mauro Carvalho Chehab wrote:
>
>
>> Despite all discussions, we didn't reach an agreement yet.
>>
>> There are some points to consider whatever solution we do:
>>
>> 1) A keycode table should be able to work with a generic raw decoder. So, on all
>> drivers, the bit order and the number of bits for a given protocol should be the same;
>>
>> 2) we should avoid to cause regressions on the existing definitions.
>>
>> That's said, suggestions to meet the needs are welcome.
> Just to throw out some ideas:
>
> It appears to me that what you are looking at are communications
> protocols with
>
> a. a common Physical layer (PHY): a pulse distance protocol with a
> common carrier freq, bit symbol encoding, leader pulse, trailer pulse,
> and repeat sequence.  The number of bits (and the leader pulse length?)
> is allowed to vary.
>
> b. differing Data Link layers (LL): the data link address can be
> different lengths and in different places; so can the data payload, so
> can the checks on address and data payload.
>
> For the end user, I would present each PHY/LL combination a different
> protocol.  How the kernel implements it internally doesn't matter much.
> It could be one raw decoder handling all the PHY/LL combinations that it
> can, or one PHY decoder and several LL decoders.
>
> The keytables should probably be working on cooked LL output from the
> raw decoder.  I think that will handle a lot of the issues you mention.
> The output from a LL could include
>
> 	destination address (from the transmitted code),
> 	source address (useful if different remotes can be detected),
> 	payload length,
> 	payload, and
> 	maybe button up/down.
>
> The LL could swallow the automatic repeats, since they are just part of
> the button up/down scheme.
>
> Aside from backward compatibility with existing keytables, I don't see
> much point in a decoder trying to flip bits from the PHY layer around to
> present a pseudo-PHY layer output.  Don't keytables get updated with the
> kernel release anyway, or did they all move to userspace utils?
>
>
> Anyway, just some thoughts.
>
> Regards,
> Andy
>
>
>> Thanks,
>> Mauro
>
TM5600, TM6000 and TM6010 IR
==========================

It give two ways to receive data

1. over the control pipe (ep0)
- polling must stop if it loads firmware
- data length are a byte (command)

2. over interrupt pipe (only TM6010)
- data length are two bytes (address << 8 | command)

It has any control registers to configure IR (protocol ...)

TM6010_REQ07_RD8_IR
??, we use 0x2f

TM6010_REQ07_RD8_IR_BSIZE
??

TM6010_REQ07_RD8_IR_WAKEUP_SEL
command mask, I think,   we use here 0xff

TM6010_REQ07_RD8_IR_WAKEUP_ADD
address mask, we use 0xff

TM6010_REQ07_RD8_IR_LEADER1
TM6010_REQ07_RD8_IR_LEADER0
is a 16bit register
for NEC 0xaa30

TM6010_REQ07_RD8_IR_PULSE_CNT1
TM6010_REQ07_RD8_IR_PULSE_CNT0
is a 16bit register
for NEC 0x20d0


Stefan Ringel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
  2010-12-18 13:56                                                     ` Andy Walls
@ 2010-12-20  5:41                                                     ` Dmitri Belimov
  2010-12-21 22:36                                                       ` Jarod Wilson
  2011-01-13  3:46                                                     ` [PATCH] tm6000: rework init code Dmitri Belimov
  2011-01-20  6:05                                                     ` [PATCH] tm6000: add/rework reg.defines Dmitri Belimov
  3 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-20  5:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

Hi

If Apple use full 32-bit scancode we need full raw 32-bit keytable for compatibility.

For this need rework all keytables and all keyread function for add scanmask configuration and
rework single byte scancode code -> key << 8.

Use scanmask and return IR reading bytes on real place.

For tm6000 don't need restore full scancode 
Only address filter

scanmask = 0xff00ff00;
return byte[1] << 24 | byte[0] <<8

With my best regards, Dmitry.

> Hi Dmitri/Stefan,
> 
> Em 17-12-2010 05:08, Dmitri Belimov escreveu:
> > On Fri, 17 Dec 2010 06:18:31 +0100
> > Stefan Ringel <stefan.ringel@arcor.de> wrote:
> > 
> >> Am 17.12.2010 02:46, schrieb Dmitri Belimov:
> >>> Hi Stefan
> >>>
> >>>> Am 16.12.2010 10:38, schrieb Dmitri Belimov:
> >>>>> Hi
> >>>>>
> >>>>>>> I think your mean is wrong. Our IR remotes send extended NEC
> >>>>>>> it is 4 bytes. We removed inverted 4 byte and now we have 3
> >>>>>>> bytes from remotes. I think we must have full RCMAP with this
> >>>>>>> 3 bytes from remotes. And use this remotes with some
> >>>>>>> different IR recievers like some TV cards and LIRC-hardware
> >>>>>>> and other. No need different RCMAP for the same remotes to
> >>>>>>> different IR recievers like now.
> >>>>>> Your change doesn't work with my terratec remote control !!
> >>>>> I found what happens. Try my new patch.
> >>>>>
> >>>>> What about NEC. Original NEC send
> >>>>> address (inverted address) key (inverted key)
> >>>>> this is realy old standart now all remotes use extended NEC
> >>>>> (adress high) (address low) key (inverted key)
> >>>>> The trident 5600/6000/6010 use old protocol but didn't test
> >>>>> inverted address byte.
> >>>>>
> >>>>> I think much better discover really address value and write it
> >>>>> to keytable. For your remotes I add low address byte. This
> >>>>> value is incorrent but usefull for tm6000. When you found
> >>>>> correct value update keytable.
> >>>>>
> >>>> That is not acceptable. Have you forgotten what Mauro have
> >>>> written? The Terratec rc map are use from other devices.
> >>> NO
> >>> The RC_MAP_NEC_TERRATEC_CINERGY_XS used only in tm6000 module.
> >>> My patch didn't kill support any other devices.
> >> That is not true.
> > 
> > I search "RC_MAP_NEC_TERRATEC_CINERGY_XS" on FULL linux kernel
> > sources. And found this string in:
> > include/media/rc-map.h
> > drivers/staging//tm6000/tm6000-cards.c
> > drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
> > 
> > No any other devices didn't use this keymap.
> > 
> >>>> The best are only the
> >>>> received data without additional data. And I think the Trident
> >>>> chip send only compatibly data (send all extended data like
> >>>> standard data). The device decoded the protocols not the driver.
> >>> You can't use this remotes with normal working IR receivers
> >>> because this receivers returned FULL scancodes. Need add one more
> >>> keytable.
> >>>
> >>> 1. With my variant we have one keytable of remote and some
> >>> workaround in device drivers. And can switch keytable and remotes
> >>> on the fly (of course when keytable has really value and device
> >>> driver has workaround)
> >>>
> >>> 2. With your variant we have some keytables for one remote for
> >>> different IR recevers. Can't use incompatible keytable with other
> >>> IR recievers. It is black magic for understanding what remotes is
> >>> working with this hardware.
> >>>
> >>> I think my variant much better.
> >>>
> >>> With my best regards, Dmitry.
> >>>
> >> I think your variant is bad.
> > 
> > Mauro we need your opinion about this question.
> 
> I'm c/c Jarod, as he has a similar issue with some NEC-based boards 
> (Apple "variant").
> 
> I also have experienced some cases where the NEC protocol in-hardware
> decoder can provide only part of the NEC "extended" range.
> 
> I don't have a clear opinion about this issue, but I think that
> putting all our brains to think about that, we may have a solution
> for it.
> 
> Let me summarize the issues. Please complete/correct me if is there
> anything else.
> 
> 1) NEC original format is 16 bits. However, some variants use 24 bits
> for it (it is called, currently, NEC extended). A few other
> manufacturers, like Apple, defines NEC protocol with 32 bits,
> removing both address and command checksums.
> 
> 2) NEC raw decoder is capable of decoding the entire NEC code, but it
> only accepts 16 or 24 bits, returning the scan code as:
> 
> 	scancode = address << 8 | command;
> 
> for 16 bits, and:
> 
> 	scancode = address << 16 | not_address <<  8 | command;
> 
> for 24 bits. There were some proposals to extend it to something like:
> 
> 	scancode = address << 24 | not_address << 16 | not_command <<
> 8 | command; (or some other bit order)
> 
> Or just return the complete 32 bits even for the original NEC
> protocol. However, changing it will break the existing userspace
> decoding tables.
> 
> Another way would be to store the length of the scancode, using it as
> well during the scancode->keycode translation.
> 
> But no patches were merged yet.
> 
> 3) Some hardware decoders can't return the complete NEC address.
> There are variants that returns 8 bits, others that returns 16 bits,
> and others that return the complete code.
> 
> For hardware that returns only 8 bits, we currently address the issue
> by using a scancode mask. When "scanmask" is set at the rc structs,
> the scancode->keycode logic will consider only the bits that are in
> the mask.
> 
> 4) Some hardware filters the NEC address, returning only the codes for
> some specific vendors.
> 
> Despite all discussions, we didn't reach an agreement yet.
> 
> There are some points to consider whatever solution we do:
> 
> 1) A keycode table should be able to work with a generic raw decoder.
> So, on all drivers, the bit order and the number of bits for a given
> protocol should be the same;
> 
> 2) we should avoid to cause regressions on the existing definitions.
> 
> That's said, suggestions to meet the needs are welcome.
> 
> Thanks,
> Mauro

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and IR
  2010-12-20  5:41                                                     ` Dmitri Belimov
@ 2010-12-21 22:36                                                       ` Jarod Wilson
  2010-12-22  8:57                                                         ` [PATCH] Rework and fix IR Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Jarod Wilson @ 2010-12-21 22:36 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Stefan Ringel, Felipe Sanches,
	Bee Hock Goh, Luis Henrique Fagundes, Linux Media Mailing List

On Mon, Dec 20, 2010 at 02:41:03PM +0900, Dmitri Belimov wrote:
> Hi
> 
> If Apple use full 32-bit scancode we need full raw 32-bit keytable for compatibility.

The Apple format is two bytes for what I guess is vendor ID, one byte for
pairing ID and one byte for the actual command. The actual keytable
*could* get by with just one byte if you didn't care about pairing, two
bytes if you do. But it can also use the full four bytes no problem.

I hacked together a proof-of-concept thing that *does* work for me, but
its not the prettiest thing around:

http://git.kernel.org/?p=linux/kernel/git/jarod/linux-2.6-ir.git;a=shortlog;h=refs/heads/staging

Basically, while loading keys, keep track of the largest one in the table,
and use that knowledge to figure out how to decode the signal. Doesn't
take key removal into account at all though, and has other issues I'm
probably forgetting right now. :)



> For this need rework all keytables and all keyread function for add scanmask configuration and
> rework single byte scancode code -> key << 8.
> 
> Use scanmask and return IR reading bytes on real place.
> 
> For tm6000 don't need restore full scancode 
> Only address filter
> 
> scanmask = 0xff00ff00;
> return byte[1] << 24 | byte[0] <<8
> 
> With my best regards, Dmitry.
> 
> > Hi Dmitri/Stefan,
> > 
> > Em 17-12-2010 05:08, Dmitri Belimov escreveu:
> > > On Fri, 17 Dec 2010 06:18:31 +0100
> > > Stefan Ringel <stefan.ringel@arcor.de> wrote:
> > > 
> > >> Am 17.12.2010 02:46, schrieb Dmitri Belimov:
> > >>> Hi Stefan
> > >>>
> > >>>> Am 16.12.2010 10:38, schrieb Dmitri Belimov:
> > >>>>> Hi
> > >>>>>
> > >>>>>>> I think your mean is wrong. Our IR remotes send extended NEC
> > >>>>>>> it is 4 bytes. We removed inverted 4 byte and now we have 3
> > >>>>>>> bytes from remotes. I think we must have full RCMAP with this
> > >>>>>>> 3 bytes from remotes. And use this remotes with some
> > >>>>>>> different IR recievers like some TV cards and LIRC-hardware
> > >>>>>>> and other. No need different RCMAP for the same remotes to
> > >>>>>>> different IR recievers like now.
> > >>>>>> Your change doesn't work with my terratec remote control !!
> > >>>>> I found what happens. Try my new patch.
> > >>>>>
> > >>>>> What about NEC. Original NEC send
> > >>>>> address (inverted address) key (inverted key)
> > >>>>> this is realy old standart now all remotes use extended NEC
> > >>>>> (adress high) (address low) key (inverted key)
> > >>>>> The trident 5600/6000/6010 use old protocol but didn't test
> > >>>>> inverted address byte.
> > >>>>>
> > >>>>> I think much better discover really address value and write it
> > >>>>> to keytable. For your remotes I add low address byte. This
> > >>>>> value is incorrent but usefull for tm6000. When you found
> > >>>>> correct value update keytable.
> > >>>>>
> > >>>> That is not acceptable. Have you forgotten what Mauro have
> > >>>> written? The Terratec rc map are use from other devices.
> > >>> NO
> > >>> The RC_MAP_NEC_TERRATEC_CINERGY_XS used only in tm6000 module.
> > >>> My patch didn't kill support any other devices.
> > >> That is not true.
> > > 
> > > I search "RC_MAP_NEC_TERRATEC_CINERGY_XS" on FULL linux kernel
> > > sources. And found this string in:
> > > include/media/rc-map.h
> > > drivers/staging//tm6000/tm6000-cards.c
> > > drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
> > > 
> > > No any other devices didn't use this keymap.
> > > 
> > >>>> The best are only the
> > >>>> received data without additional data. And I think the Trident
> > >>>> chip send only compatibly data (send all extended data like
> > >>>> standard data). The device decoded the protocols not the driver.
> > >>> You can't use this remotes with normal working IR receivers
> > >>> because this receivers returned FULL scancodes. Need add one more
> > >>> keytable.
> > >>>
> > >>> 1. With my variant we have one keytable of remote and some
> > >>> workaround in device drivers. And can switch keytable and remotes
> > >>> on the fly (of course when keytable has really value and device
> > >>> driver has workaround)
> > >>>
> > >>> 2. With your variant we have some keytables for one remote for
> > >>> different IR recevers. Can't use incompatible keytable with other
> > >>> IR recievers. It is black magic for understanding what remotes is
> > >>> working with this hardware.
> > >>>
> > >>> I think my variant much better.
> > >>>
> > >>> With my best regards, Dmitry.
> > >>>
> > >> I think your variant is bad.
> > > 
> > > Mauro we need your opinion about this question.
> > 
> > I'm c/c Jarod, as he has a similar issue with some NEC-based boards 
> > (Apple "variant").
> > 
> > I also have experienced some cases where the NEC protocol in-hardware
> > decoder can provide only part of the NEC "extended" range.
> > 
> > I don't have a clear opinion about this issue, but I think that
> > putting all our brains to think about that, we may have a solution
> > for it.
> > 
> > Let me summarize the issues. Please complete/correct me if is there
> > anything else.
> > 
> > 1) NEC original format is 16 bits. However, some variants use 24 bits
> > for it (it is called, currently, NEC extended). A few other
> > manufacturers, like Apple, defines NEC protocol with 32 bits,
> > removing both address and command checksums.
> > 
> > 2) NEC raw decoder is capable of decoding the entire NEC code, but it
> > only accepts 16 or 24 bits, returning the scan code as:
> > 
> > 	scancode = address << 8 | command;
> > 
> > for 16 bits, and:
> > 
> > 	scancode = address << 16 | not_address <<  8 | command;
> > 
> > for 24 bits. There were some proposals to extend it to something like:
> > 
> > 	scancode = address << 24 | not_address << 16 | not_command <<
> > 8 | command; (or some other bit order)
> > 
> > Or just return the complete 32 bits even for the original NEC
> > protocol. However, changing it will break the existing userspace
> > decoding tables.
> > 
> > Another way would be to store the length of the scancode, using it as
> > well during the scancode->keycode translation.
> > 
> > But no patches were merged yet.
> > 
> > 3) Some hardware decoders can't return the complete NEC address.
> > There are variants that returns 8 bits, others that returns 16 bits,
> > and others that return the complete code.
> > 
> > For hardware that returns only 8 bits, we currently address the issue
> > by using a scancode mask. When "scanmask" is set at the rc structs,
> > the scancode->keycode logic will consider only the bits that are in
> > the mask.
> > 
> > 4) Some hardware filters the NEC address, returning only the codes for
> > some specific vendors.
> > 
> > Despite all discussions, we didn't reach an agreement yet.
> > 
> > There are some points to consider whatever solution we do:
> > 
> > 1) A keycode table should be able to work with a generic raw decoder.
> > So, on all drivers, the bit order and the number of bits for a given
> > protocol should be the same;
> > 
> > 2) we should avoid to cause regressions on the existing definitions.
> > 
> > That's said, suggestions to meet the needs are welcome.
> > 
> > Thanks,
> > Mauro

-- 
Jarod Wilson
jarod@redhat.com


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH] Rework and fix IR
  2010-12-21 22:36                                                       ` Jarod Wilson
@ 2010-12-22  8:57                                                         ` Dmitri Belimov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2010-12-22  8:57 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Mauro Carvalho Chehab, Stefan Ringel, Felipe Sanches,
	Bee Hock Goh, Luis Henrique Fagundes, Linux Media Mailing List

[-- Attachment #1: Type: text/plain, Size: 11366 bytes --]

Hi

This patch didn't kill Stefan's remotes and just for upload my good part of code.
1. Add some code for show IR activity
2. Add filter for IR remotes
3. Split remotes to different types.
4. Fix stop interrupt pipe when isoc pipe started.

When we decide general way of IR I'll add support our remotes.
For our customers I'll made custom temporary patch without this part.

diff --git a/drivers/staging/tm6000/TODO b/drivers/staging/tm6000/TODO
index 34780fc..135d0ea 100644
--- a/drivers/staging/tm6000/TODO
+++ b/drivers/staging/tm6000/TODO
@@ -1,4 +1,6 @@
 There a few things to do before putting this driver in production:
+	- IR NEC with tm5600/6000 TV cards
+	- IR RC5 with tm5600/6000/6010 TV cards
 	- CodingStyle;
 	- Fix audio;
 	- Fix some panic/OOPS conditions.
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 1c9374a..2e525a6 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -328,6 +328,47 @@ struct usb_device_id tm6000_id_table[] = {
 	{ },
 };
 
+/* Control power led for show some activity */
+void tm6000_flash_led(struct tm6000_core *dev, u8 state)
+{
+	/* Power LED unconfigured */
+	if (!dev->gpio.power_led)
+		return;
+
+	/* ON Power LED */
+	if (state) {
+		switch (dev->model) {
+		case TM6010_BOARD_HAUPPAUGE_900H:
+		case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+		case TM6010_BOARD_TWINHAN_TU501:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x00);
+			break;
+		case TM6010_BOARD_BEHOLD_WANDER:
+		case TM6010_BOARD_BEHOLD_VOYAGER:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x01);
+			break;
+		}
+	}
+	/* OFF Power LED */
+	else {
+		switch (dev->model) {
+		case TM6010_BOARD_HAUPPAUGE_900H:
+		case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+		case TM6010_BOARD_TWINHAN_TU501:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x01);
+			break;
+		case TM6010_BOARD_BEHOLD_WANDER:
+		case TM6010_BOARD_BEHOLD_VOYAGER:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x00);
+			break;
+		}
+	}
+}
+
 /* Tuner callback to provide the proper gpio changes needed for xc5000 */
 int tm6000_xc5000_callback(void *ptr, int component, int command, int arg)
 {
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c
index e02ea67..21e7da4 100644
--- a/drivers/staging/tm6000/tm6000-input.c
+++ b/drivers/staging/tm6000/tm6000-input.c
@@ -37,6 +37,10 @@ static unsigned int enable_ir = 1;
 module_param(enable_ir, int, 0644);
 MODULE_PARM_DESC(enable_ir, "enable ir (default is enable)");
 
+/* number of 50ms for ON-OFF-ON power led */
+/* show IR activity */
+#define PWLED_OFF 2
+
 #undef dprintk
 
 #define dprintk(fmt, arg...) \
@@ -59,6 +63,9 @@ struct tm6000_IR {
 	struct delayed_work	work;
 	u8			wait:1;
 	u8			key:1;
+	u8			pwled:1;
+	u8			pwledcnt;
+	u16			key_addr;
 	struct urb		*int_urb;
 	u8			*urb_data;
 
@@ -89,26 +96,49 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
 	u8 buf[10];
 	int rc;
 
-	/* hack */
-	buf[0] = 0xff;
-	buf[1] = 0xff;
-	buf[2] = 0xf2;
-	buf[3] = 0x2b;
-	buf[4] = 0x20;
-	buf[5] = 0x35;
-	buf[6] = 0x60;
-	buf[7] = 0x04;
-	buf[8] = 0xc0;
-	buf[9] = 0x08;
-
-	rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
-		USB_RECIP_DEVICE, REQ_00_SET_IR_VALUE, 0, 0, buf, 0x0a);
-	msleep(100);
-
-	if (rc < 0) {
-		printk(KERN_INFO "IR configuration failed");
-		return rc;
+	switch (ir->rc_type) {
+	case RC_TYPE_NEC:
+		/* Setup IR decoder for NEC standard 12MHz system clock */
+		/* IR_LEADER_CNT = 0.9ms             */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_LEADER1, 0xaa);
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_LEADER0, 0x30);
+		/* IR_PULSE_CNT = 0.7ms              */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_PULSE_CNT1, 0x20);
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_PULSE_CNT0, 0xd0);
+		/* Remote WAKEUP = enable */
+		tm6000_set_reg(dev, TM6010_REQ07_RE5_REMOTE_WAKEUP, 0xfe);
+		/* IR_WKUP_SEL = Low byte in decoded IR data */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_WAKEUP_SEL, 0xff);
+		/* IR_WKU_ADD code */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_WAKEUP_ADD, 0xff);
+		tm6000_flash_led(dev, 0);
+		msleep(100);
+		tm6000_flash_led(dev, 1);
+		break;
+	default:
+		/* hack */
+		buf[0] = 0xff;
+		buf[1] = 0xff;
+		buf[2] = 0xf2;
+		buf[3] = 0x2b;
+		buf[4] = 0x20;
+		buf[5] = 0x35;
+		buf[6] = 0x60;
+		buf[7] = 0x04;
+		buf[8] = 0xc0;
+		buf[9] = 0x08;
+
+		rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
+			USB_RECIP_DEVICE, REQ_00_SET_IR_VALUE, 0, 0, buf, 0x0a);
+		msleep(100);
+
+		if (rc < 0) {
+			printk(KERN_INFO "IR configuration failed");
+			return rc;
+		}
+		break;
 	}
+
 	return 0;
 }
 
@@ -143,10 +173,21 @@ static int default_polling_getkey(struct tm6000_IR *ir,
 		return 0;
 
 	if (&dev->int_in) {
-		if (ir->rc_type == RC_TYPE_RC5)
+		switch (ir->rc_type) {
+		case RC_TYPE_RC5:
 			poll_result->rc_data = ir->urb_data[0];
-		else
-			poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8;
+			break;
+		case RC_TYPE_NEC:
+			if (ir->urb_data[1] == ((ir->key_addr >> 8) & 0xff)) {
+				poll_result->rc_data = ir->urb_data[0]
+							| ir->urb_data[1] << 8;
+			}
+			break;
+		default:
+			poll_result->rc_data = ir->urb_data[0]
+					| ir->urb_data[1] << 8;
+			break;
+		}
 	} else {
 		tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 0);
 		msleep(10);
@@ -186,6 +227,7 @@ static int default_polling_getkey(struct tm6000_IR *ir,
 
 static void tm6000_ir_handle_key(struct tm6000_IR *ir)
 {
+	struct tm6000_core *dev = ir->dev;
 	int result;
 	struct tm6000_ir_poll_result poll_result;
 
@@ -198,9 +240,21 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir)
 
 	dprintk("ir->get_key result data=%04x\n", poll_result.rc_data);
 
+	if (ir->pwled) {
+		if (ir->pwledcnt >= PWLED_OFF) {
+			ir->pwled = 0;
+			ir->pwledcnt = 0;
+			tm6000_flash_led(dev, 1);
+		} else
+			ir->pwledcnt += 1;
+	}
+
 	if (ir->key) {
 		rc_keydown(ir->rc, poll_result.rc_data, 0);
 		ir->key = 0;
+		ir->pwled = 1;
+		ir->pwledcnt = 0;
+		tm6000_flash_led(dev, 0);
 	}
 	return;
 }
@@ -234,19 +288,80 @@ int tm6000_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
 {
 	struct tm6000_IR *ir = rc->priv;
 
+	if (!ir)
+		return 0;
+
+	if ((rc->rc_map.scan) && (rc_type == RC_TYPE_NEC))
+		ir->key_addr = ((rc->rc_map.scan[0].scancode >> 8) & 0xffff);
+
 	ir->get_key = default_polling_getkey;
+	ir->rc_type = rc_type;
 
 	tm6000_ir_config(ir);
 	/* TODO */
 	return 0;
 }
 
+int tm6000_ir_int_start(struct tm6000_core *dev)
+{
+	struct tm6000_IR *ir = dev->ir;
+	int pipe, size;
+	int err = -ENOMEM;
+
+
+	if (!ir)
+		return -ENODEV;
+
+	ir->int_urb = usb_alloc_urb(0, GFP_KERNEL);
+
+	pipe = usb_rcvintpipe(dev->udev,
+		dev->int_in.endp->desc.bEndpointAddress
+		& USB_ENDPOINT_NUMBER_MASK);
+
+	size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
+	dprintk("IR max size: %d\n", size);
+
+	ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
+	if (ir->int_urb->transfer_buffer == NULL) {
+		usb_free_urb(ir->int_urb);
+		return err;
+	}
+	dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
+	usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
+		ir->int_urb->transfer_buffer, size,
+		tm6000_ir_urb_received, dev,
+		dev->int_in.endp->desc.bInterval);
+	err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
+	if (err) {
+		kfree(ir->int_urb->transfer_buffer);
+		usb_free_urb(ir->int_urb);
+		return err;
+	}
+	ir->urb_data = kzalloc(size, GFP_KERNEL);
+
+	return 0;
+}
+
+void tm6000_ir_int_stop(struct tm6000_core *dev)
+{
+	struct tm6000_IR *ir = dev->ir;
+
+	if (!ir)
+		return;
+
+	usb_kill_urb(ir->int_urb);
+	kfree(ir->int_urb->transfer_buffer);
+	usb_free_urb(ir->int_urb);
+	ir->int_urb = NULL;
+	kfree(ir->urb_data);
+	ir->urb_data = NULL;
+}
+
 int tm6000_ir_init(struct tm6000_core *dev)
 {
 	struct tm6000_IR *ir;
 	struct rc_dev *rc;
 	int err = -ENOMEM;
-	int pipe, size;
 
 	if (!enable_ir)
 		return -ENODEV;
@@ -276,6 +391,9 @@ int tm6000_ir_init(struct tm6000_core *dev)
 	rc->driver_type = RC_DRIVER_SCANCODE;
 
 	ir->polling = 50;
+	ir->pwled = 0;
+	ir->pwledcnt = 0;
+
 
 	snprintf(ir->name, sizeof(ir->name), "tm5600/60x0 IR (%s)",
 						dev->name);
@@ -298,32 +416,10 @@ int tm6000_ir_init(struct tm6000_core *dev)
 	if (&dev->int_in) {
 		dprintk("IR over int\n");
 
-		ir->int_urb = usb_alloc_urb(0, GFP_KERNEL);
-
-		pipe = usb_rcvintpipe(dev->udev,
-			dev->int_in.endp->desc.bEndpointAddress
-			& USB_ENDPOINT_NUMBER_MASK);
+		err = tm6000_ir_int_start(dev);
 
-		size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
-		dprintk("IR max size: %d\n", size);
-
-		ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
-		if (ir->int_urb->transfer_buffer == NULL) {
-			usb_free_urb(ir->int_urb);
-			goto out;
-		}
-		dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
-		usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
-			ir->int_urb->transfer_buffer, size,
-			tm6000_ir_urb_received, dev,
-			dev->int_in.endp->desc.bInterval);
-		err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
-		if (err) {
-			kfree(ir->int_urb->transfer_buffer);
-			usb_free_urb(ir->int_urb);
+		if (err)
 			goto out;
-		}
-		ir->urb_data = kzalloc(size, GFP_KERNEL);
 	}
 
 	/* ir register */
@@ -352,12 +448,7 @@ int tm6000_ir_fini(struct tm6000_core *dev)
 	rc_unregister_device(ir->rc);
 
 	if (ir->int_urb) {
-		usb_kill_urb(ir->int_urb);
-		kfree(ir->int_urb->transfer_buffer);
-		usb_free_urb(ir->int_urb);
-		ir->int_urb = NULL;
-		kfree(ir->urb_data);
-		ir->urb_data = NULL;
+		tm6000_ir_int_stop(dev);
 	}
 
 	kfree(ir);
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index c5690b2..b06701b 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -545,11 +545,16 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
 
 	/* De-allocates all pending stuff */
 	tm6000_uninit_isoc(dev);
+	/* Stop interrupt USB pipe */
+	tm6000_ir_int_stop(dev);
 
 	usb_set_interface(dev->udev,
 			  dev->isoc_in.bInterfaceNumber,
 			  dev->isoc_in.bAlternateSetting);
 
+	/* Start interrupt USB pipe */
+	tm6000_ir_int_start(dev);
+
 	pipe = usb_rcvisocpipe(dev->udev,
 			       dev->isoc_in.endp->desc.bEndpointAddress &
 			       USB_ENDPOINT_NUMBER_MASK);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 46017b6..bf11eee 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -266,6 +266,7 @@ struct tm6000_fh {
 int tm6000_tuner_callback(void *ptr, int component, int command, int arg);
 int tm6000_xc5000_callback(void *ptr, int component, int command, int arg);
 int tm6000_cards_setup(struct tm6000_core *dev);
+void tm6000_flash_led(struct tm6000_core *dev, u8 state);
 
 /* In tm6000-core.c */
 
@@ -332,6 +333,8 @@ int tm6000_queue_init(struct tm6000_core *dev);
 int tm6000_ir_init(struct tm6000_core *dev);
 int tm6000_ir_fini(struct tm6000_core *dev);
 void tm6000_ir_wait(struct tm6000_core *dev, u8 state);
+int tm6000_ir_int_start(struct tm6000_core *dev);
+void tm6000_ir_int_stop(struct tm6000_core *dev);
 
 /* Debug stuff */
 

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>


With my best regards, Dmitry.

[-- Attachment #2: tm6000_ir.patch --]
[-- Type: text/x-patch, Size: 10959 bytes --]

diff --git a/drivers/staging/tm6000/TODO b/drivers/staging/tm6000/TODO
index 34780fc..135d0ea 100644
--- a/drivers/staging/tm6000/TODO
+++ b/drivers/staging/tm6000/TODO
@@ -1,4 +1,6 @@
 There a few things to do before putting this driver in production:
+	- IR NEC with tm5600/6000 TV cards
+	- IR RC5 with tm5600/6000/6010 TV cards
 	- CodingStyle;
 	- Fix audio;
 	- Fix some panic/OOPS conditions.
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 1c9374a..2e525a6 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -328,6 +328,47 @@ struct usb_device_id tm6000_id_table[] = {
 	{ },
 };
 
+/* Control power led for show some activity */
+void tm6000_flash_led(struct tm6000_core *dev, u8 state)
+{
+	/* Power LED unconfigured */
+	if (!dev->gpio.power_led)
+		return;
+
+	/* ON Power LED */
+	if (state) {
+		switch (dev->model) {
+		case TM6010_BOARD_HAUPPAUGE_900H:
+		case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+		case TM6010_BOARD_TWINHAN_TU501:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x00);
+			break;
+		case TM6010_BOARD_BEHOLD_WANDER:
+		case TM6010_BOARD_BEHOLD_VOYAGER:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x01);
+			break;
+		}
+	}
+	/* OFF Power LED */
+	else {
+		switch (dev->model) {
+		case TM6010_BOARD_HAUPPAUGE_900H:
+		case TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE:
+		case TM6010_BOARD_TWINHAN_TU501:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x01);
+			break;
+		case TM6010_BOARD_BEHOLD_WANDER:
+		case TM6010_BOARD_BEHOLD_VOYAGER:
+			tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
+				dev->gpio.power_led, 0x00);
+			break;
+		}
+	}
+}
+
 /* Tuner callback to provide the proper gpio changes needed for xc5000 */
 int tm6000_xc5000_callback(void *ptr, int component, int command, int arg)
 {
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c
index e02ea67..21e7da4 100644
--- a/drivers/staging/tm6000/tm6000-input.c
+++ b/drivers/staging/tm6000/tm6000-input.c
@@ -37,6 +37,10 @@ static unsigned int enable_ir = 1;
 module_param(enable_ir, int, 0644);
 MODULE_PARM_DESC(enable_ir, "enable ir (default is enable)");
 
+/* number of 50ms for ON-OFF-ON power led */
+/* show IR activity */
+#define PWLED_OFF 2
+
 #undef dprintk
 
 #define dprintk(fmt, arg...) \
@@ -59,6 +63,9 @@ struct tm6000_IR {
 	struct delayed_work	work;
 	u8			wait:1;
 	u8			key:1;
+	u8			pwled:1;
+	u8			pwledcnt;
+	u16			key_addr;
 	struct urb		*int_urb;
 	u8			*urb_data;
 
@@ -89,26 +96,49 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
 	u8 buf[10];
 	int rc;
 
-	/* hack */
-	buf[0] = 0xff;
-	buf[1] = 0xff;
-	buf[2] = 0xf2;
-	buf[3] = 0x2b;
-	buf[4] = 0x20;
-	buf[5] = 0x35;
-	buf[6] = 0x60;
-	buf[7] = 0x04;
-	buf[8] = 0xc0;
-	buf[9] = 0x08;
-
-	rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
-		USB_RECIP_DEVICE, REQ_00_SET_IR_VALUE, 0, 0, buf, 0x0a);
-	msleep(100);
-
-	if (rc < 0) {
-		printk(KERN_INFO "IR configuration failed");
-		return rc;
+	switch (ir->rc_type) {
+	case RC_TYPE_NEC:
+		/* Setup IR decoder for NEC standard 12MHz system clock */
+		/* IR_LEADER_CNT = 0.9ms             */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_LEADER1, 0xaa);
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_LEADER0, 0x30);
+		/* IR_PULSE_CNT = 0.7ms              */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_PULSE_CNT1, 0x20);
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_PULSE_CNT0, 0xd0);
+		/* Remote WAKEUP = enable */
+		tm6000_set_reg(dev, TM6010_REQ07_RE5_REMOTE_WAKEUP, 0xfe);
+		/* IR_WKUP_SEL = Low byte in decoded IR data */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_WAKEUP_SEL, 0xff);
+		/* IR_WKU_ADD code */
+		tm6000_set_reg(dev, TM6010_REQ07_RD8_IR_WAKEUP_ADD, 0xff);
+		tm6000_flash_led(dev, 0);
+		msleep(100);
+		tm6000_flash_led(dev, 1);
+		break;
+	default:
+		/* hack */
+		buf[0] = 0xff;
+		buf[1] = 0xff;
+		buf[2] = 0xf2;
+		buf[3] = 0x2b;
+		buf[4] = 0x20;
+		buf[5] = 0x35;
+		buf[6] = 0x60;
+		buf[7] = 0x04;
+		buf[8] = 0xc0;
+		buf[9] = 0x08;
+
+		rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR |
+			USB_RECIP_DEVICE, REQ_00_SET_IR_VALUE, 0, 0, buf, 0x0a);
+		msleep(100);
+
+		if (rc < 0) {
+			printk(KERN_INFO "IR configuration failed");
+			return rc;
+		}
+		break;
 	}
+
 	return 0;
 }
 
@@ -143,10 +173,21 @@ static int default_polling_getkey(struct tm6000_IR *ir,
 		return 0;
 
 	if (&dev->int_in) {
-		if (ir->rc_type == RC_TYPE_RC5)
+		switch (ir->rc_type) {
+		case RC_TYPE_RC5:
 			poll_result->rc_data = ir->urb_data[0];
-		else
-			poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8;
+			break;
+		case RC_TYPE_NEC:
+			if (ir->urb_data[1] == ((ir->key_addr >> 8) & 0xff)) {
+				poll_result->rc_data = ir->urb_data[0]
+							| ir->urb_data[1] << 8;
+			}
+			break;
+		default:
+			poll_result->rc_data = ir->urb_data[0]
+					| ir->urb_data[1] << 8;
+			break;
+		}
 	} else {
 		tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 0);
 		msleep(10);
@@ -186,6 +227,7 @@ static int default_polling_getkey(struct tm6000_IR *ir,
 
 static void tm6000_ir_handle_key(struct tm6000_IR *ir)
 {
+	struct tm6000_core *dev = ir->dev;
 	int result;
 	struct tm6000_ir_poll_result poll_result;
 
@@ -198,9 +240,21 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir)
 
 	dprintk("ir->get_key result data=%04x\n", poll_result.rc_data);
 
+	if (ir->pwled) {
+		if (ir->pwledcnt >= PWLED_OFF) {
+			ir->pwled = 0;
+			ir->pwledcnt = 0;
+			tm6000_flash_led(dev, 1);
+		} else
+			ir->pwledcnt += 1;
+	}
+
 	if (ir->key) {
 		rc_keydown(ir->rc, poll_result.rc_data, 0);
 		ir->key = 0;
+		ir->pwled = 1;
+		ir->pwledcnt = 0;
+		tm6000_flash_led(dev, 0);
 	}
 	return;
 }
@@ -234,19 +288,80 @@ int tm6000_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
 {
 	struct tm6000_IR *ir = rc->priv;
 
+	if (!ir)
+		return 0;
+
+	if ((rc->rc_map.scan) && (rc_type == RC_TYPE_NEC))
+		ir->key_addr = ((rc->rc_map.scan[0].scancode >> 8) & 0xffff);
+
 	ir->get_key = default_polling_getkey;
+	ir->rc_type = rc_type;
 
 	tm6000_ir_config(ir);
 	/* TODO */
 	return 0;
 }
 
+int tm6000_ir_int_start(struct tm6000_core *dev)
+{
+	struct tm6000_IR *ir = dev->ir;
+	int pipe, size;
+	int err = -ENOMEM;
+
+
+	if (!ir)
+		return -ENODEV;
+
+	ir->int_urb = usb_alloc_urb(0, GFP_KERNEL);
+
+	pipe = usb_rcvintpipe(dev->udev,
+		dev->int_in.endp->desc.bEndpointAddress
+		& USB_ENDPOINT_NUMBER_MASK);
+
+	size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
+	dprintk("IR max size: %d\n", size);
+
+	ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
+	if (ir->int_urb->transfer_buffer == NULL) {
+		usb_free_urb(ir->int_urb);
+		return err;
+	}
+	dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
+	usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
+		ir->int_urb->transfer_buffer, size,
+		tm6000_ir_urb_received, dev,
+		dev->int_in.endp->desc.bInterval);
+	err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
+	if (err) {
+		kfree(ir->int_urb->transfer_buffer);
+		usb_free_urb(ir->int_urb);
+		return err;
+	}
+	ir->urb_data = kzalloc(size, GFP_KERNEL);
+
+	return 0;
+}
+
+void tm6000_ir_int_stop(struct tm6000_core *dev)
+{
+	struct tm6000_IR *ir = dev->ir;
+
+	if (!ir)
+		return;
+
+	usb_kill_urb(ir->int_urb);
+	kfree(ir->int_urb->transfer_buffer);
+	usb_free_urb(ir->int_urb);
+	ir->int_urb = NULL;
+	kfree(ir->urb_data);
+	ir->urb_data = NULL;
+}
+
 int tm6000_ir_init(struct tm6000_core *dev)
 {
 	struct tm6000_IR *ir;
 	struct rc_dev *rc;
 	int err = -ENOMEM;
-	int pipe, size;
 
 	if (!enable_ir)
 		return -ENODEV;
@@ -276,6 +391,9 @@ int tm6000_ir_init(struct tm6000_core *dev)
 	rc->driver_type = RC_DRIVER_SCANCODE;
 
 	ir->polling = 50;
+	ir->pwled = 0;
+	ir->pwledcnt = 0;
+
 
 	snprintf(ir->name, sizeof(ir->name), "tm5600/60x0 IR (%s)",
 						dev->name);
@@ -298,32 +416,10 @@ int tm6000_ir_init(struct tm6000_core *dev)
 	if (&dev->int_in) {
 		dprintk("IR over int\n");
 
-		ir->int_urb = usb_alloc_urb(0, GFP_KERNEL);
-
-		pipe = usb_rcvintpipe(dev->udev,
-			dev->int_in.endp->desc.bEndpointAddress
-			& USB_ENDPOINT_NUMBER_MASK);
+		err = tm6000_ir_int_start(dev);
 
-		size = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
-		dprintk("IR max size: %d\n", size);
-
-		ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
-		if (ir->int_urb->transfer_buffer == NULL) {
-			usb_free_urb(ir->int_urb);
-			goto out;
-		}
-		dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
-		usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
-			ir->int_urb->transfer_buffer, size,
-			tm6000_ir_urb_received, dev,
-			dev->int_in.endp->desc.bInterval);
-		err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
-		if (err) {
-			kfree(ir->int_urb->transfer_buffer);
-			usb_free_urb(ir->int_urb);
+		if (err)
 			goto out;
-		}
-		ir->urb_data = kzalloc(size, GFP_KERNEL);
 	}
 
 	/* ir register */
@@ -352,12 +448,7 @@ int tm6000_ir_fini(struct tm6000_core *dev)
 	rc_unregister_device(ir->rc);
 
 	if (ir->int_urb) {
-		usb_kill_urb(ir->int_urb);
-		kfree(ir->int_urb->transfer_buffer);
-		usb_free_urb(ir->int_urb);
-		ir->int_urb = NULL;
-		kfree(ir->urb_data);
-		ir->urb_data = NULL;
+		tm6000_ir_int_stop(dev);
 	}
 
 	kfree(ir);
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index c5690b2..b06701b 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -545,11 +545,16 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
 
 	/* De-allocates all pending stuff */
 	tm6000_uninit_isoc(dev);
+	/* Stop interrupt USB pipe */
+	tm6000_ir_int_stop(dev);
 
 	usb_set_interface(dev->udev,
 			  dev->isoc_in.bInterfaceNumber,
 			  dev->isoc_in.bAlternateSetting);
 
+	/* Start interrupt USB pipe */
+	tm6000_ir_int_start(dev);
+
 	pipe = usb_rcvisocpipe(dev->udev,
 			       dev->isoc_in.endp->desc.bEndpointAddress &
 			       USB_ENDPOINT_NUMBER_MASK);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 46017b6..bf11eee 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -266,6 +266,7 @@ struct tm6000_fh {
 int tm6000_tuner_callback(void *ptr, int component, int command, int arg);
 int tm6000_xc5000_callback(void *ptr, int component, int command, int arg);
 int tm6000_cards_setup(struct tm6000_core *dev);
+void tm6000_flash_led(struct tm6000_core *dev, u8 state);
 
 /* In tm6000-core.c */
 
@@ -332,6 +333,8 @@ int tm6000_queue_init(struct tm6000_core *dev);
 int tm6000_ir_init(struct tm6000_core *dev);
 int tm6000_ir_fini(struct tm6000_core *dev);
 void tm6000_ir_wait(struct tm6000_core *dev, u8 state);
+int tm6000_ir_int_start(struct tm6000_core *dev);
+void tm6000_ir_int_stop(struct tm6000_core *dev);
 
 /* Debug stuff */
 

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH] tm6000: rework init code
  2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
  2010-12-18 13:56                                                     ` Andy Walls
  2010-12-20  5:41                                                     ` Dmitri Belimov
@ 2011-01-13  3:46                                                     ` Dmitri Belimov
  2011-01-20  6:05                                                     ` [PATCH] tm6000: add/rework reg.defines Dmitri Belimov
  3 siblings, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2011-01-13  3:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

[-- Attachment #1: Type: text/plain, Size: 2224 bytes --]

Hi

Rework device init part. Move common code part to a function.
Usefull for register multiple devices like video, radio, vbi etc.

diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index 8fe017c..4d866cc 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1450,29 +1450,55 @@ static struct video_device tm6000_template = {
  * ------------------------------------------------------------------
  */
 
-int tm6000_v4l2_register(struct tm6000_core *dev)
+static struct video_device *vdev_init(struct tm6000_core *dev,
+		const struct video_device
+		*template, const char *type_name)
 {
-	int ret = -1;
 	struct video_device *vfd;
 
 	vfd = video_device_alloc();
-	if(!vfd) {
+	if (NULL == vfd)
+		return NULL;
+
+	*vfd = *template;
+	vfd->v4l2_dev = &dev->v4l2_dev;
+	vfd->release = video_device_release;
+	vfd->debug = tm6000_debug;
+	vfd->lock = &dev->lock;
+
+	snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
+
+	video_set_drvdata(vfd, dev);
+	return vfd;
+}
+
+int tm6000_v4l2_register(struct tm6000_core *dev)
+{
+	int ret = -1;
+
+	dev->vfd = vdev_init(dev, &tm6000_template, "video");
+
+	if (!dev->vfd) {
+		printk(KERN_INFO "%s: can't register video device\n",
+		       dev->name);
 		return -ENOMEM;
 	}
-	dev->vfd = vfd;
 
 	/* init video dma queues */
 	INIT_LIST_HEAD(&dev->vidq.active);
 	INIT_LIST_HEAD(&dev->vidq.queued);
 
-	memcpy(dev->vfd, &tm6000_template, sizeof(*(dev->vfd)));
-	dev->vfd->debug = tm6000_debug;
-	dev->vfd->lock = &dev->lock;
+	ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
 
-	vfd->v4l2_dev = &dev->v4l2_dev;
-	video_set_drvdata(vfd, dev);
+	if (ret < 0) {
+		printk(KERN_INFO "%s: can't register video device\n",
+		       dev->name);
+		return ret;
+	}
+
+	printk(KERN_INFO "%s: registered device %s\n",
+	       dev->name, video_device_node_name(dev->vfd));
 
-	ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
 	printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
 	return ret;
 }

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>


With my best regards, Dmitry.

[-- Attachment #2: tm6000_video_init.patch --]
[-- Type: text/x-patch, Size: 2059 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index 8fe017c..4d866cc 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1450,29 +1450,55 @@ static struct video_device tm6000_template = {
  * ------------------------------------------------------------------
  */
 
-int tm6000_v4l2_register(struct tm6000_core *dev)
+static struct video_device *vdev_init(struct tm6000_core *dev,
+		const struct video_device
+		*template, const char *type_name)
 {
-	int ret = -1;
 	struct video_device *vfd;
 
 	vfd = video_device_alloc();
-	if(!vfd) {
+	if (NULL == vfd)
+		return NULL;
+
+	*vfd = *template;
+	vfd->v4l2_dev = &dev->v4l2_dev;
+	vfd->release = video_device_release;
+	vfd->debug = tm6000_debug;
+	vfd->lock = &dev->lock;
+
+	snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
+
+	video_set_drvdata(vfd, dev);
+	return vfd;
+}
+
+int tm6000_v4l2_register(struct tm6000_core *dev)
+{
+	int ret = -1;
+
+	dev->vfd = vdev_init(dev, &tm6000_template, "video");
+
+	if (!dev->vfd) {
+		printk(KERN_INFO "%s: can't register video device\n",
+		       dev->name);
 		return -ENOMEM;
 	}
-	dev->vfd = vfd;
 
 	/* init video dma queues */
 	INIT_LIST_HEAD(&dev->vidq.active);
 	INIT_LIST_HEAD(&dev->vidq.queued);
 
-	memcpy(dev->vfd, &tm6000_template, sizeof(*(dev->vfd)));
-	dev->vfd->debug = tm6000_debug;
-	dev->vfd->lock = &dev->lock;
+	ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
 
-	vfd->v4l2_dev = &dev->v4l2_dev;
-	video_set_drvdata(vfd, dev);
+	if (ret < 0) {
+		printk(KERN_INFO "%s: can't register video device\n",
+		       dev->name);
+		return ret;
+	}
+
+	printk(KERN_INFO "%s: registered device %s\n",
+	       dev->name, video_device_node_name(dev->vfd));
 
-	ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
 	printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
 	return ret;
 }

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH] tm6000: add/rework reg.defines
  2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
                                                                       ` (2 preceding siblings ...)
  2011-01-13  3:46                                                     ` [PATCH] tm6000: rework init code Dmitri Belimov
@ 2011-01-20  6:05                                                     ` Dmitri Belimov
  2011-01-20 19:25                                                       ` Stefan Ringel
  3 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2011-01-20  6:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

[-- Attachment #1: Type: text/plain, Size: 5845 bytes --]

Hi

Rework registers defines. Add TM6000 specific registers defines.
Add marks and comments for TM6010 specific registers.

diff --git a/drivers/staging/tm6000/tm6000-regs.h b/drivers/staging/tm6000/tm6000-regs.h
index 1f0ced8..5375a83 100644
--- a/drivers/staging/tm6000/tm6000-regs.h
+++ b/drivers/staging/tm6000/tm6000-regs.h
@@ -97,6 +97,34 @@ enum {
 	TM6000_URB_MSG_ERR,
 };
 
+/* Define specific TM6000 Video decoder registers */
+#define TM6000_REQ07_RD8_TEST_SEL			0x07, 0xd8
+#define TM6000_REQ07_RD9_A_SIM_SEL			0x07, 0xd9
+#define TM6000_REQ07_RDA_CLK_SEL			0x07, 0xda
+#define TM6000_REQ07_RDB_OUT_SEL			0x07, 0xdb
+#define TM6000_REQ07_RDC_NSEL_I2S			0x07, 0xdc
+#define TM6000_REQ07_RDD_GPIO2_MDRV			0x07, 0xdd
+#define TM6000_REQ07_RDE_GPIO1_MDRV			0x07, 0xde
+#define TM6000_REQ07_RDF_PWDOWN_ACLK			0x07, 0xdf
+#define TM6000_REQ07_RE0_VADC_REF_CTL			0x07, 0xe0
+#define TM6000_REQ07_RE1_VADC_DACLIMP			0x07, 0xe1
+#define TM6000_REQ07_RE2_VADC_STATUS_CTL		0x07, 0xe2
+#define TM6000_REQ07_RE3_VADC_INP_LPF_SEL1		0x07, 0xe3
+#define TM6000_REQ07_RE4_VADC_TARGET1			0x07, 0xe4
+#define TM6000_REQ07_RE5_VADC_INP_LPF_SEL2		0x07, 0xe5
+#define TM6000_REQ07_RE6_VADC_TARGET2			0x07, 0xe6
+#define TM6000_REQ07_RE7_VADC_AGAIN_CTL			0x07, 0xe7
+#define TM6000_REQ07_RE8_VADC_PWDOWN_CTL		0x07, 0xe8
+#define TM6000_REQ07_RE9_VADC_INPUT_CTL1		0x07, 0xe9
+#define TM6000_REQ07_REA_VADC_INPUT_CTL2		0x07, 0xea
+#define TM6000_REQ07_REB_VADC_AADC_MODE			0x07, 0xeb
+#define TM6000_REQ07_REC_VADC_AADC_LVOL			0x07, 0xec
+#define TM6000_REQ07_RED_VADC_AADC_RVOL			0x07, 0xed
+#define TM6000_REQ07_REE_VADC_CTRL_SEL_CONTROL		0x07, 0xee
+#define TM6000_REQ07_REF_VADC_GAIN_MAP_CTL		0x07, 0xef
+#define TM6000_REQ07_RFD_BIST_ERR_VST_LOW		0x07, 0xfd
+#define TM6000_REQ07_RFE_BIST_ERR_VST_HIGH		0x07, 0xfe
+
 /* Define TM6000/TM6010 Video decoder registers */
 #define TM6010_REQ07_R00_VIDEO_CONTROL0			0x07, 0x00
 #define TM6010_REQ07_R01_VIDEO_CONTROL1			0x07, 0x01
@@ -241,6 +269,7 @@ enum {
 #define TM6010_REQ07_RC9_VEND1				0x07, 0xc9
 #define TM6010_REQ07_RCA_VEND0				0x07, 0xca
 #define TM6010_REQ07_RCB_DELAY				0x07, 0xcb
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RCC_ACTIVE_VIDEO_IF		0x07, 0xcc
 #define TM6010_REQ07_RD0_USB_PERIPHERY_CONTROL		0x07, 0xd0
 #define TM6010_REQ07_RD1_ADDR_FOR_REQ1			0x07, 0xd1
@@ -250,32 +279,59 @@ enum {
 #define TM6010_REQ07_RD5_POWERSAVE			0x07, 0xd5
 #define TM6010_REQ07_RD6_ENDP_REQ1_REQ2			0x07, 0xd6
 #define TM6010_REQ07_RD7_ENDP_REQ3_REQ4			0x07, 0xd7
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR				0x07, 0xd8
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_BSIZE			0x07, 0xd9
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_WAKEUP_SEL			0x07, 0xda
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_WAKEUP_ADD			0x07, 0xdb
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_LEADER1			0x07, 0xdc
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_LEADER0			0x07, 0xdd
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_PULSE_CNT1			0x07, 0xde
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_PULSE_CNT0			0x07, 0xdf
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE0_DVIDEO_SOURCE			0x07, 0xe0
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE0_DVIDEO_SOURCE_IF		0x07, 0xe1
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE2_OUT_SEL2			0x07, 0xe2
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE3_OUT_SEL1			0x07, 0xe3
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE4_OUT_SEL0			0x07, 0xe4
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE5_REMOTE_WAKEUP			0x07, 0xe5
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE7_PUB_GPIO			0x07, 0xe7
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE8_TYPESEL_MOS_I2S		0x07, 0xe8
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE9_TYPESEL_MOS_TS			0x07, 0xe9
+/* ONLY for TM6010 */
 #define TM6010_REQ07_REA_TYPESEL_MOS_CCIR		0x07, 0xea
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF0_BIST_CRC_RESULT0		0x07, 0xf0
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF1_BIST_CRC_RESULT1		0x07, 0xf1
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF2_BIST_CRC_RESULT2		0x07, 0xf2
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF3_BIST_CRC_RESULT3		0x07, 0xf3
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF4_BIST_ERR_VST2			0x07, 0xf4
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF5_BIST_ERR_VST1			0x07, 0xf5
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF6_BIST_ERR_VST0			0x07, 0xf6
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF7_BIST				0x07, 0xf7
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RFE_POWER_DOWN			0x07, 0xfe
 #define TM6010_REQ07_RFF_SOFT_RESET			0x07, 0xff
 
@@ -477,7 +533,8 @@ enum {
 #define TM6010_REQ05_RC4_DATA_FIFO14		0x05, 0xf8
 #define TM6010_REQ05_RC4_DATA_FIFO15		0x05, 0xfc
 
-/* Define TM6000/TM6010 Audio decoder registers */
+/* Define TM6010 Audio decoder registers */
+/* This core available only in TM6010 */
 #define TM6010_REQ08_R00_A_VERSION		0x08, 0x00
 #define TM6010_REQ08_R01_A_INIT			0x08, 0x01
 #define TM6010_REQ08_R02_A_FIX_GAIN_CTRL	0x08, 0x02
@@ -518,7 +575,7 @@ enum {
 #define TM6010_REQ08_R27_A_NOISE_AMP		0x08, 0x27
 #define TM6010_REQ08_R28_A_AUDIO_MODE_RES	0x08, 0x28
 
-/* Define TM6000/TM6010 Video ADC registers */
+/* Define TM6010 Video ADC registers */
 #define TM6010_REQ08_RE0_ADC_REF		0x08, 0xe0
 #define TM6010_REQ08_RE1_DAC_CLMP		0x08, 0xe1
 #define TM6010_REQ08_RE2_POWER_DOWN_CTRL1	0x08, 0xe2
@@ -534,7 +591,7 @@ enum {
 #define TM6010_REQ08_REC_REVERSE_YC_CTRL	0x08, 0xec
 #define TM6010_REQ08_RED_GAIN_SEL		0x08, 0xed
 
-/* Define TM6000/TM6010 Audio ADC registers */
+/* Define TM6010 Audio ADC registers */
 #define TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG	0x08, 0xf0
 #define TM6010_REQ08_RF1_AADC_POWER_DOWN	0x08, 0xf1
 #define TM6010_REQ08_RF2_LEFT_CHANNEL_VOL	0x08, 0xf2

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>


With my best regards, Dmitry.

[-- Attachment #2: tm6000_reg_defines.patch --]
[-- Type: text/x-patch, Size: 5690 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-regs.h b/drivers/staging/tm6000/tm6000-regs.h
index 1f0ced8..5375a83 100644
--- a/drivers/staging/tm6000/tm6000-regs.h
+++ b/drivers/staging/tm6000/tm6000-regs.h
@@ -97,6 +97,34 @@ enum {
 	TM6000_URB_MSG_ERR,
 };
 
+/* Define specific TM6000 Video decoder registers */
+#define TM6000_REQ07_RD8_TEST_SEL			0x07, 0xd8
+#define TM6000_REQ07_RD9_A_SIM_SEL			0x07, 0xd9
+#define TM6000_REQ07_RDA_CLK_SEL			0x07, 0xda
+#define TM6000_REQ07_RDB_OUT_SEL			0x07, 0xdb
+#define TM6000_REQ07_RDC_NSEL_I2S			0x07, 0xdc
+#define TM6000_REQ07_RDD_GPIO2_MDRV			0x07, 0xdd
+#define TM6000_REQ07_RDE_GPIO1_MDRV			0x07, 0xde
+#define TM6000_REQ07_RDF_PWDOWN_ACLK			0x07, 0xdf
+#define TM6000_REQ07_RE0_VADC_REF_CTL			0x07, 0xe0
+#define TM6000_REQ07_RE1_VADC_DACLIMP			0x07, 0xe1
+#define TM6000_REQ07_RE2_VADC_STATUS_CTL		0x07, 0xe2
+#define TM6000_REQ07_RE3_VADC_INP_LPF_SEL1		0x07, 0xe3
+#define TM6000_REQ07_RE4_VADC_TARGET1			0x07, 0xe4
+#define TM6000_REQ07_RE5_VADC_INP_LPF_SEL2		0x07, 0xe5
+#define TM6000_REQ07_RE6_VADC_TARGET2			0x07, 0xe6
+#define TM6000_REQ07_RE7_VADC_AGAIN_CTL			0x07, 0xe7
+#define TM6000_REQ07_RE8_VADC_PWDOWN_CTL		0x07, 0xe8
+#define TM6000_REQ07_RE9_VADC_INPUT_CTL1		0x07, 0xe9
+#define TM6000_REQ07_REA_VADC_INPUT_CTL2		0x07, 0xea
+#define TM6000_REQ07_REB_VADC_AADC_MODE			0x07, 0xeb
+#define TM6000_REQ07_REC_VADC_AADC_LVOL			0x07, 0xec
+#define TM6000_REQ07_RED_VADC_AADC_RVOL			0x07, 0xed
+#define TM6000_REQ07_REE_VADC_CTRL_SEL_CONTROL		0x07, 0xee
+#define TM6000_REQ07_REF_VADC_GAIN_MAP_CTL		0x07, 0xef
+#define TM6000_REQ07_RFD_BIST_ERR_VST_LOW		0x07, 0xfd
+#define TM6000_REQ07_RFE_BIST_ERR_VST_HIGH		0x07, 0xfe
+
 /* Define TM6000/TM6010 Video decoder registers */
 #define TM6010_REQ07_R00_VIDEO_CONTROL0			0x07, 0x00
 #define TM6010_REQ07_R01_VIDEO_CONTROL1			0x07, 0x01
@@ -241,6 +269,7 @@ enum {
 #define TM6010_REQ07_RC9_VEND1				0x07, 0xc9
 #define TM6010_REQ07_RCA_VEND0				0x07, 0xca
 #define TM6010_REQ07_RCB_DELAY				0x07, 0xcb
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RCC_ACTIVE_VIDEO_IF		0x07, 0xcc
 #define TM6010_REQ07_RD0_USB_PERIPHERY_CONTROL		0x07, 0xd0
 #define TM6010_REQ07_RD1_ADDR_FOR_REQ1			0x07, 0xd1
@@ -250,32 +279,59 @@ enum {
 #define TM6010_REQ07_RD5_POWERSAVE			0x07, 0xd5
 #define TM6010_REQ07_RD6_ENDP_REQ1_REQ2			0x07, 0xd6
 #define TM6010_REQ07_RD7_ENDP_REQ3_REQ4			0x07, 0xd7
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR				0x07, 0xd8
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_BSIZE			0x07, 0xd9
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_WAKEUP_SEL			0x07, 0xda
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_WAKEUP_ADD			0x07, 0xdb
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_LEADER1			0x07, 0xdc
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_LEADER0			0x07, 0xdd
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_PULSE_CNT1			0x07, 0xde
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RD8_IR_PULSE_CNT0			0x07, 0xdf
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE0_DVIDEO_SOURCE			0x07, 0xe0
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE0_DVIDEO_SOURCE_IF		0x07, 0xe1
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE2_OUT_SEL2			0x07, 0xe2
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE3_OUT_SEL1			0x07, 0xe3
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE4_OUT_SEL0			0x07, 0xe4
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE5_REMOTE_WAKEUP			0x07, 0xe5
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE7_PUB_GPIO			0x07, 0xe7
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE8_TYPESEL_MOS_I2S		0x07, 0xe8
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RE9_TYPESEL_MOS_TS			0x07, 0xe9
+/* ONLY for TM6010 */
 #define TM6010_REQ07_REA_TYPESEL_MOS_CCIR		0x07, 0xea
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF0_BIST_CRC_RESULT0		0x07, 0xf0
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF1_BIST_CRC_RESULT1		0x07, 0xf1
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF2_BIST_CRC_RESULT2		0x07, 0xf2
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF3_BIST_CRC_RESULT3		0x07, 0xf3
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF4_BIST_ERR_VST2			0x07, 0xf4
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF5_BIST_ERR_VST1			0x07, 0xf5
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF6_BIST_ERR_VST0			0x07, 0xf6
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RF7_BIST				0x07, 0xf7
+/* ONLY for TM6010 */
 #define TM6010_REQ07_RFE_POWER_DOWN			0x07, 0xfe
 #define TM6010_REQ07_RFF_SOFT_RESET			0x07, 0xff
 
@@ -477,7 +533,8 @@ enum {
 #define TM6010_REQ05_RC4_DATA_FIFO14		0x05, 0xf8
 #define TM6010_REQ05_RC4_DATA_FIFO15		0x05, 0xfc
 
-/* Define TM6000/TM6010 Audio decoder registers */
+/* Define TM6010 Audio decoder registers */
+/* This core available only in TM6010 */
 #define TM6010_REQ08_R00_A_VERSION		0x08, 0x00
 #define TM6010_REQ08_R01_A_INIT			0x08, 0x01
 #define TM6010_REQ08_R02_A_FIX_GAIN_CTRL	0x08, 0x02
@@ -518,7 +575,7 @@ enum {
 #define TM6010_REQ08_R27_A_NOISE_AMP		0x08, 0x27
 #define TM6010_REQ08_R28_A_AUDIO_MODE_RES	0x08, 0x28
 
-/* Define TM6000/TM6010 Video ADC registers */
+/* Define TM6010 Video ADC registers */
 #define TM6010_REQ08_RE0_ADC_REF		0x08, 0xe0
 #define TM6010_REQ08_RE1_DAC_CLMP		0x08, 0xe1
 #define TM6010_REQ08_RE2_POWER_DOWN_CTRL1	0x08, 0xe2
@@ -534,7 +591,7 @@ enum {
 #define TM6010_REQ08_REC_REVERSE_YC_CTRL	0x08, 0xec
 #define TM6010_REQ08_RED_GAIN_SEL		0x08, 0xed
 
-/* Define TM6000/TM6010 Audio ADC registers */
+/* Define TM6010 Audio ADC registers */
 #define TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG	0x08, 0xf0
 #define TM6010_REQ08_RF1_AADC_POWER_DOWN	0x08, 0xf1
 #define TM6010_REQ08_RF2_LEFT_CHANNEL_VOL	0x08, 0xf2

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH] tm6000: add/rework reg.defines
  2011-01-20  6:05                                                     ` [PATCH] tm6000: add/rework reg.defines Dmitri Belimov
@ 2011-01-20 19:25                                                       ` Stefan Ringel
  2011-01-20 23:20                                                         ` Dmitri Belimov
  2011-02-17  5:12                                                         ` tm6000 and radio Dmitri Belimov
  0 siblings, 2 replies; 36+ messages in thread
From: Stefan Ringel @ 2011-01-20 19:25 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Am 20.01.2011 07:05, schrieb Dmitri Belimov:
> Hi
>
> Rework registers defines. Add TM6000 specific registers defines.
> Add marks and comments for TM6010 specific registers.
>
> diff --git a/drivers/staging/tm6000/tm6000-regs.h
b/drivers/staging/tm6000/tm6000-regs.h
> index 1f0ced8..5375a83 100644
> --- a/drivers/staging/tm6000/tm6000-regs.h
> +++ b/drivers/staging/tm6000/tm6000-regs.h
> @@ -97,6 +97,34 @@ enum {
> TM6000_URB_MSG_ERR,
> };
>
> +/* Define specific TM6000 Video decoder registers */
> +#define TM6000_REQ07_RD8_TEST_SEL 0x07, 0xd8
> +#define TM6000_REQ07_RD9_A_SIM_SEL 0x07, 0xd9
> +#define TM6000_REQ07_RDA_CLK_SEL 0x07, 0xda
> +#define TM6000_REQ07_RDB_OUT_SEL 0x07, 0xdb
> +#define TM6000_REQ07_RDC_NSEL_I2S 0x07, 0xdc
> +#define TM6000_REQ07_RDD_GPIO2_MDRV 0x07, 0xdd
> +#define TM6000_REQ07_RDE_GPIO1_MDRV 0x07, 0xde
> +#define TM6000_REQ07_RDF_PWDOWN_ACLK 0x07, 0xdf
> +#define TM6000_REQ07_RE0_VADC_REF_CTL 0x07, 0xe0
> +#define TM6000_REQ07_RE1_VADC_DACLIMP 0x07, 0xe1
> +#define TM6000_REQ07_RE2_VADC_STATUS_CTL 0x07, 0xe2
> +#define TM6000_REQ07_RE3_VADC_INP_LPF_SEL1 0x07, 0xe3
> +#define TM6000_REQ07_RE4_VADC_TARGET1 0x07, 0xe4
> +#define TM6000_REQ07_RE5_VADC_INP_LPF_SEL2 0x07, 0xe5
> +#define TM6000_REQ07_RE6_VADC_TARGET2 0x07, 0xe6
> +#define TM6000_REQ07_RE7_VADC_AGAIN_CTL 0x07, 0xe7
> +#define TM6000_REQ07_RE8_VADC_PWDOWN_CTL 0x07, 0xe8
> +#define TM6000_REQ07_RE9_VADC_INPUT_CTL1 0x07, 0xe9
> +#define TM6000_REQ07_REA_VADC_INPUT_CTL2 0x07, 0xea
> +#define TM6000_REQ07_REB_VADC_AADC_MODE 0x07, 0xeb
> +#define TM6000_REQ07_REC_VADC_AADC_LVOL 0x07, 0xec
> +#define TM6000_REQ07_RED_VADC_AADC_RVOL 0x07, 0xed
> +#define TM6000_REQ07_REE_VADC_CTRL_SEL_CONTROL 0x07, 0xee
> +#define TM6000_REQ07_REF_VADC_GAIN_MAP_CTL 0x07, 0xef
> +#define TM6000_REQ07_RFD_BIST_ERR_VST_LOW 0x07, 0xfd
> +#define TM6000_REQ07_RFE_BIST_ERR_VST_HIGH 0x07, 0xfe
> +
> /* Define TM6000/TM6010 Video decoder registers */
> #define TM6010_REQ07_R00_VIDEO_CONTROL0 0x07, 0x00
> #define TM6010_REQ07_R01_VIDEO_CONTROL1 0x07, 0x01
> @@ -241,6 +269,7 @@ enum {
> #define TM6010_REQ07_RC9_VEND1 0x07, 0xc9
> #define TM6010_REQ07_RCA_VEND0 0x07, 0xca
> #define TM6010_REQ07_RCB_DELAY 0x07, 0xcb
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RCC_ACTIVE_VIDEO_IF 0x07, 0xcc
> #define TM6010_REQ07_RD0_USB_PERIPHERY_CONTROL 0x07, 0xd0
> #define TM6010_REQ07_RD1_ADDR_FOR_REQ1 0x07, 0xd1
> @@ -250,32 +279,59 @@ enum {
> #define TM6010_REQ07_RD5_POWERSAVE 0x07, 0xd5
> #define TM6010_REQ07_RD6_ENDP_REQ1_REQ2 0x07, 0xd6
> #define TM6010_REQ07_RD7_ENDP_REQ3_REQ4 0x07, 0xd7
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR 0x07, 0xd8
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_BSIZE 0x07, 0xd9
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_WAKEUP_SEL 0x07, 0xda
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_WAKEUP_ADD 0x07, 0xdb
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_LEADER1 0x07, 0xdc
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_LEADER0 0x07, 0xdd
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_PULSE_CNT1 0x07, 0xde
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RD8_IR_PULSE_CNT0 0x07, 0xdf
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE0_DVIDEO_SOURCE 0x07, 0xe0
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE0_DVIDEO_SOURCE_IF 0x07, 0xe1
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE2_OUT_SEL2 0x07, 0xe2
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE3_OUT_SEL1 0x07, 0xe3
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE4_OUT_SEL0 0x07, 0xe4
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE5_REMOTE_WAKEUP 0x07, 0xe5
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE7_PUB_GPIO 0x07, 0xe7
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE8_TYPESEL_MOS_I2S 0x07, 0xe8
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RE9_TYPESEL_MOS_TS 0x07, 0xe9
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_REA_TYPESEL_MOS_CCIR 0x07, 0xea
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF0_BIST_CRC_RESULT0 0x07, 0xf0
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF1_BIST_CRC_RESULT1 0x07, 0xf1
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF2_BIST_CRC_RESULT2 0x07, 0xf2
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF3_BIST_CRC_RESULT3 0x07, 0xf3
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF4_BIST_ERR_VST2 0x07, 0xf4
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF5_BIST_ERR_VST1 0x07, 0xf5
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF6_BIST_ERR_VST0 0x07, 0xf6
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RF7_BIST 0x07, 0xf7
> +/* ONLY for TM6010 */
> #define TM6010_REQ07_RFE_POWER_DOWN 0x07, 0xfe
> #define TM6010_REQ07_RFF_SOFT_RESET 0x07, 0xff
>
> @@ -477,7 +533,8 @@ enum {
> #define TM6010_REQ05_RC4_DATA_FIFO14 0x05, 0xf8
> #define TM6010_REQ05_RC4_DATA_FIFO15 0x05, 0xfc
>
> -/* Define TM6000/TM6010 Audio decoder registers */
> +/* Define TM6010 Audio decoder registers */
> +/* This core available only in TM6010 */
> #define TM6010_REQ08_R00_A_VERSION 0x08, 0x00
> #define TM6010_REQ08_R01_A_INIT 0x08, 0x01
> #define TM6010_REQ08_R02_A_FIX_GAIN_CTRL 0x08, 0x02
> @@ -518,7 +575,7 @@ enum {
> #define TM6010_REQ08_R27_A_NOISE_AMP 0x08, 0x27
> #define TM6010_REQ08_R28_A_AUDIO_MODE_RES 0x08, 0x28
>
> -/* Define TM6000/TM6010 Video ADC registers */
> +/* Define TM6010 Video ADC registers */
> #define TM6010_REQ08_RE0_ADC_REF 0x08, 0xe0
> #define TM6010_REQ08_RE1_DAC_CLMP 0x08, 0xe1
> #define TM6010_REQ08_RE2_POWER_DOWN_CTRL1 0x08, 0xe2
> @@ -534,7 +591,7 @@ enum {
> #define TM6010_REQ08_REC_REVERSE_YC_CTRL 0x08, 0xec
> #define TM6010_REQ08_RED_GAIN_SEL 0x08, 0xed
>
> -/* Define TM6000/TM6010 Audio ADC registers */
> +/* Define TM6010 Audio ADC registers */
> #define TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG 0x08, 0xf0
> #define TM6010_REQ08_RF1_AADC_POWER_DOWN 0x08, 0xf1
> #define TM6010_REQ08_RF2_LEFT_CHANNEL_VOL 0x08, 0xf2
>
> Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>
>
>
> With my best regards, Dmitry.
Dmitry, that are good news! And that anwers my questions. Now I think
we must separate the both chipsets in any points:

    *  audio standards
    *  video standards
    * in tm6000-alsa the functions " _tm6000_start_audio_dma" and
      "_tm6000_stop_audio_dma"
    * in tm6000-input "tm6000_ir_config"
    * in tm6000-core ?? "init_analog_mode" and "init_digital_mode"
    * in tm6000-core "tm6000_set_audio_bitrate"

My rework in tm6000-video, isoc usb buffer and vbi device, I move this
into summer 2011!!

Stefan Ringel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iQEcBAEBAgAGBQJNOIxEAAoJEAWtPFjxMvFG3LQIAKlIMVWYTTPA5RD45Sw4QBQH
I+yqhs89Qe7bKl+JjDrSiCG/ttRDtTy0+ksUFmicglntLmmtPVQnv59tIU9evQmn
Yt7n1XWHcq442+ySbQ/3fVLay1WG1eJ3UEsC7bkpT2hSUhmUf6zjSZ3ockIJfxEJ
geqFOy630vfwcKcS7KWgAJO8LKYQXcW8TLmkb3/D4W1G8o7zCKIH624Q5u+k1IGk
mmm5CiqO17FS/oK0pxTZAY8uqWr3DH3UUqiMR3GdGoivaOR+1QCdrrYZXkQxklai
zPQ6AYx/zPStZK8iUSSOHpVkfqHTgB3f6BSpsWhNGT3mgW8tTxnAz/MyECUiEms=
=Cxjk
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] tm6000: add/rework reg.defines
  2011-01-20 19:25                                                       ` Stefan Ringel
@ 2011-01-20 23:20                                                         ` Dmitri Belimov
  2011-02-17  5:12                                                         ` tm6000 and radio Dmitri Belimov
  1 sibling, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2011-01-20 23:20 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

Hi Stefan

> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1

snip

> > #define TM6010_REQ08_RF2_LEFT_CHANNEL_VOL 0x08, 0xf2
> >
> > Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov
> > <d.belimov@gmail.com>
> >
> >
> > With my best regards, Dmitry.
> Dmitry, that are good news! And that anwers my questions. Now I think
> we must separate the both chipsets in any points:
> 
>     *  audio standards
>     *  video standards
>     * in tm6000-alsa the functions " _tm6000_start_audio_dma" and
>       "_tm6000_stop_audio_dma"
>     * in tm6000-input "tm6000_ir_config"
>     * in tm6000-core ?? "init_analog_mode" and "init_digital_mode"
>     * in tm6000-core "tm6000_set_audio_bitrate"
> 
> My rework in tm6000-video, isoc usb buffer and vbi device, I move this
> into summer 2011!!

Ok. I work too. :)
I have Software Programmers Guide from Trident for TM6000 and TM6010 under NDA.
If you have any question about any registers you can ask me.

With my best regards, Dmitry.

> Stefan Ringel
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.12 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>  
> iQEcBAEBAgAGBQJNOIxEAAoJEAWtPFjxMvFG3LQIAKlIMVWYTTPA5RD45Sw4QBQH
> I+yqhs89Qe7bKl+JjDrSiCG/ttRDtTy0+ksUFmicglntLmmtPVQnv59tIU9evQmn
> Yt7n1XWHcq442+ySbQ/3fVLay1WG1eJ3UEsC7bkpT2hSUhmUf6zjSZ3ockIJfxEJ
> geqFOy630vfwcKcS7KWgAJO8LKYQXcW8TLmkb3/D4W1G8o7zCKIH624Q5u+k1IGk
> mmm5CiqO17FS/oK0pxTZAY8uqWr3DH3UUqiMR3GdGoivaOR+1QCdrrYZXkQxklai
> zPQ6AYx/zPStZK8iUSSOHpVkfqHTgB3f6BSpsWhNGT3mgW8tTxnAz/MyECUiEms=
> =Cxjk
> -----END PGP SIGNATURE-----
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* tm6000 and radio
  2011-01-20 19:25                                                       ` Stefan Ringel
  2011-01-20 23:20                                                         ` Dmitri Belimov
@ 2011-02-17  5:12                                                         ` Dmitri Belimov
  2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2011-02-17  5:12 UTC (permalink / raw)
  To: Stefan Ringel
  Cc: Mauro Carvalho Chehab, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

Hi All

Now I have working radio for our TV cards based on tm6000 and xc5000.
TV works too.

After some time I'll send my changes for discuss here.

With my best regards, Dmitry.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: tm6000 and radio
  2011-02-17  5:12                                                         ` tm6000 and radio Dmitri Belimov
@ 2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
  2011-02-18  1:11                                                             ` [PATCH] tm6000: add radio Dmitri Belimov
                                                                               ` (3 more replies)
  0 siblings, 4 replies; 36+ messages in thread
From: Mauro Carvalho Chehab @ 2011-02-17 20:58 UTC (permalink / raw)
  To: Dmitri Belimov
  Cc: Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

Em 17-02-2011 03:12, Dmitri Belimov escreveu:
> Hi All
> 
> Now I have working radio for our TV cards based on tm6000 and xc5000.
> TV works too.

Great news! I think that the only remaining issue is audio that still
doesn't work with some audio standards. The last time I tested here,
PAL/M didn't work.
> 
> After some time I'll send my changes for discuss here.
> 
> With my best regards, Dmitry.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH] tm6000: add radio
  2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
@ 2011-02-18  1:11                                                             ` Dmitri Belimov
  2011-03-01  4:55                                                             ` [PATCH] tm6000: add audio conf for new cards Dmitri Belimov
                                                                               ` (2 subsequent siblings)
  3 siblings, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2011-02-18  1:11 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Stefan Ringel, Felipe Sanches, Bee Hock Goh,
	Luis Henrique Fagundes, Linux Media Mailing List, Jarod Wilson

[-- Attachment #1: Type: text/plain, Size: 29962 bytes --]

Hi

Changes:
  Add function tm6000_set_reg_mask for change some bits in regs. Very usefull, simplify some code with this function.
  Add control mute
  Add control volume
  Add control audio input MUX
  Add support radio

Radio works well. TV works too

Known bugs:
  The programm gnomeradio can't set freq for radio, it use old v4l API. Audio over USB works via arecord.
  The programm mplayer can set freq but no any audio
           mplayer -v -rawaudio rate=48000 radio://105.2/capture driver=v4l2:alsa:adevice=hw.1,0:amode=1:audiorate=48000:forceaudio:immediatemode=0
  When start watch TV very shortly after radio the kernel crashed hardly. Didn't stop all USB URBs, need some time for stop.

diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index 184cc50..acb0317 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -76,14 +76,11 @@ MODULE_PARM_DESC(debug, "enable debug messages");
 static int _tm6000_start_audio_dma(struct snd_tm6000_card *chip)
 {
 	struct tm6000_core *core = chip->core;
-	int val;
 
 	dprintk(1, "Starting audio DMA\n");
 
 	/* Enables audio */
-	val = tm6000_get_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x0);
-	val |= 0x20;
-	tm6000_set_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, val);
+	tm6000_set_reg_mask(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x40, 0x40);
 
 	tm6000_set_audio_bitrate(core, 48000);
 
@@ -98,13 +95,11 @@ static int _tm6000_start_audio_dma(struct snd_tm6000_card *chip)
 static int _tm6000_stop_audio_dma(struct snd_tm6000_card *chip)
 {
 	struct tm6000_core *core = chip->core;
-	int val;
+
 	dprintk(1, "Stopping audio DMA\n");
 
-	/* Enables audio */
-	val = tm6000_get_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x0);
-	val &= ~0x20;
-	tm6000_set_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, val);
+	/* Disables audio */
+	tm6000_set_reg_mask(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x00, 0x40);
 
 	tm6000_set_reg(core, TM6010_REQ08_R01_A_INIT, 0);
 
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 455038b..c2aa889 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -63,6 +63,8 @@ struct tm6000_board {
 	char            *name;
 
 	struct tm6000_capabilities caps;
+	enum            tm6000_inaudio aradio;
+	enum            tm6000_inaudio avideo;
 
 	enum		tm6000_devtype type;	/* variant of the chipset */
 	int             tuner_type;     /* type of the tuner */
@@ -227,6 +229,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_addr   = 0xc2 >> 1,
 		.demod_addr   = 0x1e >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 1,
@@ -245,6 +249,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_type   = TUNER_XC5000,
 		.tuner_addr   = 0xc2 >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 0,
@@ -644,13 +650,12 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
 		struct xc5000_config ctl = {
 			.i2c_address = dev->tuner_addr,
 			.if_khz      = 4570,
-			.radio_input = XC5000_RADIO_FM1,
+			.radio_input = XC5000_RADIO_FM1_MONO,
 			};
 
 		xc5000_cfg.tuner = TUNER_XC5000;
 		xc5000_cfg.priv  = &ctl;
 
-
 		v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
 				     &xc5000_cfg);
 		}
@@ -683,6 +688,8 @@ static int tm6000_init_dev(struct tm6000_core *dev)
 
 	dev->caps = tm6000_boards[dev->model].caps;
 
+	dev->avideo = tm6000_boards[dev->model].avideo;
+	dev->aradio = tm6000_boards[dev->model].aradio;
 	/* initialize hardware */
 	rc = tm6000_init(dev);
 	if (rc < 0)
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 96aed4a..b9d9624 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -116,6 +116,29 @@ int tm6000_get_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index)
 }
 EXPORT_SYMBOL_GPL(tm6000_get_reg);
 
+int tm6000_set_reg_mask(struct tm6000_core *dev, u8 req, u16 value,
+						u16 index, u16 mask)
+{
+	int rc;
+	u8 buf[1];
+	u8 new_index;
+
+	rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR, req,
+					value, index, buf, 1);
+
+	if (rc < 0)
+		return rc;
+
+	new_index = (buf[0] & ~mask) | (index & mask);
+
+	if (new_index == index)
+		return 0;
+
+	return tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR,
+				      req, value, new_index, NULL, 0);
+}
+EXPORT_SYMBOL_GPL(tm6000_set_reg_mask);
+
 int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index)
 {
 	int rc;
@@ -245,17 +268,12 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 	struct v4l2_frequency f;
 
 	if (dev->dev_type == TM6010) {
-		int val;
-
 		/* Enable video */
-		val = tm6000_get_reg(dev, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0);
-		val |= 0x60;
-		tm6000_set_reg(dev, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, val);
-		val = tm6000_get_reg(dev,
-			TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE, 0);
-		val &= ~0x40;
-		tm6000_set_reg(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE, val);
 
+		tm6000_set_reg_mask(dev, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF,
+							0x60, 0x60);
+		tm6000_set_reg_mask(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE,
+							0x00, 0x40);
 		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
 
 	} else {
@@ -470,6 +488,14 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0 },
 	{ TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2 },
 	{ TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60 },
+	{ TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00},
+	{ TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80},
+	{ TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a},
+	{ TM6010_REQ08_R0D_A_AMD_THRES, 0x40},
+	{ TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64},
+	{ TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20},
+	{ TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe},
+	{ TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01},
 	{ TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc },
 
 	{ TM6010_REQ07_R3F_RESET, 0x01 },
@@ -590,38 +616,213 @@ int tm6000_init(struct tm6000_core *dev)
 
 int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate)
 {
-	int val;
+	int val = 0;
+	u8 areg_f0 = 0x60; /* ADC MCLK = 250 Fs */
+	u8 areg_0a = 0x91; /* SIF 48KHz */
+
+	switch (bitrate) {
+	case 48000:
+		areg_f0 = 0x60; /* ADC MCLK = 250 Fs */
+		areg_0a = 0x91; /* SIF 48KHz */
+		dev->audio_bitrate = bitrate;
+		break;
+	case 32000:
+		areg_f0 = 0x00; /* ADC MCLK = 375 Fs */
+		areg_0a = 0x90; /* SIF 32KHz */
+		dev->audio_bitrate = bitrate;
+		break;
+	default:
+		return -EINVAL;
+	}
+
 
 	if (dev->dev_type == TM6010) {
-		val = tm6000_get_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0);
+		val = tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, areg_0a);
 		if (val < 0)
 			return val;
-		val = (val & 0xf0) | 0x1; /* 48 kHz, not muted */
-		val = tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, val);
+
+		val = tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
+							areg_f0, 0xf0);
+		if (val < 0)
+			return val;
+	} else {
+		val = tm6000_set_reg_mask(dev, TM6000_REQ07_REB_VADC_AADC_MODE,
+							areg_f0, 0xf0);
 		if (val < 0)
 			return val;
 	}
 
-	val = tm6000_get_reg(dev, REQ_07_SET_GET_AVREG, 0xeb, 0x0);
-	if (val < 0)
-		return val;
+	return val;
+}
+EXPORT_SYMBOL_GPL(tm6000_set_audio_bitrate);
 
-	val &= 0x0f;		/* Preserve the audio input control bits */
-	switch (bitrate) {
-	case 44100:
-		val |= 0xd0;
-		dev->audio_bitrate = bitrate;
+int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
+{
+	if (dev->dev_type == TM6010) {
+		/* Audio crossbar setting, default SIF1 */
+		u8 areg_f0 = 0x03;
+
+		switch (ainp) {
+		case TM6000_AIP_SIF1:
+		case TM6000_AIP_SIF2:
+			areg_f0 = 0x03;
+			break;
+		case TM6000_AIP_LINE1:
+			areg_f0 = 0x00;
+			break;
+		case TM6000_AIP_LINE2:
+			areg_f0 = 0x08;
+			break;
+		default:
+			return 0;
+			break;
+		}
+		/* Set audio input crossbar */
+		tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
+							areg_f0, 0x0f);
+	} else {
+		/* Audio setting, default LINE1 */
+		u8 areg_eb = 0x00;
+
+		switch (ainp) {
+		case TM6000_AIP_LINE1:
+			areg_eb = 0x00;
+			break;
+		case TM6000_AIP_LINE2:
+			areg_eb = 0x04;
+			break;
+		default:
+			return 0;
+			break;
+		}
+		/* Set audio input */
+		tm6000_set_reg_mask(dev, TM6000_REQ07_REB_VADC_AADC_MODE,
+							areg_eb, 0x0f);
+	}
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tm6000_set_audio_input);
+
+void tm6010_set_mute_sif(struct tm6000_core *dev, u8 mute)
+{
+	u8 mute_reg = 0;
+
+	if (mute)
+		mute_reg = 0x08;
+
+	tm6000_set_reg_mask(dev, TM6010_REQ08_R0A_A_I2S_MOD, mute_reg, 0x08);
+}
+
+void tm6010_set_mute_adc(struct tm6000_core *dev, u8 mute)
+{
+	u8 mute_reg = 0;
+
+	if (mute)
+		mute_reg = 0x20;
+
+	if (dev->dev_type == TM6010) {
+		tm6000_set_reg_mask(dev, TM6010_REQ08_RF2_LEFT_CHANNEL_VOL,
+							mute_reg, 0x20);
+		tm6000_set_reg_mask(dev, TM6010_REQ08_RF3_RIGHT_CHANNEL_VOL,
+							mute_reg, 0x20);
+	} else {
+		tm6000_set_reg_mask(dev, TM6000_REQ07_REC_VADC_AADC_LVOL,
+							mute_reg, 0x20);
+		tm6000_set_reg_mask(dev, TM6000_REQ07_RED_VADC_AADC_RVOL,
+							mute_reg, 0x20);
+	}
+}
+
+int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute)
+{
+	enum tm6000_inaudio ainp;
+
+	if (dev->radio)
+		ainp = dev->aradio;
+	else
+		ainp = dev->avideo;
+
+	switch (ainp) {
+	case TM6000_AIP_SIF1:
+	case TM6000_AIP_SIF2:
+		if (dev->dev_type == TM6010)
+			tm6010_set_mute_sif(dev, mute);
+		else {
+			printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has"
+					" SIF audio inputs. Please check the %s"
+					" configuration.\n", dev->name);
+			return -EINVAL;
+		}
 		break;
-	case 48000:
-		val |= 0x60;
-		dev->audio_bitrate = bitrate;
+	case TM6000_AIP_LINE1:
+	case TM6000_AIP_LINE2:
+		tm6010_set_mute_adc(dev, mute);
+		break;
+	default:
+		return -EINVAL;
 		break;
 	}
-	val = tm6000_set_reg(dev, REQ_07_SET_GET_AVREG, 0xeb, val);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tm6000_tvaudio_set_mute);
 
-	return val;
+void tm6010_set_volume_sif(struct tm6000_core *dev, int vol)
+{
+	u8 vol_reg;
+
+	vol_reg = vol & 0x0F;
+
+	if (vol < 0)
+		vol_reg |= 0x40;
+
+	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, vol_reg);
+	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, vol_reg);
 }
-EXPORT_SYMBOL_GPL(tm6000_set_audio_bitrate);
+
+void tm6010_set_volume_adc(struct tm6000_core *dev, int vol)
+{
+	u8 vol_reg;
+
+	vol_reg = (vol + 0x10) & 0x1f;
+
+	if (dev->dev_type == TM6010) {
+		tm6000_set_reg(dev, TM6010_REQ08_RF2_LEFT_CHANNEL_VOL, vol_reg);
+		tm6000_set_reg(dev, TM6010_REQ08_RF3_RIGHT_CHANNEL_VOL, vol_reg);
+	} else {
+		tm6000_set_reg(dev, TM6000_REQ07_REC_VADC_AADC_LVOL, vol_reg);
+		tm6000_set_reg(dev, TM6000_REQ07_RED_VADC_AADC_RVOL, vol_reg);
+	}
+}
+
+void tm6000_set_volume(struct tm6000_core *dev, int vol)
+{
+	enum tm6000_inaudio ainp;
+
+	if (dev->radio) {
+		ainp = dev->aradio;
+		vol += 8; /* Offset to 0 dB */
+	} else
+		ainp = dev->avideo;
+
+	switch (ainp) {
+	case TM6000_AIP_SIF1:
+	case TM6000_AIP_SIF2:
+		if (dev->dev_type == TM6010)
+			tm6010_set_volume_sif(dev, vol);
+		else
+			printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has"
+					" SIF audio inputs. Please check the %s"
+					" configuration.\n", dev->name);
+		break;
+	case TM6000_AIP_LINE1:
+	case TM6000_AIP_LINE2:
+		tm6010_set_volume_adc(dev, vol);
+		break;
+	default:
+		break;
+	}
+}
+EXPORT_SYMBOL_GPL(tm6000_set_volume);
 
 static LIST_HEAD(tm6000_devlist);
 static DEFINE_MUTEX(tm6000_devlist_mutex);
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index cc7b866..a4c07e5 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -952,6 +952,22 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 	uint8_t mono_flag = 0;  /* No mono */
 	uint8_t nicam_flag = 0; /* No NICAM */
 
+	if (dev->radio) {
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
+		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
+		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		return 0;
+	}
+
 	switch (std) {
 #if 0
 	case DK_MONO:
@@ -984,20 +1000,6 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 	case EIAJ:
 		areg_05 = 0x02;
 		break;
-	case FM_RADIO:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
-		return 0;
-		break;
 	case I_NICAM:
 		areg_05 = 0x08;
 		nicam_flag = 1;
@@ -1010,6 +1012,9 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 		areg_05 = 0x0a;
 		nicam_flag = 1;
 		break;
+	default:
+		/* do nothink */
+		break;
 	}
 
 #if 0
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index eb9b9f1..b550340 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -53,11 +53,17 @@
 /* Declare static vars that will be used as parameters */
 static unsigned int vid_limit = 16;	/* Video memory limit, in Mb */
 static int video_nr = -1;		/* /dev/videoN, -1 for autodetect */
+static int radio_nr = -1;		/* /dev/radioN, -1 for autodetect */
 
 /* Debug level */
 int tm6000_debug;
 EXPORT_SYMBOL_GPL(tm6000_debug);
 
+static const struct v4l2_queryctrl no_ctrl = {
+	.name  = "42",
+	.flags = V4L2_CTRL_FLAG_DISABLED,
+};
+
 /* supported controls */
 static struct v4l2_queryctrl tm6000_qctrl[] = {
 	{
@@ -96,9 +102,26 @@ static struct v4l2_queryctrl tm6000_qctrl[] = {
 		.step          = 0x1,
 		.default_value = 0,
 		.flags         = 0,
+	},
+		/* --- audio --- */
+	{
+		.id            = V4L2_CID_AUDIO_MUTE,
+		.name          = "Mute",
+		.minimum       = 0,
+		.maximum       = 1,
+		.type          = V4L2_CTRL_TYPE_BOOLEAN,
+	}, {
+		.id            = V4L2_CID_AUDIO_VOLUME,
+		.name          = "Volume",
+		.minimum       = -15,
+		.maximum       = 15,
+		.step          = 1,
+		.default_value = 0,
+		.type          = V4L2_CTRL_TYPE_INTEGER,
 	}
 };
 
+static const unsigned int CTRLS = ARRAY_SIZE(tm6000_qctrl);
 static int qctl_regs[ARRAY_SIZE(tm6000_qctrl)];
 
 static struct tm6000_fmt format[] = {
@@ -117,6 +140,16 @@ static struct tm6000_fmt format[] = {
 	}
 };
 
+static const struct v4l2_queryctrl *ctrl_by_id(unsigned int id)
+{
+	unsigned int i;
+
+	for (i = 0; i < CTRLS; i++)
+		if (tm6000_qctrl[i].id == id)
+			return tm6000_qctrl+i;
+	return NULL;
+}
+
 /* ------------------------------------------------------------------
  *	DMA and thread functions
  * ------------------------------------------------------------------
@@ -199,13 +232,17 @@ static int copy_streams(u8 *data, unsigned long len,
 	char *voutp = NULL;
 	unsigned int linewidth;
 
-	/* get video buffer */
-	get_next_buf(dma_q, &vbuf);
-	if (!vbuf)
-		return rc;
-	voutp = videobuf_to_vmalloc(&vbuf->vb);
-	if (!voutp)
-		return 0;
+	if (!dev->radio) {
+		/* get video buffer */
+		get_next_buf(dma_q, &vbuf);
+
+		if (!vbuf)
+			return rc;
+		voutp = videobuf_to_vmalloc(&vbuf->vb);
+
+		if (!voutp)
+			return 0;
+	}
 
 	for (ptr = data; ptr < endp;) {
 		if (!dev->isoc_ctl.cmd) {
@@ -257,29 +294,31 @@ static int copy_streams(u8 *data, unsigned long len,
 			 */
 			switch (cmd) {
 			case TM6000_URB_MSG_VIDEO:
-				if ((dev->isoc_ctl.vfield != field) &&
-					(field == 1)) {
+				if (!dev->radio) {
+					if ((dev->isoc_ctl.vfield != field) &&
+						(field == 1)) {
 					/* Announces that a new buffer
 					 * were filled
 					 */
-					buffer_filled(dev, dma_q, vbuf);
-					dprintk(dev, V4L2_DEBUG_ISOC,
+						buffer_filled(dev, dma_q, vbuf);
+						dprintk(dev, V4L2_DEBUG_ISOC,
 							"new buffer filled\n");
-					get_next_buf(dma_q, &vbuf);
-					if (!vbuf)
-						return rc;
-					voutp = videobuf_to_vmalloc(&vbuf->vb);
-					if (!voutp)
-						return rc;
-					memset(voutp, 0, vbuf->vb.size);
-				}
-				linewidth = vbuf->vb.width << 1;
-				pos = ((line << 1) - field - 1) * linewidth +
-					block * TM6000_URB_MSG_LEN;
-				/* Don't allow to write out of the buffer */
-				if (pos + size > vbuf->vb.size)
-					cmd = TM6000_URB_MSG_ERR;
-				dev->isoc_ctl.vfield = field;
+						get_next_buf(dma_q, &vbuf);
+						if (!vbuf)
+							return rc;
+						voutp = videobuf_to_vmalloc(&vbuf->vb);
+						if (!voutp)
+							return rc;
+						memset(voutp, 0, vbuf->vb.size);
+					}
+					linewidth = vbuf->vb.width << 1;
+					pos = ((line << 1) - field - 1) *
+					linewidth + block * TM6000_URB_MSG_LEN;
+					/* Don't allow to write out of the buffer */
+					if (pos + size > vbuf->vb.size)
+						cmd = TM6000_URB_MSG_ERR;
+					dev->isoc_ctl.vfield = field;
+			}
 				break;
 			case TM6000_URB_MSG_VBI:
 				break;
@@ -537,7 +576,7 @@ static void tm6000_uninit_isoc(struct tm6000_core *dev)
 /*
  * Allocate URBs and start IRQ
  */
-static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
+static int tm6000_prepare_isoc(struct tm6000_core *dev)
 {
 	struct tm6000_dmaqueue *dma_q = &dev->vidq;
 	int i, j, sb_size, pipe, size, max_packets, num_bufs = 8;
@@ -566,11 +605,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
 
 	dev->isoc_ctl.max_pkt_size = size;
 
-	max_packets = (framesize + size - 1) / size;
-
-	if (max_packets > TM6000_MAX_ISO_PACKETS)
-		max_packets = TM6000_MAX_ISO_PACKETS;
-
+	max_packets = TM6000_MAX_ISO_PACKETS;
 	sb_size = max_packets * size;
 
 	dev->isoc_ctl.num_bufs = num_bufs;
@@ -746,7 +781,7 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
 		urb_init = 1;
 
 	if (urb_init) {
-		rc = tm6000_prepare_isoc(dev, buf->vb.size);
+		rc = tm6000_prepare_isoc(dev);
 		if (rc < 0)
 			goto fail;
 
@@ -1143,6 +1178,12 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 	case V4L2_CID_HUE:
 		val = tm6000_get_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, 0);
 		return 0;
+	case V4L2_CID_AUDIO_MUTE:
+		val = dev->ctl_mute;
+		return 0;
+	case V4L2_CID_AUDIO_VOLUME:
+		val = dev->ctl_volume;
+		return 0;
 	default:
 		return -EINVAL;
 	}
@@ -1174,6 +1215,14 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
 	case V4L2_CID_HUE:
 		tm6000_set_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, val);
 		return 0;
+	case V4L2_CID_AUDIO_MUTE:
+		dev->ctl_mute = val;
+		tm6000_tvaudio_set_mute(dev, val);
+		return 0;
+	case V4L2_CID_AUDIO_VOLUME:
+		dev->ctl_volume = val;
+		tm6000_set_volume(dev, val);
+		return 0;
 	}
 	return -EINVAL;
 }
@@ -1221,7 +1270,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 	if (unlikely(UNSET == dev->tuner_type))
 		return -EINVAL;
 
-	f->type = V4L2_TUNER_ANALOG_TV;
+	f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
 	f->frequency = dev->freq;
 
 	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_frequency, f);
@@ -1235,13 +1284,14 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 	struct tm6000_fh   *fh  = priv;
 	struct tm6000_core *dev = fh->dev;
 
-	if (unlikely(f->type != V4L2_TUNER_ANALOG_TV))
-		return -EINVAL;
-
 	if (unlikely(UNSET == dev->tuner_type))
 		return -EINVAL;
 	if (unlikely(f->tuner != 0))
 		return -EINVAL;
+	if (0 == fh->radio && V4L2_TUNER_ANALOG_TV != f->type)
+		return -EINVAL;
+	if (1 == fh->radio && V4L2_TUNER_RADIO != f->type)
+		return -EINVAL;
 
 	dev->freq = f->frequency;
 	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f);
@@ -1249,6 +1299,122 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 	return 0;
 }
 
+static int radio_querycap(struct file *file, void *priv,
+					struct v4l2_capability *cap)
+{
+	struct tm6000_fh *fh = file->private_data;
+	struct tm6000_core *dev = fh->dev;
+
+	strcpy(cap->driver, "tm6000");
+	strlcpy(cap->card, dev->name, sizeof(dev->name));
+	sprintf(cap->bus_info, "USB%04x:%04x",
+		le16_to_cpu(dev->udev->descriptor.idVendor),
+		le16_to_cpu(dev->udev->descriptor.idProduct));
+	cap->version = dev->dev_type;
+	cap->capabilities = V4L2_CAP_TUNER;
+
+	return 0;
+}
+
+static int radio_g_tuner(struct file *file, void *priv,
+					struct v4l2_tuner *t)
+{
+	struct tm6000_fh *fh = file->private_data;
+	struct tm6000_core *dev = fh->dev;
+
+	if (0 != t->index)
+		return -EINVAL;
+
+	memset(t, 0, sizeof(*t));
+	strcpy(t->name, "Radio");
+	t->type = V4L2_TUNER_RADIO;
+
+	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
+
+	if ((dev->aradio == TM6000_AIP_LINE1) ||
+				(dev->aradio == TM6000_AIP_LINE2)) {
+		t->rxsubchans = V4L2_TUNER_SUB_MONO;
+	}
+	else {
+		t->rxsubchans = V4L2_TUNER_SUB_STEREO;
+	}
+
+	return 0;
+}
+
+static int radio_s_tuner(struct file *file, void *priv,
+					struct v4l2_tuner *t)
+{
+	struct tm6000_fh *fh = file->private_data;
+	struct tm6000_core *dev = fh->dev;
+
+	if (0 != t->index)
+		return -EINVAL;
+
+	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
+
+	return 0;
+}
+
+static int radio_enum_input(struct file *file, void *priv,
+					struct v4l2_input *i)
+{
+	if (i->index != 0)
+		return -EINVAL;
+
+	strcpy(i->name, "Radio");
+	i->type = V4L2_INPUT_TYPE_TUNER;
+
+	return 0;
+}
+
+static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
+{
+	*i = 0;
+	return 0;
+}
+
+static int radio_g_audio(struct file *file, void *priv,
+					struct v4l2_audio *a)
+{
+	memset(a, 0, sizeof(*a));
+	strcpy(a->name, "Radio");
+	return 0;
+}
+
+static int radio_s_audio(struct file *file, void *priv,
+					struct v4l2_audio *a)
+{
+	return 0;
+}
+
+static int radio_s_input(struct file *filp, void *priv, unsigned int i)
+{
+	return 0;
+}
+
+static int radio_s_std(struct file *file, void *fh, v4l2_std_id *norm)
+{
+	return 0;
+}
+
+static int radio_queryctrl(struct file *file, void *priv,
+					struct v4l2_queryctrl *c)
+{
+	const struct v4l2_queryctrl *ctrl;
+
+	if (c->id <  V4L2_CID_BASE ||
+	    c->id >= V4L2_CID_LASTP1)
+		return -EINVAL;
+	if (c->id == V4L2_CID_AUDIO_MUTE) {
+		ctrl = ctrl_by_id(c->id);
+		*c = *ctrl;
+	} else
+		*c = no_ctrl;
+
+	return 0;
+}
+
 /* ------------------------------------------------------------------
 	File operations for the device
    ------------------------------------------------------------------*/
@@ -1260,6 +1426,7 @@ static int tm6000_open(struct file *file)
 	struct tm6000_fh *fh;
 	enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	int i, rc;
+	int radio = 0;
 
 	printk(KERN_INFO "tm6000: open called (dev=%s)\n",
 		video_device_node_name(vdev));
@@ -1267,6 +1434,17 @@ static int tm6000_open(struct file *file)
 	dprintk(dev, V4L2_DEBUG_OPEN, "tm6000: open called (dev=%s)\n",
 		video_device_node_name(vdev));
 
+	switch (vdev->vfl_type) {
+	case VFL_TYPE_GRABBER:
+		type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		break;
+	case VFL_TYPE_VBI:
+		type = V4L2_BUF_TYPE_VBI_CAPTURE;
+		break;
+	case VFL_TYPE_RADIO:
+		radio = 1;
+		break;
+	}
 
 	/* If more than one user, mutex should be added */
 	dev->users++;
@@ -1284,8 +1462,9 @@ static int tm6000_open(struct file *file)
 
 	file->private_data = fh;
 	fh->dev      = dev;
-
-	fh->type     = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	fh->radio    = radio;
+	dev->radio   = radio;
+	fh->type     = type;
 	dev->fourcc  = format[0].fourcc;
 
 	fh->fmt      = format_by_fourcc(dev->fourcc);
@@ -1322,6 +1501,19 @@ static int tm6000_open(struct file *file)
 			V4L2_FIELD_INTERLACED,
 			sizeof(struct tm6000_buffer), fh, &dev->lock);
 
+	if (fh->radio) {
+		dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n");
+		tm6000_set_audio_input(dev, dev->aradio);
+		tm6000_set_volume(dev, dev->ctl_volume);
+		v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio);
+		tm6000_prepare_isoc(dev);
+		tm6000_start_thread(dev);
+	}
+	else {
+		tm6000_set_audio_input(dev, dev->avideo);
+		tm6000_set_volume(dev, dev->ctl_volume);
+	}
+
 	return 0;
 }
 
@@ -1445,6 +1637,36 @@ static struct video_device tm6000_template = {
 	.current_norm   = V4L2_STD_NTSC_M,
 };
 
+static const struct v4l2_file_operations radio_fops = {
+	.owner	  = THIS_MODULE,
+	.open	  = tm6000_open,
+	.release  = tm6000_release,
+	.ioctl	  = video_ioctl2,
+};
+
+static const struct v4l2_ioctl_ops radio_ioctl_ops = {
+	.vidioc_querycap	= radio_querycap,
+	.vidioc_g_tuner		= radio_g_tuner,
+	.vidioc_enum_input	= radio_enum_input,
+	.vidioc_g_audio		= radio_g_audio,
+	.vidioc_s_tuner		= radio_s_tuner,
+	.vidioc_s_audio		= radio_s_audio,
+	.vidioc_s_input		= radio_s_input,
+	.vidioc_s_std		= radio_s_std,
+	.vidioc_queryctrl	= radio_queryctrl,
+	.vidioc_g_input		= radio_g_input,
+	.vidioc_g_ctrl		= vidioc_g_ctrl,
+	.vidioc_s_ctrl		= vidioc_s_ctrl,
+	.vidioc_g_frequency	= vidioc_g_frequency,
+	.vidioc_s_frequency	= vidioc_s_frequency,
+};
+
+struct video_device tm6000_radio_template = {
+	.name			= "tm6000",
+	.fops			= &radio_fops,
+	.ioctl_ops 		= &radio_ioctl_ops,
+};
+
 /* -----------------------------------------------------------------
  *	Initialization and module stuff
  * ------------------------------------------------------------------
@@ -1499,6 +1721,25 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
 	printk(KERN_INFO "%s: registered device %s\n",
 	       dev->name, video_device_node_name(dev->vfd));
 
+	dev->radio_dev = vdev_init(dev, &tm6000_radio_template,
+						   "radio");
+	if (!dev->radio_dev) {
+		printk(KERN_INFO "%s: can't register radio device\n",
+		       dev->name);
+		return ret; /* FIXME release resource */
+	}
+
+	ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
+				    radio_nr);
+	if (ret < 0) {
+		printk(KERN_INFO "%s: can't register radio device\n",
+		       dev->name);
+		return ret; /* FIXME release resource */
+	}
+
+	printk(KERN_INFO "%s: registered device %s\n",
+	       dev->name, video_device_node_name(dev->radio_dev));
+
 	printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
 	return ret;
 }
@@ -1507,6 +1748,14 @@ int tm6000_v4l2_unregister(struct tm6000_core *dev)
 {
 	video_unregister_device(dev->vfd);
 
+	if (dev->radio_dev) {
+		if (video_is_registered(dev->radio_dev))
+			video_unregister_device(dev->radio_dev);
+		else
+			video_device_release(dev->radio_dev);
+		dev->radio_dev = NULL;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index bf11eee..ccd120f 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -53,6 +53,14 @@ enum tm6000_devtype {
 	TM6010,
 };
 
+enum tm6000_inaudio {
+	TM6000_AIP_UNK = 0,
+	TM6000_AIP_SIF1,
+	TM6000_AIP_SIF2,
+	TM6000_AIP_LINE1,
+	TM6000_AIP_LINE2,
+};
+
 /* ------------------------------------------------------------------
  *	Basic structures
  * ------------------------------------------------------------------
@@ -174,6 +182,8 @@ struct tm6000_core {
 
 	char				*ir_codes;
 
+	__u8				radio;
+
 	/* Demodulator configuration */
 	int				demod_addr;	/* demodulator address */
 
@@ -194,6 +204,7 @@ struct tm6000_core {
 	bool				is_res_read;
 
 	struct video_device		*vfd;
+	struct video_device		*radio_dev;
 	struct tm6000_dmaqueue		vidq;
 	struct v4l2_device		v4l2_dev;
 
@@ -203,6 +214,9 @@ struct tm6000_core {
 
 	enum tm6000_mode		mode;
 
+	int				ctl_mute;             /* audio */
+	int				ctl_volume;
+
 	/* DVB-T support */
 	struct tm6000_dvb		*dvb;
 
@@ -210,7 +224,8 @@ struct tm6000_core {
 	struct snd_tm6000_card		*adev;
 	struct work_struct		wq_trigger;   /* Trigger to start/stop audio for alsa module */
 	atomic_t			stream_started;  /* stream should be running if true */
-
+	enum tm6000_inaudio		avideo;
+	enum tm6000_inaudio		aradio;
 
 	struct tm6000_IR		*ir;
 
@@ -248,6 +263,7 @@ struct tm6000_ops {
 
 struct tm6000_fh {
 	struct tm6000_core           *dev;
+	unsigned int                 radio;
 
 	/* video capture */
 	struct tm6000_fmt            *fmt;
@@ -276,12 +292,17 @@ int tm6000_get_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_get_reg32(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_set_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index);
+int tm6000_set_reg_mask(struct tm6000_core *dev, u8 req, u16 value,
+						u16 index, u16 mask);
 int tm6000_i2c_reset(struct tm6000_core *dev, u16 tsleep);
 int tm6000_init(struct tm6000_core *dev);
 
 int tm6000_init_analog_mode(struct tm6000_core *dev);
 int tm6000_init_digital_mode(struct tm6000_core *dev);
 int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate);
+int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp);
+int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute);
+void tm6000_set_volume(struct tm6000_core *dev, int vol);
 
 int tm6000_v4l2_register(struct tm6000_core *dev);
 int tm6000_v4l2_unregister(struct tm6000_core *dev);

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>


With my best regards, Dmitry.

[-- Attachment #2: tm6000_radio.patch --]
[-- Type: text/x-patch, Size: 29231 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index 184cc50..acb0317 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -76,14 +76,11 @@ MODULE_PARM_DESC(debug, "enable debug messages");
 static int _tm6000_start_audio_dma(struct snd_tm6000_card *chip)
 {
 	struct tm6000_core *core = chip->core;
-	int val;
 
 	dprintk(1, "Starting audio DMA\n");
 
 	/* Enables audio */
-	val = tm6000_get_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x0);
-	val |= 0x20;
-	tm6000_set_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, val);
+	tm6000_set_reg_mask(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x40, 0x40);
 
 	tm6000_set_audio_bitrate(core, 48000);
 
@@ -98,13 +95,11 @@ static int _tm6000_start_audio_dma(struct snd_tm6000_card *chip)
 static int _tm6000_stop_audio_dma(struct snd_tm6000_card *chip)
 {
 	struct tm6000_core *core = chip->core;
-	int val;
+
 	dprintk(1, "Stopping audio DMA\n");
 
-	/* Enables audio */
-	val = tm6000_get_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x0);
-	val &= ~0x20;
-	tm6000_set_reg(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, val);
+	/* Disables audio */
+	tm6000_set_reg_mask(core, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0x00, 0x40);
 
 	tm6000_set_reg(core, TM6010_REQ08_R01_A_INIT, 0);
 
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 455038b..c2aa889 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -63,6 +63,8 @@ struct tm6000_board {
 	char            *name;
 
 	struct tm6000_capabilities caps;
+	enum            tm6000_inaudio aradio;
+	enum            tm6000_inaudio avideo;
 
 	enum		tm6000_devtype type;	/* variant of the chipset */
 	int             tuner_type;     /* type of the tuner */
@@ -227,6 +229,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_addr   = 0xc2 >> 1,
 		.demod_addr   = 0x1e >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 1,
@@ -245,6 +249,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_type   = TUNER_XC5000,
 		.tuner_addr   = 0xc2 >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 0,
@@ -644,13 +650,12 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
 		struct xc5000_config ctl = {
 			.i2c_address = dev->tuner_addr,
 			.if_khz      = 4570,
-			.radio_input = XC5000_RADIO_FM1,
+			.radio_input = XC5000_RADIO_FM1_MONO,
 			};
 
 		xc5000_cfg.tuner = TUNER_XC5000;
 		xc5000_cfg.priv  = &ctl;
 
-
 		v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
 				     &xc5000_cfg);
 		}
@@ -683,6 +688,8 @@ static int tm6000_init_dev(struct tm6000_core *dev)
 
 	dev->caps = tm6000_boards[dev->model].caps;
 
+	dev->avideo = tm6000_boards[dev->model].avideo;
+	dev->aradio = tm6000_boards[dev->model].aradio;
 	/* initialize hardware */
 	rc = tm6000_init(dev);
 	if (rc < 0)
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 96aed4a..b9d9624 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -116,6 +116,29 @@ int tm6000_get_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index)
 }
 EXPORT_SYMBOL_GPL(tm6000_get_reg);
 
+int tm6000_set_reg_mask(struct tm6000_core *dev, u8 req, u16 value,
+						u16 index, u16 mask)
+{
+	int rc;
+	u8 buf[1];
+	u8 new_index;
+
+	rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR, req,
+					value, index, buf, 1);
+
+	if (rc < 0)
+		return rc;
+
+	new_index = (buf[0] & ~mask) | (index & mask);
+
+	if (new_index == index)
+		return 0;
+
+	return tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR,
+				      req, value, new_index, NULL, 0);
+}
+EXPORT_SYMBOL_GPL(tm6000_set_reg_mask);
+
 int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index)
 {
 	int rc;
@@ -245,17 +268,12 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 	struct v4l2_frequency f;
 
 	if (dev->dev_type == TM6010) {
-		int val;
-
 		/* Enable video */
-		val = tm6000_get_reg(dev, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, 0);
-		val |= 0x60;
-		tm6000_set_reg(dev, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF, val);
-		val = tm6000_get_reg(dev,
-			TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE, 0);
-		val &= ~0x40;
-		tm6000_set_reg(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE, val);
 
+		tm6000_set_reg_mask(dev, TM6010_REQ07_RCC_ACTIVE_VIDEO_IF,
+							0x60, 0x60);
+		tm6000_set_reg_mask(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE,
+							0x00, 0x40);
 		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
 
 	} else {
@@ -470,6 +488,14 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0 },
 	{ TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2 },
 	{ TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60 },
+	{ TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00},
+	{ TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80},
+	{ TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a},
+	{ TM6010_REQ08_R0D_A_AMD_THRES, 0x40},
+	{ TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64},
+	{ TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20},
+	{ TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe},
+	{ TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01},
 	{ TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc },
 
 	{ TM6010_REQ07_R3F_RESET, 0x01 },
@@ -590,38 +616,213 @@ int tm6000_init(struct tm6000_core *dev)
 
 int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate)
 {
-	int val;
+	int val = 0;
+	u8 areg_f0 = 0x60; /* ADC MCLK = 250 Fs */
+	u8 areg_0a = 0x91; /* SIF 48KHz */
+
+	switch (bitrate) {
+	case 48000:
+		areg_f0 = 0x60; /* ADC MCLK = 250 Fs */
+		areg_0a = 0x91; /* SIF 48KHz */
+		dev->audio_bitrate = bitrate;
+		break;
+	case 32000:
+		areg_f0 = 0x00; /* ADC MCLK = 375 Fs */
+		areg_0a = 0x90; /* SIF 32KHz */
+		dev->audio_bitrate = bitrate;
+		break;
+	default:
+		return -EINVAL;
+	}
+
 
 	if (dev->dev_type == TM6010) {
-		val = tm6000_get_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0);
+		val = tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, areg_0a);
 		if (val < 0)
 			return val;
-		val = (val & 0xf0) | 0x1; /* 48 kHz, not muted */
-		val = tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, val);
+
+		val = tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
+							areg_f0, 0xf0);
+		if (val < 0)
+			return val;
+	} else {
+		val = tm6000_set_reg_mask(dev, TM6000_REQ07_REB_VADC_AADC_MODE,
+							areg_f0, 0xf0);
 		if (val < 0)
 			return val;
 	}
 
-	val = tm6000_get_reg(dev, REQ_07_SET_GET_AVREG, 0xeb, 0x0);
-	if (val < 0)
-		return val;
+	return val;
+}
+EXPORT_SYMBOL_GPL(tm6000_set_audio_bitrate);
 
-	val &= 0x0f;		/* Preserve the audio input control bits */
-	switch (bitrate) {
-	case 44100:
-		val |= 0xd0;
-		dev->audio_bitrate = bitrate;
+int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
+{
+	if (dev->dev_type == TM6010) {
+		/* Audio crossbar setting, default SIF1 */
+		u8 areg_f0 = 0x03;
+
+		switch (ainp) {
+		case TM6000_AIP_SIF1:
+		case TM6000_AIP_SIF2:
+			areg_f0 = 0x03;
+			break;
+		case TM6000_AIP_LINE1:
+			areg_f0 = 0x00;
+			break;
+		case TM6000_AIP_LINE2:
+			areg_f0 = 0x08;
+			break;
+		default:
+			return 0;
+			break;
+		}
+		/* Set audio input crossbar */
+		tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
+							areg_f0, 0x0f);
+	} else {
+		/* Audio setting, default LINE1 */
+		u8 areg_eb = 0x00;
+
+		switch (ainp) {
+		case TM6000_AIP_LINE1:
+			areg_eb = 0x00;
+			break;
+		case TM6000_AIP_LINE2:
+			areg_eb = 0x04;
+			break;
+		default:
+			return 0;
+			break;
+		}
+		/* Set audio input */
+		tm6000_set_reg_mask(dev, TM6000_REQ07_REB_VADC_AADC_MODE,
+							areg_eb, 0x0f);
+	}
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tm6000_set_audio_input);
+
+void tm6010_set_mute_sif(struct tm6000_core *dev, u8 mute)
+{
+	u8 mute_reg = 0;
+
+	if (mute)
+		mute_reg = 0x08;
+
+	tm6000_set_reg_mask(dev, TM6010_REQ08_R0A_A_I2S_MOD, mute_reg, 0x08);
+}
+
+void tm6010_set_mute_adc(struct tm6000_core *dev, u8 mute)
+{
+	u8 mute_reg = 0;
+
+	if (mute)
+		mute_reg = 0x20;
+
+	if (dev->dev_type == TM6010) {
+		tm6000_set_reg_mask(dev, TM6010_REQ08_RF2_LEFT_CHANNEL_VOL,
+							mute_reg, 0x20);
+		tm6000_set_reg_mask(dev, TM6010_REQ08_RF3_RIGHT_CHANNEL_VOL,
+							mute_reg, 0x20);
+	} else {
+		tm6000_set_reg_mask(dev, TM6000_REQ07_REC_VADC_AADC_LVOL,
+							mute_reg, 0x20);
+		tm6000_set_reg_mask(dev, TM6000_REQ07_RED_VADC_AADC_RVOL,
+							mute_reg, 0x20);
+	}
+}
+
+int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute)
+{
+	enum tm6000_inaudio ainp;
+
+	if (dev->radio)
+		ainp = dev->aradio;
+	else
+		ainp = dev->avideo;
+
+	switch (ainp) {
+	case TM6000_AIP_SIF1:
+	case TM6000_AIP_SIF2:
+		if (dev->dev_type == TM6010)
+			tm6010_set_mute_sif(dev, mute);
+		else {
+			printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has"
+					" SIF audio inputs. Please check the %s"
+					" configuration.\n", dev->name);
+			return -EINVAL;
+		}
 		break;
-	case 48000:
-		val |= 0x60;
-		dev->audio_bitrate = bitrate;
+	case TM6000_AIP_LINE1:
+	case TM6000_AIP_LINE2:
+		tm6010_set_mute_adc(dev, mute);
+		break;
+	default:
+		return -EINVAL;
 		break;
 	}
-	val = tm6000_set_reg(dev, REQ_07_SET_GET_AVREG, 0xeb, val);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tm6000_tvaudio_set_mute);
 
-	return val;
+void tm6010_set_volume_sif(struct tm6000_core *dev, int vol)
+{
+	u8 vol_reg;
+
+	vol_reg = vol & 0x0F;
+
+	if (vol < 0)
+		vol_reg |= 0x40;
+
+	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, vol_reg);
+	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, vol_reg);
 }
-EXPORT_SYMBOL_GPL(tm6000_set_audio_bitrate);
+
+void tm6010_set_volume_adc(struct tm6000_core *dev, int vol)
+{
+	u8 vol_reg;
+
+	vol_reg = (vol + 0x10) & 0x1f;
+
+	if (dev->dev_type == TM6010) {
+		tm6000_set_reg(dev, TM6010_REQ08_RF2_LEFT_CHANNEL_VOL, vol_reg);
+		tm6000_set_reg(dev, TM6010_REQ08_RF3_RIGHT_CHANNEL_VOL, vol_reg);
+	} else {
+		tm6000_set_reg(dev, TM6000_REQ07_REC_VADC_AADC_LVOL, vol_reg);
+		tm6000_set_reg(dev, TM6000_REQ07_RED_VADC_AADC_RVOL, vol_reg);
+	}
+}
+
+void tm6000_set_volume(struct tm6000_core *dev, int vol)
+{
+	enum tm6000_inaudio ainp;
+
+	if (dev->radio) {
+		ainp = dev->aradio;
+		vol += 8; /* Offset to 0 dB */
+	} else
+		ainp = dev->avideo;
+
+	switch (ainp) {
+	case TM6000_AIP_SIF1:
+	case TM6000_AIP_SIF2:
+		if (dev->dev_type == TM6010)
+			tm6010_set_volume_sif(dev, vol);
+		else
+			printk(KERN_INFO "ERROR: TM5600 and TM6000 don't has"
+					" SIF audio inputs. Please check the %s"
+					" configuration.\n", dev->name);
+		break;
+	case TM6000_AIP_LINE1:
+	case TM6000_AIP_LINE2:
+		tm6010_set_volume_adc(dev, vol);
+		break;
+	default:
+		break;
+	}
+}
+EXPORT_SYMBOL_GPL(tm6000_set_volume);
 
 static LIST_HEAD(tm6000_devlist);
 static DEFINE_MUTEX(tm6000_devlist_mutex);
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index cc7b866..a4c07e5 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -952,6 +952,22 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 	uint8_t mono_flag = 0;  /* No mono */
 	uint8_t nicam_flag = 0; /* No NICAM */
 
+	if (dev->radio) {
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
+		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
+		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		return 0;
+	}
+
 	switch (std) {
 #if 0
 	case DK_MONO:
@@ -984,20 +1000,6 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 	case EIAJ:
 		areg_05 = 0x02;
 		break;
-	case FM_RADIO:
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
-		tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-		tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-		tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
-		return 0;
-		break;
 	case I_NICAM:
 		areg_05 = 0x08;
 		nicam_flag = 1;
@@ -1010,6 +1012,9 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 		areg_05 = 0x0a;
 		nicam_flag = 1;
 		break;
+	default:
+		/* do nothink */
+		break;
 	}
 
 #if 0
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index eb9b9f1..b550340 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -53,11 +53,17 @@
 /* Declare static vars that will be used as parameters */
 static unsigned int vid_limit = 16;	/* Video memory limit, in Mb */
 static int video_nr = -1;		/* /dev/videoN, -1 for autodetect */
+static int radio_nr = -1;		/* /dev/radioN, -1 for autodetect */
 
 /* Debug level */
 int tm6000_debug;
 EXPORT_SYMBOL_GPL(tm6000_debug);
 
+static const struct v4l2_queryctrl no_ctrl = {
+	.name  = "42",
+	.flags = V4L2_CTRL_FLAG_DISABLED,
+};
+
 /* supported controls */
 static struct v4l2_queryctrl tm6000_qctrl[] = {
 	{
@@ -96,9 +102,26 @@ static struct v4l2_queryctrl tm6000_qctrl[] = {
 		.step          = 0x1,
 		.default_value = 0,
 		.flags         = 0,
+	},
+		/* --- audio --- */
+	{
+		.id            = V4L2_CID_AUDIO_MUTE,
+		.name          = "Mute",
+		.minimum       = 0,
+		.maximum       = 1,
+		.type          = V4L2_CTRL_TYPE_BOOLEAN,
+	}, {
+		.id            = V4L2_CID_AUDIO_VOLUME,
+		.name          = "Volume",
+		.minimum       = -15,
+		.maximum       = 15,
+		.step          = 1,
+		.default_value = 0,
+		.type          = V4L2_CTRL_TYPE_INTEGER,
 	}
 };
 
+static const unsigned int CTRLS = ARRAY_SIZE(tm6000_qctrl);
 static int qctl_regs[ARRAY_SIZE(tm6000_qctrl)];
 
 static struct tm6000_fmt format[] = {
@@ -117,6 +140,16 @@ static struct tm6000_fmt format[] = {
 	}
 };
 
+static const struct v4l2_queryctrl *ctrl_by_id(unsigned int id)
+{
+	unsigned int i;
+
+	for (i = 0; i < CTRLS; i++)
+		if (tm6000_qctrl[i].id == id)
+			return tm6000_qctrl+i;
+	return NULL;
+}
+
 /* ------------------------------------------------------------------
  *	DMA and thread functions
  * ------------------------------------------------------------------
@@ -199,13 +232,17 @@ static int copy_streams(u8 *data, unsigned long len,
 	char *voutp = NULL;
 	unsigned int linewidth;
 
-	/* get video buffer */
-	get_next_buf(dma_q, &vbuf);
-	if (!vbuf)
-		return rc;
-	voutp = videobuf_to_vmalloc(&vbuf->vb);
-	if (!voutp)
-		return 0;
+	if (!dev->radio) {
+		/* get video buffer */
+		get_next_buf(dma_q, &vbuf);
+
+		if (!vbuf)
+			return rc;
+		voutp = videobuf_to_vmalloc(&vbuf->vb);
+
+		if (!voutp)
+			return 0;
+	}
 
 	for (ptr = data; ptr < endp;) {
 		if (!dev->isoc_ctl.cmd) {
@@ -257,29 +294,31 @@ static int copy_streams(u8 *data, unsigned long len,
 			 */
 			switch (cmd) {
 			case TM6000_URB_MSG_VIDEO:
-				if ((dev->isoc_ctl.vfield != field) &&
-					(field == 1)) {
+				if (!dev->radio) {
+					if ((dev->isoc_ctl.vfield != field) &&
+						(field == 1)) {
 					/* Announces that a new buffer
 					 * were filled
 					 */
-					buffer_filled(dev, dma_q, vbuf);
-					dprintk(dev, V4L2_DEBUG_ISOC,
+						buffer_filled(dev, dma_q, vbuf);
+						dprintk(dev, V4L2_DEBUG_ISOC,
 							"new buffer filled\n");
-					get_next_buf(dma_q, &vbuf);
-					if (!vbuf)
-						return rc;
-					voutp = videobuf_to_vmalloc(&vbuf->vb);
-					if (!voutp)
-						return rc;
-					memset(voutp, 0, vbuf->vb.size);
-				}
-				linewidth = vbuf->vb.width << 1;
-				pos = ((line << 1) - field - 1) * linewidth +
-					block * TM6000_URB_MSG_LEN;
-				/* Don't allow to write out of the buffer */
-				if (pos + size > vbuf->vb.size)
-					cmd = TM6000_URB_MSG_ERR;
-				dev->isoc_ctl.vfield = field;
+						get_next_buf(dma_q, &vbuf);
+						if (!vbuf)
+							return rc;
+						voutp = videobuf_to_vmalloc(&vbuf->vb);
+						if (!voutp)
+							return rc;
+						memset(voutp, 0, vbuf->vb.size);
+					}
+					linewidth = vbuf->vb.width << 1;
+					pos = ((line << 1) - field - 1) *
+					linewidth + block * TM6000_URB_MSG_LEN;
+					/* Don't allow to write out of the buffer */
+					if (pos + size > vbuf->vb.size)
+						cmd = TM6000_URB_MSG_ERR;
+					dev->isoc_ctl.vfield = field;
+			}
 				break;
 			case TM6000_URB_MSG_VBI:
 				break;
@@ -537,7 +576,7 @@ static void tm6000_uninit_isoc(struct tm6000_core *dev)
 /*
  * Allocate URBs and start IRQ
  */
-static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
+static int tm6000_prepare_isoc(struct tm6000_core *dev)
 {
 	struct tm6000_dmaqueue *dma_q = &dev->vidq;
 	int i, j, sb_size, pipe, size, max_packets, num_bufs = 8;
@@ -566,11 +605,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev, unsigned int framesize)
 
 	dev->isoc_ctl.max_pkt_size = size;
 
-	max_packets = (framesize + size - 1) / size;
-
-	if (max_packets > TM6000_MAX_ISO_PACKETS)
-		max_packets = TM6000_MAX_ISO_PACKETS;
-
+	max_packets = TM6000_MAX_ISO_PACKETS;
 	sb_size = max_packets * size;
 
 	dev->isoc_ctl.num_bufs = num_bufs;
@@ -746,7 +781,7 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
 		urb_init = 1;
 
 	if (urb_init) {
-		rc = tm6000_prepare_isoc(dev, buf->vb.size);
+		rc = tm6000_prepare_isoc(dev);
 		if (rc < 0)
 			goto fail;
 
@@ -1143,6 +1178,12 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 	case V4L2_CID_HUE:
 		val = tm6000_get_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, 0);
 		return 0;
+	case V4L2_CID_AUDIO_MUTE:
+		val = dev->ctl_mute;
+		return 0;
+	case V4L2_CID_AUDIO_VOLUME:
+		val = dev->ctl_volume;
+		return 0;
 	default:
 		return -EINVAL;
 	}
@@ -1174,6 +1215,14 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
 	case V4L2_CID_HUE:
 		tm6000_set_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, val);
 		return 0;
+	case V4L2_CID_AUDIO_MUTE:
+		dev->ctl_mute = val;
+		tm6000_tvaudio_set_mute(dev, val);
+		return 0;
+	case V4L2_CID_AUDIO_VOLUME:
+		dev->ctl_volume = val;
+		tm6000_set_volume(dev, val);
+		return 0;
 	}
 	return -EINVAL;
 }
@@ -1221,7 +1270,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 	if (unlikely(UNSET == dev->tuner_type))
 		return -EINVAL;
 
-	f->type = V4L2_TUNER_ANALOG_TV;
+	f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
 	f->frequency = dev->freq;
 
 	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_frequency, f);
@@ -1235,13 +1284,14 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 	struct tm6000_fh   *fh  = priv;
 	struct tm6000_core *dev = fh->dev;
 
-	if (unlikely(f->type != V4L2_TUNER_ANALOG_TV))
-		return -EINVAL;
-
 	if (unlikely(UNSET == dev->tuner_type))
 		return -EINVAL;
 	if (unlikely(f->tuner != 0))
 		return -EINVAL;
+	if (0 == fh->radio && V4L2_TUNER_ANALOG_TV != f->type)
+		return -EINVAL;
+	if (1 == fh->radio && V4L2_TUNER_RADIO != f->type)
+		return -EINVAL;
 
 	dev->freq = f->frequency;
 	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f);
@@ -1249,6 +1299,122 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 	return 0;
 }
 
+static int radio_querycap(struct file *file, void *priv,
+					struct v4l2_capability *cap)
+{
+	struct tm6000_fh *fh = file->private_data;
+	struct tm6000_core *dev = fh->dev;
+
+	strcpy(cap->driver, "tm6000");
+	strlcpy(cap->card, dev->name, sizeof(dev->name));
+	sprintf(cap->bus_info, "USB%04x:%04x",
+		le16_to_cpu(dev->udev->descriptor.idVendor),
+		le16_to_cpu(dev->udev->descriptor.idProduct));
+	cap->version = dev->dev_type;
+	cap->capabilities = V4L2_CAP_TUNER;
+
+	return 0;
+}
+
+static int radio_g_tuner(struct file *file, void *priv,
+					struct v4l2_tuner *t)
+{
+	struct tm6000_fh *fh = file->private_data;
+	struct tm6000_core *dev = fh->dev;
+
+	if (0 != t->index)
+		return -EINVAL;
+
+	memset(t, 0, sizeof(*t));
+	strcpy(t->name, "Radio");
+	t->type = V4L2_TUNER_RADIO;
+
+	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
+
+	if ((dev->aradio == TM6000_AIP_LINE1) ||
+				(dev->aradio == TM6000_AIP_LINE2)) {
+		t->rxsubchans = V4L2_TUNER_SUB_MONO;
+	}
+	else {
+		t->rxsubchans = V4L2_TUNER_SUB_STEREO;
+	}
+
+	return 0;
+}
+
+static int radio_s_tuner(struct file *file, void *priv,
+					struct v4l2_tuner *t)
+{
+	struct tm6000_fh *fh = file->private_data;
+	struct tm6000_core *dev = fh->dev;
+
+	if (0 != t->index)
+		return -EINVAL;
+
+	v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
+
+	return 0;
+}
+
+static int radio_enum_input(struct file *file, void *priv,
+					struct v4l2_input *i)
+{
+	if (i->index != 0)
+		return -EINVAL;
+
+	strcpy(i->name, "Radio");
+	i->type = V4L2_INPUT_TYPE_TUNER;
+
+	return 0;
+}
+
+static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
+{
+	*i = 0;
+	return 0;
+}
+
+static int radio_g_audio(struct file *file, void *priv,
+					struct v4l2_audio *a)
+{
+	memset(a, 0, sizeof(*a));
+	strcpy(a->name, "Radio");
+	return 0;
+}
+
+static int radio_s_audio(struct file *file, void *priv,
+					struct v4l2_audio *a)
+{
+	return 0;
+}
+
+static int radio_s_input(struct file *filp, void *priv, unsigned int i)
+{
+	return 0;
+}
+
+static int radio_s_std(struct file *file, void *fh, v4l2_std_id *norm)
+{
+	return 0;
+}
+
+static int radio_queryctrl(struct file *file, void *priv,
+					struct v4l2_queryctrl *c)
+{
+	const struct v4l2_queryctrl *ctrl;
+
+	if (c->id <  V4L2_CID_BASE ||
+	    c->id >= V4L2_CID_LASTP1)
+		return -EINVAL;
+	if (c->id == V4L2_CID_AUDIO_MUTE) {
+		ctrl = ctrl_by_id(c->id);
+		*c = *ctrl;
+	} else
+		*c = no_ctrl;
+
+	return 0;
+}
+
 /* ------------------------------------------------------------------
 	File operations for the device
    ------------------------------------------------------------------*/
@@ -1260,6 +1426,7 @@ static int tm6000_open(struct file *file)
 	struct tm6000_fh *fh;
 	enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	int i, rc;
+	int radio = 0;
 
 	printk(KERN_INFO "tm6000: open called (dev=%s)\n",
 		video_device_node_name(vdev));
@@ -1267,6 +1434,17 @@ static int tm6000_open(struct file *file)
 	dprintk(dev, V4L2_DEBUG_OPEN, "tm6000: open called (dev=%s)\n",
 		video_device_node_name(vdev));
 
+	switch (vdev->vfl_type) {
+	case VFL_TYPE_GRABBER:
+		type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		break;
+	case VFL_TYPE_VBI:
+		type = V4L2_BUF_TYPE_VBI_CAPTURE;
+		break;
+	case VFL_TYPE_RADIO:
+		radio = 1;
+		break;
+	}
 
 	/* If more than one user, mutex should be added */
 	dev->users++;
@@ -1284,8 +1462,9 @@ static int tm6000_open(struct file *file)
 
 	file->private_data = fh;
 	fh->dev      = dev;
-
-	fh->type     = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	fh->radio    = radio;
+	dev->radio   = radio;
+	fh->type     = type;
 	dev->fourcc  = format[0].fourcc;
 
 	fh->fmt      = format_by_fourcc(dev->fourcc);
@@ -1322,6 +1501,19 @@ static int tm6000_open(struct file *file)
 			V4L2_FIELD_INTERLACED,
 			sizeof(struct tm6000_buffer), fh, &dev->lock);
 
+	if (fh->radio) {
+		dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n");
+		tm6000_set_audio_input(dev, dev->aradio);
+		tm6000_set_volume(dev, dev->ctl_volume);
+		v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio);
+		tm6000_prepare_isoc(dev);
+		tm6000_start_thread(dev);
+	}
+	else {
+		tm6000_set_audio_input(dev, dev->avideo);
+		tm6000_set_volume(dev, dev->ctl_volume);
+	}
+
 	return 0;
 }
 
@@ -1445,6 +1637,36 @@ static struct video_device tm6000_template = {
 	.current_norm   = V4L2_STD_NTSC_M,
 };
 
+static const struct v4l2_file_operations radio_fops = {
+	.owner	  = THIS_MODULE,
+	.open	  = tm6000_open,
+	.release  = tm6000_release,
+	.ioctl	  = video_ioctl2,
+};
+
+static const struct v4l2_ioctl_ops radio_ioctl_ops = {
+	.vidioc_querycap	= radio_querycap,
+	.vidioc_g_tuner		= radio_g_tuner,
+	.vidioc_enum_input	= radio_enum_input,
+	.vidioc_g_audio		= radio_g_audio,
+	.vidioc_s_tuner		= radio_s_tuner,
+	.vidioc_s_audio		= radio_s_audio,
+	.vidioc_s_input		= radio_s_input,
+	.vidioc_s_std		= radio_s_std,
+	.vidioc_queryctrl	= radio_queryctrl,
+	.vidioc_g_input		= radio_g_input,
+	.vidioc_g_ctrl		= vidioc_g_ctrl,
+	.vidioc_s_ctrl		= vidioc_s_ctrl,
+	.vidioc_g_frequency	= vidioc_g_frequency,
+	.vidioc_s_frequency	= vidioc_s_frequency,
+};
+
+struct video_device tm6000_radio_template = {
+	.name			= "tm6000",
+	.fops			= &radio_fops,
+	.ioctl_ops 		= &radio_ioctl_ops,
+};
+
 /* -----------------------------------------------------------------
  *	Initialization and module stuff
  * ------------------------------------------------------------------
@@ -1499,6 +1721,25 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
 	printk(KERN_INFO "%s: registered device %s\n",
 	       dev->name, video_device_node_name(dev->vfd));
 
+	dev->radio_dev = vdev_init(dev, &tm6000_radio_template,
+						   "radio");
+	if (!dev->radio_dev) {
+		printk(KERN_INFO "%s: can't register radio device\n",
+		       dev->name);
+		return ret; /* FIXME release resource */
+	}
+
+	ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
+				    radio_nr);
+	if (ret < 0) {
+		printk(KERN_INFO "%s: can't register radio device\n",
+		       dev->name);
+		return ret; /* FIXME release resource */
+	}
+
+	printk(KERN_INFO "%s: registered device %s\n",
+	       dev->name, video_device_node_name(dev->radio_dev));
+
 	printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
 	return ret;
 }
@@ -1507,6 +1748,14 @@ int tm6000_v4l2_unregister(struct tm6000_core *dev)
 {
 	video_unregister_device(dev->vfd);
 
+	if (dev->radio_dev) {
+		if (video_is_registered(dev->radio_dev))
+			video_unregister_device(dev->radio_dev);
+		else
+			video_device_release(dev->radio_dev);
+		dev->radio_dev = NULL;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index bf11eee..ccd120f 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -53,6 +53,14 @@ enum tm6000_devtype {
 	TM6010,
 };
 
+enum tm6000_inaudio {
+	TM6000_AIP_UNK = 0,
+	TM6000_AIP_SIF1,
+	TM6000_AIP_SIF2,
+	TM6000_AIP_LINE1,
+	TM6000_AIP_LINE2,
+};
+
 /* ------------------------------------------------------------------
  *	Basic structures
  * ------------------------------------------------------------------
@@ -174,6 +182,8 @@ struct tm6000_core {
 
 	char				*ir_codes;
 
+	__u8				radio;
+
 	/* Demodulator configuration */
 	int				demod_addr;	/* demodulator address */
 
@@ -194,6 +204,7 @@ struct tm6000_core {
 	bool				is_res_read;
 
 	struct video_device		*vfd;
+	struct video_device		*radio_dev;
 	struct tm6000_dmaqueue		vidq;
 	struct v4l2_device		v4l2_dev;
 
@@ -203,6 +214,9 @@ struct tm6000_core {
 
 	enum tm6000_mode		mode;
 
+	int				ctl_mute;             /* audio */
+	int				ctl_volume;
+
 	/* DVB-T support */
 	struct tm6000_dvb		*dvb;
 
@@ -210,7 +224,8 @@ struct tm6000_core {
 	struct snd_tm6000_card		*adev;
 	struct work_struct		wq_trigger;   /* Trigger to start/stop audio for alsa module */
 	atomic_t			stream_started;  /* stream should be running if true */
-
+	enum tm6000_inaudio		avideo;
+	enum tm6000_inaudio		aradio;
 
 	struct tm6000_IR		*ir;
 
@@ -248,6 +263,7 @@ struct tm6000_ops {
 
 struct tm6000_fh {
 	struct tm6000_core           *dev;
+	unsigned int                 radio;
 
 	/* video capture */
 	struct tm6000_fmt            *fmt;
@@ -276,12 +292,17 @@ int tm6000_get_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_get_reg32(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_set_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index);
+int tm6000_set_reg_mask(struct tm6000_core *dev, u8 req, u16 value,
+						u16 index, u16 mask);
 int tm6000_i2c_reset(struct tm6000_core *dev, u16 tsleep);
 int tm6000_init(struct tm6000_core *dev);
 
 int tm6000_init_analog_mode(struct tm6000_core *dev);
 int tm6000_init_digital_mode(struct tm6000_core *dev);
 int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate);
+int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp);
+int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute);
+void tm6000_set_volume(struct tm6000_core *dev, int vol);
 
 int tm6000_v4l2_register(struct tm6000_core *dev);
 int tm6000_v4l2_unregister(struct tm6000_core *dev);

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH] tm6000: add audio conf for new cards
  2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
  2011-02-18  1:11                                                             ` [PATCH] tm6000: add radio Dmitri Belimov
@ 2011-03-01  4:55                                                             ` Dmitri Belimov
  2011-03-18  0:08                                                             ` [PATCH] tm6000: fix s-video input Dmitri Belimov
  2011-04-19  5:29                                                             ` [PATCH v1] tm6000: rework standards Dmitri Belimov
  3 siblings, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2011-03-01  4:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

Hi

Add configuration of an audio for our new TV cards.

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index a356ba7..88144a1 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -324,6 +324,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_addr   = 0xc2 >> 1,
 		.demod_addr   = 0x1e >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 1,
@@ -341,6 +343,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_type   = TUNER_XC5000,
 		.tuner_addr   = 0xc2 >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 0,

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

With my best regards, Dmitry.

[-- Attachment #2: tm6000_lite_audio.diff --]
[-- Type: text/x-patch, Size: 843 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index a356ba7..88144a1 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -324,6 +324,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_addr   = 0xc2 >> 1,
 		.demod_addr   = 0x1e >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 1,
@@ -341,6 +343,8 @@ struct tm6000_board tm6000_boards[] = {
 		.tuner_type   = TUNER_XC5000,
 		.tuner_addr   = 0xc2 >> 1,
 		.type         = TM6010,
+		.avideo       = TM6000_AIP_SIF1,
+		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
 			.has_tuner    = 1,
 			.has_dvb      = 0,

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH] tm6000: fix s-video input
  2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
  2011-02-18  1:11                                                             ` [PATCH] tm6000: add radio Dmitri Belimov
  2011-03-01  4:55                                                             ` [PATCH] tm6000: add audio conf for new cards Dmitri Belimov
@ 2011-03-18  0:08                                                             ` Dmitri Belimov
  2011-03-19  6:46                                                               ` Stefan Ringel
  2011-04-19  5:29                                                             ` [PATCH v1] tm6000: rework standards Dmitri Belimov
  3 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2011-03-18  0:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Stefan Ringel; +Cc: Linux Media Mailing List

[-- Attachment #1: Type: text/plain, Size: 4761 bytes --]

Hi

Add compatibility for composite and s-video inputs. Some TV cards hasn't it.
Fix S-Video input, the s-video cable has only video signals no audio. Call the function of audio configure kill chroma in signal. only b/w video.

Known bugs:
after s-video the audio for radio didn't work, TV crashed hardly
after composite TV crashed hardly too.

P.S. After this patch I'll want to rework the procedure of configure video. Now it has a lot of junk and dubles.

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 88144a1..146c7e8 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -235,11 +235,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 1,
-			.has_zl10353  = 1,
-			.has_eeprom   = 1,
-			.has_remote   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 1,
+			.has_zl10353    = 1,
+			.has_eeprom     = 1,
+			.has_remote     = 1,
+			.has_input_comp = 1,
+			.has_input_svid = 1,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
@@ -255,11 +257,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 0,
-			.has_zl10353  = 0,
-			.has_eeprom   = 1,
-			.has_remote   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 0,
+			.has_zl10353    = 0,
+			.has_eeprom     = 1,
+			.has_remote     = 1,
+			.has_input_comp = 1,
+			.has_input_svid = 1,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
@@ -327,10 +331,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 1,
-			.has_zl10353  = 1,
-			.has_eeprom   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 1,
+			.has_zl10353    = 1,
+			.has_eeprom     = 1,
+			.has_remote     = 0,
+			.has_input_comp = 0,
+			.has_input_svid = 0,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
@@ -346,10 +353,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 0,
-			.has_zl10353  = 0,
-			.has_eeprom   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 0,
+			.has_zl10353    = 0,
+			.has_eeprom     = 1,
+			.has_remote     = 0,
+			.has_input_comp = 0,
+			.has_input_svid = 0,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index a4c07e5..da3e51b 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -1161,8 +1161,6 @@ int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
 				rc = tm6000_load_std(dev, svideo_stds[i].common,
 						     sizeof(svideo_stds[i].
 							    common));
-				tm6000_set_audio_std(dev, svideo_stds[i].audio_default_std);
-
 				goto ret;
 			}
 		}
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index b550340..c80a316 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1080,18 +1080,27 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *norm)
 static int vidioc_enum_input(struct file *file, void *priv,
 				struct v4l2_input *inp)
 {
+	struct tm6000_fh   *fh = priv;
+	struct tm6000_core *dev = fh->dev;
+
 	switch (inp->index) {
 	case TM6000_INPUT_TV:
 		inp->type = V4L2_INPUT_TYPE_TUNER;
 		strcpy(inp->name, "Television");
 		break;
 	case TM6000_INPUT_COMPOSITE:
-		inp->type = V4L2_INPUT_TYPE_CAMERA;
-		strcpy(inp->name, "Composite");
+		if (dev->caps.has_input_comp) {
+			inp->type = V4L2_INPUT_TYPE_CAMERA;
+			strcpy(inp->name, "Composite");
+		} else
+			return -EINVAL;
 		break;
 	case TM6000_INPUT_SVIDEO:
-		inp->type = V4L2_INPUT_TYPE_CAMERA;
-		strcpy(inp->name, "S-Video");
+		if (dev->caps.has_input_svid) {
+			inp->type = V4L2_INPUT_TYPE_CAMERA;
+			strcpy(inp->name, "S-Video");
+		} else
+			return -EINVAL;
 		break;
 	default:
 		return -EINVAL;
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index ccd120f..99ae50e 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -129,6 +129,8 @@ struct tm6000_capabilities {
 	unsigned int    has_zl10353:1;
 	unsigned int    has_eeprom:1;
 	unsigned int    has_remote:1;
+	unsigned int    has_input_comp:1;
+	unsigned int    has_input_svid:1;
 };
 
 struct tm6000_dvb {

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

With my best regards, Dmitry.

[-- Attachment #2: tm6000_svideo.patch --]
[-- Type: text/x-patch, Size: 4271 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 88144a1..146c7e8 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -235,11 +235,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 1,
-			.has_zl10353  = 1,
-			.has_eeprom   = 1,
-			.has_remote   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 1,
+			.has_zl10353    = 1,
+			.has_eeprom     = 1,
+			.has_remote     = 1,
+			.has_input_comp = 1,
+			.has_input_svid = 1,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
@@ -255,11 +257,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 0,
-			.has_zl10353  = 0,
-			.has_eeprom   = 1,
-			.has_remote   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 0,
+			.has_zl10353    = 0,
+			.has_eeprom     = 1,
+			.has_remote     = 1,
+			.has_input_comp = 1,
+			.has_input_svid = 1,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
@@ -327,10 +331,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 1,
-			.has_zl10353  = 1,
-			.has_eeprom   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 1,
+			.has_zl10353    = 1,
+			.has_eeprom     = 1,
+			.has_remote     = 0,
+			.has_input_comp = 0,
+			.has_input_svid = 0,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
@@ -346,10 +353,13 @@ struct tm6000_board tm6000_boards[] = {
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
 		.caps = {
-			.has_tuner    = 1,
-			.has_dvb      = 0,
-			.has_zl10353  = 0,
-			.has_eeprom   = 1,
+			.has_tuner      = 1,
+			.has_dvb        = 0,
+			.has_zl10353    = 0,
+			.has_eeprom     = 1,
+			.has_remote     = 0,
+			.has_input_comp = 0,
+			.has_input_svid = 0,
 		},
 		.gpio = {
 			.tuner_reset	= TM6010_GPIO_0,
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index a4c07e5..da3e51b 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -1161,8 +1161,6 @@ int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
 				rc = tm6000_load_std(dev, svideo_stds[i].common,
 						     sizeof(svideo_stds[i].
 							    common));
-				tm6000_set_audio_std(dev, svideo_stds[i].audio_default_std);
-
 				goto ret;
 			}
 		}
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index b550340..c80a316 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1080,18 +1080,27 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *norm)
 static int vidioc_enum_input(struct file *file, void *priv,
 				struct v4l2_input *inp)
 {
+	struct tm6000_fh   *fh = priv;
+	struct tm6000_core *dev = fh->dev;
+
 	switch (inp->index) {
 	case TM6000_INPUT_TV:
 		inp->type = V4L2_INPUT_TYPE_TUNER;
 		strcpy(inp->name, "Television");
 		break;
 	case TM6000_INPUT_COMPOSITE:
-		inp->type = V4L2_INPUT_TYPE_CAMERA;
-		strcpy(inp->name, "Composite");
+		if (dev->caps.has_input_comp) {
+			inp->type = V4L2_INPUT_TYPE_CAMERA;
+			strcpy(inp->name, "Composite");
+		} else
+			return -EINVAL;
 		break;
 	case TM6000_INPUT_SVIDEO:
-		inp->type = V4L2_INPUT_TYPE_CAMERA;
-		strcpy(inp->name, "S-Video");
+		if (dev->caps.has_input_svid) {
+			inp->type = V4L2_INPUT_TYPE_CAMERA;
+			strcpy(inp->name, "S-Video");
+		} else
+			return -EINVAL;
 		break;
 	default:
 		return -EINVAL;
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index ccd120f..99ae50e 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -129,6 +129,8 @@ struct tm6000_capabilities {
 	unsigned int    has_zl10353:1;
 	unsigned int    has_eeprom:1;
 	unsigned int    has_remote:1;
+	unsigned int    has_input_comp:1;
+	unsigned int    has_input_svid:1;
 };
 
 struct tm6000_dvb {

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH] tm6000: fix s-video input
  2011-03-18  0:08                                                             ` [PATCH] tm6000: fix s-video input Dmitri Belimov
@ 2011-03-19  6:46                                                               ` Stefan Ringel
  2011-03-23  2:49                                                                 ` Dmitri Belimov
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Ringel @ 2011-03-19  6:46 UTC (permalink / raw)
  To: Dmitri Belimov; +Cc: Mauro Carvalho Chehab, Linux Media Mailing List


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Am 18.03.2011 01:08, schrieb Dmitri Belimov:
> Hi
>
> Add compatibility for composite and s-video inputs. Some TV cards
hasn't it.
> Fix S-Video input, the s-video cable has only video signals no audio.
Call the function of audio configure kill chroma in signal. only b/w video.
>
> Known bugs:
> after s-video the audio for radio didn't work, TV crashed hardly
> after composite TV crashed hardly too.
>
> P.S. After this patch I'll want to rework the procedure of configure
video. Now it has a lot of junk and dubles.
>

Why you use caps to define video input and audio with avideo and/or
aradio as flags? Better is , I think,  we use a struct for edge
virtual input (Video type (s-vhs, composite, tuner), video input pin
(video port a, video port b or both), video mode gpio, audio type ,
audio input pin (adc 1, adc 2 or sif)). If we are called
vidioc_s_input or radio_g_input setting input number. In tm6000_std.c
we can use this input number and the input struct with the same number
and can use all setting from here to set it.

Stefan Ringel


> diff --git a/drivers/staging/tm6000/tm6000-cards.c
b/drivers/staging/tm6000/tm6000-cards.c
> index 88144a1..146c7e8 100644
> --- a/drivers/staging/tm6000/tm6000-cards.c
> +++ b/drivers/staging/tm6000/tm6000-cards.c
> @@ -235,11 +235,13 @@ struct tm6000_board tm6000_boards[] = {
> .avideo = TM6000_AIP_SIF1,
> .aradio = TM6000_AIP_LINE1,
> .caps = {
> - .has_tuner = 1,
> - .has_dvb = 1,
> - .has_zl10353 = 1,
> - .has_eeprom = 1,
> - .has_remote = 1,
> + .has_tuner = 1,
> + .has_dvb = 1,
> + .has_zl10353 = 1,
> + .has_eeprom = 1,
> + .has_remote = 1,
> + .has_input_comp = 1,
> + .has_input_svid = 1,
> },
> .gpio = {
> .tuner_reset = TM6010_GPIO_0,
> @@ -255,11 +257,13 @@ struct tm6000_board tm6000_boards[] = {
> .avideo = TM6000_AIP_SIF1,
> .aradio = TM6000_AIP_LINE1,
> .caps = {
> - .has_tuner = 1,
> - .has_dvb = 0,
> - .has_zl10353 = 0,
> - .has_eeprom = 1,
> - .has_remote = 1,
> + .has_tuner = 1,
> + .has_dvb = 0,
> + .has_zl10353 = 0,
> + .has_eeprom = 1,
> + .has_remote = 1,
> + .has_input_comp = 1,
> + .has_input_svid = 1,
> },
> .gpio = {
> .tuner_reset = TM6010_GPIO_0,
> @@ -327,10 +331,13 @@ struct tm6000_board tm6000_boards[] = {
> .avideo = TM6000_AIP_SIF1,
> .aradio = TM6000_AIP_LINE1,
> .caps = {
> - .has_tuner = 1,
> - .has_dvb = 1,
> - .has_zl10353 = 1,
> - .has_eeprom = 1,
> + .has_tuner = 1,
> + .has_dvb = 1,
> + .has_zl10353 = 1,
> + .has_eeprom = 1,
> + .has_remote = 0,
> + .has_input_comp = 0,
> + .has_input_svid = 0,
> },
> .gpio = {
> .tuner_reset = TM6010_GPIO_0,
> @@ -346,10 +353,13 @@ struct tm6000_board tm6000_boards[] = {
> .avideo = TM6000_AIP_SIF1,
> .aradio = TM6000_AIP_LINE1,
> .caps = {
> - .has_tuner = 1,
> - .has_dvb = 0,
> - .has_zl10353 = 0,
> - .has_eeprom = 1,
> + .has_tuner = 1,
> + .has_dvb = 0,
> + .has_zl10353 = 0,
> + .has_eeprom = 1,
> + .has_remote = 0,
> + .has_input_comp = 0,
> + .has_input_svid = 0,
> },
> .gpio = {
> .tuner_reset = TM6010_GPIO_0,
> diff --git a/drivers/staging/tm6000/tm6000-stds.c
b/drivers/staging/tm6000/tm6000-stds.c
> index a4c07e5..da3e51b 100644
> --- a/drivers/staging/tm6000/tm6000-stds.c
> +++ b/drivers/staging/tm6000/tm6000-stds.c
> @@ -1161,8 +1161,6 @@ int tm6000_set_standard(struct tm6000_core *dev,
v4l2_std_id * norm)
> rc = tm6000_load_std(dev, svideo_stds[i].common,
> sizeof(svideo_stds[i].
> common));
> - tm6000_set_audio_std(dev, svideo_stds[i].audio_default_std);
> -
> goto ret;
> }
> }
> diff --git a/drivers/staging/tm6000/tm6000-video.c
b/drivers/staging/tm6000/tm6000-video.c
> index b550340..c80a316 100644
> --- a/drivers/staging/tm6000/tm6000-video.c
> +++ b/drivers/staging/tm6000/tm6000-video.c
> @@ -1080,18 +1080,27 @@ static int vidioc_s_std (struct file *file,
void *priv, v4l2_std_id *norm)
> static int vidioc_enum_input(struct file *file, void *priv,
> struct v4l2_input *inp)
> {
> + struct tm6000_fh *fh = priv;
> + struct tm6000_core *dev = fh->dev;
> +
> switch (inp->index) {
> case TM6000_INPUT_TV:
> inp->type = V4L2_INPUT_TYPE_TUNER;
> strcpy(inp->name, "Television");
> break;
> case TM6000_INPUT_COMPOSITE:
> - inp->type = V4L2_INPUT_TYPE_CAMERA;
> - strcpy(inp->name, "Composite");
> + if (dev->caps.has_input_comp) {
> + inp->type = V4L2_INPUT_TYPE_CAMERA;
> + strcpy(inp->name, "Composite");
> + } else
> + return -EINVAL;
> break;
> case TM6000_INPUT_SVIDEO:
> - inp->type = V4L2_INPUT_TYPE_CAMERA;
> - strcpy(inp->name, "S-Video");
> + if (dev->caps.has_input_svid) {
> + inp->type = V4L2_INPUT_TYPE_CAMERA;
> + strcpy(inp->name, "S-Video");
> + } else
> + return -EINVAL;
> break;
> default:
> return -EINVAL;
> diff --git a/drivers/staging/tm6000/tm6000.h
b/drivers/staging/tm6000/tm6000.h
> index ccd120f..99ae50e 100644
> --- a/drivers/staging/tm6000/tm6000.h
> +++ b/drivers/staging/tm6000/tm6000.h
> @@ -129,6 +129,8 @@ struct tm6000_capabilities {
> unsigned int has_zl10353:1;
> unsigned int has_eeprom:1;
> unsigned int has_remote:1;
> + unsigned int has_input_comp:1;
> + unsigned int has_input_svid:1;
> };
>
> struct tm6000_dvb {
>
> Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>
>
> With my best regards, Dmitry.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iQEcBAEBAgAGBQJNhFFgAAoJEAWtPFjxMvFGATAH/RZnxOBnRF7bvpInTVcvDr3f
siYCB6O+JKKLwA8dWzh5ejOi+cBcYWPqcgJcZ2s/0dedqEQ8/RVxGflrnYk66/vT
KP3JkysbH3Nme9mE9AlSXSrCpGg6AG9u99SgyHkCJQKASkQX7dHg/prz4iMySIgi
Ii05FHR2f5P5FmaH96eKjgzd8J8WSHe2excr07gKg2FL2bX8icnqt0Lz7S1/V0rQ
ewdL9cOh+IBsIG8dOLBetB3rxlfEtheph7bHtBqJ2s9+yo9KVj8tynpGghgoNrAw
ntDttbSrnCjcXaALKFfXBvAnv349jwbBLnyZU3PWjK560sdjg9bhLi515xYXwhM=
=eldX
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] tm6000: fix s-video input
  2011-03-19  6:46                                                               ` Stefan Ringel
@ 2011-03-23  2:49                                                                 ` Dmitri Belimov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitri Belimov @ 2011-03-23  2:49 UTC (permalink / raw)
  To: Stefan Ringel; +Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Hi Stefan

> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>  
> Am 18.03.2011 01:08, schrieb Dmitri Belimov:
> > Hi
> >
> > Add compatibility for composite and s-video inputs. Some TV cards
> hasn't it.
> > Fix S-Video input, the s-video cable has only video signals no
> > audio.
> Call the function of audio configure kill chroma in signal. only b/w
> video.
> >
> > Known bugs:
> > after s-video the audio for radio didn't work, TV crashed hardly
> > after composite TV crashed hardly too.
> >
> > P.S. After this patch I'll want to rework the procedure of configure
> video. Now it has a lot of junk and dubles.
> >
> 
> Why you use caps to define video input and audio with avideo and/or
> aradio as flags? Better is , I think,  we use a struct for edge
> virtual input (Video type (s-vhs, composite, tuner), video input pin
> (video port a, video port b or both), video mode gpio, audio type ,
> audio input pin (adc 1, adc 2 or sif)). If we are called
> vidioc_s_input or radio_g_input setting input number. In tm6000_std.c
> we can use this input number and the input struct with the same number
> and can use all setting from here to set it.

It's very intresting but right now much better for me make full-working TV cards.
You can rework this part of code as you want. Or we can do it togehter.

With my best regards, Dmitry.

> Stefan Ringel
> 
> 
> > diff --git a/drivers/staging/tm6000/tm6000-cards.c
> b/drivers/staging/tm6000/tm6000-cards.c
> > index 88144a1..146c7e8 100644
> > --- a/drivers/staging/tm6000/tm6000-cards.c
> > +++ b/drivers/staging/tm6000/tm6000-cards.c
> > @@ -235,11 +235,13 @@ struct tm6000_board tm6000_boards[] = {
> > .avideo = TM6000_AIP_SIF1,
> > .aradio = TM6000_AIP_LINE1,
> > .caps = {
> > - .has_tuner = 1,
> > - .has_dvb = 1,
> > - .has_zl10353 = 1,
> > - .has_eeprom = 1,
> > - .has_remote = 1,
> > + .has_tuner = 1,
> > + .has_dvb = 1,
> > + .has_zl10353 = 1,
> > + .has_eeprom = 1,
> > + .has_remote = 1,
> > + .has_input_comp = 1,
> > + .has_input_svid = 1,
> > },
> > .gpio = {
> > .tuner_reset = TM6010_GPIO_0,
> > @@ -255,11 +257,13 @@ struct tm6000_board tm6000_boards[] = {
> > .avideo = TM6000_AIP_SIF1,
> > .aradio = TM6000_AIP_LINE1,
> > .caps = {
> > - .has_tuner = 1,
> > - .has_dvb = 0,
> > - .has_zl10353 = 0,
> > - .has_eeprom = 1,
> > - .has_remote = 1,
> > + .has_tuner = 1,
> > + .has_dvb = 0,
> > + .has_zl10353 = 0,
> > + .has_eeprom = 1,
> > + .has_remote = 1,
> > + .has_input_comp = 1,
> > + .has_input_svid = 1,
> > },
> > .gpio = {
> > .tuner_reset = TM6010_GPIO_0,
> > @@ -327,10 +331,13 @@ struct tm6000_board tm6000_boards[] = {
> > .avideo = TM6000_AIP_SIF1,
> > .aradio = TM6000_AIP_LINE1,
> > .caps = {
> > - .has_tuner = 1,
> > - .has_dvb = 1,
> > - .has_zl10353 = 1,
> > - .has_eeprom = 1,
> > + .has_tuner = 1,
> > + .has_dvb = 1,
> > + .has_zl10353 = 1,
> > + .has_eeprom = 1,
> > + .has_remote = 0,
> > + .has_input_comp = 0,
> > + .has_input_svid = 0,
> > },
> > .gpio = {
> > .tuner_reset = TM6010_GPIO_0,
> > @@ -346,10 +353,13 @@ struct tm6000_board tm6000_boards[] = {
> > .avideo = TM6000_AIP_SIF1,
> > .aradio = TM6000_AIP_LINE1,
> > .caps = {
> > - .has_tuner = 1,
> > - .has_dvb = 0,
> > - .has_zl10353 = 0,
> > - .has_eeprom = 1,
> > + .has_tuner = 1,
> > + .has_dvb = 0,
> > + .has_zl10353 = 0,
> > + .has_eeprom = 1,
> > + .has_remote = 0,
> > + .has_input_comp = 0,
> > + .has_input_svid = 0,
> > },
> > .gpio = {
> > .tuner_reset = TM6010_GPIO_0,
> > diff --git a/drivers/staging/tm6000/tm6000-stds.c
> b/drivers/staging/tm6000/tm6000-stds.c
> > index a4c07e5..da3e51b 100644
> > --- a/drivers/staging/tm6000/tm6000-stds.c
> > +++ b/drivers/staging/tm6000/tm6000-stds.c
> > @@ -1161,8 +1161,6 @@ int tm6000_set_standard(struct tm6000_core
> > *dev,
> v4l2_std_id * norm)
> > rc = tm6000_load_std(dev, svideo_stds[i].common,
> > sizeof(svideo_stds[i].
> > common));
> > - tm6000_set_audio_std(dev, svideo_stds[i].audio_default_std);
> > -
> > goto ret;
> > }
> > }
> > diff --git a/drivers/staging/tm6000/tm6000-video.c
> b/drivers/staging/tm6000/tm6000-video.c
> > index b550340..c80a316 100644
> > --- a/drivers/staging/tm6000/tm6000-video.c
> > +++ b/drivers/staging/tm6000/tm6000-video.c
> > @@ -1080,18 +1080,27 @@ static int vidioc_s_std (struct file *file,
> void *priv, v4l2_std_id *norm)
> > static int vidioc_enum_input(struct file *file, void *priv,
> > struct v4l2_input *inp)
> > {
> > + struct tm6000_fh *fh = priv;
> > + struct tm6000_core *dev = fh->dev;
> > +
> > switch (inp->index) {
> > case TM6000_INPUT_TV:
> > inp->type = V4L2_INPUT_TYPE_TUNER;
> > strcpy(inp->name, "Television");
> > break;
> > case TM6000_INPUT_COMPOSITE:
> > - inp->type = V4L2_INPUT_TYPE_CAMERA;
> > - strcpy(inp->name, "Composite");
> > + if (dev->caps.has_input_comp) {
> > + inp->type = V4L2_INPUT_TYPE_CAMERA;
> > + strcpy(inp->name, "Composite");
> > + } else
> > + return -EINVAL;
> > break;
> > case TM6000_INPUT_SVIDEO:
> > - inp->type = V4L2_INPUT_TYPE_CAMERA;
> > - strcpy(inp->name, "S-Video");
> > + if (dev->caps.has_input_svid) {
> > + inp->type = V4L2_INPUT_TYPE_CAMERA;
> > + strcpy(inp->name, "S-Video");
> > + } else
> > + return -EINVAL;
> > break;
> > default:
> > return -EINVAL;
> > diff --git a/drivers/staging/tm6000/tm6000.h
> b/drivers/staging/tm6000/tm6000.h
> > index ccd120f..99ae50e 100644
> > --- a/drivers/staging/tm6000/tm6000.h
> > +++ b/drivers/staging/tm6000/tm6000.h
> > @@ -129,6 +129,8 @@ struct tm6000_capabilities {
> > unsigned int has_zl10353:1;
> > unsigned int has_eeprom:1;
> > unsigned int has_remote:1;
> > + unsigned int has_input_comp:1;
> > + unsigned int has_input_svid:1;
> > };
> >
> > struct tm6000_dvb {
> >
> > Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov
> > <d.belimov@gmail.com>
> >
> > With my best regards, Dmitry.
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.12 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>  
> iQEcBAEBAgAGBQJNhFFgAAoJEAWtPFjxMvFGATAH/RZnxOBnRF7bvpInTVcvDr3f
> siYCB6O+JKKLwA8dWzh5ejOi+cBcYWPqcgJcZ2s/0dedqEQ8/RVxGflrnYk66/vT
> KP3JkysbH3Nme9mE9AlSXSrCpGg6AG9u99SgyHkCJQKASkQX7dHg/prz4iMySIgi
> Ii05FHR2f5P5FmaH96eKjgzd8J8WSHe2excr07gKg2FL2bX8icnqt0Lz7S1/V0rQ
> ewdL9cOh+IBsIG8dOLBetB3rxlfEtheph7bHtBqJ2s9+yo9KVj8tynpGghgoNrAw
> ntDttbSrnCjcXaALKFfXBvAnv349jwbBLnyZU3PWjK560sdjg9bhLi515xYXwhM=
> =eldX
> -----END PGP SIGNATURE-----
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v1] tm6000: rework standards
  2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
                                                                               ` (2 preceding siblings ...)
  2011-03-18  0:08                                                             ` [PATCH] tm6000: fix s-video input Dmitri Belimov
@ 2011-04-19  5:29                                                             ` Dmitri Belimov
  2011-04-19  6:42                                                               ` Stefan Ringel
  3 siblings, 1 reply; 36+ messages in thread
From: Dmitri Belimov @ 2011-04-19  5:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Stefan Ringel; +Cc: Linux Media Mailing List

[-- Attachment #1: Type: text/plain, Size: 63878 bytes --]

Hi

Add audio configuration for composite input.
Rework init process of the tm6010.
Rework configure video standards.

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 146c7e8..9cf1abd 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -68,6 +68,7 @@ struct tm6000_board {
 	struct tm6000_capabilities caps;
 	enum            tm6000_inaudio aradio;
 	enum            tm6000_inaudio avideo;
+	enum            tm6000_inaudio acomposite;
 
 	enum		tm6000_devtype type;	/* variant of the chipset */
 	int             tuner_type;     /* type of the tuner */
@@ -234,6 +235,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 1,
@@ -256,6 +258,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 0,
@@ -330,6 +333,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 1,
@@ -352,6 +356,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 0,
@@ -753,6 +758,7 @@ static int tm6000_init_dev(struct tm6000_core *dev)
 
 	dev->avideo = tm6000_boards[dev->model].avideo;
 	dev->aradio = tm6000_boards[dev->model].aradio;
+	dev->acomposite = tm6000_boards[dev->model].acomposite;
 	/* initialize hardware */
 	rc = tm6000_init(dev);
 	if (rc < 0)
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 778e534..ec7f613 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -201,68 +201,6 @@ void tm6000_set_fourcc_format(struct tm6000_core *dev)
 	}
 }
 
-static void tm6000_set_vbi(struct tm6000_core *dev)
-{
-	/*
-	 * FIXME:
-	 * VBI lines and start/end are different between 60Hz and 50Hz
-	 * So, it is very likely that we need to change the config to
-	 * something that takes it into account, doing something different
-	 * if (dev->norm & V4L2_STD_525_60)
-	 */
-
-	if (dev->dev_type == TM6010) {
-		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ07_R41_TELETEXT_VBI_CODE1, 0x27);
-		tm6000_set_reg(dev, TM6010_REQ07_R42_VBI_DATA_HIGH_LEVEL, 0x55);
-		tm6000_set_reg(dev, TM6010_REQ07_R43_VBI_DATA_TYPE_LINE7, 0x66);
-		tm6000_set_reg(dev, TM6010_REQ07_R44_VBI_DATA_TYPE_LINE8, 0x66);
-		tm6000_set_reg(dev, TM6010_REQ07_R45_VBI_DATA_TYPE_LINE9, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R46_VBI_DATA_TYPE_LINE10, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R47_VBI_DATA_TYPE_LINE11, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R48_VBI_DATA_TYPE_LINE12, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R49_VBI_DATA_TYPE_LINE13, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4A_VBI_DATA_TYPE_LINE14, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4B_VBI_DATA_TYPE_LINE15, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4C_VBI_DATA_TYPE_LINE16, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4D_VBI_DATA_TYPE_LINE17, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4E_VBI_DATA_TYPE_LINE18, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4F_VBI_DATA_TYPE_LINE19, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R50_VBI_DATA_TYPE_LINE20, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R51_VBI_DATA_TYPE_LINE21, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R52_VBI_DATA_TYPE_LINE22, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R53_VBI_DATA_TYPE_LINE23, 0x00);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R54_VBI_DATA_TYPE_RLINES, 0x00);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R55_VBI_LOOP_FILTER_GAIN, 0x01);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R56_VBI_LOOP_FILTER_I_GAIN, 0x00);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R57_VBI_LOOP_FILTER_P_GAIN, 0x02);
-		tm6000_set_reg(dev, TM6010_REQ07_R58_VBI_CAPTION_DTO1, 0x35);
-		tm6000_set_reg(dev, TM6010_REQ07_R59_VBI_CAPTION_DTO0, 0xa0);
-		tm6000_set_reg(dev, TM6010_REQ07_R5A_VBI_TELETEXT_DTO1, 0x11);
-		tm6000_set_reg(dev, TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c);
-		tm6000_set_reg(dev, TM6010_REQ07_R40_TELETEXT_VBI_CODE0, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
-	}
-}
-
 int tm6000_init_analog_mode(struct tm6000_core *dev)
 {
 	struct v4l2_frequency f;
@@ -275,7 +213,6 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 		tm6000_set_reg_mask(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE,
 							0x00, 0x40);
 		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
-
 	} else {
 		/* Enables soft reset */
 		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
@@ -328,7 +265,6 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 
 	msleep(100);
 	tm6000_set_standard(dev, &dev->norm);
-	tm6000_set_vbi(dev);
 	tm6000_set_audio_bitrate(dev, 48000);
 
 	/* switch dvb led off */
@@ -504,12 +440,13 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x07 },
 	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
 	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00 },
-	{ TM6010_REQ07_R05_NOISE_THRESHOLD, 0x64 },
+	{ TM6010_REQ07_R05_NOISE_THRESHOLD, 0x50 },
 	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x01 },
 	{ TM6010_REQ07_R08_LUMA_CONTRAST_ADJ, 0x82 },
 	{ TM6010_REQ07_R09_LUMA_BRIGHTNESS_ADJ, 0x36 },
 	{ TM6010_REQ07_R0A_CHROMA_SATURATION_ADJ, 0x50 },
 	{ TM6010_REQ07_R0C_CHROMA_AGC_CONTROL, 0x6a },
+	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x17},
 	{ TM6010_REQ07_R11_AGC_PEAK_CONTROL, 0xc9 },
 	{ TM6010_REQ07_R12_AGC_GATE_STARTH, 0x07 },
 	{ TM6010_REQ07_R13_AGC_GATE_STARTL, 0x3b },
@@ -524,8 +461,8 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
 	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
 	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
-	{ TM6010_REQ07_R20_HSYNC_RISING_EDGE_TIME, 0x3c },
-	{ TM6010_REQ07_R21_HSYNC_PHASE_OFFSET, 0x3c },
+	{ TM6010_REQ07_R20_HSYNC_RISING_EDGE_TIME, 0x3e },
+	{ TM6010_REQ07_R21_HSYNC_PHASE_OFFSET, 0x3e },
 	{ TM6010_REQ07_R2D_CHROMA_BURST_END, 0x48 },
 	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
 	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
@@ -544,12 +481,18 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ07_R57_VBI_LOOP_FILTER_P_GAIN, 0x02 },
 	{ TM6010_REQ07_R58_VBI_CAPTION_DTO1, 0x35 },
 	{ TM6010_REQ07_R59_VBI_CAPTION_DTO0, 0xa0 },
+	{ TM6010_REQ07_R5A_VBI_TELETEXT_DTO1, 0x11},
+	{ TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c},
+	{ TM6010_REQ07_R60_TELETEXT_FRAME_START, 0x52},
+	{ TM6010_REQ07_R68_VBI_TELETEXT_START, 0x32},
 	{ TM6010_REQ07_R80_COMB_FILTER_TRESHOLD, 0x15 },
 	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
+	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xa9},
 	{ TM6010_REQ07_RC1_TRESHOLD, 0xd0 },
 	{ TM6010_REQ07_RC3_HSTART1, 0x88 },
 	{ TM6010_REQ07_R3F_RESET, 0x00 },
 
+	{ TM6010_REQ07_R3F_RESET, 0x00 },
 	{ TM6010_REQ05_R18_IMASK7, 0x00 },
 
 	{ TM6010_REQ07_RD8_IR_LEADER1, 0xaa },
@@ -615,6 +558,38 @@ int tm6000_init(struct tm6000_core *dev)
 	return rc;
 }
 
+void tm6000_init_demdec(struct tm6000_core *dev)
+{
+	/* Set GCD2 to autogain */
+	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+	/* Reduce SIF amplitude */
+	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
+	/* Set autodetect threshold */
+	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+	/* Set auto-dematrix threshold */
+	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
+	/* Set NICAM error limits max */
+	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
+	/* Set NICAM error limits min */
+	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
+	/* Set gain max +6dB */
+	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+	/* Set gain min -6dB */
+	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+	/* Enable ADC (always use) */
+	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+}
+EXPORT_SYMBOL_GPL(tm6000_init_demdec);
+
+void tm6000_reset_demdec(struct tm6000_core *dev)
+{
+	/* Set DemDec to IDLE */
+	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+	/* Set DemDec to Restart */
+	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+}
+EXPORT_SYMBOL_GPL(tm6000_reset_demdec);
+
 int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate)
 {
 	int val = 0;
@@ -662,11 +637,13 @@ int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
 	if (dev->dev_type == TM6010) {
 		/* Audio crossbar setting, default SIF1 */
 		u8 areg_f0 = 0x03;
+		u8 areg_07 = 0x10;
 
 		switch (ainp) {
 		case TM6000_AIP_SIF1:
 		case TM6000_AIP_SIF2:
 			areg_f0 = 0x03;
+			areg_07 = 0x30;
 			break;
 		case TM6000_AIP_LINE1:
 			areg_f0 = 0x00;
@@ -681,6 +658,10 @@ int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
 		/* Set audio input crossbar */
 		tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
 							areg_f0, 0x0f);
+
+		/* Mux overflow workaround */
+		tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
+							areg_07, 0xf0);
 	} else {
 		/* Audio setting, default LINE1 */
 		u8 areg_eb = 0x00;
@@ -802,8 +783,10 @@ void tm6000_set_volume(struct tm6000_core *dev, int vol)
 	if (dev->radio) {
 		ainp = dev->aradio;
 		vol += 8; /* Offset to 0 dB */
-	} else
-		ainp = dev->avideo;
+	} else if (dev->input != TM6000_INPUT_COMPOSITE)
+			ainp = dev->avideo;
+		else
+			ainp = dev->acomposite;
 
 	switch (ainp) {
 	case TM6000_AIP_SIF1:
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index da3e51b..fdb0280 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -22,12 +22,6 @@
 #include "tm6000.h"
 #include "tm6000-regs.h"
 
-struct tm6000_reg_settings {
-	unsigned char req;
-	unsigned char reg;
-	unsigned char value;
-};
-
 enum tm6000_audio_std {
 	BG_NICAM,
 	BTSC,
@@ -40,909 +34,6 @@ enum tm6000_audio_std {
 	L_NICAM,
 };
 
-struct tm6000_std_tv_settings {
-	v4l2_std_id id;
-	enum tm6000_audio_std audio_default_std;
-
-	struct tm6000_reg_settings sif[12];
-	struct tm6000_reg_settings nosif[12];
-	struct tm6000_reg_settings common[26];
-};
-
-struct tm6000_std_settings {
-	v4l2_std_id id;
-	enum tm6000_audio_std audio_default_std;
-	struct tm6000_reg_settings common[37];
-};
-
-static struct tm6000_std_tv_settings tv_stds[] = {
-	{
-		.id = V4L2_STD_PAL_M,
-		.audio_default_std = BTSC,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL_Nc,
-		.audio_default_std = BTSC,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL,
-		.audio_default_std = BG_A2,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0}
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
-		.audio_default_std = BG_NICAM,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_DK,
-		.audio_default_std = DK_NICAM,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_NTSC,
-		.audio_default_std = BTSC,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	},
-};
-
-static struct tm6000_std_settings composite_stds[] = {
-	{
-		.id = V4L2_STD_PAL_M,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	 }, {
-		.id = V4L2_STD_PAL_Nc,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL,
-		.audio_default_std = BG_A2,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	 }, {
-		.id = V4L2_STD_SECAM,
-		.audio_default_std = BG_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_DK,
-		.audio_default_std = DK_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_NTSC,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	},
-};
-
-static struct tm6000_std_settings svideo_stds[] = {
-	{
-		.id = V4L2_STD_PAL_M,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x05},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL_Nc,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x37},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL,
-		.audio_default_std = BG_A2,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x33},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	 }, {
-		.id = V4L2_STD_SECAM,
-		.audio_default_std = BG_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_DK,
-		.audio_default_std = DK_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_NTSC,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x01},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
-			{TM6010_REQ07_R17_HLOOP_MAXSTATE, 0x8b},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	},
-};
-
-
 static int tm6000_set_audio_std(struct tm6000_core *dev,
 				enum tm6000_audio_std std)
 {
@@ -952,22 +43,6 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 	uint8_t mono_flag = 0;  /* No mono */
 	uint8_t nicam_flag = 0; /* No NICAM */
 
-	if (dev->radio) {
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
-		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
-		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
-		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
-		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
-		return 0;
-	}
-
 	switch (std) {
 #if 0
 	case DK_MONO:
@@ -1012,6 +87,21 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 		areg_05 = 0x0a;
 		nicam_flag = 1;
 		break;
+	case FM_RADIO:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
+		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
+		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		return 0;
+		break;
 	default:
 		/* do nothink */
 		break;
@@ -1036,39 +126,10 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 
 	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
 	tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
-	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
 	tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, areg_05);
 	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, areg_06);
-	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
 	tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-	tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-	tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
-	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
-	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
-	tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
-	tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
-	tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
-	tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
-	tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
-	tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
-	tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
-	tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
-	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-	tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
-	tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
-	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
-	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
-	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
-	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
 	tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-	tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
-	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
 	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
 
 	return 0;
@@ -1085,106 +146,419 @@ void tm6000_get_std_res(struct tm6000_core *dev)
 	dev->width = 720;
 }
 
-static int tm6000_load_std(struct tm6000_core *dev,
-			   struct tm6000_reg_settings *set, int max_size)
+int tm6000_config_video_input(struct tm6000_core *dev)
 {
-	int i, rc;
-
-	/* Load board's initialization table */
-	for (i = 0; max_size; i++) {
-		if (!set[i].req)
-			return 0;
-
-		if ((dev->dev_type != TM6010) &&
-		    (set[i].req == REQ_08_SET_GET_AVREG_BIT))
-				continue;
-
-		rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value);
-		if (rc < 0) {
-			printk(KERN_ERR "Error %i while setting "
-			       "req %d, reg %d to value %d\n",
-			       rc, set[i].req, set[i].reg, set[i].value);
-			return rc;
-		}
+	switch (dev->input) {
+	case TM6000_INPUT_TV:
+		/* Enable ADC2 (without clamp?) */
+		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08);
+		/* Power Up CLAMP, LPF BW = SIF mode */
+		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2);
+		/* Set ADC1 input = CVBS1 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8);
+		/* Set ADC2 input = SIF1 or SIF2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL,
+				(dev->avideo == TM6000_AIP_SIF1) ? 0xf7 : 0xf3);
+		/* Clamping level control in ADC2 = SIF signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf6);
+		/* SIF gain control enable signal = SIF signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0);
+		/* GAIN selection = Y and SIF */
+		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe8);
+		break;
+	case TM6000_INPUT_SVIDEO:
+		/* Enable ADC2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00);
+		/* Power Up CLAMP, LPF BW <> SIF mode */
+		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0);
+		/* Set ADC1 input = Y */
+		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc);
+		/* Set ADC2 input = C */
+		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8);
+		/* Clamping level control in ADC2 = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
+		/* SIF gain control enable signal = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
+		/* GAIN selection = Y and C */
+		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
+		break;
+	case TM6000_INPUT_COMPOSITE:
+		/* Set ADC1 input = CVBS2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4);
+		/* Power Up CLAMP, LPF BW <> SIF mode */
+		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0);
+		/* Set ADC2 input = none */
+		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xfc);
+		/* Disable ADC2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f);
+		/* Clamping level control in ADC2 = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
+		/* SIF gain control enable signal = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
+		/* GAIN selection = Y and C */
+		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
+		/* Set audio input */
+		tm6000_set_audio_input(dev, dev->acomposite);
+		tm6000_set_volume(dev, dev->ctl_volume);
+		break;
+	default:
+		printk(KERN_ERR "Error video input source - %d\n", dev->input);
+		return -EINVAL;
+		break;
 	}
 
 	return 0;
 }
 
-static int tm6000_set_tv(struct tm6000_core *dev, int pos)
+int tm6000_config_video_std(struct tm6000_core *dev, v4l2_std_id *norm)
 {
-	int rc;
+	int rc = 0;
+	uint8_t k;
+	uint8_t areg_D5 = 0x4f;
+	uint16_t tm_regs[0x90];
+	bool pal_fl = true;
+	bool f50hz_fl = true;
+
+	memset(tm_regs, 0xffff, sizeof(tm_regs));
+
+	dev->norm = *norm;
+	tm6000_get_std_res(dev);
 
-	/* FIXME: This code is for tm6010 - not tested yet - doesn't work with
-	   tm5600
-	 */
+	/* Chroma AGC target */
+	tm_regs[0x0c] = 0x6a;
+	/* HSYNC rising-edge occurrence time */
+	tm_regs[0x20] = 0x3e;
+	/* backporch start/end */
+	tm_regs[0x28] = 0x22;
+	tm_regs[0x29] = 0x4e;
+	/* Chroma burst start/end */
+	tm_regs[0x2c] = 0x2c;
+	tm_regs[0x2d] = 0x48;
+	/* VSYNC H lockout start/end */
+	tm_regs[0x32] = 0x74;
+	tm_regs[0x33] = 0x0c;
+	/* VSYNC AGC lockout start/end */
+	tm_regs[0x34] = 0x74;
+	tm_regs[0x35] = 0x1c;
+	/* Comb filter config (PAL off) */
+	tm_regs[0x82] = 0x42;
+
+	switch (*norm) {
+	case V4L2_STD_SECAM:
+	case V4L2_STD_SECAM_B:
+	case V4L2_STD_SECAM_G:
+	case V4L2_STD_SECAM_DK:
+		/* SECAM */
+		tm_regs[0x00] = 0x08;
+		tm_regs[0x01] = 0x02;
+		/* Full 2-D adaptive comb */
+		tm_regs[0x03] = 0x00;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 17.144 */
+		tm_regs[0x18] = 0x24;
+		tm_regs[0x19] = 0x92;
+		tm_regs[0x1a] = 0xe8;
+		tm_regs[0x1b] = 0xed;
+		/* backporch start/end */
+		tm_regs[0x28] = 0x42;
+		tm_regs[0x29] = 0x62;
+		/* Chroma burst start/end */
+		tm_regs[0x2c] = 0x44;
+		tm_regs[0x2d] = 0x60;
+		/* VSYNC H lockout start/end */
+		tm_regs[0x32] = 0x74;
+		tm_regs[0x33] = 0x2c;
+		/* VSYNC AGC lockout start/end */
+		tm_regs[0x34] = 0x74;
+		tm_regs[0x35] = 0x18;
+		pal_fl = false;
+		break;
+	case V4L2_STD_PAL:
+		/* PAL */
+		tm_regs[0x00] = 0x02;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xD5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		break;
+	case V4L2_STD_PAL_N:
+	case V4L2_STD_PAL_M:
+		/* PAL MN */
+		tm_regs[0x00] = 0x04;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 221 */
+		tm_regs[0x04] = 0xdd;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xD5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		break;
+	case V4L2_STD_PAL_Nc:
+		/* PAL Nc */
+		tm_regs[0x00] = 0x06;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 14.328225 */
+		tm_regs[0x18] = 0x1e;
+		tm_regs[0x19] = 0x91;
+		tm_regs[0x1a] = 0x1f;
+		tm_regs[0x1b] = 0x0c;
+		break;
+	case V4L2_STD_PAL_60:
+		/* PAL */
+		tm_regs[0x00] = 0x02;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xd5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		/* HSYNC rising-edge occurrence time */
+		tm_regs[0x20] = 0x4c;
+		f50hz_fl = false;
+		break;
+	case V4L2_STD_NTSC_M:
+	case V4L2_STD_NTSC_M_JP:
+	case V4L2_STD_NTSC_M_KR:
+		/* NTSC */
+		tm_regs[0x00] = 0x00;
+		/* Ped = 1 */
+		tm_regs[0x01] = 0x03;
+		/* Full 2-D adaptive comb */
+		tm_regs[0x03] = 0x00;
+		/* HAGC = 221 */
+		tm_regs[0x04] = 0xdd;
+		/* Chroma AGC target */
+		tm_regs[0x0c] = 0x8a;
+		/* DTO = 14.31818182 */
+		tm_regs[0x18] = 0x1e;
+		tm_regs[0x19] = 0x8b;
+		tm_regs[0x1a] = 0xa2;
+		tm_regs[0x1b] = 0xe9;
+		tm_regs[0x33] = 0x1c;
+		f50hz_fl = false;
+		pal_fl = false;
+		if (*norm == V4L2_STD_NTSC_M_JP) {
+			/* Ped = 0*/
+			tm_regs[0x01] = 0x02;
+			/* HAGC  205 */
+			tm_regs[0x04] = 0xcd;
+		}
+		break;
+	case V4L2_STD_NTSC_443:
+		/* NTSC */
+		tm_regs[0x00] = 0x00;
+		/* Ped = 1 */
+		tm_regs[0x01] = 0x03;
+		/* Full 2-D adaptive comb */
+		tm_regs[0x03] = 0x00;
+		/* HAGC = 221 */
+		tm_regs[0x04] = 0xdd;
+		/* Chroma AGC target */
+		tm_regs[0x0c] = 0x8a;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xd5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		tm_regs[0x33] = 0x1c;
+		pal_fl = false;
+		break;
+	}
 
-	/* FIXME: This is tuner-dependent */
-	int nosif = 0;
+	if (pal_fl) {
+		/* UV_FLT_EN = 1 */
+		areg_D5 |= 0x10;
+		/* comb_wide_band = 1 */
+		tm_regs[0x82] |= 0x10;
+	}
 
-	if (nosif) {
-		rc = tm6000_load_std(dev, tv_stds[pos].nosif,
-				     sizeof(tv_stds[pos].nosif));
+	if (f50hz_fl) {
+		/* vline_625 = 1, hpixel = 864 */
+		tm_regs[0x00] |= 0x30;
+		/* hactive_start = 138 */
+		tm_regs[0x2e] = 0x8a;
+		/* vactive_start = 42 */
+		tm_regs[0x30] = 0x2a;
+		/* vactive_hight = 171 */
+		tm_regs[0x31] = 0xc1;
+		/* VBI FRAME CODE */
+		tm_regs[0x41] = 0x27;
+		/* data high level */
+		tm_regs[0x42] = 0x5e;
+		/* vbil7 */
+		tm_regs[0x43] = 0x66;
+		/* vbil8 */
+		tm_regs[0x44] = 0x66;
+		/* vbil9 */
+		tm_regs[0x45] = 0x66;
+		/* vbil10 */
+		tm_regs[0x46] = 0x66;
+		/* vbil11 */
+		tm_regs[0x47] = 0x66;
+		/* vbil12 */
+		tm_regs[0x48] = 0x66;
+		/* vbil13 */
+		tm_regs[0x49] = 0x66;
+		/* vbil14 */
+		tm_regs[0x4a] = 0x66;
+		/* vbil15 */
+		tm_regs[0x4b] = 0x66;
+		/* vbil16 */
+		tm_regs[0x4c] = 0x66;
+		/* vbil17 */
+		tm_regs[0x4d] = 0x66;
+		/* vbil18 */
+		tm_regs[0x4e] = 0x66;
+		/* vbil19 */
+		tm_regs[0x4f] = 0x66;
+		/* vbil20 */
+		tm_regs[0x50] = 0x66;
+		/* vbil21 */
+		tm_regs[0x51] = 0x66;
+		/* vbil22 */
+		tm_regs[0x52] = 0x66;
+		/* vbil23 = WSS */
+		tm_regs[0x53] = 0x00;
+		/* vbil24 */
+		tm_regs[0x54] = 0x00;
 	} else {
-		rc = tm6000_load_std(dev, tv_stds[pos].sif,
-				     sizeof(tv_stds[pos].sif));
+		/* vline_625 = 0, hpixel = 858 */
+		tm_regs[0x00] &= 0xcf;
+		/* hactive_start = 134 */
+		tm_regs[0x2e] = 0x86;
+		/* vactive_start = 34 */
+		tm_regs[0x30] = 0x22;
+		/* vactive_hight = 121 */
+		tm_regs[0x31] = 0x61;
+		/* VBI FRAME CODE */
+		tm_regs[0x41] = 0xe7;
+		/* data high level */
+		tm_regs[0x42] = 0x58;
+		/* vbil7 */
+		tm_regs[0x43] = 0x00;
+		/* vbil8 */
+		tm_regs[0x44] = 0x00;
+		/* vbil9 */
+		tm_regs[0x45] = 0x00;
+		/* vbil10 */
+		tm_regs[0x46] = 0x00;
+		/* vbil11 */
+		tm_regs[0x47] = 0x00;
+		/* vbil12 */
+		tm_regs[0x48] = 0x00;
+		/* vbil13 */
+		tm_regs[0x49] = 0x00;
+		/* vbil14 */
+		tm_regs[0x4a] = 0x00;
+		/* vbil15 */
+		tm_regs[0x4b] = 0x00;
+		/* vbil16 */
+		tm_regs[0x4c] = 0x00;
+		/* vbil17 */
+		tm_regs[0x4d] = 0x00;
+		/* vbil18 */
+		tm_regs[0x4e] = 0x00;
+		/* vbil19 */
+		tm_regs[0x4f] = 0x00;
+		/* vbil20 */
+		tm_regs[0x50] = 0x00;
+		/* vbil21 = CC */
+		tm_regs[0x51] = 0x11;
+		/* vbil22 */
+		tm_regs[0x52] = 0x00;
+		/* vbil23 */
+		tm_regs[0x53] = 0x00;
+		/* vbil24 */
+		tm_regs[0x54] = 0x00;
+	}
+
+	if (dev->input == TM6000_INPUT_SVIDEO) {
+		/* Y_C = ON */
+		tm_regs[0x00] |= 0x01;
+		/* chroma_bw_lo = wide */
+		tm_regs[0x01] |= 0x04;
+		/* basic luma notch filter mode */
+		tm_regs[0x03] = 0x03;
 	}
-	if (rc < 0)
-		return rc;
-	rc = tm6000_load_std(dev, tv_stds[pos].common,
-			     sizeof(tv_stds[pos].common));
 
-	tm6000_set_audio_std(dev, tv_stds[pos].audio_default_std);
+	/* Set HV filter for PAL */
+	tm6000_set_reg(dev, TM6010_REQ07_RD5_POWERSAVE, areg_D5);
+
+	for (k = 0; k < 0x90; k++) {
+		if (tm_regs[k] != 0xffff) {
+			rc = tm6000_set_reg(dev, 0x07, k, (uint8_t)tm_regs[k]);
+			if (rc < 0) {
+				printk(KERN_ERR "Error %i while setting "
+			       "req %d, reg %d to value %d\n",
+			       rc, 0x07, k, (uint8_t)tm_regs[k]);
+				return rc;
+			}
+		}
+	}
 
-	return rc;
+	/* TCD2 SW Reset ON */
+	tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
+	/* TCD2 SW Reset OFF */
+	tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
+
+	return 0;
 }
 
 int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
 {
-	int i, rc = 0;
+	int rc = 0;
 
 	dev->norm = *norm;
-	tm6000_get_std_res(dev);
 
-	switch (dev->input) {
-	case TM6000_INPUT_TV:
-		for (i = 0; i < ARRAY_SIZE(tv_stds); i++) {
-			if (*norm & tv_stds[i].id) {
-				rc = tm6000_set_tv(dev, i);
-				goto ret;
-			}
-		}
-		return -EINVAL;
-	case TM6000_INPUT_SVIDEO:
-		for (i = 0; i < ARRAY_SIZE(svideo_stds); i++) {
-			if (*norm & svideo_stds[i].id) {
-				rc = tm6000_load_std(dev, svideo_stds[i].common,
-						     sizeof(svideo_stds[i].
-							    common));
-				goto ret;
-			}
-		}
-		return -EINVAL;
-	case TM6000_INPUT_COMPOSITE:
-		for (i = 0; i < ARRAY_SIZE(composite_stds); i++) {
-			if (*norm & composite_stds[i].id) {
-				rc = tm6000_load_std(dev,
-						     composite_stds[i].common,
-						     sizeof(composite_stds[i].
-							    common));
-				tm6000_set_audio_std(dev, composite_stds[i].audio_default_std);
-				goto ret;
-			}
-		}
-		return -EINVAL;
-	}
+	rc = tm6000_config_video_input(dev);
+	if (rc < 0)
+		return rc;
 
-ret:
+	rc = tm6000_config_video_std(dev, norm);
 	if (rc < 0)
 		return rc;
 
-	msleep(40);
+	if (dev->radio) {
+		tm6000_set_audio_std(dev, FM_RADIO);
+		return 0;
+	}
 
+	switch (*norm) {
+	case V4L2_STD_PAL_M:
+	case V4L2_STD_PAL_N:
+	case V4L2_STD_PAL_Nc:
+	case V4L2_STD_NTSC:
+		tm6000_set_audio_std(dev, BTSC);
+		break;
+	case V4L2_STD_PAL:
+		tm6000_set_audio_std(dev, BG_A2);
+		break;
+	case V4L2_STD_SECAM_B:
+	case V4L2_STD_SECAM_G:
+		tm6000_set_audio_std(dev, BG_NICAM);
+		break;
+	case V4L2_STD_SECAM_DK:
+		tm6000_set_audio_std(dev, DK_NICAM);
+		break;
+	}
 
 	return 0;
 }
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index c80a316..ef31da1 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1510,6 +1510,7 @@ static int tm6000_open(struct file *file)
 			V4L2_FIELD_INTERLACED,
 			sizeof(struct tm6000_buffer), fh, &dev->lock);
 
+	tm6000_init_demdec(dev);
 	if (fh->radio) {
 		dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n");
 		tm6000_set_audio_input(dev, dev->aradio);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 99ae50e..2db8f2d 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -228,6 +228,7 @@ struct tm6000_core {
 	atomic_t			stream_started;  /* stream should be running if true */
 	enum tm6000_inaudio		avideo;
 	enum tm6000_inaudio		aradio;
+	enum tm6000_inaudio		acomposite;
 
 	struct tm6000_IR		*ir;
 
@@ -305,6 +306,8 @@ int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate);
 int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp);
 int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute);
 void tm6000_set_volume(struct tm6000_core *dev, int vol);
+void tm6000_init_demdec(struct tm6000_core *dev);
+void tm6000_reset_demdec(struct tm6000_core *dev);
 
 int tm6000_v4l2_register(struct tm6000_core *dev);
 int tm6000_v4l2_unregister(struct tm6000_core *dev);

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>


With my best regards, Dmitry.

[-- Attachment #2: tm6000_stds_rework.diff --]
[-- Type: text/x-patch, Size: 63727 bytes --]

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 146c7e8..9cf1abd 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -68,6 +68,7 @@ struct tm6000_board {
 	struct tm6000_capabilities caps;
 	enum            tm6000_inaudio aradio;
 	enum            tm6000_inaudio avideo;
+	enum            tm6000_inaudio acomposite;
 
 	enum		tm6000_devtype type;	/* variant of the chipset */
 	int             tuner_type;     /* type of the tuner */
@@ -234,6 +235,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 1,
@@ -256,6 +258,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 0,
@@ -330,6 +333,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 1,
@@ -352,6 +356,7 @@ struct tm6000_board tm6000_boards[] = {
 		.type         = TM6010,
 		.avideo       = TM6000_AIP_SIF1,
 		.aradio       = TM6000_AIP_LINE1,
+		.acomposite   = TM6000_AIP_LINE2,
 		.caps = {
 			.has_tuner      = 1,
 			.has_dvb        = 0,
@@ -753,6 +758,7 @@ static int tm6000_init_dev(struct tm6000_core *dev)
 
 	dev->avideo = tm6000_boards[dev->model].avideo;
 	dev->aradio = tm6000_boards[dev->model].aradio;
+	dev->acomposite = tm6000_boards[dev->model].acomposite;
 	/* initialize hardware */
 	rc = tm6000_init(dev);
 	if (rc < 0)
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 778e534..ec7f613 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -201,68 +201,6 @@ void tm6000_set_fourcc_format(struct tm6000_core *dev)
 	}
 }
 
-static void tm6000_set_vbi(struct tm6000_core *dev)
-{
-	/*
-	 * FIXME:
-	 * VBI lines and start/end are different between 60Hz and 50Hz
-	 * So, it is very likely that we need to change the config to
-	 * something that takes it into account, doing something different
-	 * if (dev->norm & V4L2_STD_525_60)
-	 */
-
-	if (dev->dev_type == TM6010) {
-		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ07_R41_TELETEXT_VBI_CODE1, 0x27);
-		tm6000_set_reg(dev, TM6010_REQ07_R42_VBI_DATA_HIGH_LEVEL, 0x55);
-		tm6000_set_reg(dev, TM6010_REQ07_R43_VBI_DATA_TYPE_LINE7, 0x66);
-		tm6000_set_reg(dev, TM6010_REQ07_R44_VBI_DATA_TYPE_LINE8, 0x66);
-		tm6000_set_reg(dev, TM6010_REQ07_R45_VBI_DATA_TYPE_LINE9, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R46_VBI_DATA_TYPE_LINE10, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R47_VBI_DATA_TYPE_LINE11, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R48_VBI_DATA_TYPE_LINE12, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R49_VBI_DATA_TYPE_LINE13, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4A_VBI_DATA_TYPE_LINE14, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4B_VBI_DATA_TYPE_LINE15, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4C_VBI_DATA_TYPE_LINE16, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4D_VBI_DATA_TYPE_LINE17, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4E_VBI_DATA_TYPE_LINE18, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R4F_VBI_DATA_TYPE_LINE19, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R50_VBI_DATA_TYPE_LINE20, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R51_VBI_DATA_TYPE_LINE21, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R52_VBI_DATA_TYPE_LINE22, 0x66);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R53_VBI_DATA_TYPE_LINE23, 0x00);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R54_VBI_DATA_TYPE_RLINES, 0x00);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R55_VBI_LOOP_FILTER_GAIN, 0x01);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R56_VBI_LOOP_FILTER_I_GAIN, 0x00);
-		tm6000_set_reg(dev,
-			TM6010_REQ07_R57_VBI_LOOP_FILTER_P_GAIN, 0x02);
-		tm6000_set_reg(dev, TM6010_REQ07_R58_VBI_CAPTION_DTO1, 0x35);
-		tm6000_set_reg(dev, TM6010_REQ07_R59_VBI_CAPTION_DTO0, 0xa0);
-		tm6000_set_reg(dev, TM6010_REQ07_R5A_VBI_TELETEXT_DTO1, 0x11);
-		tm6000_set_reg(dev, TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c);
-		tm6000_set_reg(dev, TM6010_REQ07_R40_TELETEXT_VBI_CODE0, 0x01);
-		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
-	}
-}
-
 int tm6000_init_analog_mode(struct tm6000_core *dev)
 {
 	struct v4l2_frequency f;
@@ -275,7 +213,6 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 		tm6000_set_reg_mask(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE,
 							0x00, 0x40);
 		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
-
 	} else {
 		/* Enables soft reset */
 		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
@@ -328,7 +265,6 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
 
 	msleep(100);
 	tm6000_set_standard(dev, &dev->norm);
-	tm6000_set_vbi(dev);
 	tm6000_set_audio_bitrate(dev, 48000);
 
 	/* switch dvb led off */
@@ -504,12 +440,13 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x07 },
 	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
 	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00 },
-	{ TM6010_REQ07_R05_NOISE_THRESHOLD, 0x64 },
+	{ TM6010_REQ07_R05_NOISE_THRESHOLD, 0x50 },
 	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x01 },
 	{ TM6010_REQ07_R08_LUMA_CONTRAST_ADJ, 0x82 },
 	{ TM6010_REQ07_R09_LUMA_BRIGHTNESS_ADJ, 0x36 },
 	{ TM6010_REQ07_R0A_CHROMA_SATURATION_ADJ, 0x50 },
 	{ TM6010_REQ07_R0C_CHROMA_AGC_CONTROL, 0x6a },
+	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x17},
 	{ TM6010_REQ07_R11_AGC_PEAK_CONTROL, 0xc9 },
 	{ TM6010_REQ07_R12_AGC_GATE_STARTH, 0x07 },
 	{ TM6010_REQ07_R13_AGC_GATE_STARTL, 0x3b },
@@ -524,8 +461,8 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
 	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
 	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
-	{ TM6010_REQ07_R20_HSYNC_RISING_EDGE_TIME, 0x3c },
-	{ TM6010_REQ07_R21_HSYNC_PHASE_OFFSET, 0x3c },
+	{ TM6010_REQ07_R20_HSYNC_RISING_EDGE_TIME, 0x3e },
+	{ TM6010_REQ07_R21_HSYNC_PHASE_OFFSET, 0x3e },
 	{ TM6010_REQ07_R2D_CHROMA_BURST_END, 0x48 },
 	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
 	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
@@ -544,12 +481,18 @@ struct reg_init tm6010_init_tab[] = {
 	{ TM6010_REQ07_R57_VBI_LOOP_FILTER_P_GAIN, 0x02 },
 	{ TM6010_REQ07_R58_VBI_CAPTION_DTO1, 0x35 },
 	{ TM6010_REQ07_R59_VBI_CAPTION_DTO0, 0xa0 },
+	{ TM6010_REQ07_R5A_VBI_TELETEXT_DTO1, 0x11},
+	{ TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c},
+	{ TM6010_REQ07_R60_TELETEXT_FRAME_START, 0x52},
+	{ TM6010_REQ07_R68_VBI_TELETEXT_START, 0x32},
 	{ TM6010_REQ07_R80_COMB_FILTER_TRESHOLD, 0x15 },
 	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
+	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xa9},
 	{ TM6010_REQ07_RC1_TRESHOLD, 0xd0 },
 	{ TM6010_REQ07_RC3_HSTART1, 0x88 },
 	{ TM6010_REQ07_R3F_RESET, 0x00 },
 
+	{ TM6010_REQ07_R3F_RESET, 0x00 },
 	{ TM6010_REQ05_R18_IMASK7, 0x00 },
 
 	{ TM6010_REQ07_RD8_IR_LEADER1, 0xaa },
@@ -615,6 +558,38 @@ int tm6000_init(struct tm6000_core *dev)
 	return rc;
 }
 
+void tm6000_init_demdec(struct tm6000_core *dev)
+{
+	/* Set GCD2 to autogain */
+	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+	/* Reduce SIF amplitude */
+	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
+	/* Set autodetect threshold */
+	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+	/* Set auto-dematrix threshold */
+	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
+	/* Set NICAM error limits max */
+	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
+	/* Set NICAM error limits min */
+	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
+	/* Set gain max +6dB */
+	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
+	/* Set gain min -6dB */
+	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
+	/* Enable ADC (always use) */
+	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+}
+EXPORT_SYMBOL_GPL(tm6000_init_demdec);
+
+void tm6000_reset_demdec(struct tm6000_core *dev)
+{
+	/* Set DemDec to IDLE */
+	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+	/* Set DemDec to Restart */
+	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+}
+EXPORT_SYMBOL_GPL(tm6000_reset_demdec);
+
 int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate)
 {
 	int val = 0;
@@ -662,11 +637,13 @@ int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
 	if (dev->dev_type == TM6010) {
 		/* Audio crossbar setting, default SIF1 */
 		u8 areg_f0 = 0x03;
+		u8 areg_07 = 0x10;
 
 		switch (ainp) {
 		case TM6000_AIP_SIF1:
 		case TM6000_AIP_SIF2:
 			areg_f0 = 0x03;
+			areg_07 = 0x30;
 			break;
 		case TM6000_AIP_LINE1:
 			areg_f0 = 0x00;
@@ -681,6 +658,10 @@ int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
 		/* Set audio input crossbar */
 		tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
 							areg_f0, 0x0f);
+
+		/* Mux overflow workaround */
+		tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
+							areg_07, 0xf0);
 	} else {
 		/* Audio setting, default LINE1 */
 		u8 areg_eb = 0x00;
@@ -802,8 +783,10 @@ void tm6000_set_volume(struct tm6000_core *dev, int vol)
 	if (dev->radio) {
 		ainp = dev->aradio;
 		vol += 8; /* Offset to 0 dB */
-	} else
-		ainp = dev->avideo;
+	} else if (dev->input != TM6000_INPUT_COMPOSITE)
+			ainp = dev->avideo;
+		else
+			ainp = dev->acomposite;
 
 	switch (ainp) {
 	case TM6000_AIP_SIF1:
diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
index da3e51b..fdb0280 100644
--- a/drivers/staging/tm6000/tm6000-stds.c
+++ b/drivers/staging/tm6000/tm6000-stds.c
@@ -22,12 +22,6 @@
 #include "tm6000.h"
 #include "tm6000-regs.h"
 
-struct tm6000_reg_settings {
-	unsigned char req;
-	unsigned char reg;
-	unsigned char value;
-};
-
 enum tm6000_audio_std {
 	BG_NICAM,
 	BTSC,
@@ -40,909 +34,6 @@ enum tm6000_audio_std {
 	L_NICAM,
 };
 
-struct tm6000_std_tv_settings {
-	v4l2_std_id id;
-	enum tm6000_audio_std audio_default_std;
-
-	struct tm6000_reg_settings sif[12];
-	struct tm6000_reg_settings nosif[12];
-	struct tm6000_reg_settings common[26];
-};
-
-struct tm6000_std_settings {
-	v4l2_std_id id;
-	enum tm6000_audio_std audio_default_std;
-	struct tm6000_reg_settings common[37];
-};
-
-static struct tm6000_std_tv_settings tv_stds[] = {
-	{
-		.id = V4L2_STD_PAL_M,
-		.audio_default_std = BTSC,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL_Nc,
-		.audio_default_std = BTSC,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL,
-		.audio_default_std = BG_A2,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0}
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
-		.audio_default_std = BG_NICAM,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_DK,
-		.audio_default_std = DK_NICAM,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_NTSC,
-		.audio_default_std = BTSC,
-		.sif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
-			{0, 0, 0},
-		},
-		.nosif = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-			{0, 0, 0},
-		},
-		.common = {
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-
-			{TM6010_REQ07_R3F_RESET, 0x00},
-
-			{0, 0, 0},
-		},
-	},
-};
-
-static struct tm6000_std_settings composite_stds[] = {
-	{
-		.id = V4L2_STD_PAL_M,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	 }, {
-		.id = V4L2_STD_PAL_Nc,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL,
-		.audio_default_std = BG_A2,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	 }, {
-		.id = V4L2_STD_SECAM,
-		.audio_default_std = BG_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_DK,
-		.audio_default_std = DK_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_NTSC,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	},
-};
-
-static struct tm6000_std_settings svideo_stds[] = {
-	{
-		.id = V4L2_STD_PAL_M,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x05},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL_Nc,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x37},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_PAL,
-		.audio_default_std = BG_A2,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x33},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	 }, {
-		.id = V4L2_STD_SECAM,
-		.audio_default_std = BG_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_SECAM_DK,
-		.audio_default_std = DK_NICAM,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
-
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	}, {
-		.id = V4L2_STD_NTSC,
-		.audio_default_std = BTSC,
-		.common = {
-			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
-			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
-			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
-			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
-			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
-			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
-			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
-			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
-			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
-			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
-			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
-
-			{TM6010_REQ07_R3F_RESET, 0x01},
-			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x01},
-			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
-			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
-			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
-			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
-			{TM6010_REQ07_R17_HLOOP_MAXSTATE, 0x8b},
-			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
-			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
-			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
-			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
-			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
-			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
-			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
-			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
-			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
-			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
-			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
-			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
-			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
-			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
-			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
-
-			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
-			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
-			{TM6010_REQ07_R3F_RESET, 0x00},
-			{0, 0, 0},
-		},
-	},
-};
-
-
 static int tm6000_set_audio_std(struct tm6000_core *dev,
 				enum tm6000_audio_std std)
 {
@@ -952,22 +43,6 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 	uint8_t mono_flag = 0;  /* No mono */
 	uint8_t nicam_flag = 0; /* No NICAM */
 
-	if (dev->radio) {
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
-		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
-		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
-		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
-		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
-		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
-		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
-		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
-		return 0;
-	}
-
 	switch (std) {
 #if 0
 	case DK_MONO:
@@ -1012,6 +87,21 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 		areg_05 = 0x0a;
 		nicam_flag = 1;
 		break;
+	case FM_RADIO:
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
+		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
+		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
+		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
+		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
+		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
+		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
+		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
+		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
+		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
+		return 0;
+		break;
 	default:
 		/* do nothink */
 		break;
@@ -1036,39 +126,10 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
 
 	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
 	tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
-	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
 	tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, areg_05);
 	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, areg_06);
-	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
 	tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
-	tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
-	tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
-	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
-	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
-	tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
-	tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
-	tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
-	tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
-	tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
-	tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
-	tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
-	tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
-	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
-	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
-	tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
-	tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
-	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
-	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
-	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
-	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
 	tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
-	tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
-	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
-	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
 	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
 
 	return 0;
@@ -1085,106 +146,419 @@ void tm6000_get_std_res(struct tm6000_core *dev)
 	dev->width = 720;
 }
 
-static int tm6000_load_std(struct tm6000_core *dev,
-			   struct tm6000_reg_settings *set, int max_size)
+int tm6000_config_video_input(struct tm6000_core *dev)
 {
-	int i, rc;
-
-	/* Load board's initialization table */
-	for (i = 0; max_size; i++) {
-		if (!set[i].req)
-			return 0;
-
-		if ((dev->dev_type != TM6010) &&
-		    (set[i].req == REQ_08_SET_GET_AVREG_BIT))
-				continue;
-
-		rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value);
-		if (rc < 0) {
-			printk(KERN_ERR "Error %i while setting "
-			       "req %d, reg %d to value %d\n",
-			       rc, set[i].req, set[i].reg, set[i].value);
-			return rc;
-		}
+	switch (dev->input) {
+	case TM6000_INPUT_TV:
+		/* Enable ADC2 (without clamp?) */
+		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08);
+		/* Power Up CLAMP, LPF BW = SIF mode */
+		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2);
+		/* Set ADC1 input = CVBS1 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8);
+		/* Set ADC2 input = SIF1 or SIF2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL,
+				(dev->avideo == TM6000_AIP_SIF1) ? 0xf7 : 0xf3);
+		/* Clamping level control in ADC2 = SIF signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf6);
+		/* SIF gain control enable signal = SIF signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0);
+		/* GAIN selection = Y and SIF */
+		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe8);
+		break;
+	case TM6000_INPUT_SVIDEO:
+		/* Enable ADC2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00);
+		/* Power Up CLAMP, LPF BW <> SIF mode */
+		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0);
+		/* Set ADC1 input = Y */
+		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc);
+		/* Set ADC2 input = C */
+		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8);
+		/* Clamping level control in ADC2 = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
+		/* SIF gain control enable signal = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
+		/* GAIN selection = Y and C */
+		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
+		break;
+	case TM6000_INPUT_COMPOSITE:
+		/* Set ADC1 input = CVBS2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4);
+		/* Power Up CLAMP, LPF BW <> SIF mode */
+		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0);
+		/* Set ADC2 input = none */
+		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xfc);
+		/* Disable ADC2 */
+		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f);
+		/* Clamping level control in ADC2 = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
+		/* SIF gain control enable signal = C signal */
+		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
+		/* GAIN selection = Y and C */
+		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
+		/* Set audio input */
+		tm6000_set_audio_input(dev, dev->acomposite);
+		tm6000_set_volume(dev, dev->ctl_volume);
+		break;
+	default:
+		printk(KERN_ERR "Error video input source - %d\n", dev->input);
+		return -EINVAL;
+		break;
 	}
 
 	return 0;
 }
 
-static int tm6000_set_tv(struct tm6000_core *dev, int pos)
+int tm6000_config_video_std(struct tm6000_core *dev, v4l2_std_id *norm)
 {
-	int rc;
+	int rc = 0;
+	uint8_t k;
+	uint8_t areg_D5 = 0x4f;
+	uint16_t tm_regs[0x90];
+	bool pal_fl = true;
+	bool f50hz_fl = true;
+
+	memset(tm_regs, 0xffff, sizeof(tm_regs));
+
+	dev->norm = *norm;
+	tm6000_get_std_res(dev);
 
-	/* FIXME: This code is for tm6010 - not tested yet - doesn't work with
-	   tm5600
-	 */
+	/* Chroma AGC target */
+	tm_regs[0x0c] = 0x6a;
+	/* HSYNC rising-edge occurrence time */
+	tm_regs[0x20] = 0x3e;
+	/* backporch start/end */
+	tm_regs[0x28] = 0x22;
+	tm_regs[0x29] = 0x4e;
+	/* Chroma burst start/end */
+	tm_regs[0x2c] = 0x2c;
+	tm_regs[0x2d] = 0x48;
+	/* VSYNC H lockout start/end */
+	tm_regs[0x32] = 0x74;
+	tm_regs[0x33] = 0x0c;
+	/* VSYNC AGC lockout start/end */
+	tm_regs[0x34] = 0x74;
+	tm_regs[0x35] = 0x1c;
+	/* Comb filter config (PAL off) */
+	tm_regs[0x82] = 0x42;
+
+	switch (*norm) {
+	case V4L2_STD_SECAM:
+	case V4L2_STD_SECAM_B:
+	case V4L2_STD_SECAM_G:
+	case V4L2_STD_SECAM_DK:
+		/* SECAM */
+		tm_regs[0x00] = 0x08;
+		tm_regs[0x01] = 0x02;
+		/* Full 2-D adaptive comb */
+		tm_regs[0x03] = 0x00;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 17.144 */
+		tm_regs[0x18] = 0x24;
+		tm_regs[0x19] = 0x92;
+		tm_regs[0x1a] = 0xe8;
+		tm_regs[0x1b] = 0xed;
+		/* backporch start/end */
+		tm_regs[0x28] = 0x42;
+		tm_regs[0x29] = 0x62;
+		/* Chroma burst start/end */
+		tm_regs[0x2c] = 0x44;
+		tm_regs[0x2d] = 0x60;
+		/* VSYNC H lockout start/end */
+		tm_regs[0x32] = 0x74;
+		tm_regs[0x33] = 0x2c;
+		/* VSYNC AGC lockout start/end */
+		tm_regs[0x34] = 0x74;
+		tm_regs[0x35] = 0x18;
+		pal_fl = false;
+		break;
+	case V4L2_STD_PAL:
+		/* PAL */
+		tm_regs[0x00] = 0x02;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xD5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		break;
+	case V4L2_STD_PAL_N:
+	case V4L2_STD_PAL_M:
+		/* PAL MN */
+		tm_regs[0x00] = 0x04;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 221 */
+		tm_regs[0x04] = 0xdd;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xD5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		break;
+	case V4L2_STD_PAL_Nc:
+		/* PAL Nc */
+		tm_regs[0x00] = 0x06;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 14.328225 */
+		tm_regs[0x18] = 0x1e;
+		tm_regs[0x19] = 0x91;
+		tm_regs[0x1a] = 0x1f;
+		tm_regs[0x1b] = 0x0c;
+		break;
+	case V4L2_STD_PAL_60:
+		/* PAL */
+		tm_regs[0x00] = 0x02;
+		tm_regs[0x01] = 0x02;
+		/* PAL fix (basic luma notch comb filter) */
+		tm_regs[0x03] = 0x03;
+		/* HAGC = 220 */
+		tm_regs[0x04] = 0xdc;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xd5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		/* HSYNC rising-edge occurrence time */
+		tm_regs[0x20] = 0x4c;
+		f50hz_fl = false;
+		break;
+	case V4L2_STD_NTSC_M:
+	case V4L2_STD_NTSC_M_JP:
+	case V4L2_STD_NTSC_M_KR:
+		/* NTSC */
+		tm_regs[0x00] = 0x00;
+		/* Ped = 1 */
+		tm_regs[0x01] = 0x03;
+		/* Full 2-D adaptive comb */
+		tm_regs[0x03] = 0x00;
+		/* HAGC = 221 */
+		tm_regs[0x04] = 0xdd;
+		/* Chroma AGC target */
+		tm_regs[0x0c] = 0x8a;
+		/* DTO = 14.31818182 */
+		tm_regs[0x18] = 0x1e;
+		tm_regs[0x19] = 0x8b;
+		tm_regs[0x1a] = 0xa2;
+		tm_regs[0x1b] = 0xe9;
+		tm_regs[0x33] = 0x1c;
+		f50hz_fl = false;
+		pal_fl = false;
+		if (*norm == V4L2_STD_NTSC_M_JP) {
+			/* Ped = 0*/
+			tm_regs[0x01] = 0x02;
+			/* HAGC  205 */
+			tm_regs[0x04] = 0xcd;
+		}
+		break;
+	case V4L2_STD_NTSC_443:
+		/* NTSC */
+		tm_regs[0x00] = 0x00;
+		/* Ped = 1 */
+		tm_regs[0x01] = 0x03;
+		/* Full 2-D adaptive comb */
+		tm_regs[0x03] = 0x00;
+		/* HAGC = 221 */
+		tm_regs[0x04] = 0xdd;
+		/* Chroma AGC target */
+		tm_regs[0x0c] = 0x8a;
+		/* DTO = 17.734475 */
+		tm_regs[0x18] = 0x25;
+		tm_regs[0x19] = 0xd5;
+		tm_regs[0x1a] = 0x63;
+		tm_regs[0x1b] = 0x50;
+		tm_regs[0x33] = 0x1c;
+		pal_fl = false;
+		break;
+	}
 
-	/* FIXME: This is tuner-dependent */
-	int nosif = 0;
+	if (pal_fl) {
+		/* UV_FLT_EN = 1 */
+		areg_D5 |= 0x10;
+		/* comb_wide_band = 1 */
+		tm_regs[0x82] |= 0x10;
+	}
 
-	if (nosif) {
-		rc = tm6000_load_std(dev, tv_stds[pos].nosif,
-				     sizeof(tv_stds[pos].nosif));
+	if (f50hz_fl) {
+		/* vline_625 = 1, hpixel = 864 */
+		tm_regs[0x00] |= 0x30;
+		/* hactive_start = 138 */
+		tm_regs[0x2e] = 0x8a;
+		/* vactive_start = 42 */
+		tm_regs[0x30] = 0x2a;
+		/* vactive_hight = 171 */
+		tm_regs[0x31] = 0xc1;
+		/* VBI FRAME CODE */
+		tm_regs[0x41] = 0x27;
+		/* data high level */
+		tm_regs[0x42] = 0x5e;
+		/* vbil7 */
+		tm_regs[0x43] = 0x66;
+		/* vbil8 */
+		tm_regs[0x44] = 0x66;
+		/* vbil9 */
+		tm_regs[0x45] = 0x66;
+		/* vbil10 */
+		tm_regs[0x46] = 0x66;
+		/* vbil11 */
+		tm_regs[0x47] = 0x66;
+		/* vbil12 */
+		tm_regs[0x48] = 0x66;
+		/* vbil13 */
+		tm_regs[0x49] = 0x66;
+		/* vbil14 */
+		tm_regs[0x4a] = 0x66;
+		/* vbil15 */
+		tm_regs[0x4b] = 0x66;
+		/* vbil16 */
+		tm_regs[0x4c] = 0x66;
+		/* vbil17 */
+		tm_regs[0x4d] = 0x66;
+		/* vbil18 */
+		tm_regs[0x4e] = 0x66;
+		/* vbil19 */
+		tm_regs[0x4f] = 0x66;
+		/* vbil20 */
+		tm_regs[0x50] = 0x66;
+		/* vbil21 */
+		tm_regs[0x51] = 0x66;
+		/* vbil22 */
+		tm_regs[0x52] = 0x66;
+		/* vbil23 = WSS */
+		tm_regs[0x53] = 0x00;
+		/* vbil24 */
+		tm_regs[0x54] = 0x00;
 	} else {
-		rc = tm6000_load_std(dev, tv_stds[pos].sif,
-				     sizeof(tv_stds[pos].sif));
+		/* vline_625 = 0, hpixel = 858 */
+		tm_regs[0x00] &= 0xcf;
+		/* hactive_start = 134 */
+		tm_regs[0x2e] = 0x86;
+		/* vactive_start = 34 */
+		tm_regs[0x30] = 0x22;
+		/* vactive_hight = 121 */
+		tm_regs[0x31] = 0x61;
+		/* VBI FRAME CODE */
+		tm_regs[0x41] = 0xe7;
+		/* data high level */
+		tm_regs[0x42] = 0x58;
+		/* vbil7 */
+		tm_regs[0x43] = 0x00;
+		/* vbil8 */
+		tm_regs[0x44] = 0x00;
+		/* vbil9 */
+		tm_regs[0x45] = 0x00;
+		/* vbil10 */
+		tm_regs[0x46] = 0x00;
+		/* vbil11 */
+		tm_regs[0x47] = 0x00;
+		/* vbil12 */
+		tm_regs[0x48] = 0x00;
+		/* vbil13 */
+		tm_regs[0x49] = 0x00;
+		/* vbil14 */
+		tm_regs[0x4a] = 0x00;
+		/* vbil15 */
+		tm_regs[0x4b] = 0x00;
+		/* vbil16 */
+		tm_regs[0x4c] = 0x00;
+		/* vbil17 */
+		tm_regs[0x4d] = 0x00;
+		/* vbil18 */
+		tm_regs[0x4e] = 0x00;
+		/* vbil19 */
+		tm_regs[0x4f] = 0x00;
+		/* vbil20 */
+		tm_regs[0x50] = 0x00;
+		/* vbil21 = CC */
+		tm_regs[0x51] = 0x11;
+		/* vbil22 */
+		tm_regs[0x52] = 0x00;
+		/* vbil23 */
+		tm_regs[0x53] = 0x00;
+		/* vbil24 */
+		tm_regs[0x54] = 0x00;
+	}
+
+	if (dev->input == TM6000_INPUT_SVIDEO) {
+		/* Y_C = ON */
+		tm_regs[0x00] |= 0x01;
+		/* chroma_bw_lo = wide */
+		tm_regs[0x01] |= 0x04;
+		/* basic luma notch filter mode */
+		tm_regs[0x03] = 0x03;
 	}
-	if (rc < 0)
-		return rc;
-	rc = tm6000_load_std(dev, tv_stds[pos].common,
-			     sizeof(tv_stds[pos].common));
 
-	tm6000_set_audio_std(dev, tv_stds[pos].audio_default_std);
+	/* Set HV filter for PAL */
+	tm6000_set_reg(dev, TM6010_REQ07_RD5_POWERSAVE, areg_D5);
+
+	for (k = 0; k < 0x90; k++) {
+		if (tm_regs[k] != 0xffff) {
+			rc = tm6000_set_reg(dev, 0x07, k, (uint8_t)tm_regs[k]);
+			if (rc < 0) {
+				printk(KERN_ERR "Error %i while setting "
+			       "req %d, reg %d to value %d\n",
+			       rc, 0x07, k, (uint8_t)tm_regs[k]);
+				return rc;
+			}
+		}
+	}
 
-	return rc;
+	/* TCD2 SW Reset ON */
+	tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
+	/* TCD2 SW Reset OFF */
+	tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
+
+	return 0;
 }
 
 int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
 {
-	int i, rc = 0;
+	int rc = 0;
 
 	dev->norm = *norm;
-	tm6000_get_std_res(dev);
 
-	switch (dev->input) {
-	case TM6000_INPUT_TV:
-		for (i = 0; i < ARRAY_SIZE(tv_stds); i++) {
-			if (*norm & tv_stds[i].id) {
-				rc = tm6000_set_tv(dev, i);
-				goto ret;
-			}
-		}
-		return -EINVAL;
-	case TM6000_INPUT_SVIDEO:
-		for (i = 0; i < ARRAY_SIZE(svideo_stds); i++) {
-			if (*norm & svideo_stds[i].id) {
-				rc = tm6000_load_std(dev, svideo_stds[i].common,
-						     sizeof(svideo_stds[i].
-							    common));
-				goto ret;
-			}
-		}
-		return -EINVAL;
-	case TM6000_INPUT_COMPOSITE:
-		for (i = 0; i < ARRAY_SIZE(composite_stds); i++) {
-			if (*norm & composite_stds[i].id) {
-				rc = tm6000_load_std(dev,
-						     composite_stds[i].common,
-						     sizeof(composite_stds[i].
-							    common));
-				tm6000_set_audio_std(dev, composite_stds[i].audio_default_std);
-				goto ret;
-			}
-		}
-		return -EINVAL;
-	}
+	rc = tm6000_config_video_input(dev);
+	if (rc < 0)
+		return rc;
 
-ret:
+	rc = tm6000_config_video_std(dev, norm);
 	if (rc < 0)
 		return rc;
 
-	msleep(40);
+	if (dev->radio) {
+		tm6000_set_audio_std(dev, FM_RADIO);
+		return 0;
+	}
 
+	switch (*norm) {
+	case V4L2_STD_PAL_M:
+	case V4L2_STD_PAL_N:
+	case V4L2_STD_PAL_Nc:
+	case V4L2_STD_NTSC:
+		tm6000_set_audio_std(dev, BTSC);
+		break;
+	case V4L2_STD_PAL:
+		tm6000_set_audio_std(dev, BG_A2);
+		break;
+	case V4L2_STD_SECAM_B:
+	case V4L2_STD_SECAM_G:
+		tm6000_set_audio_std(dev, BG_NICAM);
+		break;
+	case V4L2_STD_SECAM_DK:
+		tm6000_set_audio_std(dev, DK_NICAM);
+		break;
+	}
 
 	return 0;
 }
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index c80a316..ef31da1 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1510,6 +1510,7 @@ static int tm6000_open(struct file *file)
 			V4L2_FIELD_INTERLACED,
 			sizeof(struct tm6000_buffer), fh, &dev->lock);
 
+	tm6000_init_demdec(dev);
 	if (fh->radio) {
 		dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n");
 		tm6000_set_audio_input(dev, dev->aradio);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 99ae50e..2db8f2d 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -228,6 +228,7 @@ struct tm6000_core {
 	atomic_t			stream_started;  /* stream should be running if true */
 	enum tm6000_inaudio		avideo;
 	enum tm6000_inaudio		aradio;
+	enum tm6000_inaudio		acomposite;
 
 	struct tm6000_IR		*ir;
 
@@ -305,6 +306,8 @@ int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate);
 int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp);
 int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute);
 void tm6000_set_volume(struct tm6000_core *dev, int vol);
+void tm6000_init_demdec(struct tm6000_core *dev);
+void tm6000_reset_demdec(struct tm6000_core *dev);
 
 int tm6000_v4l2_register(struct tm6000_core *dev);
 int tm6000_v4l2_unregister(struct tm6000_core *dev);

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH v1] tm6000: rework standards
  2011-04-19  5:29                                                             ` [PATCH v1] tm6000: rework standards Dmitri Belimov
@ 2011-04-19  6:42                                                               ` Stefan Ringel
  2011-05-04 16:18                                                                 ` Stefan Ringel
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Ringel @ 2011-04-19  6:42 UTC (permalink / raw)
  To: Dmitri Belimov; +Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Am 19.04.2011 07:29, schrieb Dmitri Belimov:
> Hi
>
> Add audio configuration for composite input.
> Rework init process of the tm6010.
> Rework configure video standards.
>
> diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
> index 146c7e8..9cf1abd 100644
> --- a/drivers/staging/tm6000/tm6000-cards.c
> +++ b/drivers/staging/tm6000/tm6000-cards.c
> @@ -68,6 +68,7 @@ struct tm6000_board {
>   	struct tm6000_capabilities caps;
>   	enum            tm6000_inaudio aradio;
>   	enum            tm6000_inaudio avideo;
> +	enum            tm6000_inaudio acomposite;
>
>   	enum		tm6000_devtype type;	/* variant of the chipset */
>   	int             tuner_type;     /* type of the tuner */
> @@ -234,6 +235,7 @@ struct tm6000_board tm6000_boards[] = {
>   		.type         = TM6010,
>   		.avideo       = TM6000_AIP_SIF1,
>   		.aradio       = TM6000_AIP_LINE1,
> +		.acomposite   = TM6000_AIP_LINE2,
>   		.caps = {
>   			.has_tuner      = 1,
>   			.has_dvb        = 1,
> @@ -256,6 +258,7 @@ struct tm6000_board tm6000_boards[] = {
>   		.type         = TM6010,
>   		.avideo       = TM6000_AIP_SIF1,
>   		.aradio       = TM6000_AIP_LINE1,
> +		.acomposite   = TM6000_AIP_LINE2,
>   		.caps = {
>   			.has_tuner      = 1,
>   			.has_dvb        = 0,
> @@ -330,6 +333,7 @@ struct tm6000_board tm6000_boards[] = {
>   		.type         = TM6010,
>   		.avideo       = TM6000_AIP_SIF1,
>   		.aradio       = TM6000_AIP_LINE1,
> +		.acomposite   = TM6000_AIP_LINE2,
>   		.caps = {
>   			.has_tuner      = 1,
>   			.has_dvb        = 1,
> @@ -352,6 +356,7 @@ struct tm6000_board tm6000_boards[] = {
>   		.type         = TM6010,
>   		.avideo       = TM6000_AIP_SIF1,
>   		.aradio       = TM6000_AIP_LINE1,
> +		.acomposite   = TM6000_AIP_LINE2,
>   		.caps = {
>   			.has_tuner      = 1,
>   			.has_dvb        = 0,
> @@ -753,6 +758,7 @@ static int tm6000_init_dev(struct tm6000_core *dev)
>
>   	dev->avideo = tm6000_boards[dev->model].avideo;
>   	dev->aradio = tm6000_boards[dev->model].aradio;
> +	dev->acomposite = tm6000_boards[dev->model].acomposite;
>   	/* initialize hardware */
>   	rc = tm6000_init(dev);
>   	if (rc<  0)
> diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
> index 778e534..ec7f613 100644
> --- a/drivers/staging/tm6000/tm6000-core.c
> +++ b/drivers/staging/tm6000/tm6000-core.c
> @@ -201,68 +201,6 @@ void tm6000_set_fourcc_format(struct tm6000_core *dev)
>   	}
>   }
>
> -static void tm6000_set_vbi(struct tm6000_core *dev)
> -{
> -	/*
> -	 * FIXME:
> -	 * VBI lines and start/end are different between 60Hz and 50Hz
> -	 * So, it is very likely that we need to change the config to
> -	 * something that takes it into account, doing something different
> -	 * if (dev->norm&  V4L2_STD_525_60)
> -	 */
> -
> -	if (dev->dev_type == TM6010) {
> -		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
> -		tm6000_set_reg(dev, TM6010_REQ07_R41_TELETEXT_VBI_CODE1, 0x27);
> -		tm6000_set_reg(dev, TM6010_REQ07_R42_VBI_DATA_HIGH_LEVEL, 0x55);
> -		tm6000_set_reg(dev, TM6010_REQ07_R43_VBI_DATA_TYPE_LINE7, 0x66);
> -		tm6000_set_reg(dev, TM6010_REQ07_R44_VBI_DATA_TYPE_LINE8, 0x66);
> -		tm6000_set_reg(dev, TM6010_REQ07_R45_VBI_DATA_TYPE_LINE9, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R46_VBI_DATA_TYPE_LINE10, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R47_VBI_DATA_TYPE_LINE11, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R48_VBI_DATA_TYPE_LINE12, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R49_VBI_DATA_TYPE_LINE13, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R4A_VBI_DATA_TYPE_LINE14, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R4B_VBI_DATA_TYPE_LINE15, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R4C_VBI_DATA_TYPE_LINE16, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R4D_VBI_DATA_TYPE_LINE17, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R4E_VBI_DATA_TYPE_LINE18, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R4F_VBI_DATA_TYPE_LINE19, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R50_VBI_DATA_TYPE_LINE20, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R51_VBI_DATA_TYPE_LINE21, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R52_VBI_DATA_TYPE_LINE22, 0x66);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R53_VBI_DATA_TYPE_LINE23, 0x00);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R54_VBI_DATA_TYPE_RLINES, 0x00);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R55_VBI_LOOP_FILTER_GAIN, 0x01);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R56_VBI_LOOP_FILTER_I_GAIN, 0x00);
> -		tm6000_set_reg(dev,
> -			TM6010_REQ07_R57_VBI_LOOP_FILTER_P_GAIN, 0x02);
> -		tm6000_set_reg(dev, TM6010_REQ07_R58_VBI_CAPTION_DTO1, 0x35);
> -		tm6000_set_reg(dev, TM6010_REQ07_R59_VBI_CAPTION_DTO0, 0xa0);
> -		tm6000_set_reg(dev, TM6010_REQ07_R5A_VBI_TELETEXT_DTO1, 0x11);
> -		tm6000_set_reg(dev, TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c);
> -		tm6000_set_reg(dev, TM6010_REQ07_R40_TELETEXT_VBI_CODE0, 0x01);
> -		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
> -	}
> -}
> -
>   int tm6000_init_analog_mode(struct tm6000_core *dev)
>   {
>   	struct v4l2_frequency f;
> @@ -275,7 +213,6 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
>   		tm6000_set_reg_mask(dev, TM6010_REQ07_RC0_ACTIVE_VIDEO_SOURCE,
>   							0x00, 0x40);
>   		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
> -
>   	} else {
>   		/* Enables soft reset */
>   		tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
> @@ -328,7 +265,6 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)
>
>   	msleep(100);
>   	tm6000_set_standard(dev,&dev->norm);
> -	tm6000_set_vbi(dev);
>   	tm6000_set_audio_bitrate(dev, 48000);
>
>   	/* switch dvb led off */
> @@ -504,12 +440,13 @@ struct reg_init tm6010_init_tab[] = {
>   	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x07 },
>   	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
>   	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00 },
> -	{ TM6010_REQ07_R05_NOISE_THRESHOLD, 0x64 },
> +	{ TM6010_REQ07_R05_NOISE_THRESHOLD, 0x50 },
>   	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x01 },
>   	{ TM6010_REQ07_R08_LUMA_CONTRAST_ADJ, 0x82 },
>   	{ TM6010_REQ07_R09_LUMA_BRIGHTNESS_ADJ, 0x36 },
>   	{ TM6010_REQ07_R0A_CHROMA_SATURATION_ADJ, 0x50 },
>   	{ TM6010_REQ07_R0C_CHROMA_AGC_CONTROL, 0x6a },
> +	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x17},
>   	{ TM6010_REQ07_R11_AGC_PEAK_CONTROL, 0xc9 },
>   	{ TM6010_REQ07_R12_AGC_GATE_STARTH, 0x07 },
>   	{ TM6010_REQ07_R13_AGC_GATE_STARTL, 0x3b },
> @@ -524,8 +461,8 @@ struct reg_init tm6010_init_tab[] = {
>   	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
>   	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
>   	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
> -	{ TM6010_REQ07_R20_HSYNC_RISING_EDGE_TIME, 0x3c },
> -	{ TM6010_REQ07_R21_HSYNC_PHASE_OFFSET, 0x3c },
> +	{ TM6010_REQ07_R20_HSYNC_RISING_EDGE_TIME, 0x3e },
> +	{ TM6010_REQ07_R21_HSYNC_PHASE_OFFSET, 0x3e },
>   	{ TM6010_REQ07_R2D_CHROMA_BURST_END, 0x48 },
>   	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
>   	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
> @@ -544,12 +481,18 @@ struct reg_init tm6010_init_tab[] = {
>   	{ TM6010_REQ07_R57_VBI_LOOP_FILTER_P_GAIN, 0x02 },
>   	{ TM6010_REQ07_R58_VBI_CAPTION_DTO1, 0x35 },
>   	{ TM6010_REQ07_R59_VBI_CAPTION_DTO0, 0xa0 },
> +	{ TM6010_REQ07_R5A_VBI_TELETEXT_DTO1, 0x11},
> +	{ TM6010_REQ07_R5B_VBI_TELETEXT_DTO0, 0x4c},
> +	{ TM6010_REQ07_R60_TELETEXT_FRAME_START, 0x52},
> +	{ TM6010_REQ07_R68_VBI_TELETEXT_START, 0x32},
>   	{ TM6010_REQ07_R80_COMB_FILTER_TRESHOLD, 0x15 },
>   	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
> +	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xa9},
>   	{ TM6010_REQ07_RC1_TRESHOLD, 0xd0 },
>   	{ TM6010_REQ07_RC3_HSTART1, 0x88 },
>   	{ TM6010_REQ07_R3F_RESET, 0x00 },
>
> +	{ TM6010_REQ07_R3F_RESET, 0x00 },
>   	{ TM6010_REQ05_R18_IMASK7, 0x00 },
>
>   	{ TM6010_REQ07_RD8_IR_LEADER1, 0xaa },
> @@ -615,6 +558,38 @@ int tm6000_init(struct tm6000_core *dev)
>   	return rc;
>   }
>
> +void tm6000_init_demdec(struct tm6000_core *dev)
> +{
> +	/* Set GCD2 to autogain */
> +	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +	/* Reduce SIF amplitude */
> +	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
> +	/* Set autodetect threshold */
> +	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
> +	/* Set auto-dematrix threshold */
> +	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
> +	/* Set NICAM error limits max */
> +	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
> +	/* Set NICAM error limits min */
> +	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
> +	/* Set gain max +6dB */
> +	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
> +	/* Set gain min -6dB */
> +	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
> +	/* Enable ADC (always use) */
> +	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
> +}
> +EXPORT_SYMBOL_GPL(tm6000_init_demdec);
> +
> +void tm6000_reset_demdec(struct tm6000_core *dev)
> +{
> +	/* Set DemDec to IDLE */
> +	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +	/* Set DemDec to Restart */
> +	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +}
> +EXPORT_SYMBOL_GPL(tm6000_reset_demdec);
> +
>   int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate)
>   {
>   	int val = 0;
> @@ -662,11 +637,13 @@ int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
>   	if (dev->dev_type == TM6010) {
>   		/* Audio crossbar setting, default SIF1 */
>   		u8 areg_f0 = 0x03;
> +		u8 areg_07 = 0x10;
>
>   		switch (ainp) {
>   		case TM6000_AIP_SIF1:
>   		case TM6000_AIP_SIF2:
>   			areg_f0 = 0x03;
> +			areg_07 = 0x30;
>   			break;
>   		case TM6000_AIP_LINE1:
>   			areg_f0 = 0x00;
> @@ -681,6 +658,10 @@ int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp)
>   		/* Set audio input crossbar */
>   		tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
>   							areg_f0, 0x0f);
> +
> +		/* Mux overflow workaround */
> +		tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
> +							areg_07, 0xf0);
>   	} else {
>   		/* Audio setting, default LINE1 */
>   		u8 areg_eb = 0x00;
> @@ -802,8 +783,10 @@ void tm6000_set_volume(struct tm6000_core *dev, int vol)
>   	if (dev->radio) {
>   		ainp = dev->aradio;
>   		vol += 8; /* Offset to 0 dB */
> -	} else
> -		ainp = dev->avideo;
> +	} else if (dev->input != TM6000_INPUT_COMPOSITE)
> +			ainp = dev->avideo;
> +		else
> +			ainp = dev->acomposite;
>
>   	switch (ainp) {
>   	case TM6000_AIP_SIF1:
> diff --git a/drivers/staging/tm6000/tm6000-stds.c b/drivers/staging/tm6000/tm6000-stds.c
> index da3e51b..fdb0280 100644
> --- a/drivers/staging/tm6000/tm6000-stds.c
> +++ b/drivers/staging/tm6000/tm6000-stds.c
> @@ -22,12 +22,6 @@
>   #include "tm6000.h"
>   #include "tm6000-regs.h"
>
> -struct tm6000_reg_settings {
> -	unsigned char req;
> -	unsigned char reg;
> -	unsigned char value;
> -};
> -
>   enum tm6000_audio_std {
>   	BG_NICAM,
>   	BTSC,
> @@ -40,909 +34,6 @@ enum tm6000_audio_std {
>   	L_NICAM,
>   };
>
> -struct tm6000_std_tv_settings {
> -	v4l2_std_id id;
> -	enum tm6000_audio_std audio_default_std;
> -
> -	struct tm6000_reg_settings sif[12];
> -	struct tm6000_reg_settings nosif[12];
> -	struct tm6000_reg_settings common[26];
> -};
> -
> -struct tm6000_std_settings {
> -	v4l2_std_id id;
> -	enum tm6000_audio_std audio_default_std;
> -	struct tm6000_reg_settings common[37];
> -};
> -
> -static struct tm6000_std_tv_settings tv_stds[] = {
> -	{
> -		.id = V4L2_STD_PAL_M,
> -		.audio_default_std = BTSC,
> -		.sif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
> -			{0, 0, 0},
> -		},
> -		.nosif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -			{0, 0, 0},
> -		},
> -		.common = {
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_PAL_Nc,
> -		.audio_default_std = BTSC,
> -		.sif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
> -			{0, 0, 0},
> -		},
> -		.nosif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -			{0, 0, 0},
> -		},
> -		.common = {
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_PAL,
> -		.audio_default_std = BG_A2,
> -		.sif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
> -			{0, 0, 0}
> -		},
> -		.nosif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -			{0, 0, 0},
> -		},
> -		.common = {
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
> -		.audio_default_std = BG_NICAM,
> -		.sif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
> -			{0, 0, 0},
> -		},
> -		.nosif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -			{0, 0, 0},
> -		},
> -		.common = {
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
> -
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_SECAM_DK,
> -		.audio_default_std = DK_NICAM,
> -		.sif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
> -			{0, 0, 0},
> -		},
> -		.nosif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -			{0, 0, 0},
> -		},
> -		.common = {
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
> -
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_NTSC,
> -		.audio_default_std = BTSC,
> -		.sif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x62},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0xcb},
> -			{0, 0, 0},
> -		},
> -		.nosif = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x60},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -			{0, 0, 0},
> -		},
> -		.common = {
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -
> -			{0, 0, 0},
> -		},
> -	},
> -};
> -
> -static struct tm6000_std_settings composite_stds[] = {
> -	{
> -		.id = V4L2_STD_PAL_M,
> -		.audio_default_std = BTSC,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	 }, {
> -		.id = V4L2_STD_PAL_Nc,
> -		.audio_default_std = BTSC,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_PAL,
> -		.audio_default_std = BG_A2,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	 }, {
> -		.id = V4L2_STD_SECAM,
> -		.audio_default_std = BG_NICAM,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
> -
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_SECAM_DK,
> -		.audio_default_std = DK_NICAM,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
> -
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_NTSC,
> -		.audio_default_std = BTSC,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe8},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8b},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	},
> -};
> -
> -static struct tm6000_std_settings svideo_stds[] = {
> -	{
> -		.id = V4L2_STD_PAL_M,
> -		.audio_default_std = BTSC,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x05},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_PAL_Nc,
> -		.audio_default_std = BTSC,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x37},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_PAL,
> -		.audio_default_std = BG_A2,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x33},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	 }, {
> -		.id = V4L2_STD_SECAM,
> -		.audio_default_std = BG_NICAM,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
> -
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_SECAM_DK,
> -		.audio_default_std = DK_NICAM,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xFF},
> -
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	}, {
> -		.id = V4L2_STD_NTSC,
> -		.audio_default_std = BTSC,
> -		.common = {
> -			{TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0},
> -			{TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc},
> -			{TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8},
> -			{TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00},
> -			{TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2},
> -			{TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0},
> -			{TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2},
> -			{TM6010_REQ08_RED_GAIN_SEL, 0xe0},
> -			{TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG, 0x68},
> -			{TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc},
> -			{TM6010_REQ07_RFE_POWER_DOWN, 0x8a},
> -
> -			{TM6010_REQ07_R3F_RESET, 0x01},
> -			{TM6010_REQ07_R00_VIDEO_CONTROL0, 0x01},
> -			{TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f},
> -			{TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f},
> -			{TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03},
> -			{TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30},
> -			{TM6010_REQ07_R17_HLOOP_MAXSTATE, 0x8b},
> -			{TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e},
> -			{TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b},
> -			{TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2},
> -			{TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9},
> -			{TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c},
> -			{TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc},
> -			{TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc},
> -			{TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd},
> -			{TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88},
> -			{TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22},
> -			{TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61},
> -			{TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c},
> -			{TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c},
> -			{TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42},
> -			{TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6F},
> -
> -			{TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd},
> -			{TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07},
> -			{TM6010_REQ07_R3F_RESET, 0x00},
> -			{0, 0, 0},
> -		},
> -	},
> -};
> -
> -
>   static int tm6000_set_audio_std(struct tm6000_core *dev,
>   				enum tm6000_audio_std std)
>   {
> @@ -952,22 +43,6 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
>   	uint8_t mono_flag = 0;  /* No mono */
>   	uint8_t nicam_flag = 0; /* No NICAM */
>
> -	if (dev->radio) {
> -		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> -		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
> -		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
> -		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
> -		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
> -		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
> -		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
> -		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
> -		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> -		return 0;
> -	}
> -
>   	switch (std) {
>   #if 0
>   	case DK_MONO:
> @@ -1012,6 +87,21 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
>   		areg_05 = 0x0a;
>   		nicam_flag = 1;
>   		break;
> +	case FM_RADIO:
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
> +		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
> +		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
> +		tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
> +		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
> +		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
> +		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
> +		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
> +		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
> +		return 0;
> +		break;
>   	default:
>   		/* do nothink */
>   		break;
> @@ -1036,39 +126,10 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
>
>   	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
>   	tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
> -	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
> -	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
>   	tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, areg_05);
>   	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, areg_06);
> -	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
> -	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
>   	tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
> -	tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
> -	tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
> -	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
> -	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
> -	tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
> -	tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
> -	tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
> -	tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
> -	tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
> -	tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
> -	tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
> -	tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
> -	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
> -	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
> -	tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
> -	tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
> -	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
> -	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
> -	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
> -	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
>   	tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
> -	tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
> -	tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
> -	tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
> -	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
> -	tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
>   	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
>
>   	return 0;
> @@ -1085,106 +146,419 @@ void tm6000_get_std_res(struct tm6000_core *dev)
>   	dev->width = 720;
>   }
>
> -static int tm6000_load_std(struct tm6000_core *dev,
> -			   struct tm6000_reg_settings *set, int max_size)
> +int tm6000_config_video_input(struct tm6000_core *dev)
>   {
> -	int i, rc;
> -
> -	/* Load board's initialization table */
> -	for (i = 0; max_size; i++) {
> -		if (!set[i].req)
> -			return 0;
> -
> -		if ((dev->dev_type != TM6010)&&
> -		    (set[i].req == REQ_08_SET_GET_AVREG_BIT))
> -				continue;
> -
> -		rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value);
> -		if (rc<  0) {
> -			printk(KERN_ERR "Error %i while setting "
> -			       "req %d, reg %d to value %d\n",
> -			       rc, set[i].req, set[i].reg, set[i].value);
> -			return rc;
> -		}
> +	switch (dev->input) {
> +	case TM6000_INPUT_TV:
> +		/* Enable ADC2 (without clamp?) */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x08);
> +		/* Power Up CLAMP, LPF BW = SIF mode */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf2);
> +		/* Set ADC1 input = CVBS1 */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8);
> +		/* Set ADC2 input = SIF1 or SIF2 */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL,
> +				(dev->avideo == TM6000_AIP_SIF1) ? 0xf7 : 0xf3);
> +		/* Clamping level control in ADC2 = SIF signal */
> +		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf6);
> +		/* SIF gain control enable signal = SIF signal */
> +		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0);
> +		/* GAIN selection = Y and SIF */
> +		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe8);
> +		break;
> +	case TM6000_INPUT_SVIDEO:
> +		/* Enable ADC2 */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x00);
> +		/* Power Up CLAMP, LPF BW<>  SIF mode */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0);
> +		/* Set ADC1 input = Y */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc);
> +		/* Set ADC2 input = C */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8);
> +		/* Clamping level control in ADC2 = C signal */
> +		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
> +		/* SIF gain control enable signal = C signal */
> +		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
> +		/* GAIN selection = Y and C */
> +		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
> +		break;
> +	case TM6000_INPUT_COMPOSITE:
> +		/* Set ADC1 input = CVBS2 */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4);
> +		/* Power Up CLAMP, LPF BW<>  SIF mode */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, 0xf0);
> +		/* Set ADC2 input = none */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xfc);
> +		/* Disable ADC2 */
> +		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, 0x0f);
> +		/* Clamping level control in ADC2 = C signal */
> +		tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
> +		/* SIF gain control enable signal = C signal */
> +		tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
> +		/* GAIN selection = Y and C */
> +		tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
> +		/* Set audio input */
> +		tm6000_set_audio_input(dev, dev->acomposite);
> +		tm6000_set_volume(dev, dev->ctl_volume);
> +		break;
> +	default:
> +		printk(KERN_ERR "Error video input source - %d\n", dev->input);
> +		return -EINVAL;
> +		break;
>   	}
>
>   	return 0;
>   }
>
> -static int tm6000_set_tv(struct tm6000_core *dev, int pos)
> +int tm6000_config_video_std(struct tm6000_core *dev, v4l2_std_id *norm)
>   {
> -	int rc;
> +	int rc = 0;
> +	uint8_t k;
> +	uint8_t areg_D5 = 0x4f;
> +	uint16_t tm_regs[0x90];
> +	bool pal_fl = true;
> +	bool f50hz_fl = true;
> +
> +	memset(tm_regs, 0xffff, sizeof(tm_regs));
> +
> +	dev->norm = *norm;
> +	tm6000_get_std_res(dev);
>
> -	/* FIXME: This code is for tm6010 - not tested yet - doesn't work with
> -	   tm5600
> -	 */
> +	/* Chroma AGC target */
> +	tm_regs[0x0c] = 0x6a;
> +	/* HSYNC rising-edge occurrence time */
> +	tm_regs[0x20] = 0x3e;
> +	/* backporch start/end */
> +	tm_regs[0x28] = 0x22;
> +	tm_regs[0x29] = 0x4e;
> +	/* Chroma burst start/end */
> +	tm_regs[0x2c] = 0x2c;
> +	tm_regs[0x2d] = 0x48;
> +	/* VSYNC H lockout start/end */
> +	tm_regs[0x32] = 0x74;
> +	tm_regs[0x33] = 0x0c;
> +	/* VSYNC AGC lockout start/end */
> +	tm_regs[0x34] = 0x74;
> +	tm_regs[0x35] = 0x1c;
> +	/* Comb filter config (PAL off) */
> +	tm_regs[0x82] = 0x42;
> +
> +	switch (*norm) {
> +	case V4L2_STD_SECAM:
> +	case V4L2_STD_SECAM_B:
> +	case V4L2_STD_SECAM_G:
> +	case V4L2_STD_SECAM_DK:
> +		/* SECAM */
> +		tm_regs[0x00] = 0x08;
> +		tm_regs[0x01] = 0x02;
> +		/* Full 2-D adaptive comb */
> +		tm_regs[0x03] = 0x00;
> +		/* HAGC = 220 */
> +		tm_regs[0x04] = 0xdc;
> +		/* DTO = 17.144 */
> +		tm_regs[0x18] = 0x24;
> +		tm_regs[0x19] = 0x92;
> +		tm_regs[0x1a] = 0xe8;
> +		tm_regs[0x1b] = 0xed;
> +		/* backporch start/end */
> +		tm_regs[0x28] = 0x42;
> +		tm_regs[0x29] = 0x62;
> +		/* Chroma burst start/end */
> +		tm_regs[0x2c] = 0x44;
> +		tm_regs[0x2d] = 0x60;
> +		/* VSYNC H lockout start/end */
> +		tm_regs[0x32] = 0x74;
> +		tm_regs[0x33] = 0x2c;
> +		/* VSYNC AGC lockout start/end */
> +		tm_regs[0x34] = 0x74;
> +		tm_regs[0x35] = 0x18;
> +		pal_fl = false;
> +		break;
> +	case V4L2_STD_PAL:
> +		/* PAL */
> +		tm_regs[0x00] = 0x02;
> +		tm_regs[0x01] = 0x02;
> +		/* PAL fix (basic luma notch comb filter) */
> +		tm_regs[0x03] = 0x03;
> +		/* HAGC = 220 */
> +		tm_regs[0x04] = 0xdc;
> +		/* DTO = 17.734475 */
> +		tm_regs[0x18] = 0x25;
> +		tm_regs[0x19] = 0xD5;
> +		tm_regs[0x1a] = 0x63;
> +		tm_regs[0x1b] = 0x50;
> +		break;
> +	case V4L2_STD_PAL_N:
> +	case V4L2_STD_PAL_M:
> +		/* PAL MN */
> +		tm_regs[0x00] = 0x04;
> +		tm_regs[0x01] = 0x02;
> +		/* PAL fix (basic luma notch comb filter) */
> +		tm_regs[0x03] = 0x03;
> +		/* HAGC = 221 */
> +		tm_regs[0x04] = 0xdd;
> +		/* DTO = 17.734475 */
> +		tm_regs[0x18] = 0x25;
> +		tm_regs[0x19] = 0xD5;
> +		tm_regs[0x1a] = 0x63;
> +		tm_regs[0x1b] = 0x50;
> +		break;
> +	case V4L2_STD_PAL_Nc:
> +		/* PAL Nc */
> +		tm_regs[0x00] = 0x06;
> +		tm_regs[0x01] = 0x02;
> +		/* PAL fix (basic luma notch comb filter) */
> +		tm_regs[0x03] = 0x03;
> +		/* HAGC = 220 */
> +		tm_regs[0x04] = 0xdc;
> +		/* DTO = 14.328225 */
> +		tm_regs[0x18] = 0x1e;
> +		tm_regs[0x19] = 0x91;
> +		tm_regs[0x1a] = 0x1f;
> +		tm_regs[0x1b] = 0x0c;
> +		break;
> +	case V4L2_STD_PAL_60:
> +		/* PAL */
> +		tm_regs[0x00] = 0x02;
> +		tm_regs[0x01] = 0x02;
> +		/* PAL fix (basic luma notch comb filter) */
> +		tm_regs[0x03] = 0x03;
> +		/* HAGC = 220 */
> +		tm_regs[0x04] = 0xdc;
> +		/* DTO = 17.734475 */
> +		tm_regs[0x18] = 0x25;
> +		tm_regs[0x19] = 0xd5;
> +		tm_regs[0x1a] = 0x63;
> +		tm_regs[0x1b] = 0x50;
> +		/* HSYNC rising-edge occurrence time */
> +		tm_regs[0x20] = 0x4c;
> +		f50hz_fl = false;
> +		break;
> +	case V4L2_STD_NTSC_M:
> +	case V4L2_STD_NTSC_M_JP:
> +	case V4L2_STD_NTSC_M_KR:
> +		/* NTSC */
> +		tm_regs[0x00] = 0x00;
> +		/* Ped = 1 */
> +		tm_regs[0x01] = 0x03;
> +		/* Full 2-D adaptive comb */
> +		tm_regs[0x03] = 0x00;
> +		/* HAGC = 221 */
> +		tm_regs[0x04] = 0xdd;
> +		/* Chroma AGC target */
> +		tm_regs[0x0c] = 0x8a;
> +		/* DTO = 14.31818182 */
> +		tm_regs[0x18] = 0x1e;
> +		tm_regs[0x19] = 0x8b;
> +		tm_regs[0x1a] = 0xa2;
> +		tm_regs[0x1b] = 0xe9;
> +		tm_regs[0x33] = 0x1c;
> +		f50hz_fl = false;
> +		pal_fl = false;
> +		if (*norm == V4L2_STD_NTSC_M_JP) {
> +			/* Ped = 0*/
> +			tm_regs[0x01] = 0x02;
> +			/* HAGC  205 */
> +			tm_regs[0x04] = 0xcd;
> +		}
> +		break;
> +	case V4L2_STD_NTSC_443:
> +		/* NTSC */
> +		tm_regs[0x00] = 0x00;
> +		/* Ped = 1 */
> +		tm_regs[0x01] = 0x03;
> +		/* Full 2-D adaptive comb */
> +		tm_regs[0x03] = 0x00;
> +		/* HAGC = 221 */
> +		tm_regs[0x04] = 0xdd;
> +		/* Chroma AGC target */
> +		tm_regs[0x0c] = 0x8a;
> +		/* DTO = 17.734475 */
> +		tm_regs[0x18] = 0x25;
> +		tm_regs[0x19] = 0xd5;
> +		tm_regs[0x1a] = 0x63;
> +		tm_regs[0x1b] = 0x50;
> +		tm_regs[0x33] = 0x1c;
> +		pal_fl = false;
> +		break;
> +	}
>
> -	/* FIXME: This is tuner-dependent */
> -	int nosif = 0;
> +	if (pal_fl) {
> +		/* UV_FLT_EN = 1 */
> +		areg_D5 |= 0x10;
> +		/* comb_wide_band = 1 */
> +		tm_regs[0x82] |= 0x10;
> +	}
>
> -	if (nosif) {
> -		rc = tm6000_load_std(dev, tv_stds[pos].nosif,
> -				     sizeof(tv_stds[pos].nosif));
> +	if (f50hz_fl) {
> +		/* vline_625 = 1, hpixel = 864 */
> +		tm_regs[0x00] |= 0x30;
> +		/* hactive_start = 138 */
> +		tm_regs[0x2e] = 0x8a;
> +		/* vactive_start = 42 */
> +		tm_regs[0x30] = 0x2a;
> +		/* vactive_hight = 171 */
> +		tm_regs[0x31] = 0xc1;
> +		/* VBI FRAME CODE */
> +		tm_regs[0x41] = 0x27;
> +		/* data high level */
> +		tm_regs[0x42] = 0x5e;
> +		/* vbil7 */
> +		tm_regs[0x43] = 0x66;
> +		/* vbil8 */
> +		tm_regs[0x44] = 0x66;
> +		/* vbil9 */
> +		tm_regs[0x45] = 0x66;
> +		/* vbil10 */
> +		tm_regs[0x46] = 0x66;
> +		/* vbil11 */
> +		tm_regs[0x47] = 0x66;
> +		/* vbil12 */
> +		tm_regs[0x48] = 0x66;
> +		/* vbil13 */
> +		tm_regs[0x49] = 0x66;
> +		/* vbil14 */
> +		tm_regs[0x4a] = 0x66;
> +		/* vbil15 */
> +		tm_regs[0x4b] = 0x66;
> +		/* vbil16 */
> +		tm_regs[0x4c] = 0x66;
> +		/* vbil17 */
> +		tm_regs[0x4d] = 0x66;
> +		/* vbil18 */
> +		tm_regs[0x4e] = 0x66;
> +		/* vbil19 */
> +		tm_regs[0x4f] = 0x66;
> +		/* vbil20 */
> +		tm_regs[0x50] = 0x66;
> +		/* vbil21 */
> +		tm_regs[0x51] = 0x66;
> +		/* vbil22 */
> +		tm_regs[0x52] = 0x66;
> +		/* vbil23 = WSS */
> +		tm_regs[0x53] = 0x00;
> +		/* vbil24 */
> +		tm_regs[0x54] = 0x00;
>   	} else {
> -		rc = tm6000_load_std(dev, tv_stds[pos].sif,
> -				     sizeof(tv_stds[pos].sif));
> +		/* vline_625 = 0, hpixel = 858 */
> +		tm_regs[0x00]&= 0xcf;
> +		/* hactive_start = 134 */
> +		tm_regs[0x2e] = 0x86;
> +		/* vactive_start = 34 */
> +		tm_regs[0x30] = 0x22;
> +		/* vactive_hight = 121 */
> +		tm_regs[0x31] = 0x61;
> +		/* VBI FRAME CODE */
> +		tm_regs[0x41] = 0xe7;
> +		/* data high level */
> +		tm_regs[0x42] = 0x58;
> +		/* vbil7 */
> +		tm_regs[0x43] = 0x00;
> +		/* vbil8 */
> +		tm_regs[0x44] = 0x00;
> +		/* vbil9 */
> +		tm_regs[0x45] = 0x00;
> +		/* vbil10 */
> +		tm_regs[0x46] = 0x00;
> +		/* vbil11 */
> +		tm_regs[0x47] = 0x00;
> +		/* vbil12 */
> +		tm_regs[0x48] = 0x00;
> +		/* vbil13 */
> +		tm_regs[0x49] = 0x00;
> +		/* vbil14 */
> +		tm_regs[0x4a] = 0x00;
> +		/* vbil15 */
> +		tm_regs[0x4b] = 0x00;
> +		/* vbil16 */
> +		tm_regs[0x4c] = 0x00;
> +		/* vbil17 */
> +		tm_regs[0x4d] = 0x00;
> +		/* vbil18 */
> +		tm_regs[0x4e] = 0x00;
> +		/* vbil19 */
> +		tm_regs[0x4f] = 0x00;
> +		/* vbil20 */
> +		tm_regs[0x50] = 0x00;
> +		/* vbil21 = CC */
> +		tm_regs[0x51] = 0x11;
> +		/* vbil22 */
> +		tm_regs[0x52] = 0x00;
> +		/* vbil23 */
> +		tm_regs[0x53] = 0x00;
> +		/* vbil24 */
> +		tm_regs[0x54] = 0x00;
> +	}
> +
> +	if (dev->input == TM6000_INPUT_SVIDEO) {
> +		/* Y_C = ON */
> +		tm_regs[0x00] |= 0x01;
> +		/* chroma_bw_lo = wide */
> +		tm_regs[0x01] |= 0x04;
> +		/* basic luma notch filter mode */
> +		tm_regs[0x03] = 0x03;
>   	}
> -	if (rc<  0)
> -		return rc;
> -	rc = tm6000_load_std(dev, tv_stds[pos].common,
> -			     sizeof(tv_stds[pos].common));
>
> -	tm6000_set_audio_std(dev, tv_stds[pos].audio_default_std);
> +	/* Set HV filter for PAL */
> +	tm6000_set_reg(dev, TM6010_REQ07_RD5_POWERSAVE, areg_D5);
> +
> +	for (k = 0; k<  0x90; k++) {
> +		if (tm_regs[k] != 0xffff) {
> +			rc = tm6000_set_reg(dev, 0x07, k, (uint8_t)tm_regs[k]);
> +			if (rc<  0) {
> +				printk(KERN_ERR "Error %i while setting "
> +			       "req %d, reg %d to value %d\n",
> +			       rc, 0x07, k, (uint8_t)tm_regs[k]);
> +				return rc;
> +			}
> +		}
> +	}
>
> -	return rc;
> +	/* TCD2 SW Reset ON */
> +	tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x01);
> +	/* TCD2 SW Reset OFF */
> +	tm6000_set_reg(dev, TM6010_REQ07_R3F_RESET, 0x00);
> +
> +	return 0;
>   }
>
>   int tm6000_set_standard(struct tm6000_core *dev, v4l2_std_id * norm)
>   {
> -	int i, rc = 0;
> +	int rc = 0;
>
>   	dev->norm = *norm;
> -	tm6000_get_std_res(dev);
>
> -	switch (dev->input) {
> -	case TM6000_INPUT_TV:
> -		for (i = 0; i<  ARRAY_SIZE(tv_stds); i++) {
> -			if (*norm&  tv_stds[i].id) {
> -				rc = tm6000_set_tv(dev, i);
> -				goto ret;
> -			}
> -		}
> -		return -EINVAL;
> -	case TM6000_INPUT_SVIDEO:
> -		for (i = 0; i<  ARRAY_SIZE(svideo_stds); i++) {
> -			if (*norm&  svideo_stds[i].id) {
> -				rc = tm6000_load_std(dev, svideo_stds[i].common,
> -						     sizeof(svideo_stds[i].
> -							    common));
> -				goto ret;
> -			}
> -		}
> -		return -EINVAL;
> -	case TM6000_INPUT_COMPOSITE:
> -		for (i = 0; i<  ARRAY_SIZE(composite_stds); i++) {
> -			if (*norm&  composite_stds[i].id) {
> -				rc = tm6000_load_std(dev,
> -						     composite_stds[i].common,
> -						     sizeof(composite_stds[i].
> -							    common));
> -				tm6000_set_audio_std(dev, composite_stds[i].audio_default_std);
> -				goto ret;
> -			}
> -		}
> -		return -EINVAL;
> -	}
> +	rc = tm6000_config_video_input(dev);
> +	if (rc<  0)
> +		return rc;
>
> -ret:
> +	rc = tm6000_config_video_std(dev, norm);
>   	if (rc<  0)
>   		return rc;
>
> -	msleep(40);
> +	if (dev->radio) {
> +		tm6000_set_audio_std(dev, FM_RADIO);
> +		return 0;
> +	}
>
> +	switch (*norm) {
> +	case V4L2_STD_PAL_M:
> +	case V4L2_STD_PAL_N:
> +	case V4L2_STD_PAL_Nc:
> +	case V4L2_STD_NTSC:
> +		tm6000_set_audio_std(dev, BTSC);
> +		break;
> +	case V4L2_STD_PAL:
> +		tm6000_set_audio_std(dev, BG_A2);
> +		break;
> +	case V4L2_STD_SECAM_B:
> +	case V4L2_STD_SECAM_G:
> +		tm6000_set_audio_std(dev, BG_NICAM);
> +		break;
> +	case V4L2_STD_SECAM_DK:
> +		tm6000_set_audio_std(dev, DK_NICAM);
> +		break;
> +	}
>
>   	return 0;
>   }
> diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
> index c80a316..ef31da1 100644
> --- a/drivers/staging/tm6000/tm6000-video.c
> +++ b/drivers/staging/tm6000/tm6000-video.c
> @@ -1510,6 +1510,7 @@ static int tm6000_open(struct file *file)
>   			V4L2_FIELD_INTERLACED,
>   			sizeof(struct tm6000_buffer), fh,&dev->lock);
>
> +	tm6000_init_demdec(dev);
>   	if (fh->radio) {
>   		dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n");
>   		tm6000_set_audio_input(dev, dev->aradio);
> diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
> index 99ae50e..2db8f2d 100644
> --- a/drivers/staging/tm6000/tm6000.h
> +++ b/drivers/staging/tm6000/tm6000.h
> @@ -228,6 +228,7 @@ struct tm6000_core {
>   	atomic_t			stream_started;  /* stream should be running if true */
>   	enum tm6000_inaudio		avideo;
>   	enum tm6000_inaudio		aradio;
> +	enum tm6000_inaudio		acomposite;
>
>   	struct tm6000_IR		*ir;
>
> @@ -305,6 +306,8 @@ int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate);
>   int tm6000_set_audio_input(struct tm6000_core *dev, enum tm6000_inaudio ainp);
>   int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute);
>   void tm6000_set_volume(struct tm6000_core *dev, int vol);
> +void tm6000_init_demdec(struct tm6000_core *dev);
> +void tm6000_reset_demdec(struct tm6000_core *dev);
>
>   int tm6000_v4l2_register(struct tm6000_core *dev);
>   int tm6000_v4l2_unregister(struct tm6000_core *dev);
>
> Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov<d.belimov@gmail.com>
>
>
> With my best regards, Dmitry.
Not bad. But what is if a device use two composite config (see TerraTec 
Grabstar)? Or Tuner is connected by other video port, or using gpio's to 
switch external audiodecoder ... Yours doesn't give answers to that. 
Then the audio standard is not complete the decoder can more

I have:
For video norm
PAL_BGH, SECAM_BGH -> BG_A2 and BG_NICAM  -> mode 5 and 7
PAL_DK1, SECAM_DK1 -> DK1_A2 and DK_NICAM -> mode 9 and 6
PAL_DK3, SECAM_DK3 -> DK3_A2 and DK_NICAM -> mode b
PAL_I , SECAM_I -> I_NICAM -> mode 8
PAL_L, SECAM_L -> L_NICAM -> mode a
NTSC_M, PAL-M, PAL_N  -> BTSC -> mode 2
NTSC__M_JP -> EIAJ -> mode 3
NTSC_M_KR -> Korea -> mode 4
for PAL_Nc -> only auto with carier (or ...)
auto mode -> mode 1:

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v1] tm6000: rework standards
  2011-04-19  6:42                                                               ` Stefan Ringel
@ 2011-05-04 16:18                                                                 ` Stefan Ringel
  0 siblings, 0 replies; 36+ messages in thread
From: Stefan Ringel @ 2011-05-04 16:18 UTC (permalink / raw)
  To: Dmitri Belimov; +Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Dmitri,

I have tested your patch, but is doesn't work (big crash -> long, long, 
long beep).

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2011-05-04 16:18 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-07  5:28 [RFC PATCH] Audio standards on tm6000 Mauro Carvalho Chehab
2010-10-08 19:03 ` Dmitri Belimov
2010-10-08 11:52   ` Mauro Carvalho Chehab
2010-10-12 18:28     ` Dmitri Belimov
2010-10-12 16:54       ` Stefan Ringel
2010-10-13 14:13         ` Dmitri Belimov
     [not found]         ` <20101129174412.08f2001c@glory.local>
     [not found]           ` <4CF51C9E.6040600@arcor.de>
     [not found]             ` <20101201144704.43b58f2c@glory.local>
     [not found]               ` <4CF67AB9.6020006@arcor.de>
     [not found]                 ` <20101202134128.615bbfa0@glory.local>
     [not found]                   ` <4CF71CF6.7080603@redhat.com>
     [not found]                     ` <20101206010934.55d07569@glory.local>
     [not found]                       ` <4CFBF62D.7010301@arcor.de>
     [not found]                         ` <20101206190230.2259d7ab@glory.local>
     [not found]                           ` <4CFEA3D2.4050309@arcor.de>
     [not found]                             ` <20101208125539.739e2ed2@glory.local>
     [not found]                               ` <4CFFAD1E.7040004@arcor.de>
2010-12-14  3:23                                 ` tm6000 and IR Dmitri Belimov
2010-12-14 16:27                                   ` Stefan Ringel
2010-12-15  7:46                                     ` Dmitri Belimov
2010-12-15 15:52                                       ` Stefan Ringel
2010-12-16  3:26                                         ` Dmitri Belimov
2010-12-16  9:38                                         ` Dmitri Belimov
2010-12-16 17:12                                           ` Stefan Ringel
2010-12-17  1:46                                             ` Dmitri Belimov
2010-12-17  5:18                                               ` Stefan Ringel
2010-12-17  7:08                                                 ` Dmitri Belimov
2010-12-18  0:24                                                   ` Mauro Carvalho Chehab
2010-12-18 13:56                                                     ` Andy Walls
2010-12-18 15:55                                                       ` Stefan Ringel
2010-12-20  5:41                                                     ` Dmitri Belimov
2010-12-21 22:36                                                       ` Jarod Wilson
2010-12-22  8:57                                                         ` [PATCH] Rework and fix IR Dmitri Belimov
2011-01-13  3:46                                                     ` [PATCH] tm6000: rework init code Dmitri Belimov
2011-01-20  6:05                                                     ` [PATCH] tm6000: add/rework reg.defines Dmitri Belimov
2011-01-20 19:25                                                       ` Stefan Ringel
2011-01-20 23:20                                                         ` Dmitri Belimov
2011-02-17  5:12                                                         ` tm6000 and radio Dmitri Belimov
2011-02-17 20:58                                                           ` Mauro Carvalho Chehab
2011-02-18  1:11                                                             ` [PATCH] tm6000: add radio Dmitri Belimov
2011-03-01  4:55                                                             ` [PATCH] tm6000: add audio conf for new cards Dmitri Belimov
2011-03-18  0:08                                                             ` [PATCH] tm6000: fix s-video input Dmitri Belimov
2011-03-19  6:46                                                               ` Stefan Ringel
2011-03-23  2:49                                                                 ` Dmitri Belimov
2011-04-19  5:29                                                             ` [PATCH v1] tm6000: rework standards Dmitri Belimov
2011-04-19  6:42                                                               ` Stefan Ringel
2011-05-04 16:18                                                                 ` Stefan Ringel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.