Skip to content
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

zephyr: buffer: host: dai: Introduction of functions that allocate a buffer from a range #9145

Merged
merged 5 commits into from
Jun 25, 2024

Conversation

softwarecki
Copy link
Collaborator

For the needs of deep buffering, a new functions buffer_alloc_range and buffer_set_size_range have been added that allocate a buffer with a size given as a range. The suggested buffer size coming from ipc doesn't have to be met if there is not enough memory. It is then reduced step by step until it reaches its minimum size. These functions were used in dai and host.

src/audio/buffer.c Outdated Show resolved Hide resolved
src/audio/buffer.c Outdated Show resolved Hide resolved
src/audio/host-zephyr.c Show resolved Hide resolved
@softwarecki softwarecki force-pushed the alloc-range branch 3 times, most recently from 29b0422 to 5453feb Compare May 22, 2024 15:04
@softwarecki softwarecki marked this pull request as ready for review May 22, 2024 15:20
@softwarecki softwarecki force-pushed the alloc-range branch 2 times, most recently from c9910d0 to 9ca757c Compare May 23, 2024 14:16
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

One commit message style comment first, full review coming later.

src/audio/buffer.c Show resolved Hide resolved

/* Align preferred size to a multiple of the minimum size */
if (preferred_size % minimum_size)
preferred_size += minimum_size - preferred_size % minimum_size;
Copy link
Collaborator

Choose a reason for hiding this comment

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

in fact wondering, whether it would be better to align down? Doesn't seem important though

src/audio/dai-zephyr.c Outdated Show resolved Hide resolved
Change name of the buffer_init to buffer_init_stream because it is only
responsible for initiating a stream. Omit the caps parameter because it is
only assigned to a structure field. Assign this field in the function
caller.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Move part of the code responsible for initializing the buffer structure
to the new function buffer_alloc_struct, which will also be used
by a new buffer allocation function.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add two new buffer allocation functions buffer_set_size_range and
buffer_alloc_range dedicated to deep buffering. They try to allocate
the largest possible buffer according to the suggested size. If this size
cannot be obtained, it will be reduced step by step until it reaches
the minimum size.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Change buffer allocation functions to buffer_alloc_range and
buffer_set_size_range. This makes it possible to allocate the buffer even
if the suggested size given in ipc cannot be met.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Change buffer allocation functions to buffer_alloc_range and
buffer_set_size_range. This makes it possible to allocate the buffer even
if the suggested size given in ipc cannot be met.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
@softwarecki
Copy link
Collaborator Author

SOFCI TEST

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me.

@kv2019i kv2019i merged commit 9a322a2 into thesofproject:main Jun 25, 2024
44 of 46 checks passed
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