[RFC] Audio standards on tm6000

Message ID 20101012142856.2b4ee637@glory.local (mailing list archive)
State RFC, archived
Headers

Commit Message

Dmitri Belimov Oct. 12, 2010, 6:28 p.m. UTC
  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.
  

Comments

Stefan Ringel Oct. 12, 2010, 4:54 p.m. UTC | #1
-----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-----

--
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
  
Dmitri Belimov Oct. 13, 2010, 2:13 p.m. UTC | #2
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-----
> 
--
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
  
Dmitri Belimov Dec. 14, 2010, 3:23 a.m. UTC | #3
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.
--
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
  
Stefan Ringel Dec. 14, 2010, 4:27 p.m. UTC | #4
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
--
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
  
Dmitri Belimov Dec. 15, 2010, 7:46 a.m. UTC | #5
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.
--
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
  
Stefan Ringel Dec. 15, 2010, 3:52 p.m. UTC | #6
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

--
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
  
Dmitri Belimov Dec. 16, 2010, 3:26 a.m. UTC | #7
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.
--
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
  

Patch

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>