Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/video/gc2145.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <zephyr/device.h>

#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video-controls.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/gpio.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/video/ov2640.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <zephyr/device.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video-controls.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/gpio.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/video/ov5640.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video-controls.h>

LOG_MODULE_REGISTER(video_ov5640, CONFIG_VIDEO_LOG_LEVEL);

Expand Down
1 change: 1 addition & 0 deletions drivers/video/video_sw_generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <zephyr/kernel.h>
#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video-controls.h>
#include <zephyr/logging/log.h>

LOG_MODULE_REGISTER(video_sw_generator, CONFIG_VIDEO_LOG_LEVEL);
Expand Down
116 changes: 37 additions & 79 deletions include/zephyr/drivers/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@

#include <zephyr/types.h>

#include <zephyr/drivers/video-controls.h>

#ifdef __cplusplus
extern "C" {
#endif


/**
* @struct video_format
* @brief Video format structure
Expand All @@ -57,7 +54,6 @@ struct video_format {
uint32_t pitch;
};


/**
* @struct video_format_cap
* @brief Video format capability
Expand Down Expand Up @@ -211,8 +207,7 @@ enum video_signal_result {
*
* See video_set_format() for argument descriptions.
*/
typedef int (*video_api_set_format_t)(const struct device *dev,
enum video_endpoint_id ep,
typedef int (*video_api_set_format_t)(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt);

/**
Expand All @@ -221,8 +216,7 @@ typedef int (*video_api_set_format_t)(const struct device *dev,
*
* See video_get_format() for argument descriptions.
*/
typedef int (*video_api_get_format_t)(const struct device *dev,
enum video_endpoint_id ep,
typedef int (*video_api_get_format_t)(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt);

/**
Expand Down Expand Up @@ -258,8 +252,7 @@ typedef int (*video_api_enum_frmival_t)(const struct device *dev, enum video_end
*
* See video_enqueue() for argument descriptions.
*/
typedef int (*video_api_enqueue_t)(const struct device *dev,
enum video_endpoint_id ep,
typedef int (*video_api_enqueue_t)(const struct device *dev, enum video_endpoint_id ep,
struct video_buffer *buf);

/**
Expand All @@ -268,10 +261,8 @@ typedef int (*video_api_enqueue_t)(const struct device *dev,
*
* See video_dequeue() for argument descriptions.
*/
typedef int (*video_api_dequeue_t)(const struct device *dev,
enum video_endpoint_id ep,
struct video_buffer **buf,
k_timeout_t timeout);
typedef int (*video_api_dequeue_t)(const struct device *dev, enum video_endpoint_id ep,
struct video_buffer **buf, k_timeout_t timeout);

/**
* @typedef video_api_flush_t
Expand All @@ -280,9 +271,7 @@ typedef int (*video_api_dequeue_t)(const struct device *dev,
*
* See video_flush() for argument descriptions.
*/
typedef int (*video_api_flush_t)(const struct device *dev,
enum video_endpoint_id ep,
bool cancel);
typedef int (*video_api_flush_t)(const struct device *dev, enum video_endpoint_id ep, bool cancel);

/**
* @typedef video_api_stream_start_t
Expand All @@ -306,28 +295,23 @@ typedef int (*video_api_stream_stop_t)(const struct device *dev);
*
* See video_set_ctrl() for argument descriptions.
*/
typedef int (*video_api_set_ctrl_t)(const struct device *dev,
unsigned int cid,
void *value);
typedef int (*video_api_set_ctrl_t)(const struct device *dev, unsigned int cid, void *value);

/**
* @typedef video_api_get_ctrl_t
* @brief Get a video control value.
*
* See video_get_ctrl() for argument descriptions.
*/
typedef int (*video_api_get_ctrl_t)(const struct device *dev,
unsigned int cid,
void *value);
typedef int (*video_api_get_ctrl_t)(const struct device *dev, unsigned int cid, void *value);

/**
* @typedef video_api_get_caps_t
* @brief Get capabilities of a video endpoint.
*
* See video_get_caps() for argument descriptions.
*/
typedef int (*video_api_get_caps_t)(const struct device *dev,
enum video_endpoint_id ep,
typedef int (*video_api_get_caps_t)(const struct device *dev, enum video_endpoint_id ep,
struct video_caps *caps);

/**
Expand All @@ -336,8 +320,7 @@ typedef int (*video_api_get_caps_t)(const struct device *dev,
*
* See video_set_signal() for argument descriptions.
*/
typedef int (*video_api_set_signal_t)(const struct device *dev,
enum video_endpoint_id ep,
typedef int (*video_api_set_signal_t)(const struct device *dev, enum video_endpoint_id ep,
struct k_poll_signal *signal);

__subsystem struct video_driver_api {
Expand Down Expand Up @@ -373,12 +356,10 @@ __subsystem struct video_driver_api {
* @retval -ENOTSUP If format is not supported.
* @retval -EIO General input / output error.
*/
static inline int video_set_format(const struct device *dev,
enum video_endpoint_id ep,
static inline int video_set_format(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->set_format == NULL) {
return -ENOSYS;
Expand All @@ -398,12 +379,10 @@ static inline int video_set_format(const struct device *dev,
*
* @retval pointer to video format
*/
static inline int video_get_format(const struct device *dev,
enum video_endpoint_id ep,
static inline int video_get_format(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->get_format == NULL) {
return -ENOSYS;
Expand Down Expand Up @@ -511,12 +490,10 @@ static inline int video_enum_frmival(const struct device *dev, enum video_endpoi
* @retval -EINVAL If parameters are invalid.
* @retval -EIO General input / output error.
*/
static inline int video_enqueue(const struct device *dev,
enum video_endpoint_id ep,
static inline int video_enqueue(const struct device *dev, enum video_endpoint_id ep,
struct video_buffer *buf)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->enqueue == NULL) {
return -ENOSYS;
Expand All @@ -540,13 +517,10 @@ static inline int video_enqueue(const struct device *dev,
* @retval -EINVAL If parameters are invalid.
* @retval -EIO General input / output error.
*/
static inline int video_dequeue(const struct device *dev,
enum video_endpoint_id ep,
struct video_buffer **buf,
k_timeout_t timeout)
static inline int video_dequeue(const struct device *dev, enum video_endpoint_id ep,
struct video_buffer **buf, k_timeout_t timeout)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->dequeue == NULL) {
return -ENOSYS;
Expand All @@ -555,7 +529,6 @@ static inline int video_dequeue(const struct device *dev,
return api->dequeue(dev, ep, buf, timeout);
}


/**
* @brief Flush endpoint buffers.
*
Expand All @@ -570,12 +543,9 @@ static inline int video_dequeue(const struct device *dev,
*
* @retval 0 Is successful, -ERRNO code otherwise.
*/
static inline int video_flush(const struct device *dev,
enum video_endpoint_id ep,
bool cancel)
static inline int video_flush(const struct device *dev, enum video_endpoint_id ep, bool cancel)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->flush == NULL) {
return -ENOSYS;
Expand All @@ -598,8 +568,7 @@ static inline int video_flush(const struct device *dev,
*/
static inline int video_stream_start(const struct device *dev)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->stream_start == NULL) {
return -ENOSYS;
Expand All @@ -619,8 +588,7 @@ static inline int video_stream_start(const struct device *dev)
*/
static inline int video_stream_stop(const struct device *dev)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
int ret;

if (api->stream_stop == NULL) {
Expand All @@ -642,12 +610,10 @@ static inline int video_stream_stop(const struct device *dev)
*
* @retval 0 Is successful, -ERRNO code otherwise.
*/
static inline int video_get_caps(const struct device *dev,
enum video_endpoint_id ep,
static inline int video_get_caps(const struct device *dev, enum video_endpoint_id ep,
struct video_caps *caps)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->get_caps == NULL) {
return -ENOSYS;
Expand All @@ -671,11 +637,9 @@ static inline int video_get_caps(const struct device *dev,
* @retval -ENOTSUP If format is not supported.
* @retval -EIO General input / output error.
*/
static inline int video_set_ctrl(const struct device *dev, unsigned int cid,
void *value)
static inline int video_set_ctrl(const struct device *dev, unsigned int cid, void *value)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->set_ctrl == NULL) {
return -ENOSYS;
Expand All @@ -699,11 +663,9 @@ static inline int video_set_ctrl(const struct device *dev, unsigned int cid,
* @retval -ENOTSUP If format is not supported.
* @retval -EIO General input / output error.
*/
static inline int video_get_ctrl(const struct device *dev, unsigned int cid,
void *value)
static inline int video_get_ctrl(const struct device *dev, unsigned int cid, void *value)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->get_ctrl == NULL) {
return -ENOSYS;
Expand All @@ -725,12 +687,10 @@ static inline int video_get_ctrl(const struct device *dev, unsigned int cid,
*
* @retval 0 Is successful, -ERRNO code otherwise.
*/
static inline int video_set_signal(const struct device *dev,
enum video_endpoint_id ep,
static inline int video_set_signal(const struct device *dev, enum video_endpoint_id ep,
struct k_poll_signal *signal)
{
const struct video_driver_api *api =
(const struct video_driver_api *)dev->api;
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;

if (api->set_signal == NULL) {
return -ENOSYS;
Expand Down Expand Up @@ -765,12 +725,10 @@ struct video_buffer *video_buffer_alloc(size_t size);
*/
void video_buffer_release(struct video_buffer *buf);


/* fourcc - four-character-code */
#define video_fourcc(a, b, c, d)\
#define video_fourcc(a, b, c, d) \
((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))


/**
* @defgroup video_pixel_formats Video pixel formats
* @{
Expand All @@ -782,13 +740,13 @@ void video_buffer_release(struct video_buffer *buf);
*/

/** BGGR8 pixel format */
#define VIDEO_PIX_FMT_BGGR8 video_fourcc('B', 'G', 'G', 'R') /* 8 BGBG.. GRGR.. */
#define VIDEO_PIX_FMT_BGGR8 video_fourcc('B', 'G', 'G', 'R') /* 8 BGBG.. GRGR.. */
/** GBRG8 pixel format */
#define VIDEO_PIX_FMT_GBRG8 video_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
#define VIDEO_PIX_FMT_GBRG8 video_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
/** GRBG8 pixel format */
#define VIDEO_PIX_FMT_GRBG8 video_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
#define VIDEO_PIX_FMT_GRBG8 video_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
/** RGGB8 pixel format */
#define VIDEO_PIX_FMT_RGGB8 video_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */
#define VIDEO_PIX_FMT_RGGB8 video_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */

/**
* @}
Expand Down Expand Up @@ -831,7 +789,7 @@ void video_buffer_release(struct video_buffer *buf);
*/

/** JPEG pixel format */
#define VIDEO_PIX_FMT_JPEG video_fourcc('J', 'P', 'E', 'G') /* 8 JPEG */
#define VIDEO_PIX_FMT_JPEG video_fourcc('J', 'P', 'E', 'G') /* 8 JPEG */

/**
* @}
Expand Down
1 change: 1 addition & 0 deletions samples/drivers/video/capture_to_lvgl/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <zephyr/device.h>
#include <zephyr/drivers/display.h>
#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video-controls.h>
#include <lvgl.h>

#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
Expand Down
Loading