Skip to contentSkip to conversation

media: i2c: ov02e10: Add get_selection support

PATCH In review Marcel Berger 2 participants 2 messages Apr 26 – Apr 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: ov02e10: Add get_selection support

---
 drivers/media/i2c/ov02e10.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/media/i2c/ov02e10.c +25 -0
index 4a64cba..097188f 100644
@@ -655,6 +655,30 @@ static int ov02e10_get_format(struct v4l2_subdev *sd,
 	return 0;
 }
 
+static int ov02e10_get_selection(struct v4l2_subdev *sd,
+				 struct v4l2_subdev_state *sd_state,
+				 struct v4l2_subdev_selection *sel)
+{
+	struct ov02e10 *ov02e10 = to_ov02e10(sd);
+
+	if (sel->pad != 0)
+		return -EINVAL;
+
+	switch (sel->target) {
+	case V4L2_SEL_TGT_CROP:
+	case V4L2_SEL_TGT_CROP_DEFAULT:
+	case V4L2_SEL_TGT_CROP_BOUNDS:
+	case V4L2_SEL_TGT_NATIVE_SIZE:
+		sel->r.left = 0;
+		sel->r.top = 0;
+		sel->r.width = ov02e10->cur_mode->width;
+		sel->r.height = ov02e10->cur_mode->height;
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
 static int ov02e10_enum_mbus_code(struct v4l2_subdev *sd,
 				  struct v4l2_subdev_state *sd_state,
 				  struct v4l2_subdev_mbus_code_enum *code)
@@ -703,6 +727,7 @@ static const struct v4l2_subdev_pad_ops ov02e10_pad_ops = {
 	.get_fmt = ov02e10_get_format,
 	.enum_mbus_code = ov02e10_enum_mbus_code,
 	.enum_frame_size = ov02e10_enum_frame_size,
+	.get_selection = ov02e10_get_selection,
 	.enable_streams = ov02e10_enable_streams,
 	.disable_streams = ov02e10_disable_streams,
 };
Signature · 1 line
2.53.0
#1 lore raw

Quoting Marcel Berger (2026-04-26 21:01:43)

Usually we'd try to add a bit more detail to the commit message here please. Even if it's simple.

Quoted 21 lines
---
 drivers/media/i2c/ov02e10.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/media/i2c/ov02e10.c +8 -0
index 4a64cba..097188f 100644
@@ -655,6 +655,30 @@ static int ov02e10_get_format(struct v4l2_subdev *sd,
        return 0;
 }
 
+static int ov02e10_get_selection(struct v4l2_subdev *sd,
+                                struct v4l2_subdev_state *sd_state,
+                                struct v4l2_subdev_selection *sel)
+{
+       struct ov02e10 *ov02e10 = to_ov02e10(sd);
+
+       if (sel->pad != 0)
+               return -EINVAL;

drivers/media/i2c/ov02e10.c static int ov02e10_get_format(struct v4l2_subdev *sd, · line 675

Quoted 10 lines
drivers/media/i2c/ov02e10.c +10 -0
+
+       switch (sel->target) {
+       case V4L2_SEL_TGT_CROP:
+       case V4L2_SEL_TGT_CROP_DEFAULT:
+       case V4L2_SEL_TGT_CROP_BOUNDS:
+       case V4L2_SEL_TGT_NATIVE_SIZE:
+               sel->r.left = 0;
+               sel->r.top = 0;
+               sel->r.width = ov02e10->cur_mode->width;
+               sel->r.height = ov02e10->cur_mode->height;

I'm afraid this looks wrong, or perhaps insufficient ?

These should report the correct properties of the camera, so I'd expect somewhere for this to report the full resolution of the camera active area - not just always pass through the current active mode.

--
Kieran

Quoted 20 lines
drivers/media/i2c/ov02e10.c +7 -0
+               return 0;
+       default:
+               return -EINVAL;
+       }
+}
+
 static int ov02e10_enum_mbus_code(struct v4l2_subdev *sd,
                                  struct v4l2_subdev_state *sd_state,
                                  struct v4l2_subdev_mbus_code_enum *code)
@@ -703,6 +727,7 @@ static const struct v4l2_subdev_pad_ops ov02e10_pad_ops = {
        .get_fmt = ov02e10_get_format,
        .enum_mbus_code = ov02e10_enum_mbus_code,
        .enum_frame_size = ov02e10_enum_frame_size,
+       .get_selection = ov02e10_get_selection,
        .enable_streams = ov02e10_enable_streams,
        .disable_streams = ov02e10_disable_streams,
 };
Signature · 1 line
2.53.0