Commit 2a9f683e authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman

ALSA: hda - Add static DAC/pin mapping for AD1986A codec

commit 3690739b upstream.

AD1986A codec is a pretty old codec and has really many hidden
restrictions.  One of such is that each DAC is dedicated to certain
pin although there are possible connections.  Currently, the generic
parser tries to assign individual DACs as much as possible, and this
lead to two bad situations: connections where the sound actually
doesn't work, and connections conflicting other channels.

We may fix this by trying to find the best connections more harder,
but as of now, it's easier to give some hints for paired DAC/pin
connections and honor them if available, since such a hint is needed
only for specific codecs (right now only AD1986A, and there will be
unlikely any others in future).

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64971
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=66621Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 44b8b7a7
...@@ -468,6 +468,20 @@ static void invalidate_nid_path(struct hda_codec *codec, int idx) ...@@ -468,6 +468,20 @@ static void invalidate_nid_path(struct hda_codec *codec, int idx)
memset(path, 0, sizeof(*path)); memset(path, 0, sizeof(*path));
} }
/* return a DAC if paired to the given pin by codec driver */
static hda_nid_t get_preferred_dac(struct hda_codec *codec, hda_nid_t pin)
{
struct hda_gen_spec *spec = codec->spec;
const hda_nid_t *list = spec->preferred_dacs;
if (!list)
return 0;
for (; *list; list += 2)
if (*list == pin)
return list[1];
return 0;
}
/* look for an empty DAC slot */ /* look for an empty DAC slot */
static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin, static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin,
bool is_digital) bool is_digital)
...@@ -1134,6 +1148,13 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs, ...@@ -1134,6 +1148,13 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
continue; continue;
} }
dacs[i] = get_preferred_dac(codec, pin);
if (dacs[i]) {
if (is_dac_already_used(codec, dacs[i]))
badness += bad->shared_primary;
}
if (!dacs[i])
dacs[i] = look_for_dac(codec, pin, false); dacs[i] = look_for_dac(codec, pin, false);
if (!dacs[i] && !i) { if (!dacs[i] && !i) {
/* try to steal the DAC of surrounds for the front */ /* try to steal the DAC of surrounds for the front */
......
...@@ -241,6 +241,9 @@ struct hda_gen_spec { ...@@ -241,6 +241,9 @@ struct hda_gen_spec {
const struct badness_table *main_out_badness; const struct badness_table *main_out_badness;
const struct badness_table *extra_out_badness; const struct badness_table *extra_out_badness;
/* preferred pin/DAC pairs; an array of paired NIDs */
const hda_nid_t *preferred_dacs;
/* loopback mixing mode */ /* loopback mixing mode */
bool aamix_mode; bool aamix_mode;
......
...@@ -1227,6 +1227,14 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec) ...@@ -1227,6 +1227,14 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec)
{ {
int err; int err;
struct ad198x_spec *spec; struct ad198x_spec *spec;
static hda_nid_t preferred_pairs[] = {
0x1a, 0x03,
0x1b, 0x03,
0x1c, 0x04,
0x1d, 0x05,
0x1e, 0x03,
0
};
err = alloc_ad_spec(codec); err = alloc_ad_spec(codec);
if (err < 0) if (err < 0)
...@@ -1247,6 +1255,8 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec) ...@@ -1247,6 +1255,8 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec)
* So, let's disable the shared stream. * So, let's disable the shared stream.
*/ */
spec->gen.multiout.no_share_stream = 1; spec->gen.multiout.no_share_stream = 1;
/* give fixed DAC/pin pairs */
spec->gen.preferred_dacs = preferred_pairs;
snd_hda_pick_fixup(codec, NULL, ad1986a_fixup_tbl, ad1986a_fixups); snd_hda_pick_fixup(codec, NULL, ad1986a_fixup_tbl, ad1986a_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment