Skip to content

Commit 322fa43

Browse files
Amadeusz Sławińskitiwai
authored andcommitted
ASoC: Intel: Skylake: Use NHLT API to search for blob
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. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20211126140355.1042684-4-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 8235a08 commit 322fa43

5 files changed

Lines changed: 21 additions & 118 deletions

File tree

sound/soc/intel/skylake/skl-nhlt.c

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -13,108 +13,6 @@
1313
#include "skl.h"
1414
#include "skl-i2s.h"
1515

16-
static struct nhlt_specific_cfg *skl_get_specific_cfg(
17-
struct device *dev, struct nhlt_fmt *fmt,
18-
u8 no_ch, u32 rate, u16 bps, u8 linktype)
19-
{
20-
struct nhlt_specific_cfg *sp_config;
21-
struct wav_fmt *wfmt;
22-
struct nhlt_fmt_cfg *fmt_config = fmt->fmt_config;
23-
int i;
24-
25-
dev_dbg(dev, "Format count =%d\n", fmt->fmt_count);
26-
27-
for (i = 0; i < fmt->fmt_count; i++) {
28-
wfmt = &fmt_config->fmt_ext.fmt;
29-
dev_dbg(dev, "ch=%d fmt=%d s_rate=%d\n", wfmt->channels,
30-
wfmt->bits_per_sample, wfmt->samples_per_sec);
31-
if (wfmt->channels == no_ch && wfmt->bits_per_sample == bps) {
32-
/*
33-
* if link type is dmic ignore rate check as the blob is
34-
* generic for all rates
35-
*/
36-
sp_config = &fmt_config->config;
37-
if (linktype == NHLT_LINK_DMIC)
38-
return sp_config;
39-
40-
if (wfmt->samples_per_sec == rate)
41-
return sp_config;
42-
}
43-
44-
fmt_config = (struct nhlt_fmt_cfg *)(fmt_config->config.caps +
45-
fmt_config->config.size);
46-
}
47-
48-
return NULL;
49-
}
50-
51-
static void dump_config(struct device *dev, u32 instance_id, u8 linktype,
52-
u8 s_fmt, u8 num_channels, u32 s_rate, u8 dirn, u16 bps)
53-
{
54-
dev_dbg(dev, "Input configuration\n");
55-
dev_dbg(dev, "ch=%d fmt=%d s_rate=%d\n", num_channels, s_fmt, s_rate);
56-
dev_dbg(dev, "vbus_id=%d link_type=%d\n", instance_id, linktype);
57-
dev_dbg(dev, "bits_per_sample=%d\n", bps);
58-
}
59-
60-
static bool skl_check_ep_match(struct device *dev, struct nhlt_endpoint *epnt,
61-
u32 instance_id, u8 link_type, u8 dirn, u8 dev_type)
62-
{
63-
dev_dbg(dev, "vbus_id=%d link_type=%d dir=%d dev_type = %d\n",
64-
epnt->virtual_bus_id, epnt->linktype,
65-
epnt->direction, epnt->device_type);
66-
67-
if ((epnt->virtual_bus_id == instance_id) &&
68-
(epnt->linktype == link_type) &&
69-
(epnt->direction == dirn)) {
70-
/* do not check dev_type for DMIC link type */
71-
if (epnt->linktype == NHLT_LINK_DMIC)
72-
return true;
73-
74-
if (epnt->device_type == dev_type)
75-
return true;
76-
}
77-
78-
return false;
79-
}
80-
81-
struct nhlt_specific_cfg
82-
*skl_get_ep_blob(struct skl_dev *skl, u32 instance, u8 link_type,
83-
u8 s_fmt, u8 num_ch, u32 s_rate,
84-
u8 dirn, u8 dev_type)
85-
{
86-
struct nhlt_fmt *fmt;
87-
struct nhlt_endpoint *epnt;
88-
struct hdac_bus *bus = skl_to_bus(skl);
89-
struct device *dev = bus->dev;
90-
struct nhlt_specific_cfg *sp_config;
91-
struct nhlt_acpi_table *nhlt = skl->nhlt;
92-
u16 bps = (s_fmt == 16) ? 16 : 32;
93-
u8 j;
94-
95-
dump_config(dev, instance, link_type, s_fmt, num_ch, s_rate, dirn, bps);
96-
97-
epnt = (struct nhlt_endpoint *)nhlt->desc;
98-
99-
dev_dbg(dev, "endpoint count =%d\n", nhlt->endpoint_count);
100-
101-
for (j = 0; j < nhlt->endpoint_count; j++) {
102-
if (skl_check_ep_match(dev, epnt, instance, link_type,
103-
dirn, dev_type)) {
104-
fmt = (struct nhlt_fmt *)(epnt->config.caps +
105-
epnt->config.size);
106-
sp_config = skl_get_specific_cfg(dev, fmt, num_ch,
107-
s_rate, bps, link_type);
108-
if (sp_config)
109-
return sp_config;
110-
}
111-
112-
epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
113-
}
114-
115-
return NULL;
116-
}
117-
11816
static void skl_nhlt_trim_space(char *trim)
11917
{
12018
char *s = trim;

sound/soc/intel/skylake/skl-pcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream,
317317
dev_dbg(dai->dev, "dma_id=%d\n", dma_id);
318318

319319
p_params.s_fmt = snd_pcm_format_width(params_format(params));
320+
p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
320321
p_params.ch = params_channels(params);
321322
p_params.s_freq = params_rate(params);
322323
p_params.host_dma_id = dma_id;
@@ -405,6 +406,7 @@ static int skl_be_hw_params(struct snd_pcm_substream *substream,
405406
struct skl_pipe_params p_params = {0};
406407

407408
p_params.s_fmt = snd_pcm_format_width(params_format(params));
409+
p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
408410
p_params.ch = params_channels(params);
409411
p_params.s_freq = params_rate(params);
410412
p_params.stream = substream->stream;
@@ -569,6 +571,7 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,
569571
snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
570572

571573
p_params.s_fmt = snd_pcm_format_width(params_format(params));
574+
p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
572575
p_params.ch = params_channels(params);
573576
p_params.s_freq = params_rate(params);
574577
p_params.stream = substream->stream;

sound/soc/intel/skylake/skl-topology.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
285285
{
286286
struct skl_module_cfg *m_cfg = w->priv;
287287
int link_type, dir;
288-
u32 ch, s_freq, s_fmt;
288+
u32 ch, s_freq, s_fmt, s_cont;
289289
struct nhlt_specific_cfg *cfg;
290290
u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type);
291291
int fmt_idx = m_cfg->fmt_idx;
@@ -301,7 +301,8 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
301301
link_type = NHLT_LINK_DMIC;
302302
dir = SNDRV_PCM_STREAM_CAPTURE;
303303
s_freq = m_iface->inputs[0].fmt.s_freq;
304-
s_fmt = m_iface->inputs[0].fmt.bit_depth;
304+
s_fmt = m_iface->inputs[0].fmt.valid_bit_depth;
305+
s_cont = m_iface->inputs[0].fmt.bit_depth;
305306
ch = m_iface->inputs[0].fmt.channels;
306307
break;
307308

@@ -310,12 +311,14 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
310311
if (m_cfg->hw_conn_type == SKL_CONN_SOURCE) {
311312
dir = SNDRV_PCM_STREAM_PLAYBACK;
312313
s_freq = m_iface->outputs[0].fmt.s_freq;
313-
s_fmt = m_iface->outputs[0].fmt.bit_depth;
314+
s_fmt = m_iface->outputs[0].fmt.valid_bit_depth;
315+
s_cont = m_iface->outputs[0].fmt.bit_depth;
314316
ch = m_iface->outputs[0].fmt.channels;
315317
} else {
316318
dir = SNDRV_PCM_STREAM_CAPTURE;
317319
s_freq = m_iface->inputs[0].fmt.s_freq;
318-
s_fmt = m_iface->inputs[0].fmt.bit_depth;
320+
s_fmt = m_iface->inputs[0].fmt.valid_bit_depth;
321+
s_cont = m_iface->inputs[0].fmt.bit_depth;
319322
ch = m_iface->inputs[0].fmt.channels;
320323
}
321324
break;
@@ -325,16 +328,17 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
325328
}
326329

327330
/* update the blob based on virtual bus_id and default params */
328-
cfg = skl_get_ep_blob(skl, m_cfg->vbus_id, link_type,
329-
s_fmt, ch, s_freq, dir, dev_type);
331+
cfg = intel_nhlt_get_endpoint_blob(skl->dev, skl->nhlt, m_cfg->vbus_id,
332+
link_type, s_fmt, s_cont, ch,
333+
s_freq, dir, dev_type);
330334
if (cfg) {
331335
m_cfg->formats_config[SKL_PARAM_INIT].caps_size = cfg->size;
332336
m_cfg->formats_config[SKL_PARAM_INIT].caps = (u32 *)&cfg->caps;
333337
} else {
334338
dev_err(skl->dev, "Blob NULL for id %x type %d dirn %d\n",
335339
m_cfg->vbus_id, link_type, dir);
336-
dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d\n",
337-
ch, s_freq, s_fmt);
340+
dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d/%d\n",
341+
ch, s_freq, s_fmt, s_cont);
338342
return -EIO;
339343
}
340344

