diff options
Diffstat (limited to 'drivers/media/video/tvaudio.c')
-rw-r--r-- | drivers/media/video/tvaudio.c | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 4cc0497..15fd55f 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; |