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