From: Neil Armstrong <neil.armstrong@linaro.org>
To: Guillaume La Roque <glaroque@baylibre.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: dri-devel@lists.freedesktop.org,
linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
Simona Vetter <simona.vetter@ffwll.ch>
Subject: Re: [PATCH v2 2/9] drm/meson: isolate primary plane scaler setup
Date: Thu, 3 Dec 2026 20:32:43 +0100 [thread overview]
Message-ID: <2f246acc-0a15-422b-8d73-fcfaf8859836@linaro.org> (raw)
In-Reply-To: <20261203-meson-g12a-osd2-v2-2-8a4a57d32e20@baylibre.com>
On 12/3/26 20:21, Guillaume La Roque wrote:
> Separate the OSD1 scaler from format, buffer and geometry handling so
> another RGB plane can reuse scanout setup without changing the primary
> scaler state.
>
> Keep the primary blender dimensions based on crtc_w and crtc_h,
> including the existing height division for interlaced modes.
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
> ---
> drivers/gpu/drm/meson/meson_plane.c | 224 +++++++++++++++++++-----------------
> 1 file changed, 119 insertions(+), 105 deletions(-)
>
> diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
> index 639234d2f9d4..04c28289106b 100644
> --- a/drivers/gpu/drm/meson/meson_plane.c
> +++ b/drivers/gpu/drm/meson/meson_plane.c
> @@ -131,6 +131,118 @@ static u32 meson_g12a_afbcd_line_stride(struct meson_drm *priv)
> return ((line_stride + 1) >> 1) << 1;
> }
>
> +static void meson_plane_setup_scaler(struct meson_drm *priv,
> + struct drm_plane_state *new_state,
> + struct drm_rect *dest)
> +{
> + int vsc_ini_rcv_num, vsc_ini_rpt_p0_num;
> + int vsc_bot_rcv_num, vsc_bot_rpt_p0_num;
> + int hsc_ini_rcv_num, hsc_ini_rpt_p0_num;
> + int hf_phase_step, vf_phase_step;
> + int src_w, src_h, dst_w, dst_h;
> + int bot_ini_phase;
> + int hf_bank_len;
> + int vf_bank_len;
> +
> + /* Default scaler parameters */
> + vsc_bot_rcv_num = 0;
> + vsc_bot_rpt_p0_num = 0;
> + hf_bank_len = 4;
> + vf_bank_len = 4;
> +
> + if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) {
> + vsc_bot_rcv_num = 6;
> + vsc_bot_rpt_p0_num = 2;
> + }
> +
> + hsc_ini_rcv_num = hf_bank_len;
> + vsc_ini_rcv_num = vf_bank_len;
> + hsc_ini_rpt_p0_num = (hf_bank_len / 2) - 1;
> + vsc_ini_rpt_p0_num = (vf_bank_len / 2) - 1;
> +
> + src_w = fixed16_to_int(new_state->src_w);
> + src_h = fixed16_to_int(new_state->src_h);
> + dst_w = new_state->crtc_w;
> + dst_h = new_state->crtc_h;
> +
> + /*
> + * When the output is interlaced, the OSD must switch between
> + * each field using the INTERLACE_SEL_ODD (0) of VIU_OSD1_BLK0_CFG_W0
> + * at each vsync.
> + * But the vertical scaler can provide such funtionnality if
> + * is configured for 2:1 scaling with interlace options enabled.
> + */
> + if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) {
> + dest->y1 /= 2;
> + dest->y2 /= 2;
> + dst_h /= 2;
> + }
> +
> + hf_phase_step = ((src_w << 18) / dst_w) << 6;
> + vf_phase_step = (src_h << 20) / dst_h;
> +
> + if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE)
> + bot_ini_phase = ((vf_phase_step / 2) >> 4);
> + else
> + bot_ini_phase = 0;
> +
> + vf_phase_step = (vf_phase_step << 4);
> +
> + /* In interlaced mode, scaler is always active */
> + if (src_h != dst_h || src_w != dst_w) {
> + priv->viu.osd_sc_i_wh_m1 = SCI_WH_M1_W(src_w - 1) |
> + SCI_WH_M1_H(src_h - 1);
> + priv->viu.osd_sc_o_h_start_end = SCO_HV_START(dest->x1) |
> + SCO_HV_END(dest->x2 - 1);
> + priv->viu.osd_sc_o_v_start_end = SCO_HV_START(dest->y1) |
> + SCO_HV_END(dest->y2 - 1);
> + /* Enable OSD Scaler */
> + priv->viu.osd_sc_ctrl0 = SC_CTRL0_PATH_EN | SC_CTRL0_SEL_OSD1;
> + } else {
> + priv->viu.osd_sc_i_wh_m1 = 0;
> + priv->viu.osd_sc_o_h_start_end = 0;
> + priv->viu.osd_sc_o_v_start_end = 0;
> + priv->viu.osd_sc_ctrl0 = 0;
> + }
> +
> + /* In interlaced mode, vertical scaler is always active */
> + if (src_h != dst_h) {
> + priv->viu.osd_sc_v_ctrl0 =
> + VSC_BANK_LEN(vf_bank_len) |
> + VSC_TOP_INI_RCV_NUM(vsc_ini_rcv_num) |
> + VSC_TOP_RPT_L0_NUM(vsc_ini_rpt_p0_num) |
> + VSC_VERTICAL_SCALER_EN;
> +
> + if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE)
> + priv->viu.osd_sc_v_ctrl0 |=
> + VSC_BOT_INI_RCV_NUM(vsc_bot_rcv_num) |
> + VSC_BOT_RPT_L0_NUM(vsc_bot_rpt_p0_num) |
> + VSC_PROG_INTERLACE;
> +
> + priv->viu.osd_sc_v_phase_step = SC_PHASE_STEP(vf_phase_step);
> + priv->viu.osd_sc_v_ini_phase = VSC_INI_PHASE_BOT(bot_ini_phase);
> + } else {
> + priv->viu.osd_sc_v_ctrl0 = 0;
> + priv->viu.osd_sc_v_phase_step = 0;
> + priv->viu.osd_sc_v_ini_phase = 0;
> + }
> +
> + /* Horizontal scaler is only used if width does not match */
> + if (src_w != dst_w) {
> + priv->viu.osd_sc_h_ctrl0 =
> + HSC_BANK_LENGTH(hf_bank_len) |
> + HSC_INI_RCV_NUM0(hsc_ini_rcv_num) |
> + HSC_RPT_P0_NUM0(hsc_ini_rpt_p0_num) |
> + HSC_HORIZ_SCALER_EN;
> + priv->viu.osd_sc_h_phase_step = SC_PHASE_STEP(hf_phase_step);
> + priv->viu.osd_sc_h_ini_phase = 0;
> + } else {
> + priv->viu.osd_sc_h_ctrl0 = 0;
> + priv->viu.osd_sc_h_phase_step = 0;
> + priv->viu.osd_sc_h_ini_phase = 0;
> + }
> +}
> +
> static void meson_plane_atomic_update(struct drm_plane *plane,
> struct drm_atomic_commit *state)
> {
> @@ -142,14 +254,6 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
> struct drm_framebuffer *fb = new_state->fb;
> struct drm_gem_dma_object *gem;
> unsigned long flags;
> - int vsc_ini_rcv_num, vsc_ini_rpt_p0_num;
> - int vsc_bot_rcv_num, vsc_bot_rpt_p0_num;
> - int hsc_ini_rcv_num, hsc_ini_rpt_p0_num;
> - int hf_phase_step, vf_phase_step;
> - int src_w, src_h, dst_w, dst_h;
> - int bot_ini_phase;
> - int hf_bank_len;
> - int vf_bank_len;
> u8 canvas_id_osd1;
>
> /*
> @@ -246,103 +350,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
> break;
> }
>
> - /* Default scaler parameters */
> - vsc_bot_rcv_num = 0;
> - vsc_bot_rpt_p0_num = 0;
> - hf_bank_len = 4;
> - vf_bank_len = 4;
> -
> - if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) {
> - vsc_bot_rcv_num = 6;
> - vsc_bot_rpt_p0_num = 2;
> - }
> -
> - hsc_ini_rcv_num = hf_bank_len;
> - vsc_ini_rcv_num = vf_bank_len;
> - hsc_ini_rpt_p0_num = (hf_bank_len / 2) - 1;
> - vsc_ini_rpt_p0_num = (vf_bank_len / 2) - 1;
> -
> - src_w = fixed16_to_int(new_state->src_w);
> - src_h = fixed16_to_int(new_state->src_h);
> - dst_w = new_state->crtc_w;
> - dst_h = new_state->crtc_h;
> -
> - /*
> - * When the output is interlaced, the OSD must switch between
> - * each field using the INTERLACE_SEL_ODD (0) of VIU_OSD1_BLK0_CFG_W0
> - * at each vsync.
> - * But the vertical scaler can provide such funtionnality if
> - * is configured for 2:1 scaling with interlace options enabled.
> - */
> - if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) {
> - dest.y1 /= 2;
> - dest.y2 /= 2;
> - dst_h /= 2;
> - }
> -
> - hf_phase_step = ((src_w << 18) / dst_w) << 6;
> - vf_phase_step = (src_h << 20) / dst_h;
> -
> - if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE)
> - bot_ini_phase = ((vf_phase_step / 2) >> 4);
> - else
> - bot_ini_phase = 0;
> -
> - vf_phase_step = (vf_phase_step << 4);
> -
> - /* In interlaced mode, scaler is always active */
> - if (src_h != dst_h || src_w != dst_w) {
> - priv->viu.osd_sc_i_wh_m1 = SCI_WH_M1_W(src_w - 1) |
> - SCI_WH_M1_H(src_h - 1);
> - priv->viu.osd_sc_o_h_start_end = SCO_HV_START(dest.x1) |
> - SCO_HV_END(dest.x2 - 1);
> - priv->viu.osd_sc_o_v_start_end = SCO_HV_START(dest.y1) |
> - SCO_HV_END(dest.y2 - 1);
> - /* Enable OSD Scaler */
> - priv->viu.osd_sc_ctrl0 = SC_CTRL0_PATH_EN | SC_CTRL0_SEL_OSD1;
> - } else {
> - priv->viu.osd_sc_i_wh_m1 = 0;
> - priv->viu.osd_sc_o_h_start_end = 0;
> - priv->viu.osd_sc_o_v_start_end = 0;
> - priv->viu.osd_sc_ctrl0 = 0;
> - }
> -
> - /* In interlaced mode, vertical scaler is always active */
> - if (src_h != dst_h) {
> - priv->viu.osd_sc_v_ctrl0 =
> - VSC_BANK_LEN(vf_bank_len) |
> - VSC_TOP_INI_RCV_NUM(vsc_ini_rcv_num) |
> - VSC_TOP_RPT_L0_NUM(vsc_ini_rpt_p0_num) |
> - VSC_VERTICAL_SCALER_EN;
> -
> - if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE)
> - priv->viu.osd_sc_v_ctrl0 |=
> - VSC_BOT_INI_RCV_NUM(vsc_bot_rcv_num) |
> - VSC_BOT_RPT_L0_NUM(vsc_bot_rpt_p0_num) |
> - VSC_PROG_INTERLACE;
> -
> - priv->viu.osd_sc_v_phase_step = SC_PHASE_STEP(vf_phase_step);
> - priv->viu.osd_sc_v_ini_phase = VSC_INI_PHASE_BOT(bot_ini_phase);
> - } else {
> - priv->viu.osd_sc_v_ctrl0 = 0;
> - priv->viu.osd_sc_v_phase_step = 0;
> - priv->viu.osd_sc_v_ini_phase = 0;
> - }
> -
> - /* Horizontal scaler is only used if width does not match */
> - if (src_w != dst_w) {
> - priv->viu.osd_sc_h_ctrl0 =
> - HSC_BANK_LENGTH(hf_bank_len) |
> - HSC_INI_RCV_NUM0(hsc_ini_rcv_num) |
> - HSC_RPT_P0_NUM0(hsc_ini_rpt_p0_num) |
> - HSC_HORIZ_SCALER_EN;
> - priv->viu.osd_sc_h_phase_step = SC_PHASE_STEP(hf_phase_step);
> - priv->viu.osd_sc_h_ini_phase = 0;
> - } else {
> - priv->viu.osd_sc_h_ctrl0 = 0;
> - priv->viu.osd_sc_h_phase_step = 0;
> - priv->viu.osd_sc_h_ini_phase = 0;
> - }
> + meson_plane_setup_scaler(priv, new_state, &dest);
>
> /*
> * The format of these registers is (x2 << 16 | x1),
> @@ -359,6 +367,12 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
> priv->viu.osd1_blk0_cfg[4] = ((dest.y2 - 1) << 16) | dest.y1;
>
> if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
> + int dst_w = new_state->crtc_w;
> + int dst_h = new_state->crtc_h;
> +
> + if (new_state->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE)
> + dst_h /= 2;
> +
> priv->viu.osd_blend_din0_scope_h = ((dest.x2 - 1) << 16) | dest.x1;
> priv->viu.osd_blend_din0_scope_v = ((dest.y2 - 1) << 16) | dest.y1;
> priv->viu.osb_blend0_size = dst_h << 16 | dst_w;
>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Thanks,
Neil
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-12-03 20:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 19:21 [PATCH v2 0/9] drm/meson: add a second RGB plane on G12A Guillaume La Roque
2026-12-03 19:21 ` [PATCH v2 1/9] drm/meson: honor framebuffer offsets for the primary plane Guillaume La Roque
2026-12-03 19:31 ` Neil Armstrong
2026-12-03 19:43 ` sashiko-bot
2026-12-03 19:21 ` [PATCH v2 2/9] drm/meson: isolate primary plane scaler setup Guillaume La Roque
2026-12-03 19:32 ` Neil Armstrong [this message]
2026-12-03 19:21 ` [PATCH v2 3/9] drm/meson: keep RGB scanout state per OSD Guillaume La Roque
2026-12-03 19:32 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 4/9] drm/meson: parameterize the G12A OSD color matrix setup Guillaume La Roque
2026-12-03 19:21 ` [PATCH v2 5/9] drm/meson: handle primary plane zpos allocation failure Guillaume La Roque
2026-12-03 19:21 ` [PATCH v2 6/9] drm/meson: select RGB plane registers by OSD index Guillaume La Roque
2026-12-03 19:33 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 7/9] drm/meson: serialize OSD state updates with the IRQ Guillaume La Roque
2026-12-03 19:33 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 8/9] drm/meson: clear pending primary updates while disabled Guillaume La Roque
2026-12-03 19:33 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 9/9] drm/meson: add a linear RGB overlay on G12A OSD2 Guillaume La Roque
2026-12-03 19:34 ` Neil Armstrong
2026-12-03 19:38 ` [PATCH v2 0/9] drm/meson: add a second RGB plane on G12A Neil Armstrong
2026-12-03 19:58 ` Guillaume La Roque
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=2f246acc-0a15-422b-8d73-fcfaf8859836@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=glaroque@baylibre.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=mripard@kernel.org \
--cc=simona.vetter@ffwll.ch \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®