Commit graph

235 commits

Author SHA1 Message Date
Phi Bang Nguyen
ae63908ae7 drivers: video: ov5640: Drop cur_pixrate internal variable
Update the control value directly. No need for an internal variable.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-20 18:27:35 +02:00
Farah Fliss
33ff1f65d6 drivers: video: mt9m114: Make the driver multi-instance
The mt9m114 camera driver used to be single-instance.
Improve it to multi-instance.

Signed-off-by: Farah Fliss <farah.fliss@nxp.com>
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-20 18:27:35 +02:00
Farah Fliss
46bf6b589f drivers: video: mt9m114: Fix coding style
Fix coding style in a variable naming.

Signed-off-by: Farah Fliss <farah.fliss@nxp.com>
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-20 18:27:35 +02:00
Phi Bang Nguyen
c94bcb883b drivers: video: mipi_csi2rx: Fix type range related to pixel rate
Fix some type range related to pixel rate which can cause overflow.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-20 18:27:35 +02:00
Phi Bang Nguyen
a1e58acf4b drivers: video: mipi_csi2rx: Explicitly set init priority
The MIPI CSI-2 Rx needs to be initialized after the camera sensor which
is generally initialized with CONFIG_VIDEO_INIT_PRIORITY.

This is currently true "by chance" due to the order the linker links the
object files. This linker order is not easily controlled, so use an
explicit priority value to ensure this requirement.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-20 18:27:35 +02:00
Sylvio Alves
b1ab17a015 driver: video: remove endpoint id in esp32 driver
Remove endpoint ID entry in esp32 video driver needed after
API changes.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-05-19 21:55:32 +02:00
Phi Bang Nguyen
7b421398c4 drivers: video: Rename signal variables to avoid compliance violation
Rename signal variables to sig to be compliant with code rule 21.2

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-16 19:00:09 +02:00
Phi Bang Nguyen
9fa1aeea32 drivers: video: Add video_buf_type
M2M devices like ISPs or PxP have two separate buffer queues, i.e.
incoming and outcoming queues. For each API, the driver needs to
distinguish on which queue it needs to take action.

Add video buffer type to support this kind of devices.

- get_caps(), set/get_format(), enqueue()/dequeue(): the buffer type
is embeded in the video_caps, video_format and video_buffer structs

- video_stream_start/stop() : buffer type needs is sent as a parameter

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-16 19:00:09 +02:00
Phi Bang Nguyen
b63fb91622 drivers: video: Drop video_endpoint_id
The video endpoints are already described in the devicetree. The
video_endpoint_id parameter in each video API is not necessary and has
no usage. Drop it.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-16 19:00:09 +02:00
Phi Bang Nguyen
579741e5e5 drivers: video: esp32: Fix flush callback
When stopping, the framework calls driver's stop callback then driver's
flush callback. Hence, driver's flush callback does not need to call
stop callback again.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-05-16 19:00:09 +02:00
Josuah Demangeon
084f0acb36 drivers: video: controls: add the BASE and CAMERA controls
Add all the base controls present like they are in Linux into Zephyr,
limited to those that can apply in the current system:
- Buttons are left as integer for now.
- Some description is modified to fit the Zephyr situation.
- For the minimum number of buffer, Zephyr uses a different mechanism.
- No audio support through the video subsystem.
- Homogenize the wording

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-05-16 16:11:32 +02:00
Alain Volmat
c1e7bdaa75 video: stm32-dcmi: implement frame interval handling
Implement the video API frame interval handling in order
to control the framerate of capture.

This allow to remove the capture-rate DT property as well.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2025-05-13 22:22:09 -04:00
Alain Volmat
df93e20414 video: stm32-dcmi: correct get/set fmt handling
This commit mainly correct the get/set format handling and how
DCMI format is stored within the driver.  struct video_format
within the data structure is used to store the format.
Reworked way to handle get format to avoid calling the sensor
set_fmt whenever performing the get_fmt.
Slightly adjusted code to as much as possible reuse return
values provided by functions.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2025-05-13 22:22:09 -04:00
Alain Volmat
c0dae0c9ac video: stm32: dcmi: perform config based on endpoint properties
Perform sensor interface properties parsing based on values
retrieved via the endpoint rather than the root of the node.
Use DT_PROP_OR to ensure proper configuration of optional
settings.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2025-05-13 22:22:09 -04:00
Josuah Demangeon
e1f4181c29 drivers: video: common: turn ASSERT(false) into CODE_UNREACHABLE
The assert message was not very helpful, CODE_UNREACHABLE is more
readable and requires fewer effort while proofreading.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-05-12 19:20:45 +02:00
Josuah Demangeon
ee21d397d2 drivers: video: common: optimizations for video_closest_frmival()
In video_closest_frmival(), immediately stop searching when an exact
match is found, as a small performance optimization. Variables
that could be computed only once were moved further outside.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-05-12 19:20:45 +02:00
Josuah Demangeon
84f0eec62e drivers: video: common: fix video_closest_frmival() fie.index
Fix bug introduced in 46a262ffe6 where the
fie.index field was expected to be incremented by the driver, while it
is the responsibility of the caller to increment it.

Fixes #89663

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-05-12 19:20:45 +02:00
Phi Bang Nguyen
78b9f25f76 drivers: video: Use video interfaces binding for ov7670 and smartdma
Have ov7670 and video smartdma use video interfaces binding. With
this, we can fix the chicken-egg issue in init priority and don't need
the workaround anymore.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-26 11:15:50 -04:00
Phi Bang Nguyen
cc17b712f6 drivers: video: smartdma: Fix a typo breaking the build
Fix a typo so that it won't break the build.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-26 11:15:50 -04:00
Josuah Demangeon
0b2d45595e drivers: video: hotfix: force use of constant value for 'source_dev'
In Clang 16 run with some flags, the compiler does not accept a static
const variables as struct initializer. This caused build errors in only
some contexts. Always use the devicetree macros to access the source
device node as a workaround.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-04-22 15:04:47 +02:00
Phi Bang Nguyen
7a1285efe5 drivers: video: Add support for controls of menu types
Add support for controls of menu types, standard menu and drivers'
defined menu.

Rework the ov5640's test pattern and power line frequency controls using
this new support.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Phi Bang Nguyen
3378d683e9 drivers: video: Add support for composite controls
For controls that are dependent from others, we need to "cluster" them.
Whenever one or more controls of the same cluster are set or gotten,
only the callback of the 1st control of the cluster, i.e. the master
control, is called. The master control is the one that represents the
whole cluster.

A common type of control cluster is "auto"-cluster, e.g. auto_gain/gain,
auto_exposure/exposure, auto_white_balance/red_balance/blue_balance,
etc. If the cluster is in automatic mode, then the manual controls are
marked inactive and volatile which are read via get_volatile_ctrl().
If the cluster is put in manual mode, then the manual controls should
become active again and the volatile flag is cleared.

Re-implement the ov5640's autogain/analogue_gain controls with the new
auto cluster mechanism so that it work correctly and fully.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Phi Bang Nguyen
cbf104f3d0 drivers: video: Add get_volatile_ctrl driver's API
Add get_volatile_ctrl() driver's API to retrieve the current value of a
control marked as volatile, e.g. gain, exposure. This function triggers
a hardware register reading instead of returning a cached value to ensure
that users always get a fresh value which is constantly updated by the HW.

Note that the driver is responsible for marking a control as volatile by
setting VIDEO_CTRL_FLAG_VOLATILE when registering a control because not
all hardwares work the same way for the same control.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Phi Bang Nguyen
f363bd6e36 drivers: video: Support controls of 64-bit integer type
Add supports for controls that need 64-bit integer such as pixel rate.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Phi Bang Nguyen
c95387a815 drivers: video: Add video query control API
Application can query information about a control given the control id,
the framework fill the rest of the structure. Application can also
enumerate all kinds of device's supported controls by iterating with
VIDEO_CTRL_FLAG_NEXT_CTRL on the same API.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Phi Bang Nguyen
135528a1be drivers: video: Implement video control framework
Implement the video control framework with the following features:

