Skip to content

Commit ad781b5

Browse files
committed
ALSA: hda/hdmi: Rewrite to new probe method
Convert the HDMI codec drivers to use the new hda_codec_ops probe. The Intel and Nvidia-MCP HDMI drivers needed slightly more changes to deal with the unified callbacks among all models. Also another non-trivial change is Intel driver's set_power_state callback. An additional NULL check of codec->spec is needed there since the set_power_state() may be called before the probe gets called (e.g. in ASoC hda codec hda_codec_probe()). Other than that, no functional changes. Signed-off-by: Takashi Iwai <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 6cce081 commit ad781b5

File tree

8 files changed

+422
-336
lines changed

8 files changed

+422
-336
lines changed

sound/hda/codecs/hdmi/atihdmi.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,19 +528,16 @@ static const struct drm_audio_component_audio_ops atihdmi_audio_ops = {
528528
.master_unbind = snd_hda_hdmi_acomp_master_unbind,
529529
};
530530

531-
static int patch_atihdmi(struct hda_codec *codec)
531+
static int atihdmi_probe(struct hda_codec *codec, const struct hda_device_id *id)
532532
{
533533
struct hdmi_spec *spec;
534534
struct hdmi_spec_per_cvt *per_cvt;
535535
int err, cvt_idx;
536536

537-
err = patch_generic_hdmi(codec);
538-
537+
err = snd_hda_hdmi_generic_probe(codec);
539538
if (err)
540539
return err;
541540

542-
codec->patch_ops.init = atihdmi_init;
543-
544541
spec = codec->spec;
545542

546543
spec->static_pcm_mapping = true;
@@ -583,15 +580,26 @@ static int patch_atihdmi(struct hda_codec *codec)
583580
return 0;
584581
}
585582

583+
static const struct hda_codec_ops atihdmi_codec_ops = {
584+
.probe = atihdmi_probe,
585+
.remove = snd_hda_hdmi_generic_remove,
586+
.init = atihdmi_init,
587+
.build_pcms = snd_hda_hdmi_generic_build_pcms,
588+
.build_controls = snd_hda_hdmi_generic_build_controls,
589+
.unsol_event = snd_hda_hdmi_generic_unsol_event,
590+
.suspend = snd_hda_hdmi_generic_suspend,
591+
.resume = snd_hda_hdmi_generic_resume,
592+
};
593+
586594
/*
587-
* patch entries
595+
* driver entries
588596
*/
589597
static const struct hda_device_id snd_hda_id_atihdmi[] = {
590-
HDA_CODEC_ENTRY(0x1002793c, "RS600 HDMI", patch_atihdmi),
591-
HDA_CODEC_ENTRY(0x10027919, "RS600 HDMI", patch_atihdmi),
592-
HDA_CODEC_ENTRY(0x1002791a, "RS690/780 HDMI", patch_atihdmi),
593-
HDA_CODEC_ENTRY(0x1002aa01, "R6xx HDMI", patch_atihdmi),
594-
{} /* terminator */
598+
HDA_CODEC_ID(0x1002793c, "RS600 HDMI"),
599+
HDA_CODEC_ID(0x10027919, "RS600 HDMI"),
600+
HDA_CODEC_ID(0x1002791a, "RS690/780 HDMI"),
601+
HDA_CODEC_ID(0x1002aa01, "R6xx HDMI"),
602+
{} /* terminator */
595603
};
596604
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_atihdmi);
597605

@@ -601,6 +609,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_HDMI");
601609

602610
static struct hda_codec_driver atihdmi_driver = {
603611
.id = snd_hda_id_atihdmi,
612+
.ops = &atihdmi_codec_ops,
604613
};
605614

606615
module_hda_codec_driver(atihdmi_driver);

sound/hda/codecs/hdmi/hdmi.c

Lines changed: 66 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ void snd_hda_hdmi_generic_spec_free(struct hda_codec *codec)
20872087
}
20882088
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_generic_spec_free, "SND_HDA_CODEC_HDMI");
20892089

