Skip to content

Conversation

@ranj063
Copy link
Collaborator

@ranj063 ranj063 commented Jan 31, 2023

This PR makes the audio format tokens extensible for non-zero pins as well. Depends on thesofproject/sof#7014

bardliao
bardliao previously approved these changes Jan 31, 2023
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.

IPC4 is becoming rocket science without a user manual or textbook. I can't review this, sorry.

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.

Now that I understand the direction, it's indeed quite an improvement @ranj063

Still a couple of unclear parts, see comments below.

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 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?

Copy link
Collaborator Author

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

Copy link
Member

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?

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.

Copy link
Member

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

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.

@ranj063 ranj063 force-pushed the fix/available_fmts_new branch 2 times, most recently from 4c6ad25 to aebe3d0 Compare January 31, 2023 21:09
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.

couple of nit-picks below.

@ranj063 ranj063 force-pushed the fix/available_fmts_new branch 2 times, most recently from 4ca911d to 8f2876f Compare February 1, 2023 05:56
@ranj063
Copy link
Collaborator Author

ranj063 commented Feb 1, 2023

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

@ranj063 ranj063 force-pushed the fix/available_fmts_new branch from 8f2876f to a203f7f Compare February 2, 2023 04:03
bardliao
bardliao previously approved these changes Feb 2, 2023
Copy link
Collaborator

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?

Copy link
Collaborator

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?

@ranj063, any thought?

Copy link
Collaborator

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?

Copy link
Collaborator

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?

@ujfalusi
Copy link
Collaborator

ujfalusi commented Feb 2, 2023

SOFCI TEST

@ujfalusi
Copy link
Collaborator

ujfalusi commented Feb 2, 2023

SOFCI TEST

The tplg dependency is merged, let's re-run and see how it behaves.

@ranj063 ranj063 force-pushed the fix/available_fmts_new branch from 4aaeaad to c21c54c Compare February 7, 2023 17:40
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>
@ranj063 ranj063 force-pushed the fix/available_fmts_new branch from c21c54c to ef8b8ea Compare February 7, 2023 17:57
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.

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) {
Copy link
Member

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

Copy link
Collaborator Author

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.

Copy link
Member

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?

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 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.

Copy link
Member

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>
@ranj063 ranj063 force-pushed the fix/available_fmts_new branch from ef8b8ea to cad1a16 Compare February 7, 2023 18:55
@ranj063 ranj063 requested review from kv2019i and plbossart February 7, 2023 18:55
plbossart
plbossart previously approved these changes Feb 7, 2023
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.

LGTM @ranj063

Copy link
Member

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

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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

Copy link
Member

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!

@ranj063 ranj063 force-pushed the fix/available_fmts_new branch 2 times, most recently from b671382 to cffe1cc Compare February 7, 2023 23:52
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>
@ranj063 ranj063 force-pushed the fix/available_fmts_new branch from cffe1cc to e9ce8b9 Compare February 8, 2023 01:54
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

@lgirdwood lgirdwood added the P1 Blocker bugs or important features label Feb 8, 2023
@lgirdwood
Copy link
Member

@ujfalusi @ranj063 pls review/merge.

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.

@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.

@plbossart
Copy link
Member

@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

Known issue unrelated to this.

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.

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 Blocker bugs or important features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants