-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: ipc4-topology: update output hw_params in init audio fmt #4097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sound/soc/sof/ipc4-topology.c
Outdated
| if (out_format) { | ||
| memcpy(out_format, &available_fmt->out_audio_fmt[i], | ||
| sizeof(struct sof_ipc4_audio_format)); | ||
| ret = sof_update_hw_params(sdev, params, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang I dont get this. Previously we set the input params for the next module connected to the copier based on the output format set for Pin 0. Now you will keep overwriting the params with the output formats and what will stick is the last one, right? Am I understanding this correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support different output formats currently. The outputs of one widget should be the same. I heard Chao is working on different output formats. At that time we will support this feature.
This patch is just to find a general point to change the parameter. Copier may change the hw_params, and other modules may change the hw_params also, such as micsel, src. With this patch, we don't need to add a patch each time we support a new module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang can you please coordinate with @aiChaoSONG and come up with one fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang can you please coordinate with @aiChaoSONG and come up with one fix?
@ranj063 Thanks for the suggestion. We discussed it today and decide combine the 2 PR into one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063 Thanks for the suggestion. We discussed it today and decide combine the 2 PR into one.
Synced with Chao that he will not submit the hw_params update patch as SmartAMP doesn't need such feature. So I reopen this PR.
sound/soc/sof/ipc4-topology.c
Outdated
| i->max = val; | ||
| i->openmin = 0; | ||
| i->openmax = 0; | ||
| i->integer = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do the last 3 lines above do and what are they needed for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openmin and openmax means whether the min value and max value is included in the set or not. If open is set, the value is not included in the set. If we set min and max to the same, but they are open, this will be wrong. So we must set they are not open.
I think i->integer means this is a integer or not. Maybe we don't need to set i->integer as this should be set already. However I refer snd_interval_refine() at
Line 615 in 5694a58
| } else if (!i->openmin && !i->openmax && i->min == i->max) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang this sort of code doesn't seem be used in most drivers, i.e. there are exactly two occurrences of such code in the entire sound/soc tree. I would assert that this is needlessly complicated?
sound/soc$ git grep openmax
atmel/atmel_ssc_dai.c: t.openmin = t.openmax = 0;
sti/sti_uniperif.c: t.openmax = 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart The integer in atmel and sti belongs the local variable struct snd_interval t. The snd_interval_refine() will be called immediately after this setting. And the set of t.integer = 0 is just letting the integer in the local struct snd_interval t not impact integer in the hw_param's snd_interval i.
However I think integer may be not necessary to set in our case as the integer should already set before and don't need to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point @libinyang is that virtually no one else has played with this sort of constraints. That makes me question if this is a wise direction. This is a very very obscure part of ALSA, do we even want to look into this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart Yes. I agree we do not touch integer. Setting min, max, openmin and openmax is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're not getting the point @libinyang. Even openmin and openmax are not used very often, and not at all outside of codecs, so it's unclear to me why the SOF driver would need to be the first one to use these fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're not getting the point @libinyang. Even openmin and openmax are not used very often, and not at all outside of codecs, so it's unclear to me why the SOF driver would need to be the first one to use these fields.
I removed the openmin, openmax and integer updating in the new version as it is supposed that such setting should already be set correctly when open.
sound/soc/sof/ipc4-topology.c
Outdated
|
|
||
| snd_mask_none(m); | ||
| snd_mask_set_format(m, val); | ||
| } else if (hw_is_interval(var)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd return in the if {} block and remove the else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I will update it in the next version
|
Close it and Chao will help to merge this PR into #4096 |
18ceaf0 to
a2c1040
Compare
a2c1040 to
86b6913
Compare
sound/soc/sof/ipc4-topology.c
Outdated
|
|
||
| if (process->payload_with_output_fmt) { | ||
| ret = sof_update_hw_params(sdev, pipeline_params, | ||
| &available_fmt->out_audio_fmt[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang how was this tested? AFAICT i is uninitialized at this point. So what is available_fmt->out_audio_fmt[i]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang &available_fmt->out_audio_fmt[i] should be &process->output_format, right? IIRC, the origin PR updated pipeline_params in sof_ipc4_init_audio_fmt and it can cover all copier widgets. But now you update pipeline_params here. It means @RanderWang need to update pipeline_params in sof_ipc4_prepare_copier_module since he need to convert the format in a buffer type copier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang how was this tested? AFAICT i is uninitialized at this point. So what is available_fmt->out_audio_fmt[i]?
@ranj063 Thanks for pointing it out. I copied the code from my origin code and didn't do the corresponding changing.
&available_fmt->out_audio_fmt[i] should be &process->output_format, right?
Yes, Thanks for suggestion @bardliao.
86b6913 to
d362d14
Compare
sound/soc/sof/ipc4-topology.c
Outdated
|
|
||
| /* update hw_params based on the audio stream format */ | ||
| static int sof_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw_params *params, | ||
| struct sof_ipc4_audio_format *fmt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be sof_ipc4_update_hw_params() but it is actually forcing a single configuration to the pointed hw_params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I will rename the function. It updates the snd_pcm_hw_params based on the module instance output.
sound/soc/sof/ipc4-topology.c
Outdated
| return 0; | ||
| } | ||
|
|
||
| static void sof_update_hw_param(struct snd_pcm_hw_params *params, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you really need this function? Can we just set these in the function below directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will do it.
sound/soc/sof/ipc4-topology.c
Outdated
| return; | ||
| } | ||
|
|
||
| /* if params is not snd_mask, then it is snd_interval */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont quite understand what this statemeant means "if params is not snd_mask, then it is snd_interval". "params" is obviously not snd_mask. it is snd_pcm_ha_params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I mean snd_pcm_hw_param_t var to determine whether it is a snd_mask or snd_interval. Anyway, I will merge this function into sof_update_hw_params() as you suggested. So we don't need this function.
Some process modules output hw_params is different from its input hw_params. Let's add a common help function to support this feature. And update the hw_params in process module prepare callback. Signed-off-by: Libin Yang <libin.yang@intel.com>
d362d14 to
95f2d4e
Compare
|
patch updated:
|
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| if (process->payload_with_output_fmt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang IIUC this flag is only applicable for modules that are built into the base FW. Why do we only update the pipeline params only for base FW modules and not all external modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063, I don't get why we are locking module features to their position (in or out of basefw). When loaded to the DSP, it is there, does not matter if it was loaded as part of the base library or as an external library.
This flag is telling that the given module's MOD_INIT_INSTANCE message should also have this extra output format section, it is irrelevant how that module got into the RAM of the DSP.
imho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ujfalusi you are right once it is in the DSP, it is there. But this part is before it is initialized in the DSP and how we initialize them is very module implementation specific. Unfortunately for us, there is a difference between how a module in the base FW in initialized and how external module is initialized.
But to clarify my comment, my point was that updating the output params in the pipeline params should be independent of whether the module is built-in or not. And thie flags "payload_with_output_format) is only applicable to the built-in ones. So the check is restrictive and it shouldnt be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063, I don't think so. The library loading is a separate step and after that is done the module is in the DSP. Only modules which are already loaded can be initialized. loading a module to firmware and the module initialization is completely different thing, or it is supposed to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @ranj063 is talking the IADK modules, which use different payload format with base FW module. I didn't support IADK modules in this PR, because they are using different payload format and SmartAMP and WoV doesn't need to update the params for IADK modules and don't have any scenarios to test the feature. We will add the IADK support when it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang I think we should update the pipeline params based on the output format for all process modules unconditionally. It doesn't make sense to restrict it to only those that have the output format in their init module instance ipc payload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libinyang I think we should update the pipeline params based on the output format for all process modules unconditionally. It doesn't make sense to restrict it to only those that have the output format in their init module instance ipc payload.
Yes, this is our final goal, to support all process modules. However, we currently don't have any user case to test it. I think it should be easy to add such support. @aiChaoSONG had a patch before. The 2 types of modules has different implmentation to support this feature. I think when we need to add this feature for IADK module, we can submit another PR for it based on this PR. What do you think?
|
This PR has been on-going for nearly 2 months and there's no consensus that it's needed. Any objections to closing it? @libinyang @ranj063 @ujfalusi @aiChaoSONG |
|
no objections recorded, closing |
Some module instances will change its output hw_params from its input hw_params. Let's add a common help function to support this feature. And update the hw_params in sof_ipc4_init_audio_fmt()
Signed-off-by: Libin Yang libin.yang@intel.com