Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions sound/soc/sof/amd/acp-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@ int acp_sof_ipc_msg_data(struct snd_sof_dev *sdev, struct snd_pcm_substream *sub
}
EXPORT_SYMBOL_NS(acp_sof_ipc_msg_data, SND_SOC_SOF_AMD_COMMON);

int acp_sof_ipc_pcm_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
{
/* TODO: Implement stream hw params to validate stream offset */
return 0;
}
EXPORT_SYMBOL_NS(acp_sof_ipc_pcm_params, SND_SOC_SOF_AMD_COMMON);

int acp_sof_ipc_get_mailbox_offset(struct snd_sof_dev *sdev)
{
return ACP_SCRATCH_MEMORY_ADDRESS;
Expand Down
15 changes: 9 additions & 6 deletions sound/soc/sof/amd/acp-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
#include "acp-dsp-offset.h"

int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params)
struct snd_pcm_hw_params *params,
struct snd_sof_platform_stream_params *platform_params)
{
struct acp_dsp_stream *stream = substream->runtime->private_data;
struct snd_pcm_runtime *runtime = substream->runtime;
struct acp_dsp_stream *stream = runtime->private_data;
unsigned int buf_offset, index;
u32 size;
int ret;

size = ipc_params->buffer.size;
stream->num_pages = ipc_params->buffer.pages;
size = runtime->dma_bytes;
stream->num_pages = PFN_UP(runtime->dma_bytes);
stream->dmab = substream->runtime->dma_buffer_p;

ret = acp_dsp_stream_config(sdev, stream);
Expand All @@ -34,8 +36,9 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr
return ret;
}

ipc_params->buffer.phy_addr = stream->reg_offset;
ipc_params->stream_tag = stream->stream_tag;
platform_params->use_phy_address = true;
platform_params->phy_addr = stream->reg_offset;
platform_params->stream_tag = stream->stream_tag;

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

Expand Down
5 changes: 2 additions & 3 deletions sound/soc/sof/amd/acp.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ int acp_sof_ipc_send_msg(struct snd_sof_dev *sdev,
struct snd_sof_ipc_msg *msg);
int acp_sof_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
int acp_sof_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
int acp_sof_ipc_pcm_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply);
void acp_mailbox_write(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes);
void acp_mailbox_read(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes);

Expand All @@ -202,7 +200,8 @@ int acp_dsp_stream_put(struct snd_sof_dev *sdev, struct acp_dsp_stream *acp_stre
int acp_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params);
struct snd_pcm_hw_params *params,
struct snd_sof_platform_stream_params *platform_params);

extern const struct snd_sof_dsp_ops sof_renoir_ops;

