30 #include <linux/slab.h>
46 #define AK4114_ADDR 0x20
47 #define AK4358_ADDR 0x22
78 #define GPIO_FREQ_MASK (3<<0)
79 #define GPIO_FREQ_32KHZ (0<<0)
80 #define GPIO_FREQ_44KHZ (1<<0)
81 #define GPIO_FREQ_48KHZ (2<<0)
82 #define GPIO_MULTI_MASK (3<<2)
83 #define GPIO_MULTI_4X (0<<2)
84 #define GPIO_MULTI_2X (1<<2)
85 #define GPIO_MULTI_1X (2<<2)
86 #define GPIO_MULTI_HALF (3<<2)
87 #define GPIO_INTERNAL_CLOCK (1<<4)
88 #define GPIO_CLOCK_MASK (1<<4)
89 #define GPIO_ANALOG_PRESENT (1<<5)
90 #define GPIO_RXMCLK_SEL (1<<7)
91 #define GPIO_AK5385A_CKS0 (1<<8)
92 #define GPIO_AK5385A_DFS1 (1<<9)
93 #define GPIO_AK5385A_DFS0 (1<<10)
94 #define GPIO_DIGOUT_MONITOR (1<<11)
95 #define GPIO_DIGIN_MONITOR (1<<12)
96 #define GPIO_ANAIN_MONITOR (1<<13)
97 #define GPIO_AK5385A_CKS1 (1<<14)
98 #define GPIO_MUTE_CONTROL (1<<15)
100 #define GPIO_RATE_MASK (GPIO_FREQ_MASK | GPIO_MULTI_MASK | \
102 #define GPIO_AK5385A_MASK (GPIO_AK5385A_CKS0 | GPIO_AK5385A_DFS0 | \
103 GPIO_AK5385A_DFS1 | GPIO_AK5385A_CKS1)
105 #define JULI_PCM_RATE (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
106 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
107 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \
108 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \
109 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
111 #define GPIO_RATE_16000 (GPIO_FREQ_32KHZ | GPIO_MULTI_HALF | \
113 #define GPIO_RATE_22050 (GPIO_FREQ_44KHZ | GPIO_MULTI_HALF | \
115 #define GPIO_RATE_24000 (GPIO_FREQ_48KHZ | GPIO_MULTI_HALF | \
117 #define GPIO_RATE_32000 (GPIO_FREQ_32KHZ | GPIO_MULTI_1X | \
119 #define GPIO_RATE_44100 (GPIO_FREQ_44KHZ | GPIO_MULTI_1X | \
121 #define GPIO_RATE_48000 (GPIO_FREQ_48KHZ | GPIO_MULTI_1X | \
123 #define GPIO_RATE_64000 (GPIO_FREQ_32KHZ | GPIO_MULTI_2X | \
125 #define GPIO_RATE_88200 (GPIO_FREQ_44KHZ | GPIO_MULTI_2X | \
127 #define GPIO_RATE_96000 (GPIO_FREQ_48KHZ | GPIO_MULTI_2X | \
129 #define GPIO_RATE_176400 (GPIO_FREQ_44KHZ | GPIO_MULTI_4X | \
131 #define GPIO_RATE_192000 (GPIO_FREQ_48KHZ | GPIO_MULTI_4X | \
137 static unsigned int juli_rates[] = {
138 16000, 22050, 24000, 32000,
139 44100, 48000, 64000, 88200,
140 96000, 176400, 192000,
143 static unsigned int gpio_vals[] = {
155 static int get_gpio_val(
int rate)
159 if (juli_rates[i] == rate)
171 static unsigned char juli_ak4114_read(
void *private_data,
unsigned char reg)
181 static void juli_spdif_in_open(
struct snd_ice1712 *ice,
192 if (rate >= runtime->
hw.rate_min && rate <= runtime->
hw.rate_max) {
193 runtime->
hw.rate_min =
rate;
194 runtime->
hw.rate_max =
rate;
211 unsigned char addr,
unsigned char data)
223 static void juli_akm_set_rate_val(
struct snd_akm4xxx *ak,
unsigned int rate)
225 unsigned char old,
tmp, ak4358_dfs;
226 unsigned int ak5385_pins, old_gpio, new_gpio;
238 }
else if (rate > 48000) {
246 old_gpio = ice->
gpio.get_data(ice);
250 ice->
gpio.set_data(ice, new_gpio);
264 tmp |= ak4358_dfs << 4;
272 #define AK_DAC(xname, xch) { .name = xname, .num_channels = xch }
273 #define PCM_VOLUME "PCM Playback Volume"
274 #define MONITOR_AN_IN_VOLUME "Monitor Analog In Volume"
275 #define MONITOR_DIG_IN_VOLUME "Monitor Digital In Volume"
276 #define MONITOR_DIG_OUT_VOLUME "Monitor Digital Out Volume"
294 .lock = juli_akm_lock,
295 .unlock = juli_akm_unlock,
296 .write = juli_akm_write,
297 .set_rate_val = juli_akm_set_rate_val
299 .dac_info = juli_dac,
302 #define juli_mute_info snd_ctl_boolean_mono_info
312 ucontrol->
value.integer.value[0] = (
val) ? 0 : 1;
315 ucontrol->
value.integer.value[0] = (
val) ? 1 : 0;
323 unsigned int old_gpio, new_gpio;
324 old_gpio = ice->
gpio.get_data(ice);
325 if (ucontrol->
value.integer.value[0]) {
334 new_gpio = old_gpio |
345 new_gpio = old_gpio &
353 if (old_gpio != new_gpio) {
354 ice->
gpio.set_data(ice, new_gpio);
364 .name =
"Master Playback Switch",
366 .get = juli_mute_get,
367 .put = juli_mute_put,
391 .name =
"Monitor Analog In Switch",
393 .get = juli_mute_get,
394 .put = juli_mute_put,
399 .name =
"Monitor Digital Out Switch",
401 .get = juli_mute_get,
402 .put = juli_mute_put,
407 .name =
"Monitor Digital In Switch",
409 .get = juli_mute_get,
410 .put = juli_mute_put,
415 static char *slave_vols[] __devinitdata = {
440 for (; *
list; list++) {
445 snd_ctl_add_slave(master, slave);
461 for (i = 0; i <
ARRAY_SIZE(juli_mute_controls); i++) {
469 juli_master_db_scale);
472 add_slaves(ice->
card, vmaster, slave_vols);
489 #ifdef CONFIG_PM_SLEEP
514 static inline int juli_is_spdif_master(
struct snd_ice1712 *ice)
519 static unsigned int juli_get_rate(
struct snd_ice1712 *ice)
526 if (gpio_vals[i] == result)
527 return juli_rates[
i];
532 static void juli_set_rate(
struct snd_ice1712 *ice,
unsigned int rate)
534 unsigned int old,
new;
537 old = ice->
gpio.get_data(ice);
543 ice->
gpio.set_data(ice,
new);
549 static inline unsigned char juli_set_mclk(
struct snd_ice1712 *ice,
560 old = ice->
gpio.get_data(ice);
568 static void juli_ak4114_change(
struct ak4114 *
ak4114,
unsigned char c0,
578 juli_akm_set_rate_val(ice->
akm, rate);
584 static const unsigned char ak4114_init_vals[] = {
594 static const unsigned char ak4114_init_txcsb[] = {
595 0x41, 0x02, 0x2c, 0x00, 0x00
609 ak4114_init_vals, ak4114_init_txcsb,
614 spec->
ak4114->change_callback = juli_ak4114_change;
615 spec->
ak4114->change_callback_private = ice;
617 spec->
ak4114->check_flags = 0;
653 ice->
spdif.ops.open = juli_spdif_in_open;
655 #ifdef CONFIG_PM_SLEEP
656 ice->pm_resume = juli_resume;
657 ice->pm_suspend = juli_suspend;
658 ice->pm_suspend_enabled = 1;
670 static unsigned char juli_eeprom[] __devinitdata = {
694 .chip_init = juli_init,
695 .build_controls = juli_add_controls,
696 .eeprom_size =
sizeof(juli_eeprom),