aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-kthreads.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2006-01-09 15:21:36 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 15:21:36 -0500
commitd312a46e5340be6a89c662ac483230c0737148c9 (patch)
tree4d458407ce0baaf613360c4b0866e9f96b5d5df3 /drivers/media/video/msp3400-kthreads.c
parent1157020d542684e273242663d0befb58e284ade7 (diff)
V4L/DVB (3324): msp3400 audio handling bug fixes.
- Check capabilities for audio settings (volume, balance, bass, treble, loudness, mute) - added loudness support - added missing VIDEO_AUDIO_BALANCE flags for v4l1 compatibility - do not call msp_any_detect_stereo for non-autoselect chips to retrieve the current stereo setting: that will temporarily mute the sound. It is only needed when the stereo mode might be changed, and for autoselect msp processors that do not periodically need to update their stereo setting. - do not wake up the thread if the standard did not change. Prevents temporary audio drop-out if the standard is set to the same value. - fix confused stereo detect code where V4L2_TUNER_SUB_STEREO and V4L2_TUNER_MODE_STEREO values were used incorrectly. - stereo mode reporting was broken (v4l2 value used to index a string array expecting v4l1 mode values). - do not set dsp register 0x30 in the 3410d thread: that register does not exist for pre-'G' revision msp chips. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/video/msp3400-kthreads.c')
-rw-r--r--drivers/media/video/msp3400-kthreads.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 4ecbf56b008e..14a425a6ff85 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -209,24 +209,10 @@ void msp3400c_setmode(struct i2c_client *client, int type)
209 } 209 }
210} 210}
211 211
212/* given a bitmask of VIDEO_SOUND_XXX returns the "best" in the bitmask */
213static int msp3400c_best_video_sound(int rxsubchans)
214{
215 if (rxsubchans & V4L2_TUNER_SUB_STEREO)
216 return V4L2_TUNER_MODE_STEREO;
217 if (rxsubchans & V4L2_TUNER_SUB_LANG1)
218 return V4L2_TUNER_MODE_LANG1;
219 if (rxsubchans & V4L2_TUNER_SUB_LANG2)
220 return V4L2_TUNER_MODE_LANG2;
221 return V4L2_TUNER_MODE_MONO;
222}
223
224/* turn on/off nicam + stereo */ 212/* turn on/off nicam + stereo */
225void msp3400c_setstereo(struct i2c_client *client, int mode) 213void msp3400c_setstereo(struct i2c_client *client, int mode)
226{ 214{
227 static char *strmode[] = { "0", "mono", "stereo", "3", 215 static char *strmode[] = { "mono", "stereo", "lang2", "lang1" };
228 "lang1", "5", "6", "7", "lang2"
229 };
230 struct msp_state *state = i2c_get_clientdata(client); 216 struct msp_state *state = i2c_get_clientdata(client);
231 int nicam = 0; /* channel source: FM/AM or nicam */ 217 int nicam = 0; /* channel source: FM/AM or nicam */
232 int src = 0; 218 int src = 0;
@@ -244,7 +230,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
244 switch (state->mode) { 230 switch (state->mode) {
245 case MSP_MODE_FM_TERRA: 231 case MSP_MODE_FM_TERRA:
246 v4l_dbg(1, client, "FM setstereo: %s\n", strmode[mode]); 232 v4l_dbg(1, client, "FM setstereo: %s\n", strmode[mode]);
247 msp3400c_setcarrier(client,state->second,state->main); 233 msp3400c_setcarrier(client, state->second, state->main);
248 switch (mode) { 234 switch (mode) {
249 case V4L2_TUNER_MODE_STEREO: 235 case V4L2_TUNER_MODE_STEREO:
250 msp_write_dsp(client, 0x000e, 0x3001); 236 msp_write_dsp(client, 0x000e, 0x3001);
@@ -298,7 +284,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
298 } 284 }
299 285
300 /* switch audio */ 286 /* switch audio */
301 switch (msp3400c_best_video_sound(mode)) { 287 switch (mode) {
302 case V4L2_TUNER_MODE_STEREO: 288 case V4L2_TUNER_MODE_STEREO:
303 src = 0x0020 | nicam; 289 src = 0x0020 | nicam;
304 break; 290 break;
@@ -330,6 +316,9 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
330 msp_write_dsp(client, 0x0009, src); 316 msp_write_dsp(client, 0x0009, src);
331 msp_write_dsp(client, 0x000a, src); 317 msp_write_dsp(client, 0x000a, src);
332 msp_write_dsp(client, 0x000b, src); 318 msp_write_dsp(client, 0x000b, src);
319 msp_write_dsp(client, 0x000c, src);
320 if (state->has_scart23_in_scart2_out)
321 msp_write_dsp(client, 0x0041, src);
333 } 322 }
334} 323}
335 324
@@ -455,9 +444,9 @@ static void watch_stereo(struct i2c_client *client)
455 struct msp_state *state = i2c_get_clientdata(client); 444 struct msp_state *state = i2c_get_clientdata(client);
456 445
457 if (autodetect_stereo(client)) { 446 if (autodetect_stereo(client)) {
458 if (state->stereo & V4L2_TUNER_MODE_STEREO) 447 if (state->rxsubchans & V4L2_TUNER_SUB_STEREO)
459 msp3400c_setstereo(client, V4L2_TUNER_MODE_STEREO); 448 msp3400c_setstereo(client, V4L2_TUNER_MODE_STEREO);
460 else if (state->stereo & VIDEO_SOUND_LANG1) 449 else if (state->rxsubchans & V4L2_TUNER_SUB_LANG1)
461 msp3400c_setstereo(client, V4L2_TUNER_MODE_LANG1); 450 msp3400c_setstereo(client, V4L2_TUNER_MODE_LANG1);
462 else 451 else
463 msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 452 msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO);
@@ -657,7 +646,7 @@ int msp3410d_thread(void *data)
657{ 646{
658 struct i2c_client *client = data; 647 struct i2c_client *client = data;
659 struct msp_state *state = i2c_get_clientdata(client); 648 struct msp_state *state = i2c_get_clientdata(client);
660 int mode,val,i,std; 649 int val, i, std;
661 650
662 v4l_dbg(1, client, "msp3410 daemon started\n"); 651 v4l_dbg(1, client, "msp3410 daemon started\n");
663 652
@@ -687,10 +676,11 @@ int msp3410d_thread(void *data)
687 goto restart; 676 goto restart;
688 677
689 /* start autodetect */ 678 /* start autodetect */
690 mode = msp_modus(client); 679 std = 1;
691 std = (state->std & V4L2_STD_NTSC) ? 0x20 : 1; 680 if (state->std & V4L2_STD_NTSC)
692 msp_write_dem(client, 0x30, mode); 681 std = 0x20;
693 msp_write_dem(client, 0x20, std); 682 else
683 msp_write_dem(client, 0x20, std);
694 state->watch_stereo = 0; 684 state->watch_stereo = 0;
695 685
696 if (debug) 686 if (debug)
@@ -703,7 +693,7 @@ int msp3410d_thread(void *data)
703 } else { 693 } else {
704 /* triggered autodetect */ 694 /* triggered autodetect */
705 for (;;) { 695 for (;;) {
706 if (msp_sleep(state,100)) 696 if (msp_sleep(state, 100))
707 goto restart; 697 goto restart;
708 698
709 /* check results */ 699 /* check results */