Skip to content

Commit 9cce2ad

Browse files
ujfalusiplbossart
authored andcommitted
ASoC: SOF: Make pcm_hw_params snd_sof_dsp_ops callback IPC neutral
Do not send IPC structure directly via pcm_hw_params to make it IPC agnostic. A new struct is created to retrieve the needed platform parameters and if there is a need it can be extended with new options. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 3a0aa29 commit 9cce2ad

7 files changed

Lines changed: 51 additions & 24 deletions

File tree

sound/soc/sof/amd/acp-pcm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#include "acp-dsp-offset.h"
1818

1919
int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
20-
struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params)
20+
struct snd_pcm_hw_params *params,
21+
struct snd_sof_platform_stream_params *platform_params)
2122
{
2223
struct snd_pcm_runtime *runtime = substream->runtime;
2324
struct acp_dsp_stream *stream = runtime->private_data;
@@ -35,8 +36,9 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr
3536
return ret;
3637
}
3738

38-
ipc_params->buffer.phy_addr = stream->reg_offset;
39-
ipc_params->stream_tag = stream->stream_tag;
39+
platform_params->use_phy_address = true;
40+
platform_params->phy_addr = stream->reg_offset;
41+
platform_params->stream_tag = stream->stream_tag;
4042

4143
/* write buffer size of stream in scratch memory */
4244

sound/soc/sof/amd/acp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ int acp_dsp_stream_put(struct snd_sof_dev *sdev, struct acp_dsp_stream *acp_stre
202202
int acp_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
203203
int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
204204
int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
205-
struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params);
205+
struct snd_pcm_hw_params *params,
206+
struct snd_sof_platform_stream_params *platform_params);
206207

207208
extern const struct snd_sof_dsp_ops sof_renoir_ops;
208209

sound/soc/sof/intel/hda-pcm.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ u32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits)
9393
int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
9494
struct snd_pcm_substream *substream,
9595
struct snd_pcm_hw_params *params,
96-
struct sof_ipc_stream_params *ipc_params)
96+
struct snd_sof_platform_stream_params *platform_params)
9797
{
9898
struct hdac_stream *hstream = substream->runtime->private_data;
9999
struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
100100
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
101101
struct snd_dma_buffer *dmab;
102-
struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
103102
int ret;
104103
u32 size, rate, bits;
105104

@@ -130,19 +129,10 @@ int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
130129
else
131130
hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_DISABLE, 0);
132131

133-
/* update no_stream_position flag for ipc params */
134-
if (hda && hda->no_ipc_position) {
135-
/* For older ABIs set host_period_bytes to zero to inform
136-
* FW we don't want position updates. Newer versions use
137-
* no_stream_position for this purpose.
138-
*/
139-
if (v->abi_version < SOF_ABI_VER(3, 10, 0))
140-
ipc_params->host_period_bytes = 0;
141-
else
142-
ipc_params->no_stream_position = 1;
143-
}
132+
if (hda)
133+
platform_params->no_ipc_position = hda->no_ipc_position;
144134

145-
ipc_params->stream_tag = hstream->stream_tag;
135+
platform_params->stream_tag = hstream->stream_tag;
146136

147137
return 0;
148138
}

sound/soc/sof/intel/hda.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
524524
int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
525525
struct snd_pcm_substream *substream,
526526
struct snd_pcm_hw_params *params,
527-
struct sof_ipc_stream_params *ipc_params);
527+
struct snd_sof_platform_stream_params *platform_params);
528528
int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
529529
struct snd_pcm_substream *substream);
530530
int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,

sound/soc/sof/ops.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ static inline int
420420
snd_sof_pcm_platform_hw_params(struct snd_sof_dev *sdev,
421421
struct snd_pcm_substream *substream,
422422
struct snd_pcm_hw_params *params,
423-
struct sof_ipc_stream_params *ipc_params)
423+
struct snd_sof_platform_stream_params *platform_params)
424424
{
425425
if (sof_ops(sdev) && sof_ops(sdev)->pcm_hw_params)
426-
return sof_ops(sdev)->pcm_hw_params(sdev, substream,
427-
params, ipc_params);
426+
return sof_ops(sdev)->pcm_hw_params(sdev, substream, params,
427+
platform_params);
428428

429429
return 0;
430430
}

sound/soc/sof/pcm.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
162162
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
163163
struct snd_pcm_runtime *runtime = substream->runtime;
164164
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
165+
struct snd_sof_platform_stream_params platform_params = { 0 };
166+
struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
165167
struct snd_sof_pcm *spcm;
166168
struct sof_ipc_pcm_params pcm;
167169
struct sof_ipc_pcm_params_reply ipc_params_reply;
@@ -242,12 +244,29 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
242244
ret = snd_sof_pcm_platform_hw_params(sdev,
243245
substream,
244246
params,
245-
&pcm.params);
247+
&platform_params);
246248
if (ret < 0) {
247249
dev_err(component->dev, "error: platform hw params failed\n");
248250
return ret;
249251
}
250252

253+
/* Update the IPC message with information from the platform */
254+
pcm.params.stream_tag = platform_params.stream_tag;
255+
256+
if (platform_params.use_phy_address)
257+
pcm.params.buffer.phy_addr = platform_params.phy_addr;
258+
259+
if (platform_params.no_ipc_position) {
260+
/* For older ABIs set host_period_bytes to zero to inform
261+
* FW we don't want position updates. Newer versions use
262+
* no_stream_position for this purpose.
263+
*/
264+
if (v->abi_version < SOF_ABI_VER(3, 10, 0))
265+
pcm.params.host_period_bytes = 0;
266+
else
267+
pcm.params.no_stream_position = 1;
268+
}
269+
251270
dev_dbg(component->dev, "stream_tag %d", pcm.params.stream_tag);
252271

253272
/* if this is a repeated hw_params without hw_free, skip setting up widgets */

sound/soc/sof/sof-priv.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ struct snd_soc_tplg_ops;
103103
struct snd_soc_component;
104104
struct snd_sof_pdata;
105105

106+
/**
107+
* struct snd_sof_platform_stream_params - platform dependent stream parameters
108+
* @stream_tag: Stream tag to use
109+
* @use_phy_addr: Use the provided @phy_addr for configuration
110+
* @phy_addr: Platform dependent address to be used, if @use_phy_addr
111+
* is true
112+
* @no_ipc_position: Disable position update IPC from firmware
113+
*/
114+
struct snd_sof_platform_stream_params {
115+
u16 stream_tag;
116+
bool use_phy_address;
117+
u32 phy_addr;
118+
bool no_ipc_position;
119+
};
120+
106121
/*
107122
* SOF DSP HW abstraction operations.
108123
* Used to abstract DSP HW architecture and any IO busses between host CPU
@@ -181,7 +196,7 @@ struct snd_sof_dsp_ops {
181196
int (*pcm_hw_params)(struct snd_sof_dev *sdev,
182197
struct snd_pcm_substream *substream,
183198
struct snd_pcm_hw_params *params,
184-
struct sof_ipc_stream_params *ipc_params); /* optional */
199+
struct snd_sof_platform_stream_params *platform_params); /* optional */
185200

186201
/* host stream hw_free */
187202
int (*pcm_hw_free)(struct snd_sof_dev *sdev,

0 commit comments

Comments
 (0)