diff options
author | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2005-11-09 00:38:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:30 -0500 |
commit | eac94356c8f9f7d3854ed0290a406b13bfe8df4c (patch) | |
tree | 5dd31d7ecbb1d0d857972478a322ccb838dd668c /drivers/media/video/msp3400.c | |
parent | c3d931929f1d11f9d198567850247ae1754dfc06 (diff) |
[PATCH] V4L: 907: em28xx cleanups and fixes
- Em28xx cleanups and fixes.
- Some cleanups and audio amux adjust.
- em28xx will allways try, by default, the biggest size alt.
- Fixes audio mux code.
- Fixes some logs.
- Adds support for digital output for WinTV USB2 board.
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/msp3400.c')
-rw-r--r-- | drivers/media/video/msp3400.c | 142 |
1 files changed, 129 insertions, 13 deletions
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index d603229c9f2f..b599f0554fb7 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c | |||
@@ -90,6 +90,8 @@ struct msp3400c { | |||
90 | int stereo; | 90 | int stereo; |
91 | int nicam_on; | 91 | int nicam_on; |
92 | int acb; | 92 | int acb; |
93 | int in_scart; | ||
94 | int i2s_mode; | ||
93 | int main, second; /* sound carrier */ | 95 | int main, second; /* sound carrier */ |
94 | int input; | 96 | int input; |
95 | int source; /* see msp34xxg_set_source */ | 97 | int source; /* see msp34xxg_set_source */ |
@@ -364,12 +366,40 @@ static struct CARRIER_DETECT carrier_detect_65[] = { | |||
364 | 366 | ||
365 | #define CARRIER_COUNT(x) (sizeof(x)/sizeof(struct CARRIER_DETECT)) | 367 | #define CARRIER_COUNT(x) (sizeof(x)/sizeof(struct CARRIER_DETECT)) |
366 | 368 | ||
367 | /* ----------------------------------------------------------------------- */ | 369 | /* ----------------------------------------------------------------------- * |
370 | * bits 9 8 5 - SCART DSP input Select: | ||
371 | * 0 0 0 - SCART 1 to DSP input (reset position) | ||
372 | * 0 1 0 - MONO to DSP input | ||
373 | * 1 0 0 - SCART 2 to DSP input | ||
374 | * 1 1 1 - Mute DSP input | ||
375 | * | ||
376 | * bits 11 10 6 - SCART 1 Output Select: | ||
377 | * 0 0 0 - undefined (reset position) | ||
378 | * 0 1 0 - SCART 2 Input to SCART 1 Output (for devices with 2 SCARTS) | ||
379 | * 1 0 0 - MONO input to SCART 1 Output | ||
380 | * 1 1 0 - SCART 1 DA to SCART 1 Output | ||
381 | * 0 0 1 - SCART 2 DA to SCART 1 Output | ||
382 | * 0 1 1 - SCART 1 Input to SCART 1 Output | ||
383 | * 1 1 1 - Mute SCART 1 Output | ||
384 | * | ||
385 | * bits 13 12 7 - SCART 2 Output Select (for devices with 2 Output SCART): | ||
386 | * 0 0 0 - SCART 1 DA to SCART 2 Output (reset position) | ||
387 | * 0 1 0 - SCART 1 Input to SCART 2 Output | ||
388 | * 1 0 0 - MONO input to SCART 2 Output | ||
389 | * 0 0 1 - SCART 2 DA to SCART 2 Output | ||
390 | * 0 1 1 - SCART 2 Input to SCART 2 Output | ||
391 | * 1 1 0 - Mute SCART 2 Output | ||
392 | * | ||
393 | * Bits 4 to 0 should be zero. | ||
394 | * ----------------------------------------------------------------------- */ | ||
368 | 395 | ||
369 | static int scarts[3][9] = { | 396 | static int scarts[3][9] = { |
370 | /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */ | 397 | /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */ |
398 | /* SCART DSP Input select */ | ||
371 | { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 }, | 399 | { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 }, |
400 | /* SCART1 Output select */ | ||
372 | { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 }, | 401 | { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 }, |
402 | /* SCART2 Output select */ | ||
373 | { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 }, | 403 | { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 }, |
374 | }; | 404 | }; |
375 | 405 | ||
@@ -381,13 +411,23 @@ static void msp3400c_set_scart(struct i2c_client *client, int in, int out) | |||
381 | { | 411 | { |
382 | struct msp3400c *msp = i2c_get_clientdata(client); | 412 | struct msp3400c *msp = i2c_get_clientdata(client); |
383 | 413 | ||
384 | if (-1 == scarts[out][in]) | 414 | msp->in_scart=in; |
385 | return; | 415 | |
416 | if (in<=2) { | ||
417 | if (-1 == scarts[out][in]) | ||
418 | return; | ||
419 | |||
420 | msp->acb &= ~scarts[out][SCART_MASK]; | ||
421 | msp->acb |= scarts[out][in]; | ||
422 | } else | ||
423 | msp->acb = 0xf60; /* Mute Input and SCART 1 Output */ | ||
424 | |||
425 | dprintk("msp34xx: scart switch: %s => %d (ACB=0x%04x)\n", | ||
426 | scart_names[in], out, msp->acb); | ||
427 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x13, msp->acb); | ||
386 | 428 | ||
387 | dprintk("msp34xx: scart switch: %s => %d\n", scart_names[in], out); | 429 | /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */ |
388 | msp->acb &= ~scarts[out][SCART_MASK]; | 430 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); |
389 | msp->acb |= scarts[out][in]; | ||
390 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0013, msp->acb); | ||
391 | } | 431 | } |
392 | 432 | ||
393 | /* ------------------------------------------------------------------------ */ | 433 | /* ------------------------------------------------------------------------ */ |
@@ -1235,7 +1275,8 @@ static int msp3410d_thread(void *data) | |||
1235 | msp3400c_setbass(client, msp->bass); | 1275 | msp3400c_setbass(client, msp->bass); |
1236 | msp3400c_settreble(client, msp->treble); | 1276 | msp3400c_settreble(client, msp->treble); |
1237 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); | 1277 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); |
1238 | msp3400c_write(client, I2C_MSP3400C_DFP, 0x0013, msp->acb); | 1278 | msp3400c_write(client, I2C_MSP3400C_DFP, 0x13, msp->acb); |
1279 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); | ||
1239 | msp3400c_restore_dfp(client); | 1280 | msp3400c_restore_dfp(client); |
1240 | 1281 | ||
1241 | /* monitor tv audio mode */ | 1282 | /* monitor tv audio mode */ |
@@ -1275,6 +1316,8 @@ static int msp34xxg_reset(struct i2c_client *client) | |||
1275 | 0x0f20 /* mute DSP input, mute SCART 1 */)) | 1316 | 0x0f20 /* mute DSP input, mute SCART 1 */)) |
1276 | return -1; | 1317 | return -1; |
1277 | 1318 | ||
1319 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); | ||
1320 | |||
1278 | /* step-by-step initialisation, as described in the manual */ | 1321 | /* step-by-step initialisation, as described in the manual */ |
1279 | modus = msp34xx_modus(msp->norm); | 1322 | modus = msp34xx_modus(msp->norm); |
1280 | std = msp34xx_standard(msp->norm); | 1323 | std = msp34xx_standard(msp->norm); |
@@ -1371,6 +1414,8 @@ static int msp34xxg_thread(void *data) | |||
1371 | 0x13, /* ACB */ | 1414 | 0x13, /* ACB */ |
1372 | msp->acb)) | 1415 | msp->acb)) |
1373 | return -1; | 1416 | return -1; |
1417 | |||
1418 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); | ||
1374 | } | 1419 | } |
1375 | dprintk("msp34xxg: thread: exit\n"); | 1420 | dprintk("msp34xxg: thread: exit\n"); |
1376 | return 0; | 1421 | return 0; |
@@ -1539,6 +1584,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1539 | msp->treble = 32768; | 1584 | msp->treble = 32768; |
1540 | msp->input = -1; | 1585 | msp->input = -1; |
1541 | msp->muted = 0; | 1586 | msp->muted = 0; |
1587 | msp->i2s_mode = 0; | ||
1542 | for (i = 0; i < DFP_COUNT; i++) | 1588 | for (i = 0; i < DFP_COUNT; i++) |
1543 | msp->dfp_regs[i] = -1; | 1589 | msp->dfp_regs[i] = -1; |
1544 | 1590 | ||
@@ -1735,6 +1781,7 @@ static void msp_any_set_audmode(struct i2c_client *client, int audmode) | |||
1735 | } | 1781 | } |
1736 | } | 1782 | } |
1737 | 1783 | ||
1784 | |||
1738 | static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | 1785 | static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) |
1739 | { | 1786 | { |
1740 | struct msp3400c *msp = i2c_get_clientdata(client); | 1787 | struct msp3400c *msp = i2c_get_clientdata(client); |
@@ -1745,6 +1792,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1745 | 1792 | ||
1746 | case AUDC_SET_INPUT: | 1793 | case AUDC_SET_INPUT: |
1747 | dprintk("msp34xx: AUDC_SET_INPUT(%d)\n",*sarg); | 1794 | dprintk("msp34xx: AUDC_SET_INPUT(%d)\n",*sarg); |
1795 | |||
1748 | if (*sarg == msp->input) | 1796 | if (*sarg == msp->input) |
1749 | break; | 1797 | break; |
1750 | msp->input = *sarg; | 1798 | msp->input = *sarg; |
@@ -1923,6 +1971,16 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1923 | break; | 1971 | break; |
1924 | } | 1972 | } |
1925 | 1973 | ||
1974 | /* msp34xx specific */ | ||
1975 | case MSP_SET_MATRIX: | ||
1976 | { | ||
1977 | struct msp_matrix *mspm = arg; | ||
1978 | |||
1979 | dprintk("msp34xx: MSP_SET_MATRIX\n"); | ||
1980 | msp3400c_set_scart(client, mspm->input, mspm->output); | ||
1981 | break; | ||
1982 | } | ||
1983 | |||
1926 | /* --- v4l2 ioctls --- */ | 1984 | /* --- v4l2 ioctls --- */ |
1927 | case VIDIOC_S_STD: | 1985 | case VIDIOC_S_STD: |
1928 | { | 1986 | { |
@@ -1941,6 +1999,33 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1941 | return 0; | 1999 | return 0; |
1942 | } | 2000 | } |
1943 | 2001 | ||
2002 | case VIDIOC_ENUMINPUT: | ||
2003 | { | ||
2004 | struct v4l2_input *i = arg; | ||
2005 | |||
2006 | if (i->index != 0) | ||
2007 | return -EINVAL; | ||
2008 | |||
2009 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
2010 | switch (i->index) { | ||
2011 | case AUDIO_RADIO: | ||
2012 | strcpy(i->name,"Radio"); | ||
2013 | break; | ||
2014 | case AUDIO_EXTERN_1: | ||
2015 | strcpy(i->name,"Extern 1"); | ||
2016 | break; | ||
2017 | case AUDIO_EXTERN_2: | ||
2018 | strcpy(i->name,"Extern 2"); | ||
2019 | break; | ||
2020 | case AUDIO_TUNER: | ||
2021 | strcpy(i->name,"Television"); | ||
2022 | break; | ||
2023 | default: | ||
2024 | return -EINVAL; | ||
2025 | } | ||
2026 | return 0; | ||
2027 | } | ||
2028 | |||
1944 | case VIDIOC_G_AUDIO: | 2029 | case VIDIOC_G_AUDIO: |
1945 | { | 2030 | { |
1946 | struct v4l2_audio *a = arg; | 2031 | struct v4l2_audio *a = arg; |
@@ -2032,13 +2117,44 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
2032 | break; | 2117 | break; |
2033 | } | 2118 | } |
2034 | 2119 | ||
2035 | /* msp34xx specific */ | 2120 | case VIDIOC_G_AUDOUT: |
2036 | case MSP_SET_MATRIX: | ||
2037 | { | 2121 | { |
2038 | struct msp_matrix *mspm = arg; | 2122 | struct v4l2_audioout *a=(struct v4l2_audioout *)arg; |
2123 | |||
2124 | memset(a,0,sizeof(*a)); | ||
2125 | |||
2126 | switch (a->index) { | ||
2127 | case 0: | ||
2128 | strcpy(a->name,"Scart1 Out"); | ||
2129 | break; | ||
2130 | case 1: | ||
2131 | strcpy(a->name,"Scart2 Out"); | ||
2132 | break; | ||
2133 | case 2: | ||
2134 | strcpy(a->name,"I2S Out"); | ||
2135 | break; | ||
2136 | default: | ||
2137 | return -EINVAL; | ||
2138 | } | ||
2139 | break; | ||
2140 | |||
2141 | } | ||
2142 | case VIDIOC_S_AUDOUT: | ||
2143 | { | ||
2144 | struct v4l2_audioout *a=(struct v4l2_audioout *)arg; | ||
2145 | |||
2146 | if (a->index<0||a->index>2) | ||
2147 | return -EINVAL; | ||
2148 | |||
2149 | if (a->index==2) { | ||
2150 | if (a->mode == V4L2_AUDMODE_32BITS) | ||
2151 | msp->i2s_mode=1; | ||
2152 | else | ||
2153 | msp->i2s_mode=0; | ||
2154 | } | ||
2155 | printk("Setting audio out on msp34xx to input %i, mode %i\n",a->index,msp->i2s_mode); | ||
2156 | msp3400c_set_scart(client,msp->in_scart,a->index); | ||
2039 | 2157 | ||
2040 | dprintk("msp34xx: MSP_SET_MATRIX\n"); | ||
2041 | msp3400c_set_scart(client, mspm->input, mspm->output); | ||
2042 | break; | 2158 | break; |
2043 | } | 2159 | } |
2044 | 2160 | ||