28 #include <linux/slab.h>
41 static void revo_i2s_mclk_changed(
struct snd_ice1712 *ice)
53 static void revo_set_rate_val(
struct snd_akm4xxx *ak,
unsigned int rate)
55 unsigned char old,
tmp, dfs;
64 else if (rate > 48000)
69 if (ak->
type == SND_AK4355 || ak->
type == SND_AK4358) {
77 old = (tmp >> shift) & 0x03;
84 tmp &= ~(0x03 << shift);
98 snd_ice1712_save_gpio_status(ice);
104 snd_ice1712_restore_gpio_status(ice);
118 ice->
gpio.direction &= ~mask;
120 snd_ice1712_gpio_set_dir(ice, ice->
gpio.direction);
121 snd_ice1712_gpio_set_mask(ice, ~mask);
124 static void revo_i2c_setlines(
struct snd_i2c_bus *bus,
int clk,
int data)
127 unsigned int val = 0;
133 snd_ice1712_gpio_write_bits(ice,
151 .start = revo_i2c_start,
152 .stop = revo_i2c_stop,
153 .direction = revo_i2c_direction,
154 .setlines = revo_i2c_setlines,
155 .getdata = revo_i2c_getdata,
158 static int revo51_i2c_init(
struct snd_ice1712 *ice,
174 ice->
i2c->private_data = ice;
175 ice->
i2c->hw_ops.bit = &revo51_bit_ops;
196 #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
200 .name =
"PCM Playback Volume",
203 .switch_name =
"PCM Playback Switch",
208 AK_DAC(
"PCM Center Playback Volume", 1),
209 AK_DAC(
"PCM LFE Playback Volume", 1),
210 AK_DAC(
"PCM Side Playback Volume", 2),
211 AK_DAC(
"PCM Rear Playback Volume", 2),
215 AK_DAC(
"PCM Playback Volume", 2),
216 AK_DAC(
"PCM Center Playback Volume", 1),
217 AK_DAC(
"PCM LFE Playback Volume", 1),
218 AK_DAC(
"PCM Rear Playback Volume", 2),
219 AK_DAC(
"PCM Headphone Volume", 2),
222 static const char *revo51_adc_input_names[] = {
231 .name =
"PCM Capture Volume",
232 .switch_name =
"PCM Capture Switch",
234 .input_names = revo51_adc_input_names
242 .set_rate_val = revo_set_rate_val
244 .dac_info = revo71_front,
259 static struct snd_akm4xxx akm_revo_surround __devinitdata = {
264 .set_rate_val = revo_set_rate_val
266 .dac_info = revo71_surround,
281 static struct snd_akm4xxx akm_revo51 __devinitdata = {
285 .set_rate_val = revo_set_rate_val
287 .dac_info = revo51_dac,
302 static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
305 .adc_info = revo51_adc,
323 static void ap192_set_rate_val(
struct snd_akm4xxx *ak,
unsigned int rate)
328 revo_set_rate_val(ak, rate);
331 snd_ice1712_gpio_write_bits(ice, 1 << 8, rate > 96000 ? 1 << 8 : 0);
335 else if (rate > 48000)
339 snd_ice1712_gpio_write_bits(ice, 3 << 9, dfs << 9);
341 snd_ice1712_gpio_write_bits(ice, 1 << 11, 0);
342 snd_ice1712_gpio_write_bits(ice, 1 << 11, 1 << 11);
346 AK_DAC(
"PCM Playback Volume", 2)
349 static struct snd_akm4xxx akm_ap192 __devinitdata = {
353 .set_rate_val = ap192_set_rate_val
355 .dac_info = ap192_dac,
376 #define AK4114_ADDR 0x02
379 unsigned int data,
int idx)
381 for (; idx >= 0; idx--) {
384 snd_ice1712_gpio_write(ice, gpio);
387 if (data & (1 << idx))
391 snd_ice1712_gpio_write(ice, gpio);
395 snd_ice1712_gpio_write(ice, gpio);
400 static unsigned char read_data(
struct snd_ice1712 *ice,
unsigned int gpio,
403 unsigned char data = 0;
405 for (; idx >= 0; idx--) {
408 snd_ice1712_gpio_write(ice, gpio);
416 snd_ice1712_gpio_write(ice, gpio);
422 static unsigned int ap192_4wire_start(
struct snd_ice1712 *ice)
426 snd_ice1712_save_gpio_status(ice);
427 tmp = snd_ice1712_gpio_read(ice);
431 snd_ice1712_gpio_write(ice, tmp);
436 static void ap192_4wire_finish(
struct snd_ice1712 *ice,
unsigned int tmp)
440 snd_ice1712_gpio_write(ice, tmp);
442 snd_ice1712_restore_gpio_status(ice);
449 unsigned int tmp, addrdata;
451 tmp = ap192_4wire_start(ice);
452 addrdata = (
AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
453 addrdata = (addrdata << 8) | data;
454 write_data(ice, tmp, addrdata, 15);
455 ap192_4wire_finish(ice, tmp);
458 static unsigned char ap192_ak4114_read(
void *private_data,
unsigned char addr)
464 tmp = ap192_4wire_start(ice);
465 write_data(ice, tmp, (
AK4114_ADDR << 6) | (addr & 0x1f), 7);
466 data = read_data(ice, tmp, 7);
467 ap192_4wire_finish(ice, tmp);
473 static const unsigned char ak4114_init_vals[] = {
481 static const unsigned char ak4114_init_txcsb[] = {
482 0x41, 0x02, 0x2c, 0x00, 0x00
490 ak4114_init_vals, ak4114_init_txcsb,
505 switch (ice->
eeprom.subvendor) {
509 ice->
gpio.i2s_mclk_changed = revo_i2s_mclk_changed;
528 switch (ice->
eeprom.subvendor) {
532 &akm_revo_front_priv, ice);
536 &akm_revo_surround_priv, ice);
546 &akm_revo51_priv, ice);
550 &akm_revo51_adc_priv, ice);
553 err = revo51_i2c_init(ice, &ptc_revo51_volume);
582 switch (ice->
eeprom.subvendor) {
601 err = ap192_ak4114_init(ice);
613 .name =
"M Audio Revolution-7.1",
615 .chip_init = revo_init,
616 .build_controls = revo_add_controls,
620 .name =
"M Audio Revolution-5.1",
622 .chip_init = revo_init,
623 .build_controls = revo_add_controls,
627 .name =
"M Audio Audiophile192",
629 .chip_init = revo_init,
630 .build_controls = revo_add_controls,