ALSA: hda: New NHLT functions and cleanup
Subsystems (3)
Cezary Rojewski
maintainerv5 cover ALSA: hda: New NHLT functions and cleanup
Changes add two crucial functions: endpoint presence-check and retrieval of endpoint's BLOB (hardware configuration) to NHLT API.
Outside of that, "is DMIC in NHLT?" check is being re-visited. No need to check for channel count or anything DMIC-configuration related, just straight up verify link_type presence.
Changes in v5:
- no code changes
- actually removed the tags mentioned in v3
Changes in v4:
- patch renaming nhlt_acpi_table struct to acpi_nhlt_table has been dropped due to naming conflicts with other parts of the kernel
- revoked previously appended tags from Mark and Pierre as every patch required an update due to above
Changes in v3:
- no code changes
- appended Mark's Acked-by tag for patch 4/4
- appended Pierre's Reviewed-by tag for all patches
Changes in v2:
- patch "ALSA hda: Drop device-argument in NHLT functions" has been dropped
- updated newly added declarations in intel-nhlt.h so warning:
"no-previous-prototype-for-function" and error:
"use-of-undeclared-identifier" are no longer observed when CONFIG_SND_INTEL_NHLT is not enabled
- added Mark's tag to the last patch of the series
Amadeusz Sławiński (3):
ALSA: hda: Fill gaps in NHLT endpoint-interface
ALSA: hda: Simplify DMIC-in-NHLT check
ASoC: Intel: Skylake: Use NHLT API to search for blob
include/sound/intel-nhlt.h | 37 +++++++-- sound/hda/intel-dsp-config.c | 2 +- sound/hda/intel-nhlt.c | 102 +++++++++++++++++++++++++ sound/soc/intel/skylake/skl-nhlt.c | 102 ------------------------- sound/soc/intel/skylake/skl-pcm.c | 3 + sound/soc/intel/skylake/skl-topology.c | 29 ++++--- sound/soc/intel/skylake/skl-topology.h | 1 + sound/soc/intel/skylake/skl.h | 4 - 8 files changed, 153 insertions(+), 127 deletions(-)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 1/3 ALSA: hda: Fill gaps in NHLT endpoint-interface
From: Amadeusz Sławiński <[email protected]>
Two key operations missings are: endpoint presence-check and retrieval of matching endpoint hardware configuration (blob). Add operations for both use cases.
--- include/sound/intel-nhlt.h | 37 +++++++++++--- sound/hda/intel-nhlt.c | 102 +++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 8 deletions(-)
include/sound/intel-nhlt.h +29 -8
@@ -10,6 +10,14 @@#include <linux/acpi.h> +enum nhlt_link_type { +NHLT_LINK_HDA =0 , +NHLT_LINK_DSP =1 , +NHLT_LINK_DMIC =2 , +NHLT_LINK_SSP =3 , +NHLT_LINK_INVALID +}; +#if IS_ENABLED (CONFIG_ACPI ) &&IS_ENABLED (CONFIG_SND_INTEL_NHLT ) struct wav_fmt {
@@ -33,14 +41,6 @@ struct wav_fmt_ext {u8 sub_fmt[16 ]; } __packed; -enum nhlt_link_type { -NHLT_LINK_HDA =0 , -NHLT_LINK_DSP =1 , -NHLT_LINK_DMIC =2 , -NHLT_LINK_SSP =3 , -NHLT_LINK_INVALID -}; -enum nhlt_device_type {NHLT_DEVICE_BT =0 ,NHLT_DEVICE_DMIC =1 ,
@@ -132,6 +132,12 @@ void intel_nhlt_free(struct nhlt_acpi_table *addr);int intel_nhlt_get_dmic_geo (struct device *dev,struct nhlt_acpi_table *nhlt); +bool intel_nhlt_has_endpoint_type (struct nhlt_acpi_table *nhlt,u8 link_type); +struct nhlt_specific_cfg * +intel_nhlt_get_endpoint_blob (struct device *dev,struct nhlt_acpi_table *nhlt, +u32 bus_id,u8 link_type,u8 vbps,u8 bps, +u8 num_ch,u32 rate,u8 dir,u8 dev_type); +#else struct nhlt_acpi_table ;
@@ -150,6 +156,21 @@ static inline int intel_nhlt_get_dmic_geo(struct device *dev, {return 0 ; } + +static inline bool intel_nhlt_has_endpoint_type (struct nhlt_acpi_table *nhlt, +u8 link_type) +{ +return false; +} + +static inline struct nhlt_specific_cfg * +intel_nhlt_get_endpoint_blob (struct device *dev,struct nhlt_acpi_table *nhlt, +u32 bus_id,u8 link_type,u8 vbps,u8 bps, +u8 num_ch,u32 rate,u8 dir,u8 dev_type) +{ +return NULL ; +} +#endif #endif
sound/hda/intel-nhlt.c +102 -0
105 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 2/3 ALSA: hda: Simplify DMIC-in-NHLT check
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
Only DMIC endpoint presence is relevant, not its configuration.
--- sound/hda/intel-dsp-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/intel-dsp-config.c +1 -1
@@ -384,7 +384,7 @@ static int snd_intel_dsp_check_dmic(struct pci_dev *pci) nhlt =intel_nhlt_init (&pci->dev);if (nhlt) { -if (intel_nhlt_get_dmic_geo (&pci->dev, nhlt)) +if (intel_nhlt_has_endpoint_type (nhlt,NHLT_LINK_DMIC )) ret =1 ;intel_nhlt_free (nhlt); }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 3/3 ASoC: Intel: Skylake: Use NHLT API to search for blob
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
With NHLT enriched with new search functions, remove local code in favour of them. This also fixes broken behaviour: search should be based on significant bits count rather than container size.
--- sound/soc/intel/skylake/skl-nhlt.c | 102 ------------------------- sound/soc/intel/skylake/skl-pcm.c | 3 + sound/soc/intel/skylake/skl-topology.c | 29 ++++--- sound/soc/intel/skylake/skl-topology.h | 1 + sound/soc/intel/skylake/skl.h | 4 - 5 files changed, 21 insertions(+), 118 deletions(-)
sound/soc/intel/skylake/skl-nhlt.c +0 -102
@@ -13,108 +13,6 @@#include "skl.h" #include "skl-i2s.h" -static struct nhlt_specific_cfg *skl_get_specific_cfg ( -struct device *dev,struct nhlt_fmt *fmt, -u8 no_ch,u32 rate,u16 bps,u8 linktype) -{ -struct nhlt_specific_cfg *sp_config; -struct wav_fmt *wfmt; -struct nhlt_fmt_cfg *fmt_config = fmt->fmt_config; -int i; - -dev_dbg (dev,"Format count =%d\n" , fmt->fmt_count); - -for (i =0 ; i < fmt->fmt_count; i++) { - wfmt = &fmt_config->fmt_ext.fmt; -dev_dbg (dev,"ch=%d fmt=%d s_rate=%d\n" , wfmt->channels, - wfmt->bits_per_sample, wfmt->samples_per_sec); -if (wfmt->channels == no_ch && wfmt->bits_per_sample == bps) { -/* -* if link type is dmic ignore rate check as the blob is -* generic for all rates -*/ - sp_config = &fmt_config->config; -if (linktype ==NHLT_LINK_DMIC ) -return sp_config; - -if (wfmt->samples_per_sec == rate) -return sp_config; - } - - fmt_config = (struct nhlt_fmt_cfg *)(fmt_config->config.caps + - fmt_config->config.size); - } - -return NULL ; -} - -static void dump_config (struct device *dev,u32 instance_id,u8 linktype, -u8 s_fmt,u8 num_channels,u32 s_rate,u8 dirn,u16 bps) -{ -dev_dbg (dev,"Input configuration\n" ); -dev_dbg (dev,"ch=%d fmt=%d s_rate=%d\n" , num_channels, s_fmt, s_rate); -dev_dbg (dev,"vbus_id=%d link_type=%d\n" , instance_id, linktype); -dev_dbg (dev,"bits_per_sample=%d\n" , bps); -} - -static bool skl_check_ep_match (struct device *dev,struct nhlt_endpoint *epnt, -u32 instance_id,u8 link_type,u8 dirn,u8 dev_type) -{ -dev_dbg (dev,"vbus_id=%d link_type=%d dir=%d dev_type = %d\n" , - epnt->virtual_bus_id, epnt->linktype, - epnt->direction, epnt->device_type); - -if ((epnt->virtual_bus_id == instance_id) && - (epnt->linktype == link_type) && - (epnt->direction == dirn)) { -/* do not check dev_type for DMIC link type */ -if (epnt->linktype ==NHLT_LINK_DMIC ) -return true; - -if (epnt->device_type == dev_type) -return true; - } - -return false; -} - -struct nhlt_specific_cfg -*skl_get_ep_blob (struct skl_dev *skl,u32 instance,u8 link_type, -u8 s_fmt,u8 num_ch,u32 s_rate, -u8 dirn,u8 dev_type) -{ -struct nhlt_fmt *fmt; -struct nhlt_endpoint *epnt; -struct hdac_bus *bus =skl_to_bus (skl); -struct device *dev = bus->dev; -struct nhlt_specific_cfg *sp_config; -struct nhlt_acpi_table *nhlt = skl->nhlt; -u16 bps = (s_fmt ==16 ) ?16 :32 ; -u8 j; - -dump_config (dev, instance, link_type, s_fmt, num_ch, s_rate, dirn, bps); - - epnt = (struct nhlt_endpoint *)nhlt->desc; - -dev_dbg (dev,"endpoint count =%d\n" , nhlt->endpoint_count); - -for (j =0 ; j < nhlt->endpoint_count; j++) { -if (skl_check_ep_match (dev, epnt, instance, link_type, - dirn, dev_type)) { - fmt = (struct nhlt_fmt *)(epnt->config.caps + - epnt->config.size); - sp_config =skl_get_specific_cfg (dev, fmt, num_ch, - s_rate, bps, link_type); -if (sp_config) -return sp_config; - } - - epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); - } - -return NULL ; -} -static void skl_nhlt_trim_space (char *trim) {char *s = trim;
sound/soc/intel/skylake/skl-pcm.c +3 -0
@@ -317,6 +317,7 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream,dev_dbg (dai->dev,"dma_id=%d\n" , dma_id); p_params.s_fmt =snd_pcm_format_width (params_format (params)); + p_params.s_cont =snd_pcm_format_physical_width (params_format (params)); p_params.ch =params_channels (params); p_params.s_freq =params_rate (params); p_params.host_dma_id = dma_id;
@@ -405,6 +406,7 @@ static int skl_be_hw_params(struct snd_pcm_substream *substream,struct skl_pipe_params p_params = {0 }; p_params.s_fmt =snd_pcm_format_width (params_format (params)); + p_params.s_cont =snd_pcm_format_physical_width (params_format (params)); p_params.ch =params_channels (params); p_params.s_freq =params_rate (params); p_params.stream = substream->stream;
@@ -569,6 +571,7 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,snd_soc_dai_set_tdm_slot (codec_dai,0 , stream_tag,0 ,0 ); p_params.s_fmt =snd_pcm_format_width (params_format (params)); + p_params.s_cont =snd_pcm_format_physical_width (params_format (params)); p_params.ch =params_channels (params); p_params.s_freq =params_rate (params); p_params.stream = substream->stream;
sound/soc/intel/skylake/skl-topology.c +17 -12
@@ -285,7 +285,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, {struct skl_module_cfg *m_cfg = w->priv;int link_type, dir; -u32 ch, s_freq, s_fmt; +u32 ch, s_freq, s_fmt, s_cont;struct nhlt_specific_cfg *cfg;u8 dev_type =skl_tplg_be_dev_type (m_cfg->dev_type);int fmt_idx = m_cfg->fmt_idx;
@@ -301,7 +301,8 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, link_type =NHLT_LINK_DMIC ; dir =SNDRV_PCM_STREAM_CAPTURE ; s_freq = m_iface->inputs[0 ].fmt.s_freq; - s_fmt = m_iface->inputs[0 ].fmt.bit_depth; + s_fmt = m_iface->inputs[0 ].fmt.valid_bit_depth; + s_cont = m_iface->inputs[0 ].fmt.bit_depth; ch = m_iface->inputs[0 ].fmt.channels;break ;
@@ -310,12 +311,14 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,if (m_cfg->hw_conn_type ==SKL_CONN_SOURCE ) { dir =SNDRV_PCM_STREAM_PLAYBACK ; s_freq = m_iface->outputs[0 ].fmt.s_freq; - s_fmt = m_iface->outputs[0 ].fmt.bit_depth; + s_fmt = m_iface->outputs[0 ].fmt.valid_bit_depth; + s_cont = m_iface->outputs[0 ].fmt.bit_depth; ch = m_iface->outputs[0 ].fmt.channels; }else { dir =SNDRV_PCM_STREAM_CAPTURE ; s_freq = m_iface->inputs[0 ].fmt.s_freq; - s_fmt = m_iface->inputs[0 ].fmt.bit_depth; + s_fmt = m_iface->inputs[0 ].fmt.valid_bit_depth; + s_cont = m_iface->inputs[0 ].fmt.bit_depth; ch = m_iface->inputs[0 ].fmt.channels; }break ;
@@ -325,16 +328,17 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, }/* update the blob based on virtual bus_id and default params */ - cfg =skl_get_ep_blob (skl, m_cfg->vbus_id, link_type, - s_fmt, ch, s_freq, dir, dev_type); + cfg =intel_nhlt_get_endpoint_blob (skl->dev, skl->nhlt, m_cfg->vbus_id, + link_type, s_fmt, s_cont, ch, + s_freq, dir, dev_type);if (cfg) { m_cfg->formats_config[SKL_PARAM_INIT ].caps_size = cfg->size; m_cfg->formats_config[SKL_PARAM_INIT ].caps = (u32 *)&cfg->caps; }else {dev_err (skl->dev,"Blob NULL for id %x type %d dirn %d\n" , m_cfg->vbus_id, link_type, dir); -dev_err (skl->dev,"PCM: ch %d, freq %d, fmt %d\n" , - ch, s_freq, s_fmt); +dev_err (skl->dev,"PCM: ch %d, freq %d, fmt %d/%d\n" , + ch, s_freq, s_fmt, s_cont);return -EIO ; }
@@ -1849,10 +1853,11 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai, pipe_fmt = &pipe->configs[pipe->pipe_config_idx].in_fmt;/* update the blob based on virtual bus_id*/ - cfg =skl_get_ep_blob (skl, mconfig->vbus_id, link_type, - pipe_fmt->bps, pipe_fmt->channels, - pipe_fmt->freq, pipe->direction, - dev_type); + cfg =intel_nhlt_get_endpoint_blob (dai->dev, skl->nhlt, + mconfig->vbus_id, link_type, + pipe_fmt->bps, params->s_cont, + pipe_fmt->channels, pipe_fmt->freq, + pipe->direction, dev_type);if (cfg) { mconfig->formats_config[SKL_PARAM_INIT ].caps_size = cfg->size; mconfig->formats_config[SKL_PARAM_INIT ].caps = (u32 *)&cfg->caps;
sound/soc/intel/skylake/skl-topology.h +1 -0
@@ -284,6 +284,7 @@ struct skl_pipe_params {u32 ch;u32 s_freq;u32 s_fmt; +u32 s_cont;u8 linktype;snd_pcm_format_t format;int link_index;
sound/soc/intel/skylake/skl.h +0 -4
@@ -165,10 +165,6 @@ struct skl_dsp_ops {int skl_platform_unregister (struct device *dev);int skl_platform_register (struct device *dev); -struct nhlt_specific_cfg *skl_get_ep_blob (struct skl_dev *skl,u32 instance, -u8 link_type,u8 s_fmt,u8 num_ch, -u32 s_rate,u8 dirn,u8 dev_type); -int skl_nhlt_update_topology_bin (struct skl_dev *skl);int skl_init_dsp (struct skl_dev *skl);int skl_free_dsp (struct skl_dev *skl);
Signature · 1 line
2.25.1
Re: [PATCH v5 3/3] ASoC: Intel: Skylake: Use NHLT API to search for blob
Quoted 5 lines · Cezary Rojewski
From: Amadeusz Sławiński <[email protected]>
With NHLT enriched with new search functions, remove local code in favour of them. This also fixes broken behaviour: search should be based on significant bits count rather than container size.
Takashi Iwai
AppliedQuoted 32 lines · Cezary Rojewski
Changes add two crucial functions: endpoint presence-check and retrieval of endpoint's BLOB (hardware configuration) to NHLT API.
Outside of that, "is DMIC in NHLT?" check is being re-visited. No need to check for channel count or anything DMIC-configuration related, just straight up verify
link_typepresence.Changes in v5:
- no code changes
- actually removed the tags mentioned in v3Changes in v4:
- patch renamingnhlt_acpi_tablestruct toacpi_nhlt_tablehas been dropped due to naming conflicts with other parts of the kernel
- revoked previously appended tags from Mark and Pierre as every patch required an update due to aboveChanges in v3:
- no code changes
- appended Mark's Acked-by tag for patch 4/4
- appended Pierre's Reviewed-by tag for all patchesChanges in v2:
- patch "ALSA hda: Drop device-argument in NHLT functions" has been dropped
- updated newly added declarations inintel-nhlt.hso warning:
"no-previous-prototype-for-function" and error:
"use-of-undeclared-identifier" are no longer observed whenCONFIG_SND_INTEL_NHLTis not enabled
- added Mark's tag to the last patch of the series
Quoted 4 lines
Amadeusz Sławiński (3):
ALSA: hda: Fill gaps in NHLT endpoint-interface
ALSA: hda: Simplify DMIC-in-NHLT check
ASoC: Intel: Skylake: Use NHLT API to search for blob
Applied all three patches now to for-next branch.
thanks,
Takashi