-
Notifications
You must be signed in to change notification settings - Fork 349
[WIP][RFC]codec adapter: move generic mem alloc to component #4112
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6571c72
ipc: abstraction: abstract pipeline_new() to support other IPC ABIs
lrgirdwo 579fcbb
pipeline: add support for pipeline to allocate memory
lrgirdwo 04a82ee
ipc4: wip
lrgirdwo 381f005
ipc: abstraction: Add yet more IPC structures
lrgirdwo ed05c68
ipc4: fix compiling error
RanderWang c45a83c
ipc: add fw ready support for ipc4
RanderWang 1cf4bc3
ipc4: process ipc message for ipc4
RanderWang 70772b4
ipc4: reply ipc message status to host
RanderWang 337a1a8
ipc4: add dmic & ssp header file for ipc4
RanderWang 04779a1
ipc4: add alh header file for ipc4
bardliao 2f9a09a
ipc: abstraction: ipc4 header cleanup
lrgirdwo c71da8f
ipc: abstraction: ipc4 use gateway
lrgirdwo a08969a
codec adapter: move generic mem alloc to component
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -455,3 +455,57 @@ struct comp_dev *comp_make_shared(struct comp_dev *dev) | |
|
|
||
| return dev; | ||
| } | ||
|
|
||
| void *comp_devm_alloc(struct comp_dev *dev, uint32_t size, | ||
| uint32_t alignment) | ||
| { | ||
| struct comp_dev_mem *container; | ||
| void *ptr; | ||
|
|
||
| if (!size) { | ||
| comp_err(dev, "comp_devm_alloc: requested allocation of 0 bytes."); | ||
| return NULL; | ||
| } | ||
|
|
||
| /* Allocate memory container */ | ||
| container = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, | ||
| sizeof(struct comp_dev_mem)); | ||
| if (!container) { | ||
| comp_err(dev, "comp_devm_alloc: failed to allocate memory container."); | ||
| return NULL; | ||
| } | ||
|
|
||
| /* Allocate memory for codec */ | ||
| if (alignment) | ||
| ptr = rballoc_align(0, SOF_MEM_CAPS_RAM, size, alignment); | ||
| else | ||
| ptr = rballoc(0, SOF_MEM_CAPS_RAM, size); | ||
|
|
||
| if (!ptr) { | ||
| comp_err(dev, "comp_devm_alloc: failed to allocate memory for comp_dev\n"); | ||
| return NULL; | ||
| } | ||
|
|
||
| /* Store reference to allocated memory */ | ||
| container->ptr = ptr; | ||
| list_item_prepend(&container->mem_list, &dev->mem.mem_list); | ||
|
|
||
| return ptr; | ||
| } | ||
|
|
||
| int comp_devm_free(struct comp_dev *dev) | ||
| { | ||
| struct comp_dev_mem *mem; | ||
| struct list_item *mem_list; | ||
| struct list_item *_mem_list; | ||
|
|
||
| /* Find which container keeps this memory */ | ||
| list_for_item_safe(mem_list, _mem_list, &dev->mem.mem_list) { | ||
| mem = container_of(mem_list, struct comp_dev_mem, mem_list); | ||
| rfree(mem->ptr); | ||
| list_item_del(&mem->mem_list); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe first delete from the list, then free? |
||
| rfree(mem); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause | ||
| * | ||
| * Copyright(c) 2021 Intel Corporation. All rights reserved. | ||
| */ | ||
|
|
||
| /* | ||
| * This file contains structures that are exact copies of an existing ABI used | ||
| * by IOT middleware. They are Intel specific and will be used by one middleware. | ||
| * | ||
| * Some of the structures may contain programming implementations that makes them | ||
| * unsuitable for generic use and general usage. | ||
| */ | ||
|
|
||
| /** | ||
| * \file include/ipc4/alh.h | ||
| * \brief IPC4 global definitions. | ||
| * NOTE: This ABI uses bit fields and is non portable. | ||
| */ | ||
|
|
||
| #ifndef __SOF_IPC4_ALH_H__ | ||
| #define __SOF_IPC4_ALH_H__ | ||
|
|
||
| #include <stdint.h> | ||
| #include <ipc4/gateway.h> | ||
|
|
||
| #define ALH_MAX_NUMBER_OF_GTW 16 | ||
|
|
||
| struct ipc4_alh_multi_gtw_cfg { | ||
| /* Number of single channels (valid items in mapping array). */ | ||
| uint32_t count; | ||
| /* Single to multi aggregation mapping item. */ | ||
| struct { | ||
| /* Vindex of a single ALH channel aggregated. */ | ||
| uint32_t alh_id; | ||
| /* Channel mask */ | ||
| uint32_t channel_mask; | ||
| } mapping[ALH_MAX_NUMBER_OF_GTW]; /* < Mapping items */ | ||
| } __attribute__((packed, aligned(4))); | ||
|
|
||
| struct sof_alh_configuration_blob { | ||
| union ipc4_gateway_attributes gtw_attributes; | ||
| struct ipc4_alh_multi_gtw_cfg alh_cfg; | ||
| } __attribute__((packed, aligned(4))); | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if this shouldn't be better called devm_comp_alloc(dev, ..) similar with its Linux counterpart.
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 sure. Can revisit the naming as I need to shuffle this around anyway...