Skip to contentSkip to conversation

media: mt9p031: Implement crop bounds get selection

PATCH Superseded Marek Vasut 2 participants 4 messages Jun 18, 2022 – Jun 19, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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]>
---
 drivers/media/i2c/mt9p031.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9p031.c +13 -5
index cbce8b88dbcf5..e73e814c60207 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_DEF;
+		sel->r.top = MT9P031_ROW_START_DEF;
+		sel->r.width = MT9P031_WINDOW_WIDTH_DEF;
+		sel->r.height = MT9P031_WINDOW_HEIGHT_DEF;
+		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
#1 lore raw

Hi Marek,

Thank you for the patch.

Quoted 17 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]>
---
 drivers/media/i2c/mt9p031.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9p031.c +0 -0
index cbce8b88dbcf5..e73e814c60207 100644

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

Quoted 8 lines
drivers/media/i2c/mt9p031.c +4 -1
@@ -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_DEF;
+		sel->r.top = MT9P031_ROW_START_DEF;

Shouldn't this be MT9P031_COLUMN_START_MIN and MT9P031_ROW_START_MIN ?

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

Quoted 2 lines
drivers/media/i2c/mt9p031.c +2 -0
+		sel->r.width = MT9P031_WINDOW_WIDTH_DEF;
+		sel->r.height = MT9P031_WINDOW_HEIGHT_DEF;

And here MT9P031_WINDOW_WIDTH_MAX and MT9P031_WINDOW_HEIGHT_MAX ?

Quoted 15 lines
drivers/media/i2c/mt9p031.c +7 -4
+		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 · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
Quoted 33 lines · Laurent Pinchart

Hi Marek,

Thank you for the patch.

Quoted 17 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]>
---
  drivers/media/i2c/mt9p031.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9p031.c +0 -0
index cbce8b88dbcf5..e73e814c60207 100644

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

Quoted 8 lines
drivers/media/i2c/mt9p031.c +4 -1
@@ -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_DEF;
+		sel->r.top = MT9P031_ROW_START_DEF;

Shouldn't this be MT9P031_COLUMN_START_MIN and MT9P031_ROW_START_MIN ?

Quoted 4 lines

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

Quoted 2 lines
drivers/media/i2c/mt9p031.c +2 -0
+		sel->r.width = MT9P031_WINDOW_WIDTH_DEF;
+		sel->r.height = MT9P031_WINDOW_HEIGHT_DEF;

And here MT9P031_WINDOW_WIDTH_MAX and MT9P031_WINDOW_HEIGHT_MAX ?

What makes you think that ?

maintainer
#3 lore raw
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Laurent Pinchart

Hi Marek,

Thank you for the patch.

Quoted 17 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]>
---
  drivers/media/i2c/mt9p031.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9p031.c +0 -0
index cbce8b88dbcf5..e73e814c60207 100644

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

Quoted 8 lines
drivers/media/i2c/mt9p031.c +4 -1
@@ -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_DEF;
+		sel->r.top = MT9P031_ROW_START_DEF;

Shouldn't this be MT9P031_COLUMN_START_MIN and MT9P031_ROW_START_MIN ?

Quoted 6 lines
Quoted 4 lines

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

Quoted 2 lines
drivers/media/i2c/mt9p031.c +2 -0
+		sel->r.width = MT9P031_WINDOW_WIDTH_DEF;
+		sel->r.height = MT9P031_WINDOW_HEIGHT_DEF;

And here MT9P031_WINDOW_WIDTH_MAX and MT9P031_WINDOW_HEIGHT_MAX ?

What makes you think that ?

https://linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/v4l2-selection-targets.html#v4l2-selection-targets

"Bounds of the crop rectangle. All valid crop rectangles fit inside the crop bounds rectangle."

Signature · 3 lines
Regards,

Laurent Pinchart