oxygen.c (bc030d6cb9532877c1c5a3f5e7123344fa24a285) oxygen.c (1f4d7be7293aecd5f8469a46f606f62f0f05d84c)
1/*
2 * C-Media CMI8788 driver for C-Media's reference design and similar models
3 *
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.

--- 6 unchanged lines hidden (view full) ---

15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/*
21 * CMI8788:
22 *
1/*
2 * C-Media CMI8788 driver for C-Media's reference design and similar models
3 *
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.

--- 6 unchanged lines hidden (view full) ---

15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/*
21 * CMI8788:
22 *
23 * SPI 0 -> 1st AK4396 (front)
24 * SPI 1 -> 2nd AK4396 (surround)
25 * SPI 2 -> 3rd AK4396 (center/LFE)
26 * SPI 3 -> WM8785
27 * SPI 4 -> 4th AK4396 (back)
23 * SPI 0 -> 1st AK4396 (front)
24 * SPI 1 -> 2nd AK4396 (surround)
25 * SPI 2 -> 3rd AK4396 (center/LFE)
26 * SPI 3 -> WM8785
27 * SPI 4 -> 4th AK4396 (back)
28 *
28 *
29 * GPIO 0 -> DFS0 of AK5385
30 * GPIO 1 -> DFS1 of AK5385
31 * GPIO 8 -> enable headphone amplifier on HT-Omega models
29 * GPIO 0 -> DFS0 of AK5385
30 * GPIO 1 -> DFS1 of AK5385
31 * GPIO 8 -> enable headphone amplifier on HT-Omega models
32 *
33 * CM9780:
34 *
32 *
33 * CM9780:
34 *
35 * GPO 0 -> route line-in (0) or AC97 output (1) to ADC input
35 * LINE_OUT -> input of ADC
36 *
37 * AUX_IN <- aux
38 * CD_IN <- CD
39 * MIC_IN <- mic
40 *
41 * GPO 0 -> route line-in (0) or AC97 output (1) to ADC input
36 */
37
38#include <linux/delay.h>
39#include <linux/mutex.h>
40#include <linux/pci.h>
41#include <sound/ac97_codec.h>
42#include <sound/control.h>
43#include <sound/core.h>
42 */
43
44#include <linux/delay.h>
45#include <linux/mutex.h>
46#include <linux/pci.h>
47#include <sound/ac97_codec.h>
48#include <sound/control.h>
49#include <sound/core.h>
50#include <sound/info.h>
44#include <sound/initval.h>
45#include <sound/pcm.h>
46#include <sound/pcm_params.h>
47#include <sound/tlv.h>
48#include "oxygen.h"
49#include "ak4396.h"
50#include "wm8785.h"
51

--- 9 unchanged lines hidden (view full) ---

