cx88: add optional stereo detection to PAL-BG mode with A2 sound system
PATCH 1/1 cx88: add optional stereo detection to PAL-BG mode with A2 sound system
This patchset adds support for optional stereo detection for PAL-BG mode. This is a slightly modified version of the original patch I sent to this list earlier this year. The first patch disables the audio thread in cx88, and the second implements stereo detection.
The audio thread in the cx88 code is totally useless, because cx88_get_stereo is not implemented correctly. Because of this, the audio thread occaisonally sets the audio to MONO after starting a TV application, and unfortuantely this may happen after the stereo detection.
Stereo detection is optional, and is not enabled by default, because it is not always reliable, the actual results may depend on your TV application and your provider. It works 100% for me using tvtime, and another guy reported success earlier, as a result of my original posting.
Regards,
Marton Balint
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
PATCH 1/1 cx88: add optional stereo detection to PAL-BG mode with A2 sound system
# HG changeset patch
# User Marton Balint <[email protected]>
# Date 1226268742 -3600
# Node ID 45eba6ab2f4cdcaf7aebd707e1ac545b66ae66bc
# Parent e9f7514f435ad89666cd12e8384d88114c21b5ee
cx88: add optional stereo detection to PAL-BG mode with A2 sound system
From: Marton Balint <[email protected]>
This patch adds a module parameter detect_stereo which can be used to enable stereo detection for PAL-BG mode, using the following method:
AUD_NICAM_STATUS1 and AUD_NICAM_STATUS2 registers change randomly if and only if the second audio channel is missing, so if these registers are constant (Usually 0x0000 and 0x01), we can assume that the tv channel has two audio channels, so we can use STEREO mode. This method seems a bit ugly, but nicam detection works the same way.
This stereo detection method is not perfect. For example, it works quite well for me using tvtime, but it misdetects some of the channels using mplayer. Since the stereo detection is disabled by default, it should not harm the average user, but an advanced user may try setting the parameter and may have mostly working stereo detection.
Priority: normal
linux/drivers/media/video/cx88/cx88-tvaudio.c +43 -14
@@ -69,6 +69,11 @@module_param (radio_deemphasis,int,0644 );MODULE_PARM_DESC (radio_deemphasis,"Radio deemphasis time constant, " "0=None, 1=50us (elsewhere), 2=75us (USA)" ); + +static unsigned int detect_stereo; +module_param (detect_stereo,int,0644 ); +MODULE_PARM_DESC (detect_stereo,"enable unreliable but often working " +"stereo detection code for PAL-BG audio" ); #define dprintk(fmt, arg...) if (audio_debug) \ printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
@@ -718,31 +723,52 @@/* ----------------------------------------------------------- */ -static int cx88_detect_nicam (struct cx88_core *core) +static int cx88_detect_nicam_or_stereo (struct cx88_core *core) { -int i, j =0 ; +int i, stereo =0 ; +u32 status1, status2; +u32 last_status1, last_status2;dprintk ("start nicam autodetect.\n" ); + last_status1 =cx_read (AUD_NICAM_STATUS1 ); + last_status2 =cx_read (AUD_NICAM_STATUS2 ); -for (i =0 ; i <6 ; i++) { +/* wait here max 50 ms or if stereo is ambigous then max 70 ms */ +for (i =0 ; i <5 || (stereo >0 && stereo <3 && i <7 ); i++) { +/* wait a little bit for next reading status */ +msleep (10 ); + + status1 =cx_read (AUD_NICAM_STATUS1 ); + status2 =cx_read (AUD_NICAM_STATUS2 ); +/* if bit1=1 then nicam is detected */ - j += ((cx_read (AUD_NICAM_STATUS2 ) &0x02 ) >>1 ); - -if (j ==1 ) { +if (status2 &0x02 ) {dprintk ("nicam is detected.\n" );return 1 ; } -/* wait a little bit for next reading status */ -msleep (10 ); +/* try stereo detection only for PAL-BG */ +if (core->tvaudio ==WW_BG && detect_stereo) { +if (last_status1 == status1 && last_status2 == status2) + stereo++; +else + stereo =0 ; + last_status1 = status1; + last_status2 = status2; + } }dprintk ("nicam is not detected.\n" ); -return 0 ; +if (core->tvaudio ==WW_BG && detect_stereo) +dprintk ("stereo detection result: %d\n" , stereo); + +return stereo >=3 ?2 :0 ; }void cx88_set_tvaudio (struct cx88_core *core) { +int nicam_or_stereo; +switch (core->tvaudio) {case WW_BTSC :set_audio_standard_BTSC (core,0 ,EN_BTSC_AUTO_STEREO );
@@ -757,12 +783,15 @@/* set nicam mode - otherwise AUD_NICAM_STATUS2 contains wrong values */ set_audio_standard_NICAM (core,EN_NICAM_AUTO_STEREO ); -if (0 ==cx88_detect_nicam (core)) { -/* fall back to fm / am mono */ -set_audio_standard_A2 (core,EN_A2_FORCE_MONO1 ); + nicam_or_stereo =cx88_detect_nicam_or_stereo (core); +if (nicam_or_stereo ==1 ) { + core->use_nicam =1 ; + }else { +/* fall back to fm / am stereo or mono */ +set_audio_standard_A2 (core, (nicam_or_stereo ==2 ) + ?EN_A2_FORCE_STEREO + :EN_A2_FORCE_MONO1 ); core->use_nicam =0 ; - }else { - core->use_nicam =1 ; }break ;case WW_EIAJ :
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
PATCH 1/1 cx88: disable audio thread
In reply to Marton Balint# HG changeset patch
# User Marton Balint <[email protected]>
# Date 1217451009 -7200
# Node ID e9f7514f435ad89666cd12e8384d88114c21b5ee # Parent 46604f47fca16225c854ad69c3d8a335c94d5448
cx88: disable audio thread
From: Marton Balint <[email protected]>
The audio thread in the cx88 code is totally useless, because cx88_get_stereo is not implemented correctly. Because of this, the audio thread occaisonally sets the audio to MONO after starting a TV application. This patch disables the audio thread by ifdefing out the relevant lines.
linux/drivers/media/video/cx88/cx88-tvaudio.c +4 -1
@@ -970,7 +970,7 @@ }return ; } - +#if 0 int cx88_audio_thread (void *data) {struct cx88_core *core = data;
@@ -1008,6 +1008,7 @@dprintk ("cx88: tvaudio thread exiting\n" ); return 0; } +#endif /* ----------------------------------------------------------- */
@@ -1015,7 +1016,9 @@EXPORT_SYMBOL (cx88_newstation);EXPORT_SYMBOL (cx88_set_stereo);EXPORT_SYMBOL (cx88_get_stereo); +#if 0 EXPORT_SYMBOL (cx88_audio_thread); +#endif /* * Local variables:
linux/drivers/media/video/cx88/cx88-video.c +4 -1
@@ -2229,6 +2229,7 @@cx88_video_mux (core,0 );mutex_unlock (&core->lock); +#if 0 /* start tvaudio thread */ if (core->board.tuner_type !=TUNER_ABSENT ) { core->kthread =kthread_run (cx88_audio_thread, core,"cx88 tvaudio" );
@@ -2238,6 +2239,7 @@ core->name, err); } } +#endif return 0 ; fail_unreg:
@@ -2255,12 +2257,13 @@struct cx8800_dev *dev =pci_get_drvdata (pci_dev);struct cx88_core *core = dev->core; +#if 0 /* stop thread */ if (core->kthread) {kthread_stop (core->kthread); core->kthread =NULL ; } - +#endif if (core->ir)cx88_ir_stop (core, core->ir);
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Hello,
Quoted 10 lines · Marton Balint
This patchset adds support for optional stereo detection for PAL-BG mode. This is a slightly modified version of the original patch I sent to this list earlier this year. The first patch disables the audio thread in cx88, and the second implements stereo detection.
The audio thread in the cx88 code is totally useless, because
cx88_get_stereois not implemented correctly. Because of this, the audio thread occaisonally sets the audio to MONO after starting a TV application, and unfortuantely this may happen after the stereo detection.
Quoted 5 lines
Stereo detection is optional, and is not enabled by default, because it is not always reliable, the actual results may depend on your TV application and your provider. It works 100% for me using tvtime, and another guy reported success earlier, as a result of my original posting.
I am the one who has tried original Marton's patches this year.
After applying I was able to get stereo working with Aver TV Studio 303 using mplayer / mencoder. When there were multiple audio streams broadcasted I was getting them in the respective channels I.E. I had no mono sound. I am using this setup for recording only so actually this is great for me as I can do multidub rips when available.
Do you recommend to update to latest V4L and apply new patches?
Regards
Peter Vágner
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Hello,
How about audio support in NTSC mode?
What needs to be done to add support for it?
I'm using a PlayTV 8000GT, that says to support "Stereo Sound".
Thanks,
Rafael Diniz
Quoted 10 lines · On Sunday 09 November 2008 21:19:20 Marton Balint wrote:
This patchset adds support for optional stereo detection for PAL-BG mode. This is a slightly modified version of the original patch I sent to this list earlier this year. The first patch disables the audio thread in cx88, and the second implements stereo detection.
The audio thread in the cx88 code is totally useless, because
cx88_get_stereois not implemented correctly. Because of this, the audio thread occaisonally sets the audio to MONO after starting a TV application, and unfortuantely this may happen after the stereo detection.
Quoted 7 lines
Stereo detection is optional, and is not enabled by default, because it is not always reliable, the actual results may depend on your TV application and your provider. It works 100% for me using tvtime, and another guy reported success earlier, as a result of my original posting.
Regards,
Marton Balint
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Hello,
Quoted 4 lines · Rafael Diniz
Hello,
How about audio support in NTSC mode?
What needs to be done to add support for it?
I'm using a PlayTV 8000GT, that says to support "Stereo Sound".
Sorry, i am not an expert of the cx88 driver, others may be more familiar with it and the status of NTSC stereo support. But unless I am mistaken NTSC uses the BTSC audio standard, and if I understand the code correctly, this audio standard already has stereo autodetection. If it doesn't work for you, maybe you can try a similar approach like mine in PAL-BG mode, but probably it won't work.
Regards,
Marton
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello,
Quoted 8 lines · Peter Vágner
I am the one who has tried original Marton's patches this year. After applying I was able to get stereo working with Aver TV Studio 303 using mplayer / mencoder. When there were multiple audio streams broadcasted I was getting them in the respective channels I.E. I had no mono sound. I am using this setup for recording only so actually this is great for me as I can do multidub rips when available.
Do you recommend to update to latest V4L and apply new patches?
Sure, try it.
Regards,
Marton
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 10 lines · Marton Balint
This patchset adds support for optional stereo detection for PAL-BG mode. This is a slightly modified version of the original patch I sent to this list earlier this year. The first patch disables the audio thread in cx88, and the second implements stereo detection.
The audio thread in the cx88 code is totally useless, because
cx88_get_stereois not implemented correctly. Because of this, the audio thread occaisonally sets the audio to MONO after starting a TV application, and unfortuantely this may happen after the stereo detection.
Quoted 4 lines
Stereo detection is optional, and is not enabled by default, because it is not always reliable, the actual results may depend on your TV application and your provider. It works 100% for me using tvtime, and another guy reported success earlier, as a result of my original posting.
Has any of the developers reviewed the patches? I know you're busy, but please have a look at them, and if they are applicable, apply them :)
Thanks,
Marton Balint
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list