Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 17337
b: refs/heads/master
c: 9360535
h: refs/heads/master
i:
  17335: 13c2610
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jan 9, 2006
1 parent 765ee87 commit 3f1d6f5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a544521ef06ee7b8a3d82fa29627401196fda77a
refs/heads/master: 936053516aef6505ab3174c3443f3ba8749d4d98
65 changes: 37 additions & 28 deletions trunk/drivers/media/video/cs53l32a.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
void *arg)
{
int *input = arg;
struct v4l2_audio *input = arg;
struct v4l2_control *ctrl = arg;

switch (cmd) {
case AUDC_SET_INPUT:
switch (*input) {
case AUDIO_TUNER:
cs53l32a_write(client, 0x01, 0x01);
break;
case AUDIO_EXTERN:
cs53l32a_write(client, 0x01, 0x21);
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);
case VIDIOC_S_AUDIO:
/* There are 2 physical inputs, but the second input can be
placed in two modes, the first mode bypasses the PGA (gain),
the second goes through the PGA. Hence there are three
possible inputs to choose from. */
if (input->index > 2) {
cs53l32a_err("Invalid input %d.\n", input->index);
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;

case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl = arg;

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);
if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
cs53l32a_write(client, 0x03, ctrl->value ? 0xf0 : 0x30);
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:
{
u8 v = cs53l32a_read(client, 0x01);
u8 m = cs53l32a_read(client, 0x03);
s8 vol = cs53l32a_read(client, 0x04);

cs53l32a_info("Input: %s%s\n",
v == 0x21 ? "external line in" : "tuner",
cs53l32a_info("Input: %d%s\n", (v >> 4) & 3,
(m & 0xC0) ? " (muted)" : "");
cs53l32a_info("Volume: %d dB\n", vol);
break;
}

Expand Down

0 comments on commit 3f1d6f5

Please sign in to comment.