Skip to content

Commit 89d73cc

Browse files
kv2019ibroonie
authored andcommitted
ASoC: SOF: Intel: hda: fix generic hda codec support
Add support for using generic codec driver with SOF. Generic driver is used if: - snd_sof_intel_hda_common.hda_model="generic" is set, or - fallback if no other codec driver is found The implementation is aligned with snd-hda-intel driver, and fixes audio support for systems like Acer Swift 3 SF314-57G, on which this issue was originally reported. Signed-off-by: Kai Vehmanen <[email protected]> Reviewed-by: Hui Wang <[email protected]> Reviewed-by: Guennadi Liakhovetski <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> BugLink: thesofproject#1807 BugLink: https://bugs.launchpad.net/bugs/1877757 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent af89e7d commit 89d73cc

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

sound/soc/sof/intel/hda-codec.c

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,44 @@
2424
#define IDISP_VID_INTEL 0x80860000
2525

2626
/* load the legacy HDA codec driver */
27-
static int hda_codec_load_module(struct hda_codec *codec)
27+
static int request_codec_module(struct hda_codec *codec)
2828
{
2929
#ifdef MODULE
3030
char alias[MODULE_NAME_LEN];
31-
const char *module = alias;
31+
const char *mod = NULL;
3232

33-
snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias));
34-
dev_dbg(&codec->core.dev, "loading codec module: %s\n", module);
35-
request_module(module);
33+
switch (codec->probe_id) {
34+
case HDA_CODEC_ID_GENERIC:
35+
#if IS_MODULE(CONFIG_SND_HDA_GENERIC)
36+
mod = "snd-hda-codec-generic";
3637
#endif
38+
break;
39+
default:
40+
snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias));
41+
mod = alias;
42+
break;
43+
}
44+
45+
if (mod) {
46+
dev_dbg(&codec->core.dev, "loading codec module: %s\n", mod);
47+
request_module(mod);
48+
}
49+
#endif /* MODULE */
3750
return device_attach(hda_codec_dev(codec));
3851
}
3952

53+
static int hda_codec_load_module(struct hda_codec *codec)
54+
{
55+
int ret = request_codec_module(codec);
56+
57+
if (ret <= 0) {
58+
codec->probe_id = HDA_CODEC_ID_GENERIC;
59+
ret = request_codec_module(codec);
60+
}
61+
62+
return ret;
63+
}
64+
4065
/* enable controller wake up event for all codecs with jack connectors */
4166
void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev)
4267
{
@@ -78,6 +103,13 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev) {}
78103
EXPORT_SYMBOL_NS(hda_codec_jack_wake_enable, SND_SOC_SOF_HDA_AUDIO_CODEC);
79104
EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC);
80105

106+
#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
107+
#define is_generic_config(bus) \
108+
((bus)->modelname && !strcmp((bus)->modelname, "generic"))
109+
#else
110+
#define is_generic_config(x) 0
111+
#endif
112+
81113
/* probe individual codec */
82114
static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
83115
bool hda_codec_use_common_hdmi)
@@ -87,6 +119,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
87119
#endif
88120
struct hda_bus *hbus = sof_to_hbus(sdev);
89121
struct hdac_device *hdev;
122+
struct hda_codec *codec;
90123
u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
91124
(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
92125
u32 resp = -1;
@@ -108,6 +141,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
108141

109142
hda_priv->codec.bus = hbus;
110143
hdev = &hda_priv->codec.core;
144+
codec = &hda_priv->codec;
111145

112146
ret = snd_hdac_ext_bus_device_init(&hbus->core, address, hdev);
113147
if (ret < 0)
@@ -122,14 +156,19 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
122156
hda_priv->need_display_power = true;
123157
}
124158

159+
if (is_generic_config(hbus))
160+
codec->probe_id = HDA_CODEC_ID_GENERIC;
161+
else
162+
codec->probe_id = 0;
163+
125164
/*
126165
* if common HDMI codec driver is not used, codec load
127166
* is skipped here and hdac_hdmi is used instead
128167
*/
129168
if (hda_codec_use_common_hdmi ||
130169
(resp & 0xFFFF0000) != IDISP_VID_INTEL) {
131170
hdev->type = HDA_DEV_LEGACY;
132-
ret = hda_codec_load_module(&hda_priv->codec);
171+
ret = hda_codec_load_module(codec);
133172
/*
134173
* handle ret==0 (no driver bound) as an error, but pass
135174
* other return codes without modification

0 commit comments

Comments
 (0)