53 #include <linux/pci.h>
54 #include <linux/module.h>
73 ",{C-Media,CMI8788}}");
136 #define GPIO_AK5385_DFS_MASK 0x0003
137 #define GPIO_AK5385_DFS_NORMAL 0x0000
138 #define GPIO_AK5385_DFS_DOUBLE 0x0001
139 #define GPIO_AK5385_DFS_QUAD 0x0002
141 #define GPIO_MERIDIAN_DIG_MASK 0x0050
142 #define GPIO_MERIDIAN_DIG_EXT 0x0010
143 #define GPIO_MERIDIAN_DIG_BOARD 0x0040
145 #define GPIO_CLARO_DIG_COAX 0x0040
146 #define GPIO_CLARO_HP 0x0100
158 static const u8 codec_spi_map[4] = {
172 static void ak4396_write_cached(
struct oxygen *chip,
unsigned int codec,
178 ak4396_write(chip, codec, reg, value);
181 static void wm8785_write(
struct oxygen *chip,
u8 reg,
unsigned int value)
195 static void ak4396_registers_init(
struct oxygen *chip)
200 for (i = 0; i < data->
dacs; ++
i) {
214 static void ak4396_init(
struct oxygen *chip)
218 data->
dacs = chip->
model.dac_channels_pcm / 2;
221 ak4396_registers_init(chip);
225 static void ak5385_init(
struct oxygen *chip)
232 static void wm8785_registers_init(
struct oxygen *chip)
241 static void wm8785_init(
struct oxygen *chip)
248 wm8785_registers_init(chip);
252 static void generic_init(
struct oxygen *chip)
258 static void meridian_init(
struct oxygen *chip)
268 static void claro_enable_hp(
struct oxygen *chip)
275 static void claro_init(
struct oxygen *chip)
281 claro_enable_hp(chip);
284 static void claro_halo_init(
struct oxygen *chip)
290 claro_enable_hp(chip);
293 static void fantasia_init(
struct oxygen *chip)
299 static void stereo_output_init(
struct oxygen *chip)
304 static void generic_cleanup(
struct oxygen *chip)
308 static void claro_disable_hp(
struct oxygen *chip)
313 static void claro_cleanup(
struct oxygen *chip)
315 claro_disable_hp(chip);
318 static void claro_suspend(
struct oxygen *chip)
320 claro_disable_hp(chip);
323 static void generic_resume(
struct oxygen *chip)
325 ak4396_registers_init(chip);
326 wm8785_registers_init(chip);
329 static void meridian_resume(
struct oxygen *chip)
331 ak4396_registers_init(chip);
334 static void claro_resume(
struct oxygen *chip)
336 ak4396_registers_init(chip);
337 claro_enable_hp(chip);
340 static void stereo_resume(
struct oxygen *chip)
342 ak4396_registers_init(chip);
345 static void set_ak4396_params(
struct oxygen *chip,
363 for (i = 0; i < data->
dacs; ++
i) {
373 static void update_ak4396_volume(
struct oxygen *chip)
378 for (i = 0; i < data->
dacs; ++
i) {
386 static void update_ak4396_mute(
struct oxygen *chip)
395 for (i = 0; i < data->
dacs; ++
i)
399 static void set_wm8785_params(
struct oxygen *chip,
419 static void set_ak5385_params(
struct oxygen *chip,
441 static const char *
const names[2] = {
442 "Sharp Roll-off",
"Slow Roll-off"
454 value->
value.enumerated.item[0] =
470 if (value->
value.enumerated.item[0])
476 for (i = 0; i < data->
dacs; ++
i)
485 .name =
"DAC Filter Playback Enum",
486 .info = rolloff_info,
493 static const char *
const names[2] = {
494 "None",
"High-pass Filter"
505 value->
value.enumerated.item[0] =
519 if (value->
value.enumerated.item[0])
530 .name =
"ADC Filter Capture Enum",
536 static int meridian_dig_source_info(
struct snd_kcontrol *ctl,
539 static const char *
const names[2] = {
"On-board",
"Extension" };
544 static int claro_dig_source_info(
struct snd_kcontrol *ctl,
547 static const char *
const names[2] = {
"Optical",
"Coaxial" };
552 static int meridian_dig_source_get(
struct snd_kcontrol *ctl,
557 value->
value.enumerated.item[0] =
563 static int claro_dig_source_get(
struct snd_kcontrol *ctl,
568 value->
value.enumerated.item[0] =
574 static int meridian_dig_source_put(
struct snd_kcontrol *ctl,
578 u16 old_reg, new_reg;
584 if (value->
value.enumerated.item[0] == 0)
588 changed = new_reg != old_reg;
595 static int claro_dig_source_put(
struct snd_kcontrol *ctl,
599 u16 old_reg, new_reg;
605 if (value->
value.enumerated.item[0])
607 changed = new_reg != old_reg;
616 .name =
"IEC958 Source Capture Enum",
617 .info = meridian_dig_source_info,
618 .get = meridian_dig_source_get,
619 .put = meridian_dig_source_put,
624 .name =
"IEC958 Source Capture Enum",
625 .info = claro_dig_source_info,
626 .get = claro_dig_source_get,
627 .put = claro_dig_source_put,
630 static int generic_mixer_init(
struct oxygen *chip)
635 static int generic_wm8785_mixer_init(
struct oxygen *chip)
639 err = generic_mixer_init(chip);
648 static int meridian_mixer_init(
struct oxygen *chip)
652 err = generic_mixer_init(chip);
662 static int claro_mixer_init(
struct oxygen *chip)
666 err = generic_wm8785_mixer_init(chip);
676 static int claro_halo_mixer_init(
struct oxygen *chip)
680 err = generic_mixer_init(chip);
690 static void dump_ak4396_registers(
struct oxygen *chip,
696 for (dac = 0; dac < data->
dacs; ++dac) {
697 snd_iprintf(buffer,
"\nAK4396 %u:", dac + 1);
698 for (i = 0; i < 5; ++
i)
699 snd_iprintf(buffer,
" %02x", data->
ak4396_regs[dac][i]);
701 snd_iprintf(buffer,
"\n");
704 static void dump_wm8785_registers(
struct oxygen *chip,
710 snd_iprintf(buffer,
"\nWM8785:");
711 for (i = 0; i < 3; ++
i)
712 snd_iprintf(buffer,
" %03x", data->
wm8785_regs[i]);
713 snd_iprintf(buffer,
"\n");
716 static void dump_oxygen_registers(
struct oxygen *chip,
719 dump_ak4396_registers(chip, buffer);
720 dump_wm8785_registers(chip, buffer);
726 .shortname =
"C-Media CMI8788",
727 .longname =
"C-Media Oxygen HD Audio",
729 .init = generic_init,
730 .mixer_init = generic_wm8785_mixer_init,
731 .cleanup = generic_cleanup,
732 .resume = generic_resume,
733 .set_dac_params = set_ak4396_params,
734 .set_adc_params = set_wm8785_params,
735 .update_dac_volume = update_ak4396_volume,
736 .update_dac_mute = update_ak4396_mute,
737 .dump_registers = dump_oxygen_registers,
738 .dac_tlv = ak4396_db_scale,
747 .dac_channels_pcm = 8,
748 .dac_channels_mixer = 8,
750 .dac_volume_max = 255,
762 static const char *
const names[] = {
772 chip->
model = model_generic;
776 chip->
model.init = meridian_init;
777 chip->
model.mixer_init = meridian_mixer_init;
778 chip->
model.resume = meridian_resume;
779 chip->
model.set_adc_params = set_ak5385_params;
780 chip->
model.dump_registers = dump_ak4396_registers;
789 chip->
model.init = claro_init;
790 chip->
model.mixer_init = claro_mixer_init;
791 chip->
model.cleanup = claro_cleanup;
792 chip->
model.suspend = claro_suspend;
793 chip->
model.resume = claro_resume;
796 chip->
model.init = claro_halo_init;
797 chip->
model.mixer_init = claro_halo_mixer_init;
798 chip->
model.cleanup = claro_cleanup;
799 chip->
model.suspend = claro_suspend;
800 chip->
model.resume = claro_resume;
801 chip->
model.set_adc_params = set_ak5385_params;
802 chip->
model.dump_registers = dump_ak4396_registers;
812 chip->
model.shortname =
"C-Media CMI8787";
813 chip->
model.chip =
"CMI8787";
815 chip->
model.init = fantasia_init;
817 chip->
model.init = stereo_output_init;
818 chip->
model.resume = stereo_resume;
819 chip->
model.mixer_init = generic_mixer_init;
820 chip->
model.set_adc_params = set_no_params;
821 chip->
model.dump_registers = dump_ak4396_registers;
828 chip->
model.dac_channels_pcm = 2;
829 chip->
model.dac_channels_mixer = 2;
833 chip->
model.shortname =
"Xonar DG";
837 chip->
model.shortname =
"Xonar DGX";
847 chip->
model.shortname = names[
id->driver_data];
864 oxygen_ids, get_oxygen_model);
871 .name = KBUILD_MODNAME,
872 .id_table = oxygen_ids,
873 .probe = generic_oxygen_probe,
875 #ifdef CONFIG_PM_SLEEP
877 .pm = &oxygen_pci_pm,