- Drivers initialize the control with a valid value range at boot which
  guides the application developer and the framework. Hence, the video
  framework could do all common works for drivers e.g., sanity check.

- Controls need to be cached to memory. Video framework handles
  get_ctrl(), drivers don't need to implement this API. It is because
  reading control value directly from registers are not only inefficient
  but also sometimes impossible, e.g. controls that scatter through
  several registers. Only "volatile" control needs to be updated at
  runtime.

- Only the devices (e.g., sensors) owning the controls need to
  implement set_ctrl(). Other devices of the pipeline do not need to
  propagate set_ctrl() and hence, do not need to implement this API

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Phi Bang Nguyen
2b46cc0b78 drivers: video: Introduce video device structure
Introduce a new video device structure representing a device in a
video pipeline. Each video device embeds a pointer to its "source"
device and other "video" characteristics.

This structure give the video framework an access to all video features
of the device and a hierachical view of the video pipeline that the
device belongs to.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Caio Barz Molinari
e57cf1e5ce drivers: video: ov5640: add support to QVGA and QQVGA in CSI mode
The ov5640 driver already supports QVGA and QQVGA in dvp mode but not
in CSI mode. This PR adds support for these resolutions in CSI mode.

Signed-off-by: Caio Barz Molinari <caioheitor.barzmolinari_1@nxp.com>
2025-04-03 13:16:20 +02:00
Josuah Demangeon
5e799193fc drivers: video: gc2145: Add Chip ID 0x2145
The Chip ID field of the GC2145 was assumed to be 0x2155, but sensors
with Chip ID 0x2145 are still present. Rework how chip IDs verification
is done slightly and add support for both.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-04-02 05:30:19 +02:00
Josuah Demangeon
61a1cdf03f drivers: video: emul_imager: use a "PRIV" video CID
Use a video control ID in the private range rather than using an existing
CID, as the emulated imager does not effectively applies these properties
to the image feed and are just for API test purpose.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-03-20 07:20:55 +01:00
Josuah Demangeon
283e502b07 drivers: video: emul_imager: remove the test pattern support
Remove the test pattern generator implemented inline in video_emul_imager,
as this feature is overlapping with VIDEO_SW_GENERATOR, and does not add
value to the driver.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-03-20 07:20:55 +01:00
Josuah Demangeon
b0712d0022 drivers: video: emul_imager: deduplicate the registers
Deduplicate the registers of "modes": only a single definition of each:
pixelformats, resolutions, framerate.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-03-20 07:20:55 +01:00
Josuah Demangeon
dfdbcbb12a drivers: video: emul_imager: remove dev->name from logs
Depending on the log mode selected, the device name will be visible
for every log message, so not useful to add it again in the log payload.
Various other log improvements also added.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-03-20 07:20:55 +01:00
Josuah Demangeon
a86da87a52 drivers: video: emul: store only one line of data
Only store a single line of the full frame. This allows to support a
large enough frame size to remove the Kconfig option, which simplifies
the implementation (fewer checks needed).

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-03-20 07:20:55 +01:00
Armin Kessler
4bb5ffd786 driver: video: esp32: add video_flush() callback
Adding missing `video_flush()` callback to driver.

Signed-off-by: Armin Kessler <ake@espros.com>
2025-03-13 10:50:11 +01:00
Ibrahim Abdalkader
b887cc4db5 drivers: video: gc2145: Fix video_format_cap array.
video_format_cap needs to be terminated with a NULL entry
to allow looping over the formats.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-03-12 02:28:40 +01:00
Sylvio Alves
774730e06a drivers: video: use correct return error
Build fails due to wrong variable used in log output.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-02-13 20:13:05 +01:00
Ibrahim Abdalkader
e6c5f4d6aa drivers: video: gc2145: Fix output format.
- Fix analog mode register address.
- Fix output format register update.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-02-12 12:24:03 +01:00
Phi Bang Nguyen
b341d9d6a4 video: Merge video_stream_start/stop driver APIs
The video_stream_start/stop() APIs are counter-symetric and have
the same function signature. Also, the implementation logic for
those driver APIs is generally the same. Merge them to save memory
and code lines.

For the sake of simplicity, still keep the user APIs to preserve
backward compatibility with downstream applications.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-02-11 07:43:58 +01:00
Phi Bang Nguyen
db6a4e02ad drivers: video: emul_rx: Fix flush function
When stopping, the framework calls driver's stop callback then driver's
flush callback. Hence, driver's flush callback does not need to call
stop callback again.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-02-11 07:43:58 +01:00
Charles Dias
73afa0bcbe drivers: video: ov5640: add DVP support
Improve the ov5640 video driver to provide parallel interface (DVP) support

Signed-off-by: Charles Dias <charlesdias.cd@outlook.com>
2025-02-05 23:48:09 +01:00
Ibrahim Abdalkader
33ec0276b8 drivers: video: video_stm32_dcmi: Sanity-check frame size.
Add a check to ensure the frame size does not exceed the video buffer
size defined by `CONFIG_VIDEO_BUFFER_POOL_SZ_MAX`. Even if the sensor
supports the resolution, the frame size could overflow the buffer.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-30 16:20:17 +01:00
Ibrahim Abdalkader
a4ce71dc70 drivers: video: video_stm32_dcmi: Fix DCMI video buffer release.
Ensure the DCMI video buffer is released only after the DCMI
has been fully stopped. This prevents potential access to the
buffer while the DCMI is still active, avoiding undefined behavior.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-30 16:20:17 +01:00
Benjamin Cabé
a253fe27c9 drivers: ov2640: fix integer underflow in retry logic
Properly stop retrying instead of underflowing uint8_t
fixes CID-487667 and CID-487767

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-28 23:43:31 +01:00
Benjamin Cabé
3f81c69b2b drivers: gc2145: fix integer underflow in retry logic
Properly stop retrying instead of underflowing uint8_t
fixes CID-487682 and CID-487631

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-28 23:43:21 +01:00
Ibrahim Abdalkader
5af9d55b73 drivers: video: ov7670: Use default YUYV/RGB565 order.
TSLB[3] swaps the YUYV/RGB565 output.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-28 18:24:51 +01:00
Ibrahim Abdalkader
1d6a80ca7c drivers: video: ov7670: Use a free-running pixel clock.
The STM32 DCMI capture seems to stop when the pixel clock is
disabled during horizontal blank. This patch switches pixel
clock to free-running, which shouldn't have any effect on other
capture devices.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-28 18:24:51 +01:00
Ibrahim Abdalkader
ec7628b9b3 drivers: video: ov7670: Implement missing video API functions
Add the missing stream_start and stream_stop API functions
(the driver doesn't work without them) and implement video
controls for horizontal mirror (hmirror) and vertical flip.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-28 18:24:51 +01:00
Ibrahim Abdalkader
b58671fd1a drivers: video: video_stm32_dcmi: Use video buffers for DCMI buffer.
Instead of reserving a static (possibly unaligned) buffer for DCMI,
this patch reserves and holds one of the video buffers to use as the
main DCMI buffer. This buffer will be aligned (using the alignment
specified in the config) and will either be allocated from `video_common`
pool or a shared multi-heap (if enabled).

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-28 09:50:16 +01:00
Ibrahim Abdalkader
2924a99cd1 drivers: video: gc2145: Add support for YUV format.
Can be used to get a fast grayscale image.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2025-01-27 11:02:44 +01:00