blob: 93d74bee292afc82a3b8b33ede264dd18b745dc1 [file] [log] [blame]
Hans Verkuilbd985162005-11-13 16:07:56 -08001/* cx25840 audio functions
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18
19#include <linux/videodev2.h>
20#include <linux/i2c.h>
Hans Verkuilbd985162005-11-13 16:07:56 -080021#include <media/v4l2-common.h>
Hans Verkuil31bc09b2006-03-25 10:26:09 -030022#include <media/cx25840.h>
Hans Verkuilbd985162005-11-13 16:07:56 -080023
Hans Verkuil31bc09b2006-03-25 10:26:09 -030024#include "cx25840-core.h"
Hans Verkuilbd985162005-11-13 16:07:56 -080025
Hans Verkuil3578d3d2006-01-09 15:25:41 -020026static int set_audclk_freq(struct i2c_client *client, u32 freq)
Hans Verkuilbd985162005-11-13 16:07:56 -080027{
Hans Verkuil9357b312008-11-29 12:50:06 -030028 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuilbd985162005-11-13 16:07:56 -080029
Hans Verkuil3578d3d2006-01-09 15:25:41 -020030 if (freq != 32000 && freq != 44100 && freq != 48000)
31 return -EINVAL;
32
Hans Verkuilbd985162005-11-13 16:07:56 -080033 /* common for all inputs and rates */
34 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
Steven Tothf2340812008-01-10 01:22:39 -030035 if (!state->is_cx23885)
36 cx25840_write(client, 0x127, 0x50);
Hans Verkuilbd985162005-11-13 16:07:56 -080037
Hans Verkuila8bbf122006-01-09 15:25:42 -020038 if (state->aud_input != CX25840_AUDIO_SERIAL) {
Hans Verkuilbd985162005-11-13 16:07:56 -080039 switch (freq) {
Hans Verkuil3578d3d2006-01-09 15:25:41 -020040 case 32000:
Steven Tothf2340812008-01-10 01:22:39 -030041 if (state->is_cx23885) {
42 /* We don't have register values
43 * so avoid destroying registers. */
44 break;
45 }
Hans Verkuilbd985162005-11-13 16:07:56 -080046 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030047 cx25840_write4(client, 0x108, 0x1006040f);
Hans Verkuilbd985162005-11-13 16:07:56 -080048
49 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030050 cx25840_write4(client, 0x110, 0x01bb39ee);
Hans Verkuilbd985162005-11-13 16:07:56 -080051
Hans Verkuile2b8cf42006-04-22 10:22:46 -030052 if (state->is_cx25836)
53 break;
54
Hans Verkuilbd985162005-11-13 16:07:56 -080055 /* src3/4/6_ctl = 0x0801f77f */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030056 cx25840_write4(client, 0x900, 0x0801f77f);
57 cx25840_write4(client, 0x904, 0x0801f77f);
58 cx25840_write4(client, 0x90c, 0x0801f77f);
Hans Verkuilbd985162005-11-13 16:07:56 -080059 break;
60
Hans Verkuil3578d3d2006-01-09 15:25:41 -020061 case 44100:
Steven Tothf2340812008-01-10 01:22:39 -030062 if (state->is_cx23885) {
63 /* We don't have register values
64 * so avoid destroying registers. */
65 break;
66 }
Hans Verkuilbd985162005-11-13 16:07:56 -080067 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030068 cx25840_write4(client, 0x108, 0x1009040f);
Hans Verkuilbd985162005-11-13 16:07:56 -080069
70 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030071 cx25840_write4(client, 0x110, 0x00ec6bd6);
Hans Verkuilbd985162005-11-13 16:07:56 -080072
Hans Verkuile2b8cf42006-04-22 10:22:46 -030073 if (state->is_cx25836)
74 break;
75
Hans Verkuilbd985162005-11-13 16:07:56 -080076 /* src3/4/6_ctl = 0x08016d59 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030077 cx25840_write4(client, 0x900, 0x08016d59);
78 cx25840_write4(client, 0x904, 0x08016d59);
79 cx25840_write4(client, 0x90c, 0x08016d59);
Hans Verkuilbd985162005-11-13 16:07:56 -080080 break;
81
Hans Verkuil3578d3d2006-01-09 15:25:41 -020082 case 48000:
Steven Tothf2340812008-01-10 01:22:39 -030083 if (state->is_cx23885) {
84 /* We don't have register values
85 * so avoid destroying registers. */
86 break;
87 }
Hans Verkuilbd985162005-11-13 16:07:56 -080088 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030089 cx25840_write4(client, 0x108, 0x100a040f);
Hans Verkuilbd985162005-11-13 16:07:56 -080090
91 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030092 cx25840_write4(client, 0x110, 0x0098d6e5);
Hans Verkuilbd985162005-11-13 16:07:56 -080093
Hans Verkuile2b8cf42006-04-22 10:22:46 -030094 if (state->is_cx25836)
95 break;
96
Hans Verkuilbd985162005-11-13 16:07:56 -080097 /* src3/4/6_ctl = 0x08014faa */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030098 cx25840_write4(client, 0x900, 0x08014faa);
99 cx25840_write4(client, 0x904, 0x08014faa);
100 cx25840_write4(client, 0x90c, 0x08014faa);
Hans Verkuilbd985162005-11-13 16:07:56 -0800101 break;
102 }
Hans Verkuila8bbf122006-01-09 15:25:42 -0200103 } else {
Hans Verkuilbd985162005-11-13 16:07:56 -0800104 switch (freq) {
Hans Verkuil3578d3d2006-01-09 15:25:41 -0200105 case 32000:
Steven Tothf2340812008-01-10 01:22:39 -0300106 if (state->is_cx23885) {
107 /* We don't have register values
108 * so avoid destroying registers. */
109 break;
110 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800111 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300112 cx25840_write4(client, 0x108, 0x1e08040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800113
114 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300115 cx25840_write4(client, 0x110, 0x012a0869);
Hans Verkuilbd985162005-11-13 16:07:56 -0800116
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300117 if (state->is_cx25836)
118 break;
119
Hans Verkuilbd985162005-11-13 16:07:56 -0800120 /* src1_ctl = 0x08010000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300121 cx25840_write4(client, 0x8f8, 0x08010000);
Hans Verkuilbd985162005-11-13 16:07:56 -0800122
123 /* src3/4/6_ctl = 0x08020000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300124 cx25840_write4(client, 0x900, 0x08020000);
125 cx25840_write4(client, 0x904, 0x08020000);
126 cx25840_write4(client, 0x90c, 0x08020000);
Hans Verkuilbd985162005-11-13 16:07:56 -0800127
128 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
129 cx25840_write(client, 0x127, 0x54);
130 break;
131
Hans Verkuil3578d3d2006-01-09 15:25:41 -0200132 case 44100:
Steven Tothf2340812008-01-10 01:22:39 -0300133 if (state->is_cx23885) {
134 /* We don't have register values
135 * so avoid destroying registers. */
136 break;
137 }
138
Hans Verkuilbd985162005-11-13 16:07:56 -0800139 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300140 cx25840_write4(client, 0x108, 0x1809040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800141
142 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300143 cx25840_write4(client, 0x110, 0x00ec6bd6);
Hans Verkuilbd985162005-11-13 16:07:56 -0800144
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300145 if (state->is_cx25836)
146 break;
147
Hans Verkuilbd985162005-11-13 16:07:56 -0800148 /* src1_ctl = 0x08010000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300149 cx25840_write4(client, 0x8f8, 0x080160cd);
Hans Verkuilbd985162005-11-13 16:07:56 -0800150
151 /* src3/4/6_ctl = 0x08020000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300152 cx25840_write4(client, 0x900, 0x08017385);
153 cx25840_write4(client, 0x904, 0x08017385);
154 cx25840_write4(client, 0x90c, 0x08017385);
Hans Verkuilbd985162005-11-13 16:07:56 -0800155 break;
156
Hans Verkuil3578d3d2006-01-09 15:25:41 -0200157 case 48000:
Steven Tothf2340812008-01-10 01:22:39 -0300158 if (!state->is_cx23885) {
159 /* VID_PLL and AUX_PLL */
160 cx25840_write4(client, 0x108, 0x180a040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800161
Steven Tothf2340812008-01-10 01:22:39 -0300162 /* AUX_PLL_FRAC */
163 cx25840_write4(client, 0x110, 0x0098d6e5);
164 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800165
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300166 if (state->is_cx25836)
167 break;
168
Steven Tothf2340812008-01-10 01:22:39 -0300169 if (!state->is_cx23885) {
170 /* src1_ctl */
171 cx25840_write4(client, 0x8f8, 0x08018000);
Hans Verkuilbd985162005-11-13 16:07:56 -0800172
Steven Tothf2340812008-01-10 01:22:39 -0300173 /* src3/4/6_ctl */
174 cx25840_write4(client, 0x900, 0x08015555);
175 cx25840_write4(client, 0x904, 0x08015555);
176 cx25840_write4(client, 0x90c, 0x08015555);
177 } else {
178
179 cx25840_write4(client, 0x8f8, 0x0801867c);
180
181 cx25840_write4(client, 0x900, 0x08014faa);
182 cx25840_write4(client, 0x904, 0x08014faa);
183 cx25840_write4(client, 0x90c, 0x08014faa);
184 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800185 break;
186 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800187 }
188
Hans Verkuilbd985162005-11-13 16:07:56 -0800189 state->audclk_freq = freq;
190
191 return 0;
192}
193
Hans Verkuila8bbf122006-01-09 15:25:42 -0200194void cx25840_audio_set_path(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800195{
Hans Verkuil9357b312008-11-29 12:50:06 -0300196 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuilbd985162005-11-13 16:07:56 -0800197
Hans Verkuil82677612007-08-07 07:16:07 -0300198 /* assert soft reset */
199 cx25840_and_or(client, 0x810, ~0x1, 0x01);
200
Hans Verkuilbd985162005-11-13 16:07:56 -0800201 /* stop microcontroller */
202 cx25840_and_or(client, 0x803, ~0x10, 0);
203
204 /* Mute everything to prevent the PFFT! */
205 cx25840_write(client, 0x8d3, 0x1f);
206
Hans Verkuila8bbf122006-01-09 15:25:42 -0200207 if (state->aud_input == CX25840_AUDIO_SERIAL) {
Hans Verkuilbd985162005-11-13 16:07:56 -0800208 /* Set Path1 to Serial Audio Input */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300209 cx25840_write4(client, 0x8d0, 0x01011012);
Hans Verkuilbd985162005-11-13 16:07:56 -0800210
211 /* The microcontroller should not be started for the
212 * non-tuner inputs: autodetection is specific for
213 * TV audio. */
Hans Verkuila8bbf122006-01-09 15:25:42 -0200214 } else {
215 /* Set Path1 to Analog Demod Main Channel */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300216 cx25840_write4(client, 0x8d0, 0x1f063870);
Hans Verkuilc0c044a2006-04-29 12:11:18 -0300217 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800218
Hans Verkuilc0c044a2006-04-29 12:11:18 -0300219 set_audclk_freq(client, state->audclk_freq);
220
221 if (state->aud_input != CX25840_AUDIO_SERIAL) {
Hans Verkuila8bbf122006-01-09 15:25:42 -0200222 /* When the microcontroller detects the
223 * audio format, it will unmute the lines */
224 cx25840_and_or(client, 0x803, ~0x10, 0x10);
Hans Verkuilbd985162005-11-13 16:07:56 -0800225 }
Hans Verkuil82677612007-08-07 07:16:07 -0300226
227 /* deassert soft reset */
228 cx25840_and_or(client, 0x810, ~0x1, 0x00);
Steven Tothf2340812008-01-10 01:22:39 -0300229
230 if (state->is_cx23885) {
231 /* Ensure the controller is running when we exit */
232 cx25840_and_or(client, 0x803, ~0x10, 0x10);
233 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800234}
235
Hans Verkuild92c20e2006-01-09 15:32:41 -0200236static int get_volume(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800237{
Hans Verkuil9357b312008-11-29 12:50:06 -0300238 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuil87410da2007-08-05 08:00:36 -0300239 int vol;
240
241 if (state->unmute_volume >= 0)
242 return state->unmute_volume;
243
Hans Verkuilbd985162005-11-13 16:07:56 -0800244 /* Volume runs +18dB to -96dB in 1/2dB steps
245 * change to fit the msp3400 -114dB to +12dB range */
246
247 /* check PATH1_VOLUME */
Hans Verkuil87410da2007-08-05 08:00:36 -0300248 vol = 228 - cx25840_read(client, 0x8d4);
Hans Verkuilbd985162005-11-13 16:07:56 -0800249 vol = (vol / 2) + 23;
250 return vol << 9;
251}
252
Hans Verkuild92c20e2006-01-09 15:32:41 -0200253static void set_volume(struct i2c_client *client, int volume)
Hans Verkuilbd985162005-11-13 16:07:56 -0800254{
Hans Verkuil9357b312008-11-29 12:50:06 -0300255 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuil87410da2007-08-05 08:00:36 -0300256 int vol;
257
258 if (state->unmute_volume >= 0) {
259 state->unmute_volume = volume;
260 return;
261 }
262
263 /* Convert the volume to msp3400 values (0-127) */
264 vol = volume >> 9;
265
Hans Verkuilbd985162005-11-13 16:07:56 -0800266 /* now scale it up to cx25840 values
267 * -114dB to -96dB maps to 0
268 * this should be 19, but in my testing that was 4dB too loud */
269 if (vol <= 23) {
270 vol = 0;
271 } else {
272 vol -= 23;
273 }
274
275 /* PATH1_VOLUME */
276 cx25840_write(client, 0x8d4, 228 - (vol * 2));
277}
278
Hans Verkuild92c20e2006-01-09 15:32:41 -0200279static int get_bass(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800280{
281 /* bass is 49 steps +12dB to -12dB */
282
283 /* check PATH1_EQ_BASS_VOL */
284 int bass = cx25840_read(client, 0x8d9) & 0x3f;
285 bass = (((48 - bass) * 0xffff) + 47) / 48;
286 return bass;
287}
288
Hans Verkuild92c20e2006-01-09 15:32:41 -0200289static void set_bass(struct i2c_client *client, int bass)
Hans Verkuilbd985162005-11-13 16:07:56 -0800290{
291 /* PATH1_EQ_BASS_VOL */
292 cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff));
293}
294
Hans Verkuild92c20e2006-01-09 15:32:41 -0200295static int get_treble(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800296{
297 /* treble is 49 steps +12dB to -12dB */
298
299 /* check PATH1_EQ_TREBLE_VOL */
300 int treble = cx25840_read(client, 0x8db) & 0x3f;
301 treble = (((48 - treble) * 0xffff) + 47) / 48;
302 return treble;
303}
304
Hans Verkuild92c20e2006-01-09 15:32:41 -0200305static void set_treble(struct i2c_client *client, int treble)
Hans Verkuilbd985162005-11-13 16:07:56 -0800306{
307 /* PATH1_EQ_TREBLE_VOL */
308 cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff));
309}
310
Hans Verkuild92c20e2006-01-09 15:32:41 -0200311static int get_balance(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800312{
313 /* balance is 7 bit, 0 to -96dB */
314
315 /* check PATH1_BAL_LEVEL */
316 int balance = cx25840_read(client, 0x8d5) & 0x7f;
317 /* check PATH1_BAL_LEFT */
318 if ((cx25840_read(client, 0x8d5) & 0x80) == 0)
319 balance = 0x80 - balance;
320 else
321 balance = 0x80 + balance;
322 return balance << 8;
323}
324
Hans Verkuild92c20e2006-01-09 15:32:41 -0200325static void set_balance(struct i2c_client *client, int balance)
Hans Verkuilbd985162005-11-13 16:07:56 -0800326{
327 int bal = balance >> 8;
328 if (bal > 0x80) {
329 /* PATH1_BAL_LEFT */
330 cx25840_and_or(client, 0x8d5, 0x7f, 0x80);
331 /* PATH1_BAL_LEVEL */
332 cx25840_and_or(client, 0x8d5, ~0x7f, bal & 0x7f);
333 } else {
334 /* PATH1_BAL_LEFT */
335 cx25840_and_or(client, 0x8d5, 0x7f, 0x00);
336 /* PATH1_BAL_LEVEL */
337 cx25840_and_or(client, 0x8d5, ~0x7f, 0x80 - bal);
338 }
339}
340
Hans Verkuild92c20e2006-01-09 15:32:41 -0200341static int get_mute(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800342{
Hans Verkuil9357b312008-11-29 12:50:06 -0300343 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuil87410da2007-08-05 08:00:36 -0300344
345 return state->unmute_volume >= 0;
Hans Verkuilbd985162005-11-13 16:07:56 -0800346}
347
Hans Verkuild92c20e2006-01-09 15:32:41 -0200348static void set_mute(struct i2c_client *client, int mute)
Hans Verkuilbd985162005-11-13 16:07:56 -0800349{
Hans Verkuil9357b312008-11-29 12:50:06 -0300350 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuilbd985162005-11-13 16:07:56 -0800351
Hans Verkuil87410da2007-08-05 08:00:36 -0300352 if (mute && state->unmute_volume == -1) {
353 int vol = get_volume(client);
354
355 set_volume(client, 0);
356 state->unmute_volume = vol;
357 }
358 else if (!mute && state->unmute_volume != -1) {
359 int vol = state->unmute_volume;
360
361 state->unmute_volume = -1;
362 set_volume(client, vol);
Hans Verkuilbd985162005-11-13 16:07:56 -0800363 }
364}
365
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300366int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
Hans Verkuilbd985162005-11-13 16:07:56 -0800367{
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300368 struct i2c_client *client = v4l2_get_subdevdata(sd);
369 struct cx25840_state *state = to_state(sd);
Hans Verkuilc0c044a2006-04-29 12:11:18 -0300370 int retval;
Hans Verkuilbd985162005-11-13 16:07:56 -0800371
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300372 if (!state->is_cx25836)
373 cx25840_and_or(client, 0x810, ~0x1, 1);
374 if (state->aud_input != CX25840_AUDIO_SERIAL) {
375 cx25840_and_or(client, 0x803, ~0x10, 0);
376 cx25840_write(client, 0x8d3, 0x1f);
377 }
378 retval = set_audclk_freq(client, freq);
379 if (state->aud_input != CX25840_AUDIO_SERIAL)
380 cx25840_and_or(client, 0x803, ~0x10, 0x10);
381 if (!state->is_cx25836)
382 cx25840_and_or(client, 0x810, ~0x1, 0);
383 return retval;
384}
Hans Verkuila8bbf122006-01-09 15:25:42 -0200385
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300386int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
387{
388 struct i2c_client *client = v4l2_get_subdevdata(sd);
389
390 switch (ctrl->id) {
391 case V4L2_CID_AUDIO_VOLUME:
392 ctrl->value = get_volume(client);
Hans Verkuilbd985162005-11-13 16:07:56 -0800393 break;
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300394 case V4L2_CID_AUDIO_BASS:
395 ctrl->value = get_bass(client);
Hans Verkuilbd985162005-11-13 16:07:56 -0800396 break;
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300397 case V4L2_CID_AUDIO_TREBLE:
398 ctrl->value = get_treble(client);
399 break;
400 case V4L2_CID_AUDIO_BALANCE:
401 ctrl->value = get_balance(client);
402 break;
403 case V4L2_CID_AUDIO_MUTE:
404 ctrl->value = get_mute(client);
405 break;
Hans Verkuilbd985162005-11-13 16:07:56 -0800406 default:
407 return -EINVAL;
408 }
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300409 return 0;
410}
Hans Verkuilbd985162005-11-13 16:07:56 -0800411
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300412int cx25840_audio_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
413{
414 struct i2c_client *client = v4l2_get_subdevdata(sd);
415
416 switch (ctrl->id) {
417 case V4L2_CID_AUDIO_VOLUME:
418 set_volume(client, ctrl->value);
419 break;
420 case V4L2_CID_AUDIO_BASS:
421 set_bass(client, ctrl->value);
422 break;
423 case V4L2_CID_AUDIO_TREBLE:
424 set_treble(client, ctrl->value);
425 break;
426 case V4L2_CID_AUDIO_BALANCE:
427 set_balance(client, ctrl->value);
428 break;
429 case V4L2_CID_AUDIO_MUTE:
430 set_mute(client, ctrl->value);
431 break;
432 default:
433 return -EINVAL;
434 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800435 return 0;
436}