Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 1 | /* 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 Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 21 | #include <media/v4l2-common.h> |
Hans Verkuil | 31bc09b | 2006-03-25 10:26:09 -0300 | [diff] [blame] | 22 | #include <media/cx25840.h> |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 23 | |
Hans Verkuil | 31bc09b | 2006-03-25 10:26:09 -0300 | [diff] [blame] | 24 | #include "cx25840-core.h" |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 25 | |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 26 | static int set_audclk_freq(struct i2c_client *client, u32 freq) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 27 | { |
| 28 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 29 | |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 30 | if (freq != 32000 && freq != 44100 && freq != 48000) |
| 31 | return -EINVAL; |
| 32 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 33 | /* common for all inputs and rates */ |
| 34 | /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */ |
| 35 | cx25840_write(client, 0x127, 0x50); |
| 36 | |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 37 | if (state->aud_input != CX25840_AUDIO_SERIAL) { |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 38 | switch (freq) { |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 39 | case 32000: |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 40 | /* VID_PLL and AUX_PLL */ |
| 41 | cx25840_write4(client, 0x108, 0x0f040610); |
| 42 | |
| 43 | /* AUX_PLL_FRAC */ |
| 44 | cx25840_write4(client, 0x110, 0xee39bb01); |
| 45 | |
Hans Verkuil | e2b8cf4 | 2006-04-22 10:22:46 -0300 | [diff] [blame] | 46 | if (state->is_cx25836) |
| 47 | break; |
| 48 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 49 | /* src3/4/6_ctl = 0x0801f77f */ |
| 50 | cx25840_write4(client, 0x900, 0x7ff70108); |
| 51 | cx25840_write4(client, 0x904, 0x7ff70108); |
| 52 | cx25840_write4(client, 0x90c, 0x7ff70108); |
| 53 | break; |
| 54 | |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 55 | case 44100: |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 56 | /* VID_PLL and AUX_PLL */ |
| 57 | cx25840_write4(client, 0x108, 0x0f040910); |
| 58 | |
| 59 | /* AUX_PLL_FRAC */ |
| 60 | cx25840_write4(client, 0x110, 0xd66bec00); |
| 61 | |
Hans Verkuil | e2b8cf4 | 2006-04-22 10:22:46 -0300 | [diff] [blame] | 62 | if (state->is_cx25836) |
| 63 | break; |
| 64 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 65 | /* src3/4/6_ctl = 0x08016d59 */ |
| 66 | cx25840_write4(client, 0x900, 0x596d0108); |
| 67 | cx25840_write4(client, 0x904, 0x596d0108); |
| 68 | cx25840_write4(client, 0x90c, 0x596d0108); |
| 69 | break; |
| 70 | |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 71 | case 48000: |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 72 | /* VID_PLL and AUX_PLL */ |
| 73 | cx25840_write4(client, 0x108, 0x0f040a10); |
| 74 | |
| 75 | /* AUX_PLL_FRAC */ |
| 76 | cx25840_write4(client, 0x110, 0xe5d69800); |
| 77 | |
Hans Verkuil | e2b8cf4 | 2006-04-22 10:22:46 -0300 | [diff] [blame] | 78 | if (state->is_cx25836) |
| 79 | break; |
| 80 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 81 | /* src3/4/6_ctl = 0x08014faa */ |
| 82 | cx25840_write4(client, 0x900, 0xaa4f0108); |
| 83 | cx25840_write4(client, 0x904, 0xaa4f0108); |
| 84 | cx25840_write4(client, 0x90c, 0xaa4f0108); |
| 85 | break; |
| 86 | } |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 87 | } else { |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 88 | switch (freq) { |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 89 | case 32000: |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 90 | /* VID_PLL and AUX_PLL */ |
| 91 | cx25840_write4(client, 0x108, 0x0f04081e); |
| 92 | |
| 93 | /* AUX_PLL_FRAC */ |
| 94 | cx25840_write4(client, 0x110, 0x69082a01); |
| 95 | |
Hans Verkuil | e2b8cf4 | 2006-04-22 10:22:46 -0300 | [diff] [blame] | 96 | if (state->is_cx25836) |
| 97 | break; |
| 98 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 99 | /* src1_ctl = 0x08010000 */ |
| 100 | cx25840_write4(client, 0x8f8, 0x00000108); |
| 101 | |
| 102 | /* src3/4/6_ctl = 0x08020000 */ |
| 103 | cx25840_write4(client, 0x900, 0x00000208); |
| 104 | cx25840_write4(client, 0x904, 0x00000208); |
| 105 | cx25840_write4(client, 0x90c, 0x00000208); |
| 106 | |
| 107 | /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */ |
| 108 | cx25840_write(client, 0x127, 0x54); |
| 109 | break; |
| 110 | |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 111 | case 44100: |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 112 | /* VID_PLL and AUX_PLL */ |
| 113 | cx25840_write4(client, 0x108, 0x0f040918); |
| 114 | |
| 115 | /* AUX_PLL_FRAC */ |
| 116 | cx25840_write4(client, 0x110, 0xd66bec00); |
| 117 | |
Hans Verkuil | e2b8cf4 | 2006-04-22 10:22:46 -0300 | [diff] [blame] | 118 | if (state->is_cx25836) |
| 119 | break; |
| 120 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 121 | /* src1_ctl = 0x08010000 */ |
| 122 | cx25840_write4(client, 0x8f8, 0xcd600108); |
| 123 | |
| 124 | /* src3/4/6_ctl = 0x08020000 */ |
| 125 | cx25840_write4(client, 0x900, 0x85730108); |
| 126 | cx25840_write4(client, 0x904, 0x85730108); |
| 127 | cx25840_write4(client, 0x90c, 0x85730108); |
| 128 | break; |
| 129 | |
Hans Verkuil | 3578d3d | 2006-01-09 15:25:41 -0200 | [diff] [blame] | 130 | case 48000: |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 131 | /* VID_PLL and AUX_PLL */ |
| 132 | cx25840_write4(client, 0x108, 0x0f040a18); |
| 133 | |
| 134 | /* AUX_PLL_FRAC */ |
| 135 | cx25840_write4(client, 0x110, 0xe5d69800); |
| 136 | |
Hans Verkuil | e2b8cf4 | 2006-04-22 10:22:46 -0300 | [diff] [blame] | 137 | if (state->is_cx25836) |
| 138 | break; |
| 139 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 140 | /* src1_ctl = 0x08010000 */ |
| 141 | cx25840_write4(client, 0x8f8, 0x00800108); |
| 142 | |
| 143 | /* src3/4/6_ctl = 0x08020000 */ |
| 144 | cx25840_write4(client, 0x900, 0x55550108); |
| 145 | cx25840_write4(client, 0x904, 0x55550108); |
| 146 | cx25840_write4(client, 0x90c, 0x55550108); |
| 147 | break; |
| 148 | } |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 149 | } |
| 150 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 151 | state->audclk_freq = freq; |
| 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 156 | void cx25840_audio_set_path(struct i2c_client *client) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 157 | { |
| 158 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 159 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 160 | /* stop microcontroller */ |
| 161 | cx25840_and_or(client, 0x803, ~0x10, 0); |
| 162 | |
Hans Verkuil | 2e2aef7 | 2006-04-29 12:26:46 -0300 | [diff] [blame] | 163 | /* assert soft reset */ |
| 164 | if (!state->is_cx25836) |
| 165 | cx25840_and_or(client, 0x810, ~0x1, 0x01); |
| 166 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 167 | /* Mute everything to prevent the PFFT! */ |
| 168 | cx25840_write(client, 0x8d3, 0x1f); |
| 169 | |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 170 | if (state->aud_input == CX25840_AUDIO_SERIAL) { |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 171 | /* Set Path1 to Serial Audio Input */ |
| 172 | cx25840_write4(client, 0x8d0, 0x12100101); |
| 173 | |
| 174 | /* The microcontroller should not be started for the |
| 175 | * non-tuner inputs: autodetection is specific for |
| 176 | * TV audio. */ |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 177 | } else { |
| 178 | /* Set Path1 to Analog Demod Main Channel */ |
| 179 | cx25840_write4(client, 0x8d0, 0x7038061f); |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 180 | } |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 181 | |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 182 | set_audclk_freq(client, state->audclk_freq); |
| 183 | |
Hans Verkuil | 2e2aef7 | 2006-04-29 12:26:46 -0300 | [diff] [blame] | 184 | /* deassert soft reset */ |
| 185 | if (!state->is_cx25836) |
| 186 | cx25840_and_or(client, 0x810, ~0x1, 0x00); |
| 187 | |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 188 | if (state->aud_input != CX25840_AUDIO_SERIAL) { |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 189 | /* When the microcontroller detects the |
| 190 | * audio format, it will unmute the lines */ |
| 191 | cx25840_and_or(client, 0x803, ~0x10, 0x10); |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 192 | } |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 195 | static int get_volume(struct i2c_client *client) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 196 | { |
Hans Verkuil | 87410da | 2007-08-05 08:00:36 -0300 | [diff] [blame^] | 197 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 198 | int vol; |
| 199 | |
| 200 | if (state->unmute_volume >= 0) |
| 201 | return state->unmute_volume; |
| 202 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 203 | /* Volume runs +18dB to -96dB in 1/2dB steps |
| 204 | * change to fit the msp3400 -114dB to +12dB range */ |
| 205 | |
| 206 | /* check PATH1_VOLUME */ |
Hans Verkuil | 87410da | 2007-08-05 08:00:36 -0300 | [diff] [blame^] | 207 | vol = 228 - cx25840_read(client, 0x8d4); |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 208 | vol = (vol / 2) + 23; |
| 209 | return vol << 9; |
| 210 | } |
| 211 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 212 | static void set_volume(struct i2c_client *client, int volume) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 213 | { |
Hans Verkuil | 87410da | 2007-08-05 08:00:36 -0300 | [diff] [blame^] | 214 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 215 | int vol; |
| 216 | |
| 217 | if (state->unmute_volume >= 0) { |
| 218 | state->unmute_volume = volume; |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | /* Convert the volume to msp3400 values (0-127) */ |
| 223 | vol = volume >> 9; |
| 224 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 225 | /* now scale it up to cx25840 values |
| 226 | * -114dB to -96dB maps to 0 |
| 227 | * this should be 19, but in my testing that was 4dB too loud */ |
| 228 | if (vol <= 23) { |
| 229 | vol = 0; |
| 230 | } else { |
| 231 | vol -= 23; |
| 232 | } |
| 233 | |
| 234 | /* PATH1_VOLUME */ |
| 235 | cx25840_write(client, 0x8d4, 228 - (vol * 2)); |
| 236 | } |
| 237 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 238 | static int get_bass(struct i2c_client *client) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 239 | { |
| 240 | /* bass is 49 steps +12dB to -12dB */ |
| 241 | |
| 242 | /* check PATH1_EQ_BASS_VOL */ |
| 243 | int bass = cx25840_read(client, 0x8d9) & 0x3f; |
| 244 | bass = (((48 - bass) * 0xffff) + 47) / 48; |
| 245 | return bass; |
| 246 | } |
| 247 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 248 | static void set_bass(struct i2c_client *client, int bass) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 249 | { |
| 250 | /* PATH1_EQ_BASS_VOL */ |
| 251 | cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff)); |
| 252 | } |
| 253 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 254 | static int get_treble(struct i2c_client *client) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 255 | { |
| 256 | /* treble is 49 steps +12dB to -12dB */ |
| 257 | |
| 258 | /* check PATH1_EQ_TREBLE_VOL */ |
| 259 | int treble = cx25840_read(client, 0x8db) & 0x3f; |
| 260 | treble = (((48 - treble) * 0xffff) + 47) / 48; |
| 261 | return treble; |
| 262 | } |
| 263 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 264 | static void set_treble(struct i2c_client *client, int treble) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 265 | { |
| 266 | /* PATH1_EQ_TREBLE_VOL */ |
| 267 | cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff)); |
| 268 | } |
| 269 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 270 | static int get_balance(struct i2c_client *client) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 271 | { |
| 272 | /* balance is 7 bit, 0 to -96dB */ |
| 273 | |
| 274 | /* check PATH1_BAL_LEVEL */ |
| 275 | int balance = cx25840_read(client, 0x8d5) & 0x7f; |
| 276 | /* check PATH1_BAL_LEFT */ |
| 277 | if ((cx25840_read(client, 0x8d5) & 0x80) == 0) |
| 278 | balance = 0x80 - balance; |
| 279 | else |
| 280 | balance = 0x80 + balance; |
| 281 | return balance << 8; |
| 282 | } |
| 283 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 284 | static void set_balance(struct i2c_client *client, int balance) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 285 | { |
| 286 | int bal = balance >> 8; |
| 287 | if (bal > 0x80) { |
| 288 | /* PATH1_BAL_LEFT */ |
| 289 | cx25840_and_or(client, 0x8d5, 0x7f, 0x80); |
| 290 | /* PATH1_BAL_LEVEL */ |
| 291 | cx25840_and_or(client, 0x8d5, ~0x7f, bal & 0x7f); |
| 292 | } else { |
| 293 | /* PATH1_BAL_LEFT */ |
| 294 | cx25840_and_or(client, 0x8d5, 0x7f, 0x00); |
| 295 | /* PATH1_BAL_LEVEL */ |
| 296 | cx25840_and_or(client, 0x8d5, ~0x7f, 0x80 - bal); |
| 297 | } |
| 298 | } |
| 299 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 300 | static int get_mute(struct i2c_client *client) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 301 | { |
Hans Verkuil | 87410da | 2007-08-05 08:00:36 -0300 | [diff] [blame^] | 302 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 303 | |
| 304 | return state->unmute_volume >= 0; |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 305 | } |
| 306 | |
Hans Verkuil | d92c20e | 2006-01-09 15:32:41 -0200 | [diff] [blame] | 307 | static void set_mute(struct i2c_client *client, int mute) |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 308 | { |
| 309 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 310 | |
Hans Verkuil | 87410da | 2007-08-05 08:00:36 -0300 | [diff] [blame^] | 311 | if (mute && state->unmute_volume == -1) { |
| 312 | int vol = get_volume(client); |
| 313 | |
| 314 | set_volume(client, 0); |
| 315 | state->unmute_volume = vol; |
| 316 | } |
| 317 | else if (!mute && state->unmute_volume != -1) { |
| 318 | int vol = state->unmute_volume; |
| 319 | |
| 320 | state->unmute_volume = -1; |
| 321 | set_volume(client, vol); |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | |
| 325 | int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg) |
| 326 | { |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 327 | struct cx25840_state *state = i2c_get_clientdata(client); |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 328 | struct v4l2_control *ctrl = arg; |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 329 | int retval; |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 330 | |
| 331 | switch (cmd) { |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 332 | case VIDIOC_INT_AUDIO_CLOCK_FREQ: |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 333 | if (state->aud_input != CX25840_AUDIO_SERIAL) { |
| 334 | cx25840_and_or(client, 0x803, ~0x10, 0); |
| 335 | cx25840_write(client, 0x8d3, 0x1f); |
| 336 | } |
Hans Verkuil | 2e2aef7 | 2006-04-29 12:26:46 -0300 | [diff] [blame] | 337 | if (!state->is_cx25836) |
| 338 | cx25840_and_or(client, 0x810, ~0x1, 1); |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 339 | retval = set_audclk_freq(client, *(u32 *)arg); |
Hans Verkuil | 2e2aef7 | 2006-04-29 12:26:46 -0300 | [diff] [blame] | 340 | if (!state->is_cx25836) |
| 341 | cx25840_and_or(client, 0x810, ~0x1, 0); |
Hans Verkuil | c0c044a | 2006-04-29 12:11:18 -0300 | [diff] [blame] | 342 | if (state->aud_input != CX25840_AUDIO_SERIAL) { |
| 343 | cx25840_and_or(client, 0x803, ~0x10, 0x10); |
| 344 | } |
| 345 | return retval; |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 346 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 347 | case VIDIOC_G_CTRL: |
| 348 | switch (ctrl->id) { |
| 349 | case V4L2_CID_AUDIO_VOLUME: |
| 350 | ctrl->value = get_volume(client); |
| 351 | break; |
| 352 | case V4L2_CID_AUDIO_BASS: |
| 353 | ctrl->value = get_bass(client); |
| 354 | break; |
| 355 | case V4L2_CID_AUDIO_TREBLE: |
| 356 | ctrl->value = get_treble(client); |
| 357 | break; |
| 358 | case V4L2_CID_AUDIO_BALANCE: |
| 359 | ctrl->value = get_balance(client); |
| 360 | break; |
| 361 | case V4L2_CID_AUDIO_MUTE: |
| 362 | ctrl->value = get_mute(client); |
| 363 | break; |
| 364 | default: |
| 365 | return -EINVAL; |
| 366 | } |
| 367 | break; |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 368 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 369 | case VIDIOC_S_CTRL: |
| 370 | switch (ctrl->id) { |
| 371 | case V4L2_CID_AUDIO_VOLUME: |
| 372 | set_volume(client, ctrl->value); |
| 373 | break; |
| 374 | case V4L2_CID_AUDIO_BASS: |
| 375 | set_bass(client, ctrl->value); |
| 376 | break; |
| 377 | case V4L2_CID_AUDIO_TREBLE: |
| 378 | set_treble(client, ctrl->value); |
| 379 | break; |
| 380 | case V4L2_CID_AUDIO_BALANCE: |
| 381 | set_balance(client, ctrl->value); |
| 382 | break; |
| 383 | case V4L2_CID_AUDIO_MUTE: |
| 384 | set_mute(client, ctrl->value); |
| 385 | break; |
| 386 | default: |
| 387 | return -EINVAL; |
| 388 | } |
| 389 | break; |
Hans Verkuil | a8bbf12 | 2006-01-09 15:25:42 -0200 | [diff] [blame] | 390 | |
Hans Verkuil | bd98516 | 2005-11-13 16:07:56 -0800 | [diff] [blame] | 391 | default: |
| 392 | return -EINVAL; |
| 393 | } |
| 394 | |
| 395 | return 0; |
| 396 | } |