Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
[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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6571c72579fcbb04a82ee381f005ed05c68c45a83c1cf4bc370772b4337a1a804779a12f9a09ac71da8fa08969aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
| } | ||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.
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...