* [PATCH 0/2] media: Add get_selecton to ov56470 and ov13858
@ 2020-12-11 14:14 Jacopo Mondi
2020-12-11 14:14 ` [PATCH 1/2] media: i2c: ov13858: Add .get_selection support Jacopo Mondi
2020-12-11 14:14 ` [PATCH 2/2] media: i2c: ov5670: " Jacopo Mondi
0 siblings, 2 replies; 3+ messages in thread
From: Jacopo Mondi @ 2020-12-11 14:14 UTC (permalink / raw)
To: mchehab, sakari.ailus; +Cc: Jacopo Mondi, tfiga, linux-media
Add support for the .get_selection pad operation to ov5670 and ov13858
sensor drivers.
Support the V4L2_SEL_TGT_CROP_BOUNDS and V4L2_SEL_TGT_CROP_DEFAULT
targets which report the same rectangles, as the size of the active
and readable pixel matrix is the only information available in public
documentation.
Question: do I really need to initialize the try_crop rectangle at open() time?
I don't think it's strictly necessary, but for simmetry and to guard against
future developments, I think it's fair to have it.
Thanks
j
Jacopo Mondi (2):
media: i2c: ov13858: Add .get_selection support
media: i2c: ov5670: Add .get_selection support
drivers/media/i2c/ov13858.c | 31 +++++++++++++++++++++++++++++++
drivers/media/i2c/ov5670.c | 32 +++++++++++++++++++++++++++++++-
2 files changed, 62 insertions(+), 1 deletion(-)
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] media: i2c: ov13858: Add .get_selection support
2020-12-11 14:14 [PATCH 0/2] media: Add get_selecton to ov56470 and ov13858 Jacopo Mondi
@ 2020-12-11 14:14 ` Jacopo Mondi
2020-12-11 14:14 ` [PATCH 2/2] media: i2c: ov5670: " Jacopo Mondi
1 sibling, 0 replies; 3+ messages in thread
From: Jacopo Mondi @ 2020-12-11 14:14 UTC (permalink / raw)
To: mchehab, sakari.ailus; +Cc: Jacopo Mondi, tfiga, linux-media
Add support for the get_selection subdev pad operation.
Support the V4L2_SEL_TGT_CROP_DEFAULT and V4L2_SEL_TGT_CROP_BOUNDS
static targets only to report the active pixel array size.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
drivers/media/i2c/ov13858.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index 2f3be7a80cef4..5cda917e10569 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -82,6 +82,10 @@
/* Number of frames to skip */
#define OV13858_NUM_OF_SKIP_FRAMES 2
+/* OV13858 pixel array size. */
+#define OV13858_PIXEL_ARRAY_WIDTH 4256
+#define OV13858_PIXEL_ARRAY_HEIGHT 3168
+
struct ov13858_reg {
u16 address;
u8 val;
@@ -1152,6 +1156,7 @@ static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd,
fh->pad,
0);
+ struct v4l2_rect *try_crop;
mutex_lock(&ov13858->mutex);
@@ -1161,6 +1166,13 @@ static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
try_fmt->field = V4L2_FIELD_NONE;
+ /* Initialize try_crop */
+ try_crop = v4l2_subdev_get_try_crop(sd, fh->pad, 0);
+ try_crop->top = 0;
+ try_crop->left = 0;
+ try_crop->width = OV13858_PIXEL_ARRAY_WIDTH;
+ try_crop->height = OV13858_PIXEL_ARRAY_HEIGHT;
+
/* No crop or compose */
mutex_unlock(&ov13858->mutex);
@@ -1402,6 +1414,24 @@ ov13858_set_pad_format(struct v4l2_subdev *sd,
return 0;
}
+static int ov13858_get_selection(struct v4l2_subdev *sd,
+ struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_selection *sel)
+{
+ switch (sel->target) {
+ case V4L2_SEL_TGT_CROP_DEFAULT:
+ case V4L2_SEL_TGT_CROP_BOUNDS:
+ sel->r.top = 0;
+ sel->r.left = 0;
+ sel->r.width = OV13858_PIXEL_ARRAY_WIDTH;
+ sel->r.height = OV13858_PIXEL_ARRAY_HEIGHT;
+
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
static int ov13858_get_skip_frames(struct v4l2_subdev *sd, u32 *frames)
{
*frames = OV13858_NUM_OF_SKIP_FRAMES;
@@ -1563,6 +1593,7 @@ static const struct v4l2_subdev_pad_ops ov13858_pad_ops = {
.enum_mbus_code = ov13858_enum_mbus_code,
.get_fmt = ov13858_get_pad_format,
.set_fmt = ov13858_set_pad_format,
+ .get_selection = ov13858_get_selection,
.enum_frame_size = ov13858_enum_frame_size,
};
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] media: i2c: ov5670: Add .get_selection support
2020-12-11 14:14 [PATCH 0/2] media: Add get_selecton to ov56470 and ov13858 Jacopo Mondi
2020-12-11 14:14 ` [PATCH 1/2] media: i2c: ov13858: Add .get_selection support Jacopo Mondi
@ 2020-12-11 14:14 ` Jacopo Mondi
1 sibling, 0 replies; 3+ messages in thread
From: Jacopo Mondi @ 2020-12-11 14:14 UTC (permalink / raw)
To: mchehab, sakari.ailus; +Cc: Jacopo Mondi, tfiga, linux-media
Add support for the get_selection subdev pad operation.
Support the V4L2_SEL_TGT_CROP_DEFAULT and V4L2_SEL_TGT_CROP_BOUNDS
static targets only to report the active pixel array size.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
drivers/media/i2c/ov5670.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index 148fd4e05029a..7f85ae1d93faf 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -67,6 +67,10 @@
/* Initial number of frames to skip to avoid possible garbage */
#define OV5670_NUM_OF_SKIP_FRAMES 2
+/* OV5670 pixel array size. */
+#define OV5670_PIXEL_ARRAY_WIDTH 2592
+#define OV5670_PIXEL_ARRAY_HEIGHT 1944
+
struct ov5670_reg {
u16 address;
u8 val;
@@ -1938,6 +1942,7 @@ static int ov5670_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
struct ov5670 *ov5670 = to_ov5670(sd);
struct v4l2_mbus_framefmt *try_fmt =
v4l2_subdev_get_try_format(sd, fh->pad, 0);
+ struct v4l2_rect *try_crop;
mutex_lock(&ov5670->mutex);
@@ -1947,7 +1952,13 @@ static int ov5670_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
try_fmt->field = V4L2_FIELD_NONE;
- /* No crop or compose */
+ /* Initialize try_crop */
+ try_crop = v4l2_subdev_get_try_crop(sd, fh->pad, 0);
+ try_crop->top = 0;
+ try_crop->left = 0;
+ try_crop->width = OV5670_PIXEL_ARRAY_WIDTH;
+ try_crop->height = OV5670_PIXEL_ARRAY_HEIGHT;
+
mutex_unlock(&ov5670->mutex);
return 0;
@@ -2263,6 +2274,24 @@ static int ov5670_set_pad_format(struct v4l2_subdev *sd,
return 0;
}
+static int ov5670_get_selection(struct v4l2_subdev *sd,
+ struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_selection *sel)
+{
+ switch (sel->target) {
+ case V4L2_SEL_TGT_CROP_DEFAULT:
+ case V4L2_SEL_TGT_CROP_BOUNDS:
+ sel->r.top = 0;
+ sel->r.left = 0;
+ sel->r.width = OV5670_PIXEL_ARRAY_WIDTH;
+ sel->r.height = OV5670_PIXEL_ARRAY_HEIGHT;
+
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
static int ov5670_get_skip_frames(struct v4l2_subdev *sd, u32 *frames)
{
*frames = OV5670_NUM_OF_SKIP_FRAMES;
@@ -2428,6 +2457,7 @@ static const struct v4l2_subdev_pad_ops ov5670_pad_ops = {
.enum_mbus_code = ov5670_enum_mbus_code,
.get_fmt = ov5670_get_pad_format,
.set_fmt = ov5670_set_pad_format,
+ .get_selection = ov5670_get_selection,
.enum_frame_size = ov5670_enum_frame_size,
};
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-12 1:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 14:14 [PATCH 0/2] media: Add get_selecton to ov56470 and ov13858 Jacopo Mondi
2020-12-11 14:14 ` [PATCH 1/2] media: i2c: ov13858: Add .get_selection support Jacopo Mondi
2020-12-11 14:14 ` [PATCH 2/2] media: i2c: ov5670: " Jacopo Mondi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.