From: Daniel Golle <daniel@makrotopia.org>
To: Paul Elder <paul.elder@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Dafna Hirschfeld <dafna@fastmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
michael.riesch@collabora.com, stefan.klug@ideasonboard.com,
mehdi.djait@linux.intel.com, xuhf@rock-chips.com,
zyc@rock-chips.com, dalong.deng@rock-chips.com,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/5] media: rkisp2: Add parameters output video node
Date: Fri, 16 Oct 2026 17:06:29 +0100 [thread overview]
Message-ID: <atJLhTeuvukW4XFx@makrotopia.org> (raw)
In-Reply-To: <20260827-rkisp2-v3-2-e91ff0a604d6@ideasonboard.com>
On Thu, Aug 27, 2026 at 07:48:31PM +0900, Paul Elder wrote:
> Implement support for setting parameters on the ISP by queueing
> parameter buffers to rkisp2.
[...]
Hi Paul,
A few comments from running this on the RV1126; the RK3588 statements
are by code inspection.
[...]
> +++ b/Documentation/userspace-api/media/v4l/metafmt-rkisp2.rst
[...]
> +The configuration parameters are passed to the :ref:`rkisp2_params
> +<rkisp2_params>` metadata output video node, using the
There is no rkisp2_params label anywhere under Documentation/ (rkisp1
defines its labels in admin-guide/media/rkisp1.rst), so Sphinx warns
about an undefined label. The same holds for rkisp2_stats in patch 3.
[...]
> +++ b/drivers/media/platform/rockchip/rkisp2/rkisp2-params.c
[...]
> +static void rkisp2_params_goc(struct rkisp2_params *params,
[...]
> + if (arg->mode == RKISP2_ISP_GOC_MODE_EQUIDISTANT)
> + control = ISP3X_GAMMA_OUT_CTRL_MODE_EQUIDISTANT;
> + if (arg->mode == RKISP2_ISP_GOC_SEGMENTS_48)
> + control |= ISP3X_GAMMA_OUT_CTRL_SEGMENTS_48;
The second test is meant for arg->segments. As
RKISP2_ISP_GOC_SEGMENTS_48 and RKISP2_ISP_GOC_MODE_EQUIDISTANT are both
1, equidistant mode always gets the 48 segment layout and the segments
member of the uapi is dead.
[...]
> +static void rkisp2_params_crop_init(struct rkisp2_params *params)
> +{
> + struct rkisp2_device *rkisp2 = params->rkisp2;
> +
> + /* Create an initial crop configuration to configure */
> + struct rkisp2_params_crop arg = {
> + .header.type = RKISP2_PARAMS_BLOCK_CROP,
> + .header.flags = 0,
> + .header.size = sizeof(struct rkisp2_params_crop),
> + .crop_en = RKISP2_ISP_CROP_ENABLE_MAIN | RKISP2_ISP_CROP_ENABLE_SELF,
> +
> + .mp_crop.h_offs = 0,
> + .mp_crop.v_offs = 0,
> + .mp_crop.h_size = rkisp2->resizer_devs[0].source_size.width,
> + .mp_crop.v_size = rkisp2->resizer_devs[0].source_size.height,
Without a params buffer at stream start this crops a window of the
output size at the top left corner, so a 1920x1080 capture from a
3864x2192 sensor shows that corner only. The sink size (what the CROP
block uses when it is disabled), scaled by the resizer, is what rkisp1
does and what a plain v4l2-ctl capture expects.
[...]
> +static void rkisp2_params_configure(struct rkisp2_params *params,
[...]
> + /* update shadow register immediately */
> + rkisp2_param_set_bits(params, RKISP2_CIF_ISP_CTRL,
> + RKISP2_CIF_ISP_CTRL_ISP_CFG_UPD);
> +
> + if (prio == RKISP2_PARAMS_CONFIG_PRIO_NONE)
> + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
> +}
[...]
> +void rkisp2_params_pre_configure(struct rkisp2_params *params,
[...]
> + spin_lock_irq(¶ms->buf_lock);
> + buf = list_first_entry_or_null(¶ms->params,
> + struct rkisp2_params_buffer, queue);
> + spin_unlock_irq(¶ms->buf_lock);
> +
> + if (!buf) {
> + /*
> + * Initialize crop in the event that are no pre-queued
> + * parameter buffers
> + */
> + rkisp2_params_crop_init(params);
> + return;
> + }
> +
> + rkisp2_params_configure(params, buf, RKISP2_PARAMS_CONFIG_PRIO_PRE);
When a buffer is queued but carries no CROP block, neither path
programs the dual crop and the resizer, so they keep the state of the
previous stream (the IRCL pulse in rkisp2_isp_stop() resets the ISP
and MIPI blocks only) or the reset state. With a capture size that
differs from the sink size the MI is then fed frames of the wrong
size. Running rkisp2_params_crop_init() first and letting a CROP block
override it covers both cases.
> +}
> +
> +void rkisp2_params_post_configure(struct rkisp2_params *params)
> +{
> + struct rkisp2_params_buffer *buf;
> +
> + spin_lock_irq(¶ms->buf_lock);
> + buf = list_first_entry_or_null(¶ms->params,
> + struct rkisp2_params_buffer, queue);
> + if (buf)
> + list_del(&buf->queue);
> + spin_unlock_irq(¶ms->buf_lock);
> +
> + if (!buf)
> + return;
> +
> + rkisp2_params_configure(params, buf, RKISP2_PARAMS_CONFIG_PRIO_POST);
> +}
The buffer is taken off the list here and configured with PRIO_POST,
which does not complete it (see above), so a params buffer queued
before STREAMON never comes back from DQBUF; at STREAMOFF vb2 warns
that stop_streaming left a buffer in active state and releases it
itself. rkisp1_params_post_configure() completes the buffer after the
LSC group; vb2_buffer_done() belongs here after the POST pass.
[...]
> + ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
> + if (ret) {
> + dev_err(rkisp2->dev,
> + "failed to register %s, ret=%d\n", vdev->name, ret);
> + return ret;
> + }
> +
> + return 0;
> +
> +err_media:
> + media_entity_cleanup(&vdev->entity);
> + mutex_destroy(&node->vlock);
> + return ret;
goto err_media here as well. Neither path releases the vb2 queue that
was initialised above.
[...]
> +++ b/drivers/media/platform/rockchip/rkisp2/rkisp2-resizer.c
[...]
> +void rkisp2_resizer_configure(struct rkisp2_resizer *rsz,
[...]
> + if (crop->width == rsz->source_size.width && crop->height == rsz->source_size.height)
> + rkisp2_resizer_disable_rsz(rsz);
> + else
> + rkisp2_resizer_config_rsz(rsz, crop,
> + &rsz->source_size,
> + &rsz->source_format);
The bypass test compares the luma size only. The ISP delivers 4:2:2,
and rkisp2_resizer_config_rsz() handles the chroma subsampling when it
runs, but an unscaled 4:2:0 stream (crop equal to the output size)
disables the resizer and the MI gets one chroma row per luma row. On
the RV1126 main path the chroma plane offset wraps halfway through the
frame and the chroma of the lower half lands on the upper half
(displaced colour ghosts and neutral halos). rkisp1_rsz_config()
bypasses only when the size and the subsampling are both unchanged;
the same test here fixed it for me. I do not know whether the 3.0 MI
subsamples on its own in the ISP32_MI_OUTPUT_YUV420 mode; if it does
not, this applies to the RK3588 too.
Best regards,
Daniel
next prev parent reply other threads:[~2026-10-16 16:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 10:48 [PATCH v3 0/5] media: rockchip: rkisp2: Add driver for ISP on Rk3588 Paul Elder
2026-08-27 10:48 ` [PATCH v3 2/5] media: rkisp2: Add parameters output video node Paul Elder
2026-10-16 16:06 ` Daniel Golle [this message]
2026-08-27 10:48 ` [PATCH v3 3/5] media: rkisp2: Add statistics capture " Paul Elder
2026-10-16 16:06 ` Daniel Golle
2026-08-27 10:48 ` [PATCH v3 4/5] dt-bindings: media: Add rockchip rkisp2 Paul Elder
2026-08-27 16:43 ` Conor Dooley
2026-08-27 10:48 ` [PATCH v3 5/5] arm64: dts: rockchip: add ISP nodes to rk3588 Paul Elder
2026-10-16 16:06 ` Daniel Golle
2026-10-16 16:06 ` [PATCH v3 0/5] media: rockchip: rkisp2: Add driver for ISP on Rk3588 Daniel Golle
[not found] ` <20260827-rkisp2-v3-1-e91ff0a604d6@ideasonboard.com>
2026-10-16 16:06 ` [PATCH v3 1/5] media: rockchip: rkisp2: Add rkisp2 driver Daniel Golle
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=atJLhTeuvukW4XFx@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=conor+dt@kernel.org \
--cc=dafna@fastmail.com \
--cc=dalong.deng@rock-chips.com \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@linux.intel.com \
--cc=michael.riesch@collabora.com \
--cc=paul.elder@ideasonboard.com \
--cc=robh@kernel.org \
--cc=stefan.klug@ideasonboard.com \
--cc=xuhf@rock-chips.com \
--cc=zyc@rock-chips.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