Commit 93605351 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (3246): Use VIDIOC_S_AUDIO instead of AUDC_SET_INPUT in cs53l32a


- Replace AUDC_SET_INPUT with VIDIOC_S_AUDIO.
- Added V4L2_CID_AUDIO_MUTE.
- Minimum volume is -96 dB, not -90.
- Show volume in VIDIOC_LOG_STATUS.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@brturbo.com.br>
parent a544521e
...@@ -74,50 +74,59 @@ static int cs53l32a_read(struct i2c_client *client, u8 reg) ...@@ -74,50 +74,59 @@ static int cs53l32a_read(struct i2c_client *client, u8 reg)
static int cs53l32a_command(struct i2c_client *client, unsigned int cmd, static int cs53l32a_command(struct i2c_client *client, unsigned int cmd,
void *arg) void *arg)
{ {
int *input = arg; struct v4l2_audio *input = arg;
struct v4l2_control *ctrl = arg;
switch (cmd) { switch (cmd) {
case AUDC_SET_INPUT: case VIDIOC_S_AUDIO:
switch (*input) { /* There are 2 physical inputs, but the second input can be
case AUDIO_TUNER: placed in two modes, the first mode bypasses the PGA (gain),
cs53l32a_write(client, 0x01, 0x01); the second goes through the PGA. Hence there are three
break; possible inputs to choose from. */
case AUDIO_EXTERN: if (input->index > 2) {
cs53l32a_write(client, 0x01, 0x21); cs53l32a_err("Invalid input %d.\n", input->index);
break;
case AUDIO_MUTE:
cs53l32a_write(client, 0x03, 0xF0);
break;
case AUDIO_UNMUTE:
cs53l32a_write(client, 0x03, 0x30);
break;
default:
cs53l32a_err("Invalid input %d.\n", *input);
return -EINVAL; return -EINVAL;
} }
cs53l32a_write(client, 0x01, 0x01 + (input->index << 4));
break;
case VIDIOC_G_AUDIO:
memset(input, 0, sizeof(*input));
input->index = (cs53l32a_read(client, 0x01) >> 4) & 3;
break;
case VIDIOC_G_CTRL:
if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
ctrl->value = (cs53l32a_read(client, 0x03) & 0xc0) != 0;
break;
}
if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
return -EINVAL;
ctrl->value = (s8)cs53l32a_read(client, 0x04);
break; break;
case VIDIOC_S_CTRL: case VIDIOC_S_CTRL:
{ if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
struct v4l2_control *ctrl = arg; cs53l32a_write(client, 0x03, ctrl->value ? 0xf0 : 0x30);
if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
return -EINVAL;
if (ctrl->value > 12 || ctrl->value < -90)
return -EINVAL;
cs53l32a_write(client, 0x04, (u8) ctrl->value);
cs53l32a_write(client, 0x05, (u8) ctrl->value);
break; break;
} }
if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
return -EINVAL;
if (ctrl->value > 12 || ctrl->value < -96)
return -EINVAL;
cs53l32a_write(client, 0x04, (u8) ctrl->value);
cs53l32a_write(client, 0x05, (u8) ctrl->value);
break;
case VIDIOC_LOG_STATUS: case VIDIOC_LOG_STATUS:
{ {
u8 v = cs53l32a_read(client, 0x01); u8 v = cs53l32a_read(client, 0x01);
u8 m = cs53l32a_read(client, 0x03); u8 m = cs53l32a_read(client, 0x03);
s8 vol = cs53l32a_read(client, 0x04);
cs53l32a_info("Input: %s%s\n", cs53l32a_info("Input: %d%s\n", (v >> 4) & 3,
v == 0x21 ? "external line in" : "tuner",
(m & 0xC0) ? " (muted)" : ""); (m & 0xC0) ? " (muted)" : "");
cs53l32a_info("Volume: %d dB\n", vol);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment