A temporarily empty input FIFO can leave active_buf NULL for
a subsequent callback. Skip the metadata update and output enqueue
when there is no buffer to deliver.
Fixes#117173
Assisted-by: Copilot:GPT-6 Luna
Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
The OV7670 and OV7675 need XCLK running before they answer on SCCB.
On boards where XCLK comes from a clock controller that is off at
boot, such as a pwm-clock node, the product ID read in init fails.
Add an optional clocks property to both bindings. When it is set,
the driver enables the clock before touching the sensor and waits
1 ms, the minimum time the datasheet asks for before the first SCCB
access. The clock specifier is passed as the clock_control subsystem,
taken from the id cell as for pwm-clock.
Tested on an ESP32-DevKitC with an OV7675, XCLK from a pwm-clock node
on LEDC: the sensor probes at boot without deferred init.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Wojciech Jakubiszyn <wojtekjakubiszyn@gmail.com>
For SoCs that support clock control, turn on the gate clock
during init. Nodes without a clocks property are unaffected.
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
In 2x2 binning, HMAX 0x0280 and 0x0140 give 25.78 and 51.56 fps
instead of 25 and 50. Sony datasheet E18112A84 corrects them to
0x0294 and 0x014A (p.57, revision history p.97), which give 25.00
and 50.00 fps.
Signed-off-by: Kirill Shypachov <kshypachov@outlook.com>
The reset and pwdn initializer macros were guarded with
DT_ANY_INST_HAS_PROP_STATUS_OKAY(), which is evaluated while
DT_DRV_COMPAT is still ovti_ov7670. When only an ovti,ov7675 node
is enabled, the guards are false, the config struct gets no
reset/pwdn entries and the pins from devicetree are never driven.
Check both compatibles, as the config struct definition already
does.
Found with an OV7675 on an ESP32-DevKitC: the preprocessed config
initializer had no .pwdn member although the node sets pwdn-gpios.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Wojciech Jakubiszyn <wojtekjakubiszyn@gmail.com>
When stopping the stream, the DCMI driver currently stop
first the source device (ex: sensor) then afterward call
the HAL_DCMI_Stop. This leads to a timeout at HAL_DCMI_Stop
since the HW block is waiting for an EOF to frame to come
before clearing its ongoing capture bit. Avoid this
timeout by first stopping the DCMI capture and only
afterward stop the source device.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Enable multiple platform-level defaults to make video receiver work without
the need to configure every sample.
Also supports shared-multi-heap to be turned off and use memory region
names instead as an option.
Signed-off-by: Josuah Demangeon <me@josuah.net>
Until the first input buffer is parsed, set_format accepted any request
without storing it or filling the pitch and size, so a caller sizing its
buffers from the returned format got whatever its struct held. Reject an
input format other than JPEG and an output format the decoder cannot
produce, estimate the pitch and size for the requested format and keep it
as the current one, as the other m2m codec drivers do. The JPEG header
still replaces the output format on the first enqueue.
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/video`
- `drivers/wifi`
Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Fix typos from "on succes" to "on success" in video control
function documentation comments.
Assisted-by: Gemini:gemini-3.8-flash
Signed-off-by: Jacky Mpoka <jackympoka22@gmail.com>
The driver was marked experimental because frame intervals and controls
are not implemented yet. Adding them later extends what the driver
supports through the video API without changing its devicetree binding,
so there is no reason to keep it experimental. Drop the EXPERIMENTAL
selection and the prompt suffix.
Assisted-by: Antigravity:gemini-3-pro
Signed-off-by: Changyeon Jo <changyeon@google.com>
A host pipe holds 64 KiB by default, less than a single frame of the
default 320x240 RGB565 format. The host writer then blocks mid-frame
until the driver drains the pipe, and the driver waits poll-interval-ms
between two reads, so every larger frame takes several polls to arrive.
The default format could not keep up with a 30 fps writer, and 640x480
YUYV frames arrived at under 6 fps whatever the writer rate.
Enlarge the pipe with F_SETPIPE_SZ when the stream starts, and when a
larger format is selected while streaming, so that it holds two frames:
with room for a single one, the host writer stalls until each frame is
read. The pipe is never shrunk, so smaller frames are unaffected.
Unprivileged processes cannot go beyond /proc/sys/fs/pipe-max-size,
1 MiB by default, nor /proc/sys/fs/pipe-user-pages-soft for all their
pipes together. The largest allowed capacity is used instead, and the
driver warns that the frame rate may be limited.
F_SETPIPE_SZ needs _GNU_SOURCE, which the bottom half defines as other
native simulator bottoms do. Also spell out that when the pipe runs
dry mid-frame, the rest of the frame is read on a later poll.
Assisted-by: Antigravity:gemini-3-pro
Signed-off-by: Changyeon Jo <changyeon@google.com>
On the STM32MP25 the DCMIPP kernel clock source is selected by the
Cortex-A35 firmware and the Cortex-M33 has no mux to configure. Only
call clock_control_configure() when a dcmipp-ker clock is described, so
such SoCs can list the DCMIPP gate alone.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Jerome LAMY <jerome.lamy@savoirfairelinux.com>
enum_frmival() reported one stepwise range with min and max swapped:
frame dropping only lengthens the interval, so the sensor interval is
the lower bound, not the upper one.
Even with the bounds fixed, one range with the sensor step advertises
intervals the DCMI cannot produce. Its frame control captures every
frame, every 2nd or every 4th one, so dropping multiplies both the
interval and the step. Report each sensor interval once per capture
rate instead, with the interval and the step scaled accordingly.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Add a video capture driver for native_sim that reads fixed size raw
frames from a named pipe on the host and exposes them through the video
API as an ordinary zephyr,camera device. A host process such as ffmpeg
feeds the pipe from a webcam, a video file or a test pattern, which
lets video applications run on native_sim without camera hardware.
The driver is split the usual way for native_sim. The bottom half is
built in the native simulator runner context and is the only part
touching the host C library: it creates the FIFO with mkfifo() when
needed, refuses a path that exists but is not a FIFO, and opens it
O_RDONLY | O_NONBLOCK so that no read() can ever stall the simulation.
A dedicated thread polls the FIFO and reads straight into the buffer at
the head of the input queue. The buffer is only dequeued once exactly
width * height * bpp bytes have been read, so stop and flush never lose
it. While the application holds every buffer the driver stops reading
and the host writer blocks on the full pipe.
A writer disconnecting mid-frame makes read() return 0. The partial
frame is then discarded while the descriptor stays open, so the next
writer to attach is guaranteed to be frame aligned.
The application selects the format with video_set_format(), as with the
other video drivers. get_caps() lists the formats of video_sw_generator
that ffmpeg can write (RGB565, RGB24, BGR24, XRGB32, BGRX32, YUYV and
GREY), any size up to 1920x1080, with an even width for YUYV, and the
default is 320x240 RGB565. The host writer is responsible for scaling
and pixel format conversion, so it must write frames of the selected
format. A buffer queued before a larger format was selected is returned
unfilled rather than overrun.
The FIFO path comes from the fifo-path property, or defaults to
/tmp/zephyr-<device>-<pid>.fifo so that several simulator instances do
not collide. It can be overridden at runtime with the --<device>=<path>
command line option. A FIFO created by the driver is removed when the
simulator exits.
Frame intervals and controls are not implemented yet, so the driver is
marked experimental for now.
Assisted-by: Antigravity:gemini-3-pro
Signed-off-by: Changyeon Jo <changyeon@google.com>
The FIFO threshold in the dmas features cell, documented in the binding,
is ignored by dma_stm32_zcfg_to_halcfg() which always selects direct
mode.
Direct mode writes every word to memory as it arrives, which is too slow
for destinations such as external SDRAM. The DCMI overruns and capture
never completes.
Enable the FIFO when the DT asks for a full threshold. This driver
transfers words, and full is the only threshold the hardware accepts at
that size, so boards asking for 1/4, 1/2 or 3/4 cannot use the FIFO at
all and keep direct mode as before.
Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
Ask for a 4 beat burst on the memory side with dest_burst_length instead
of leaving it equal to the data size.
Note this has no effect on its own, the burst bits are only written to
the stream when the FIFO is enabled, which it is not yet on any board.
Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
Return -ENOSYS instead of -EINVAL for selection targets other than
VIDEO_SEL_TGT_CROP, since these operations are not implemented by
the driver.
This lets video_set_compose_format() proceed with format configuration
through set_format instead of aborting with -EINVAL.
Signed-off-by: Daniele Cloralio <d.cloralio@arduino.cc>
The slot argument from macros STM32_DT_INST_DMA_SLOT* was useless.
With it the macro was basically a redefinition a the Zephyr macro.
It is now removed to be similar to other STM32 DMA macros that call
DT_INST_DMAS_CELL_BY_NAME.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Typically Zephyr device tree macros that take a inst as argument
start with DT_INST_.
For the STM32 DMA driver we currently have several macros taking an inst as
argument but missing this prefix.
For consistency, it is added to these macros. The goal is to also define
DT_ variants of these macros that take a node_id as argument.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add support for NXP PNG decoder hardware module. This driver provides
memory-to-memory (M2M) video transformation capability to decode PNG
compressed images into raw pixel formats.
Key features:
- Supports PNG input format (VIDEO_PIX_FMT_PNG)
- Resolution support: 1x1 to 1024x65535 pixels (1-pixel step)
- Fixed RGBA32 output format (VIDEO_PIX_FMT_RGBA32)
- Interrupt-driven operation with input/output buffer queues
- 8-byte buffer alignment requirement
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
The new dma_stm32_zcfg_to_halcfg() relies heavily on default STM32
configuration. Document it in order not to loose the DMA consumer
drivers into wrong configuration.
Signed-off-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>
Use the private STM32 DMA helper in HAL-managed DMA setup paths instead
of open-coding common DMA_InitTypeDef fields in each consumer.
Keep peripheral-specific settings such as request lines, instances,
channel attributes, bursts, and port allocation local to each driver.
This reduces duplicated HAL DMA setup in flash, MSPI, SAI, SDMMC, and
DCMI STM32 drivers.
Assisted-by: Copilot:gpt-5.5
Signed-off-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>
Add support for NXP JPEG decoder hardware module. This driver provides
memory-to-memory (M2M) video transformation capability to decode JPEG
compressed images into raw pixel formats.
Key features:
- Supports JPEG input format (VIDEO_PIX_FMT_JPEG)
- Resolution support: 64x64 to 8192x8192 pixels (16-pixel step)
- Automatic format detection from JPEG header parsing
- No color space conversion (output format matches JPEG encoding)
- Interrupt-driven operation with input/output buffer queues
- Configurable output buffer pitch for flexible memory layouts
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
Add a new video driver for NXP FlexIO-based parallel camera
interface (DVP). The driver captures 8-bit parallel pixel data
via FlexIO shifters, with pixel clock (PCLK) gating and horizontal
sync (HREF) line synchronization. Pixel data is transferred to
memory using eDMA, with frame boundaries synchronized via VSYNC
GPIO interrupt. An optional XCLK output can be generated by a FlexIO
timer for camera sensor clock supply.
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
Use controller/peripheral and SDO/SDI terminology in the remaining
SPI-using drivers (audio, auxdisplay, bluetooth HCI, dac, eeprom,
ethernet, flash, fpga, gpio, haptics, hdlc_rcp_if, ieee802154,
input, led, led_strip, lora, mfd, misc, mux, rtc, sdhc, stepper,
video, watchdog, wifi) and the ec_host_cmd SPI STM32 backend,
following coding guideline rule A.2: switch to
SPI_OP_MODE_CONTROLLER/PERIPHERAL and SPI_SDO_OVERRUN_DT, rename
Zephyr-owned identifiers (the HCI SPI header buffers, the winc1500
bus wrapper transfer parameters), and update comments, log messages
and Kconfig help prose.
Vendor and out-of-scope identifiers keep their names: STM32
LL_SPI_MODE_SLAVE in the ec_host_cmd backend, the ATWINC1500 SDK I2C
SLAVE_ADDRESS definition, and the I2S codec clock-role variable in
tlv320aic26.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The help text of VIDEO_BUFFER_POOL_ZEPHYR_REGION points the reader at
CONFIG_VIDEO_BUFFER_ZEPHYR_REGION_NAME, which does not exist. The option
is declared two lines below as VIDEO_BUFFER_POOL_ZEPHYR_REGION_NAME and
is the name used everywhere else: subsys/video/buffer.c and the board
defconfigs for stm32h7s78_dk and stm32n6570_dk.
Fix the name in the help text so it matches the declared option.
Signed-off-by: Daniel M'BOUYOU <danielmbouyou@gmail.com>
Enabling proper zoom/scaling for windowed resolutions;
e.g. smaller than uxga
That makes camera's ISP to downscale frame to a desired resolution
Signed-off-by: Roman Pustobaiev <romanpustobayev@gmail.com>
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Use same window settings for both MIPI and DVP mode, helping reducing
the code size of the driver as well.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
In preparation for making DVP frmrate handling common with the existing
MIPI one, rename the structure ov5640_mipi_frmrate_config into
ov5640_frmrate_config as well as associated tables.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Avoid setting the output format as part of init_common_dvp since
this is set via the ov5640_set_fmt function as well.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
HFLIP/VFLIP settings are already done as part of the common init
sequence so avoid changing them specifically in the dvp part as
this is also accessible via dedicated controls.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Perform the sensor ID register check first before doing anything
else after the reset of the sensor.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Add the ability to run cameras in a logical
snapshot mode instead of always running
in video mode. In particular, the camera
starts when you ask for an image to be dequeued
and stops when it receives an image.
There are two ways to setup to run in this mode:
a) Tell it to do so in the overlay by giving the DCMI object
the property: snapshot-mode
b) At run time: I added a video control: VIDEO_CID_SNAPSHOT_MODE
Which can have the values
0 - normal - continuous video mode
1 - snapshot - snapshot mode enabled.
As mentioned in the snapshot modes, the HAL DMA is stopped after each
image and restarted when the user asks for another image. I added a
timeout default to 1 second, that handles the case where sometimes
the HAL is silently not successful in retrieving an image.
Signed-off-by: Kurt Eckhardt <kurte@rockisland.com>
When HAL_DCM_Stop return an error code, their failure does not
appear to be a real failure, but instead it is more like it
simply did not have to do anything. As such changed from reporting
it from LOG_WRN to LOG_DBG
Signed-off-by: Kurt Eckhardt <kurte@rockisland.com>
Move most of the shared sources from drivers/video/ into subsys/video/.
The content left in drivers/video/ is now only used by drivers, or
drivers themselves.
Signed-off-by: Josuah Demangeon <me@josuah.net>
Move all the content of <zephyr/drivers/video.h> to a separate include
file in <zephyr/video/video.h> except driver entry points, all with a
video_drivers_... prefix.
Video control IDs are now in <zephyr/video/controls.h> and included
from both <zephyr/drivers/video.h> and <zephyr/video/video.h>.
Video format FourCCs are now in <zephyr/video/formats.h> and included
from both <zephyr/drivers/video.h> and <zephyr/video/video.h>.
As a side effect, introduce a video subsystem in MAINTAINERS.yml
Signed-off-by: Josuah Demangeon <me@josuah.net>
Return the whole video_buffer structure instead of just the index.
This helps to make index transparent to application and also make the
buffer accessible from the application.
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
1-byte write in mt9m114_write_reg() was not assigned to `val` variable,
which caused uninitialized value to be written to the register, and
causing corrupted / invalid byte write.
Introduced from commit e3a7a32334
Signed-off-by: Hong Nguyen <hong.nguyen.k54@gmail.com>
Add optional H.264 test stream support to the video software generator.
Generate the Annex-B stream at build time with ffmpeg and copy one access
unit into each video buffer.
Signed-off-by: Mohammad Massoudi <m.massoudi32@gmail.com>
Depending on the series, the JPEG HAL requires either MDMA or
DMA HAL and for some series DMA_EX HAL is required as well.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
- Add pclk-hb-disable DTS property to control PCLK toggling
during horizontal blank periods. Different camera receivers may
have different requirement on this configuration.
- Reorder initialization sequence to apply format settings after
the common initialization table. Different format may apply differnt
configurations and overwrite the default configurations.
- Change the input XCLK frequency from 6MHz to 24MHz. According to
the data sheet and software application note, the camera sensor
requires the clock to be within the range of 10~48 MHz and the
typical value is 24 MHz. It can work with 6MHz XCLK but the
performance is not ideal. For example it glitches with VGA resolution.
- Fix resolution-specific register tables for QCIF, CIF, and VGA modes
with corrected timing and gamma settings for OV7670. When the OV7670
driver was originally enabled with the camera receiver smartdma, only
the QVGA resolution is tested, since smartdma can only support this
resolution, the others are not tested.
- Fix comment typo: case 352 is CIF, not QCIF
- Fix array size bug in QVGA format selection
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>