By Date: <-- -->
By Thread: <-- -->

bttv msp3400 2.6.15.6 - > 2.6.16 stereo stop working



Hans Verkuil wrote:
On Wednesday 29 March 2006 08:25, Daniel Smolik wrote:
Please apply the attached patch to msp3400-kthreads.c and let me
know if this fixes the problems.
I mean that situation is the same. But in log as I send before (log
is with patch applied) isn't  stereo newer set automaticaly I must
always switch manualy (xawtv always show mono) but don't hear any
difference when switch mono/stereo.

Sorry to ask you this again, but can you make another log, this time with debug set to 3 and taken from the /var/log/messages file so that I can see the timestamps too. It's really peculiar and I need a more detailed log.
Sorry, too late :-) Here's a patch, works for me (against hg-v4l-dvb two days or so ago, patched with your 2 patches).
- since msp3400c_set_carrier is no longer called within set_audio_mode, the DCO values for one channel never got set up, which is why the chip always reported mono.
- With that fixed, xawtv still always thinked a channel is already stereo and thus not switch to stereo automatically (it only switches to stereo if it detects stereo capability but not already set stereo mode I think). This is due to the incredibly messy v4l2 to v4l1 translation inside bttv, which will pretty much guarantee you get (and set) more or less random values with the v4l2 functions (at least for audio). Quick hack up for that included.
- I also increased the wait period for watch_stereo the first time, I've seen it (twice) that 1 second wasn't quite enough.


Oh, and btw the driver writes to another reg which doesn't exist (dsp 0x41) (the msp3400c has 2 scart outputs, but according to my datasheet the channel source/matrix (not the acb bits) are the same for both scart outputs I think). This is not new however and doesn't seem to cause any harm. The msp_prod_hi/lo assignment with that div and modulo 10 look a bit crazy if you ask me, but don't seem to be the cause for this.
(I do have a msp3400c c8 datasheet, the chip actually seems to be newer:
rev1=0x0503, rev2=0x0a1b)
There also seems to be some problem with overmodulation sometimes, maybe something is wrong with input biasing or fir coefficients or whatnot. Not sure exactly since when this problem exists, depending on the channel it's not noticeable. Maybe I'll need to look at those quasi peak registers to see what's going on ;-).


Roland
P.S: actually, can't you test this code on a msp3410d? IIRC the d versions could be programmed like the c versions if you wanted. I might remember that wrong though...


diff -ur ./linux/drivers/media/video/msp3400-driver.c ../hg-v4l-dvb-5cebd12ccb8f/linux/drivers/media/video/msp3400-driver.c
--- ./linux/drivers/media/video/msp3400-driver.c	2006-03-29 23:30:23.000000000 +0200
+++ ../hg-v4l-dvb-5cebd12ccb8f/linux/drivers/media/video/msp3400-driver.c	2006-03-29 21:48:21.000000000 +0200
 (at)  (at)  -675,6 +675,7  (at)  (at) 
 
 		if (va->mode != 0 && state->radio == 0) {
 			state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
+		v4l_dbg(3, msp_debug, client, "setting v4l1_to_v4l2 audmode %d to %d\n", va->mode, state->audmode);
 			msp_set_audmode(client);
 		}
 		break;
diff -ur ./linux/drivers/media/video/msp3400-kthreads.c ../hg-v4l-dvb-5cebd12ccb8f/linux/drivers/media/video/msp3400-kthreads.c
--- ./linux/drivers/media/video/msp3400-kthreads.c	2006-03-29 23:30:19.000000000 +0200
+++ ../hg-v4l-dvb-5cebd12ccb8f/linux/drivers/media/video/msp3400-kthreads.c	2006-03-29 23:14:24.000000000 +0200
 (at)  (at)  -256,6 +256,11  (at)  (at) 
 	if (audmode == V4L2_TUNER_MODE_LANG1 &&
 	    (state->rxsubchans & V4L2_TUNER_SUB_STEREO)) 
 		audmode = V4L2_TUNER_MODE_STEREO;
