-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Video: Display: NXP: Decouple PxP from eLCDIF. Make a new driver for PxP in video m2m category #92366
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
base: main
Are you sure you want to change the base?
Video: Display: NXP: Decouple PxP from eLCDIF. Make a new driver for PxP in video m2m category #92366
Changes from 1 commit
7906f4d
065487a
bad94d3
81acde2
b4c8ede
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
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. putting source files in |
||
* Copyright 2025 NXP | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/device.h> | ||
#include <zephyr/drivers/video.h> | ||
#include <zephyr/drivers/video-controls.h> | ||
|
||
#include <zephyr/logging/log.h> | ||
|
||
LOG_MODULE_REGISTER(transform, CONFIG_LOG_DEFAULT_LEVEL); | ||
|
||
static const struct device *transform_dev; | ||
static struct video_buffer *transformed_buffer; | ||
|
||
int video_transform_setup(struct video_format in_fmt, struct video_format *out_fmt) | ||
{ | ||
int ret; | ||
struct video_control ctrl = {.id = VIDEO_CID_ROTATE, .val = 90}; | ||
|
||
transform_dev = DEVICE_DT_GET(DT_NODELABEL(pxp)); | ||
|
||
out_fmt->pixelformat = in_fmt.pixelformat; | ||
out_fmt->width = in_fmt.height; | ||
out_fmt->height = in_fmt.width; | ||
out_fmt->type = VIDEO_BUF_TYPE_OUTPUT; | ||
|
||
/* Set input and output formats */ | ||
in_fmt.type = VIDEO_BUF_TYPE_INPUT; | ||
ret = video_set_format(transform_dev, &in_fmt); | ||
if (ret) { | ||
LOG_ERR("Unable to set input format"); | ||
return ret; | ||
} | ||
|
||
ret = video_set_format(transform_dev, out_fmt); | ||
if (ret) { | ||
LOG_ERR("Unable to set output format"); | ||
return ret; | ||
} | ||
|
||
/* Set controls */ | ||
video_set_ctrl(transform_dev, &ctrl); | ||
|
||
/* Allocate a buffer for output queue */ | ||
transformed_buffer = video_buffer_aligned_alloc(in_fmt.pitch * in_fmt.height, | ||
CONFIG_VIDEO_BUFFER_POOL_ALIGN, K_FOREVER); | ||
|
||
if (transformed_buffer == NULL) { | ||
LOG_ERR("Unable to alloc video buffer"); | ||
return -ENOMEM; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int video_transform_process(struct video_buffer *in_buf, struct video_buffer **out_buf) | ||
{ | ||
int err; | ||
struct video_buffer *transformed_buf = &(struct video_buffer){}; | ||
/* Store the input buffer type to recover later */ | ||
enum video_buf_type in_buf_type = in_buf->type; | ||
|
||
in_buf->type = VIDEO_BUF_TYPE_INPUT; | ||
err = video_enqueue(transform_dev, in_buf); | ||
if (err) { | ||
LOG_ERR("Unable to enqueue input buffer"); | ||
return err; | ||
} | ||
|
||
transformed_buffer->type = VIDEO_BUF_TYPE_OUTPUT; | ||
err = video_enqueue(transform_dev, transformed_buffer); | ||
if (err) { | ||
LOG_ERR("Unable to enqueue output buffer"); | ||
return err; | ||
} | ||
|
||
/* Same start for both input and output */ | ||
if (video_stream_start(transform_dev, VIDEO_BUF_TYPE_INPUT)) { | ||
LOG_ERR("Unable to start PxP"); | ||
return 0; | ||
} | ||
|
||
/* Dequeue input and output buffers */ | ||
err = video_dequeue(transform_dev, &in_buf, K_FOREVER); | ||
if (err) { | ||
LOG_ERR("Unable to dequeue PxP video buf in"); | ||
return err; | ||
} | ||
|
||
transformed_buf->type = VIDEO_BUF_TYPE_OUTPUT; | ||
err = video_dequeue(transform_dev, &transformed_buf, K_FOREVER); | ||
if (err) { | ||
LOG_ERR("Unable to dequeue PxP video buf out"); | ||
return err; | ||
} | ||
|
||
*out_buf = transformed_buf; | ||
|
||
/* Keep the input buffer intact */ | ||
in_buf->type = in_buf_type; | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=3686800 | ||
CONFIG_VIDEO_TRANSFORM=y | ||
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=6530200 | ||
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. This is a mistake. Should keep the same buffer size as before |
||
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=3 |
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.
There does not seem to be any source in the boards/ directories of samples:
find samples/ -path '*/boards/*.c' | grep -v samples/boards/
However there are some in
src/
at times:find samples/ -name src -exec ls {} +
How about renaming the file to be slightly more generic, such as
samples/drivers/video/capture/src/transform_mcux_pxp.c
so that all boards that supportspxp
can include this from CMakeLists.txt? i.e. a build condition onCONFIG_VIDEO_MCUX_PXP && CONFIG_VIDEO_SAMPLE_TRANSFORM
?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.
File name is
transform.c
and this is done on purposeto allow each board to write their custom
transform.c
without cluttering the CMakeList.txt with plenty ofif()
, I think.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.
We really need a libZcamera 😅
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.
Zephyr strives to abstract the hardware and planned no room for an application-side
board.c
which we seem to need now.Is something like this acceptable compromise for keeping all sources in src?
This could make things easy to group:
Probably other variants are possible too...
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.
This is another way of placing the applicatation board's specific source code, but placing them all in src/ seems pollluting the common space ? Is it better to place them in board/ instead as config, overlay are also placed there ?
It seems there is no recomendation for where to place the application's board-specific source code.
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 asked recommendations on the
#build-system
channel, and from what I understood:samples/boards/<board>
samples/drivers/video/
.c
files better be kept out of./boards/
expected to be scanned for config files by the build systemMaybe boards can define
CONFIG_VIDEO_SAMPLE_TRANSFORM_PXP=y
in theirprj.conf
? Then this reduces the number of files in./src/
while allowing all the per-board configuration in./boards/...
?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.
Thank you for this info !
But then in CMakeList.txt it seems we need to do
if(CONFIG_VIDEO_SAMPLE_TRANSFORM_PXP)
for each HW (PxP, JPEG decoder, etc.) ?How about ?
of it is preferred to not create sub-folders in src/, we can do as before:
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 am not a reference for this but does not cause problem as per the build system.
What I wonder, however, is how to avoid an explosion of number of board-specific files due to then:
A compromise could be defining the string in Kconfig so that the makefile does not need to be changed:
Then boards can set any of this depending on how board-specific things are:
However, I am also glad with what you proposed, in particular in the beginning where not many boards will need a custom transform.