1/* 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 3 * Universal routines for AK4531 codec 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 */ 21 22#include <linux/delay.h> 23#include <linux/init.h> 24#include <linux/slab.h> 25#include <linux/mutex.h> 26 27#include <sound/core.h> 28#include <sound/ak4531_codec.h> 29#include <sound/tlv.h> 30 31/* 32MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 33MODULE_DESCRIPTION("Universal routines for AK4531 codec"); 34MODULE_LICENSE("GPL"); 35*/ 36 37#ifdef CONFIG_PROC_FS 38static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531); 39#else 40#define snd_ak4531_proc_init(card,ak) 41#endif 42 43/* 44 * 45 */ 46 47 48/* 49 * 50 */ 51 52#define AK4531_SINGLE(xname, xindex, reg, shift, mask, invert) \ 53{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 54 .info = snd_ak4531_info_single, \ 55 .get = snd_ak4531_get_single, .put = snd_ak4531_put_single, \ 56 .private_value = reg | (shift << 16) | (mask << 24) | (invert << 22) } 57#define AK4531_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ 58{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 59 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 60 .name = xname, .index = xindex, \ 61 .info = snd_ak4531_info_single, \ 62 .get = snd_ak4531_get_single, .put = snd_ak4531_put_single, \ 63 .private_value = reg | (shift << 16) | (mask << 24) | (invert << 22), \ 64 .tlv = { .p = (xtlv) } } 65 66static int snd_ak4531_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 67{ 68 int mask = (kcontrol->private_value >> 24) & 0xff; 69 70 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; 71 uinfo->count = 1; 72 uinfo->value.integer.min = 0; 73 uinfo->value.integer.max = mask; 74 return 0; 75} 76 77static int snd_ak4531_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 78{ 79 struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); 80 int reg = kcontrol->private_value & 0xff; 81 int shift = (kcontrol->private_value >> 16) & 0x07; 82 int mask = (kcontrol->private_value >> 24) & 0xff; 83 int invert = (kcontrol->private_value >> 22) & 1; 84 int val; 85 86 mutex_lock(&ak4531->reg_mutex); 87 val = (ak4531->regs[reg] >> shift) & mask; 88 mutex_unlock(&ak4531->reg_mutex); 89 if (invert) { 90 val = mask - val; 91 } 92 ucontrol->value.integer.value[0] = val; 93 return 0; 94} 95 96static int snd_ak4531_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 97{ 98 struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); 99 int reg = kcontrol->private_value & 0xff; 100 int shift = (kcontrol->private_value >> 16) & 0x07; 101 int mask = (kcontrol->private_value >> 24) & 0xff; 102 int invert = (kcontrol->private_value >> 22) & 1; 103 int change; 104 int val; 105 106 val = ucontrol->value.integer.value[0] & mask; 107 if (invert) { 108 val = mask - val; 109 } 110 val <<= shift; 111 mutex_lock(&ak4531->reg_mutex); 112 val = (ak4531->regs[reg] & ~(mask << shift)) | val; 113 change = val != ak4531->regs[reg]; 114 ak4531->write(ak4531, reg, ak4531->regs[reg] = val); 115 mutex_unlock(&ak4531->reg_mutex); 116 return change; 117} 118 119#define AK4531_DOUBLE(xname, xindex, left_reg, right_reg, left_shift, right_shift, mask, invert) \ 120{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 121 .info = snd_ak4531_info_double, \ 122 .get = snd_ak4531_get_double, .put = snd_ak4531_put_double, \ 123 .private_value = left_reg | (right_reg << 8) | (left_shift << 16) | (right_shift << 19) | (mask << 24) | (invert << 22) } 124#define AK4531_DOUBLE_TLV(xname, xindex, left_reg, right_reg, left_shift, right_shift, mask, invert, xtlv) \ 125{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 126 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 127 .name = xname, .index = xindex, \ 128 .info = snd_ak4531_info_double, \ 129 .get = snd_ak4531_get_double, .put = snd_ak4531_put_double, \ 130 .private_value = left_reg | (right_reg << 8) | (left_shift << 16) | (right_shift << 19) | (mask << 24) | (invert << 22), \ 131 .tlv = { .p = (xtlv) } } 132 133static int snd_ak4531_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 134{ 135 int mask = (kcontrol->private_value >> 24) & 0xff; 136 137 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; 138 uinfo->count = 2; 139 uinfo->value.integer.min = 0; 140 uinfo->value.integer.max = mask; 141 return 0; 142} 143 144static int snd_ak4531_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 145{ 146 struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); 147 int left_reg = kcontrol->private_value & 0xff; 148 int right_reg = (kcontrol->private_value >> 8) & 0xff; 149 int left_shift = (kcontrol->private_value >> 16) & 0x07; 150 int right_shift = (kcontrol->private_value >> 19) & 0x07; 151 int mask = (kcontrol->private_value >> 24) & 0xff; 152 int invert = (kcontrol->private_value >> 22) & 1; 153 int left, right; 154 155 mutex_lock(&ak4531->reg_mutex); 156 left = (ak4531->regs[left_reg] >> left_shift) & mask; 157 right = (ak4531->regs[right_reg] >> right_shift) & mask; 158 mutex_unlock(&ak4531->reg_mutex); 159 if (invert) { 160 left = mask - left; 161 right = mask - right; 162 } 163 ucontrol->value.integer.value[0] = left; 164 ucontrol->value.integer.value[1] = right; 165 return 0; 166} 167 168static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 169{ 170 struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); 171 int left_reg = kcontrol->private_value & 0xff; 172 int right_reg = (kcontrol->private_value >> 8) & 0xff; 173 int left_shift = (kcontrol->private_value >> 16) & 0x07; 174 int right_shift = (kcontrol->private_value >> 19) & 0x07; 175 int mask = (kcontrol->private_value >> 24) & 0xff; 176 int invert = (kcontrol->private_value >> 22) & 1; 177 int change; 178 int left, right; 179 180 left = ucontrol->value.integer.value[0] & mask; 181 right = ucontrol->value.integer.value[1] & mask; 182 if (invert) { 183 left = mask - left; 184 right = mask - right; 185 } 186 left <<= left_shift; 187 right <<= right_shift; 188 mutex_lock(&ak4531->reg_mutex); 189 if (left_reg == right_reg) { 190 left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right; 191 change = left != ak4531->regs[left_reg]; 192 ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left); 193 } else { 194 left = (ak4531->regs[left_reg] & ~(mask << left_shift)) | left; 195 right = (ak4531->regs[right_reg] & ~(mask << right_shift)) | right; 196 change = left != ak4531->regs[left_reg] || right != ak4531->regs[right_reg]; 197 ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left); 198 ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right); 199 } 200 mutex_unlock(&ak4531->reg_mutex); 201 return change; 202} 203 204#define AK4531_INPUT_SW(xname, xindex, reg1, reg2, left_shift, right_shift) \ 205{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 206 .info = snd_ak4531_info_input_sw, \ 207 .get = snd_ak4531_get_input_sw, .put = snd_ak4531_put_input_sw, \ 208 .private_value = reg1 | (reg2 << 8) | (left_shift << 16) | (right_shift << 24) } 209 210static int snd_ak4531_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 211{ 212 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 213 uinfo->count = 4; 214 uinfo->value.integer.min = 0; 215 uinfo->value.integer.max = 1; 216 return 0; 217} 218 219static int snd_ak4531_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 220{ 221 struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); 222 int reg1 = kcontrol->private_value & 0xff; 223 int reg2 = (kcontrol->private_value >> 8) & 0xff; 224 int left_shift = (kcontrol->private_value >> 16) & 0x0f; 225 int right_shift = (kcontrol->private_value >> 24) & 0x0f; 226 227 mutex_lock(&ak4531->reg_mutex); 228 ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1; 229 ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1; 230 ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1; 231 ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1; 232 mutex_unlock(&ak4531->reg_mutex); 233 return 0; 234} 235 236static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 237{ 238 struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); 239 int reg1 = kcontrol->private_value & 0xff; 240 int reg2 = (kcontrol->private_value >> 8) & 0xff; 241 int left_shift = (kcontrol->private_value >> 16) & 0x0f; 242 int right_shift = (kcontrol->private_value >> 24) & 0x0f; 243 int change; 244 int val1, val2; 245 246 mutex_lock(&ak4531->reg_mutex); 247 val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift)); 248 val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift)); 249 val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift; 250 val2 |= (ucontrol->value.integer.value[1] & 1) << left_shift; 251 val1 |= (ucontrol->value.integer.value[2] & 1) << right_shift; 252 val2 |= (ucontrol->value.integer.value[3] & 1) << right_shift; 253 change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2]; 254 ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1); 255 ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2); 256 mutex_unlock(&ak4531->reg_mutex); 257 return change; 258} 259 260static const DECLARE_TLV_DB_SCALE(db_scale_master, -6200, 200, 0); 261static const DECLARE_TLV_DB_SCALE(db_scale_mono, -2800, 400, 0); 262static const DECLARE_TLV_DB_SCALE(db_scale_input, -5000, 200, 0); 263 264static struct snd_kcontrol_new snd_ak4531_controls[] __devinitdata = { 265 266AK4531_DOUBLE_TLV("Master Playback Switch", 0, 267 AK4531_LMASTER, AK4531_RMASTER, 7, 7, 1, 1, 268 db_scale_master), 269AK4531_DOUBLE("Master Playback Volume", 0, AK4531_LMASTER, AK4531_RMASTER, 0, 0, 0x1f, 1), 270 271AK4531_SINGLE_TLV("Master Mono Playback Switch", 0, AK4531_MONO_OUT, 7, 1, 1, 272 db_scale_mono), 273AK4531_SINGLE("Master Mono Playback Volume", 0, AK4531_MONO_OUT, 0, 0x07, 1), 274 275AK4531_DOUBLE("PCM Switch", 0, AK4531_LVOICE, AK4531_RVOICE, 7, 7, 1, 1), 276AK4531_DOUBLE_TLV("PCM Volume", 0, AK4531_LVOICE, AK4531_RVOICE, 0, 0, 0x1f, 1, 277 db_scale_input), 278AK4531_DOUBLE("PCM Playback Switch", 0, AK4531_OUT_SW2, AK4531_OUT_SW2, 3, 2, 1, 0), 279AK4531_DOUBLE("PCM Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 2, 2, 1, 0), 280 281AK4531_DOUBLE("PCM Switch", 1, AK4531_LFM, AK4531_RFM, 7, 7, 1, 1), 282AK4531_DOUBLE_TLV("PCM Volume", 1, AK4531_LFM, AK4531_RFM, 0, 0, 0x1f, 1, 283 db_scale_input), 284AK4531_DOUBLE("PCM Playback Switch", 1, AK4531_OUT_SW1, AK4531_OUT_SW1, 6, 5, 1, 0), 285AK4531_INPUT_SW("PCM Capture Route", 1, AK4531_LIN_SW1, AK4531_RIN_SW1, 6, 5), 286 287AK4531_DOUBLE("CD Switch", 0, AK4531_LCD, AK4531_RCD, 7, 7, 1, 1), 288AK4531_DOUBLE_TLV("CD Volume", 0, AK4531_LCD, AK4531_RCD, 0, 0, 0x1f, 1, 289 db_scale_input), 290AK4531_DOUBLE("CD Playback Switch", 0, AK4531_OUT_SW1, AK4531_OUT_SW1, 2, 1, 1, 0), 291AK4531_INPUT_SW("CD Capture Route", 0, AK4531_LIN_SW1, AK4531_RIN_SW1, 2, 1), 292 293AK4531_DOUBLE("Line Switch", 0, AK4531_LLINE, AK4531_RLINE, 7, 7, 1, 1), 294AK4531_DOUBLE_TLV("Line Volume", 0, AK4531_LLINE, AK4531_RLINE, 0, 0, 0x1f, 1, 295 db_scale_input), 296AK4531_DOUBLE("Line Playback Switch", 0, AK4531_OUT_SW1, AK4531_OUT_SW1, 4, 3, 1, 0), 297AK4531_INPUT_SW("Line Capture Route", 0, AK4531_LIN_SW1, AK4531_RIN_SW1, 4, 3), 298 299AK4531_DOUBLE("Aux Switch", 0, AK4531_LAUXA, AK4531_RAUXA, 7, 7, 1, 1), 300AK4531_DOUBLE_TLV("Aux Volume", 0, AK4531_LAUXA, AK4531_RAUXA, 0, 0, 0x1f, 1, 301 db_scale_input), 302AK4531_DOUBLE("Aux Playback Switch", 0, AK4531_OUT_SW2, AK4531_OUT_SW2, 5, 4, 1, 0), 303AK4531_INPUT_SW("Aux Capture Route", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 4, 3), 304 305AK4531_SINGLE("Mono Switch", 0, AK4531_MONO1, 7, 1, 1), 306AK4531_SINGLE_TLV("Mono Volume", 0, AK4531_MONO1, 0, 0x1f, 1, db_scale_input), 307AK4531_SINGLE("Mono Playback Switch", 0, AK4531_OUT_SW2, 0, 1, 0), 308AK4531_DOUBLE("Mono Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 0, 0, 1, 0), 309 310AK4531_SINGLE("Mono Switch", 1, AK4531_MONO2, 7, 1, 1), 311AK4531_SINGLE_TLV("Mono Volume", 1, AK4531_MONO2, 0, 0x1f, 1, db_scale_input), 312AK4531_SINGLE("Mono Playback Switch", 1, AK4531_OUT_SW2, 1, 1, 0), 313AK4531_DOUBLE("Mono Capture Switch", 1, AK4531_LIN_SW2, AK4531_RIN_SW2, 1, 1, 1, 0), 314 315AK4531_SINGLE_TLV("Mic Volume", 0, AK4531_MIC, 0, 0x1f, 1, db_scale_input), 316AK4531_SINGLE("Mic Switch", 0, AK4531_MIC, 7, 1, 1), 317AK4531_SINGLE("Mic Playback Switch", 0, AK4531_OUT_SW1, 0, 1, 0), 318AK4531_DOUBLE("Mic Capture Switch", 0, AK4531_LIN_SW1, AK4531_RIN_SW1, 0, 0, 1, 0), 319 320AK4531_DOUBLE("Mic Bypass Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 7, 7, 1, 0), 321AK4531_DOUBLE("Mono1 Bypass Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 6, 6, 1, 0), 322AK4531_DOUBLE("Mono2 Bypass Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 5, 5, 1, 0), 323 324AK4531_SINGLE("AD Input Select", 0, AK4531_AD_IN, 0, 1, 0), 325AK4531_SINGLE("Mic Boost (+30dB)", 0, AK4531_MIC_GAIN, 0, 1, 0) 326}; 327 328static int snd_ak4531_free(struct snd_ak4531 *ak4531) 329{ 330 if (ak4531) { 331 if (ak4531->private_free) 332 ak4531->private_free(ak4531); 333 kfree(ak4531); 334 } 335 return 0; 336} 337 338static int snd_ak4531_dev_free(struct snd_device *device) 339{ 340 struct snd_ak4531 *ak4531 = device->device_data; 341 return snd_ak4531_free(ak4531); 342} 343 344static u8 snd_ak4531_initial_map[0x19 + 1] = { 345 0x9f, /* 00: Master Volume Lch */ 346 0x9f, /* 01: Master Volume Rch */ 347 0x9f, /* 02: Voice Volume Lch */ 348 0x9f, /* 03: Voice Volume Rch */ 349 0x9f, /* 04: FM Volume Lch */ 350 0x9f, /* 05: FM Volume Rch */ 351 0x9f, /* 06: CD Audio Volume Lch */ 352 0x9f, /* 07: CD Audio Volume Rch */ 353 0x9f, /* 08: Line Volume Lch */ 354 0x9f, /* 09: Line Volume Rch */ 355 0x9f, /* 0a: Aux Volume Lch */ 356 0x9f, /* 0b: Aux Volume Rch */ 357 0x9f, /* 0c: Mono1 Volume */ 358 0x9f, /* 0d: Mono2 Volume */ 359 0x9f, /* 0e: Mic Volume */ 360 0x87, /* 0f: Mono-out Volume */ 361 0x00, /* 10: Output Mixer SW1 */ 362 0x00, /* 11: Output Mixer SW2 */ 363 0x00, /* 12: Lch Input Mixer SW1 */ 364 0x00, /* 13: Rch Input Mixer SW1 */ 365 0x00, /* 14: Lch Input Mixer SW2 */ 366 0x00, /* 15: Rch Input Mixer SW2 */ 367 0x00, /* 16: Reset & Power Down */ 368 0x00, /* 17: Clock Select */ 369 0x00, /* 18: AD Input Select */ 370 0x01 /* 19: Mic Amp Setup */ 371}; 372 373int __devinit snd_ak4531_mixer(struct snd_card *card, 374 struct snd_ak4531 *_ak4531, 375 struct snd_ak4531 **rak4531) 376{ 377 unsigned int idx; 378 int err; 379 struct snd_ak4531 *ak4531; 380 static struct snd_device_ops ops = { 381 .dev_free = snd_ak4531_dev_free, 382 }; 383 384 if (snd_BUG_ON(!card || !_ak4531)) 385 return -EINVAL; 386 if (rak4531) 387 *rak4531 = NULL; 388 ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL); 389 if (ak4531 == NULL) 390 return -ENOMEM; 391 *ak4531 = *_ak4531; 392 mutex_init(&ak4531->reg_mutex); 393 if ((err = snd_component_add(card, "AK4531")) < 0) { 394 snd_ak4531_free(ak4531); 395 return err; 396 } 397 strcpy(card->mixername, "Asahi Kasei AK4531"); 398 ak4531->write(ak4531, AK4531_RESET, 0x03); /* no RST, PD */ 399 udelay(100); 400 ak4531->write(ak4531, AK4531_CLOCK, 0x00); /* CODEC ADC and CODEC DAC use {LR,B}CLK2 and run off LRCLK2 PLL */ 401 for (idx = 0; idx <= 0x19; idx++) { 402 if (idx == AK4531_RESET || idx == AK4531_CLOCK) 403 continue; 404 ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]); /* recording source is mixer */ 405 } 406 for (idx = 0; idx < ARRAY_SIZE(snd_ak4531_controls); idx++) { 407 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ak4531_controls[idx], ak4531))) < 0) { 408 snd_ak4531_free(ak4531); 409 return err; 410 } 411 } 412 snd_ak4531_proc_init(card, ak4531); 413 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops)) < 0) { 414 snd_ak4531_free(ak4531); 415 return err; 416 } 417 418 if (rak4531) 419 *rak4531 = ak4531; 420 return 0; 421} 422 423/* 424 * power management 425 */ 426#ifdef CONFIG_PM 427void snd_ak4531_suspend(struct snd_ak4531 *ak4531) 428{ 429 /* mute */ 430 ak4531->write(ak4531, AK4531_LMASTER, 0x9f); 431 ak4531->write(ak4531, AK4531_RMASTER, 0x9f); 432 /* powerdown */ 433 ak4531->write(ak4531, AK4531_RESET, 0x01); 434} 435 436void snd_ak4531_resume(struct snd_ak4531 *ak4531) 437{ 438 int idx; 439 440 /* initialize */ 441 ak4531->write(ak4531, AK4531_RESET, 0x03); 442 udelay(100); 443 ak4531->write(ak4531, AK4531_CLOCK, 0x00); 444 /* restore mixer registers */ 445 for (idx = 0; idx <= 0x19; idx++) { 446 if (idx == AK4531_RESET || idx == AK4531_CLOCK) 447 continue; 448 ak4531->write(ak4531, idx, ak4531->regs[idx]); 449 } 450} 451#endif 452 453#ifdef CONFIG_PROC_FS 454/* 455 * /proc interface 456 */ 457 458static void snd_ak4531_proc_read(struct snd_info_entry *entry, 459 struct snd_info_buffer *buffer) 460{ 461 struct snd_ak4531 *ak4531 = entry->private_data; 462 463 snd_iprintf(buffer, "Asahi Kasei AK4531\n\n"); 464 snd_iprintf(buffer, "Recording source : %s\n" 465 "MIC gain : %s\n", 466 ak4531->regs[AK4531_AD_IN] & 1 ? "external" : "mixer", 467 ak4531->regs[AK4531_MIC_GAIN] & 1 ? "+30dB" : "+0dB"); 468} 469 470static void __devinit 471snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531) 472{ 473 struct snd_info_entry *entry; 474 475 if (! snd_card_proc_new(card, "ak4531", &entry)) 476 snd_info_set_text_ops(entry, ak4531, snd_ak4531_proc_read); 477} 478#endif 479