From: Takashi Iwai Date: Wed, 12 Dec 2012 17:02:41 +0000 (+0100) Subject: ALSA: hda/realtek - Parse analog loopback paths more generically X-Git-Tag: v3.9-rc1~52^2~77^2~182 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2fd19c2fc3cc5e609c573f3c66711fd809f9d3c;p=platform%2Fkernel%2Flinux-exynos.git ALSA: hda/realtek - Parse analog loopback paths more generically Improve the parser of analog loopback paths and handle in a more generic way. The following changes are included in this patch: - Instead of assuming direct connections between pins and the mixer widget, track the whole path between them. This fixes some missing connections like ALC660. - Introduce the path list for loopback paths like input and output path lists. Currently it's not used for any real purposes, yet. Signed-off-by: Takashi Iwai --- diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index fbc4a97..8ce0a0d 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -203,6 +203,9 @@ struct alc_spec { /* input paths */ struct snd_array in_path; + /* analog loopback paths */ + struct snd_array loopback_path; + /* hooks */ void (*init_hook)(struct hda_codec *codec); #ifdef CONFIG_PM @@ -2436,6 +2439,7 @@ static void alc_free(struct hda_codec *codec) alc_free_bind_ctls(codec); snd_array_free(&spec->out_path); snd_array_free(&spec->in_path); + snd_array_free(&spec->loopback_path); snd_hda_gen_free(&spec->gen); kfree(spec); snd_hda_detach_beep_device(codec); @@ -2660,12 +2664,22 @@ static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) #endif /* create input playback/capture controls for the given pin */ -static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, +static int new_analog_input(struct hda_codec *codec, hda_nid_t pin, const char *ctlname, int ctlidx, - int idx, hda_nid_t mix_nid) + hda_nid_t mix_nid) { - int err; + struct alc_spec *spec = codec->spec; + struct nid_path *path; + int err, idx; + + path = snd_array_new(&spec->loopback_path); + if (!path) + return -ENOMEM; + memset(path, 0, sizeof(*path)); + if (!parse_nid_path(codec, pin, mix_nid, 2, path)) + return -EINVAL; + idx = path->idx[path->depth - 1]; err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); if (err < 0) @@ -2706,6 +2720,15 @@ static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) return (pincap & AC_PINCAP_IN) != 0; } +/* check whether the given two widgets can be connected */ +static bool is_reachable_path(struct hda_codec *codec, + hda_nid_t from_nid, hda_nid_t to_nid) +{ + if (!from_nid || !to_nid) + return false; + return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; +} + /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ static int alc_auto_fill_adc_caps(struct hda_codec *codec) { @@ -2787,11 +2810,9 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec) prev_label = label; if (mixer) { - idx = get_connection_index(codec, mixer, pin); - if (idx >= 0) { - err = new_analog_input(spec, pin, - label, type_idx, - idx, mixer); + if (is_reachable_path(codec, pin, mixer)) { + err = new_analog_input(codec, pin, + label, type_idx, mixer); if (err < 0) return err; } @@ -4572,6 +4593,7 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); snd_array_init(&spec->out_path, sizeof(struct nid_path), 8); snd_array_init(&spec->in_path, sizeof(struct nid_path), 8); + snd_array_init(&spec->loopback_path, sizeof(struct nid_path), 8); err = alc_codec_rename_from_preset(codec); if (err < 0) {