aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cs53l32a.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2006-01-09 12:25:39 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 12:25:39 -0500
commit936053516aef6505ab3174c3443f3ba8749d4d98 (patch)
treeb8a378f8b8d107b7fa7eb3020663f418fda0a134 /drivers/media/video/cs53l32a.c
parenta544521ef06ee7b8a3d82fa29627401196fda77a (diff)
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: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/video/cs53l32a.c')
-rw-r--r--drivers/media/video/cs53l32a.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index aa31b6736a7a..7d997aeda63e 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -74,50 +74,59 @@ static int cs53l32a_read(struct i2c_client *client, u8 reg)
74static int cs53l32a_command(struct i2c_client *client, unsigned int cmd, 74static int cs53l32a_command(struct i2c_client *client, unsigned int cmd,
75 void *arg) 75 void *arg)
76{ 76{
77 int *input = arg; 77 struct v4l2_audio *input = arg;
78 struct v4l2_control *ctrl = arg;
78 79
79 switch (cmd) { 80 switch (cmd) {
80 case AUDC_SET_INPUT: 81 case VIDIOC_S_AUDIO:
81 switch (*input) { 82 /* There are 2 physical inputs, but the second input can be
82 case AUDIO_TUNER: 83 placed in two modes, the first mode bypasses the PGA (gain),
83 cs53l32a_write(client, 0x01, 0x01); 84 the second goes through the PGA. Hence there are three
84 break; 85 possible inputs to choose from. */
85 case AUDIO_EXTERN: 86 if (input->index > 2) {
86 cs53l32a_write(client, 0x01, 0x21); 87 cs53l32a_err("Invalid input %d.\n", input->index);
87 break;
88 case AUDIO_MUTE:
89 cs53l32a_write(client, 0x03, 0xF0);
90 break;
91 case AUDIO_UNMUTE:
92 cs53l32a_write(client, 0x03, 0x30);
93 break;
94 default:
95 cs53l32a_err("Invalid input %d.\n", *input);
96 return -EINVAL; 88 return -EINVAL;
97 } 89 }
90 cs53l32a_write(client, 0x01, 0x01 + (input->index << 4));
91 break;
92
93 case VIDIOC_G_AUDIO:
94 memset(input, 0, sizeof(*input));
95 input->index = (cs53l32a_read(client, 0x01) >> 4) & 3;
96 break;
97
98 case VIDIOC_G_CTRL:
99 if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
100 ctrl->value = (cs53l32a_read(client, 0x03) & 0xc0) != 0;
101 break;
102 }
103 if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
104 return -EINVAL;
105 ctrl->value = (s8)cs53l32a_read(client, 0x04);
98 break; 106 break;
99 107
100 case VIDIOC_S_CTRL: 108 case VIDIOC_S_CTRL:
101 { 109 if (ctrl->id == V4L2_CID_AUDIO_MUTE) {
102 struct v4l2_control *ctrl = arg; 110 cs53l32a_write(client, 0x03, ctrl->value ? 0xf0 : 0x30);
103
104 if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
105 return -EINVAL;
106 if (ctrl->value > 12 || ctrl->value < -90)
107 return -EINVAL;
108 cs53l32a_write(client, 0x04, (u8) ctrl->value);
109 cs53l32a_write(client, 0x05, (u8) ctrl->value);
110 break; 111 break;
111 } 112 }
113 if (ctrl->id != V4L2_CID_AUDIO_VOLUME)
114 return -EINVAL;
115 if (ctrl->value > 12 || ctrl->value < -96)
116 return -EINVAL;
117 cs53l32a_write(client, 0x04, (u8) ctrl->value);
118 cs53l32a_write(client, 0x05, (u8) ctrl->value);
119 break;
112 120
113 case VIDIOC_LOG_STATUS: 121 case VIDIOC_LOG_STATUS:
114 { 122 {
115 u8 v = cs53l32a_read(client, 0x01); 123 u8 v = cs53l32a_read(client, 0x01);
116 u8 m = cs53l32a_read(client, 0x03); 124 u8 m = cs53l32a_read(client, 0x03);
125 s8 vol = cs53l32a_read(client, 0x04);
117 126
118 cs53l32a_info("Input: %s%s\n", 127 cs53l32a_info("Input: %d%s\n", (v >> 4) & 3,
119 v == 0x21 ? "external line in" : "tuner",
120 (m & 0xC0) ? " (muted)" : ""); 128 (m & 0xC0) ? " (muted)" : "");
129 cs53l32a_info("Volume: %d dB\n", vol);
121 break; 130 break;
122 } 131 }
123 132