Expand Down
1 change: 0 additions & 1 deletion sound/soc/sof/amd/renoir.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ const struct snd_sof_dsp_ops sof_renoir_ops = {
/*IPC */
.send_msg = acp_sof_ipc_send_msg,
.ipc_msg_data = acp_sof_ipc_msg_data,
.ipc_pcm_params = acp_sof_ipc_pcm_params,
.get_mailbox_offset = acp_sof_ipc_get_mailbox_offset,
.irq_thread = acp_sof_ipc_irq_thread,
.fw_ready = sof_fw_ready,
Expand Down
3 changes: 1 addition & 2 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
if (!sof_ops(sdev) || !sof_ops(sdev)->probe || !sof_ops(sdev)->run ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit description need to be updated , it still says "pcm_set_pipeline_offset() callback." while it's renamed to stream_data_offset()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is always one left ;)
I will fix it right away, thanks for spotting it!

!sof_ops(sdev)->block_read || !sof_ops(sdev)->block_write ||
!sof_ops(sdev)->send_msg || !sof_ops(sdev)->load_firmware ||
!sof_ops(sdev)->ipc_msg_data || !sof_ops(sdev)->ipc_pcm_params ||
!sof_ops(sdev)->fw_ready) {
!sof_ops(sdev)->ipc_msg_data || !sof_ops(sdev)->fw_ready) {
dev_err(dev, "error: missing mandatory ops\n");
return -EINVAL;
}
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/sof/imx/imx8.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static const struct snd_sof_dsp_ops sof_imx8_ops = {
.get_window_offset = imx8_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* module loading */
.load_module = snd_sof_parse_module_memcpy,
Expand Down Expand Up @@ -572,7 +572,7 @@ static const struct snd_sof_dsp_ops sof_imx8x_ops = {
.get_window_offset = imx8_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* module loading */
.load_module = snd_sof_parse_module_memcpy,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/imx/imx8m.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static const struct snd_sof_dsp_ops sof_imx8m_ops = {
.get_window_offset = imx8m_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* module loading */
.load_module = snd_sof_parse_module_memcpy,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/apl.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
.get_window_offset = hda_dsp_ipc_get_window_offset,

.ipc_msg_data = hda_ipc_msg_data,
.ipc_pcm_params = hda_ipc_pcm_params,
.set_stream_data_offset = hda_set_stream_data_offset,

/* machine driver */
.machine_select = hda_machine_select,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/bdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
.get_window_offset = bdw_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* machine driver */
.machine_select = bdw_machine_select,
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/sof/intel/byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.get_window_offset = atom_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* machine driver */
.machine_select = atom_machine_select,
Expand Down Expand Up @@ -332,7 +332,7 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.get_window_offset = atom_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* machine driver */
.machine_select = atom_machine_select,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/cnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
.get_window_offset = hda_dsp_ipc_get_window_offset,

.ipc_msg_data = hda_ipc_msg_data,
.ipc_pcm_params = hda_ipc_pcm_params,
.set_stream_data_offset = hda_set_stream_data_offset,

/* machine driver */
.machine_select = hda_machine_select,
Expand Down
8 changes: 3 additions & 5 deletions sound/soc/sof/intel/hda-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,12 @@ int hda_ipc_msg_data(struct snd_sof_dev *sdev,
return 0;
}

int hda_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
int hda_set_stream_data_offset(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
size_t posn_offset)
{
struct hdac_stream *hstream = substream->runtime->private_data;
struct sof_intel_hda_stream *hda_stream;
/* validate offset */
size_t posn_offset = reply->posn_offset;

hda_stream = container_of(hstream, struct sof_intel_hda_stream,
hext_stream.hstream);
Expand Down
18 changes: 4 additions & 14 deletions sound/soc/sof/intel/hda-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ u32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits)
int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct sof_ipc_stream_params *ipc_params)
struct snd_sof_platform_stream_params *platform_params)
{
struct hdac_stream *hstream = substream->runtime->private_data;
struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
struct snd_dma_buffer *dmab;
struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
int ret;
u32 size, rate, bits;

Expand Down Expand Up @@ -130,19 +129,10 @@ int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
else
hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_DISABLE, 0);

/* update no_stream_position flag for ipc params */
if (hda && hda->no_ipc_position) {
/* For older ABIs set host_period_bytes to zero to inform
* FW we don't want position updates. Newer versions use
* no_stream_position for this purpose.
*/
if (v->abi_version < SOF_ABI_VER(3, 10, 0))
ipc_params->host_period_bytes = 0;
else
ipc_params->no_stream_position = 1;
}
if (hda)
platform_params->no_ipc_position = hda->no_ipc_position;

ipc_params->stream_tag = hstream->stream_tag;
platform_params->stream_tag = hstream->stream_tag;

return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/intel/hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct sof_ipc_stream_params *ipc_params);
struct snd_sof_platform_stream_params *platform_params);
int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
Expand Down Expand Up @@ -566,9 +566,9 @@ int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
int hda_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz);
int hda_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply);
int hda_set_stream_data_offset(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
size_t posn_offset);

/*
* DSP IPC Operations.
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/icl.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const struct snd_sof_dsp_ops sof_icl_ops = {
.get_window_offset = hda_dsp_ipc_get_window_offset,

.ipc_msg_data = hda_ipc_msg_data,
.ipc_pcm_params = hda_ipc_pcm_params,
.set_stream_data_offset = hda_set_stream_data_offset,

/* machine driver */
.machine_select = hda_machine_select,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/pci-tng.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.get_window_offset = atom_get_window_offset,

.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,
.set_stream_data_offset = sof_set_stream_data_offset,

/* machine driver */
.machine_select = atom_machine_select,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/tgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const struct snd_sof_dsp_ops sof_tgl_ops = {
.get_window_offset = hda_dsp_ipc_get_window_offset,

.ipc_msg_data = hda_ipc_msg_data,
.ipc_pcm_params = hda_ipc_pcm_params,
.set_stream_data_offset = hda_set_stream_data_offset,

/* machine driver */
.machine_select = hda_machine_select,
Expand Down
21 changes: 12 additions & 9 deletions sound/soc/sof/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ static inline int
snd_sof_pcm_platform_hw_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct sof_ipc_stream_params *ipc_params)
struct snd_sof_platform_stream_params *platform_params)
{
if (sof_ops(sdev) && sof_ops(sdev)->pcm_hw_params)
return sof_ops(sdev)->pcm_hw_params(sdev, substream,
params, ipc_params);
return sof_ops(sdev)->pcm_hw_params(sdev, substream, params,
platform_params);

return 0;
}
Expand Down Expand Up @@ -466,14 +466,17 @@ static inline int snd_sof_ipc_msg_data(struct snd_sof_dev *sdev,
{
return sof_ops(sdev)->ipc_msg_data(sdev, substream, p, sz);
}

/* host configure DSP HW parameters */
/* host side configuration of the stream's data offset in stream mailbox area */
static inline int
snd_sof_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
snd_sof_set_stream_data_offset(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
size_t posn_offset)
{
return sof_ops(sdev)->ipc_pcm_params(sdev, substream, reply);
if (sof_ops(sdev) && sof_ops(sdev)->set_stream_data_offset)
return sof_ops(sdev)->set_stream_data_offset(sdev, substream,
posn_offset);

return 0;
}

/* host stream pointer */
Expand Down
45 changes: 26 additions & 19 deletions sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ static int create_page_table(struct snd_soc_component *component,
spcm->stream[stream].page_table.area, size);
}

static int sof_pcm_dsp_params(struct snd_sof_pcm *spcm, struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
{
struct snd_soc_component *scomp = spcm->scomp;
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);

/* validate offset */
int ret = snd_sof_ipc_pcm_params(sdev, substream, reply);

if (ret < 0)
dev_err(scomp->dev, "error: got wrong reply for PCM %d\n",
spcm->pcm.pcm_id);

return ret;
}

/*
* sof pcm period elapse work
*/
Expand Down Expand Up @@ -162,6 +146,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_platform_stream_params platform_params = { 0 };
struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
struct snd_sof_pcm *spcm;
struct sof_ipc_pcm_params pcm;
struct sof_ipc_pcm_params_reply ipc_params_reply;
Expand Down Expand Up @@ -242,12 +228,29 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
ret = snd_sof_pcm_platform_hw_params(sdev,
substream,
params,
&pcm.params);
&platform_params);
if (ret < 0) {
dev_err(component->dev, "error: platform hw params failed\n");
return ret;
}

/* Update the IPC message with information from the platform */
pcm.params.stream_tag = platform_params.stream_tag;

if (platform_params.use_phy_address)
pcm.params.buffer.phy_addr = platform_params.phy_addr;

if (platform_params.no_ipc_position) {
/* For older ABIs set host_period_bytes to zero to inform
* FW we don't want position updates. Newer versions use
* no_stream_position for this purpose.
*/
if (v->abi_version < SOF_ABI_VER(3, 10, 0))
pcm.params.host_period_bytes = 0;
else
pcm.params.no_stream_position = 1;
}

dev_dbg(component->dev, "stream_tag %d", pcm.params.stream_tag);

/* if this is a repeated hw_params without hw_free, skip setting up widgets */
Expand All @@ -266,9 +269,13 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
return ret;
}

ret = sof_pcm_dsp_params(spcm, substream, &ipc_params_reply);
if (ret < 0)
ret = snd_sof_set_stream_data_offset(sdev, substream,
ipc_params_reply.posn_offset);
if (ret < 0) {
dev_err(component->dev, "%s: invalid stream data offset for PCM %d\n",
__func__, spcm->pcm.pcm_id);
return ret;
}

spcm->prepared[substream->stream] = true;

Expand Down
Loading