blob: eb7ad7706205a3e28076eb99f9b5ee9d16e7b777 [file] [log] [blame]
Clemens Ladisch66410bf2011-01-10 16:20:29 +01001/*
Clemens Ladisch76bc7a02012-05-01 17:40:30 +02002 * card driver for the Xonar DG/DGX
Clemens Ladisch66410bf2011-01-10 16:20:29 +01003 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.
9 *
10 * This driver is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
Clemens Ladisch76bc7a02012-05-01 17:40:30 +020020 * Xonar DG/DGX
21 * ------------
Clemens Ladisch66410bf2011-01-10 16:20:29 +010022 *
23 * CMI8788:
24 *
25 * SPI 0 -> CS4245
26 *
Clemens Ladischefbeb072011-01-31 11:47:52 +010027 * I²S 1 -> CS4245
28 * I²S 2 -> CS4361 (center/LFE)
29 * I²S 3 -> CS4361 (surround)
30 * I²S 4 -> CS4361 (front)
31 *
Clemens Ladisch66410bf2011-01-10 16:20:29 +010032 * GPIO 3 <- ?
33 * GPIO 4 <- headphone detect
34 * GPIO 5 -> route input jack to line-in (0) or mic-in (1)
35 * GPIO 6 -> route input jack to line-in (0) or mic-in (1)
36 * GPIO 7 -> enable rear headphone amp
37 * GPIO 8 -> enable output to speakers
38 *
39 * CS4245:
40 *
41 * input 1 <- aux
42 * input 2 <- front mic
43 * input 4 <- line/mic
Clemens Ladischefbeb072011-01-31 11:47:52 +010044 * DAC out -> headphones
Clemens Ladisch66410bf2011-01-10 16:20:29 +010045 * aux out -> front panel headphones
46 */
47
48#include <linux/pci.h>
Stephen Rothwelle92d4572011-01-11 13:20:30 +110049#include <linux/delay.h>
Clemens Ladisch66410bf2011-01-10 16:20:29 +010050#include <sound/control.h>
51#include <sound/core.h>
52#include <sound/info.h>
53#include <sound/pcm.h>
54#include <sound/tlv.h>
55#include "oxygen.h"
56#include "xonar_dg.h"
57#include "cs4245.h"
58
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
64
65struct dg {
66 unsigned int output_sel;
67 s8 input_vol[4][2];
68 unsigned int input_sel;
69 u8 hp_vol_att;
70 u8 cs4245_regs[0x11];
71};
72
73static void cs4245_write(struct oxygen *chip, unsigned int reg, u8 value)
74{
75 struct dg *data = chip->model_data;
76
77 oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER |
78 OXYGEN_SPI_DATA_LENGTH_3 |
79 OXYGEN_SPI_CLOCK_1280 |
80 (0 << OXYGEN_SPI_CODEC_SHIFT) |
81 OXYGEN_SPI_CEN_LATCH_CLOCK_HI,
82 CS4245_SPI_ADDRESS |
83 CS4245_SPI_WRITE |
Clemens Ladischf8fe80e2011-01-14 08:07:50 +010084 (reg << 8) | value);
Clemens Ladisch66410bf2011-01-10 16:20:29 +010085 data->cs4245_regs[reg] = value;
86}
87
88static void cs4245_write_cached(struct oxygen *chip, unsigned int reg, u8 value)
89{
90 struct dg *data = chip->model_data;
91
92 if (value != data->cs4245_regs[reg])
93 cs4245_write(chip, reg, value);
94}
95
96static void cs4245_registers_init(struct oxygen *chip)
97{
98 struct dg *data = chip->model_data;
99
100 cs4245_write(chip, CS4245_POWER_CTRL, CS4245_PDN);
101 cs4245_write(chip, CS4245_DAC_CTRL_1,
102 data->cs4245_regs[CS4245_DAC_CTRL_1]);
103 cs4245_write(chip, CS4245_ADC_CTRL,
104 data->cs4245_regs[CS4245_ADC_CTRL]);
105 cs4245_write(chip, CS4245_SIGNAL_SEL,
106 data->cs4245_regs[CS4245_SIGNAL_SEL]);
107 cs4245_write(chip, CS4245_PGA_B_CTRL,
108 data->cs4245_regs[CS4245_PGA_B_CTRL]);
109 cs4245_write(chip, CS4245_PGA_A_CTRL,
110 data->cs4245_regs[CS4245_PGA_A_CTRL]);
111 cs4245_write(chip, CS4245_ANALOG_IN,
112 data->cs4245_regs[CS4245_ANALOG_IN]);
113 cs4245_write(chip, CS4245_DAC_A_CTRL,
114 data->cs4245_regs[CS4245_DAC_A_CTRL]);
115 cs4245_write(chip, CS4245_DAC_B_CTRL,
116 data->cs4245_regs[CS4245_DAC_B_CTRL]);
117 cs4245_write(chip, CS4245_DAC_CTRL_2,
118 CS4245_DAC_SOFT | CS4245_DAC_ZERO | CS4245_INVERT_DAC);
119 cs4245_write(chip, CS4245_INT_MASK, 0);
120 cs4245_write(chip, CS4245_POWER_CTRL, 0);
121}
122
123static void cs4245_init(struct oxygen *chip)
124{
125 struct dg *data = chip->model_data;
126
127 data->cs4245_regs[CS4245_DAC_CTRL_1] =
128 CS4245_DAC_FM_SINGLE | CS4245_DAC_DIF_LJUST;
129 data->cs4245_regs[CS4245_ADC_CTRL] =
130 CS4245_ADC_FM_SINGLE | CS4245_ADC_DIF_LJUST;
131 data->cs4245_regs[CS4245_SIGNAL_SEL] =
132 CS4245_A_OUT_SEL_HIZ | CS4245_ASYNCH;
133 data->cs4245_regs[CS4245_PGA_B_CTRL] = 0;
134 data->cs4245_regs[CS4245_PGA_A_CTRL] = 0;
135 data->cs4245_regs[CS4245_ANALOG_IN] =
136 CS4245_PGA_SOFT | CS4245_PGA_ZERO | CS4245_SEL_INPUT_4;
137 data->cs4245_regs[CS4245_DAC_A_CTRL] = 0;
138 data->cs4245_regs[CS4245_DAC_B_CTRL] = 0;
139 cs4245_registers_init(chip);
140 snd_component_add(chip->card, "CS4245");
141}
142
143static void dg_output_enable(struct oxygen *chip)
144{
145 msleep(2500);
146 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
147}
148
149static void dg_init(struct oxygen *chip)
150{
151 struct dg *data = chip->model_data;
152
153 data->output_sel = 0;
154 data->input_sel = 3;
155 data->hp_vol_att = 2 * 16;
156
157 cs4245_init(chip);
158
159 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
160 GPIO_MAGIC | GPIO_HP_DETECT);
161 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL,
162 GPIO_INPUT_ROUTE | GPIO_HP_REAR | GPIO_OUTPUT_ENABLE);
163 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA,
164 GPIO_INPUT_ROUTE | GPIO_HP_REAR);
165 dg_output_enable(chip);
166}
167
168static void dg_cleanup(struct oxygen *chip)
169{
170 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
171}
172
173static void dg_suspend(struct oxygen *chip)
174{
175 dg_cleanup(chip);
176}
177
178static void dg_resume(struct oxygen *chip)
179{
180 cs4245_registers_init(chip);
181 dg_output_enable(chip);
182}
183
184static void set_cs4245_dac_params(struct oxygen *chip,
185 struct snd_pcm_hw_params *params)
186{
187 struct dg *data = chip->model_data;
188 u8 value;
189
190 value = data->cs4245_regs[CS4245_DAC_CTRL_1] & ~CS4245_DAC_FM_MASK;
191 if (params_rate(params) <= 50000)
192 value |= CS4245_DAC_FM_SINGLE;
193 else if (params_rate(params) <= 100000)
194 value |= CS4245_DAC_FM_DOUBLE;
195 else
196 value |= CS4245_DAC_FM_QUAD;
197 cs4245_write_cached(chip, CS4245_DAC_CTRL_1, value);
198}
199
200static void set_cs4245_adc_params(struct oxygen *chip,
201 struct snd_pcm_hw_params *params)
202{
203 struct dg *data = chip->model_data;
204 u8 value;
205
206 value = data->cs4245_regs[CS4245_ADC_CTRL] & ~CS4245_ADC_FM_MASK;
207 if (params_rate(params) <= 50000)
208 value |= CS4245_ADC_FM_SINGLE;
209 else if (params_rate(params) <= 100000)
210 value |= CS4245_ADC_FM_DOUBLE;
211 else
212 value |= CS4245_ADC_FM_QUAD;
213 cs4245_write_cached(chip, CS4245_ADC_CTRL, value);
214}
215
Clemens Ladischefbeb072011-01-31 11:47:52 +0100216static inline unsigned int shift_bits(unsigned int value,
217 unsigned int shift_from,
218 unsigned int shift_to,
219 unsigned int mask)
220{
221 if (shift_from < shift_to)
222 return (value << (shift_to - shift_from)) & mask;
223 else
224 return (value >> (shift_from - shift_to)) & mask;
225}
226
227static unsigned int adjust_dg_dac_routing(struct oxygen *chip,
228 unsigned int play_routing)
229{
230 return (play_routing & OXYGEN_PLAY_DAC0_SOURCE_MASK) |
231 shift_bits(play_routing,
232 OXYGEN_PLAY_DAC2_SOURCE_SHIFT,
233 OXYGEN_PLAY_DAC1_SOURCE_SHIFT,
234 OXYGEN_PLAY_DAC1_SOURCE_MASK) |
235 shift_bits(play_routing,
236 OXYGEN_PLAY_DAC1_SOURCE_SHIFT,
237 OXYGEN_PLAY_DAC2_SOURCE_SHIFT,
238 OXYGEN_PLAY_DAC2_SOURCE_MASK) |
239 shift_bits(play_routing,
240 OXYGEN_PLAY_DAC0_SOURCE_SHIFT,
241 OXYGEN_PLAY_DAC3_SOURCE_SHIFT,
242 OXYGEN_PLAY_DAC3_SOURCE_MASK);
243}
244
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100245static int output_switch_info(struct snd_kcontrol *ctl,
246 struct snd_ctl_elem_info *info)
247{
248 static const char *const names[3] = {
249 "Speakers", "Headphones", "FP Headphones"
250 };
251
Clemens Ladisch96007322011-01-10 16:25:44 +0100252 return snd_ctl_enum_info(info, 1, 3, names);
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100253}
254
255static int output_switch_get(struct snd_kcontrol *ctl,
256 struct snd_ctl_elem_value *value)
257{
258 struct oxygen *chip = ctl->private_data;
259 struct dg *data = chip->model_data;
260
261 mutex_lock(&chip->mutex);
262 value->value.enumerated.item[0] = data->output_sel;
263 mutex_unlock(&chip->mutex);
264 return 0;
265}
266
267static int output_switch_put(struct snd_kcontrol *ctl,
268 struct snd_ctl_elem_value *value)
269{
270 struct oxygen *chip = ctl->private_data;
271 struct dg *data = chip->model_data;
272 u8 reg;
273 int changed;
274
275 if (value->value.enumerated.item[0] > 2)
276 return -EINVAL;
277
278 mutex_lock(&chip->mutex);
279 changed = value->value.enumerated.item[0] != data->output_sel;
280 if (changed) {
281 data->output_sel = value->value.enumerated.item[0];
282
283 reg = data->cs4245_regs[CS4245_SIGNAL_SEL] &
284 ~CS4245_A_OUT_SEL_MASK;
285 reg |= data->output_sel == 2 ?
286 CS4245_A_OUT_SEL_DAC : CS4245_A_OUT_SEL_HIZ;
287 cs4245_write_cached(chip, CS4245_SIGNAL_SEL, reg);
288
289 cs4245_write_cached(chip, CS4245_DAC_A_CTRL,
290 data->output_sel ? data->hp_vol_att : 0);
291 cs4245_write_cached(chip, CS4245_DAC_B_CTRL,
292 data->output_sel ? data->hp_vol_att : 0);
293
294 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
295 data->output_sel == 1 ? GPIO_HP_REAR : 0,
296 GPIO_HP_REAR);
Roman Volkov4010fe82014-01-24 16:18:11 +0400297 oxygen_write8_masked(chip, OXYGEN_PLAY_ROUTING,
298 data->output_sel == 0 ?
299 OXYGEN_PLAY_MUTE01 :
300 OXYGEN_PLAY_MUTE23 |
301 OXYGEN_PLAY_MUTE45 |
302 OXYGEN_PLAY_MUTE67,
303 OXYGEN_PLAY_MUTE01 |
304 OXYGEN_PLAY_MUTE23 |
305 OXYGEN_PLAY_MUTE45 |
306 OXYGEN_PLAY_MUTE67);
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100307 }
308 mutex_unlock(&chip->mutex);
309 return changed;
310}
311
312static int hp_volume_offset_info(struct snd_kcontrol *ctl,
313 struct snd_ctl_elem_info *info)
314{
315 static const char *const names[3] = {
316 "< 64 ohms", "64-150 ohms", "150-300 ohms"
317 };
318
Clemens Ladisch96007322011-01-10 16:25:44 +0100319 return snd_ctl_enum_info(info, 1, 3, names);
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100320}
321
322static int hp_volume_offset_get(struct snd_kcontrol *ctl,
323 struct snd_ctl_elem_value *value)
324{
325 struct oxygen *chip = ctl->private_data;
326 struct dg *data = chip->model_data;
327
328 mutex_lock(&chip->mutex);
329 if (data->hp_vol_att > 2 * 7)
330 value->value.enumerated.item[0] = 0;
331 else if (data->hp_vol_att > 0)
332 value->value.enumerated.item[0] = 1;
333 else
334 value->value.enumerated.item[0] = 2;
335 mutex_unlock(&chip->mutex);
336 return 0;
337}
338
339static int hp_volume_offset_put(struct snd_kcontrol *ctl,
340 struct snd_ctl_elem_value *value)
341{
342 static const s8 atts[3] = { 2 * 16, 2 * 7, 0 };
343 struct oxygen *chip = ctl->private_data;
344 struct dg *data = chip->model_data;
345 s8 att;
346 int changed;
347
348 if (value->value.enumerated.item[0] > 2)
349 return -EINVAL;
350 att = atts[value->value.enumerated.item[0]];
351 mutex_lock(&chip->mutex);
352 changed = att != data->hp_vol_att;
353 if (changed) {
354 data->hp_vol_att = att;
355 if (data->output_sel) {
356 cs4245_write_cached(chip, CS4245_DAC_A_CTRL, att);
357 cs4245_write_cached(chip, CS4245_DAC_B_CTRL, att);
358 }
359 }
360 mutex_unlock(&chip->mutex);
361 return changed;
362}
363
364static int input_vol_info(struct snd_kcontrol *ctl,
365 struct snd_ctl_elem_info *info)
366{
367 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
368 info->count = 2;
369 info->value.integer.min = 2 * -12;
370 info->value.integer.max = 2 * 12;
371 return 0;
372}
373
374static int input_vol_get(struct snd_kcontrol *ctl,
375 struct snd_ctl_elem_value *value)
376{
377 struct oxygen *chip = ctl->private_data;
378 struct dg *data = chip->model_data;
379 unsigned int idx = ctl->private_value;
380
381 mutex_lock(&chip->mutex);
382 value->value.integer.value[0] = data->input_vol[idx][0];
383 value->value.integer.value[1] = data->input_vol[idx][1];
384 mutex_unlock(&chip->mutex);
385 return 0;
386}
387
388static int input_vol_put(struct snd_kcontrol *ctl,
389 struct snd_ctl_elem_value *value)
390{
391 struct oxygen *chip = ctl->private_data;
392 struct dg *data = chip->model_data;
393 unsigned int idx = ctl->private_value;
394 int changed = 0;
395
396 if (value->value.integer.value[0] < 2 * -12 ||
397 value->value.integer.value[0] > 2 * 12 ||
398 value->value.integer.value[1] < 2 * -12 ||
399 value->value.integer.value[1] > 2 * 12)
400 return -EINVAL;
401 mutex_lock(&chip->mutex);
402 changed = data->input_vol[idx][0] != value->value.integer.value[0] ||
403 data->input_vol[idx][1] != value->value.integer.value[1];
404 if (changed) {
405 data->input_vol[idx][0] = value->value.integer.value[0];
406 data->input_vol[idx][1] = value->value.integer.value[1];
407 if (idx == data->input_sel) {
408 cs4245_write_cached(chip, CS4245_PGA_A_CTRL,
409 data->input_vol[idx][0]);
410 cs4245_write_cached(chip, CS4245_PGA_B_CTRL,
411 data->input_vol[idx][1]);
412 }
413 }
414 mutex_unlock(&chip->mutex);
415 return changed;
416}
417
418static DECLARE_TLV_DB_SCALE(cs4245_pga_db_scale, -1200, 50, 0);
419
420static int input_sel_info(struct snd_kcontrol *ctl,
421 struct snd_ctl_elem_info *info)
422{
423 static const char *const names[4] = {
424 "Mic", "Aux", "Front Mic", "Line"
425 };
426
Clemens Ladisch96007322011-01-10 16:25:44 +0100427 return snd_ctl_enum_info(info, 1, 4, names);
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100428}
429
430static int input_sel_get(struct snd_kcontrol *ctl,
431 struct snd_ctl_elem_value *value)
432{
433 struct oxygen *chip = ctl->private_data;
434 struct dg *data = chip->model_data;
435
436 mutex_lock(&chip->mutex);
437 value->value.enumerated.item[0] = data->input_sel;
438 mutex_unlock(&chip->mutex);
439 return 0;
440}
441
442static int input_sel_put(struct snd_kcontrol *ctl,
443 struct snd_ctl_elem_value *value)
444{
445 static const u8 sel_values[4] = {
446 CS4245_SEL_MIC,
447 CS4245_SEL_INPUT_1,
448 CS4245_SEL_INPUT_2,
449 CS4245_SEL_INPUT_4
450 };
451 struct oxygen *chip = ctl->private_data;
452 struct dg *data = chip->model_data;
453 int changed;
454
455 if (value->value.enumerated.item[0] > 3)
456 return -EINVAL;
457
458 mutex_lock(&chip->mutex);
459 changed = value->value.enumerated.item[0] != data->input_sel;
460 if (changed) {
461 data->input_sel = value->value.enumerated.item[0];
462
463 cs4245_write(chip, CS4245_ANALOG_IN,
464 (data->cs4245_regs[CS4245_ANALOG_IN] &
465 ~CS4245_SEL_MASK) |
466 sel_values[data->input_sel]);
467
468 cs4245_write_cached(chip, CS4245_PGA_A_CTRL,
469 data->input_vol[data->input_sel][0]);
470 cs4245_write_cached(chip, CS4245_PGA_B_CTRL,
471 data->input_vol[data->input_sel][1]);
472
473 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
474 data->input_sel ? 0 : GPIO_INPUT_ROUTE,
475 GPIO_INPUT_ROUTE);
476 }
477 mutex_unlock(&chip->mutex);
478 return changed;
479}
480
481static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
482{
483 static const char *const names[2] = { "Active", "Frozen" };
484
Clemens Ladisch96007322011-01-10 16:25:44 +0100485 return snd_ctl_enum_info(info, 1, 2, names);
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100486}
487
488static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
489{
490 struct oxygen *chip = ctl->private_data;
491 struct dg *data = chip->model_data;
492
493 value->value.enumerated.item[0] =
494 !!(data->cs4245_regs[CS4245_ADC_CTRL] & CS4245_HPF_FREEZE);
495 return 0;
496}
497
498static int hpf_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
499{
500 struct oxygen *chip = ctl->private_data;
501 struct dg *data = chip->model_data;
502 u8 reg;
503 int changed;
504
505 mutex_lock(&chip->mutex);
506 reg = data->cs4245_regs[CS4245_ADC_CTRL] & ~CS4245_HPF_FREEZE;
507 if (value->value.enumerated.item[0])
508 reg |= CS4245_HPF_FREEZE;
509 changed = reg != data->cs4245_regs[CS4245_ADC_CTRL];
510 if (changed)
511 cs4245_write(chip, CS4245_ADC_CTRL, reg);
512 mutex_unlock(&chip->mutex);
513 return changed;
514}
515
516#define INPUT_VOLUME(xname, index) { \
517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
518 .name = xname, \
519 .info = input_vol_info, \
520 .get = input_vol_get, \
521 .put = input_vol_put, \
522 .tlv = { .p = cs4245_pga_db_scale }, \
523 .private_value = index, \
524}
525static const struct snd_kcontrol_new dg_controls[] = {
526 {
527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
528 .name = "Analog Output Playback Enum",
529 .info = output_switch_info,
530 .get = output_switch_get,
531 .put = output_switch_put,
532 },
533 {
534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
535 .name = "Headphones Impedance Playback Enum",
536 .info = hp_volume_offset_info,
537 .get = hp_volume_offset_get,
538 .put = hp_volume_offset_put,
539 },
540 INPUT_VOLUME("Mic Capture Volume", 0),
541 INPUT_VOLUME("Aux Capture Volume", 1),
542 INPUT_VOLUME("Front Mic Capture Volume", 2),
543 INPUT_VOLUME("Line Capture Volume", 3),
544 {
545 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
546 .name = "Capture Source",
547 .info = input_sel_info,
548 .get = input_sel_get,
549 .put = input_sel_put,
550 },
551 {
552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
553 .name = "ADC High-pass Filter Capture Enum",
554 .info = hpf_info,
555 .get = hpf_get,
556 .put = hpf_put,
557 },
558};
559
560static int dg_control_filter(struct snd_kcontrol_new *template)
561{
562 if (!strncmp(template->name, "Master Playback ", 16))
563 return 1;
564 return 0;
565}
566
567static int dg_mixer_init(struct oxygen *chip)
568{
569 unsigned int i;
570 int err;
571
572 for (i = 0; i < ARRAY_SIZE(dg_controls); ++i) {
573 err = snd_ctl_add(chip->card,
574 snd_ctl_new1(&dg_controls[i], chip));
575 if (err < 0)
576 return err;
577 }
578 return 0;
579}
580
581static void dump_cs4245_registers(struct oxygen *chip,
582 struct snd_info_buffer *buffer)
583{
584 struct dg *data = chip->model_data;
585 unsigned int i;
586
587 snd_iprintf(buffer, "\nCS4245:");
588 for (i = 1; i <= 0x10; ++i)
589 snd_iprintf(buffer, " %02x", data->cs4245_regs[i]);
590 snd_iprintf(buffer, "\n");
591}
592
593struct oxygen_model model_xonar_dg = {
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100594 .longname = "C-Media Oxygen HD Audio",
595 .chip = "CMI8786",
596 .init = dg_init,
597 .control_filter = dg_control_filter,
598 .mixer_init = dg_mixer_init,
599 .cleanup = dg_cleanup,
600 .suspend = dg_suspend,
601 .resume = dg_resume,
602 .set_dac_params = set_cs4245_dac_params,
603 .set_adc_params = set_cs4245_adc_params,
Clemens Ladischefbeb072011-01-31 11:47:52 +0100604 .adjust_dac_routing = adjust_dg_dac_routing,
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100605 .dump_registers = dump_cs4245_registers,
606 .model_data_size = sizeof(struct dg),
607 .device_config = PLAYBACK_0_TO_I2S |
608 PLAYBACK_1_TO_SPDIF |
Roman Volkovfd642c22014-01-24 16:18:14 +0400609 CAPTURE_0_FROM_I2S_1 |
Clemens Ladisch56225e42011-12-06 10:07:43 +0100610 CAPTURE_1_FROM_SPDIF,
Clemens Ladisch66410bf2011-01-10 16:20:29 +0100611 .dac_channels_pcm = 6,
612 .dac_channels_mixer = 0,
613 .function_flags = OXYGEN_FUNCTION_SPI,
614 .dac_mclks = OXYGEN_MCLKS(256, 128, 128),
615 .adc_mclks = OXYGEN_MCLKS(256, 128, 128),
616 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
617 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
618};