-
Notifications
You must be signed in to change notification settings - Fork 140
Some clean ups for the way we parse the available audio formats in topology #4163
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
Some clean ups for the way we parse the available audio formats in topology #4163
Conversation
plbossart
left a comment
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.
IPC4 is becoming rocket science without a user manual or textbook. I can't review this, sorry.
91438c0 to
0f5f9d9
Compare
plbossart
left a comment
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.
Now that I understand the direction, it's indeed quite an improvement @ranj063
Still a couple of unclear parts, see comments below.
sound/soc/sof/ipc4-pcm.c
Outdated
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 am not able to follow the original code or the suggested change. In both cases, input_audio_fmts can be an array of "@audio_fmt_num: Number of available audio formats" elements, so why take the first element only?
in other places you use &available_fmt->input_audio_fmts[i].audio_fmt, so not sure why the index 0 is used?
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 needs to be revisited later @plbossart . I do not know the intention for the original code. This change is needed though because the sampling_frequency is in a different field
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 was added by @RanderWang in bed4045. Can you comment Rander?
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.
sof_ipc4_pcm_dai_link_fixup is called for BE and then FE is processed, at this function ipc4_copier is not prepared, so we can only get sample frequency from available_fmt (we can't use current params for SRC case). Use the first entry since dai copier is fixed with one sampling rate.
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.
Erm, what @RanderWang? @kv2019i is precisely trying to add more rates to the BT pipelines, so I am not sure how your assumption that dai copiers have a single sampling rate could hold
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.
yes, my assumption is stale.
4c6ad25 to
aebe3d0
Compare
plbossart
left a comment
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.
couple of nit-picks below.
4ca911d to
8f2876f
Compare
|
The CI device test shows all fails because the PR depends on the SOF PR 7014. The results with the SOF PR are available in plan 20422 |
8f2876f to
a203f7f
Compare
sound/soc/sof/ipc4-topology.c
Outdated
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 wounder if this should be done in the similar way the out_format is done, with local temp struct.
Should we also NULL out the available_fmt->input_audio_fmts just for safety?
Add a new label to jump?
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 wounder if this should be done in the similar way the
out_formatis done, with local temp struct. Should we also NULL out theavailable_fmt->input_audio_fmtsjust for safety? Add a new label to jump?
@ranj063, any thought?
sound/soc/sof/ipc4-topology.c
Outdated
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.
How did the cpc and is_pages made it's way to these base_configs? I can not see it so there is a chance that it is overridden from the other base_configs?
sound/soc/sof/ipc4-topology.c
Outdated
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.
If we can save on memory allocation when it is clearly not needed to be done, then why we don't?
|
SOFCI TEST |
The tplg dependency is merged, let's re-run and see how it behaves. |
4aaeaad to
c21c54c
Compare
Currently we use input/output and sink/source pins interchangeably. Remove the references to sink/source pins and replace with input/output pins everywhere for consistency and clarity. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
c21c54c to
ef8b8ea
Compare
plbossart
left a comment
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.
couple more comments @ranj063.
| dev_err(scomp->dev, "invalid pins for %s: [sink: %d, src: %d]\n", | ||
| swidget->widget->name, swidget->num_sink_pins, swidget->num_source_pins); | ||
| if (swidget->num_input_pins > SOF_WIDGET_MAX_NUM_PINS || | ||
| swidget->num_output_pins > SOF_WIDGET_MAX_NUM_PINS) { |
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.
should we check that the sum is < SOF_WIDGET_MAX_NUM_PINS
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.
the definition of MAX_NUM_PINS applies individually for input and output pins. So I dont think a check for sum is required.
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.
didn't we have an array where we first have the input pins and then the output pins?
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 am pretty sure we discussed this with @aiChaoSONG but I don't know if this applies in this context.
This could be addressed as a separate patch if 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.
yes, this is documented here:
cf6e9a5#diff-3aa89cf77fc07290f36500245dad57c983ae8628a8fb4b43804391a01ca4f520R444
But I am not sure what the binding array size might be.
…e_audio_format Add a new field, input_audio_fmts, in struct sof_ipc4_available_audio_format and parse all the available input audio formats into this new field and not into the base_config field. This is preparation to remove the base_config array from the struct sof_ipc4_available_audio_format. This simplifies the sof_ipc4_init_audio_fmt() function as the reference audio format for matching with input params has the same size. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
ef8b8ea to
cad1a16
Compare
plbossart
left a comment
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.
LGTM @ranj063
sound/soc/sof/ipc4-topology.c
Outdated
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.
nit-pick , you could remove the if/else and do
copier_data->gtw_cfg.dma_buffer_size = min( 2, deep_buffer_dma_ms) * copier_data->base_config.ibs;
can be a fixup if agreed
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 min(2, deep_buffer_dma_ms) would always result in 2 even with deep_buffer_dma_ms > 2 right?
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.
should be max, fixed now
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.
Yes, I meant max. brain typo!
b671382 to
cffe1cc
Compare
Do not parse the SOF_TKN_CAVS_AUDIO_FORMAT_DMA_BUFFER_SIZE token as the dma_buffer_size can be derived from the input/output buffer size and the type of widget during copier prepare. For the deep buffer case, introduce a new token that will be used to get the deep buffer DMA size for the host copier from topology. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
There is no need to parse the cpc and is_pages values multiple times. It is enough to parse the 2 tokens directly into the base_config field in each module's init_instance IPC payload. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Parse the output formats available in topology always. Whether the output format is sent in the init instance payload or not is decided when sof_ipc4_init_audio_fmt() is invoked. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
…ormats Introduce a new struct sof_ipc4_pin_format which contains the pin index and the buffer size. Replace the type of available input/output audio formats in struct sof_ipc4_available_audio_format with this new struct type and rename them to input_pin_fmts and output_pin_fmts. Also, add a new token, SOF_TKN_CAVS_AUDIO_FORMAT_PIN_INDEX that will be used to parse the pin index for the audio format from topology. Currently we only set the audio format for Pin 0 in topology, so the default value will be 0 for all audio formats. Finally, parse the pin_index and the input/output buffer sizes along with audio formats into the pin_format arrays in struct sof_ipc4_available_audio_format. This makes the base_config array in struct sof_ipc4_available_audio_format redundant. So remove it. This change will allow the addition of audio formats for the non-zero pins in topology transparent to the topology parser in the kernel. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
…_fmt() Only the copier needs to set the output format in its IPC payload. So move the code to set the output format inside sof_ipc4_prepare_copier_module() and modify the signature of sof_ipc4_init_audio_fmt() to remove the out_format argument. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Remove the field in struct sof_ipc4_available_audio_format and pass the format list to be searched as an argument to sof_ipc4_init_audio_fmt() directly. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
…count In preparation for handling processing modules with different input/output pin counts, introduce two new tokens for input/output audio format counts. Use these token values to parse all the available audio formats from topology. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Base config only contains the input/output audio formats for pin 0. So match only the pin 0 formats during runtime format selection. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
cffe1cc to
e9ce8b9
Compare
RanderWang
left a comment
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.
LGTM
ujfalusi
left a comment
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, one failure in PR test which I can not connect to the content of this:
[ 825.361247] kernel: sof-audio-pci-intel-tgl 0000:00:1f.3: ipc timed out for 0x13000004|0x1
I can not see anything standing out.
Known issue unrelated to this. |
plbossart
left a comment
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.
LGTM @ranj063 , except for the restriction to 2ms. That's not something that we should encode in the kernel. Clearly that would prevent low-latency usages that are possible with a lower system tick - it's been done before.
This can be updated later, so approving for now.
| #define SOF_IPC4_INVALID_NODE_ID 0xffffffff | ||
|
|
||
| /* FW requires minimum 2ms DMA buffer size */ | ||
| #define SOF_IPC4_MIN_DMA_BUFFER_SIZE 2 |
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.
is this really 2ms or 2x the system tick?
I see no reason why 2ms would be required, there's nothing in hardware that requires this.
can be updated with a fixup
This PR makes the audio format tokens extensible for non-zero pins as well. Depends on thesofproject/sof#7014