aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-driver.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2006-03-30 17:50:34 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-04-02 03:56:06 -0400
commit0020d3ef915fc01a0184bc96eeb3c240bded5d8e (patch)
tree89685985691405ae3c407b699a1f8cefa19425ce /drivers/media/video/msp3400-driver.c
parent9bc7400a9d01b1fe05c7f0200e7384e17794f6e4 (diff)
V4L/DVB (3693): Fix msp3400c and bttv stereo/mono/bilingual detection/handling
- msp3400c did not detect the second carrier, thus being always mono. - properly mute the msp3400c while detecting the carrier. - fix checks on the presence of scart2/3 inputs and scart 2 output. - implement proper audio mode fallbacks for msp3400c/d, identical to the way msp3400g works. - MODE_STEREO no longer produces dual languages when set for a bilingual transmission, instead it falls back to LANG1. Use LANG1_LANG2 to hear both languages of a bilingual transmission. This is much more intuitive for the user and is in accordance with the preferred usage in the v4l2 specification. - bttv tried to implement v4l2 calls with v4l1 calls to the i2c devices, completely mangling the audmode/rxsubchans handling. v4l2 calls now do v4l2 calls to the i2c devices. - fixed broken i2c_vidiocschan in bttv. - add start/end lines to LOG_STATUS. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/msp3400-driver.c')
-rw-r--r--drivers/media/video/msp3400-driver.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 12a83ec7872..027c3d35eaa 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -283,19 +283,6 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
283 msp_write_dem(client, 0x40, state->i2s_mode); 283 msp_write_dem(client, 0x40, state->i2s_mode);
284} 284}
285 285
286void msp_set_mute(struct i2c_client *client)
287{
288 struct msp_state *state = i2c_get_clientdata(client);
289
290 v4l_dbg(1, msp_debug, client, "mute audio\n");
291 msp_write_dsp(client, 0x0000, 0);
292 msp_write_dsp(client, 0x0007, 1);
293 if (state->has_scart2_out_volume)
294 msp_write_dsp(client, 0x0040, 1);
295 if (state->has_headphones)
296 msp_write_dsp(client, 0x0006, 0);
297}
298
299void msp_set_audio(struct i2c_client *client) 286void msp_set_audio(struct i2c_client *client)
300{ 287{
301 struct msp_state *state = i2c_get_clientdata(client); 288 struct msp_state *state = i2c_get_clientdata(client);
@@ -347,7 +334,6 @@ static void msp_wake_thread(struct i2c_client *client)
347 334
348 if (NULL == state->kthread) 335 if (NULL == state->kthread)
349 return; 336 return;
350 msp_set_mute(client);
351 state->watch_stereo = 0; 337 state->watch_stereo = 0;
352 state->restart = 1; 338 state->restart = 1;
353 wake_up_interruptible(&state->wq); 339 wake_up_interruptible(&state->wq);
@@ -375,19 +361,15 @@ int msp_sleep(struct msp_state *state, int timeout)
375 361
376/* ------------------------------------------------------------------------ */ 362/* ------------------------------------------------------------------------ */
377 363
378static int msp_mode_v4l2_to_v4l1(int rxsubchans) 364static int msp_mode_v4l2_to_v4l1(int rxsubchans, int audmode)
379{ 365{
380 int mode = 0; 366 if (rxsubchans == V4L2_TUNER_SUB_MONO)
381 367 return VIDEO_SOUND_MONO;
382 if (rxsubchans & V4L2_TUNER_SUB_STEREO) 368 if (rxsubchans == V4L2_TUNER_SUB_STEREO)
383 mode |= VIDEO_SOUND_STEREO; 369 return VIDEO_SOUND_STEREO;
384 if (rxsubchans & V4L2_TUNER_SUB_LANG2) 370 if (audmode == V4L2_TUNER_MODE_LANG2)
385 mode |= VIDEO_SOUND_LANG2 | VIDEO_SOUND_STEREO; 371 return VIDEO_SOUND_LANG2;
386 if (rxsubchans & V4L2_TUNER_SUB_LANG1) 372 return VIDEO_SOUND_LANG1;
387 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_STEREO;
388 if (mode == 0)
389 mode |= VIDEO_SOUND_MONO;
390 return mode;
391} 373}
392 374
393static int msp_mode_v4l1_to_v4l2(int mode) 375static int msp_mode_v4l1_to_v4l2(int mode)
@@ -606,7 +588,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
606 break; 588 break;
607 if (state->opmode == OPMODE_AUTOSELECT) 589 if (state->opmode == OPMODE_AUTOSELECT)
608 msp_detect_stereo(client); 590 msp_detect_stereo(client);
609 va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans); 591 va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans, state->audmode);
610 break; 592 break;
611 } 593 }
612 594
@@ -621,7 +603,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
621 state->treble = va->treble; 603 state->treble = va->treble;
622 msp_set_audio(client); 604 msp_set_audio(client);
623 605
624 if (va->mode != 0 && state->radio == 0) { 606 if (va->mode != 0 && state->radio == 0 &&
607 state->audmode != msp_mode_v4l1_to_v4l2(va->mode)) {
625 state->audmode = msp_mode_v4l1_to_v4l2(va->mode); 608 state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
626 msp_set_audmode(client); 609 msp_set_audmode(client);
627 } 610 }
@@ -727,6 +710,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
727 710
728 if (state->radio) /* TODO: add mono/stereo support for radio */ 711 if (state->radio) /* TODO: add mono/stereo support for radio */
729 break; 712 break;
713 if (state->audmode == vt->audmode)
714 break;
730 state->audmode = vt->audmode; 715 state->audmode = vt->audmode;
731 /* only set audmode */ 716 /* only set audmode */
732 msp_set_audmode(client); 717 msp_set_audmode(client);
@@ -888,7 +873,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
888 873
889 memset(state, 0, sizeof(*state)); 874 memset(state, 0, sizeof(*state));
890 state->v4l2_std = V4L2_STD_NTSC; 875 state->v4l2_std = V4L2_STD_NTSC;
891 state->audmode = V4L2_TUNER_MODE_LANG1; 876 state->audmode = V4L2_TUNER_MODE_STEREO;
892 state->volume = 58880; /* 0db gain */ 877 state->volume = 58880; /* 0db gain */
893 state->balance = 32768; /* 0db gain */ 878 state->balance = 32768; /* 0db gain */
894 state->bass = 32768; 879 state->bass = 32768;
@@ -932,13 +917,16 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
932 state->has_radio = msp_revision >= 'G'; 917 state->has_radio = msp_revision >= 'G';
933 /* Has headphones output: not for stripped down products */ 918 /* Has headphones output: not for stripped down products */
934 state->has_headphones = msp_prod_lo < 5; 919 state->has_headphones = msp_prod_lo < 5;
920 /* Has scart2 input: not in stripped down products of the '3' family */
921 state->has_scart2 = msp_family >= 4 || msp_prod_lo < 7;
922 /* Has scart3 input: not in stripped down products of the '3' family */
923 state->has_scart3 = msp_family >= 4 || msp_prod_lo < 5;
935 /* Has scart4 input: not in pre D revisions, not in stripped D revs */ 924 /* Has scart4 input: not in pre D revisions, not in stripped D revs */
936 state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5); 925 state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5);
937 /* Has scart2 and scart3 inputs and scart2 output: not in stripped 926 /* Has scart2 output: not in stripped down products of the '3' family */
938 down products of the '3' family */ 927 state->has_scart2_out = msp_family >= 4 || msp_prod_lo < 5;
939 state->has_scart23_in_scart2_out = msp_family >= 4 || msp_prod_lo < 5;
940 /* Has scart2 a volume control? Not in pre-D revisions. */ 928 /* Has scart2 a volume control? Not in pre-D revisions. */
941 state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart23_in_scart2_out; 929 state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart2_out;
942 /* Has a configurable i2s out? */ 930 /* Has a configurable i2s out? */
943 state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7; 931 state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7;
944 /* Has subwoofer output: not in pre-D revs and not in stripped down products */ 932 /* Has subwoofer output: not in pre-D revs and not in stripped down products */