Skip to content

Commit fe070ad

Browse files
tiwaigregkh
authored andcommitted
ALSA: hda - Check leaf nodes to find aamix amps
commit 2ded3e5 upstream. The current generic parser assumes blindly that the volume and mute amps are found in the aamix node itself. But on some codecs, typically Analog Devices ones, the aamix amps are separately implemented in each leaf node of the aamix node, and the current driver can't establish the correct amp controls. This is a regression compared with the previous static quirks. This patch extends the search for the amps to the leaf nodes for allowing the aamix controls again on such codecs. In this implementation, I didn't code to loop through the whole paths, since usually one depth should suffice, and we can't search too deeply, as it may result in the conflicting control assignments. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=65641 Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7f9bf8a commit fe070ad

1 file changed

Lines changed: 45 additions & 12 deletions

File tree

‎sound/pci/hda/hda_generic.c‎

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,19 +2747,54 @@ static int add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx)
27472747
return 0;
27482748
}
27492749

2750+
/* return true if either a volume or a mute amp is found for the given
2751+
* aamix path; the amp has to be either in the mixer node or its direct leaf
2752+
*/
2753+
static bool look_for_mix_leaf_ctls(struct hda_codec *codec, hda_nid_t mix_nid,
2754+
hda_nid_t pin, unsigned int *mix_val,
2755+
unsigned int *mute_val)
2756+
{
2757+
int idx, num_conns;
2758+
const hda_nid_t *list;
2759+
hda_nid_t nid;
2760+
2761+
idx = snd_hda_get_conn_index(codec, mix_nid, pin, true);
2762+
if (idx < 0)
2763+
return false;
2764+
2765+
*mix_val = *mute_val = 0;
2766+
if (nid_has_volume(codec, mix_nid, HDA_INPUT))
2767+
*mix_val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
2768+
if (nid_has_mute(codec, mix_nid, HDA_INPUT))
2769+
*mute_val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
2770+
if (*mix_val && *mute_val)
2771+
return true;
2772+
2773+
/* check leaf node */
2774+
num_conns = snd_hda_get_conn_list(codec, mix_nid, &list);
2775+
if (num_conns < idx)
2776+
return false;
2777+
nid = list[idx];
2778+
if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT))
2779+
*mix_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2780+
if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT))
2781+
*mute_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2782+
2783+
return *mix_val || *mute_val;
2784+
}
2785+
27502786
/* create input playback/capture controls for the given pin */
27512787
static int new_analog_input(struct hda_codec *codec, int input_idx,
27522788
hda_nid_t pin, const char *ctlname, int ctlidx,
27532789
hda_nid_t mix_nid)
27542790
{
27552791
struct hda_gen_spec *spec = codec->spec;
27562792
struct nid_path *path;
2757-
unsigned int val;
2793+
unsigned int mix_val, mute_val;
27582794
int err, idx;
27592795

2760-
if (!nid_has_volume(codec, mix_nid, HDA_INPUT) &&
2761-
!nid_has_mute(codec, mix_nid, HDA_INPUT))
2762-
return 0; /* no need for analog loopback */
2796+
if (!look_for_mix_leaf_ctls(codec, mix_nid, pin, &mix_val, &mute_val))
2797+
return 0;
27632798

27642799
path = snd_hda_add_new_path(codec, pin, mix_nid, 0);
27652800
if (!path)
@@ -2768,20 +2803,18 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
27682803
spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path);
27692804

27702805
idx = path->idx[path->depth - 1];
2771-
if (nid_has_volume(codec, mix_nid, HDA_INPUT)) {
2772-
val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
2773-
err = __add_pb_vol_ctrl(spec, HDA_CTL_WIDGET_VOL, ctlname, ctlidx, val);
2806+
if (mix_val) {
2807+
err = __add_pb_vol_ctrl(spec, HDA_CTL_WIDGET_VOL, ctlname, ctlidx, mix_val);
27742808
if (err < 0)
27752809
return err;
2776-
path->ctls[NID_PATH_VOL_CTL] = val;
2810+
path->ctls[NID_PATH_VOL_CTL] = mix_val;
27772811
}
27782812

2779-
if (nid_has_mute(codec, mix_nid, HDA_INPUT)) {
2780-
val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
2781-
err = __add_pb_sw_ctrl(spec, HDA_CTL_WIDGET_MUTE, ctlname, ctlidx, val);
2813+
if (mute_val) {
2814+
err = __add_pb_sw_ctrl(spec, HDA_CTL_WIDGET_MUTE, ctlname, ctlidx, mute_val);
27822815
if (err < 0)
27832816
return err;
2784-
path->ctls[NID_PATH_MUTE_CTL] = val;
2817+
path->ctls[NID_PATH_MUTE_CTL] = mute_val;
27852818
}
27862819

27872820
path->active = true;

0 commit comments

Comments
 (0)