aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/tvaudio.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2006-03-18 21:31:00 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-03-24 16:26:56 -0300
commit8bf2f8e747700419cc5bbc56c4496774eb8f2f1f (patch)
tree94e9b7e99d2e95d4515d48247ce549540374a989 /drivers/media/video/tvaudio.c
parentae62e3d4a8194680023b47ab778bf1dcea8d6b42 (diff)
V4L/DVB (3577): Cleanup audio input handling
Cleanup audio input handling in bttv and tvaudio: - inputs were specified that were never used - mute was handled as a special input which led to confusing code - confusing naming made it difficult to see if the setting was for i2c or gpio. The old audiochip.h input names moved to tvaudio.h. Currently this is used both by tvaudio and msp3400 until the msp3400 implements the new msp3400-specific inputs. Detect in bttv the tvaudio and msp3400 i2c clients and use these client pointers to set the inputs directly instead of broadcasting the command. Removed AUDC_SET_INPUT. Now replaced by VIDIOC_S_AUDIO. This will be replaced again later by the new ROUTING commands. Removed VIDIOC_G_AUDIO implementations in i2c drivers: this command is a user level command and not to be used internally. It wasn't called at all anyway. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tvaudio.c')
-rw-r--r--drivers/media/video/tvaudio.c67
1 files changed, 48 insertions, 19 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 4cc0497dcbd..15fd55ff69c 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -30,7 +30,7 @@
#include <linux/init.h>
#include <linux/smp_lock.h>
-#include <media/audiochip.h>
+#include <media/tvaudio.h>
#include <media/v4l2-common.h>
#include <media/i2c-addr.h>
@@ -102,7 +102,7 @@ struct CHIPDESC {
/* input switch register + values for v4l inputs */
int inputreg;
- int inputmap[8];
+ int inputmap[4];
int inputmute;
int inputmask;
};
@@ -119,9 +119,10 @@ struct CHIPSTATE {
audiocmd shadow;
/* current settings */
- __u16 left,right,treble,bass,mode;
+ __u16 left,right,treble,bass,muted,mode;
int prevmode;
int radio;
+ int input;
/* thread */
pid_t tpid;
@@ -1101,9 +1102,8 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; }
static int tda8425_initialize(struct CHIPSTATE *chip)
{
struct CHIPDESC *desc = chiplist + chip->type;
- int inputmap[8] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
- /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF,
- /* off */ TDA8425_S1_OFF, /* on */ TDA8425_S1_CH2};
+ int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
+ /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF};
if (chip->c.adapter->id == I2C_HW_B_RIVA) {
memcpy (desc->inputmap, inputmap, sizeof (inputmap));
@@ -1298,7 +1298,7 @@ static struct CHIPDESC chiplist[] = {
.init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } },
.inputreg = TDA9873_SW,
.inputmute = TDA9873_MUTE | TDA9873_AUTOMUTE,
- .inputmap = {0xa0, 0xa2, 0xa0, 0xa0, 0xc0},
+ .inputmap = {0xa0, 0xa2, 0xa0, 0xa0},
.inputmask = TDA9873_INP_MASK|TDA9873_MUTE|TDA9873_AUTOMUTE,
},
@@ -1446,8 +1446,7 @@ static struct CHIPDESC chiplist[] = {
.inputmap = {PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_TUNER,
PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE,
PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE,
- PIC16C54_MISC_SND_MUTE,PIC16C54_MISC_SND_MUTE,
- PIC16C54_MISC_SND_NOTMUTE},
+ PIC16C54_MISC_SND_MUTE},
.inputmute = PIC16C54_MISC_SND_MUTE,
},
{
@@ -1583,28 +1582,40 @@ static int chip_detach(struct i2c_client *client)
return 0;
}
+static int tvaudio_set_ctrl(struct CHIPSTATE *chip, struct v4l2_control *ctrl)
+{
+ struct CHIPDESC *desc = chiplist + chip->type;
+
+ switch (ctrl->id) {
+ case V4L2_CID_AUDIO_MUTE:
+ if (ctrl->value < 0 || ctrl->value >= 2)
+ return -ERANGE;
+ chip->muted = ctrl->value;
+ if (chip->muted)
+ chip_write_masked(chip,desc->inputreg,desc->inputmute,desc->inputmask);
+ else
+ chip_write_masked(chip,desc->inputreg,
+ desc->inputmap[chip->input],desc->inputmask);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+
/* ---------------------------------------------------------------------- */
/* video4linux interface */
static int chip_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
- __u16 *sarg = arg;
struct CHIPSTATE *chip = i2c_get_clientdata(client);
struct CHIPDESC *desc = chiplist + chip->type;
v4l_dbg(1, debug, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd);
switch (cmd) {
- case AUDC_SET_INPUT:
- if (desc->flags & CHIP_HAS_INPUTSEL) {
- if (*sarg & 0x80)
- chip_write_masked(chip,desc->inputreg,desc->inputmute,desc->inputmask);
- else
- chip_write_masked(chip,desc->inputreg,desc->inputmap[*sarg],desc->inputmask);
- }
- break;
-
case AUDC_SET_RADIO:
chip->radio = 1;
chip->watch_stereo = 0;
@@ -1668,6 +1679,24 @@ static int chip_command(struct i2c_client *client,
break;
}
+ case VIDIOC_S_CTRL:
+ return tvaudio_set_ctrl(chip, arg);
+
+ case VIDIOC_S_AUDIO:
+ {
+ struct v4l2_audio *sarg = arg;
+
+ if (!(desc->flags & CHIP_HAS_INPUTSEL) || sarg->index >= 4)
+ return -EINVAL;
+ /* There are four inputs: tuner, radio, extern and intern. */
+ chip->input = sarg->index;
+ if (chip->muted)
+ break;
+ chip_write_masked(chip, desc->inputreg,
+ desc->inputmap[chip->input], desc->inputmask);
+ break;
+ }
+
case VIDIOC_S_TUNER:
{
struct v4l2_tuner *vt = arg;