drivers: video_common: Add aligned allocation API
For some hardwares, it is very common that some aligment on the allocated memory is required. For example, the PxP and eLCDIF of NXP require aligned buffers so that their performances can be optimal. Add a new video_buffer_aligned_alloc() API for these needs. Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
This commit is contained in:
parent
99f94295eb
commit
de29ffb033
2 changed files with 18 additions and 3 deletions
|
@ -19,7 +19,7 @@ struct mem_block {
|
|||
|
||||
static struct mem_block video_block[CONFIG_VIDEO_BUFFER_POOL_NUM_MAX];
|
||||
|
||||
struct video_buffer *video_buffer_alloc(size_t size)
|
||||
struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align)
|
||||
{
|
||||
struct video_buffer *vbuf = NULL;
|
||||
struct mem_block *block;
|
||||
|
@ -39,7 +39,7 @@ struct video_buffer *video_buffer_alloc(size_t size)
|
|||
}
|
||||
|
||||
/* Alloc buffer memory */
|
||||
block->data = k_heap_alloc(&video_buffer_pool, size, K_FOREVER);
|
||||
block->data = k_heap_aligned_alloc(&video_buffer_pool, align, size, K_FOREVER);
|
||||
if (block->data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ struct video_buffer *video_buffer_alloc(size_t size)
|
|||
return vbuf;
|
||||
}
|
||||
|
||||
struct video_buffer *video_buffer_alloc(size_t size)
|
||||
{
|
||||
return video_buffer_aligned_alloc(size, sizeof(void *));
|
||||
}
|
||||
|
||||
void video_buffer_release(struct video_buffer *vbuf)
|
||||
{
|
||||
struct mem_block *block = NULL;
|
||||
|
|
|
@ -560,10 +560,20 @@ static inline int video_set_signal(const struct device *dev,
|
|||
return api->set_signal(dev, ep, signal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Allocate aligned video buffer.
|
||||
*
|
||||
* @param size Size of the video buffer (in bytes).
|
||||
* @param align Alignment of the requested memory, must be a power of two.
|
||||
*
|
||||
* @retval pointer to allocated video buffer
|
||||
*/
|
||||
struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align);
|
||||
|
||||
/**
|
||||
* @brief Allocate video buffer.
|
||||
*
|
||||
* @param size Size of the video buffer.
|
||||
* @param size Size of the video buffer (in bytes).
|
||||
*
|
||||
* @retval pointer to allocated video buffer
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue