Skip to content

ASoC: SOF: Make sof_pcm_hw_params() callback path to be IPC neutral - #3303

Merged
plbossart merged 12 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/pcm_hw_params_neutral_01
Dec 6, 2021
Merged

plbossart merged 12 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/pcm_hw_params_neutral_01

Conversation

@ujfalusi

@ujfalusi ujfalusi commented Dec 1, 2021

Copy link
Copy Markdown
Collaborator

Hi,

in the current implementation in the sof_pcm_hw_params() path we are passing IPC structures via callbacks from core to platform code to be used and/or to be updated.

This PR converts these callbacks to be IPC neutral while preserving their functionality which will allow us to create simple IPC dependent functions to deal with IPC messages based on the information we have, thus making the core functions completely IPC independent.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work @ujfalusi
I added a couple of comments (typos and renaming suggestions), but no objections on the directions.

Comment thread sound/soc/sof/sof-priv.h Resolved
Comment thread sound/soc/sof/sof-priv.h Resolved
Comment thread sound/soc/sof/pcm.c Resolved
Comment thread sound/soc/sof/ops.h Resolved
ranj063
ranj063 previously approved these changes Dec 1, 2021

@ranj063 ranj063 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice work @ujfalusi

@ujfalusi
ujfalusi force-pushed the peter/sof/pr/pcm_hw_params_neutral_01 branch from a5a03fc to 0a6b7df Compare December 1, 2021 16:54
@ujfalusi

ujfalusi commented Dec 1, 2021

Copy link
Copy Markdown
Collaborator Author

Changes since v1:

  • Rename all instances of set_pipeline_offset to set_stream_data_offset
  • Corrected the typos

plbossart
plbossart previously approved these changes Dec 1, 2021

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need @dbaluta and @ajitkupandey to review (NXP and AMD-related changes)

ranj063
ranj063 previously approved these changes Dec 1, 2021
ajitkupandey
ajitkupandey previously approved these changes Dec 2, 2021

@ajitkupandey ajitkupandey left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks really good, just a minor comment with commit description

Comment thread sound/soc/sof/core.c
@@ -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!

…laration

The implementation for snd_sof_ipc_stream_pcm_params() does not exist,
remove it from the header file.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Instead of using the values from ipc_params, take them directly from
substream->runtime.

This is in preparation of making the platform hw_params callback to be
IPC agnostic.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
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>
Call directly for snd_sof_ipc_pcm_params() from sof_pcm_hw_params() and
remove the wrapper for it.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
RanderWang
RanderWang previously approved these changes Dec 2, 2021
Each running audio stream's data have distinct start offset within the
stream mailbox area from/to where the host can read/write.

Instead of using the struct sof_ipc_pcm_params_reply to configure this
offset, add an optional callback which is IPC agnostic.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi
ujfalusi dismissed stale reviews from RanderWang and ajitkupandey via d173012 December 2, 2021 14:01
@ujfalusi
ujfalusi dismissed stale reviews from ranj063 and plbossart via d173012 December 2, 2021 14:01
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/pcm_hw_params_neutral_01 branch from 0a6b7df to d173012 Compare December 2, 2021 14:01
AMD is only implementing an empty function to pass the required test and
it is going to be deprecated in favor of the IPC agnostic
set_stream_data_offset() callback.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Add implementation for the generic set_stream_data_offset() callback in
core to be used by platforms.

Convert the sof_ipc_pcm_params() to a wrapper for the new function.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Add implementation for the generic set_stream_data_offset() callback to be
used by HDA platforms.

Convert the hda_ipc_pcm_params() to a wrapper for the new function.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Switch from the IPC dependent ipc_pcm_params() ops to the IPC neutral
set_stream_data_offset().

Remove the no longer used hda_ipc_pcm_params() function as well.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The ipc_pcm_params() ops implementation for AMD is a NOP and since the
callback is marked now as optional, it can be dropped along with the
empty function.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Switch from the IPC dependent ipc_pcm_params() ops to the IPC neutral
set_stream_data_offset().

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
All users have been converted to use the IPC agnostic
set_stream_data_offsett()

Remove all code related to the old API.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi

ujfalusi commented Dec 2, 2021

Copy link
Copy Markdown
Collaborator Author

Changes since v2:

  • Removed leftover remains of pipeline_offset from commit message and one comment in pcm.c

@plbossart

Copy link
Copy Markdown
Member

let's wait on @dbaluta review.

@dbaluta

dbaluta commented Dec 5, 2021

Copy link
Copy Markdown
Collaborator

@ujfalusi it looks good to me. The only thing I didn't fully internalized is what is the reason for this change? I mean OK it is fine to have hw_params to be IPC neutral but is there a future change that will benefit from this?

@ranj063

ranj063 commented Dec 5, 2021 •

Copy link
Copy Markdown
Collaborator

@ujfalusi it looks good to me. The only thing I didn't fully internalized is what is the reason for this change? I mean OK it is fine to have hw_params to be IPC neutral but is there a future change that will benefit from this?

@dbaluta this is in preparation for introducing IPC4 which will be using new structures for IPC payload. Without this change, we'd struggle with a clean separation of sequences for the 2 different IPC versions.

@dbaluta

dbaluta commented Dec 5, 2021

Copy link
Copy Markdown
Collaborator

@dbaluta this is in preparation for introducing IPC4 which will be using new structures for IPC payload. Without this change, we'd struggle with a clean separation of sequences for the 2 different IPC versions.

That was a good explanation. @ujfalusi is there any way to squash this information in one of the commits?

@ranj063

ranj063 commented Dec 5, 2021

Copy link
Copy Markdown
Collaborator

That was a good explanation. @ujfalusi is there any way to squash this information in one of the commits?

@dbaluta we cannclude the explanation with more details in the cover letter before sending upstream. There are more patches coming with a similar theme #3287

@plbossart
plbossart merged commit ab814f9 into thesofproject:topic/sof-dev Dec 6, 2021
@ujfalusi
ujfalusi deleted the peter/sof/pr/pcm_hw_params_neutral_01 branch November 18, 2022 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants