1 From 71fdb5d9021eb4aba727af8e5a7daedeb2f00860 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 17 Feb 2022 16:23:23 +0000
4 Subject: [PATCH] media: i2c: ov7251: Add get_selection for
5 NATIVE_SIZE, CROP_BOUNDS, CROP_DEFAULT
7 As required by libcamera, add get_selection handling for
8 V4L2_SEL_TGT_NATIVE_SIZE, V4L2_SEL_TGT_CROP_DEFAULT, and
9 V4L2_SEL_TGT_CROP_BOUNDS.
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 drivers/media/i2c/ov7251.c | 45 ++++++++++++++++++++++++++++++++------
14 1 file changed, 38 insertions(+), 7 deletions(-)
16 --- a/drivers/media/i2c/ov7251.c
17 +++ b/drivers/media/i2c/ov7251.c
19 #define OV7251_PLL2_SYS_DIV_REG 0x309a
20 #define OV7251_PLL2_ADC_DIV_REG 0x309b
23 + * OV7251 native and active pixel array size.
24 + * Datasheet not available to confirm these values, so assume there are no
27 +#define OV7251_NATIVE_WIDTH 640U
28 +#define OV7251_NATIVE_HEIGHT 480U
29 +#define OV7251_PIXEL_ARRAY_LEFT 0U
30 +#define OV7251_PIXEL_ARRAY_TOP 0U
31 +#define OV7251_PIXEL_ARRAY_WIDTH 640U
32 +#define OV7251_PIXEL_ARRAY_HEIGHT 480U
34 #define OV7251_PIXEL_CLOCK 48000000
37 @@ -1212,15 +1224,34 @@ static int ov7251_get_selection(struct v
39 struct ov7251 *ov7251 = to_ov7251(sd);
41 - if (sel->target != V4L2_SEL_TGT_CROP)
43 + switch (sel->target) {
44 + case V4L2_SEL_TGT_CROP:
45 + mutex_lock(&ov7251->lock);
46 + sel->r = *__ov7251_get_pad_crop(ov7251, sd_state, sel->pad,
48 + mutex_unlock(&ov7251->lock);
50 - mutex_lock(&ov7251->lock);
51 - sel->r = *__ov7251_get_pad_crop(ov7251, sd_state, sel->pad,
53 - mutex_unlock(&ov7251->lock);
57 + case V4L2_SEL_TGT_NATIVE_SIZE:
60 + sel->r.width = OV7251_NATIVE_WIDTH;
61 + sel->r.height = OV7251_NATIVE_HEIGHT;
65 + case V4L2_SEL_TGT_CROP_DEFAULT:
66 + case V4L2_SEL_TGT_CROP_BOUNDS:
67 + sel->r.top = OV7251_PIXEL_ARRAY_TOP;
68 + sel->r.left = OV7251_PIXEL_ARRAY_LEFT;
69 + sel->r.width = OV7251_PIXEL_ARRAY_WIDTH;
70 + sel->r.height = OV7251_PIXEL_ARRAY_HEIGHT;
78 static int ov7251_s_stream(struct v4l2_subdev *subdev, int enable)