ALSA: hda: Add snd_hdac_ext_bus_link_at() helper
This patch exposes a new helper to directly retrieve the link from the codec address, and makes use of this helper when retrieving the link from the codec name. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220214101404.4074026-2-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
15175a4f2b
commit
fefee95488
|
@ -28,6 +28,7 @@ void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip,
|
||||||
bool enable, int index);
|
bool enable, int index);
|
||||||
|
|
||||||
int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus);
|
int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus);
|
||||||
|
struct hdac_ext_link *snd_hdac_ext_bus_link_at(struct hdac_bus *bus, int addr);
|
||||||
struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
|
struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
|
||||||
const char *codec_name);
|
const char *codec_name);
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,26 @@ void snd_hdac_link_free_all(struct hdac_bus *bus)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_hdac_link_free_all);
|
EXPORT_SYMBOL_GPL(snd_hdac_link_free_all);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* snd_hdac_ext_bus_link_at - get link at specified address
|
||||||
|
* @bus: link's parent bus device
|
||||||
|
* @addr: codec device address
|
||||||
|
*
|
||||||
|
* Returns link object or NULL if matching link is not found.
|
||||||
|
*/
|
||||||
|
struct hdac_ext_link *snd_hdac_ext_bus_link_at(struct hdac_bus *bus, int addr)
|
||||||
|
{
|
||||||
|
struct hdac_ext_link *hlink;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
list_for_each_entry(hlink, &bus->hlink_list, list)
|
||||||
|
for (i = 0; i < HDA_MAX_CODECS; i++)
|
||||||
|
if (hlink->lsdiid & (0x1 << addr))
|
||||||
|
return hlink;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_at);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* snd_hdac_ext_bus_get_link - get link based on codec name
|
* snd_hdac_ext_bus_get_link - get link based on codec name
|
||||||
* @bus: the pointer to HDAC bus object
|
* @bus: the pointer to HDAC bus object
|
||||||
|
@ -140,8 +160,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_link_free_all);
|
||||||
struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
|
struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
|
||||||
const char *codec_name)
|
const char *codec_name)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
struct hdac_ext_link *hlink = NULL;
|
|
||||||
int bus_idx, addr;
|
int bus_idx, addr;
|
||||||
|
|
||||||
if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
|
if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
|
||||||
|
@ -151,14 +169,7 @@ struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
|
||||||
if (addr < 0 || addr > 31)
|
if (addr < 0 || addr > 31)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
list_for_each_entry(hlink, &bus->hlink_list, list) {
|
return snd_hdac_ext_bus_link_at(bus, addr);
|
||||||
for (i = 0; i < HDA_MAX_CODECS; i++) {
|
|
||||||
if (hlink->lsdiid & (0x1 << addr))
|
|
||||||
return hlink;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_link);
|
EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_link);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue