48 #include <linux/pci.h>
59 #define GPIO_MAGIC 0x0008
60 #define GPIO_HP_DETECT 0x0010
61 #define GPIO_INPUT_ROUTE 0x0060
62 #define GPIO_HP_REAR 0x0080
63 #define GPIO_OUTPUT_ENABLE 0x0100
93 cs4245_write(chip, reg, value);
96 static void cs4245_registers_init(
struct oxygen *chip)
123 static void cs4245_init(
struct oxygen *chip)
139 cs4245_registers_init(chip);
143 static void dg_output_enable(
struct oxygen *chip)
149 static void dg_init(
struct oxygen *chip)
165 dg_output_enable(chip);
168 static void dg_cleanup(
struct oxygen *chip)
173 static void dg_suspend(
struct oxygen *chip)
178 static void dg_resume(
struct oxygen *chip)
180 cs4245_registers_init(chip);
181 dg_output_enable(chip);
184 static void set_cs4245_dac_params(
struct oxygen *chip,
200 static void set_cs4245_adc_params(
struct oxygen *chip,
216 static inline unsigned int shift_bits(
unsigned int value,
217 unsigned int shift_from,
218 unsigned int shift_to,
221 if (shift_from < shift_to)
222 return (value << (shift_to - shift_from)) &
mask;
224 return (value >> (shift_from - shift_to)) &
mask;
227 static unsigned int adjust_dg_dac_routing(
struct oxygen *chip,
228 unsigned int play_routing)
231 shift_bits(play_routing,
235 shift_bits(play_routing,
239 shift_bits(play_routing,
248 static const char *
const names[3] = {
249 "Speakers",
"Headphones",
"FP Headphones"
275 if (value->
value.enumerated.item[0] > 2)
302 static int hp_volume_offset_info(
struct snd_kcontrol *ctl,
305 static const char *
const names[3] = {
306 "< 64 ohms",
"64-150 ohms",
"150-300 ohms"
312 static int hp_volume_offset_get(
struct snd_kcontrol *ctl,
320 value->
value.enumerated.item[0] = 0;
322 value->
value.enumerated.item[0] = 1;
324 value->
value.enumerated.item[0] = 2;
329 static int hp_volume_offset_put(
struct snd_kcontrol *ctl,
332 static const s8 atts[3] = { 2 * 16, 2 * 7, 0 };
338 if (value->
value.enumerated.item[0] > 2)
340 att = atts[value->
value.enumerated.item[0]];
386 if (value->
value.integer.value[0] < 2 * -12 ||
387 value->
value.integer.value[0] > 2 * 12 ||
388 value->
value.integer.value[1] < 2 * -12 ||
389 value->
value.integer.value[1] > 2 * 12)
413 static const char *
const names[4] = {
414 "Mic",
"Aux",
"Front Mic",
"Line"
435 static const u8 sel_values[4] = {
445 if (value->
value.enumerated.item[0] > 3)
473 static const char *
const names[2] = {
"Active",
"Frozen" };
483 value->
value.enumerated.item[0] =
497 if (value->
value.enumerated.item[0])
506 #define INPUT_VOLUME(xname, index) { \
507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
509 .info = input_vol_info, \
510 .get = input_vol_get, \
511 .put = input_vol_put, \
512 .tlv = { .p = cs4245_pga_db_scale }, \
513 .private_value = index, \
518 .name =
"Analog Output Playback Enum",
519 .info = output_switch_info,
520 .get = output_switch_get,
521 .put = output_switch_put,
525 .name =
"Headphones Impedance Playback Enum",
526 .info = hp_volume_offset_info,
527 .get = hp_volume_offset_get,
528 .put = hp_volume_offset_put,
536 .name =
"Capture Source",
537 .info = input_sel_info,
538 .get = input_sel_get,
539 .put = input_sel_put,
543 .name =
"ADC High-pass Filter Capture Enum",
557 static int dg_mixer_init(
struct oxygen *chip)
571 static void dump_cs4245_registers(
struct oxygen *chip,
577 snd_iprintf(buffer,
"\nCS4245:");
578 for (i = 1; i <= 0x10; ++
i)
579 snd_iprintf(buffer,
" %02x", data->
cs4245_regs[i]);
580 snd_iprintf(buffer,
"\n");
584 .longname =
"C-Media Oxygen HD Audio",
587 .control_filter = dg_control_filter,
588 .mixer_init = dg_mixer_init,
589 .cleanup = dg_cleanup,
590 .suspend = dg_suspend,
592 .set_dac_params = set_cs4245_dac_params,
593 .set_adc_params = set_cs4245_adc_params,
594 .adjust_dac_routing = adjust_dg_dac_routing,
595 .dump_registers = dump_cs4245_registers,
596 .model_data_size =
sizeof(
struct dg),
601 .dac_channels_pcm = 6,
602 .dac_channels_mixer = 0,