drivers: video: allow allocation with a header preceding the buffer#79168
drivers: video: allow allocation with a header preceding the buffer#79168josuah wants to merge 1 commit intozephyrproject-rtos:mainfrom
Conversation
|
I am not entirely happy with reinventing buffer management inside
This PR goal is mostly to expose the requirements of #76798. |
Some protocols expect a header followed the buffer payload. Inserting a header at allocation time permits to have a single buffer including both the header and the payload in a continuous memory region as expected by some drivers, without requiring to memcpy the header and payload every time. Convert all video buffer allocation functions to use a common internal function with default parameters provided. Signed-off-by: Josuah Demangeon <me@josuah.net>
d092cdf to
b616821
Compare
|
How are we supposed to know header size when doing allocation? Wouldn't make it sense to allocate the necessary size from the capture driver itself. We could have an internal |
|
Thank you for this feedback! Looking at how the SKB API is used, the headroom is taken into account during the allocation ( skb = netdev_alloc_skb(ndev, PKT_BUF_SZ + RTSN_ALIGN - 1);
if (!skb)
goto error;
skb_reserve(skb, NET_IP_ALIGN);If it is a global In https://github.com/zephyrproject-rtos/zephyr/pull/76798/files I will |
|
The workaround above works: the first packet is |
Some protocols expect a header followed the buffer payload. Inserting a header at allocation time permits to have a single buffer including both the header and the payload in a continuous memory region as expected by some drivers, without requiring to
memcpy()the header and payload every time.Before:
After: