From: Dave Stevenson <dave.stevenson@raspberrypi.com>
To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com,
linux-media@vger.kernel.org
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
Subject: [PATCH 05/16] media: i2c: ov9281: Support more than 1 mode.
Date: Wed, 5 Oct 2022 16:27:58 +0100 [thread overview]
Message-ID: <20221005152809.3785786-6-dave.stevenson@raspberrypi.com> (raw)
In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com>
The driver currently has multiple assumptions that there is
only one supported mode.
Convert supported_mode to an array, and fix up all references
to correctly look at that array.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
drivers/media/i2c/ov9282.c | 44 ++++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index 798ff8ba50bd..f7823d584522 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -262,20 +262,24 @@ static const struct ov9282_reg mode_1280x720_regs[] = {
};
/* Supported sensor mode configurations */
-static const struct ov9282_mode supported_mode = {
- .width = 1280,
- .height = 720,
- .hblank = 250,
- .vblank = 1022,
- .vblank_min = 151,
- .vblank_max = 51540,
- .link_freq_idx = 0,
- .reg_list = {
- .num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
- .regs = mode_1280x720_regs,
+static const struct ov9282_mode supported_modes[] = {
+ {
+ .width = 1280,
+ .height = 720,
+ .hblank = 250,
+ .vblank = 1022,
+ .vblank_min = 151,
+ .vblank_max = 51540,
+ .link_freq_idx = 0,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
+ .regs = mode_1280x720_regs,
+ },
},
};
+#define OV9282_NUM_MODES ARRAY_SIZE(supported_modes)
+
/**
* to_ov9282() - ov9282 V4L2 sub-device to ov9282 device.
* @subdev: pointer to ov9282 V4L2 sub-device
@@ -536,15 +540,15 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_size_enum *fsize)
{
- if (fsize->index > 0)
+ if (fsize->index >= OV9282_NUM_MODES)
return -EINVAL;
if (fsize->code != MEDIA_BUS_FMT_Y10_1X10)
return -EINVAL;
- fsize->min_width = supported_mode.width;
+ fsize->min_width = supported_modes[fsize->index].width;
fsize->max_width = fsize->min_width;
- fsize->min_height = supported_mode.height;
+ fsize->min_height = supported_modes[fsize->index].height;
fsize->max_height = fsize->min_height;
return 0;
@@ -619,7 +623,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd,
mutex_lock(&ov9282->mutex);
- mode = &supported_mode;
+ mode = v4l2_find_nearest_size(supported_modes,
+ OV9282_NUM_MODES,
+ width, height,
+ fmt->format.width,
+ fmt->format.height);
ov9282_fill_pad_format(ov9282, mode, fmt);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
@@ -652,7 +660,7 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd,
struct v4l2_subdev_format fmt = { 0 };
fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
- ov9282_fill_pad_format(ov9282, &supported_mode, &fmt);
+ ov9282_fill_pad_format(ov9282, &supported_modes[0], &fmt);
return ov9282_set_pad_format(sd, sd_state, &fmt);
}
@@ -1081,8 +1089,8 @@ static int ov9282_probe(struct i2c_client *client)
goto error_power_off;
}
- /* Set default mode to max resolution */
- ov9282->cur_mode = &supported_mode;
+ /* Set default mode to first mode */
+ ov9282->cur_mode = &supported_modes[0];
ov9282->vblank = ov9282->cur_mode->vblank;
ret = ov9282_init_controls(ov9282);
--
2.34.1
next prev parent reply other threads:[~2022-10-05 15:28 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 15:27 [PATCH 00/16] Updates to ov9282 sensor driver Dave Stevenson
2022-10-05 15:27 ` [PATCH 01/16] media: i2c: ov9282: Remove duplication of registers Dave Stevenson
2022-10-06 9:14 ` Jacopo Mondi
2022-10-05 15:27 ` [PATCH 02/16] media: i2c: ov9282: Split registers into common and mode specific Dave Stevenson
2022-10-06 9:15 ` Jacopo Mondi
2022-10-05 15:27 ` [PATCH 03/16] media: i2c: ov9282: Remove format code from the mode Dave Stevenson
2022-10-06 9:15 ` Jacopo Mondi
2022-10-05 15:27 ` [PATCH 04/16] media: i2c: ov9282: Remove pixel rate from mode definition Dave Stevenson
2022-10-06 9:17 ` Jacopo Mondi
2022-10-06 11:51 ` Dave Stevenson
2022-10-05 15:27 ` Dave Stevenson [this message]
2022-10-06 9:18 ` [PATCH 05/16] media: i2c: ov9281: Support more than 1 mode Jacopo Mondi
2022-10-26 7:22 ` Sakari Ailus
2022-10-05 15:27 ` [PATCH 06/16] media: i2c: ov9282: Correct HTS register for configured pixel rate Dave Stevenson
2022-10-06 9:23 ` Jacopo Mondi
2022-10-06 13:01 ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 07/16] media: i2c: ov9282: Reduce vblank_min values based on testing Dave Stevenson
2022-10-06 11:56 ` Jacopo Mondi
2022-10-06 13:02 ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 08/16] media: i2c: ov9282: Add selection for CSI2 clock mode Dave Stevenson
2022-10-06 9:24 ` Jacopo Mondi
2022-10-26 7:21 ` Sakari Ailus
2022-10-28 12:57 ` Dave Stevenson
2022-10-28 14:30 ` Sakari Ailus
2022-10-28 15:03 ` Dave Stevenson
2022-10-31 13:06 ` Sakari Ailus
2022-10-05 15:28 ` [PATCH 09/16] media: i2c: ov9282: Add the properties from fwnode Dave Stevenson
2022-10-06 11:57 ` Jacopo Mondi
2022-10-05 15:28 ` [PATCH 10/16] media: i2c: ov9282: Action CID_VBLANK when set Dave Stevenson
2022-10-06 9:29 ` Jacopo Mondi
2022-10-06 13:21 ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 11/16] media: i2c: ov9282: Add HFLIP and VFLIP support Dave Stevenson
2022-10-06 9:38 ` Jacopo Mondi
2022-10-06 14:21 ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 12/16] media: i2c: ov9282: Make V4L2_CID_HBLANK r/w Dave Stevenson
2022-10-06 9:41 ` Jacopo Mondi
2022-10-06 11:33 ` Dave Stevenson
2022-10-06 11:53 ` Jacopo Mondi
2022-10-05 15:28 ` [PATCH 13/16] media: i2c: ov9282: Add selection API calls for cropping info Dave Stevenson
2022-10-06 9:43 ` Jacopo Mondi
2022-10-06 11:39 ` Dave Stevenson
2022-10-06 11:54 ` Jacopo Mondi
2022-10-05 15:28 ` [PATCH 14/16] media: i2c: ov9282: Add support for 1280x800 and 640x400 modes Dave Stevenson
2022-10-06 9:48 ` Jacopo Mondi
2022-10-06 11:46 ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 15/16] media: i2c: ov9282: Add support for 8bit readout Dave Stevenson
2022-10-06 9:57 ` Jacopo Mondi
2022-10-06 12:20 ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 16/16] media: i2c: ov9282: Support event handlers Dave Stevenson
2022-10-06 9:59 ` Jacopo Mondi
2022-10-07 10:22 ` Dave Stevenson
2022-10-07 12:57 ` Jacopo Mondi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221005152809.3785786-6-dave.stevenson@raspberrypi.com \
--to=dave.stevenson@raspberrypi.com \
--cc=daniele.alessandrelli@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=paul.j.murphy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox