Skip to content

video: Drop video endpoint id in video APIs #87070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8 changes: 8 additions & 0 deletions doc/releases/migration-guide-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ Video
:c:func:`video_set_frmival`.
See (:github:`89627`).

* video_endpoint_id enum has been dropped. It is no longer a parameter in any video API.

* video_buf_type enum has been added. It is a required parameter in the following video APIs:

``set_stream``
``video_stream_start``
``video_stream_stop``

Other subsystems
****************

Expand Down
13 changes: 5 additions & 8 deletions drivers/video/gc2145.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,7 @@ static uint8_t gc2145_check_connection(const struct device *dev)
return 0;
}

static int gc2145_set_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int gc2145_set_fmt(const struct device *dev, struct video_format *fmt)
{
struct gc2145_data *drv_data = dev->data;
size_t res = ARRAY_SIZE(fmts);
Expand Down Expand Up @@ -1085,8 +1084,7 @@ static int gc2145_set_fmt(const struct device *dev, enum video_endpoint_id ep,
return 0;
}

static int gc2145_get_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int gc2145_get_fmt(const struct device *dev, struct video_format *fmt)
{
struct gc2145_data *drv_data = dev->data;

Expand All @@ -1095,16 +1093,15 @@ static int gc2145_get_fmt(const struct device *dev, enum video_endpoint_id ep,
return 0;
}

static int gc2145_set_stream(const struct device *dev, bool enable)
static int gc2145_set_stream(const struct device *dev, bool enable, enum video_buf_type type)
{
const struct gc2145_config *cfg = dev->config;

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,
struct video_caps *caps)
static int gc2145_get_caps(const struct device *dev, struct video_caps *caps)
{
caps->format_caps = fmts;
return 0;
Expand Down Expand Up @@ -1188,7 +1185,7 @@ static int gc2145_init(const struct device *dev)
fmt.height = RESOLUTION_QVGA_H;
fmt.pitch = RESOLUTION_QVGA_W * 2;

ret = gc2145_set_fmt(dev, VIDEO_EP_OUT, &fmt);
ret = gc2145_set_fmt(dev, &fmt);
if (ret) {
LOG_ERR("Unable to configure default format");
return ret;
Expand Down
13 changes: 5 additions & 8 deletions drivers/video/mt9m114.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ static int mt9m114_set_output_format(const struct device *dev, int pixel_format)
return ret;
}

static int mt9m114_set_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int mt9m114_set_fmt(const struct device *dev, struct video_format *fmt)
{
struct mt9m114_data *drv_data = dev->data;
int ret;
Expand Down Expand Up @@ -450,8 +449,7 @@ static int mt9m114_set_fmt(const struct device *dev, enum video_endpoint_id ep,
return mt9m114_set_state(dev, MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
}

static int mt9m114_get_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int mt9m114_get_fmt(const struct device *dev, struct video_format *fmt)
{
struct mt9m114_data *drv_data = dev->data;

Expand All @@ -460,14 +458,13 @@ static int mt9m114_get_fmt(const struct device *dev, enum video_endpoint_id ep,
return 0;
}

static int mt9m114_set_stream(const struct device *dev, bool enable)
static int mt9m114_set_stream(const struct device *dev, bool enable, enum video_buf_type type)
{
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,
struct video_caps *caps)
static int mt9m114_get_caps(const struct device *dev, struct video_caps *caps)
{
caps->format_caps = fmts;
return 0;
Expand Down Expand Up @@ -563,7 +560,7 @@ static int mt9m114_init(const struct device *dev)
fmt.height = 272;
fmt.pitch = fmt.width * 2;

ret = mt9m114_set_fmt(dev, VIDEO_EP_OUT, &fmt);
ret = mt9m114_set_fmt(dev, &fmt);
if (ret) {
LOG_ERR("Unable to configure default format");
return -EIO;
Expand Down
14 changes: 5 additions & 9 deletions drivers/video/ov2640.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,7 @@ uint8_t ov2640_check_connection(const struct device *dev)
return ret;
}

static int ov2640_set_fmt(const struct device *dev,
enum video_endpoint_id ep, struct video_format *fmt)
static int ov2640_set_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov2640_data *drv_data = dev->data;
uint16_t width, height;
Expand Down Expand Up @@ -872,8 +871,7 @@ static int ov2640_set_fmt(const struct device *dev,
return -ENOTSUP;
}

static int ov2640_get_fmt(const struct device *dev,
enum video_endpoint_id ep, struct video_format *fmt)
static int ov2640_get_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov2640_data *drv_data = dev->data;

Expand All @@ -882,14 +880,12 @@ static int ov2640_get_fmt(const struct device *dev,
return 0;
}

static int ov2640_set_stream(const struct device *dev, bool enable)
static int ov2640_set_stream(const struct device *dev, bool enable, enum video_buf_type type)
{
return 0;
}

static int ov2640_get_caps(const struct device *dev,
enum video_endpoint_id ep,
struct video_caps *caps)
static int ov2640_get_caps(const struct device *dev, struct video_caps *caps)
{
caps->format_caps = fmts;
return 0;
Expand Down Expand Up @@ -1037,7 +1033,7 @@ static int ov2640_init(const struct device *dev)
fmt.width = SVGA_HSIZE;
fmt.height = SVGA_VSIZE;
fmt.pitch = SVGA_HSIZE * 2;
ret = ov2640_set_fmt(dev, VIDEO_EP_OUT, &fmt);
ret = ov2640_set_fmt(dev, &fmt);
if (ret) {
LOG_ERR("Unable to configure default format");
return -EIO;
Expand Down
24 changes: 9 additions & 15 deletions drivers/video/ov5640.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,7 @@ static int ov5640_set_fmt_dvp(const struct ov5640_config *cfg)
return 0;
}

static int ov5640_set_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival *frmival)
static int ov5640_set_frmival(const struct device *dev, struct video_frmival *frmival)
{
const struct ov5640_config *cfg = dev->config;
struct ov5640_data *drv_data = dev->data;
Expand Down Expand Up @@ -823,8 +822,7 @@ static int ov5640_set_frmival(const struct device *dev, enum video_endpoint_id e
return 0;
}

static int ov5640_set_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int ov5640_set_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov5640_data *drv_data = dev->data;
const struct ov5640_config *cfg = dev->config;
Expand Down Expand Up @@ -906,11 +904,10 @@ static int ov5640_set_fmt(const struct device *dev, enum video_endpoint_id ep,
def_frmival.denominator = drv_data->cur_mode->def_frmrate;
def_frmival.numerator = 1;

return ov5640_set_frmival(dev, ep, &def_frmival);
return ov5640_set_frmival(dev, &def_frmival);
}

static int ov5640_get_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int ov5640_get_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov5640_data *drv_data = dev->data;

Expand All @@ -919,14 +916,13 @@ static int ov5640_get_fmt(const struct device *dev, enum video_endpoint_id ep,
return 0;
}

static int ov5640_get_caps(const struct device *dev, enum video_endpoint_id ep,
struct video_caps *caps)
static int ov5640_get_caps(const struct device *dev, struct video_caps *caps)
{
caps->format_caps = ov5640_is_dvp(dev) ? dvp_fmts : csi2_fmts;
return 0;
}

static int ov5640_set_stream(const struct device *dev, bool enable)
static int ov5640_set_stream(const struct device *dev, bool enable, enum video_buf_type type)
{
const struct ov5640_config *cfg = dev->config;

Expand Down Expand Up @@ -1177,8 +1173,7 @@ static int ov5640_get_volatile_ctrl(const struct device *dev, uint32_t id)
return 0;
}

static int ov5640_get_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival *frmival)
static int ov5640_get_frmival(const struct device *dev, struct video_frmival *frmival)
{
struct ov5640_data *drv_data = dev->data;

Expand All @@ -1192,8 +1187,7 @@ static int ov5640_get_frmival(const struct device *dev, enum video_endpoint_id e
return 0;
}

static int ov5640_enum_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival_enum *fie)
static int ov5640_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
{
uint8_t i = 0;

Expand Down Expand Up @@ -1430,7 +1424,7 @@ static int ov5640_init(const struct device *dev)
fmt.height = 720;
}
fmt.pitch = fmt.width * 2;
ret = ov5640_set_fmt(dev, VIDEO_EP_OUT, &fmt);
ret = ov5640_set_fmt(dev, &fmt);
if (ret) {
LOG_ERR("Unable to configure default format");
return -EIO;
Expand Down
13 changes: 5 additions & 8 deletions drivers/video/ov7670.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,13 @@ static const struct ov7670_reg ov7670_init_regtbl[] = {
{0xb8, 0x0a},
};

static int ov7670_get_caps(const struct device *dev, enum video_endpoint_id ep,
struct video_caps *caps)
static int ov7670_get_caps(const struct device *dev, struct video_caps *caps)
{
caps->format_caps = fmts;
return 0;
}

static int ov7670_set_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int ov7670_set_fmt(const struct device *dev, struct video_format *fmt)
{
const struct ov7670_config *config = dev->config;
struct ov7670_data *data = dev->data;
Expand Down Expand Up @@ -446,8 +444,7 @@ static int ov7670_set_fmt(const struct device *dev, enum video_endpoint_id ep,
return -ENOTSUP;
}

static int ov7670_get_fmt(const struct device *dev, enum video_endpoint_id ep,
struct video_format *fmt)
static int ov7670_get_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov7670_data *data = dev->data;

Expand Down Expand Up @@ -558,7 +555,7 @@ static int ov7670_init(const struct device *dev)
fmt.width = 640;
fmt.height = 480;
fmt.pitch = fmt.width * 2;
ret = ov7670_set_fmt(dev, VIDEO_EP_OUT, &fmt);
ret = ov7670_set_fmt(dev, &fmt);
if (ret < 0) {
return ret;
}
Expand All @@ -576,7 +573,7 @@ static int ov7670_init(const struct device *dev)
return ov7670_init_controls(dev);
}

static int ov7670_set_stream(const struct device *dev, bool enable)
static int ov7670_set_stream(const struct device *dev, bool enable, enum video_buf_type type)
{
return 0;
}
Expand Down
16 changes: 5 additions & 11 deletions drivers/video/ov7725.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,7 @@ static int ov7725_set_clock(const struct device *dev,
return -1;
}

static int ov7725_set_fmt(const struct device *dev,
enum video_endpoint_id ep,
struct video_format *fmt)
static int ov7725_set_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov7725_data *drv_data = dev->data;
const struct ov7725_config *cfg = dev->config;
Expand Down Expand Up @@ -508,9 +506,7 @@ static int ov7725_set_fmt(const struct device *dev,
((width & 3U) << 0U));
}

static int ov7725_get_fmt(const struct device *dev,
enum video_endpoint_id ep,
struct video_format *fmt)
static int ov7725_get_fmt(const struct device *dev, struct video_format *fmt)
{
struct ov7725_data *drv_data = dev->data;

Expand All @@ -519,7 +515,7 @@ static int ov7725_get_fmt(const struct device *dev,
return 0;
}

static int ov7725_set_stream(const struct device *dev, bool enable)
static int ov7725_set_stream(const struct device *dev, bool enable, enum video_buf_type type)
{
return 0;
}
Expand All @@ -537,9 +533,7 @@ static const struct video_format_cap fmts[] = {
{ 0 }
};

static int ov7725_get_caps(const struct device *dev,
enum video_endpoint_id ep,
struct video_caps *caps)
static int ov7725_get_caps(const struct device *dev, struct video_caps *caps)
{
caps->format_caps = fmts;
return 0;
Expand Down Expand Up @@ -599,7 +593,7 @@ static int ov7725_init(const struct device *dev)
fmt.width = 640;
fmt.height = 480;
fmt.pitch = 640 * 2;
ret = ov7725_set_fmt(dev, VIDEO_EP_OUT, &fmt);
ret = ov7725_set_fmt(dev, &fmt);
if (ret) {
LOG_ERR("Unable to configure default format");
return -EIO;
Expand Down
5 changes: 2 additions & 3 deletions drivers/video/video_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ void video_closest_frmival_stepwise(const struct video_frmival_stepwise *stepwis
stepwise->step.denominator * desired->denominator;
}

void video_closest_frmival(const struct device *dev, enum video_endpoint_id ep,
struct video_frmival_enum *match)
void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match)
{
struct video_frmival desired = match->discrete;
struct video_frmival_enum fie = {.format = match->format};
Expand All @@ -136,7 +135,7 @@ void video_closest_frmival(const struct device *dev, enum video_endpoint_id ep,
__ASSERT(match->type != VIDEO_FRMIVAL_TYPE_STEPWISE,
"cannot find range matching the range, only a value matching the range");

for (fie.index = 0; video_enum_frmival(dev, ep, &fie) == 0; fie.index++) {
for (fie.index = 0; video_enum_frmival(dev, &fie) == 0; fie.index++) {
struct video_frmival tmp = {0};
uint64_t diff_nsec = 0;
uint64_t tmp_nsec;
Expand Down
Loading