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>
This commit is contained in:
Phi Bang Nguyen 2025-02-10 14:15:51 +01:00 committed by Benjamin Cabé
commit b341d9d6a4
17 changed files with 141 additions and 232 deletions

View file

@ -471,6 +471,10 @@ Video
``pitch = width * video_pix_fmt_bpp(pixfmt)`` needs to be replaced by an equivalent
``pitch = width * video_bits_per_pixel(pixfmt) / BITS_PER_BYTE``.
* The :c:func:`video_stream_start` and :c:func:`video_stream_stop` driver APIs are now merged
into the new :c:func:`video_set_stream` driver API. The user APIs are however unchanged to
keep backward compatibility with downstream applications.
Watchdog
========

View file

@ -77,6 +77,9 @@ Removed APIs and options
and only supported 8-bit depth to :c:func:`video_bits_per_pixel()` returning
the *bit* count and supporting any color depth.
* The ``video_stream_start()`` and ``video_stream_stop()`` driver APIs have been
replaced by ``video_set_stream()``.
* :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO`
* The :kconfig:option:`CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE` option has been removed
@ -161,6 +164,11 @@ New APIs and options
* Image management :c:macro:`MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED` now has image data field
:c:struct:`img_mgmt_image_confirmed`.
* Video
* :c:func:`video_set_stream()` driver API has replaced :c:func:`video_stream_start()` and
:c:func:`video_stream_stop()` driver APIs.
* Other
* :kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA`

View file

