Skip to content

Conversation

@bardliao
Copy link
Collaborator

@bardliao bardliao commented Sep 28, 2022

The corresponding IPC4 module of snd_soc_dapm_buffer widget is module
-to-module copier.
The module-to-module copier is a buffer-like component with demuxing
capabilities.
Rename the host_token_list to common_copier_token_list since it will
be used by host copier and module-to-module copier.
The setup callback is almost the same as sof_ipc4_widget_setup_pcm except
the gtw_cfg data, and the free callback is exactly the same as
sof_ipc4_widget_free_comp_pcm. To reduce the duplication, the commit
reuses the setup and free callbacks.

The topology PR is thesofproject/sof#6329.

@RanderWang @aiChaoSONG @libinyang Could you take a look?

@aiChaoSONG
Copy link

Do we have firmware log here? what firmware are you used?

@RanderWang
Copy link

@bardliao As I suggested, the last four dword should be "000000, ffffffff, 0000000, 000000" // invalid node id for non-gtw

[  118.230600] Message payload: 00000000: 0000066f 00000180 00000180 00000001
[  118.230602] Message payload: 00000010: 0000bb80 00000020 ffffff10 00000001
[  118.230604] Message payload: 00000020: 00000000 00002002 0000bb80 00000020
[  118.230606] Message payload: 00000030: ffffff10 00000001 00000000 00002002
[  118.230608] Message payload: 00000040: 00000000 00000000 00000300 00000000

@bardliao
Copy link
Collaborator Author

@bardliao As I suggested, the last four dword should be "000000, ffffffff, 0000000, 000000" // invalid node id for non-gtw

[  118.230600] Message payload: 00000000: 0000066f 00000180 00000180 00000001
[  118.230602] Message payload: 00000010: 0000bb80 00000020 ffffff10 00000001
[  118.230604] Message payload: 00000020: 00000000 00002002 0000bb80 00000020
[  118.230606] Message payload: 00000030: ffffff10 00000001 00000000 00002002
[  118.230608] Message payload: 00000040: 00000000 00000000 00000300 00000000

Thanks @RanderWang I will try it.

@bardliao
Copy link
Collaborator Author

bardliao commented Oct 3, 2022

@bardliao As I suggested, the last four dword should be "000000, ffffffff, 0000000, 000000" // invalid node id for non-gtw

[  118.230600] Message payload: 00000000: 0000066f 00000180 00000180 00000001
[  118.230602] Message payload: 00000010: 0000bb80 00000020 ffffff10 00000001
[  118.230604] Message payload: 00000020: 00000000 00002002 0000bb80 00000020
[  118.230606] Message payload: 00000030: ffffff10 00000001 00000000 00002002
[  118.230608] Message payload: 00000040: 00000000 00000000 00000300 00000000

Thanks @RanderWang I will try it.

Thanks @RanderWang. Your suggestion works with SOF.

@plbossart @ranj063 @RanderWang I have an open on this PR. What dapm type should we use for the "module" type copier? It is snd_soc_dapm_buffer in this PR, but I am wondering is it the best one?

@bardliao bardliao force-pushed the copier-module-type branch 3 times, most recently from 9b949ab to 381bc16 Compare October 3, 2022 09:48
@aiChaoSONG
Copy link

aiChaoSONG commented Oct 9, 2022

What dapm type should we use for the "module" type copier? It is snd_soc_dapm_buffer in this PR, but I am wondering is it the best one?

I think it should be snd_soc_dapm_effect, because in this circumstance, the copier works just like a demux, and I think its init and configure can be covered by Libin's PR: #3755. I am just wondering if we really want to have special code for module copier?

@plbossart
Copy link
Member

What's wrong with:

	snd_soc_dapm_demux,			/* connects the input to one of multiple outputs */

That's exactly what a copier does, doesn't it?

@bardliao
Copy link
Collaborator Author

What dapm type should we use for the "module" type copier? It is snd_soc_dapm_buffer in this PR, but I am wondering is it the best one?

I think it should be snd_soc_dapm_effect, because in this circumstance, the copier works just like a demux, and I think its init and configure can be covered by Libin's PR: #3755. I am just wondering if we really want to have special code for module copier?

@aiChaoSONG We already support copier module for host and dai. We can reuse the existing code if we add its ops in tplg_ipc4_widget_ops. And IMHO, demux is not an effect.

What's wrong with:

	snd_soc_dapm_demux,			/* connects the input to one of multiple outputs */

That's exactly what a copier does, doesn't it?

@plbossart In this specific use case, yes. But copier can also simply do format conversion. And I would like to use the same sof_ipc_tplg_widget_ops for both use cases.