2090-
void snd_hda_hdmi_generic_free(struct hda_codec *codec)
2090+
void snd_hda_hdmi_generic_remove(struct hda_codec *codec)
20912091
{
20922092
struct hdmi_spec *spec = codec->spec;
20932093
int pin_idx, pcm_idx;
@@ -2113,7 +2113,7 @@ void snd_hda_hdmi_generic_free(struct hda_codec *codec)
21132113

21142114
snd_hda_hdmi_generic_spec_free(codec);
21152115
}
2116-
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_generic_free, "SND_HDA_CODEC_HDMI");
2116+
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_generic_remove, "SND_HDA_CODEC_HDMI");
21172117

21182118
int snd_hda_hdmi_generic_suspend(struct hda_codec *codec)
21192119
{
@@ -2133,7 +2133,7 @@ int snd_hda_hdmi_generic_resume(struct hda_codec *codec)
21332133
struct hdmi_spec *spec = codec->spec;
21342134
int pin_idx;
21352135

2136-
codec->patch_ops.init(codec);
2136+
snd_hda_codec_init(codec);
21372137
snd_hda_regmap_sync(codec);
21382138

21392139
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
@@ -2144,16 +2144,6 @@ int snd_hda_hdmi_generic_resume(struct hda_codec *codec)
21442144
}
21452145
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_generic_resume, "SND_HDA_CODEC_HDMI");
21462146

2147-
static const struct hda_codec_ops generic_hdmi_patch_ops = {
2148-
.init = snd_hda_hdmi_generic_init,
2149-
.free = snd_hda_hdmi_generic_free,
2150-
.build_pcms = snd_hda_hdmi_generic_build_pcms,
2151-
.build_controls = snd_hda_hdmi_generic_build_controls,
2152-
.unsol_event = snd_hda_hdmi_generic_unsol_event,
2153-
.suspend = snd_hda_hdmi_generic_suspend,
2154-
.resume = snd_hda_hdmi_generic_resume,
2155-
};
2156-
21572147
static const struct hdmi_ops generic_standard_hdmi_ops = {
21582148
.pin_get_eld = hdmi_pin_get_eld,
21592149
.pin_setup_infoframe = hdmi_pin_setup_infoframe,
@@ -2185,14 +2175,12 @@ int snd_hda_hdmi_generic_alloc(struct hda_codec *codec)
21852175
codec->spec = spec;
21862176
hdmi_array_init(spec, 4);
21872177

2188-
codec->patch_ops = generic_hdmi_patch_ops;
2189-
21902178
return 0;
21912179
}
21922180
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_generic_alloc, "SND_HDA_CODEC_HDMI");
21932181

21942182
/* generic HDMI parser */
2195-
int patch_generic_hdmi(struct hda_codec *codec)
2183+
int snd_hda_hdmi_generic_probe(struct hda_codec *codec)
21962184
{
21972185
int err;
21982186

@@ -2209,7 +2197,7 @@ int patch_generic_hdmi(struct hda_codec *codec)
22092197
snd_hda_hdmi_generic_init_per_pins(codec);
22102198
return 0;
22112199
}
2212-
EXPORT_SYMBOL_NS_GPL(patch_generic_hdmi, "SND_HDA_CODEC_HDMI");
2200+
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_generic_probe, "SND_HDA_CODEC_HDMI");
22132201

22142202
/*
22152203
* generic audio component binding
@@ -2346,65 +2334,83 @@ EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_acomp_init, "SND_HDA_CODEC_HDMI");
23462334
/*
23472335
*/
23482336

