[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250221-imx219_fixes_v2-v2-3-a72154c7c267@ideasonboard.com>
Date: Fri, 21 Feb 2025 16:22:15 +0530
From: Jai Luthra <jai.luthra@...asonboard.com>
To: Sakari Ailus <sakari.ailus@...ux.intel.com>,
Dave Stevenson <dave.stevenson@...pberrypi.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Jacopo Mondi <jacopo.mondi@...asonboard.com>,
Jai Luthra <jai.luthra@...asonboard.com>
Subject: [PATCH v2 3/3] media: i2c: imx219: Only use higher LLP_MIN for
binned resolutions
The LLP_MIN of 3560 is only needed to fix artefacts seen with binned
resolutions. As increasing the LLP reduces the highest possible
framerate by ~3%, use the old default minimum of 3448 if we are not
doing 2x2 analog binning.
Also restore the fll_def value for non-binned modes in the modes
definition to restore the default mode framerate to 30fps.
Suggested-by: Dave Stevenson <dave.stevenson@...pberrypi.com>
Link: https://lore.kernel.org/linux-media/CAPY8ntC1-S6zKtDvmc6EgyxP+j6rTShuG8Dr8PKb9XQr2PeS_w@mail.gmail.com/
Signed-off-by: Jai Luthra <jai.luthra@...asonboard.com>
---
Changes in v2:
- Fix the binning check, and only update the LLP minimum if we are
doing analog binning
- Add a note in the commit message for the fll_def value reverts
---
drivers/media/i2c/imx219.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 2081822533f9dff0a1ca93a09dd8333ec4043645..ec8d32b0f9e75b4b14d905b1e6b85180e5697ce1 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -74,7 +74,8 @@
#define IMX219_FLL_MAX 0xffff
#define IMX219_VBLANK_MIN 32
#define IMX219_REG_LINE_LENGTH_A CCI_REG16(0x0162)
-#define IMX219_LLP_MIN 0x0de8
+#define IMX219_LLP_MIN 0x0d78
+#define IMX219_BINNED_LLP_MIN 0x0de8
#define IMX219_LLP_MAX 0x7ff0
#define IMX219_REG_X_ADD_STA_A CCI_REG16(0x0164)
@@ -311,13 +312,13 @@ static const struct imx219_mode supported_modes[] = {
/* 8MPix 15fps mode */
.width = 3280,
.height = 2464,
- .fll_def = 3415,
+ .fll_def = 3526,
},
{
/* 1080P 30fps cropped */
.width = 1920,
.height = 1080,
- .fll_def = 1707,
+ .fll_def = 1763,
},
{
/* 2x2 binned 60fps mode */
@@ -865,7 +866,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
const struct imx219_mode *mode;
struct v4l2_mbus_framefmt *format;
struct v4l2_rect *crop;
- unsigned int bin_h, bin_v;
+ u8 bin_h, bin_v;
u32 prev_line_len;
format = v4l2_subdev_state_get_format(state, 0);
@@ -895,7 +896,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
int exposure_max;
int exposure_def;
- int hblank;
+ int hblank, llp_min;
int pixel_rate;
/* Update limits and set FPS to default */
@@ -912,6 +913,19 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
imx219->exposure->minimum,
exposure_max, imx219->exposure->step,
exposure_def);
+
+ /*
+ * With analog binning the default minimum line length of 3448
+ * can cause artefacts with RAW10 formats, because the ADC
+ * operates on two lines together. So we switch to a higher
+ * minimum of 3560.
+ */
+ imx219_get_binning(state, &bin_h, &bin_v);
+ llp_min = (bin_h & bin_v) == IMX219_BINNING_X2_ANALOG ?
+ IMX219_BINNED_LLP_MIN : IMX219_LLP_MIN;
+ __v4l2_ctrl_modify_range(imx219->hblank, llp_min - mode->width,
+ IMX219_LLP_MAX - mode->width, 1,
+ llp_min - mode->width);
/*
* Retain PPL setting from previous mode so that the
* line time does not change on a mode change.
@@ -920,10 +934,6 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
* mode width subtracted.
*/
hblank = prev_line_len - mode->width;
- __v4l2_ctrl_modify_range(imx219->hblank,
- IMX219_LLP_MIN - mode->width,
- IMX219_LLP_MAX - mode->width, 1,
- IMX219_LLP_MIN - mode->width);
__v4l2_ctrl_s_ctrl(imx219->hblank, hblank);
/* Scale the pixel rate based on the mode specific factor */
--
2.48.1
Powered by blists - more mailing lists