28 #include <linux/slab.h>
44 #define WM_HP_ATTEN_L 0x00
45 #define WM_HP_ATTEN_R 0x01
46 #define WM_HP_MASTER 0x02
48 #define WM_DAC_ATTEN_L 0x03
49 #define WM_DAC_ATTEN_R 0x04
50 #define WM_DAC_MASTER 0x05
51 #define WM_PHASE_SWAP 0x06
52 #define WM_DAC_CTRL1 0x07
53 #define WM_DAC_MUTE 0x08
54 #define WM_DAC_CTRL2 0x09
55 #define WM_DAC_INT 0x0a
56 #define WM_ADC_INT 0x0b
57 #define WM_MASTER_CTRL 0x0c
58 #define WM_POWERDOWN 0x0d
59 #define WM_ADC_ATTEN_L 0x0e
60 #define WM_ADC_ATTEN_R 0x0f
61 #define WM_ALC_CTRL1 0x10
62 #define WM_ALC_CTRL2 0x11
63 #define WM_ALC_CTRL3 0x12
64 #define WM_NOISE_GATE 0x13
65 #define WM_LIMITER 0x14
66 #define WM_ADC_MUX 0x15
67 #define WM_OUT_MUX 0x16
73 #define PONTIS_CS_CS (1<<4)
74 #define PONTIS_CS_CLK (1<<5)
75 #define PONTIS_CS_RDATA (1<<6)
76 #define PONTIS_CS_WDATA (1<<7)
85 return ((
unsigned short)ice->
akm[0].images[reg] << 8) |
86 ice->
akm[0].images[reg + 1];
95 cval = (reg << 9) | val;
101 wm_put_nocache(ice, reg, val);
103 ice->
akm[0].images[
reg] = val >> 8;
104 ice->
akm[0].images[reg + 1] =
val;
113 #define DAC_MIN (DAC_0dB - DAC_RES)
131 for (i = 0; i < 2; i++) {
143 unsigned short oval, nval;
144 int i,
idx, change = 0;
147 for (i = 0; i < 2; i++) {
148 nval = ucontrol->
value.integer.value[
i];
149 nval = (nval ? (nval +
DAC_MIN) : 0) & 0xff;
151 oval = wm_get(ice, idx) & 0xff;
153 wm_put(ice, idx, nval);
154 wm_put_nocache(ice, idx, nval | 0x100);
168 #define ADC_MIN (ADC_0dB - ADC_RES)
186 for (i = 0; i < 2; i++) {
198 unsigned short ovol, nvol;
199 int i,
idx, change = 0;
202 for (i = 0; i < 2; i++) {
203 nvol = ucontrol->
value.integer.value[
i];
204 nvol = nvol ? (nvol +
ADC_MIN) : 0;
206 ovol = wm_get(ice, idx) & 0xff;
208 wm_put(ice, idx, nvol);
219 #define wm_adc_mux_info snd_ctl_boolean_mono_info
236 unsigned short oval, nval;
241 if (ucontrol->
value.integer.value[0])
245 change = nval != oval;
256 #define wm_bypass_info snd_ctl_boolean_mono_info
263 ucontrol->
value.integer.value[0] = (wm_get(ice,
WM_OUT_MUX) & 0x04) ? 1 : 0;
271 unsigned short val, oval;
276 if (ucontrol->
value.integer.value[0])
291 #define wm_chswap_info snd_ctl_boolean_mono_info
306 unsigned short val, oval;
312 if (ucontrol->
value.integer.value[0])
328 static void set_gpio_bit(
struct snd_ice1712 *ice,
unsigned int bit,
int val)
330 unsigned int tmp = snd_ice1712_gpio_read(ice);
335 snd_ice1712_gpio_write(ice, tmp);
341 for (i = 0; i < 8; i++) {
352 static unsigned int spi_read_byte(
struct snd_ice1712 *ice)
355 unsigned int val = 0;
357 for (i = 0; i < 8; i++) {
371 static void spi_write(
struct snd_ice1712 *ice,
unsigned int dev,
unsigned int reg,
unsigned int data)
376 spi_send_byte(ice, dev & ~1);
377 spi_send_byte(ice, reg);
378 spi_send_byte(ice, data);
383 snd_ice1712_gpio_set_mask(ice, ice->
gpio.write_mask);
384 snd_ice1712_gpio_set_dir(ice, ice->
gpio.direction);
387 static unsigned int spi_read(
struct snd_ice1712 *ice,
unsigned int dev,
unsigned int reg)
393 spi_send_byte(ice, dev & ~1);
394 spi_send_byte(ice, reg);
399 spi_send_byte(ice, dev | 1);
400 val = spi_read_byte(ice);
405 snd_ice1712_gpio_set_mask(ice, ice->
gpio.write_mask);
406 snd_ice1712_gpio_set_dir(ice, ice->
gpio.direction);
416 static const char *
const texts[] = {
435 ucontrol->
value.enumerated.item[0] = ice->
gpio.saved[0];
447 if (ucontrol->
value.enumerated.item[0] != ice->
gpio.saved[0]) {
448 ice->
gpio.saved[0] = ucontrol->
value.enumerated.item[0] & 3;
449 val = 0x80 | (ice->
gpio.saved[0] << 3);
450 spi_write(ice,
CS_DEV, 0x04, val);
475 ucontrol->
value.integer.value[0] = (~ice->
gpio.write_mask & 0xffff) | 0x00f0;
487 val = (~ucontrol->
value.integer.value[0] & 0xffff) | 0x00f0;
488 changed = val != ice->
gpio.write_mask;
499 ucontrol->
value.integer.value[0] = ice->
gpio.direction & 0xff0f;
511 val = ucontrol->
value.integer.value[0] & 0xff0f;
512 changed = (val != ice->
gpio.direction);
522 snd_ice1712_gpio_set_dir(ice, ice->
gpio.direction);
523 snd_ice1712_gpio_set_mask(ice, ice->
gpio.write_mask);
524 ucontrol->
value.integer.value[0] = snd_ice1712_gpio_read(ice) & 0xffff;
532 unsigned int val, nval;
535 snd_ice1712_gpio_set_dir(ice, ice->
gpio.direction);
536 snd_ice1712_gpio_set_mask(ice, ice->
gpio.write_mask);
537 val = snd_ice1712_gpio_read(ice) & 0xffff;
538 nval = ucontrol->
value.integer.value[0] & 0xffff;
540 snd_ice1712_gpio_write(ice, nval);
558 .
name =
"PCM Playback Volume",
559 .
info = wm_dac_vol_info,
560 .
get = wm_dac_vol_get,
561 .
put = wm_dac_vol_put,
562 .
tlv = { .p = db_scale_volume },
568 .
name =
"Capture Volume",
569 .
info = wm_adc_vol_info,
570 .
get = wm_adc_vol_get,
571 .
put = wm_adc_vol_put,
572 .
tlv = { .p = db_scale_volume },
576 .name =
"CD Capture Switch",
578 .get = wm_adc_mux_get,
579 .put = wm_adc_mux_put,
584 .name =
"Line Capture Switch",
586 .get = wm_adc_mux_get,
587 .put = wm_adc_mux_put,
592 .name =
"Analog Bypass Switch",
594 .get = wm_bypass_get,
595 .put = wm_bypass_put,
599 .name =
"Swap Output Channels",
601 .get = wm_chswap_get,
602 .put = wm_chswap_put,
606 .name =
"IEC958 Input Source",
607 .info = cs_source_info,
608 .get = cs_source_get,
609 .put = cs_source_put,
615 .info = pontis_gpio_mask_info,
616 .get = pontis_gpio_mask_get,
617 .put = pontis_gpio_mask_put,
621 .name =
"GPIO Direction",
622 .info = pontis_gpio_mask_info,
623 .get = pontis_gpio_dir_get,
624 .put = pontis_gpio_dir_put,
629 .info = pontis_gpio_mask_info,
630 .get = pontis_gpio_data_get,
631 .put = pontis_gpio_data_put,
645 while (!snd_info_get_line(buffer, line,
sizeof(line))) {
646 if (
sscanf(line,
"%x %x", ®, &val) != 2)
648 if (reg <= 0x17 && val <= 0xffff)
649 wm_put(ice, reg, val);
660 for (reg = 0; reg <= 0x17; reg++) {
661 val = wm_get(ice, reg);
662 snd_iprintf(buffer,
"%02x = %04x\n", reg, val);
670 if (! snd_card_proc_new(ice->
card,
"wm_codec", &entry)) {
671 snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
673 entry->
c.
text.write = wm_proc_regs_write;
683 for (reg = 0; reg <= 0x26; reg++) {
684 val = spi_read(ice,
CS_DEV, reg);
685 snd_iprintf(buffer,
"%02x = %02x\n", reg, val);
687 val = spi_read(ice,
CS_DEV, 0x7f);
688 snd_iprintf(buffer,
"%02x = %02x\n", 0x7f, val);
695 if (! snd_card_proc_new(ice->
card,
"cs_codec", &entry))
696 snd_info_set_text_ops(entry, ice, cs_proc_regs_read);
705 for (i = 0; i <
ARRAY_SIZE(pontis_controls); i++) {
723 static const unsigned short wm_inits[] = {
732 static const unsigned short wm_inits2[] = {
758 static const unsigned char cs_inits[] = {
780 ice->
gpio.saved[0] = 0;
784 wm_put(ice, wm_inits[i], wm_inits[i+1]);
786 for (i = 0; i <
ARRAY_SIZE(wm_inits2); i += 2)
787 wm_put(ice, wm_inits2[i], wm_inits2[i+1]);
797 spi_write(ice,
CS_DEV, cs_inits[i], cs_inits[i+1]);
808 static unsigned char pontis_eeprom[] __devinitdata = {
828 .name =
"Pontis MS300",
830 .chip_init = pontis_init,
831 .build_controls = pontis_add_controls,
832 .eeprom_size =
sizeof(pontis_eeprom),