61module_param_array(index, int, NULL, 0444);
62MODULE_PARM_DESC(index, "card index");
63module_param_array(id, charp, NULL, 0444);
64MODULE_PARM_DESC(id, "ID string");
65module_param_array(enable, bool, NULL, 0444);
66MODULE_PARM_DESC(enable, "enable card");
67
68enum {
51#include <sound/initval.h>
52#include <sound/pcm.h>
53#include <sound/pcm_params.h>
54#include <sound/tlv.h>
55#include "oxygen.h"
56#include "ak4396.h"
57#include "wm8785.h"
58

--- 9 unchanged lines hidden (view full) ---

68module_param_array(index, int, NULL, 0444);
69MODULE_PARM_DESC(index, "card index");
70module_param_array(id, charp, NULL, 0444);
71MODULE_PARM_DESC(id, "ID string");
72module_param_array(enable, bool, NULL, 0444);
73MODULE_PARM_DESC(enable, "enable card");
74
75enum {
69 MODEL_CMEDIA_REF, /* C-Media's reference design */
70 MODEL_MERIDIAN, /* AuzenTech X-Meridian */
71 MODEL_CLARO, /* HT-Omega Claro */
72 MODEL_CLARO_HALO, /* HT-Omega Claro halo */
76 MODEL_CMEDIA_REF,
77 MODEL_MERIDIAN,
78 MODEL_CLARO,
79 MODEL_CLARO_HALO,
80 MODEL_FANTASIA,
81 MODEL_2CH_OUTPUT,
73};
74
75static DEFINE_PCI_DEVICE_TABLE(oxygen_ids) = {
82};
83
84static DEFINE_PCI_DEVICE_TABLE(oxygen_ids) = {
85 /* C-Media's reference design */
76 { OXYGEN_PCI_SUBID(0x10b0, 0x0216), .driver_data = MODEL_CMEDIA_REF },
77 { OXYGEN_PCI_SUBID(0x10b0, 0x0218), .driver_data = MODEL_CMEDIA_REF },
78 { OXYGEN_PCI_SUBID(0x10b0, 0x0219), .driver_data = MODEL_CMEDIA_REF },
79 { OXYGEN_PCI_SUBID(0x13f6, 0x0001), .driver_data = MODEL_CMEDIA_REF },
80 { OXYGEN_PCI_SUBID(0x13f6, 0x0010), .driver_data = MODEL_CMEDIA_REF },
81 { OXYGEN_PCI_SUBID(0x13f6, 0x8788), .driver_data = MODEL_CMEDIA_REF },
86 { OXYGEN_PCI_SUBID(0x10b0, 0x0216), .driver_data = MODEL_CMEDIA_REF },
87 { OXYGEN_PCI_SUBID(0x10b0, 0x0218), .driver_data = MODEL_CMEDIA_REF },
88 { OXYGEN_PCI_SUBID(0x10b0, 0x0219), .driver_data = MODEL_CMEDIA_REF },
89 { OXYGEN_PCI_SUBID(0x13f6, 0x0001), .driver_data = MODEL_CMEDIA_REF },
90 { OXYGEN_PCI_SUBID(0x13f6, 0x0010), .driver_data = MODEL_CMEDIA_REF },
91 { OXYGEN_PCI_SUBID(0x13f6, 0x8788), .driver_data = MODEL_CMEDIA_REF },
82 { OXYGEN_PCI_SUBID(0x13f6, 0xffff), .driver_data = MODEL_CMEDIA_REF },
83 { OXYGEN_PCI_SUBID(0x147a, 0xa017), .driver_data = MODEL_CMEDIA_REF },
84 { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF },
92 { OXYGEN_PCI_SUBID(0x147a, 0xa017), .driver_data = MODEL_CMEDIA_REF },
93 { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF },
94 /* Kuroutoshikou CMI8787-HG2PCI */
95 { OXYGEN_PCI_SUBID(0x13f6, 0xffff), .driver_data = MODEL_2CH_OUTPUT },
96 /* TempoTec HiFier Fantasia */
97 { OXYGEN_PCI_SUBID(0x14c3, 0x1710), .driver_data = MODEL_FANTASIA },
98 /* TempoTec HiFier Serenade */
99 { OXYGEN_PCI_SUBID(0x14c3, 0x1711), .driver_data = MODEL_2CH_OUTPUT },
100 /* AuzenTech X-Meridian */
85 { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN },
101 { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN },
102 /* HT-Omega Claro */
86 { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CLARO },
103 { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CLARO },
104 /* HT-Omega Claro halo */
87 { OXYGEN_PCI_SUBID(0x7284, 0x9781), .driver_data = MODEL_CLARO_HALO },
88 { }
89};
90MODULE_DEVICE_TABLE(pci, oxygen_ids);
91
92
93#define GPIO_AK5385_DFS_MASK 0x0003
94#define GPIO_AK5385_DFS_NORMAL 0x0000
95#define GPIO_AK5385_DFS_DOUBLE 0x0001
96#define GPIO_AK5385_DFS_QUAD 0x0002
97
98#define GPIO_CLARO_HP 0x0100
99
100struct generic_data {
105 { OXYGEN_PCI_SUBID(0x7284, 0x9781), .driver_data = MODEL_CLARO_HALO },
106 { }
107};
108MODULE_DEVICE_TABLE(pci, oxygen_ids);
109
110
111#define GPIO_AK5385_DFS_MASK 0x0003
112#define GPIO_AK5385_DFS_NORMAL 0x0000
113#define GPIO_AK5385_DFS_DOUBLE 0x0001
114#define GPIO_AK5385_DFS_QUAD 0x0002
115
116#define GPIO_CLARO_HP 0x0100
117
118struct generic_data {
119 unsigned int dacs;
101 u8 ak4396_regs[4][5];
102 u16 wm8785_regs[3];
103};
104
105static void ak4396_write(struct oxygen *chip, unsigned int codec,
106 u8 reg, u8 value)
107{
108 /* maps ALSA channel pair number to SPI output */

--- 34 unchanged lines hidden (view full) ---

143 data->wm8785_regs[reg] = value;
144}
145
146static void ak4396_registers_init(struct oxygen *chip)
147{
148 struct generic_data *data = chip->model_data;
149 unsigned int i;
150
120 u8 ak4396_regs[4][5];
121 u16 wm8785_regs[3];
122};
123
124static void ak4396_write(struct oxygen *chip, unsigned int codec,
125 u8 reg, u8 value)
126{
127 /* maps ALSA channel pair number to SPI output */

--- 34 unchanged lines hidden (view full) ---

162 data->wm8785_regs[reg] = value;
163}
164
165static void ak4396_registers_init(struct oxygen *chip)
166{
167 struct generic_data *data = chip->model_data;
168 unsigned int i;
169
151 for (i = 0; i < 4; ++i) {
170 for (i = 0; i < data->dacs; ++i) {
152 ak4396_write(chip, i, AK4396_CONTROL_1,
153 AK4396_DIF_24_MSB | AK4396_RSTN);
154 ak4396_write(chip, i, AK4396_CONTROL_2,
155 data->ak4396_regs[0][AK4396_CONTROL_2]);
156 ak4396_write(chip, i, AK4396_CONTROL_3,
157 AK4396_PCM);
158 ak4396_write(chip, i, AK4396_LCH_ATT,
159 chip->dac_volume[i * 2]);
160 ak4396_write(chip, i, AK4396_RCH_ATT,
161 chip->dac_volume[i * 2 + 1]);
162 }
163}
164
165static void ak4396_init(struct oxygen *chip)
166{
167 struct generic_data *data = chip->model_data;
168
171 ak4396_write(chip, i, AK4396_CONTROL_1,
172 AK4396_DIF_24_MSB | AK4396_RSTN);
173 ak4396_write(chip, i, AK4396_CONTROL_2,
174 data->ak4396_regs[0][AK4396_CONTROL_2]);
175 ak4396_write(chip, i, AK4396_CONTROL_3,
176 AK4396_PCM);
177 ak4396_write(chip, i, AK4396_LCH_ATT,
178 chip->dac_volume[i * 2]);
179 ak4396_write(chip, i, AK4396_RCH_ATT,
180 chip->dac_volume[i * 2 + 1]);
181 }
182}
183
184static void ak4396_init(struct oxygen *chip)
185{
186 struct generic_data *data = chip->model_data;
187
188 data->dacs = chip->model.dac_channels_pcm / 2;
169 data->ak4396_regs[0][AK4396_CONTROL_2] =
170 AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
171 ak4396_registers_init(chip);
172 snd_component_add(chip->card, "AK4396");
173}
174
175static void ak5385_init(struct oxygen *chip)
176{

--- 50 unchanged lines hidden (view full) ---

227
228static void claro_halo_init(struct oxygen *chip)
229{
230 ak4396_init(chip);
231 ak5385_init(chip);
232 claro_enable_hp(chip);
233}
234
189 data->ak4396_regs[0][AK4396_CONTROL_2] =
190 AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
191 ak4396_registers_init(chip);
192 snd_component_add(chip->card, "AK4396");
193}
194
195static void ak5385_init(struct oxygen *chip)
196{

--- 50 unchanged lines hidden (view full) ---

247
248static void claro_halo_init(struct oxygen *chip)
249{
250 ak4396_init(chip);
251 ak5385_init(chip);
252 claro_enable_hp(chip);
253}
254
255static void fantasia_init(struct oxygen *chip)
256{
257 ak4396_init(chip);
258 snd_component_add(chip->card, "CS5340");
259}
260
261static void stereo_output_init(struct oxygen *chip)
262{
263 ak4396_init(chip);
264}
265
235static void generic_cleanup(struct oxygen *chip)
236{
237}
238
239static void claro_disable_hp(struct oxygen *chip)
240{
241 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_CLARO_HP);
242}

--- 20 unchanged lines hidden (view full) ---

263}
264
265static void claro_resume(struct oxygen *chip)
266{
267 ak4396_registers_init(chip);
268 claro_enable_hp(chip);
269}
270
266static void generic_cleanup(struct oxygen *chip)
267{
268}
269
270static void claro_disable_hp(struct oxygen *chip)
271{
272 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_CLARO_HP);
273}