@RanderWang
Copy link

What's wrong with:

	snd_soc_dapm_demux,			/* connects the input to one of multiple outputs */

That's exactly what a copier does, doesn't it?

copier can accept 1 input and duplicate to max 4 outputs

@ranj063
Copy link
Collaborator

ranj063 commented Oct 14, 2022

What's wrong with:

	snd_soc_dapm_demux,			/* connects the input to one of multiple outputs */

That's exactly what a copier does, doesn't it?

@plbossart the demux we have in SOF need kcontrol data isnt it whereas the copier doesnt it. If we call this type of copier a demux, we'll need to differentiate between the SOF demux component and the copier with UUIDs. I suppose its not so bad but I somehow like the "buffer" type better

@bardliao
Copy link
Collaborator Author

We can't use snd_soc_dapm_demux as there is no such tplg dapm type defined for now.
https://github.com/torvalds/linux/blob/master/include/uapi/sound/asoc.h#L56
https://github.com/alsa-project/alsa-lib/blob/master/src/topology/dapm.c#L24
So I will go with snd_soc_dapm_buffer

@bardliao bardliao changed the title [TEST] ASoC: SOF: ipc4-topology: add copier module type support ASoC: SOF: ipc4-topology: add copier module type support Oct 14, 2022
@bardliao bardliao force-pushed the copier-module-type branch 2 times, most recently from 427e0c0 to abc9f38 Compare October 14, 2022 06:17
@bardliao bardliao marked this pull request as ready for review October 14, 2022 06:32
RanderWang
RanderWang previously approved these changes Oct 26, 2022
Copy link

@RanderWang RanderWang left a comment

Choose a reason for hiding this comment

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

LGTM

ranj063
ranj063 previously approved these changes Oct 26, 2022
@bardliao
Copy link
Collaborator Author

@plbossart Could you review it? Thanks.

Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@bardliao, this "copier module" thing is basically a different configuration of the copier module, right?
We have copier on the DAI side, we have copier on the AIF side and this is somewhere else, likely in the middle.

It is a bit confusing to me at least the fact that we have separate setup and free callbacks for the two other type of copiers (this patch does not adds copier type support, it adds a buffer type of the copier) while you are re-using the AIF copier for the buffer copier.

I think it would be cleaner to just add a new setup and free for the buffer type of copier?

I would probably extend the commit message a bit since this is not obvious a bit.

The "module copier" is as meaningless as it can get, imho. I won't block this PR, but I really feel that it can be done cleaner.

@ranj063
Copy link
Collaborator

ranj063 commented Oct 28, 2022

It is a bit confusing to me at least the fact that we have separate setup and free callbacks for the two other type of copiers (this patch does not adds copier type support, it adds a buffer type of the copier) while you are re-using the AIF copier for the buffer copier.

@ujfalusi I asked to merge the set/free for cmodule copier and host copier parts. There was just too much code duplication with separate callbacks

@bardliao
Copy link
Collaborator Author

@bardliao, this "copier module" thing is basically a different configuration of the copier module, right?

Yes

We have copier on the DAI side, we have copier on the AIF side and this is somewhere else, likely in the middle.

Yes

It is a bit confusing to me at least the fact that we have separate setup and free callbacks for the two other type of copiers (this patch does not adds copier type support, it adds a buffer type of the copier) while you are re-using the AIF copier for the buffer copier.

I think it would be cleaner to just add a new setup and free for the buffer type of copier?

DAI and host copiers have separate setup and free callbacks because the callbacks don't look so similar.
However, the setup callbacks of module and host copiers are almost the same except the gtw_cfg data.
And the free callbacks of module and host copiers are exactly the same.
I call it module type instead of buffer type is because I would like to be aligned with topology definition.
See https://github.com/thesofproject/sof/blob/main/tools/topology/topology2/include/components/copier.conf#L50
The copier types are

				"HDA"
				"host"
				"SSP"
				"ALH"
				"DMIC"
				"module"

snd_soc_dapm_buffer is a dapm widget type and I use it to map to the module copier.

I would probably extend the commit message a bit since this is not obvious a bit.

Sure, I will try to explain it more in the commit message.

The "module copier" is as meaningless as it can get, imho. I won't block this PR, but I really feel that it can be done cleaner.

@bardliao bardliao dismissed stale reviews from ranj063 and RanderWang via 836d4dc October 31, 2022 06:21
@ujfalusi
Copy link
Collaborator

It is a bit confusing to me at least the fact that we have separate setup and free callbacks for the two other type of copiers (this patch does not adds copier type support, it adds a buffer type of the copier) while you are re-using the AIF copier for the buffer copier.
I think it would be cleaner to just add a new setup and free for the buffer type of copier?