@ -1076,18 +1076,12 @@ static int gc2145_get_fmt(const struct device *dev, enum video_endpoint_id ep,
return 0;
}
static int gc2145_stream_start(const struct device *dev)
static int gc2145_set_stream(const struct device *dev, bool enable)
{
const struct gc2145_config *cfg = dev->config;
return gc2145_write_reg(&cfg->i2c, 0xf2, 0x0f);
}
static int gc2145_stream_stop(const struct device *dev)
{
const struct gc2145_config *cfg = dev->config;
return gc2145_write_reg(&cfg->i2c, 0xf2, 0x00);
return enable ? gc2145_write_reg(&cfg->i2c, 0xf2, 0x0f)
: gc2145_write_reg(&cfg->i2c, 0xf2, 0x00);
}
static int gc2145_get_caps(const struct device *dev, enum video_endpoint_id ep,
@ -1113,8 +1107,7 @@ static DEVICE_API(video, gc2145_driver_api) = {
.set_format = gc2145_set_fmt,
.get_format = gc2145_get_fmt,
.get_caps = gc2145_get_caps,
.stream_start = gc2145_stream_start,
.stream_stop = gc2145_stream_stop,
.set_stream = gc2145_set_stream,
.set_ctrl = gc2145_set_ctrl,
};

View file

@ -451,14 +451,10 @@ static int mt9m114_get_fmt(const struct device *dev, enum video_endpoint_id ep,
return 0;
}
static int mt9m114_stream_start(const struct device *dev)
static int mt9m114_set_stream(const struct device *dev, bool enable)
{
return mt9m114_set_state(dev, MT9M114_SYS_STATE_START_STREAMING);
}
static int mt9m114_stream_stop(const struct device *dev)
{
return mt9m114_set_state(dev, MT9M114_SYS_STATE_ENTER_SUSPEND);
return enable ? mt9m114_set_state(dev, MT9M114_SYS_STATE_START_STREAMING)
: mt9m114_set_state(dev, MT9M114_SYS_STATE_ENTER_SUSPEND);
}
static int mt9m114_get_caps(const struct device *dev, enum video_endpoint_id ep,
@ -499,8 +495,7 @@ static DEVICE_API(video, mt9m114_driver_api) = {
.set_format = mt9m114_set_fmt,
.get_format = mt9m114_get_fmt,
.get_caps = mt9m114_get_caps,
.stream_start = mt9m114_stream_start,
.stream_stop = mt9m114_stream_stop,
.set_stream = mt9m114_set_stream,
.set_ctrl = mt9m114_set_ctrl,
};

View file

@ -910,12 +910,7 @@ static int ov2640_get_fmt(const struct device *dev,
return 0;
}
static int ov2640_stream_start(const struct device *dev)
{
return 0;
}
static int ov2640_stream_stop(const struct device *dev)
static int ov2640_set_stream(const struct device *dev, bool enable)
{
return 0;
}
@ -975,8 +970,7 @@ static DEVICE_API(video, ov2640_driver_api) = {
.set_format = ov2640_set_fmt,
.get_format = ov2640_get_fmt,
.get_caps = ov2640_get_caps,
.stream_start = ov2640_stream_start,
.stream_stop = ov2640_stream_stop,
.set_stream = ov2640_set_stream,
.set_ctrl = ov2640_set_ctrl,
};

View file

@ -862,38 +862,21 @@ static int ov5640_get_caps(const struct device *dev, enum video_endpoint_id ep,
return 0;
}
static int ov5640_stream_start(const struct device *dev)
static int ov5640_set_stream(const struct device *dev, bool enable)
{
const struct ov5640_config *cfg = dev->config;
if (!ov5640_is_dvp(dev)) {
/* Power up MIPI PHY HS Tx & LP Rx in 2 data lanes mode */
int ret = ov5640_write_reg(&cfg->i2c, IO_MIPI_CTRL00_REG, 0x45);
/* Power up / down MIPI PHY HS Tx & LP Rx in 2 data lanes mode */
int ret = ov5640_write_reg(&cfg->i2c, IO_MIPI_CTRL00_REG, enable ? 0x45 : 0x40);
if (ret) {
LOG_ERR("Unable to power up MIPI PHY");
LOG_ERR("Unable to power up / down MIPI PHY");
return ret;
}
}
return ov5640_write_reg(&cfg->i2c, SYS_CTRL0_REG, SYS_CTRL0_SW_PWUP);
}
static int ov5640_stream_stop(const struct device *dev)
{
const struct ov5640_config *cfg = dev->config;
if (!ov5640_is_dvp(dev)) {
/* Power down MIPI PHY HS Tx & LP Rx */
int ret = ov5640_write_reg(&cfg->i2c, IO_MIPI_CTRL00_REG, 0x40);
if (ret) {
LOG_ERR("Unable to power down MIPI PHY");
return ret;
}
}
return ov5640_write_reg(&cfg->i2c, SYS_CTRL0_REG, SYS_CTRL0_SW_PWDN);
return ov5640_write_reg(&cfg->i2c, SYS_CTRL0_REG,
enable ? SYS_CTRL0_SW_PWUP : SYS_CTRL0_SW_PWDN);
}
#define TEST_PATTERN_ENABLE BIT(7)
@ -1164,8 +1147,7 @@ static DEVICE_API(video, ov5640_driver_api) = {
.set_format = ov5640_set_fmt,
.get_format = ov5640_get_fmt,
.get_caps = ov5640_get_caps,
.stream_start = ov5640_stream_start,
.stream_stop = ov5640_stream_stop,
.set_stream = ov5640_set_stream,
.set_ctrl = ov5640_set_ctrl,
.get_ctrl = ov5640_get_ctrl,
.set_frmival = ov5640_set_frmival,

View file

@ -550,12 +550,7 @@ static int ov7670_init(const struct device *dev)
return 0;
}
static int ov7670_stream_start(const struct device *dev)
{
return 0;
}
static int ov7670_stream_stop(const struct device *dev)
static int ov7670_set_stream(const struct device *dev, bool enable)
{
return 0;
}
@ -580,8 +575,7 @@ static DEVICE_API(video, ov7670_api) = {
.set_format = ov7670_set_fmt,
.get_format = ov7670_get_fmt,
.get_caps = ov7670_get_caps,
.stream_start = ov7670_stream_start,
.stream_stop = ov7670_stream_stop,
.set_stream = ov7670_set_stream,
.set_ctrl = ov7670_set_ctrl,
};

View file

@ -517,12 +517,7 @@ static int ov7725_get_fmt(const struct device *dev,
return 0;
}
static int ov7725_stream_start(const struct device *dev)
{
return 0;
}
static int ov7725_stream_stop(const struct device *dev)
static int ov7725_set_stream(const struct device *dev, bool enable)
{
return 0;
}
@ -552,8 +547,7 @@ static DEVICE_API(video, ov7725_driver_api) = {
.set_format = ov7725_set_fmt,
.get_format = ov7725_get_fmt,
.get_caps = ov7725_get_caps,
.stream_start = ov7725_stream_start,
.stream_stop = ov7725_stream_stop,
.set_stream = ov7725_set_stream,
};
static int ov7725_init(const struct device *dev)

View file

@ -423,14 +423,9 @@ static int emul_imager_get_caps(const struct device *dev, enum video_endpoint_id
return 0;
}
static int emul_imager_stream_start(const struct device *dev)
static int emul_imager_set_stream(const struct device *dev, bool enable)
{
return emul_imager_write_reg(dev, EMUL_IMAGER_REG_CTRL, 1);
}
static int emul_imager_stream_stop(const struct device *dev)
{
return emul_imager_write_reg(dev, EMUL_IMAGER_REG_CTRL, 0);
return emul_imager_write_reg(dev, EMUL_IMAGER_REG_CTRL, enable ? 1 : 0);
}
static DEVICE_API(video, emul_imager_driver_api) = {
@ -442,8 +437,7 @@ static DEVICE_API(video, emul_imager_driver_api) = {
.set_format = emul_imager_set_fmt,
.get_format = emul_imager_get_fmt,
.get_caps = emul_imager_get_caps,
.stream_start = emul_imager_stream_start,
.stream_stop = emul_imager_stream_stop,
.set_stream = emul_imager_set_stream,
};
int emul_imager_init(const struct device *dev)

View file

@ -131,20 +131,12 @@ static int emul_rx_get_caps(const struct device *dev, enum video_endpoint_id ep,
return video_get_caps(cfg->source_dev, VIDEO_EP_OUT, caps);
}
static int emul_rx_stream_start(const struct device *dev)
static int emul_rx_set_stream(const struct device *dev, bool enable)
{
const struct emul_rx_config *cfg = dev->config;
/* A real hardware driver would first start its own peripheral */
return video_stream_start(cfg->source_dev);
}
static int emul_rx_stream_stop(const struct device *dev)
{
const struct emul_rx_config *cfg = dev->config;
return video_stream_stop(cfg->source_dev);
/* A real hardware driver would then stop its own peripheral */
/* A real hardware driver would first start / stop its own peripheral */
return enable ? video_stream_start(cfg->source_dev) : video_stream_stop(cfg->source_dev);
}
static void emul_rx_worker(struct k_work *work)
@ -259,8 +251,7 @@ static DEVICE_API(video, emul_rx_driver_api) = {
.set_format = emul_rx_set_fmt,
.get_format = emul_rx_get_fmt,
.get_caps = emul_rx_get_caps,
.stream_start = emul_rx_stream_start,
.stream_stop = emul_rx_stream_stop,
.set_stream = emul_rx_set_stream,
.enqueue = emul_rx_enqueue,
.dequeue = emul_rx_dequeue,
.flush = emul_rx_flush,

View file

@ -133,7 +133,7 @@ void video_esp32_dma_rx_done(const struct device *dev, void *user_data, uint32_t
video_esp32_reload_dma(data);
}
static int video_esp32_stream_start(const struct device *dev)
static int video_esp32_set_stream(const struct device *dev, bool enable)
{
const struct video_esp32_config *cfg = dev->config;
struct video_esp32_data *data = dev->data;
@ -143,6 +143,25 @@ static int video_esp32_stream_start(const struct device *dev)
uint32_t buffer_size = 0;
int error = 0;
if (!enable) {
LOG_DBG("Stop streaming");
if (video_stream_stop(cfg->source_dev)) {
return -EIO;
}
data->is_streaming = false;
error = dma_stop(cfg->dma_dev, cfg->rx_dma_channel);
if (error) {
LOG_ERR("Unable to stop DMA (%d)", ret);
return error;
}
cam_hal_stop_streaming(&data->hal);
return 0;
}
if (data->is_streaming) {
return -EBUSY;
}
@ -219,29 +238,6 @@ static int video_esp32_stream_start(const struct device *dev)
return 0;
}
static int video_esp32_stream_stop(const struct device *dev)
{
const struct video_esp32_config *cfg = dev->config;
struct video_esp32_data *data = dev->data;
int ret = 0;
LOG_DBG("Stop streaming");
if (video_stream_stop(cfg->source_dev)) {
return -EIO;
}
data->is_streaming = false;
ret = dma_stop(cfg->dma_dev, cfg->rx_dma_channel);
if (ret) {
LOG_ERR("Unable to stop DMA (%d)", ret);
return ret;
}
cam_hal_stop_streaming(&data->hal);
return 0;
}
static int video_esp32_get_caps(const struct device *dev, enum video_endpoint_id ep,
struct video_caps *caps)
{
@ -400,8 +396,7 @@ static DEVICE_API(video, esp32_driver_api) = {
/* mandatory callbacks */
.set_format = video_esp32_set_fmt,
.get_format = video_esp32_get_fmt,
.stream_start = video_esp32_stream_start,
.stream_stop = video_esp32_stream_stop,
.set_stream = video_esp32_set_stream,
.get_caps = video_esp32_get_caps,
/* optional callbacks */
.enqueue = video_esp32_enqueue,

View file

@ -194,37 +194,30 @@ static int video_mcux_csi_get_fmt(const struct device *dev, enum video_endpoint_
return -EIO;
}
static int video_mcux_csi_stream_start(const struct device *dev)
static int video_mcux_csi_set_stream(const struct device *dev, bool enable)
{
const struct video_mcux_csi_config *config = dev->config;
struct video_mcux_csi_data *data = dev->data;
status_t ret;
ret = CSI_TransferStart(config->base, &data->csi_handle);
if (ret != kStatus_Success) {
return -EIO;
}
if (enable) {
ret = CSI_TransferStart(config->base, &data->csi_handle);
if (ret != kStatus_Success) {
return -EIO;
}
if (config->source_dev && video_stream_start(config->source_dev)) {
return -EIO;
}
if (config->source_dev && video_stream_start(config->source_dev)) {
return -EIO;
}
} else {
if (config->source_dev && video_stream_stop(config->source_dev)) {
return -EIO;
}
return 0;
}
static int video_mcux_csi_stream_stop(const struct device *dev)
{
const struct video_mcux_csi_config *config = dev->config;
struct video_mcux_csi_data *data = dev->data;
status_t ret;
if (config->source_dev && video_stream_stop(config->source_dev)) {
return -EIO;
}
ret = CSI_TransferStop(config->base, &data->csi_handle);
if (ret != kStatus_Success) {
return -EIO;
ret = CSI_TransferStop(config->base, &data->csi_handle);
if (ret != kStatus_Success) {
return -EIO;
}
}
return 0;
@ -471,8 +464,7 @@ static int video_mcux_csi_enum_frmival(const struct device *dev, enum video_endp
static DEVICE_API(video, video_mcux_csi_driver_api) = {
.set_format = video_mcux_csi_set_fmt,
.get_format = video_mcux_csi_get_fmt,
.stream_start = video_mcux_csi_stream_start,
.stream_stop = video_mcux_csi_stream_stop,
.set_stream = video_mcux_csi_set_stream,
.flush = video_mcux_csi_flush,
.enqueue = video_mcux_csi_enqueue,
.dequeue = video_mcux_csi_dequeue,

View file

@ -146,29 +146,23 @@ static int mipi_csi2rx_get_fmt(const struct device *dev, enum video_endpoint_id
return 0;
}
static int mipi_csi2rx_stream_start(const struct device *dev)
{
const struct mipi_csi2rx_config *config = dev->config;
struct mipi_csi2rx_data *drv_data = dev->data;
CSI2RX_Init((MIPI_CSI2RX_Type *)config->base, &drv_data->csi2rxConfig);
if (video_stream_start(config->sensor_dev)) {
return -EIO;
}
return 0;
}
static int mipi_csi2rx_stream_stop(const struct device *dev)
static int mipi_csi2rx_set_stream(const struct device *dev, bool enable)
{
const struct mipi_csi2rx_config *config = dev->config;
if (video_stream_stop(config->sensor_dev)) {
return -EIO;
}
if (enable) {
struct mipi_csi2rx_data *drv_data = dev->data;
CSI2RX_Deinit((MIPI_CSI2RX_Type *)config->base);
CSI2RX_Init((MIPI_CSI2RX_Type *)config->base, &drv_data->csi2rxConfig);
if (video_stream_start(config->sensor_dev)) {
return -EIO;
}
} else {
if (video_stream_stop(config->sensor_dev)) {
return -EIO;
}
CSI2RX_Deinit((MIPI_CSI2RX_Type *)config->base);
}
return 0;
}
@ -310,8 +304,7 @@ static DEVICE_API(video, mipi_csi2rx_driver_api) = {
.get_caps = mipi_csi2rx_get_caps,
.get_format = mipi_csi2rx_get_fmt,
.set_format = mipi_csi2rx_set_fmt,
.stream_start = mipi_csi2rx_stream_start,
.stream_stop = mipi_csi2rx_stream_stop,
.set_stream = mipi_csi2rx_set_stream,
.set_ctrl = mipi_csi2rx_set_ctrl,
.set_frmival = mipi_csi2rx_set_frmival,
.get_frmival = mipi_csi2rx_get_frmival,

View file

@ -93,13 +93,17 @@ static void nxp_video_sdma_callback(const struct device *dev, void *user_data,
data->buf_reload_flag = !data->buf_reload_flag;
}
static int nxp_video_sdma_stream_start(const struct device *dev)
static int nxp_video_sdma_set_stream(const struct device *dev, bool enable)
{
const struct nxp_video_sdma_config *config = dev->config;
struct nxp_video_sdma_data *data = dev->data;
struct dma_config sdma_config = {0};
int ret;
if (!enable) {
return dma_stop(config->dma_dev, 0);
}
/* Setup dma configuration for SmartDMA */
sdma_config.dma_slot = kSMARTDMA_CameraDiv16FrameQVGA;
sdma_config.dma_callback = nxp_video_sdma_callback;
@ -142,14 +146,6 @@ static int nxp_video_sdma_stream_start(const struct device *dev)
return 0;
}
static int nxp_video_sdma_stream_stop(const struct device *dev)
{
const struct nxp_video_sdma_config *config = dev->config;
/* Stop DMA engine */
return dma_stop(config->dma_dev, 0);
}
static int nxp_video_sdma_enqueue(const struct device *dev,
enum video_endpoint_id ep,
struct video_buffer *vbuf)
@ -170,7 +166,7 @@ static int nxp_video_sdma_enqueue(const struct device *dev,
k_fifo_put(&data->fifo_in, vbuf);
if (data->stream_starved) {
/* Kick SmartDMA off */
nxp_video_sdma_stream_start(dev);
nxp_video_sdma_set_stream(dev, true);
}
return 0;
}
@ -361,8 +357,7 @@ static DEVICE_API(video, nxp_video_sdma_api) = {
.get_format = nxp_video_sdma_get_format,
.set_format = nxp_video_sdma_set_format,
.get_caps = nxp_video_sdma_get_caps,
.stream_start = nxp_video_sdma_stream_start,
.stream_stop = nxp_video_sdma_stream_stop,
.set_stream = nxp_video_sdma_set_stream,
.enqueue = nxp_video_sdma_enqueue,
.dequeue = nxp_video_sdma_dequeue,
.flush = nxp_video_sdma_flush

View file

@ -246,11 +246,29 @@ static int video_stm32_dcmi_get_fmt(const struct device *dev,
return 0;
}
static int video_stm32_dcmi_stream_start(const struct device *dev)
static int video_stm32_dcmi_set_stream(const struct device *dev, bool enable)
{
int err;
struct video_stm32_dcmi_data *data = dev->data;
const struct video_stm32_dcmi_config *config = dev->config;
if (!enable) {
if (video_stream_stop(config->sensor_dev)) {
return -EIO;
}
err = HAL_DCMI_Stop(&data->hdcmi);
if (err != HAL_OK) {
LOG_ERR("Failed to stop DCMI");
return -EIO;
}
/* Release the video buffer allocated when start streaming */
k_fifo_put(&data->fifo_in, data->vbuf);
return 0;
}
data->vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
if (data->vbuf == NULL) {
@ -258,7 +276,7 @@ static int video_stm32_dcmi_stream_start(const struct device *dev)
return -ENOMEM;
}
int err = HAL_DCMI_Start_DMA(&data->hdcmi, DCMI_MODE_CONTINUOUS,
err = HAL_DCMI_Start_DMA(&data->hdcmi, DCMI_MODE_CONTINUOUS,
(uint32_t)data->vbuf->buffer, data->vbuf->bytesused / 4);
if (err != HAL_OK) {
LOG_ERR("Failed to start DCMI DMA");
@ -272,28 +290,6 @@ static int video_stm32_dcmi_stream_start(const struct device *dev)
return 0;
}
static int video_stm32_dcmi_stream_stop(const struct device *dev)
{
struct video_stm32_dcmi_data *data = dev->data;
const struct video_stm32_dcmi_config *config = dev->config;
int err;
if (video_stream_stop(config->sensor_dev)) {
return -EIO;
}
err = HAL_DCMI_Stop(&data->hdcmi);
if (err != HAL_OK) {
LOG_ERR("Failed to stop DCMI");
return -EIO;
}
/* Release the video buffer allocated in stream_start */
k_fifo_put(&data->fifo_in, data->vbuf);
return 0;
}
static int video_stm32_dcmi_enqueue(const struct device *dev,
enum video_endpoint_id ep,
struct video_buffer *vbuf)
@ -381,8 +377,7 @@ static inline int video_stm32_dcmi_get_ctrl(const struct device *dev, unsigned i
static DEVICE_API(video, video_stm32_dcmi_driver_api) = {
.set_format = video_stm32_dcmi_set_fmt,
.get_format = video_stm32_dcmi_get_fmt,
.stream_start = video_stm32_dcmi_stream_start,
.stream_stop = video_stm32_dcmi_stream_stop,
.set_stream = video_stm32_dcmi_set_stream,
.enqueue = video_stm32_dcmi_enqueue,
.dequeue = video_stm32_dcmi_dequeue,
.get_caps = video_stm32_dcmi_get_caps,

View file

@ -99,20 +99,15 @@ static int video_sw_generator_get_fmt(const struct device *dev, enum video_endpo
return 0;
}
static int video_sw_generator_stream_start(const struct device *dev)
static int video_sw_generator_set_stream(const struct device *dev, bool enable)
{
struct video_sw_generator_data *data = dev->data;
k_work_schedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
return 0;
}
static int video_sw_generator_stream_stop(const struct device *dev)
{
struct video_sw_generator_data *data = dev->data;
k_work_cancel_delayable_sync(&data->buf_work, &data->work_sync);
if (enable) {
k_work_schedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
} else {
k_work_cancel_delayable_sync(&data->buf_work, &data->work_sync);
}
return 0;
}
@ -340,8 +335,7 @@ static int video_sw_generator_enum_frmival(const struct device *dev, enum video_
static DEVICE_API(video, video_sw_generator_driver_api) = {
.set_format = video_sw_generator_set_fmt,
.get_format = video_sw_generator_get_fmt,
.stream_start = video_sw_generator_stream_start,
.stream_stop = video_sw_generator_stream_stop,
.set_stream = video_sw_generator_set_stream,
.flush = video_sw_generator_flush,
.enqueue = video_sw_generator_enqueue,
.dequeue = video_sw_generator_dequeue,

View file

@ -302,20 +302,17 @@ typedef int (*video_api_dequeue_t)(const struct device *dev, enum video_endpoint
typedef int (*video_api_flush_t)(const struct device *dev, enum video_endpoint_id ep, bool cancel);
/**
* @typedef video_api_stream_start_t
* @brief Start the capture or output process.
* @typedef video_api_set_stream_t
* @brief Start or stop streaming on the video device.
*
* See video_stream_start() for argument descriptions.
*/
typedef int (*video_api_stream_start_t)(const struct device *dev);
/**
* @typedef video_api_stream_stop_t
* @brief Stop the capture or output process.
* Start (enable == true) or stop (enable == false) streaming on the video device.
*
* See video_stream_stop() for argument descriptions.
* @param dev Pointer to the device structure.
* @param enable If true, start streaming, otherwise stop streaming.
*
* @retval 0 on success, otherwise a negative errno code.
*/
typedef int (*video_api_stream_stop_t)(const struct device *dev);
typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable);
/**
* @typedef video_api_set_ctrl_t
@ -355,8 +352,7 @@ __subsystem struct video_driver_api {
/* mandatory callbacks */
video_api_set_format_t set_format;
video_api_get_format_t get_format;
video_api_stream_start_t stream_start;
video_api_stream_stop_t stream_stop;
video_api_set_stream_t set_stream;
video_api_get_caps_t get_caps;
/* optional callbacks */
video_api_enqueue_t enqueue;
@ -598,11 +594,11 @@ static inline int video_stream_start(const struct device *dev)
{
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
if (api->stream_start == NULL) {
if (api->set_stream == NULL) {
return -ENOSYS;
}
return api->stream_start(dev);
return api->set_stream(dev, true);
}
/**
@ -619,11 +615,11 @@ static inline int video_stream_stop(const struct device *dev)
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
int ret;
if (api->stream_stop == NULL) {
if (api->set_stream == NULL) {
return -ENOSYS;
}
ret = api->stream_stop(dev);
ret = api->set_stream(dev, false);
video_flush(dev, VIDEO_EP_ALL, true);
return ret;