ALSA: hda: Update and expose codec register procedures
With few changes, snd_hda_codec_register() and its unregister-counterpart can be re-used by ASoC drivers. While at it, provide kernel doc for the exposed functions. Due to ALSA-device vs ASoC-component organization differences, new 'snddev_managed' argument is specified allowing for better control over codec registration process. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220214101404.4074026-4-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
595511a3ab
commit
17e0c4cbb7
@ -312,9 +312,12 @@ snd_hda_codec_device_init(struct hda_bus *bus, unsigned int codec_addr,
|
||||
int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
|
||||
unsigned int codec_addr, struct hda_codec **codecp);
|
||||
int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,
|
||||
unsigned int codec_addr, struct hda_codec *codec);
|
||||
unsigned int codec_addr, struct hda_codec *codec,
|
||||
bool snddev_managed);
|
||||
int snd_hda_codec_configure(struct hda_codec *codec);
|
||||
int snd_hda_codec_update_widgets(struct hda_codec *codec);
|
||||
void snd_hda_codec_register(struct hda_codec *codec);
|
||||
void snd_hda_codec_unregister(struct hda_codec *codec);
|
||||
|
||||
/*
|
||||
* low level functions
|
||||
|
@ -813,7 +813,12 @@ void snd_hda_codec_display_power(struct hda_codec *codec, bool enable)
|
||||
snd_hdac_display_power(&codec->bus->core, codec->addr, enable);
|
||||
}
|
||||
|
||||
/* also called from hda_bind.c */
|
||||
/**
|
||||
* snd_hda_codec_register - Finalize codec initialization
|
||||
* @codec: codec device to register
|
||||
*
|
||||
* Also called from hda_bind.c
|
||||
*/
|
||||
void snd_hda_codec_register(struct hda_codec *codec)
|
||||
{
|
||||
if (codec->registered)
|
||||
@ -826,6 +831,7 @@ void snd_hda_codec_register(struct hda_codec *codec)
|
||||
codec->registered = 1;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_hda_codec_register);
|
||||
|
||||
static int snd_hda_codec_dev_register(struct snd_device *device)
|
||||
{
|
||||
@ -833,10 +839,12 @@ static int snd_hda_codec_dev_register(struct snd_device *device)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_hda_codec_dev_free(struct snd_device *device)
|
||||
/**
|
||||
* snd_hda_codec_unregister - Unregister specified codec device
|
||||
* @codec: codec device to unregister
|
||||
*/
|
||||
void snd_hda_codec_unregister(struct hda_codec *codec)
|
||||
{
|
||||
struct hda_codec *codec = device->device_data;
|
||||
|
||||
codec->in_freeing = 1;
|
||||
/*
|
||||
* snd_hda_codec_device_new() is used by legacy HDA and ASoC driver.
|
||||
@ -853,7 +861,12 @@ static int snd_hda_codec_dev_free(struct snd_device *device)
|
||||
*/
|
||||
if (codec->core.type == HDA_DEV_LEGACY)
|
||||
put_device(hda_codec_dev(codec));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_hda_codec_unregister);
|
||||
|
||||
static int snd_hda_codec_dev_free(struct snd_device *device)
|
||||
{
|
||||
snd_hda_codec_unregister(device->device_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -940,12 +953,13 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
|
||||
return PTR_ERR(codec);
|
||||
*codecp = codec;
|
||||
|
||||
return snd_hda_codec_device_new(bus, card, codec_addr, *codecp);
|
||||
return snd_hda_codec_device_new(bus, card, codec_addr, *codecp, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_hda_codec_new);
|
||||
|
||||
int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,
|
||||
unsigned int codec_addr, struct hda_codec *codec)
|
||||
unsigned int codec_addr, struct hda_codec *codec,
|
||||
bool snddev_managed)
|
||||
{
|
||||
char component[31];
|
||||
hda_nid_t fg;
|
||||
@ -1020,9 +1034,12 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,
|
||||
codec->core.subsystem_id, codec->core.revision_id);
|
||||
snd_component_add(card, component);
|
||||
|
||||
err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
if (snddev_managed) {
|
||||
/* ASoC features component management instead */
|
||||
err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* PM runtime needs to be enabled later after binding codec */
|
||||
pm_runtime_forbid(&codec->core.dev);
|
||||
|
@ -135,7 +135,6 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
|
||||
#define snd_hda_add_vmaster(codec, name, tlv, followers, suffix, access) \
|
||||
__snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, access, NULL)
|
||||
int snd_hda_codec_reset(struct hda_codec *codec);
|
||||
void snd_hda_codec_register(struct hda_codec *codec);
|
||||
void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec);
|
||||
void snd_hda_codec_disconnect_pcms(struct hda_codec *codec);
|
||||
|
||||
|
@ -413,7 +413,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
|
||||
HDA_CODEC_IDX_CONTROLLER, true);
|
||||
|
||||
ret = snd_hda_codec_device_new(hcodec->bus, component->card->snd_card,
|
||||
hdev->addr, hcodec);
|
||||
hdev->addr, hcodec, true);
|
||||
if (ret < 0) {
|
||||
dev_err(&hdev->dev, "failed to create hda codec %d\n", ret);
|
||||
goto error_no_pm;
|
||||
|
Loading…
Reference in New Issue
Block a user