Skip to contentSkip to conversation

media: mt9p031: Implement crop bounds get selection

PATCH In review Marek Vasut 2 participants 2 messages Jun 19, 2022 – Jul 11, 2022

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

PATCH v2 1/1 media: mt9p031: Implement crop bounds get selection

Implement V4L2_SEL_TGT_CROP_BOUNDS query in get_selection subdev op for this sensor. This is required e.g. to bind it to STM32MP15x DCMI.

Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stefan Riedmueller <[email protected]>

---
V2: Use min/max sizes for crop bounds

---
 drivers/media/i2c/mt9p031.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9p031.c +13 -5
index cbce8b88dbcf5..69a3165b8fb91 100644
@@ -623,12 +623,20 @@ static int mt9p031_get_selection(struct v4l2_subdev *subdev,
 {
 	struct mt9p031 *mt9p031 = to_mt9p031(subdev);
 
-	if (sel->target != V4L2_SEL_TGT_CROP)
+	switch (sel->target) {
+	case V4L2_SEL_TGT_CROP_BOUNDS:
+		sel->r.left = MT9P031_COLUMN_START_MIN;
+		sel->r.top = MT9P031_ROW_START_MIN;
+		sel->r.width = MT9P031_WINDOW_WIDTH_MAX;
+		sel->r.height = MT9P031_WINDOW_HEIGHT_MAX;
+		return 0;
+	case V4L2_SEL_TGT_CROP:
+		sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state,
+						 sel->pad, sel->which);
+		return 0;
+	default:
 		return -EINVAL;
-
-	sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state, sel->pad,
-					 sel->which);
-	return 0;
+	}
 }
 
 static int mt9p031_set_selection(struct v4l2_subdev *subdev,
Signature · 1 line
2.35.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

Hi Marek,

Thank you for the patch.

Quoted 20 lines · Marek Vasut

Implement V4L2_SEL_TGT_CROP_BOUNDS query in get_selection subdev op for this sensor. This is required e.g. to bind it to STM32MP15x DCMI.

Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stefan Riedmueller <[email protected]>

---
V2: Use min/max sizes for crop bounds

---
 drivers/media/i2c/mt9p031.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9p031.c +0 -0
index cbce8b88dbcf5..69a3165b8fb91 100644
@@ -623,12 +623,20 @@ static int mt9p031_get_selection(struct v4l2_subdev *subdev,
 {

drivers/media/i2c/mt9p031.c static int mt9p031_get_selection(struct v4l2_subdev *subdev, · line 632

Quoted 10 lines
drivers/media/i2c/mt9p031.c +7 -1
 	struct mt9p031 *mt9p031 = to_mt9p031(subdev);
 
-	if (sel->target != V4L2_SEL_TGT_CROP)
+	switch (sel->target) {
+	case V4L2_SEL_TGT_CROP_BOUNDS:
+		sel->r.left = MT9P031_COLUMN_START_MIN;
+		sel->r.top = MT9P031_ROW_START_MIN;
+		sel->r.width = MT9P031_WINDOW_WIDTH_MAX;
+		sel->r.height = MT9P031_WINDOW_HEIGHT_MAX;
+		return 0;

A blank line would be nice.

drivers/media/i2c/mt9p031.c static int mt9p031_get_selection(struct v4l2_subdev *subdev, · line 636

Quoted 4 lines
drivers/media/i2c/mt9p031.c +4 -0
+	case V4L2_SEL_TGT_CROP:
+		sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state,
+						 sel->pad, sel->which);
+		return 0;

Ditto.

This can be changed when applying the patch.

Quoted 10 lines
drivers/media/i2c/mt9p031.c +2 -4
+	default:
 		return -EINVAL;
-
-	sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state, sel->pad,
-					 sel->which);
-	return 0;
+	}
 }
 
 static int mt9p031_set_selection(struct v4l2_subdev *subdev,
Signature · 3 lines
Regards,

Laurent Pinchart