From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: linux-media@vger.kernel.org,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>,
Manivannan Sadhasivam <mani@kernel.org>,
Sakari Ailus <sakari.ailus@iki.fi>
Subject: Re: [PATCH v3 10/15] media: i2c: imx290: Convert V4L2_CID_VBLANK to read/write
Date: Fri, 17 Feb 2023 09:26:00 +0100 [thread overview]
Message-ID: <8184512.T7Z3S40VBb@steina-w> (raw)
In-Reply-To: <20230215223003.30170-11-laurent.pinchart@ideasonboard.com>
Hi Laurent,
thanks for putting these series together.
Am Mittwoch, 15. Februar 2023, 23:29:58 CET schrieb Laurent Pinchart:
> From: Dave Stevenson <dave.stevenson@raspberrypi.com>
>
> The driver exposed V4L2_CID_VBLANK as a read only control to allow
> for exposure calculations and determination of the frame rate.
>
> Convert to a read/write control so that the frame rate can be
> controlled.
> V4L2_CID_VBLANK also sets the limits for the exposure control,
> therefore exposure ranges have to be updated when vblank changes
> (either via s_ctrl, or via changing mode).
>
> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/media/i2c/imx290.c | 58 +++++++++++++++++++++++++++++++-------
> 1 file changed, 48 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
> index f82fb05b6695..1ae01cd43efb 100644
> --- a/drivers/media/i2c/imx290.c
> +++ b/drivers/media/i2c/imx290.c
> @@ -46,6 +46,7 @@
> #define IMX290_BLKLEVEL
IMX290_REG_16BIT(0x300a)
> #define IMX290_GAIN
IMX290_REG_8BIT(0x3014)
> #define IMX290_VMAX
IMX290_REG_24BIT(0x3018)
> +#define IMX290_VMAX_MAX 0x3ffff
> #define IMX290_HMAX
IMX290_REG_16BIT(0x301c)
> #define IMX290_HMAX_MAX 0xffff
> #define IMX290_SHS1
IMX290_REG_24BIT(0x3020)
> @@ -106,6 +107,9 @@
> #define IMX290_PGCTRL_THRU BIT(1)
> #define IMX290_PGCTRL_MODE(n) ((n) <<
4)
>
> +/* Number of lines by which exposure must be less than VMAX) */
I guess the ')' is a leftover. Despite that:
Acked-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Best regards,
Alexander
> +#define IMX290_EXPOSURE_OFFSET 2
> +
> #define IMX290_VMAX_DEFAULT 1125
>
> #define IMX290_PIXEL_RATE 148500000
> @@ -222,6 +226,7 @@ struct imx290 {
> struct v4l2_ctrl *link_freq;
> struct v4l2_ctrl *hblank;
> struct v4l2_ctrl *vblank;
> + struct v4l2_ctrl *exposure;
> };
>
> static inline struct imx290 *to_imx290(struct v4l2_subdev *_sd)
> @@ -235,7 +240,6 @@ static inline struct imx290 *to_imx290(struct
> v4l2_subdev *_sd)
>
> static const struct imx290_regval imx290_global_init_settings[] = {
> { IMX290_CTRL_07, IMX290_WINMODE_1080P },
> - { IMX290_VMAX, IMX290_VMAX_DEFAULT },
> { IMX290_EXTCK_FREQ, 0x2520 },
> { IMX290_WINWV_OB, 12 },
> { IMX290_WINPH, 0 },
> @@ -659,6 +663,16 @@ static int imx290_setup_format(struct imx290 *imx290,
> /*
> ---------------------------------------------------------------------------
> - * Controls
> */
> +static void imx290_exposure_update(struct imx290 *imx290,
> + const struct imx290_mode *mode)
> +{
> + unsigned int exposure_max;
> +
> + exposure_max = imx290->vblank->val + mode->height -
> + IMX290_EXPOSURE_OFFSET;
> + __v4l2_ctrl_modify_range(imx290->exposure, 1, exposure_max, 1,
> + exposure_max);
> +}
>
> static int imx290_set_ctrl(struct v4l2_ctrl *ctrl)
> {
> @@ -666,7 +680,7 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl)
> struct imx290, ctrls);
> const struct v4l2_mbus_framefmt *format;
> struct v4l2_subdev_state *state;
> - int ret = 0;
> + int ret = 0, vmax;
>
> /*
> * Return immediately for controls that don't need to be applied to
the
> @@ -675,6 +689,11 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl)
> if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)
> return 0;
>
> + if (ctrl->id == V4L2_CID_VBLANK) {
> + /* Changing vblank changes the allowed range for exposure.
*/
> + imx290_exposure_update(imx290, imx290->current_mode);
> + }
> +
> /* V4L2 controls values will be applied only when power is already
up */
> if (!pm_runtime_get_if_in_use(imx290->dev))
> return 0;
> @@ -687,9 +706,23 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl)
> ret = imx290_write(imx290, IMX290_GAIN, ctrl->val, NULL);
> break;
>
> + case V4L2_CID_VBLANK:
> + ret = imx290_write(imx290, IMX290_VMAX,
> + ctrl->val + imx290->current_mode-
>height,
> + NULL);
> + /*
> + * Due to the way that exposure is programmed in this
sensor in
> + * relation to VMAX, we have to reprogramme it whenever
VMAX is
> + * changed.
> + * Update ctrl so that the V4L2_CID_EXPOSURE case can
refer to
> + * it.
> + */
> + ctrl = imx290->exposure;
> + fallthrough;
> case V4L2_CID_EXPOSURE:
> + vmax = imx290->vblank->val + imx290->current_mode->height;
> ret = imx290_write(imx290, IMX290_SHS1,
> - IMX290_VMAX_DEFAULT - ctrl->val -
1, NULL);
> + vmax - ctrl->val - 1, NULL);
> break;
>
> case V4L2_CID_TEST_PATTERN:
> @@ -746,13 +779,15 @@ static void imx290_ctrl_update(struct imx290 *imx290,
> {
> unsigned int hblank_min = mode->hmax_min - mode->width;
> unsigned int hblank_max = IMX290_HMAX_MAX - mode->width;
> - unsigned int vblank = IMX290_VMAX_DEFAULT - mode->height;
> + unsigned int vblank_min = IMX290_VMAX_DEFAULT - mode->height;
> + unsigned int vblank_max = IMX290_VMAX_MAX - mode->height;
>
> __v4l2_ctrl_s_ctrl(imx290->link_freq, mode->link_freq_index);
>
> __v4l2_ctrl_modify_range(imx290->hblank, hblank_min, hblank_max, 1,
> hblank_min);
> - __v4l2_ctrl_modify_range(imx290->vblank, vblank, vblank, 1, vblank);
> + __v4l2_ctrl_modify_range(imx290->vblank, vblank_min, vblank_max, 1,
> + vblank_min);
> }
>
> static int imx290_ctrl_init(struct imx290 *imx290)
> @@ -782,9 +817,13 @@ static int imx290_ctrl_init(struct imx290 *imx290)
> v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
> V4L2_CID_ANALOGUE_GAIN, 0, 100, 1, 0);
>
> - v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
> - V4L2_CID_EXPOSURE, 1, IMX290_VMAX_DEFAULT - 2,
1,
> - IMX290_VMAX_DEFAULT - 2);
> + /*
> + * Correct range will be determined through imx290_ctrl_update
setting
> + * V4L2_CID_VBLANK.
> + */
> + imx290->exposure = v4l2_ctrl_new_std(&imx290->ctrls,
&imx290_ctrl_ops,
> + V4L2_CID_EXPOSURE, 1,
65535, 1,
> + 65535);
>
> /*
> * Set the link frequency, pixel rate, horizontal blanking and
vertical
> @@ -816,8 +855,6 @@ static int imx290_ctrl_init(struct imx290 *imx290)
>
> imx290->vblank = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
> V4L2_CID_VBLANK, 1, 1, 1,
1);
> - if (imx290->vblank)
> - imx290->vblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>
> v4l2_ctrl_new_fwnode_properties(&imx290->ctrls, &imx290_ctrl_ops,
> &props);
> @@ -1003,6 +1040,7 @@ static int imx290_set_fmt(struct v4l2_subdev *sd,
> imx290->current_mode = mode;
>
> imx290_ctrl_update(imx290, &fmt->format, mode);
> + imx290_exposure_update(imx290, mode);
> }
>
> *format = fmt->format;
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
next prev parent reply other threads:[~2023-02-17 8:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 22:29 [PATCH v3 00/15] media: i2c: imx290: Mono support, minor fixes, alternate INCK, and more controls Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 01/15] media: dt-bindings: media: i2c: Add mono version to IMX290 bindings Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 02/15] media: i2c: imx290: Add support for the mono sensor variant Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 03/15] media: i2c: imx290: Match kernel coding style on whitespace Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 04/15] media: i2c: imx290: Set the colorspace fields in the format Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 05/15] media: i2c: imx290: Add V4L2_SUBDEV_FL_HAS_EVENTS and subscribe hooks Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 06/15] media: i2c: imx290: Fix the pixel rate at 148.5Mpix/s Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 07/15] media: i2c: imx290: Support 60fps in 2 lane operation Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 08/15] media: i2c: imx290: Use CSI timings as per datasheet Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 09/15] media: i2c: imx290: Convert V4L2_CID_HBLANK to read/write Laurent Pinchart
2023-02-15 22:29 ` [PATCH v3 10/15] media: i2c: imx290: Convert V4L2_CID_VBLANK " Laurent Pinchart
2023-02-17 8:26 ` Alexander Stein [this message]
2023-02-15 22:29 ` [PATCH v3 11/15] media: i2c: imx290: VMAX is mode dependent Laurent Pinchart
2023-02-15 22:30 ` [PATCH v3 12/15] media: i2c: imx290: Remove duplicated write to IMX290_CTRL_07 Laurent Pinchart
2023-02-15 22:30 ` [PATCH v3 13/15] media: i2c: imx290: Add support for 74.25MHz external clock Laurent Pinchart
2023-02-15 22:30 ` [PATCH v3 14/15] media: i2c: imx290: Add support for H & V Flips Laurent Pinchart
2023-02-15 22:30 ` [PATCH v3 15/15] media: i2c: imx290: Add the error code to logs in start_streaming Laurent Pinchart
2023-02-17 9:08 ` [PATCH v3 00/15] media: i2c: imx290: Mono support, minor fixes, alternate INCK, and more controls Alexander Stein
2023-03-09 8:16 ` Alexander Stein
2023-03-12 12:56 ` Laurent Pinchart
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=8184512.T7Z3S40VBb@steina-w \
--to=alexander.stein@ew.tq-group.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mani@kernel.org \
--cc=sakari.ailus@iki.fi \
/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