blob: d2faeaa79759e9dd138759008a4e62a7ff56d1a1 [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 */
Sri Deevi149783b2009-03-03 06:07:42 -030035 if (!state->is_cx23885 && !state->is_cx231xx)
Steven Tothf2340812008-01-10 01:22:39 -030036 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
Sri Deevi149783b2009-03-03 06:07:42 -030047 if (!state->is_cx231xx) {
48
49 /* VID_PLL and AUX_PLL */
50 cx25840_write4(client, 0x108, 0x1006040f);
51
52 /* AUX_PLL_FRAC */
53 cx25840_write4(client, 0x110, 0x01bb39ee);
54 }
Hans Verkuilbd985162005-11-13 16:07:56 -080055
Hans Verkuile2b8cf42006-04-22 10:22:46 -030056 if (state->is_cx25836)
57 break;
58
Hans Verkuilbd985162005-11-13 16:07:56 -080059 /* src3/4/6_ctl = 0x0801f77f */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030060 cx25840_write4(client, 0x900, 0x0801f77f);
61 cx25840_write4(client, 0x904, 0x0801f77f);
62 cx25840_write4(client, 0x90c, 0x0801f77f);
Hans Verkuilbd985162005-11-13 16:07:56 -080063 break;
64
Hans Verkuil3578d3d2006-01-09 15:25:41 -020065 case 44100:
Steven Tothf2340812008-01-10 01:22:39 -030066 if (state->is_cx23885) {
67 /* We don't have register values
68 * so avoid destroying registers. */
69 break;
70 }
Hans Verkuilbd985162005-11-13 16:07:56 -080071
Sri Deevi149783b2009-03-03 06:07:42 -030072 if (!state->is_cx231xx) {
73
74 /* VID_PLL and AUX_PLL */
75 cx25840_write4(client, 0x108, 0x1009040f);
76
77 /* AUX_PLL_FRAC */
78 cx25840_write4(client, 0x110, 0x00ec6bd6);
79 }
Hans Verkuilbd985162005-11-13 16:07:56 -080080
Hans Verkuile2b8cf42006-04-22 10:22:46 -030081 if (state->is_cx25836)
82 break;
83
Hans Verkuilbd985162005-11-13 16:07:56 -080084 /* src3/4/6_ctl = 0x08016d59 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -030085 cx25840_write4(client, 0x900, 0x08016d59);
86 cx25840_write4(client, 0x904, 0x08016d59);
87 cx25840_write4(client, 0x90c, 0x08016d59);
Hans Verkuilbd985162005-11-13 16:07:56 -080088 break;
89
Hans Verkuil3578d3d2006-01-09 15:25:41 -020090 case 48000:
Steven Tothf2340812008-01-10 01:22:39 -030091 if (state->is_cx23885) {
92 /* We don't have register values
93 * so avoid destroying registers. */
94 break;
95 }
Sri Deevi149783b2009-03-03 06:07:42 -030096
97 if (!state->is_cx231xx) {
98
Hans Verkuilbd985162005-11-13 16:07:56 -080099 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300100 cx25840_write4(client, 0x108, 0x100a040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800101
102 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300103 cx25840_write4(client, 0x110, 0x0098d6e5);
Sri Deevi149783b2009-03-03 06:07:42 -0300104 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800105
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300106 if (state->is_cx25836)
107 break;
108
Hans Verkuilbd985162005-11-13 16:07:56 -0800109 /* src3/4/6_ctl = 0x08014faa */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300110 cx25840_write4(client, 0x900, 0x08014faa);
111 cx25840_write4(client, 0x904, 0x08014faa);
112 cx25840_write4(client, 0x90c, 0x08014faa);
Hans Verkuilbd985162005-11-13 16:07:56 -0800113 break;
114 }
Hans Verkuila8bbf122006-01-09 15:25:42 -0200115 } else {
Hans Verkuilbd985162005-11-13 16:07:56 -0800116 switch (freq) {
Hans Verkuil3578d3d2006-01-09 15:25:41 -0200117 case 32000:
Steven Tothf2340812008-01-10 01:22:39 -0300118 if (state->is_cx23885) {
119 /* We don't have register values
120 * so avoid destroying registers. */
121 break;
122 }
Sri Deevi149783b2009-03-03 06:07:42 -0300123
124 if (!state->is_cx231xx) {
125
Hans Verkuilbd985162005-11-13 16:07:56 -0800126 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300127 cx25840_write4(client, 0x108, 0x1e08040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800128
129 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300130 cx25840_write4(client, 0x110, 0x012a0869);
Sri Deevi149783b2009-03-03 06:07:42 -0300131 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800132
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300133 if (state->is_cx25836)
134 break;
135
Hans Verkuilbd985162005-11-13 16:07:56 -0800136 /* src1_ctl = 0x08010000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300137 cx25840_write4(client, 0x8f8, 0x08010000);
Hans Verkuilbd985162005-11-13 16:07:56 -0800138
139 /* src3/4/6_ctl = 0x08020000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300140 cx25840_write4(client, 0x900, 0x08020000);
141 cx25840_write4(client, 0x904, 0x08020000);
142 cx25840_write4(client, 0x90c, 0x08020000);
Hans Verkuilbd985162005-11-13 16:07:56 -0800143
144 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
145 cx25840_write(client, 0x127, 0x54);
146 break;
147
Hans Verkuil3578d3d2006-01-09 15:25:41 -0200148 case 44100:
Steven Tothf2340812008-01-10 01:22:39 -0300149 if (state->is_cx23885) {
150 /* We don't have register values
151 * so avoid destroying registers. */
152 break;
153 }
154
Sri Deevi149783b2009-03-03 06:07:42 -0300155
156 if (!state->is_cx231xx) {
157
Hans Verkuilbd985162005-11-13 16:07:56 -0800158 /* VID_PLL and AUX_PLL */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300159 cx25840_write4(client, 0x108, 0x1809040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800160
161 /* AUX_PLL_FRAC */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300162 cx25840_write4(client, 0x110, 0x00ec6bd6);
Sri Deevi149783b2009-03-03 06:07:42 -0300163 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800164
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300165 if (state->is_cx25836)
166 break;
167
Hans Verkuilbd985162005-11-13 16:07:56 -0800168 /* src1_ctl = 0x08010000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300169 cx25840_write4(client, 0x8f8, 0x080160cd);
Hans Verkuilbd985162005-11-13 16:07:56 -0800170
171 /* src3/4/6_ctl = 0x08020000 */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300172 cx25840_write4(client, 0x900, 0x08017385);
173 cx25840_write4(client, 0x904, 0x08017385);
174 cx25840_write4(client, 0x90c, 0x08017385);
Hans Verkuilbd985162005-11-13 16:07:56 -0800175 break;
176
Hans Verkuil3578d3d2006-01-09 15:25:41 -0200177 case 48000:
Sri Deevi149783b2009-03-03 06:07:42 -0300178 if (!state->is_cx23885 && !state->is_cx231xx) {
Steven Tothf2340812008-01-10 01:22:39 -0300179 /* VID_PLL and AUX_PLL */
180 cx25840_write4(client, 0x108, 0x180a040f);
Hans Verkuilbd985162005-11-13 16:07:56 -0800181
Steven Tothf2340812008-01-10 01:22:39 -0300182 /* AUX_PLL_FRAC */
183 cx25840_write4(client, 0x110, 0x0098d6e5);
184 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800185
Hans Verkuile2b8cf42006-04-22 10:22:46 -0300186 if (state->is_cx25836)
187 break;
188
Sri Deevi149783b2009-03-03 06:07:42 -0300189 if (!state->is_cx23885 && !state->is_cx231xx) {
Steven Tothf2340812008-01-10 01:22:39 -0300190 /* src1_ctl */
191 cx25840_write4(client, 0x8f8, 0x08018000);
Hans Verkuilbd985162005-11-13 16:07:56 -0800192
Steven Tothf2340812008-01-10 01:22:39 -0300193 /* src3/4/6_ctl */
194 cx25840_write4(client, 0x900, 0x08015555);
195 cx25840_write4(client, 0x904, 0x08015555);
196 cx25840_write4(client, 0x90c, 0x08015555);
197 } else {
198
199 cx25840_write4(client, 0x8f8, 0x0801867c);
200
201 cx25840_write4(client, 0x900, 0x08014faa);
202 cx25840_write4(client, 0x904, 0x08014faa);
203 cx25840_write4(client, 0x90c, 0x08014faa);
204 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800205 break;
206 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800207 }
208
Hans Verkuilbd985162005-11-13 16:07:56 -0800209 state->audclk_freq = freq;
210
211 return 0;
212}
213
Hans Verkuila8bbf122006-01-09 15:25:42 -0200214void cx25840_audio_set_path(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800215{
Hans Verkuil9357b312008-11-29 12:50:06 -0300216 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuilbd985162005-11-13 16:07:56 -0800217
Hans Verkuil82677612007-08-07 07:16:07 -0300218 /* assert soft reset */
219 cx25840_and_or(client, 0x810, ~0x1, 0x01);
220
Hans Verkuilbd985162005-11-13 16:07:56 -0800221 /* stop microcontroller */
222 cx25840_and_or(client, 0x803, ~0x10, 0);
223
224 /* Mute everything to prevent the PFFT! */
225 cx25840_write(client, 0x8d3, 0x1f);
226
Hans Verkuila8bbf122006-01-09 15:25:42 -0200227 if (state->aud_input == CX25840_AUDIO_SERIAL) {
Hans Verkuilbd985162005-11-13 16:07:56 -0800228 /* Set Path1 to Serial Audio Input */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300229 cx25840_write4(client, 0x8d0, 0x01011012);
Hans Verkuilbd985162005-11-13 16:07:56 -0800230
231 /* The microcontroller should not be started for the
232 * non-tuner inputs: autodetection is specific for
233 * TV audio. */
Hans Verkuila8bbf122006-01-09 15:25:42 -0200234 } else {
235 /* Set Path1 to Analog Demod Main Channel */
Hans Verkuil4a56eb32007-12-02 07:03:45 -0300236 cx25840_write4(client, 0x8d0, 0x1f063870);
Hans Verkuilc0c044a2006-04-29 12:11:18 -0300237 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800238
Hans Verkuilc0c044a2006-04-29 12:11:18 -0300239 set_audclk_freq(client, state->audclk_freq);
240
241 if (state->aud_input != CX25840_AUDIO_SERIAL) {
Hans Verkuila8bbf122006-01-09 15:25:42 -0200242 /* When the microcontroller detects the
243 * audio format, it will unmute the lines */
244 cx25840_and_or(client, 0x803, ~0x10, 0x10);
Hans Verkuilbd985162005-11-13 16:07:56 -0800245 }
Hans Verkuil82677612007-08-07 07:16:07 -0300246
247 /* deassert soft reset */
248 cx25840_and_or(client, 0x810, ~0x1, 0x00);
Steven Tothf2340812008-01-10 01:22:39 -0300249
Sri Deevi149783b2009-03-03 06:07:42 -0300250 if (state->is_cx23885 || state->is_cx231xx) {
Steven Tothf2340812008-01-10 01:22:39 -0300251 /* Ensure the controller is running when we exit */
252 cx25840_and_or(client, 0x803, ~0x10, 0x10);
253 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800254}
255
Hans Verkuild92c20e2006-01-09 15:32:41 -0200256static int get_volume(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800257{
Hans Verkuil9357b312008-11-29 12:50:06 -0300258 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuil87410da2007-08-05 08:00:36 -0300259 int vol;
260
261 if (state->unmute_volume >= 0)
262 return state->unmute_volume;
263
Hans Verkuilbd985162005-11-13 16:07:56 -0800264 /* Volume runs +18dB to -96dB in 1/2dB steps
265 * change to fit the msp3400 -114dB to +12dB range */
266
267 /* check PATH1_VOLUME */
Hans Verkuil87410da2007-08-05 08:00:36 -0300268 vol = 228 - cx25840_read(client, 0x8d4);
Hans Verkuilbd985162005-11-13 16:07:56 -0800269 vol = (vol / 2) + 23;
270 return vol << 9;
271}
272
Hans Verkuild92c20e2006-01-09 15:32:41 -0200273static void set_volume(struct i2c_client *client, int volume)
Hans Verkuilbd985162005-11-13 16:07:56 -0800274{
Hans Verkuil9357b312008-11-29 12:50:06 -0300275 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuil87410da2007-08-05 08:00:36 -0300276 int vol;
277
278 if (state->unmute_volume >= 0) {
279 state->unmute_volume = volume;
280 return;
281 }
282
283 /* Convert the volume to msp3400 values (0-127) */
284 vol = volume >> 9;
285
Hans Verkuilbd985162005-11-13 16:07:56 -0800286 /* now scale it up to cx25840 values
287 * -114dB to -96dB maps to 0
288 * this should be 19, but in my testing that was 4dB too loud */
289 if (vol <= 23) {
290 vol = 0;
291 } else {
292 vol -= 23;
293 }
294
295 /* PATH1_VOLUME */
296 cx25840_write(client, 0x8d4, 228 - (vol * 2));
297}
298
Hans Verkuild92c20e2006-01-09 15:32:41 -0200299static int get_bass(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800300{
301 /* bass is 49 steps +12dB to -12dB */
302
303 /* check PATH1_EQ_BASS_VOL */
304 int bass = cx25840_read(client, 0x8d9) & 0x3f;
305 bass = (((48 - bass) * 0xffff) + 47) / 48;
306 return bass;
307}
308
Hans Verkuild92c20e2006-01-09 15:32:41 -0200309static void set_bass(struct i2c_client *client, int bass)
Hans Verkuilbd985162005-11-13 16:07:56 -0800310{
311 /* PATH1_EQ_BASS_VOL */
312 cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff));
313}
314
Hans Verkuild92c20e2006-01-09 15:32:41 -0200315static int get_treble(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800316{
317 /* treble is 49 steps +12dB to -12dB */
318
319 /* check PATH1_EQ_TREBLE_VOL */
320 int treble = cx25840_read(client, 0x8db) & 0x3f;
321 treble = (((48 - treble) * 0xffff) + 47) / 48;
322 return treble;
323}
324
Hans Verkuild92c20e2006-01-09 15:32:41 -0200325static void set_treble(struct i2c_client *client, int treble)
Hans Verkuilbd985162005-11-13 16:07:56 -0800326{
327 /* PATH1_EQ_TREBLE_VOL */
328 cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff));
329}
330
Hans Verkuild92c20e2006-01-09 15:32:41 -0200331static int get_balance(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800332{
333 /* balance is 7 bit, 0 to -96dB */
334
335 /* check PATH1_BAL_LEVEL */
336 int balance = cx25840_read(client, 0x8d5) & 0x7f;
337 /* check PATH1_BAL_LEFT */
338 if ((cx25840_read(client, 0x8d5) & 0x80) == 0)
339 balance = 0x80 - balance;
340 else
341 balance = 0x80 + balance;
342 return balance << 8;
343}
344
Hans Verkuild92c20e2006-01-09 15:32:41 -0200345static void set_balance(struct i2c_client *client, int balance)
Hans Verkuilbd985162005-11-13 16:07:56 -0800346{
347 int bal = balance >> 8;
348 if (bal > 0x80) {
349 /* PATH1_BAL_LEFT */
350 cx25840_and_or(client, 0x8d5, 0x7f, 0x80);
351 /* PATH1_BAL_LEVEL */
352 cx25840_and_or(client, 0x8d5, ~0x7f, bal & 0x7f);
353 } else {
354 /* PATH1_BAL_LEFT */
355 cx25840_and_or(client, 0x8d5, 0x7f, 0x00);
356 /* PATH1_BAL_LEVEL */
357 cx25840_and_or(client, 0x8d5, ~0x7f, 0x80 - bal);
358 }
359}
360
Hans Verkuild92c20e2006-01-09 15:32:41 -0200361static int get_mute(struct i2c_client *client)
Hans Verkuilbd985162005-11-13 16:07:56 -0800362{
Hans Verkuil9357b312008-11-29 12:50:06 -0300363 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuil87410da2007-08-05 08:00:36 -0300364
365 return state->unmute_volume >= 0;
Hans Verkuilbd985162005-11-13 16:07:56 -0800366}
367
Hans Verkuild92c20e2006-01-09 15:32:41 -0200368static void set_mute(struct i2c_client *client, int mute)
Hans Verkuilbd985162005-11-13 16:07:56 -0800369{
Hans Verkuil9357b312008-11-29 12:50:06 -0300370 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
Hans Verkuilbd985162005-11-13 16:07:56 -0800371
Hans Verkuil87410da2007-08-05 08:00:36 -0300372 if (mute && state->unmute_volume == -1) {
373 int vol = get_volume(client);
374
375 set_volume(client, 0);
376 state->unmute_volume = vol;
377 }
378 else if (!mute && state->unmute_volume != -1) {
379 int vol = state->unmute_volume;
380
381 state->unmute_volume = -1;
382 set_volume(client, vol);
Hans Verkuilbd985162005-11-13 16:07:56 -0800383 }
384}
385
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300386int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
Hans Verkuilbd985162005-11-13 16:07:56 -0800387{
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300388 struct i2c_client *client = v4l2_get_subdevdata(sd);
389 struct cx25840_state *state = to_state(sd);
Hans Verkuilc0c044a2006-04-29 12:11:18 -0300390 int retval;
Hans Verkuilbd985162005-11-13 16:07:56 -0800391
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300392 if (!state->is_cx25836)
393 cx25840_and_or(client, 0x810, ~0x1, 1);
394 if (state->aud_input != CX25840_AUDIO_SERIAL) {
395 cx25840_and_or(client, 0x803, ~0x10, 0);
396 cx25840_write(client, 0x8d3, 0x1f);
397 }
398 retval = set_audclk_freq(client, freq);
399 if (state->aud_input != CX25840_AUDIO_SERIAL)
400 cx25840_and_or(client, 0x803, ~0x10, 0x10);
401 if (!state->is_cx25836)
402 cx25840_and_or(client, 0x810, ~0x1, 0);
403 return retval;
404}
Hans Verkuila8bbf122006-01-09 15:25:42 -0200405
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300406int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
407{
408 struct i2c_client *client = v4l2_get_subdevdata(sd);
409
410 switch (ctrl->id) {
411 case V4L2_CID_AUDIO_VOLUME:
412 ctrl->value = get_volume(client);
Hans Verkuilbd985162005-11-13 16:07:56 -0800413 break;
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300414 case V4L2_CID_AUDIO_BASS:
415 ctrl->value = get_bass(client);
Hans Verkuilbd985162005-11-13 16:07:56 -0800416 break;
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300417 case V4L2_CID_AUDIO_TREBLE:
418 ctrl->value = get_treble(client);
419 break;
420 case V4L2_CID_AUDIO_BALANCE:
421 ctrl->value = get_balance(client);
422 break;
423 case V4L2_CID_AUDIO_MUTE:
424 ctrl->value = get_mute(client);
425 break;
Hans Verkuilbd985162005-11-13 16:07:56 -0800426 default:
427 return -EINVAL;
428 }
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300429 return 0;
430}
Hans Verkuilbd985162005-11-13 16:07:56 -0800431
Hans Verkuildf1d5ed2009-03-30 06:26:40 -0300432int cx25840_audio_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
433{
434 struct i2c_client *client = v4l2_get_subdevdata(sd);
435
436 switch (ctrl->id) {
437 case V4L2_CID_AUDIO_VOLUME:
438 set_volume(client, ctrl->value);
439 break;
440 case V4L2_CID_AUDIO_BASS:
441 set_bass(client, ctrl->value);
442 break;
443 case V4L2_CID_AUDIO_TREBLE:
444 set_treble(client, ctrl->value);
445 break;
446 case V4L2_CID_AUDIO_BALANCE:
447 set_balance(client, ctrl->value);
448 break;
449 case V4L2_CID_AUDIO_MUTE:
450 set_mute(client, ctrl->value);
451 break;
452 default:
453 return -EINVAL;
454 }
Hans Verkuilbd985162005-11-13 16:07:56 -0800455 return 0;
456}