26 #include <linux/slab.h>
38 #define WM8776_REG_HEADPHONE_L 0x00
39 #define WM8776_REG_HEADPHONE_R 0x01
40 #define WM8776_REG_HEADPHONE_MASTER 0x02
41 #define WM8776_REG_DAC_ATTEN_L 0x03
42 #define WM8776_REG_DAC_ATTEN_R 0x04
43 #define WM8776_REG_DAC_ATTEN_MASTER 0x05
44 #define WM8776_REG_DAC_PHASE 0x06
45 #define WM8776_REG_DAC_CONTROL 0x07
46 #define WM8776_REG_DAC_MUTE 0x08
47 #define WM8776_REG_DAC_DEEMPH 0x09
48 #define WM8776_REG_DAC_IF_CONTROL 0x0a
49 #define WM8776_REG_ADC_IF_CONTROL 0x0b
50 #define WM8776_REG_MASTER_MODE_CONTROL 0x0c
51 #define WM8776_REG_POWERDOWN 0x0d
52 #define WM8776_REG_ADC_ATTEN_L 0x0e
53 #define WM8776_REG_ADC_ATTEN_R 0x0f
54 #define WM8776_REG_ADC_ALC1 0x10
55 #define WM8776_REG_ADC_ALC2 0x11
56 #define WM8776_REG_ADC_ALC3 0x12
57 #define WM8776_REG_ADC_NOISE_GATE 0x13
58 #define WM8776_REG_ADC_LIMITER 0x14
59 #define WM8776_REG_ADC_MUX 0x15
60 #define WM8776_REG_OUTPUT_MUX 0x16
61 #define WM8776_REG_RESET 0x17
63 #define WM8776_NUM_REGS 0x18
66 #define WM8776_CLOCK_RATIO_128FS 0
67 #define WM8776_CLOCK_RATIO_192FS 1
68 #define WM8776_CLOCK_RATIO_256FS 2
69 #define WM8776_CLOCK_RATIO_384FS 3
70 #define WM8776_CLOCK_RATIO_512FS 4
71 #define WM8776_CLOCK_RATIO_768FS 5
92 unsigned char reg,
unsigned short val)
99 (reg << 1) | ((val >> 8) & 1),
109 unsigned short mask,
unsigned short val)
112 if (val != wm->
regs[reg]) {
113 wm8776_write(ice, wm, reg, val);
158 .mux_bits = { 0x80, 0x40 },
190 &chip->
wm[snd_ctl_get_ioff(kcontrol, &ucontrol->
id)];
205 &chip->
wm[snd_ctl_get_ioff(kcontrol, &ucontrol->
id)];
212 for (ch = 0; ch < 2; ch++) {
213 val = ucontrol->
value.integer.value[ch];
216 if (val == wm->
volumes[idx][ch])
221 data = (val - 1) + vol->
offset;
223 changed |= wm8776_write_bits(chip->
ice, wm, vol->
regs[ch],
239 #define COMPOSE_SW_VAL(idx, reg, mask) ((idx) | ((reg) << 8) | ((mask) << 16))
240 #define GET_SW_VAL_IDX(val) ((val) & 0xff)
241 #define GET_SW_VAL_REG(val) (((val) >> 8) & 0xff)
242 #define GET_SW_VAL_MASK(val) (((val) >> 16) & 0xff)
244 #define maya_sw_info snd_ctl_boolean_mono_info
251 &chip->
wm[snd_ctl_get_ioff(kcontrol, &ucontrol->
id)];
263 &chip->
wm[snd_ctl_get_ioff(kcontrol, &ucontrol->
id)];
271 val = ucontrol->
value.integer.value[0];
275 changed = wm8776_write_bits(chip->
ice, wm,
277 mask, val ? mask : 0);
285 #define GPIO_PHANTOM_OFF 2
286 #define GPIO_MIC_RELAY 4
287 #define GPIO_SPDIF_IN_INV 5
288 #define GPIO_MUST_BE_0 7
294 #define COMPOSE_GPIO_VAL(shift, inv) ((shift) | ((inv) << 8))
295 #define GET_GPIO_VAL_SHIFT(val) ((val) & 0xff)
296 #define GET_GPIO_VAL_INV(val) (((val) >> 8) & 1)
298 static int maya_set_gpio_bits(
struct snd_ice1712 *ice,
unsigned int mask,
302 data = snd_ice1712_gpio_read(ice);
303 if ((data & mask) == bits)
305 snd_ice1712_gpio_write(ice, (data & ~mask) | bits);
309 #define maya_gpio_sw_info snd_ctl_boolean_mono_info
311 static int maya_gpio_sw_get(
struct snd_kcontrol *kcontrol,
318 val = (snd_ice1712_gpio_read(chip->
ice) >> shift) & 1;
321 ucontrol->
value.integer.value[0] =
val;
325 static int maya_gpio_sw_put(
struct snd_kcontrol *kcontrol,
335 val = ucontrol->
value.integer.value[0];
338 val = val ? mask : 0;
339 changed = maya_set_gpio_bits(chip->
ice, mask, val);
349 #define MAYA_LINE_IN 1
350 #define MAYA_MIC_IN 3
352 static void wm8776_select_input(
struct snd_maya44 *chip,
int idx,
int line)
358 static int maya_rec_src_info(
struct snd_kcontrol *kcontrol,
361 static char *texts[] = {
"Line",
"Mic" };
374 static int maya_rec_src_get(
struct snd_kcontrol *kcontrol,
384 ucontrol->
value.enumerated.item[0] =
sel;
388 static int maya_rec_src_put(
struct snd_kcontrol *kcontrol,
392 int sel = ucontrol->
value.enumerated.item[0];
407 static int maya_pb_route_info(
struct snd_kcontrol *kcontrol,
410 static char *texts[] = {
412 "Input 1",
"Input 2",
"Input 3",
"Input 4"
426 static int maya_pb_route_shift(
int idx)
428 static const unsigned char shift[10] =
429 { 8, 20, 0, 3, 11, 23, 14, 26, 17, 29 };
430 return shift[idx % 10];
433 static int maya_pb_route_get(
struct snd_kcontrol *kcontrol,
437 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
438 ucontrol->
value.enumerated.item[0] =
443 static int maya_pb_route_put(
struct snd_kcontrol *kcontrol,
447 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
449 ucontrol->
value.enumerated.item[0],
450 maya_pb_route_shift(idx));
460 .name =
"Crossmix Playback Volume",
467 .tlv = { .p = db_scale_hp },
472 .name =
"PCM Playback Volume",
479 .tlv = { .p = db_scale_dac },
484 .name =
"Line Capture Volume",
491 .tlv = { .p = db_scale_adc },
496 .name =
"PCM Playback Switch",
506 .name =
"Bypass Playback Switch",
516 .name =
"Capture Source",
518 .info = maya_rec_src_info,
519 .get = maya_rec_src_get,
520 .put = maya_rec_src_put,
523 .name =
"Mic Phantom Power Switch",
526 .get = maya_gpio_sw_get,
527 .put = maya_gpio_sw_put,
531 .name =
"SPDIF Capture Switch",
534 .get = maya_gpio_sw_get,
535 .put = maya_gpio_sw_put,
540 .name =
"H/W Playback Route",
541 .info = maya_pb_route_info,
542 .get = maya_pb_route_get,
543 .put = maya_pb_route_put,
552 for (i = 0; i <
ARRAY_SIZE(maya_controls); i++) {
568 static const unsigned short inits_wm8776[] = {
594 const unsigned short *
ptr;
603 while (*ptr != 0xff) {
606 wm8776_write(ice, wm, reg, data);
670 for (i = 0; i < 2; i++)
671 wm8776_write_bits(ice, &chip->
wm[i],
681 static unsigned int rates[] = {
682 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000
696 static unsigned char wm8776_addr[2] __devinitdata = {
720 for (i = 0; i < 2; i++) {
721 wm8776_init(ice, &chip->
wm[i], wm8776_addr[i]);
729 ice->
gpio.set_pro_rate = set_rate;
746 static unsigned char maya44_eeprom[] __devinitdata = {
771 .name =
"ESI Maya44",
773 .chip_init = maya44_init,
774 .build_controls = maya44_add_controls,
775 .eeprom_size =
sizeof(maya44_eeprom),