24
24
#define IDISP_VID_INTEL 0x80860000
25
25
26
26
/* 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 )
28
28
{
29
29
#ifdef MODULE
30
30
char alias [MODULE_NAME_LEN ];
31
- const char * module = alias ;
31
+ const char * mod = NULL ;
32
32
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" ;
36
37
#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 */
37
50
return device_attach (hda_codec_dev (codec ));
38
51
}
39
52
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
+
40
65
/* enable controller wake up event for all codecs with jack connectors */
41
66
void hda_codec_jack_wake_enable (struct snd_sof_dev * sdev )
42
67
{
@@ -78,6 +103,13 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev) {}
78
103
EXPORT_SYMBOL_NS (hda_codec_jack_wake_enable , SND_SOC_SOF_HDA_AUDIO_CODEC );
79
104
EXPORT_SYMBOL_NS (hda_codec_jack_check , SND_SOC_SOF_HDA_AUDIO_CODEC );
80
105
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
+
81
113
/* probe individual codec */
82
114
static int hda_codec_probe (struct snd_sof_dev * sdev , int address ,
83
115
bool hda_codec_use_common_hdmi )
@@ -87,6 +119,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
87
119
#endif
88
120
struct hda_bus * hbus = sof_to_hbus (sdev );
89
121
struct hdac_device * hdev ;
122
+ struct hda_codec * codec ;
90
123
u32 hda_cmd = (address << 28 ) | (AC_NODE_ROOT << 20 ) |
91
124
(AC_VERB_PARAMETERS << 8 ) | AC_PAR_VENDOR_ID ;
92
125
u32 resp = -1 ;
@@ -108,6 +141,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
108
141
109
142
hda_priv -> codec .bus = hbus ;
110
143
hdev = & hda_priv -> codec .core ;
144
+ codec = & hda_priv -> codec ;
111
145
112
146
ret = snd_hdac_ext_bus_device_init (& hbus -> core , address , hdev );
113
147
if (ret < 0 )
@@ -122,14 +156,19 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
122
156
hda_priv -> need_display_power = true;
123
157
}
124
158
159
+ if (is_generic_config (hbus ))
160
+ codec -> probe_id = HDA_CODEC_ID_GENERIC ;
161
+ else
162
+ codec -> probe_id = 0 ;
163
+
125
164
/*
126
165
* if common HDMI codec driver is not used, codec load
127
166
* is skipped here and hdac_hdmi is used instead
128
167
*/
129
168
if (hda_codec_use_common_hdmi ||
130
169
(resp & 0xFFFF0000 ) != IDISP_VID_INTEL ) {
131
170
hdev -> type = HDA_DEV_LEGACY ;
132
- ret = hda_codec_load_module (& hda_priv -> codec );
171
+ ret = hda_codec_load_module (codec );
133
172
/*
134
173
* handle ret==0 (no driver bound) as an error, but pass
135
174
* other return codes without modification
0 commit comments