+	/* that covers just stereo->mono switching. Someone may want to use stereo
+	   to capture both lang1 and lang2 though LANG1_LANG2 should be used for that */
+	if (audmode == V4L2_TUNER_MODE_STEREO &&
+		((state->rxsubchans & V4L2_TUNER_SUB_MONO) == V4L2_TUNER_SUB_MONO))
+		audmode = V4L2_TUNER_MODE_MONO;
 
 	/* switch demodulator */
 	switch (state->mode) {
 (at)  (at)  -428,6 +433,13  (at)  (at) 
 		v4l_dbg(1, msp_debug, client, "watch: rxsubchans %02x => %02x\n",
 			state->rxsubchans, rxsubchans);
 		state->rxsubchans = rxsubchans;
+		/* need this since communication between bttv and msp is done with v4l1 ctrls
+		   and a program asking for the current audio mode with vidioc_g_tuner WILL ALWAYS
+		   GET STEREO AS ANSWER even though the sound actually gets set to mono probably
+		   because of the same v4l1-v4l2 translation somewhere when channel switching. */
+		if (rxsubchans == V4L2_TUNER_SUB_STEREO) {
+			state->audmode = V4L2_TUNER_MODE_STEREO;
+		}
 	}
 	if (newnicam != state->nicam_on) {
 		update = 1;
 (at)  (at)  -573,7 +585,6  (at)  (at) 
 				/* B/G NICAM */
 				state->second = msp3400c_carrier_detect_55[max2].cdo;
 				msp3400c_set_mode(client, MSP_MODE_FM_NICAM1);
-				msp3400c_set_carrier(client, state->second, state->main);
 				state->nicam_on = 1;
 				state->watch_stereo = 1;
 			} else {
 (at)  (at)  -584,7 +595,6  (at)  (at) 
 			/* PAL I NICAM */
 			state->second = MSP_CARRIER(6.552);
 			msp3400c_set_mode(client, MSP_MODE_FM_NICAM2);
-			msp3400c_set_carrier(client, state->second, state->main);
 			state->nicam_on = 1;
 			state->watch_stereo = 1;
 			break;
 (at)  (at)  -598,13 +608,11  (at)  (at) 
 				/* L NICAM or AM-mono */
 				state->second = msp3400c_carrier_detect_65[max2].cdo;
 				msp3400c_set_mode(client, MSP_MODE_AM_NICAM);
-				msp3400c_set_carrier(client, state->second, state->main);
 				state->watch_stereo = 1;
 			} else if (max2 == 0 && state->has_nicam) {
 				/* D/K NICAM */
 				state->second = msp3400c_carrier_detect_65[max2].cdo;
 				msp3400c_set_mode(client, MSP_MODE_FM_NICAM1);
-				msp3400c_set_carrier(client, state->second, state->main);
 				state->nicam_on = 1;
 				state->watch_stereo = 1;
 			} else {
 (at)  (at)  -616,10 +624,10  (at)  (at) 
 		no_second:
 			state->second = msp3400c_carrier_detect_main[max1].cdo;
 			msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
-			msp3400c_set_carrier(client, state->second, state->main);
 			state->rxsubchans = V4L2_TUNER_SUB_MONO;
 			break;
 		}
+		msp3400c_set_carrier(client, state->second, state->main);
 
 		/* unmute */
 		msp_set_audio(client);
 (at)  (at)  -629,8 +637,9  (at)  (at) 
 			msp3400c_print_mode(client);
 
 		/* monitor tv audio mode, the first time don't wait
-		   so long to get a quick stereo/bilingual result */
-		if (msp_sleep(state, 1000))
+		   so long to get a quick stereo/bilingual result
+		   1 second doesn't seem to be quite enough always */
+		if (msp_sleep(state, 2000))
 			goto restart;
 		while (state->watch_stereo) {
 			watch_stereo(client);
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request (at) redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list