2349-
static int patch_gf_hdmi(struct hda_codec *codec)
2337+
enum {
2338+
MODEL_GENERIC,
2339+
MODEL_GF,
2340+
};
2341+
2342+
static int generichdmi_probe(struct hda_codec *codec,
2343+
const struct hda_device_id *id)
23502344
{
23512345
int err;
23522346

2353-
err = patch_generic_hdmi(codec);
2354-
if (err)
2347+
err = snd_hda_hdmi_generic_probe(codec);
2348+
if (err < 0)
23552349
return err;
2356-
23572350
/*
23582351
* Glenfly GPUs have two codecs, stream switches from one codec to
23592352
* another, need to do actual clean-ups in codec_cleanup_stream
23602353
*/
2361-
codec->no_sticky_stream = 1;
2354+
if (id->driver_data == MODEL_GF)
2355+
codec->no_sticky_stream = 1;
2356+
23622357
return 0;
23632358
}
23642359

2360+
static const struct hda_codec_ops generichdmi_codec_ops = {
2361+
.probe = generichdmi_probe,
2362+
.remove = snd_hda_hdmi_generic_remove,
2363+
.init = snd_hda_hdmi_generic_init,
2364+
.build_pcms = snd_hda_hdmi_generic_build_pcms,
2365+
.build_controls = snd_hda_hdmi_generic_build_controls,
2366+
.unsol_event = snd_hda_hdmi_generic_unsol_event,
2367+
.suspend = snd_hda_hdmi_generic_suspend,
2368+
.resume = snd_hda_hdmi_generic_resume,
2369+
};
2370+
23652371
/*
2366-
* patch entries
23672372
*/
2368-
static const struct hda_device_id snd_hda_id_hdmi[] = {
2369-
HDA_CODEC_ENTRY(0x00147a47, "Loongson HDMI", patch_generic_hdmi),
2370-
HDA_CODEC_ENTRY(0x10951390, "SiI1390 HDMI", patch_generic_hdmi),
2371-
HDA_CODEC_ENTRY(0x10951392, "SiI1392 HDMI", patch_generic_hdmi),
2372-
HDA_CODEC_ENTRY(0x17e80047, "Chrontel HDMI", patch_generic_hdmi),
2373-
HDA_CODEC_ENTRY(0x67663d82, "Arise 82 HDMI/DP", patch_gf_hdmi),
2374-
HDA_CODEC_ENTRY(0x67663d83, "Arise 83 HDMI/DP", patch_gf_hdmi),
2375-
HDA_CODEC_ENTRY(0x67663d84, "Arise 84 HDMI/DP", patch_gf_hdmi),
2376-
HDA_CODEC_ENTRY(0x67663d85, "Arise 85 HDMI/DP", patch_gf_hdmi),
2377-
HDA_CODEC_ENTRY(0x67663d86, "Arise 86 HDMI/DP", patch_gf_hdmi),
2378-
HDA_CODEC_ENTRY(0x67663d87, "Arise 87 HDMI/DP", patch_gf_hdmi),
2379-
HDA_CODEC_ENTRY(0x11069f84, "VX11 HDMI/DP", patch_generic_hdmi),
2380-
HDA_CODEC_ENTRY(0x11069f85, "VX11 HDMI/DP", patch_generic_hdmi),
2381-
HDA_CODEC_ENTRY(0x1d179f86, "ZX-100S HDMI/DP", patch_gf_hdmi),
2382-
HDA_CODEC_ENTRY(0x1d179f87, "ZX-100S HDMI/DP", patch_gf_hdmi),
2383-
HDA_CODEC_ENTRY(0x1d179f88, "KX-5000 HDMI/DP", patch_gf_hdmi),
2384-
HDA_CODEC_ENTRY(0x1d179f89, "KX-5000 HDMI/DP", patch_gf_hdmi),
2385-
HDA_CODEC_ENTRY(0x1d179f8a, "KX-6000 HDMI/DP", patch_gf_hdmi),
2386-
HDA_CODEC_ENTRY(0x1d179f8b, "KX-6000 HDMI/DP", patch_gf_hdmi),
2387-
HDA_CODEC_ENTRY(0x1d179f8c, "KX-6000G HDMI/DP", patch_gf_hdmi),
2388-
HDA_CODEC_ENTRY(0x1d179f8d, "KX-6000G HDMI/DP", patch_gf_hdmi),
2389-
HDA_CODEC_ENTRY(0x1d179f8e, "KX-7000 HDMI/DP", patch_gf_hdmi),
2390-
HDA_CODEC_ENTRY(0x1d179f8f, "KX-7000 HDMI/DP", patch_gf_hdmi),
2391-
HDA_CODEC_ENTRY(0x1d179f90, "KX-7000 HDMI/DP", patch_gf_hdmi),
2392-
HDA_CODEC_ENTRY(0x80862801, "Bearlake HDMI", patch_generic_hdmi),
2393-
HDA_CODEC_ENTRY(0x80862802, "Cantiga HDMI", patch_generic_hdmi),
2394-
HDA_CODEC_ENTRY(0x80862803, "Eaglelake HDMI", patch_generic_hdmi),
2395-
HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi),
2396-
HDA_CODEC_ENTRY(0x808629fb, "Crestline HDMI", patch_generic_hdmi),
2397-
/* special ID for generic HDMI */
2398-
HDA_CODEC_ENTRY(HDA_CODEC_ID_GENERIC_HDMI, "Generic HDMI", patch_generic_hdmi),
2399-
{} /* terminator */
2373+
static const struct hda_device_id snd_hda_id_generichdmi[] = {
2374+
HDA_CODEC_ID_MODEL(0x00147a47, "Loongson HDMI", MODEL_GENERIC),
2375+
HDA_CODEC_ID_MODEL(0x10951390, "SiI1390 HDMI", MODEL_GENERIC),
2376+
HDA_CODEC_ID_MODEL(0x10951392, "SiI1392 HDMI", MODEL_GENERIC),
2377+
HDA_CODEC_ID_MODEL(0x11069f84, "VX11 HDMI/DP", MODEL_GENERIC),
2378+
HDA_CODEC_ID_MODEL(0x11069f85, "VX11 HDMI/DP", MODEL_GENERIC),
2379+
HDA_CODEC_ID_MODEL(0x17e80047, "Chrontel HDMI", MODEL_GENERIC),
2380+
HDA_CODEC_ID_MODEL(0x1d179f86, "ZX-100S HDMI/DP", MODEL_GF),
2381+
HDA_CODEC_ID_MODEL(0x1d179f87, "ZX-100S HDMI/DP", MODEL_GF),
2382+
HDA_CODEC_ID_MODEL(0x1d179f88, "KX-5000 HDMI/DP", MODEL_GF),
2383+
HDA_CODEC_ID_MODEL(0x1d179f89, "KX-5000 HDMI/DP", MODEL_GF),
2384+
HDA_CODEC_ID_MODEL(0x1d179f8a, "KX-6000 HDMI/DP", MODEL_GF),
2385+
HDA_CODEC_ID_MODEL(0x1d179f8b, "KX-6000 HDMI/DP", MODEL_GF),
2386+
HDA_CODEC_ID_MODEL(0x1d179f8c, "KX-6000G HDMI/DP", MODEL_GF),
2387+
HDA_CODEC_ID_MODEL(0x1d179f8d, "KX-6000G HDMI/DP", MODEL_GF),
2388+
HDA_CODEC_ID_MODEL(0x1d179f8e, "KX-7000 HDMI/DP", MODEL_GF),
2389+
HDA_CODEC_ID_MODEL(0x1d179f8f, "KX-7000 HDMI/DP", MODEL_GF),
2390+
HDA_CODEC_ID_MODEL(0x1d179f90, "KX-7000 HDMI/DP", MODEL_GF),
2391+
HDA_CODEC_ID_MODEL(0x67663d82, "Arise 82 HDMI/DP", MODEL_GF),
2392+
HDA_CODEC_ID_MODEL(0x67663d83, "Arise 83 HDMI/DP", MODEL_GF),
2393+
HDA_CODEC_ID_MODEL(0x67663d84, "Arise 84 HDMI/DP", MODEL_GF),
2394+
HDA_CODEC_ID_MODEL(0x67663d85, "Arise 85 HDMI/DP", MODEL_GF),
2395+
HDA_CODEC_ID_MODEL(0x67663d86, "Arise 86 HDMI/DP", MODEL_GF),
2396+
HDA_CODEC_ID_MODEL(0x67663d87, "Arise 87 HDMI/DP", MODEL_GF),
2397+
HDA_CODEC_ID_MODEL(0x80862801, "Bearlake HDMI", MODEL_GENERIC),
2398+
HDA_CODEC_ID_MODEL(0x80862802, "Cantiga HDMI", MODEL_GENERIC),
2399+
HDA_CODEC_ID_MODEL(0x80862803, "Eaglelake HDMI", MODEL_GENERIC),
2400+
HDA_CODEC_ID_MODEL(0x80862880, "CedarTrail HDMI", MODEL_GENERIC),
2401+
HDA_CODEC_ID_MODEL(0x808629fb, "Crestline HDMI", MODEL_GENERIC),
2402+
/* special ID for generic HDMI */
2403+
HDA_CODEC_ID_MODEL(HDA_CODEC_ID_GENERIC_HDMI, "Generic HDMI", MODEL_GENERIC),
2404+
{} /* terminator */
24002405
};
2401-
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_hdmi);
2406+
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_generichdmi);
24022407