--- 20 unchanged lines hidden (view full) ---

294}
295
296static void claro_resume(struct oxygen *chip)
297{
298 ak4396_registers_init(chip);
299 claro_enable_hp(chip);
300}
301
302static void stereo_resume(struct oxygen *chip)
303{
304 ak4396_registers_init(chip);
305}
306
271static void set_ak4396_params(struct oxygen *chip,
272 struct snd_pcm_hw_params *params)
273{
274 struct generic_data *data = chip->model_data;
275 unsigned int i;
276 u8 value;
277
278 value = data->ak4396_regs[0][AK4396_CONTROL_2] & ~AK4396_DFS_MASK;
279 if (params_rate(params) <= 54000)
280 value |= AK4396_DFS_NORMAL;
281 else if (params_rate(params) <= 108000)
282 value |= AK4396_DFS_DOUBLE;
283 else
284 value |= AK4396_DFS_QUAD;
285
286 msleep(1); /* wait for the new MCLK to become stable */
287
288 if (value != data->ak4396_regs[0][AK4396_CONTROL_2]) {
307static void set_ak4396_params(struct oxygen *chip,
308 struct snd_pcm_hw_params *params)
309{
310 struct generic_data *data = chip->model_data;
311 unsigned int i;
312 u8 value;
313
314 value = data->ak4396_regs[0][AK4396_CONTROL_2] & ~AK4396_DFS_MASK;
315 if (params_rate(params) <= 54000)
316 value |= AK4396_DFS_NORMAL;
317 else if (params_rate(params) <= 108000)
318 value |= AK4396_DFS_DOUBLE;
319 else
320 value |= AK4396_DFS_QUAD;
321
322 msleep(1); /* wait for the new MCLK to become stable */
323
324 if (value != data->ak4396_regs[0][AK4396_CONTROL_2]) {
289 for (i = 0; i < 4; ++i) {
325 for (i = 0; i < data->dacs; ++i) {
290 ak4396_write(chip, i, AK4396_CONTROL_1,
291 AK4396_DIF_24_MSB);
292 ak4396_write(chip, i, AK4396_CONTROL_2, value);
293 ak4396_write(chip, i, AK4396_CONTROL_1,
294 AK4396_DIF_24_MSB | AK4396_RSTN);
295 }
296 }
297}
298
299static void update_ak4396_volume(struct oxygen *chip)
300{
326 ak4396_write(chip, i, AK4396_CONTROL_1,
327 AK4396_DIF_24_MSB);
328 ak4396_write(chip, i, AK4396_CONTROL_2, value);
329 ak4396_write(chip, i, AK4396_CONTROL_1,
330 AK4396_DIF_24_MSB | AK4396_RSTN);
331 }
332 }
333}
334
335static void update_ak4396_volume(struct oxygen *chip)
336{
337 struct generic_data *data = chip->model_data;
301 unsigned int i;
302
338 unsigned int i;
339
303 for (i = 0; i < 4; ++i) {
340 for (i = 0; i < data->dacs; ++i) {
304 ak4396_write_cached(chip, i, AK4396_LCH_ATT,
305 chip->dac_volume[i * 2]);
306 ak4396_write_cached(chip, i, AK4396_RCH_ATT,
307 chip->dac_volume[i * 2 + 1]);
308 }
309}
310
311static void update_ak4396_mute(struct oxygen *chip)
312{
313 struct generic_data *data = chip->model_data;
314 unsigned int i;
315 u8 value;
316
317 value = data->ak4396_regs[0][AK4396_CONTROL_2] & ~AK4396_SMUTE;
318 if (chip->dac_mute)
319 value |= AK4396_SMUTE;
341 ak4396_write_cached(chip, i, AK4396_LCH_ATT,
342 chip->dac_volume[i * 2]);
343 ak4396_write_cached(chip, i, AK4396_RCH_ATT,
344 chip->dac_volume[i * 2 + 1]);
345 }
346}
347
348static void update_ak4396_mute(struct oxygen *chip)
349{
350 struct generic_data *data = chip->model_data;
351 unsigned int i;
352 u8 value;
353
354 value = data->ak4396_regs[0][AK4396_CONTROL_2] & ~AK4396_SMUTE;
355 if (chip->dac_mute)
356 value |= AK4396_SMUTE;
320 for (i = 0; i < 4; ++i)
357 for (i = 0; i < data->dacs; ++i)
321 ak4396_write_cached(chip, i, AK4396_CONTROL_2, value);
322}
323
324static void set_wm8785_params(struct oxygen *chip,
325 struct snd_pcm_hw_params *params)
326{
327 struct generic_data *data = chip->model_data;
328 unsigned int value;

--- 22 unchanged lines hidden (view full) ---

351 else if (params_rate(params) <= 108000)
352 value = GPIO_AK5385_DFS_DOUBLE;
353 else
354 value = GPIO_AK5385_DFS_QUAD;
355 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
356 value, GPIO_AK5385_DFS_MASK);
357}
358
358 ak4396_write_cached(chip, i, AK4396_CONTROL_2, value);
359}
360
361static void set_wm8785_params(struct oxygen *chip,
362 struct snd_pcm_hw_params *params)
363{
364 struct generic_data *data = chip->model_data;
365 unsigned int value;

--- 22 unchanged lines hidden (view full) ---

388 else if (params_rate(params) <= 108000)
389 value = GPIO_AK5385_DFS_DOUBLE;
390 else
391 value = GPIO_AK5385_DFS_QUAD;
392 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
393 value, GPIO_AK5385_DFS_MASK);
394}
395
396static void set_no_params(struct oxygen *chip, struct snd_pcm_hw_params *params)
397{
398}
399
359static int rolloff_info(struct snd_kcontrol *ctl,
360 struct snd_ctl_elem_info *info)
361{
362 static const char *const names[2] = {
363 "Sharp Roll-off", "Slow Roll-off"
364 };
365
366 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;

--- 28 unchanged lines hidden (view full) ---

395 mutex_lock(&chip->mutex);
396 reg = data->ak4396_regs[0][AK4396_CONTROL_2];
397 if (value->value.enumerated.item[0])
398 reg |= AK4396_SLOW;
399 else
400 reg &= ~AK4396_SLOW;
401 changed = reg != data->ak4396_regs[0][AK4396_CONTROL_2];
402 if (changed) {
400static int rolloff_info(struct snd_kcontrol *ctl,
401 struct snd_ctl_elem_info *info)
402{
403 static const char *const names[2] = {
404 "Sharp Roll-off", "Slow Roll-off"
405 };
406
407 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;

--- 28 unchanged lines hidden (view full) ---

436 mutex_lock(&chip->mutex);
437 reg = data->ak4396_regs[0][AK4396_CONTROL_2];
438 if (value->value.enumerated.item[0])
439 reg |= AK4396_SLOW;
440 else
441 reg &= ~AK4396_SLOW;
442 changed = reg != data->ak4396_regs[0][AK4396_CONTROL_2];
443 if (changed) {
403 for (i = 0; i < 4; ++i)
444 for (i = 0; i < data->dacs; ++i)
404 ak4396_write(chip, i, AK4396_CONTROL_2, reg);
405 }
406 mutex_unlock(&chip->mutex);
407 return changed;
408}
409
410static const struct snd_kcontrol_new rolloff_control = {
411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,

--- 67 unchanged lines hidden (view full) ---

479 if (err < 0)
480 return err;
481 err = snd_ctl_add(chip->card, snd_ctl_new1(&hpf_control, chip));
482 if (err < 0)
483 return err;
484 return 0;
485}
486
445 ak4396_write(chip, i, AK4396_CONTROL_2, reg);
446 }
447 mutex_unlock(&chip->mutex);
448 return changed;
449}
450
451static const struct snd_kcontrol_new rolloff_control = {
452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,

--- 67 unchanged lines hidden (view full) ---

520 if (err < 0)
521 return err;
522 err = snd_ctl_add(chip->card, snd_ctl_new1(&hpf_control, chip));
523 if (err < 0)
524 return err;
525 return 0;
526}
527
528static void dump_ak4396_registers(struct oxygen *chip,
529 struct snd_info_buffer *buffer)
530{
531 struct generic_data *data = chip->model_data;
532 unsigned int dac, i;
533
534 for (dac = 0; dac < data->dacs; ++dac) {
535 snd_iprintf(buffer, "\nAK4396 %u:", dac + 1);
536 for (i = 0; i < 5; ++i)
537 snd_iprintf(buffer, " %02x", data->ak4396_regs[dac][i]);
538 }
539 snd_iprintf(buffer, "\n");
540}
541
542static void dump_wm8785_registers(struct oxygen *chip,
543 struct snd_info_buffer *buffer)
544{
545 struct generic_data *data = chip->model_data;
546 unsigned int i;
547
548 snd_iprintf(buffer, "\nWM8785:");
549 for (i = 0; i < 3; ++i)
550 snd_iprintf(buffer, " %03x", data->wm8785_regs[i]);
551 snd_iprintf(buffer, "\n");
552}
553
554static void dump_oxygen_registers(struct oxygen *chip,
555 struct snd_info_buffer *buffer)
556{
557 dump_ak4396_registers(chip, buffer);
558 dump_wm8785_registers(chip, buffer);
559}
560
487static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
488
489static const struct oxygen_model model_generic = {
490 .shortname = "C-Media CMI8788",
491 .longname = "C-Media Oxygen HD Audio",
492 .chip = "CMI8788",
493 .init = generic_init,
494 .mixer_init = generic_wm8785_mixer_init,
495 .cleanup = generic_cleanup,
496 .resume = generic_resume,
497 .get_i2s_mclk = oxygen_default_i2s_mclk,
498 .set_dac_params = set_ak4396_params,
499 .set_adc_params = set_wm8785_params,
500 .update_dac_volume = update_ak4396_volume,
501 .update_dac_mute = update_ak4396_mute,
561static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
562
563static const struct oxygen_model model_generic = {
564 .shortname = "C-Media CMI8788",
565 .longname = "C-Media Oxygen HD Audio",
566 .chip = "CMI8788",
567 .init = generic_init,
568 .mixer_init = generic_wm8785_mixer_init,
569 .cleanup = generic_cleanup,
570 .resume = generic_resume,
571 .get_i2s_mclk = oxygen_default_i2s_mclk,
572 .set_dac_params = set_ak4396_params,
573 .set_adc_params = set_wm8785_params,
574 .update_dac_volume = update_ak4396_volume,
575 .update_dac_mute = update_ak4396_mute,
576 .dump_registers = dump_oxygen_registers,
502 .dac_tlv = ak4396_db_scale,
503 .model_data_size = sizeof(struct generic_data),
504 .device_config = PLAYBACK_0_TO_I2S |
505 PLAYBACK_1_TO_SPDIF |
506 PLAYBACK_2_TO_AC97_1 |
507 CAPTURE_0_FROM_I2S_1 |
508 CAPTURE_1_FROM_SPDIF |
509 CAPTURE_2_FROM_AC97_1 |
510 AC97_CD_INPUT,
577 .dac_tlv = ak4396_db_scale,
578 .model_data_size = sizeof(struct generic_data),
579 .device_config = PLAYBACK_0_TO_I2S |
580 PLAYBACK_1_TO_SPDIF |
581 PLAYBACK_2_TO_AC97_1 |
582 CAPTURE_0_FROM_I2S_1 |
583 CAPTURE_1_FROM_SPDIF |
584 CAPTURE_2_FROM_AC97_1 |
585 AC97_CD_INPUT,
511 .dac_channels = 8,
586 .dac_channels_pcm = 8,
587 .dac_channels_mixer = 8,
512 .dac_volume_min = 0,
513 .dac_volume_max = 255,
514 .function_flags = OXYGEN_FUNCTION_SPI |
515 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
516 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
517 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
518};
519
520static int __devinit get_oxygen_model(struct oxygen *chip,
521 const struct pci_device_id *id)
522{
523 chip->model = model_generic;
524 switch (id->driver_data) {
525 case MODEL_MERIDIAN:
526 chip->model.init = meridian_init;
527 chip->model.mixer_init = generic_mixer_init;
528 chip->model.resume = meridian_resume;
529 chip->model.set_adc_params = set_ak5385_params;
588 .dac_volume_min = 0,
589 .dac_volume_max = 255,
590 .function_flags = OXYGEN_FUNCTION_SPI |
591 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
592 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
593 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
594};
595
596static int __devinit get_oxygen_model(struct oxygen *chip,
597 const struct pci_device_id *id)
598{
599 chip->model = model_generic;
600 switch (id->driver_data) {
601 case MODEL_MERIDIAN:
602 chip->model.init = meridian_init;
603 chip->model.mixer_init = generic_mixer_init;
604 chip->model.resume = meridian_resume;
605 chip->model.set_adc_params = set_ak5385_params;
606 chip->model.dump_registers = dump_ak4396_registers;
530 chip->model.device_config = PLAYBACK_0_TO_I2S |
531 PLAYBACK_1_TO_SPDIF |
532 CAPTURE_0_FROM_I2S_2 |
533 CAPTURE_1_FROM_SPDIF;
534 break;
535 case MODEL_CLARO:
536 chip->model.init = claro_init;
537 chip->model.cleanup = claro_cleanup;
538 chip->model.suspend = claro_suspend;
539 chip->model.resume = claro_resume;
540 break;
541 case MODEL_CLARO_HALO:
542 chip->model.init = claro_halo_init;
543 chip->model.mixer_init = generic_mixer_init;
544 chip->model.cleanup = claro_cleanup;
545 chip->model.suspend = claro_suspend;
546 chip->model.resume = claro_resume;
547 chip->model.set_adc_params = set_ak5385_params;
607 chip->model.device_config = PLAYBACK_0_TO_I2S |
608 PLAYBACK_1_TO_SPDIF |
609 CAPTURE_0_FROM_I2S_2 |
610 CAPTURE_1_FROM_SPDIF;
611 break;
612 case MODEL_CLARO:
613 chip->model.init = claro_init;
614 chip->model.cleanup = claro_cleanup;
615 chip->model.suspend = claro_suspend;
616 chip->model.resume = claro_resume;
617 break;
618 case MODEL_CLARO_HALO:
619 chip->model.init = claro_halo_init;
620 chip->model.mixer_init = generic_mixer_init;
621 chip->model.cleanup = claro_cleanup;
622 chip->model.suspend = claro_suspend;
623 chip->model.resume = claro_resume;
624 chip->model.set_adc_params = set_ak5385_params;
625 chip->model.dump_registers = dump_ak4396_registers;
548 chip->model.device_config = PLAYBACK_0_TO_I2S |
549 PLAYBACK_1_TO_SPDIF |
550 CAPTURE_0_FROM_I2S_2 |
551 CAPTURE_1_FROM_SPDIF;
552 break;
626 chip->model.device_config = PLAYBACK_0_TO_I2S |
627 PLAYBACK_1_TO_SPDIF |
628 CAPTURE_0_FROM_I2S_2 |
629 CAPTURE_1_FROM_SPDIF;
630 break;
631 case MODEL_FANTASIA:
632 case MODEL_2CH_OUTPUT:
633 chip->model.shortname = "C-Media CMI8787";
634 chip->model.chip = "CMI8787";
635 if (id->driver_data == MODEL_FANTASIA)
636 chip->model.init = fantasia_init;
637 else
638 chip->model.init = stereo_output_init;
639 chip->model.resume = stereo_resume;
640 chip->model.mixer_init = generic_mixer_init;
641 chip->model.set_adc_params = set_no_params;
642 chip->model.dump_registers = dump_ak4396_registers;
643 chip->model.device_config = PLAYBACK_0_TO_I2S |
644 PLAYBACK_1_TO_SPDIF;
645 if (id->driver_data == MODEL_FANTASIA)
646 chip->model.device_config |= CAPTURE_0_FROM_I2S_1;
647 chip->model.dac_channels_pcm = 2;
648 chip->model.dac_channels_mixer = 2;
649 break;
553 }
554 if (id->driver_data == MODEL_MERIDIAN ||
555 id->driver_data == MODEL_CLARO_HALO) {
556 chip->model.misc_flags = OXYGEN_MISC_MIDI;
557 chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT;
558 }
559 return 0;
560}

--- 43 unchanged lines hidden ---
650 }
651 if (id->driver_data == MODEL_MERIDIAN ||
652 id->driver_data == MODEL_CLARO_HALO) {
653 chip->model.misc_flags = OXYGEN_MISC_MIDI;
654 chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT;
655 }
656 return 0;
657}

--- 43 unchanged lines hidden ---