2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for C-Media CMI9880
6 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sound/driver.h>
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28 #include <linux/pci.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
35 /* board config type */
37 CMI_MINIMAL, /* back 3-jack */
38 CMI_MIN_FP, /* back 3-jack + front-panel 2-jack */
39 CMI_FULL, /* back 6-jack + front-panel 2-jack */
40 CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */
41 CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */
42 CMI_AUTO, /* let driver guess it */
47 unsigned int no_line_in: 1; /* no line-in (5-jack) */
48 unsigned int front_panel: 1; /* has front-panel 2-jack */
51 struct hda_multi_out multiout;
52 hda_nid_t dac_nids[4]; /* NID for each DAC */
60 const struct hda_input_mux *input_mux;
61 unsigned int cur_mux[2];
64 int num_channel_modes;
65 const struct hda_channel_mode *channel_modes;
67 struct hda_pcm pcm_rec[2]; /* PCM information */
69 /* pin deafault configuration */
70 hda_nid_t pin_nid[NUM_PINS];
71 unsigned int def_conf[NUM_PINS];
72 unsigned int pin_def_confs;
74 /* multichannel pins */
75 hda_nid_t multich_pin[4]; /* max 8-channel */
76 struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */
80 #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
81 #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
82 #define AMP_OUT_MUTE 0xb080
83 #define AMP_OUT_UNMUTE 0xb000
84 #define AMP_OUT_ZERO 0xb000
87 #define PIN_VREF80 0x24
88 #define PIN_VREF50 0x21
95 static int cmi_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
97 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
98 struct cmi_spec *spec = codec->spec;
99 return snd_hda_input_mux_info(spec->input_mux, uinfo);
102 static int cmi_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
104 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
105 struct cmi_spec *spec = codec->spec;
106 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
108 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
112 static int cmi_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
114 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
115 struct cmi_spec *spec = codec->spec;
116 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
118 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
119 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
123 * shared line-in, mic for surrounds
126 /* 3-stack / 2 channel */
127 static struct hda_verb cmi9880_ch2_init[] = {
128 /* set line-in PIN for input */
129 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
130 /* set mic PIN for input, also enable vref */
131 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
132 /* route front PCM (DAC1) to HP */
133 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
137 /* 3-stack / 6 channel */
138 static struct hda_verb cmi9880_ch6_init[] = {
139 /* set line-in PIN for output */
140 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
141 /* set mic PIN for output */
142 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
143 /* route front PCM (DAC1) to HP */
144 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
148 /* 3-stack+front / 8 channel */
149 static struct hda_verb cmi9880_ch8_init[] = {
150 /* set line-in PIN for output */
151 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
152 /* set mic PIN for output */
153 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
154 /* route rear-surround PCM (DAC4) to HP */
155 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x03 },
159 static struct hda_channel_mode cmi9880_channel_modes[3] = {
160 { 2, cmi9880_ch2_init },
161 { 6, cmi9880_ch6_init },
162 { 8, cmi9880_ch8_init },
165 static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
167 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
168 struct cmi_spec *spec = codec->spec;
169 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_modes,
170 spec->num_channel_modes);
173 static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
176 struct cmi_spec *spec = codec->spec;
177 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_modes,
178 spec->num_channel_modes, spec->multiout.max_channels);
181 static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
183 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
184 struct cmi_spec *spec = codec->spec;
185 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_modes,
186 spec->num_channel_modes, &spec->multiout.max_channels);
191 static snd_kcontrol_new_t cmi9880_basic_mixer[] = {
192 /* CMI9880 has no playback volumes! */
193 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), /* front */
194 HDA_CODEC_MUTE("Surround Playback Switch", 0x04, 0x0, HDA_OUTPUT),
195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
197 HDA_CODEC_MUTE("Side Playback Switch", 0x06, 0x0, HDA_OUTPUT),
199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
200 /* The multiple "Capture Source" controls confuse alsamixer
201 * So call somewhat different..
202 * FIXME: the controls appear in the "playback" view!
204 /* .name = "Capture Source", */
205 .name = "Input Source",
207 .info = cmi_mux_enum_info,
208 .get = cmi_mux_enum_get,
209 .put = cmi_mux_enum_put,
211 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0, HDA_INPUT),
212 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0, HDA_INPUT),
213 HDA_CODEC_MUTE("Capture Switch", 0x08, 0, HDA_INPUT),
214 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0, HDA_INPUT),
215 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x23, 0, HDA_OUTPUT),
216 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x23, 0, HDA_OUTPUT),
223 static snd_kcontrol_new_t cmi9880_ch_mode_mixer[] = {
225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
226 .name = "Channel Mode",
227 .info = cmi_ch_mode_info,
228 .get = cmi_ch_mode_get,
229 .put = cmi_ch_mode_put,
234 /* AUD-in selections:
235 * 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x1f 0x20
237 static struct hda_input_mux cmi9880_basic_mux = {
240 { "Front Mic", 0x5 },
247 static struct hda_input_mux cmi9880_no_line_mux = {
250 { "Front Mic", 0x5 },
256 /* front, rear, clfe, rear_surr */
257 static hda_nid_t cmi9880_dac_nids[4] = {
258 0x03, 0x04, 0x05, 0x06
261 static hda_nid_t cmi9880_adc_nids[2] = {
265 #define CMI_DIG_OUT_NID 0x07
266 #define CMI_DIG_IN_NID 0x0a
270 static struct hda_verb cmi9880_basic_init[] = {
271 /* port-D for line out (rear panel) */
272 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
273 /* port-E for HP out (front panel) */
274 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
275 /* route front PCM to HP */
276 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
277 /* port-A for surround (rear panel) */
278 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
279 /* port-G for CLFE (rear panel) */
280 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
281 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 },
282 /* port-H for side (rear panel) */
283 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
284 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 },
285 /* port-C for line-in (rear panel) */
286 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
287 /* port-B for mic-in (rear panel) with vref */
288 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
289 /* port-F for mic-in (front panel) with vref */
290 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
292 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
293 /* route front mic to ADC1/2 */
294 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 },
295 { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 },
299 static struct hda_verb cmi9880_allout_init[] = {
300 /* port-D for line out (rear panel) */
301 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
302 /* port-E for HP out (front panel) */
303 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
304 /* route front PCM to HP */
305 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
306 /* port-A for side (rear panel) */
307 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
308 /* port-G for CLFE (rear panel) */
309 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
310 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 },
311 /* port-H for side (rear panel) */
312 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
313 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 },
314 /* port-C for surround (rear panel) */
315 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
316 /* port-B for mic-in (rear panel) with vref */
317 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
318 /* port-F for mic-in (front panel) with vref */
319 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
321 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
322 /* route front mic to ADC1/2 */
323 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 },
324 { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 },
330 static int cmi9880_build_controls(struct hda_codec *codec)
332 struct cmi_spec *spec = codec->spec;
335 err = snd_hda_add_new_ctls(codec, cmi9880_basic_mixer);
338 if (spec->channel_modes) {
339 err = snd_hda_add_new_ctls(codec, cmi9880_ch_mode_mixer);
343 if (spec->multiout.dig_out_nid) {
344 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
348 if (spec->dig_in_nid) {
349 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
356 /* fill in the multi_dac_nids table, which will decide
357 which audio widget to use for each channel */
358 static int cmi9880_fill_multi_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
360 struct cmi_spec *spec = codec->spec;
365 /* clear the table, only one c-media dac assumed here */
366 memset(spec->dac_nids, 0, sizeof(spec->dac_nids));
367 memset(assigned, 0, sizeof(assigned));
368 /* check the pins we found */
369 for (i = 0; i < cfg->line_outs; i++) {
370 nid = cfg->line_out_pins[i];
371 /* nid 0x0b~0x0e is hardwired to audio widget 0x3~0x6 */
372 if (nid >= 0x0b && nid <= 0x0e) {
373 spec->dac_nids[i] = (nid - 0x0b) + 0x03;
374 assigned[nid - 0x0b] = 1;
377 /* left pin can be connect to any audio widget */
378 for (i = 0; i < cfg->line_outs; i++) {
379 nid = cfg->line_out_pins[i];
382 /* search for an empty channel */
383 for (j = 0; j < cfg->line_outs; j++) {
385 spec->dac_nids[i] = j + 0x03;
391 spec->num_dacs = cfg->line_outs;
395 /* create multi_init table, which is used for multichannel initialization */
396 static int cmi9880_fill_multi_init(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
398 struct cmi_spec *spec = codec->spec;
402 /* clear the table, only one c-media dac assumed here */
403 memset(spec->multi_init, 0, sizeof(spec->multi_init));
404 for (j = 0, i = 0; i < cfg->line_outs; i++) {
406 nid = cfg->line_out_pins[i];
408 spec->multi_init[j].nid = nid;
409 spec->multi_init[j].verb = AC_VERB_SET_PIN_WIDGET_CONTROL;
410 spec->multi_init[j].param = PIN_OUT;
414 spec->multi_init[j].nid = nid;
415 spec->multi_init[j].verb = AC_VERB_SET_CONNECT_SEL;
416 spec->multi_init[j].param = 0;
417 /* find the index in connect list */
418 len = snd_hda_get_connections(codec, nid, conn, 4);
419 for (k = 0; k < len; k++)
420 if (conn[k] == spec->dac_nids[i]) {
421 spec->multi_init[j].param = k;
430 static int cmi9880_init(struct hda_codec *codec)
432 struct cmi_spec *spec = codec->spec;
433 if (spec->board_config == CMI_ALLOUT)
434 snd_hda_sequence_write(codec, cmi9880_allout_init);
436 snd_hda_sequence_write(codec, cmi9880_basic_init);
437 if (spec->board_config == CMI_AUTO)
438 snd_hda_sequence_write(codec, spec->multi_init);
446 static int cmi9880_resume(struct hda_codec *codec)
448 struct cmi_spec *spec = codec->spec;
451 snd_hda_resume_ctls(codec, cmi9880_basic_mixer);
452 if (spec->channel_modes)
453 snd_hda_resume_ctls(codec, cmi9880_ch_mode_mixer);
454 if (spec->multiout.dig_out_nid)
455 snd_hda_resume_spdif_out(codec);
456 if (spec->dig_in_nid)
457 snd_hda_resume_spdif_in(codec);
464 * Analog playback callbacks
466 static int cmi9880_playback_pcm_open(struct hda_pcm_stream *hinfo,
467 struct hda_codec *codec,
468 snd_pcm_substream_t *substream)
470 struct cmi_spec *spec = codec->spec;
471 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
474 static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
475 struct hda_codec *codec,
476 unsigned int stream_tag,
478 snd_pcm_substream_t *substream)
480 struct cmi_spec *spec = codec->spec;
481 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
485 static int cmi9880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
486 struct hda_codec *codec,
487 snd_pcm_substream_t *substream)
489 struct cmi_spec *spec = codec->spec;
490 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
496 static int cmi9880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
497 struct hda_codec *codec,
498 snd_pcm_substream_t *substream)
500 struct cmi_spec *spec = codec->spec;
501 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
504 static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
505 struct hda_codec *codec,
506 snd_pcm_substream_t *substream)
508 struct cmi_spec *spec = codec->spec;
509 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
515 static int cmi9880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
516 struct hda_codec *codec,
517 unsigned int stream_tag,
519 snd_pcm_substream_t *substream)
521 struct cmi_spec *spec = codec->spec;
523 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
524 stream_tag, 0, format);
528 static int cmi9880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
529 struct hda_codec *codec,
530 snd_pcm_substream_t *substream)
532 struct cmi_spec *spec = codec->spec;
534 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
541 static struct hda_pcm_stream cmi9880_pcm_analog_playback = {
545 .nid = 0x03, /* NID to query formats and rates */
547 .open = cmi9880_playback_pcm_open,
548 .prepare = cmi9880_playback_pcm_prepare,
549 .cleanup = cmi9880_playback_pcm_cleanup
553 static struct hda_pcm_stream cmi9880_pcm_analog_capture = {
557 .nid = 0x08, /* NID to query formats and rates */
559 .prepare = cmi9880_capture_pcm_prepare,
560 .cleanup = cmi9880_capture_pcm_cleanup
564 static struct hda_pcm_stream cmi9880_pcm_digital_playback = {
568 /* NID is set in cmi9880_build_pcms */
570 .open = cmi9880_dig_playback_pcm_open,
571 .close = cmi9880_dig_playback_pcm_close
575 static struct hda_pcm_stream cmi9880_pcm_digital_capture = {
579 /* NID is set in cmi9880_build_pcms */
582 static int cmi9880_build_pcms(struct hda_codec *codec)
584 struct cmi_spec *spec = codec->spec;
585 struct hda_pcm *info = spec->pcm_rec;
588 codec->pcm_info = info;
590 info->name = "CMI9880";
591 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_analog_playback;
592 info->stream[SNDRV_PCM_STREAM_CAPTURE] = cmi9880_pcm_analog_capture;
594 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
597 info->name = "CMI9880 Digital";
598 if (spec->multiout.dig_out_nid) {
599 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback;
600 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
602 if (spec->dig_in_nid) {
603 info->stream[SNDRV_PCM_STREAM_CAPTURE] = cmi9880_pcm_digital_capture;
604 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
611 static void cmi9880_free(struct hda_codec *codec)
619 static struct hda_board_config cmi9880_cfg_tbl[] = {
620 { .modelname = "minimal", .config = CMI_MINIMAL },
621 { .modelname = "min_fp", .config = CMI_MIN_FP },
622 { .modelname = "full", .config = CMI_FULL },
623 { .modelname = "full_dig", .config = CMI_FULL_DIG },
624 { .pci_subvendor = 0x1043, .pci_subdevice = 0x813d, .config = CMI_FULL_DIG }, /* ASUS P5AD2 */
625 { .modelname = "allout", .config = CMI_ALLOUT },
626 { .modelname = "auto", .config = CMI_AUTO },
630 static struct hda_codec_ops cmi9880_patch_ops = {
631 .build_controls = cmi9880_build_controls,
632 .build_pcms = cmi9880_build_pcms,
633 .init = cmi9880_init,
634 .free = cmi9880_free,
636 .resume = cmi9880_resume,
640 static int patch_cmi9880(struct hda_codec *codec)
642 struct cmi_spec *spec;
644 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
649 spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl);
650 if (spec->board_config < 0) {
651 snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n");
652 spec->board_config = CMI_AUTO; /* try everything */
655 /* copy default DAC NIDs */
656 memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids));
659 switch (spec->board_config) {
662 spec->channel_modes = cmi9880_channel_modes;
663 if (spec->board_config == CMI_MINIMAL)
664 spec->num_channel_modes = 2;
666 spec->front_panel = 1;
667 spec->num_channel_modes = 3;
669 spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
670 spec->input_mux = &cmi9880_basic_mux;
674 spec->front_panel = 1;
675 spec->multiout.max_channels = 8;
676 spec->input_mux = &cmi9880_basic_mux;
677 if (spec->board_config == CMI_FULL_DIG) {
678 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
679 spec->dig_in_nid = CMI_DIG_IN_NID;
683 spec->front_panel = 1;
684 spec->multiout.max_channels = 8;
685 spec->no_line_in = 1;
686 spec->input_mux = &cmi9880_no_line_mux;
687 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
691 unsigned int port_e, port_f, port_g, port_h;
692 unsigned int port_spdifi, port_spdifo;
693 struct auto_pin_cfg cfg;
695 /* collect pin default configuration */
696 port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
697 port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
698 spec->front_panel = 1;
699 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE ||
700 get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) {
701 port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
702 port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
703 spec->channel_modes = cmi9880_channel_modes;
705 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE ||
706 get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) {
707 /* no optional rear panel */
708 spec->board_config = CMI_MINIMAL;
709 spec->front_panel = 0;
710 spec->num_channel_modes = 2;
712 spec->board_config = CMI_MIN_FP;
713 spec->num_channel_modes = 3;
715 spec->input_mux = &cmi9880_basic_mux;
716 spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
718 spec->input_mux = &cmi9880_basic_mux;
719 port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
720 port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
721 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE)
722 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
723 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE)
724 spec->dig_in_nid = CMI_DIG_IN_NID;
725 spec->multiout.max_channels = 8;
727 snd_hda_parse_pin_def_config(codec, &cfg);
729 spec->multiout.max_channels = cfg.line_outs * 2;
730 cmi9880_fill_multi_dac_nids(codec, &cfg);
731 cmi9880_fill_multi_init(codec, &cfg);
733 snd_printd("patch_cmedia: cannot detect association in defcfg\n");
738 spec->multiout.num_dacs = spec->num_dacs;
739 spec->multiout.dac_nids = spec->dac_nids;
741 spec->adc_nids = cmi9880_adc_nids;
743 codec->patch_ops = cmi9880_patch_ops;
751 struct hda_codec_preset snd_hda_preset_cmedia[] = {
752 { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 },
753 { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 },