24032408
MODULE_LICENSE("GPL");
2404-
MODULE_DESCRIPTION("HDMI HD-audio codec");
2409+
MODULE_DESCRIPTION("Generic HDMI HD-audio codec");
24052410

2406-
static struct hda_codec_driver hdmi_driver = {
2407-
.id = snd_hda_id_hdmi,
2411+
static struct hda_codec_driver generichdmi_driver = {
2412+
.id = snd_hda_id_generichdmi,
2413+
.ops = &generichdmi_codec_ops,
24082414
};
24092415

2410-
module_hda_codec_driver(hdmi_driver);
2416+
module_hda_codec_driver(generichdmi_driver);

sound/hda/codecs/hdmi/hdmi_local.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ union audio_infoframe {
237237
/* Generic HDMI codec support */
238238
int snd_hda_hdmi_generic_alloc(struct hda_codec *codec);
239239
int snd_hda_hdmi_parse_codec(struct hda_codec *codec);
240-
int patch_generic_hdmi(struct hda_codec *codec);
241-
void snd_hda_hdmi_generic_free(struct hda_codec *codec);
240+
int snd_hda_hdmi_generic_probe(struct hda_codec *codec);
241+
void snd_hda_hdmi_generic_remove(struct hda_codec *codec);
242242

243243
int snd_hda_hdmi_generic_build_pcms(struct hda_codec *codec);
244244
int snd_hda_hdmi_generic_build_controls(struct hda_codec *codec);
@@ -286,9 +286,9 @@ void snd_hda_hdmi_acomp_master_unbind(struct device *dev,
286286
struct drm_audio_component *acomp);
287287

288288
/* Simple / legacy HDMI codec support */
289-
int patch_simple_hdmi(struct hda_codec *codec,
290-
hda_nid_t cvt_nid, hda_nid_t pin_nid);
291-
void snd_hda_hdmi_simple_free(struct hda_codec *codec);
289+
int snd_hda_hdmi_simple_probe(struct hda_codec *codec,
290+
hda_nid_t cvt_nid, hda_nid_t pin_nid);
291+
void snd_hda_hdmi_simple_remove(struct hda_codec *codec);
292292

293293
int snd_hda_hdmi_simple_build_pcms(struct hda_codec *codec);
294294
int snd_hda_hdmi_simple_build_controls(struct hda_codec *codec);

0 commit comments

Comments
 (0)