DAI and host copiers have separate setup and free callbacks because the callbacks don't look so similar. However, the setup callbacks of module and host copiers are almost the same except the gtw_cfg data. And the free callbacks of module and host copiers are exactly the same. I call it module type instead of buffer type is because I would like to be aligned with topology definition. See https://github.com/thesofproject/sof/blob/main/tools/topology/topology2/include/components/copier.conf#L50 The copier types are

				"HDA"
				"host"
				"SSP"
				"ALH"
				"DMIC"
				"module"

But a horrible and meaningless name in firmware does no mean it is good, again imho.
Think about it: this is the copier module's module mode configuration. What?
We name the dai configuration of the copier module' as dai_copier instead of hda/ssp/alh/dmic_copier

Codewise I don't have issue with the PR, but I opt to not approve which is not to say that this should not be merged, but to say that I really not on the let's call the buffer (mux/mix/passthrough/conversion) mode of the copier module as module.

snd_soc_dapm_buffer is a dapm widget type and I use it to map to the module copier.

I would probably extend the commit message a bit since this is not obvious a bit.

Sure, I will try to explain it more in the commit message.

Thanks!

The "module copier" is as meaningless as it can get, imho. I won't block this PR, but I really feel that it can be done cleaner.

ranj063
ranj063 previously approved these changes Nov 1, 2022
RanderWang
RanderWang previously approved these changes Nov 1, 2022
@ranj063
Copy link
Collaborator

ranj063 commented Nov 1, 2022

@bardliao copier.module doesnt bring out the essensce of what this copier does. I understand where you're coming from ie the tester interface that uses this name. But if you want to convince reviewers and make it clearer, why not call it copier.module_to_module.blah. That way you know that it is a copier that goes between 2 other modules instead of DAI/host copier that are endpoint copiers

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

It seems that for this buffer handling sometimes we use AIF helpers and sometimes DAI tokens. This looks rather weird. It looks rather ad-hoc and could be clarified IMHO

Copy link
Member

Choose a reason for hiding this comment

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

why are we using a dai_token_list for something that is not a DAI?

This sounds bad to me, I would guess some tokens apply only for real DAIs and not for internal buffer handling?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why are we using a dai_token_list for something that is not a DAI?

This sounds bad to me, I would guess some tokens apply only for real DAIs and not for internal buffer handling?

Thanks @plbossart change it to host_token_list now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why are we using a dai_token_list for something that is not a DAI?
This sounds bad to me, I would guess some tokens apply only for real DAIs and not for internal buffer handling?

Thanks @plbossart change it to host_token_list now.

And rename it to common_copier_token_list after chatting with Ranjani.

Copy link
Member

Choose a reason for hiding this comment

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

I am a bit lost here, we are trying to reuse the same setup_pcm for AIF and internal buffer handling. So do we need a dma_buffer_size here? what does this mean for an internal buffer. Should this test be moved to line 349 instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am a bit lost here, we are trying to reuse the same setup_pcm for AIF and internal buffer handling. So do we need a dma_buffer_size here? what does this mean for an internal buffer. Should this test be moved to line 349 instead?

We don't need to get dma_buffer_size from topology. It should be always 0. But we need to allocate available_fmt->dma_buffer_size and it will be used in sof_ipc4_prepare_copier_module https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/ipc4-topology.c#L1358

Copy link
Member

Choose a reason for hiding this comment

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

you should capture this with a comment, this is useful information that explains the code structure.
this can be done with a fixup

@bardliao bardliao dismissed stale reviews from RanderWang and ranj063 via e5171d9 November 2, 2022 01:52
The corresponding IPC4 module of snd_soc_dapm_buffer widget is module
-to-module copier.
The module-to-module copier is a buffer-like component with demuxing
capabilities.
Rename the host_token_list to common_copier_token_list since it will
be used by host copier and module-to-module copier.
The setup callback is almost the same as sof_ipc4_widget_setup_pcm except
the gtw_cfg data, and the free callback is exactly the same as
sof_ipc4_widget_free_comp_pcm. To reduce the duplication, the commit
reuses the setup and free callbacks.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Copy link
Member

Choose a reason for hiding this comment

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

you should capture this with a comment, this is useful information that explains the code structure.
this can be done with a fixup

@plbossart plbossart requested review from ranj063 and ujfalusi November 2, 2022 12:44
Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@bardliao, thank you for the updates, looks great!

@plbossart
Copy link
Member

SOFCI TEST

@plbossart
Copy link
Member

no regressions beyond known issues, merging

@plbossart plbossart merged commit 69222fa into thesofproject:topic/sof-dev Nov 4, 2022
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