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

drivers: video: gc2145: Add support for YUV format. #84370

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iabdalkader
Copy link
Contributor

Can be used to get a fast grayscale image. Note enum resolutions is not needed at all, but I wanted to keep changes minimal.

josuah
josuah previously approved these changes Jan 22, 2025
Copy link
Collaborator

@josuah josuah left a comment

Choose a reason for hiding this comment

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

The changes look ideal IMHO.

@iabdalkader
Copy link
Contributor Author

@josuah

Is there a way to provide the memory pool for video_buffer_aligned_alloc or specify the video memory via conf or overlay? For example, to use SDRAM for buffers? I'm running out of memory and can't test any bigger frames.

@josuah
Copy link
Collaborator

josuah commented Jan 22, 2025

I believe the way @LucasTambor wanted to solve this is through the use of "shared multi-heap":

CONFIG_ESP_SPIRAM -> CONFIG_SHARED_MULTI_HEAP -> CONFIG_MULTI_HEAP

And was integrated into the Video allocation API via CONFIG_VIDEO_BUFFER_USE_SHARED_MULTI_HEAP:

It's up to the user to use to configure it or not. If their platform supports it and they want to use a memory region with capabilities such as external/cacheable/non-cacheable (depends on what SMH supports) is now possible, otherwise if they do nothing it will use default sys_heap as it used to be.

Applied here:

block->data = VIDEO_COMMON_HEAP_ALLOC(align, size, timeout);

@josuah
Copy link
Collaborator

josuah commented Jan 22, 2025

The alternative would be to catch the video memory pool defined here in a board-specific linker script or custom linker script:

K_HEAP_DEFINE(video_buffer_pool, CONFIG_VIDEO_BUFFER_POOL_SZ_MAX*CONFIG_VIDEO_BUFFER_POOL_NUM_MAX);

A bit more ad-hoc but could work too depending on the goals.
Maybe that would be a good time to look how that solution got solved on other subsystems and introduce some way to tell where implicitly allocated buffers go.

@iabdalkader
Copy link
Contributor Author

@josuah I'll give the first option a try tomorrow and let you know how it goes. Thanks for the hint!

@iabdalkader
Copy link
Contributor Author

iabdalkader commented Jan 23, 2025

@josuah I tried the shared multi-heap and it works fine. However, I think video_stm32_dcmi.c requires a small fix. Currently, it allocates its own static buffer in SRAM which overflows if CONFIG_VIDEO_BUFFER_POOL_SZ_MAX is increased (something you'd want to do after switching to SDRAM), and this buffer was never aligned, I think. Basically, we need to use VIDEO_COMMON_HEAP_ALLOC from video_common.c. Can I move this to video.h, or just duplicate it?
See: #84446

Also, display_stm32_ltdc.c does something similar by placing the frame buffer in SDRAM. I'm not sure how to get the remaining free SDRAM for the shared multi-heap and I couldn't find a config option to specify its size either. I understand the heap blocks are added at runtime, just not sure how to specify the SDRAM heap size.

@josuah
Copy link
Collaborator

josuah commented Jan 23, 2025

Thank you for this new PR! I will pursue the discussion on that topic on #84446.

kartben
kartben previously approved these changes Jan 24, 2025
drivers/video/gc2145.c Outdated Show resolved Hide resolved
drivers/video/gc2145.c Outdated Show resolved Hide resolved
Can be used to get a fast grayscale image.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Video Video subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants