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 */
36 hda_nid_t slist[2]; /* temporay list */
37 unsigned int wid_caps; /* widget capabilities */
38 unsigned char type; /* widget type */
39 unsigned char pin_ctl; /* pin controls */
40 unsigned char checked; /* the flag indicates that the node is already parsed */
41 unsigned int pin_caps; /* pin widget capabilities */
42 unsigned int def_cfg; /* default configuration */
43 unsigned int amp_out_caps; /* AMP out capabilities */
44 unsigned int amp_in_caps; /* AMP in capabilities */
45 struct list_head list;
48 /* patch-specific record */
50 struct hda_gnode *dac_node; /* DAC node */
51 struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */
52 struct hda_gnode *pcm_vol_node; /* Node for PCM volume */
53 unsigned int pcm_vol_index; /* connection of PCM volume */
55 struct hda_gnode *adc_node; /* ADC node */
56 struct hda_gnode *cap_vol_node; /* Node for capture volume */
57 unsigned int cur_cap_src; /* current capture source */
58 struct hda_input_mux input_mux;
59 char cap_labels[HDA_MAX_NUM_INPUTS][16];
61 unsigned int def_amp_in_caps;
62 unsigned int def_amp_out_caps;
64 struct hda_pcm pcm_rec; /* PCM information */
66 struct list_head nid_list; /* list of widgets */
70 * retrieve the default device type from the default config value
72 #define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
73 #define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
78 static void snd_hda_generic_free(struct hda_codec *codec)
80 struct hda_gspec *spec = codec->spec;
81 struct list_head *p, *n;
85 /* free all widgets */
86 list_for_each_safe(p, n, &spec->nid_list) {
87 struct hda_gnode *node = list_entry(p, struct hda_gnode, list);
88 if (node->conn_list != node->slist)
89 kfree(node->conn_list);
97 * add a new widget node and read its attributes
99 static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid_t nid)
101 struct hda_gnode *node;
103 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
105 node = kzalloc(sizeof(*node), GFP_KERNEL);
109 nconns = snd_hda_get_connections(codec, nid, conn_list,
110 HDA_MAX_CONNECTIONS);
115 if (nconns <= ARRAY_SIZE(node->slist))
116 node->conn_list = node->slist;
118 node->conn_list = kmalloc(sizeof(hda_nid_t) * nconns,
120 if (! node->conn_list) {
121 snd_printk(KERN_ERR "hda-generic: cannot malloc\n");
126 memcpy(node->conn_list, conn_list, nconns);
127 node->nconns = nconns;
128 node->wid_caps = get_wcaps(codec, nid);
129 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
131 if (node->type == AC_WID_PIN) {
132 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP);
133 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
134 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
137 if (node->wid_caps & AC_WCAP_OUT_AMP) {
138 if (node->wid_caps & AC_WCAP_AMP_OVRD)
139 node->amp_out_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_OUT_CAP);
140 if (! node->amp_out_caps)
141 node->amp_out_caps = spec->def_amp_out_caps;
143 if (node->wid_caps & AC_WCAP_IN_AMP) {
144 if (node->wid_caps & AC_WCAP_AMP_OVRD)
145 node->amp_in_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_IN_CAP);
146 if (! node->amp_in_caps)
147 node->amp_in_caps = spec->def_amp_in_caps;
149 list_add_tail(&node->list, &spec->nid_list);
154 * build the AFG subtree
156 static int build_afg_tree(struct hda_codec *codec)
158 struct hda_gspec *spec = codec->spec;
162 snd_assert(spec, return -EINVAL);
164 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP);
165 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP);
167 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
168 if (! nid || nodes < 0) {
169 printk(KERN_ERR "Invalid AFG subtree\n");
173 /* parse all nodes belonging to the AFG */
174 for (i = 0; i < nodes; i++, nid++) {
175 if ((err = add_new_node(codec, spec, nid)) < 0)
184 * look for the node record for the given NID
186 /* FIXME: should avoid the braindead linear search */
187 static struct hda_gnode *hda_get_node(struct hda_gspec *spec, hda_nid_t nid)
190 struct hda_gnode *node;
192 list_for_each(p, &spec->nid_list) {
193 node = list_entry(p, struct hda_gnode, list);
194 if (node->nid == nid)
201 * unmute (and set max vol) the output amplifier
203 static int unmute_output(struct hda_codec *codec, struct hda_gnode *node)
205 unsigned int val, ofs;
206 snd_printdd("UNMUTE OUT: NID=0x%x\n", node->nid);
207 val = (node->amp_out_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
208 ofs = (node->amp_out_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
211 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;
212 val |= AC_AMP_SET_OUTPUT;
213 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val);
217 * unmute (and set max vol) the input amplifier
219 static int unmute_input(struct hda_codec *codec, struct hda_gnode *node, unsigned int index)
221 unsigned int val, ofs;
222 snd_printdd("UNMUTE IN: NID=0x%x IDX=0x%x\n", node->nid, index);
223 val = (node->amp_in_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
224 ofs = (node->amp_in_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
227 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;
228 val |= AC_AMP_SET_INPUT;
229 // awk added - fixed to allow unmuting of indexed amps
230 val |= index << AC_AMP_SET_INDEX_SHIFT;
231 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val);
235 * select the input connection of the given node.
237 static int select_input_connection(struct hda_codec *codec, struct hda_gnode *node,
240 snd_printdd("CONNECT: NID=0x%x IDX=0x%x\n", node->nid, index);
241 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_CONNECT_SEL, index);
245 * clear checked flag of each node in the node list
247 static void clear_check_flags(struct hda_gspec *spec)
250 struct hda_gnode *node;
252 list_for_each(p, &spec->nid_list) {
253 node = list_entry(p, struct hda_gnode, list);
259 * parse the output path recursively until reach to an audio output widget
261 * returns 0 if not found, 1 if found, or a negative error code.
263 static int parse_output_path(struct hda_codec *codec, struct hda_gspec *spec,
264 struct hda_gnode *node)
267 struct hda_gnode *child;
273 if (node->type == AC_WID_AUD_OUT) {
274 if (node->wid_caps & AC_WCAP_DIGITAL) {
275 snd_printdd("Skip Digital OUT node %x\n", node->nid);
278 snd_printdd("AUD_OUT found %x\n", node->nid);
279 if (spec->dac_node) {
280 /* already DAC node is assigned, just unmute & connect */
281 return node == spec->dac_node;
283 spec->dac_node = node;
284 if (node->wid_caps & AC_WCAP_OUT_AMP) {
285 spec->pcm_vol_node = node;
286 spec->pcm_vol_index = 0;
288 return 1; /* found */
291 for (i = 0; i < node->nconns; i++) {
292 child = hda_get_node(spec, node->conn_list[i]);
295 err = parse_output_path(codec, spec, child);
300 * select the path, unmute both input and output
302 if (node->nconns > 1)
303 select_input_connection(codec, node, i);
304 unmute_input(codec, node, i);
305 unmute_output(codec, node);
306 if (! spec->pcm_vol_node) {
307 if (node->wid_caps & AC_WCAP_IN_AMP) {
308 spec->pcm_vol_node = node;
309 spec->pcm_vol_index = i;
310 } else if (node->wid_caps & AC_WCAP_OUT_AMP) {
311 spec->pcm_vol_node = node;
312 spec->pcm_vol_index = 0;
322 * Look for the output PIN widget with the given jack type
323 * and parse the output path to that PIN.
325 * Returns the PIN node when the path to DAC is established.
327 static struct hda_gnode *parse_output_jack(struct hda_codec *codec,
328 struct hda_gspec *spec,
332 struct hda_gnode *node;
335 list_for_each(p, &spec->nid_list) {
336 node = list_entry(p, struct hda_gnode, list);
337 if (node->type != AC_WID_PIN)
339 /* output capable? */
340 if (! (node->pin_caps & AC_PINCAP_OUT))
342 if (jack_type >= 0) {
343 if (jack_type != defcfg_type(node))
345 if (node->wid_caps & AC_WCAP_DIGITAL)
346 continue; /* skip SPDIF */
348 /* output as default? */
349 if (! (node->pin_ctl & AC_PINCTL_OUT_EN))
352 clear_check_flags(spec);
353 err = parse_output_path(codec, spec, node);
357 /* unmute the PIN output */
358 unmute_output(codec, node);
359 /* set PIN-Out enable */
360 snd_hda_codec_write(codec, node->nid, 0,
361 AC_VERB_SET_PIN_WIDGET_CONTROL,
362 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
373 static int parse_output(struct hda_codec *codec)
375 struct hda_gspec *spec = codec->spec;
376 struct hda_gnode *node;
379 * Look for the output PIN widget
381 /* first, look for the line-out pin */
382 node = parse_output_jack(codec, spec, AC_JACK_LINE_OUT);
383 if (node) /* found, remember the PIN node */
384 spec->out_pin_node = node;
385 /* look for the HP-out pin */
386 node = parse_output_jack(codec, spec, AC_JACK_HP_OUT);
388 if (! spec->out_pin_node)
389 spec->out_pin_node = node;
392 if (! spec->out_pin_node) {
393 /* no line-out or HP pins found,
394 * then choose for the first output pin
396 spec->out_pin_node = parse_output_jack(codec, spec, -1);
397 if (! spec->out_pin_node)
398 snd_printd("hda_generic: no proper output path found\n");
408 /* control callbacks */
409 static int capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
412 struct hda_gspec *spec = codec->spec;
413 return snd_hda_input_mux_info(&spec->input_mux, uinfo);
416 static int capture_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
419 struct hda_gspec *spec = codec->spec;
421 ucontrol->value.enumerated.item[0] = spec->cur_cap_src;
425 static int capture_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct hda_gspec *spec = codec->spec;
429 return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol,
430 spec->adc_node->nid, &spec->cur_cap_src);
434 * return the string name of the given input PIN widget
436 static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl)
438 unsigned int location = defcfg_location(node);
439 switch (defcfg_type(node)) {
440 case AC_JACK_LINE_IN:
441 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
446 *pinctl |= AC_PINCTL_VREF_GRD;
449 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
453 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
456 case AC_JACK_SPDIF_IN:
458 case AC_JACK_DIG_OTHER_IN:
465 * parse the nodes recursively until reach to the input PIN
467 * returns 0 if not found, 1 if found, or a negative error code.
469 static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
470 struct hda_gnode *node)
481 if (node->type != AC_WID_PIN) {
482 for (i = 0; i < node->nconns; i++) {
483 struct hda_gnode *child;
484 child = hda_get_node(spec, node->conn_list[i]);
487 err = parse_adc_sub_nodes(codec, spec, child);
492 * select the path, unmute both input and output
494 if (node->nconns > 1)
495 select_input_connection(codec, node, i);
496 unmute_input(codec, node, i);
497 unmute_output(codec, node);
505 if (! (node->pin_caps & AC_PINCAP_IN))
508 if (node->wid_caps & AC_WCAP_DIGITAL)
509 return 0; /* skip SPDIF */
511 if (spec->input_mux.num_items >= HDA_MAX_NUM_INPUTS) {
512 snd_printk(KERN_ERR "hda_generic: Too many items for capture\n");
516 pinctl = AC_PINCTL_IN_EN;
517 /* create a proper capture source label */
518 type = get_input_type(node, &pinctl);
520 /* input as default? */
521 if (! (node->pin_ctl & AC_PINCTL_IN_EN))
525 label = spec->cap_labels[spec->input_mux.num_items];
527 spec->input_mux.items[spec->input_mux.num_items].label = label;
529 /* unmute the PIN external input */
530 unmute_input(codec, node, 0); /* index = 0? */
531 /* set PIN-In enable */
532 snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
534 return 1; /* found */
540 static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node)
542 struct hda_gspec *spec = codec->spec;
543 struct hda_gnode *node;
546 snd_printdd("AUD_IN = %x\n", adc_node->nid);
547 clear_check_flags(spec);
549 // awk added - fixed no recording due to muted widget
550 unmute_input(codec, adc_node, 0);
553 * check each connection of the ADC
554 * if it reaches to a proper input PIN, add the path as the
557 for (i = 0; i < adc_node->nconns; i++) {
558 node = hda_get_node(spec, adc_node->conn_list[i]);
561 err = parse_adc_sub_nodes(codec, spec, node);
565 struct hda_input_mux_item *csrc = &spec->input_mux.items[spec->input_mux.num_items];
566 char *buf = spec->cap_labels[spec->input_mux.num_items];
568 for (ocap = 0; ocap < spec->input_mux.num_items; ocap++) {
569 if (! strcmp(buf, spec->cap_labels[ocap])) {
570 /* same label already exists,
571 * put the index number to be unique
573 sprintf(buf, "%s %d", spec->cap_labels[ocap],
574 spec->input_mux.num_items);
578 spec->input_mux.num_items++;
582 if (! spec->input_mux.num_items)
583 return 0; /* no input path found... */
585 snd_printdd("[Capture Source] NID=0x%x, #SRC=%d\n", adc_node->nid, spec->input_mux.num_items);
586 for (i = 0; i < spec->input_mux.num_items; i++)
587 snd_printdd(" [%s] IDX=0x%x\n", spec->input_mux.items[i].label,
588 spec->input_mux.items[i].index);
590 spec->adc_node = adc_node;
597 static int parse_input(struct hda_codec *codec)
599 struct hda_gspec *spec = codec->spec;
601 struct hda_gnode *node;
605 * At first we look for an audio input widget.
606 * If it reaches to certain input PINs, we take it as the
609 list_for_each(p, &spec->nid_list) {
610 node = list_entry(p, struct hda_gnode, list);
611 if (node->wid_caps & AC_WCAP_DIGITAL)
612 continue; /* skip SPDIF */
613 if (node->type == AC_WID_AUD_IN) {
614 err = parse_input_path(codec, node);
621 snd_printd("hda_generic: no proper input path found\n");
626 * create mixer controls if possible
631 static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
632 unsigned int index, const char *type, const char *dir_sfx)
637 struct snd_kcontrol_new knew;
640 sprintf(name, "%s %s Switch", type, dir_sfx);
642 sprintf(name, "%s Switch", dir_sfx);
643 if ((node->wid_caps & AC_WCAP_IN_AMP) &&
644 (node->amp_in_caps & AC_AMPCAP_MUTE)) {
645 knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT);
646 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
647 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
650 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
651 (node->amp_out_caps & AC_AMPCAP_MUTE)) {
652 knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT);
653 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
654 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
660 sprintf(name, "%s %s Volume", type, dir_sfx);
662 sprintf(name, "%s Volume", dir_sfx);
663 if ((node->wid_caps & AC_WCAP_IN_AMP) &&
664 (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) {
665 knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT);
666 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
667 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
670 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
671 (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) {
672 knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);
673 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
674 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
683 * check whether the controls with the given name and direction suffix already exist
685 static int check_existing_control(struct hda_codec *codec, const char *type, const char *dir)
687 struct snd_ctl_elem_id id;
688 memset(&id, 0, sizeof(id));
689 sprintf(id.name, "%s %s Volume", type, dir);
690 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
691 if (snd_ctl_find_id(codec->bus->card, &id))
693 sprintf(id.name, "%s %s Switch", type, dir);
694 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
695 if (snd_ctl_find_id(codec->bus->card, &id))
701 * build output mixer controls
703 static int build_output_controls(struct hda_codec *codec)
705 struct hda_gspec *spec = codec->spec;
708 err = create_mixer(codec, spec->pcm_vol_node, spec->pcm_vol_index,
715 /* create capture volume/switch */
716 static int build_input_controls(struct hda_codec *codec)
718 struct hda_gspec *spec = codec->spec;
719 struct hda_gnode *adc_node = spec->adc_node;
723 return 0; /* not found */
725 /* create capture volume and switch controls if the ADC has an amp */
726 err = create_mixer(codec, adc_node, 0, NULL, "Capture");
728 /* create input MUX if multiple sources are available */
729 if (spec->input_mux.num_items > 1) {
730 static struct snd_kcontrol_new cap_sel = {
731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
732 .name = "Capture Source",
733 .info = capture_source_info,
734 .get = capture_source_get,
735 .put = capture_source_put,
737 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&cap_sel, codec))) < 0)
739 spec->cur_cap_src = 0;
740 select_input_connection(codec, adc_node, spec->input_mux.items[0].index);
747 * parse the nodes recursively until reach to the output PIN.
749 * returns 0 - if not found,
750 * 1 - if found, but no mixer is created
751 * 2 - if found and mixer was already created, (just skip)
752 * a negative error code
754 static int parse_loopback_path(struct hda_codec *codec, struct hda_gspec *spec,
755 struct hda_gnode *node, struct hda_gnode *dest_node,
764 if (node == dest_node) {
765 /* loopback connection found */
769 for (i = 0; i < node->nconns; i++) {
770 struct hda_gnode *child = hda_get_node(spec, node->conn_list[i]);
773 err = parse_loopback_path(codec, spec, child, dest_node, type);
778 err = create_mixer(codec, node, i, type, "Playback");
782 return 2; /* ok, created */
783 /* not created, maybe in the lower path */
786 /* connect and unmute */
787 if (node->nconns > 1)
788 select_input_connection(codec, node, i);
789 unmute_input(codec, node, i);
790 unmute_output(codec, node);
798 * parse the tree and build the loopback controls
800 static int build_loopback_controls(struct hda_codec *codec)
802 struct hda_gspec *spec = codec->spec;
804 struct hda_gnode *node;
808 if (! spec->out_pin_node)
811 list_for_each(p, &spec->nid_list) {
812 node = list_entry(p, struct hda_gnode, list);
813 if (node->type != AC_WID_PIN)
816 if (! (node->pin_caps & AC_PINCAP_IN))
818 type = get_input_type(node, NULL);
820 if (check_existing_control(codec, type, "Playback"))
822 clear_check_flags(spec);
823 err = parse_loopback_path(codec, spec, spec->out_pin_node,
835 * build mixer controls
837 static int build_generic_controls(struct hda_codec *codec)
841 if ((err = build_input_controls(codec)) < 0 ||
842 (err = build_output_controls(codec)) < 0 ||
843 (err = build_loopback_controls(codec)) < 0)
852 static struct hda_pcm_stream generic_pcm_playback = {
858 static int build_generic_pcms(struct hda_codec *codec)
860 struct hda_gspec *spec = codec->spec;
861 struct hda_pcm *info = &spec->pcm_rec;
863 if (! spec->dac_node && ! spec->adc_node) {
864 snd_printd("hda_generic: no PCM found\n");
869 codec->pcm_info = info;
871 info->name = "HDA Generic";
872 if (spec->dac_node) {
873 info->stream[0] = generic_pcm_playback;
874 info->stream[0].nid = spec->dac_node->nid;
876 if (spec->adc_node) {
877 info->stream[1] = generic_pcm_playback;
878 info->stream[1].nid = spec->adc_node->nid;
887 static struct hda_codec_ops generic_patch_ops = {
888 .build_controls = build_generic_controls,
889 .build_pcms = build_generic_pcms,
890 .free = snd_hda_generic_free,
896 int snd_hda_parse_generic_codec(struct hda_codec *codec)
898 struct hda_gspec *spec;
904 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
906 printk(KERN_ERR "hda_generic: can't allocate spec\n");
910 INIT_LIST_HEAD(&spec->nid_list);
912 if ((err = build_afg_tree(codec)) < 0)
915 if ((err = parse_input(codec)) < 0 ||
916 (err = parse_output(codec)) < 0)
919 codec->patch_ops = generic_patch_ops;
924 snd_hda_generic_free(codec);