2 * Universal Interface for Intel High Definition Audio Codec
4 * Generic widget tree parser
6 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
8 * This driver is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This driver is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <sound/driver.h>
24 #include <linux/init.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include "hda_codec.h"
29 #include "hda_local.h"
31 /* widget node for parsing */
33 hda_nid_t nid; /* NID of this widget */
34 unsigned short nconns; /* number of input connections */
35 hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; /* input connections */
36 unsigned int wid_caps; /* widget capabilities */
37 unsigned char type; /* widget type */
38 unsigned char pin_ctl; /* pin controls */
39 unsigned char checked; /* the flag indicates that the node is already parsed */
40 unsigned int pin_caps; /* pin widget capabilities */
41 unsigned int def_cfg; /* default configuration */
42 unsigned int amp_out_caps; /* AMP out capabilities */
43 unsigned int amp_in_caps; /* AMP in capabilities */
44 struct list_head list;
47 /* patch-specific record */
49 struct hda_gnode *dac_node; /* DAC node */
50 struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */
51 struct hda_gnode *pcm_vol_node; /* Node for PCM volume */
52 unsigned int pcm_vol_index; /* connection of PCM volume */
54 struct hda_gnode *adc_node; /* ADC node */
55 struct hda_gnode *cap_vol_node; /* Node for capture volume */
56 unsigned int cur_cap_src; /* current capture source */
57 struct hda_input_mux input_mux;
58 char cap_labels[HDA_MAX_NUM_INPUTS][16];
60 unsigned int def_amp_in_caps;
61 unsigned int def_amp_out_caps;
63 struct hda_pcm pcm_rec; /* PCM information */
65 struct list_head nid_list; /* list of widgets */
69 * retrieve the default device type from the default config value
71 #define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
72 #define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
77 static void snd_hda_generic_free(struct hda_codec *codec)
79 struct hda_gspec *spec = codec->spec;
80 struct list_head *p, *n;
84 /* free all widgets */
85 list_for_each_safe(p, n, &spec->nid_list) {
86 struct hda_gnode *node = list_entry(p, struct hda_gnode, list);
94 * add a new widget node and read its attributes
96 static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid_t nid)
98 struct hda_gnode *node;
101 node = kcalloc(1, sizeof(*node), GFP_KERNEL);
105 nconns = snd_hda_get_connections(codec, nid, node->conn_list, HDA_MAX_CONNECTIONS);
110 node->nconns = nconns;
111 node->wid_caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
112 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
114 if (node->type == AC_WID_PIN) {
115 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP);
116 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
117 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
120 if (node->wid_caps & AC_WCAP_OUT_AMP) {
121 if (node->wid_caps & AC_WCAP_AMP_OVRD)
122 node->amp_out_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_OUT_CAP);
123 if (! node->amp_out_caps)
124 node->amp_out_caps = spec->def_amp_out_caps;
126 if (node->wid_caps & AC_WCAP_IN_AMP) {
127 if (node->wid_caps & AC_WCAP_AMP_OVRD)
128 node->amp_in_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_IN_CAP);
129 if (! node->amp_in_caps)
130 node->amp_in_caps = spec->def_amp_in_caps;
132 list_add_tail(&node->list, &spec->nid_list);
137 * build the AFG subtree
139 static int build_afg_tree(struct hda_codec *codec)
141 struct hda_gspec *spec = codec->spec;
145 snd_assert(spec, return -EINVAL);
147 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP);
148 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP);
150 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
151 if (! nid || nodes < 0) {
152 printk(KERN_ERR "Invalid AFG subtree\n");
156 /* parse all nodes belonging to the AFG */
157 for (i = 0; i < nodes; i++, nid++) {
158 if ((err = add_new_node(codec, spec, nid)) < 0)
167 * look for the node record for the given NID
169 /* FIXME: should avoid the braindead linear search */
170 static struct hda_gnode *hda_get_node(struct hda_gspec *spec, hda_nid_t nid)
173 struct hda_gnode *node;
175 list_for_each(p, &spec->nid_list) {
176 node = list_entry(p, struct hda_gnode, list);
177 if (node->nid == nid)
184 * unmute (and set max vol) the output amplifier
186 static int unmute_output(struct hda_codec *codec, struct hda_gnode *node)
188 unsigned int val, ofs;
189 snd_printdd("UNMUTE OUT: NID=0x%x\n", node->nid);
190 val = (node->amp_out_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
191 ofs = (node->amp_out_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
194 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;
195 val |= AC_AMP_SET_OUTPUT;
196 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val);
200 * unmute (and set max vol) the input amplifier
202 static int unmute_input(struct hda_codec *codec, struct hda_gnode *node, unsigned int index)
204 unsigned int val, ofs;
205 snd_printdd("UNMUTE IN: NID=0x%x IDX=0x%x\n", node->nid, index);
206 val = (node->amp_in_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
207 ofs = (node->amp_in_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
210 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;
211 val |= AC_AMP_SET_INPUT;
212 // awk added - fixed to allow unmuting of indexed amps
213 val |= index << AC_AMP_SET_INDEX_SHIFT;
214 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val);
218 * select the input connection of the given node.
220 static int select_input_connection(struct hda_codec *codec, struct hda_gnode *node,
223 snd_printdd("CONNECT: NID=0x%x IDX=0x%x\n", node->nid, index);
224 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_CONNECT_SEL, index);
228 * clear checked flag of each node in the node list
230 static void clear_check_flags(struct hda_gspec *spec)
233 struct hda_gnode *node;
235 list_for_each(p, &spec->nid_list) {
236 node = list_entry(p, struct hda_gnode, list);
242 * parse the output path recursively until reach to an audio output widget
244 * returns 0 if not found, 1 if found, or a negative error code.
246 static int parse_output_path(struct hda_codec *codec, struct hda_gspec *spec,
247 struct hda_gnode *node)
250 struct hda_gnode *child;
256 if (node->type == AC_WID_AUD_OUT) {
257 if (node->wid_caps & AC_WCAP_DIGITAL) {
258 snd_printdd("Skip Digital OUT node %x\n", node->nid);
261 snd_printdd("AUD_OUT found %x\n", node->nid);
262 if (spec->dac_node) {
263 /* already DAC node is assigned, just unmute & connect */
264 return node == spec->dac_node;
266 spec->dac_node = node;
267 if (node->wid_caps & AC_WCAP_OUT_AMP) {
268 spec->pcm_vol_node = node;
269 spec->pcm_vol_index = 0;
271 return 1; /* found */
274 for (i = 0; i < node->nconns; i++) {
275 child = hda_get_node(spec, node->conn_list[i]);
278 err = parse_output_path(codec, spec, child);
283 * select the path, unmute both input and output
285 if (node->nconns > 1)
286 select_input_connection(codec, node, i);
287 unmute_input(codec, node, i);
288 unmute_output(codec, node);
289 if (! spec->pcm_vol_node) {
290 if (node->wid_caps & AC_WCAP_IN_AMP) {
291 spec->pcm_vol_node = node;
292 spec->pcm_vol_index = i;
293 } else if (node->wid_caps & AC_WCAP_OUT_AMP) {
294 spec->pcm_vol_node = node;
295 spec->pcm_vol_index = 0;
305 * Look for the output PIN widget with the given jack type
306 * and parse the output path to that PIN.
308 * Returns the PIN node when the path to DAC is established.
310 static struct hda_gnode *parse_output_jack(struct hda_codec *codec,
311 struct hda_gspec *spec,
315 struct hda_gnode *node;
318 list_for_each(p, &spec->nid_list) {
319 node = list_entry(p, struct hda_gnode, list);
320 if (node->type != AC_WID_PIN)
322 /* output capable? */
323 if (! (node->pin_caps & AC_PINCAP_OUT))
325 if (jack_type >= 0) {
326 if (jack_type != defcfg_type(node))
328 if (node->wid_caps & AC_WCAP_DIGITAL)
329 continue; /* skip SPDIF */
331 /* output as default? */
332 if (! (node->pin_ctl & AC_PINCTL_OUT_EN))
335 clear_check_flags(spec);
336 err = parse_output_path(codec, spec, node);
340 /* unmute the PIN output */
341 unmute_output(codec, node);
342 /* set PIN-Out enable */
343 snd_hda_codec_write(codec, node->nid, 0,
344 AC_VERB_SET_PIN_WIDGET_CONTROL,
345 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
356 static int parse_output(struct hda_codec *codec)
358 struct hda_gspec *spec = codec->spec;
359 struct hda_gnode *node;
362 * Look for the output PIN widget
364 /* first, look for the line-out pin */
365 node = parse_output_jack(codec, spec, AC_JACK_LINE_OUT);
366 if (node) /* found, remember the PIN node */
367 spec->out_pin_node = node;
368 /* look for the HP-out pin */
369 node = parse_output_jack(codec, spec, AC_JACK_HP_OUT);
371 if (! spec->out_pin_node)
372 spec->out_pin_node = node;
375 if (! spec->out_pin_node) {
376 /* no line-out or HP pins found,
377 * then choose for the first output pin
379 spec->out_pin_node = parse_output_jack(codec, spec, -1);
380 if (! spec->out_pin_node)
381 snd_printd("hda_generic: no proper output path found\n");
391 /* control callbacks */
392 static int capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct hda_gspec *spec = codec->spec;
396 return snd_hda_input_mux_info(&spec->input_mux, uinfo);
399 static int capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
402 struct hda_gspec *spec = codec->spec;
404 ucontrol->value.enumerated.item[0] = spec->cur_cap_src;
408 static int capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 struct hda_gspec *spec = codec->spec;
412 return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol,
413 spec->adc_node->nid, &spec->cur_cap_src);
417 * return the string name of the given input PIN widget
419 static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl)
421 unsigned int location = defcfg_location(node);
422 switch (defcfg_type(node)) {
423 case AC_JACK_LINE_IN:
424 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
429 *pinctl |= AC_PINCTL_VREF_GRD;
432 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
436 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
439 case AC_JACK_SPDIF_IN:
441 case AC_JACK_DIG_OTHER_IN:
448 * parse the nodes recursively until reach to the input PIN
450 * returns 0 if not found, 1 if found, or a negative error code.
452 static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
453 struct hda_gnode *node)
464 if (node->type != AC_WID_PIN) {
465 for (i = 0; i < node->nconns; i++) {
466 struct hda_gnode *child;
467 child = hda_get_node(spec, node->conn_list[i]);
470 err = parse_adc_sub_nodes(codec, spec, child);
475 * select the path, unmute both input and output
477 if (node->nconns > 1)
478 select_input_connection(codec, node, i);
479 unmute_input(codec, node, i);
480 unmute_output(codec, node);
488 if (! (node->pin_caps & AC_PINCAP_IN))
491 if (node->wid_caps & AC_WCAP_DIGITAL)
492 return 0; /* skip SPDIF */
494 if (spec->input_mux.num_items >= HDA_MAX_NUM_INPUTS) {
495 snd_printk(KERN_ERR "hda_generic: Too many items for capture\n");
499 pinctl = AC_PINCTL_IN_EN;
500 /* create a proper capture source label */
501 type = get_input_type(node, &pinctl);
503 /* input as default? */
504 if (! (node->pin_ctl & AC_PINCTL_IN_EN))
508 label = spec->cap_labels[spec->input_mux.num_items];
510 spec->input_mux.items[spec->input_mux.num_items].label = label;
512 /* unmute the PIN external input */
513 unmute_input(codec, node, 0); /* index = 0? */
514 /* set PIN-In enable */
515 snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
517 return 1; /* found */
523 static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node)
525 struct hda_gspec *spec = codec->spec;
526 struct hda_gnode *node;
529 snd_printdd("AUD_IN = %x\n", adc_node->nid);
530 clear_check_flags(spec);
532 // awk added - fixed no recording due to muted widget
533 unmute_input(codec, adc_node, 0);
536 * check each connection of the ADC
537 * if it reaches to a proper input PIN, add the path as the
540 for (i = 0; i < adc_node->nconns; i++) {
541 node = hda_get_node(spec, adc_node->conn_list[i]);
544 err = parse_adc_sub_nodes(codec, spec, node);
548 struct hda_input_mux_item *csrc = &spec->input_mux.items[spec->input_mux.num_items];
549 char *buf = spec->cap_labels[spec->input_mux.num_items];
551 for (ocap = 0; ocap < spec->input_mux.num_items; ocap++) {
552 if (! strcmp(buf, spec->cap_labels[ocap])) {
553 /* same label already exists,
554 * put the index number to be unique
556 sprintf(buf, "%s %d", spec->cap_labels[ocap],
557 spec->input_mux.num_items);
561 spec->input_mux.num_items++;
565 if (! spec->input_mux.num_items)
566 return 0; /* no input path found... */
568 snd_printdd("[Capture Source] NID=0x%x, #SRC=%d\n", adc_node->nid, spec->input_mux.num_items);
569 for (i = 0; i < spec->input_mux.num_items; i++)
570 snd_printdd(" [%s] IDX=0x%x\n", spec->input_mux.items[i].label,
571 spec->input_mux.items[i].index);
573 spec->adc_node = adc_node;
580 static int parse_input(struct hda_codec *codec)
582 struct hda_gspec *spec = codec->spec;
584 struct hda_gnode *node;
588 * At first we look for an audio input widget.
589 * If it reaches to certain input PINs, we take it as the
592 list_for_each(p, &spec->nid_list) {
593 node = list_entry(p, struct hda_gnode, list);
594 if (node->wid_caps & AC_WCAP_DIGITAL)
595 continue; /* skip SPDIF */
596 if (node->type == AC_WID_AUD_IN) {
597 err = parse_input_path(codec, node);
604 snd_printd("hda_generic: no proper input path found\n");
609 * create mixer controls if possible
614 static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
615 unsigned int index, const char *type, const char *dir_sfx)
620 snd_kcontrol_new_t knew;
623 sprintf(name, "%s %s Switch", type, dir_sfx);
625 sprintf(name, "%s Switch", dir_sfx);
626 if ((node->wid_caps & AC_WCAP_IN_AMP) &&
627 (node->amp_in_caps & AC_AMPCAP_MUTE)) {
628 knew = (snd_kcontrol_new_t)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT);
629 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
630 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
633 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
634 (node->amp_out_caps & AC_AMPCAP_MUTE)) {
635 knew = (snd_kcontrol_new_t)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT);
636 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
637 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
643 sprintf(name, "%s %s Volume", type, dir_sfx);
645 sprintf(name, "%s Volume", dir_sfx);
646 if ((node->wid_caps & AC_WCAP_IN_AMP) &&
647 (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) {
648 knew = (snd_kcontrol_new_t)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT);
649 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
650 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
653 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
654 (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) {
655 knew = (snd_kcontrol_new_t)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);
656 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
657 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
666 * check whether the controls with the given name and direction suffix already exist
668 static int check_existing_control(struct hda_codec *codec, const char *type, const char *dir)
670 snd_ctl_elem_id_t id;
671 memset(&id, 0, sizeof(id));
672 sprintf(id.name, "%s %s Volume", type, dir);
673 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
674 if (snd_ctl_find_id(codec->bus->card, &id))
676 sprintf(id.name, "%s %s Switch", type, dir);
677 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
678 if (snd_ctl_find_id(codec->bus->card, &id))
684 * build output mixer controls
686 static int build_output_controls(struct hda_codec *codec)
688 struct hda_gspec *spec = codec->spec;
691 err = create_mixer(codec, spec->pcm_vol_node, spec->pcm_vol_index,
698 /* create capture volume/switch */
699 static int build_input_controls(struct hda_codec *codec)
701 struct hda_gspec *spec = codec->spec;
702 struct hda_gnode *adc_node = spec->adc_node;
706 return 0; /* not found */
708 /* create capture volume and switch controls if the ADC has an amp */
709 err = create_mixer(codec, adc_node, 0, NULL, "Capture");
711 /* create input MUX if multiple sources are available */
712 if (spec->input_mux.num_items > 1) {
713 static snd_kcontrol_new_t cap_sel = {
714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
715 .name = "Capture Source",
716 .info = capture_source_info,
717 .get = capture_source_get,
718 .put = capture_source_put,
720 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&cap_sel, codec))) < 0)
722 spec->cur_cap_src = 0;
723 select_input_connection(codec, adc_node, spec->input_mux.items[0].index);
730 * parse the nodes recursively until reach to the output PIN.
732 * returns 0 - if not found,
733 * 1 - if found, but no mixer is created
734 * 2 - if found and mixer was already created, (just skip)
735 * a negative error code
737 static int parse_loopback_path(struct hda_codec *codec, struct hda_gspec *spec,
738 struct hda_gnode *node, struct hda_gnode *dest_node,
747 if (node == dest_node) {
748 /* loopback connection found */
752 for (i = 0; i < node->nconns; i++) {
753 struct hda_gnode *child = hda_get_node(spec, node->conn_list[i]);
756 err = parse_loopback_path(codec, spec, child, dest_node, type);
761 err = create_mixer(codec, node, i, type, "Playback");
765 return 2; /* ok, created */
766 /* not created, maybe in the lower path */
769 /* connect and unmute */
770 if (node->nconns > 1)
771 select_input_connection(codec, node, i);
772 unmute_input(codec, node, i);
773 unmute_output(codec, node);
781 * parse the tree and build the loopback controls
783 static int build_loopback_controls(struct hda_codec *codec)
785 struct hda_gspec *spec = codec->spec;
787 struct hda_gnode *node;
791 if (! spec->out_pin_node)
794 list_for_each(p, &spec->nid_list) {
795 node = list_entry(p, struct hda_gnode, list);
796 if (node->type != AC_WID_PIN)
799 if (! (node->pin_caps & AC_PINCAP_IN))
801 type = get_input_type(node, NULL);
803 if (check_existing_control(codec, type, "Playback"))
805 clear_check_flags(spec);
806 err = parse_loopback_path(codec, spec, spec->out_pin_node,
818 * build mixer controls
820 static int build_generic_controls(struct hda_codec *codec)
824 if ((err = build_input_controls(codec)) < 0 ||
825 (err = build_output_controls(codec)) < 0 ||
826 (err = build_loopback_controls(codec)) < 0)
835 static struct hda_pcm_stream generic_pcm_playback = {
841 static int build_generic_pcms(struct hda_codec *codec)
843 struct hda_gspec *spec = codec->spec;
844 struct hda_pcm *info = &spec->pcm_rec;
846 if (! spec->dac_node && ! spec->adc_node) {
847 snd_printd("hda_generic: no PCM found\n");
852 codec->pcm_info = info;
854 info->name = "HDA Generic";
855 if (spec->dac_node) {
856 info->stream[0] = generic_pcm_playback;
857 info->stream[0].nid = spec->dac_node->nid;
859 if (spec->adc_node) {
860 info->stream[1] = generic_pcm_playback;
861 info->stream[1].nid = spec->adc_node->nid;
870 static struct hda_codec_ops generic_patch_ops = {
871 .build_controls = build_generic_controls,
872 .build_pcms = build_generic_pcms,
873 .free = snd_hda_generic_free,
879 int snd_hda_parse_generic_codec(struct hda_codec *codec)
881 struct hda_gspec *spec;
884 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
886 printk(KERN_ERR "hda_generic: can't allocate spec\n");
890 INIT_LIST_HEAD(&spec->nid_list);
892 if ((err = build_afg_tree(codec)) < 0)
895 if ((err = parse_input(codec)) < 0 ||
896 (err = parse_output(codec)) < 0)
899 codec->patch_ops = generic_patch_ops;
904 snd_hda_generic_free(codec);