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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Deduplicate the registers of "modes": only a single definition of each:
pixelformats, resolutions, framerate.
Signed-off-by: Josuah Demangeon <me@josuah.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>