@@ -1849,10 +1853,11 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai,
18491853
pipe_fmt = &pipe->configs[pipe->pipe_config_idx].in_fmt;
18501854

18511855
/* update the blob based on virtual bus_id*/
1852-
cfg = skl_get_ep_blob(skl, mconfig->vbus_id, link_type,
1853-
pipe_fmt->bps, pipe_fmt->channels,
1854-
pipe_fmt->freq, pipe->direction,
1855-
dev_type);
1856+
cfg = intel_nhlt_get_endpoint_blob(dai->dev, skl->nhlt,
1857+
mconfig->vbus_id, link_type,
1858+
pipe_fmt->bps, params->s_cont,
1859+
pipe_fmt->channels, pipe_fmt->freq,
1860+
pipe->direction, dev_type);
18561861
if (cfg) {
18571862
mconfig->formats_config[SKL_PARAM_INIT].caps_size = cfg->size;
18581863
mconfig->formats_config[SKL_PARAM_INIT].caps = (u32 *)&cfg->caps;

sound/soc/intel/skylake/skl-topology.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ struct skl_pipe_params {
284284
u32 ch;
285285
u32 s_freq;
286286
u32 s_fmt;
287+
u32 s_cont;
287288
u8 linktype;
288289
snd_pcm_format_t format;
289290
int link_index;

sound/soc/intel/skylake/skl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ struct skl_dsp_ops {
165165
int skl_platform_unregister(struct device *dev);
166166
int skl_platform_register(struct device *dev);
167167

168-
struct nhlt_specific_cfg *skl_get_ep_blob(struct skl_dev *skl, u32 instance,
169-
u8 link_type, u8 s_fmt, u8 num_ch,
170-
u32 s_rate, u8 dirn, u8 dev_type);
171-
172168
int skl_nhlt_update_topology_bin(struct skl_dev *skl);
173169
int skl_init_dsp(struct skl_dev *skl);
174170
int skl_free_dsp(struct skl_dev *skl);

0 commit comments

Comments
 (0)