24 #include <linux/slab.h>
26 #include <linux/module.h>
41 #define snd_ak4531_proc_init(card,ak)
50 static void snd_ak4531_dump(
struct snd_ak4531 *ak4531)
54 for (idx = 0; idx < 0x19; idx++)
56 idx, ak4531->
regs[idx]);
65 #define AK4531_SINGLE(xname, xindex, reg, shift, mask, invert) \
66 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
67 .info = snd_ak4531_info_single, \
68 .get = snd_ak4531_get_single, .put = snd_ak4531_put_single, \
69 .private_value = reg | (shift << 16) | (mask << 24) | (invert << 22) }
70 #define AK4531_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
71 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
72 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
73 .name = xname, .index = xindex, \
74 .info = snd_ak4531_info_single, \
75 .get = snd_ak4531_get_single, .put = snd_ak4531_put_single, \
76 .private_value = reg | (shift << 16) | (mask << 24) | (invert << 22), \
77 .tlv = { .p = (xtlv) } }
100 val = (ak4531->
regs[
reg] >> shift) & mask;
105 ucontrol->
value.integer.value[0] =
val;
119 val = ucontrol->
value.integer.value[0] &
mask;
125 val = (ak4531->
regs[
reg] & ~(mask << shift)) |
val;
126 change = val != ak4531->
regs[
reg];
127 ak4531->
write(ak4531, reg, ak4531->
regs[reg] = val);
132 #define AK4531_DOUBLE(xname, xindex, left_reg, right_reg, left_shift, right_shift, mask, invert) \
133 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
134 .info = snd_ak4531_info_double, \
135 .get = snd_ak4531_get_double, .put = snd_ak4531_put_double, \
136 .private_value = left_reg | (right_reg << 8) | (left_shift << 16) | (right_shift << 19) | (mask << 24) | (invert << 22) }
137 #define AK4531_DOUBLE_TLV(xname, xindex, left_reg, right_reg, left_shift, right_shift, mask, invert, xtlv) \
138 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
139 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
140 .name = xname, .index = xindex, \
141 .info = snd_ak4531_info_double, \
142 .get = snd_ak4531_get_double, .put = snd_ak4531_put_double, \
143 .private_value = left_reg | (right_reg << 8) | (left_shift << 16) | (right_shift << 19) | (mask << 24) | (invert << 22), \
144 .tlv = { .p = (xtlv) } }
169 left = (ak4531->
regs[left_reg] >> left_shift) & mask;
170 right = (ak4531->
regs[right_reg] >> right_shift) & mask;
174 right = mask -
right;
193 left = ucontrol->
value.integer.value[0] &
mask;
194 right = ucontrol->
value.integer.value[1] &
mask;
197 right = mask -
right;
200 right <<= right_shift;
202 if (left_reg == right_reg) {
203 left = (ak4531->
regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left |
right;
204 change = left != ak4531->
regs[left_reg];
205 ak4531->
write(ak4531, left_reg, ak4531->
regs[left_reg] = left);
207 left = (ak4531->
regs[left_reg] & ~(mask << left_shift)) |
left;
208 right = (ak4531->
regs[right_reg] & ~(mask << right_shift)) |
right;
209 change = left != ak4531->
regs[left_reg] || right != ak4531->
regs[right_reg];
210 ak4531->
write(ak4531, left_reg, ak4531->
regs[left_reg] = left);
211 ak4531->
write(ak4531, right_reg, ak4531->
regs[right_reg] = right);
217 #define AK4531_INPUT_SW(xname, xindex, reg1, reg2, left_shift, right_shift) \
218 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
219 .info = snd_ak4531_info_input_sw, \
220 .get = snd_ak4531_get_input_sw, .put = snd_ak4531_put_input_sw, \
221 .private_value = reg1 | (reg2 << 8) | (left_shift << 16) | (right_shift << 24) }
241 ucontrol->
value.integer.value[0] = (ak4531->
regs[
reg1] >> left_shift) & 1;
242 ucontrol->
value.integer.value[1] = (ak4531->
regs[
reg2] >> left_shift) & 1;
243 ucontrol->
value.integer.value[2] = (ak4531->
regs[
reg1] >> right_shift) & 1;
244 ucontrol->
value.integer.value[3] = (ak4531->
regs[
reg2] >> right_shift) & 1;
260 val1 = ak4531->
regs[
reg1] & ~((1 << left_shift) | (1 << right_shift));
261 val2 = ak4531->
regs[
reg2] & ~((1 << left_shift) | (1 << right_shift));
262 val1 |= (ucontrol->
value.integer.value[0] & 1) << left_shift;
263 val2 |= (ucontrol->
value.integer.value[1] & 1) << left_shift;
264 val1 |= (ucontrol->
value.integer.value[2] & 1) << right_shift;
265 val2 |= (ucontrol->
value.integer.value[3] & 1) << right_shift;
267 ak4531->
write(ak4531, reg1, ak4531->
regs[reg1] = val1);
268 ak4531->
write(ak4531, reg2, ak4531->
regs[reg2] = val2);
341 static int snd_ak4531_free(
struct snd_ak4531 *ak4531)
354 return snd_ak4531_free(ak4531);
357 static u8 snd_ak4531_initial_map[0x19 + 1] = {
401 ak4531 = kzalloc(
sizeof(*ak4531),
GFP_KERNEL);
407 snd_ak4531_free(ak4531);
414 for (idx = 0; idx <= 0x19; idx++) {
417 ak4531->
write(ak4531, idx, ak4531->
regs[idx] = snd_ak4531_initial_map[idx]);
419 for (idx = 0; idx <
ARRAY_SIZE(snd_ak4531_controls); idx++) {
421 snd_ak4531_free(ak4531);
427 snd_ak4531_free(ak4531);
432 snd_ak4531_dump(ak4531);
443 void snd_ak4531_suspend(
struct snd_ak4531 *ak4531)
452 void snd_ak4531_resume(
struct snd_ak4531 *ak4531)
461 for (idx = 0; idx <= 0x19; idx++) {
464 ak4531->
write(ak4531, idx, ak4531->
regs[idx]);
469 #ifdef CONFIG_PROC_FS
479 snd_iprintf(buffer,
"Asahi Kasei AK4531\n\n");
480 snd_iprintf(buffer,
"Recording source : %s\n"
491 if (! snd_card_proc_new(card,
"ak4531", &entry))
492 snd_info_set_text_ops(entry, ak4531, snd_ak4531_proc_read);