From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F3AE606A695 for ; Thu, 3 Dec 2026 19:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=VH5XOd3r; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=Vza24fL7 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=MWHQX7N8nEa2SevW7JGkasptMGo/2Z6s64kyjp6NhMI=; b=VH5XOd3roQoXy2LpvF5Zh4Ui3Z VxBeTYUa3Yi7IDv1vqTSCGN17Xio43nkZ/QHYcihqK7xFp/YEKP2lRgn1GFzCAmISmHiiZjYuyVuu 5/Q7sfkRykIzRQRTC6V0UnYUL5EQOms6NvIxeA/rAXTZ6RFeKvGC++BHFsK1FkruvOt8wvSAKu2NQ TJ2044gWAgGkBnaa826n4Mvb/j8En9MSzbjUDk5GwCYaR+yPCkk1LfmtMf1Jj461I5TLsHPuNPN/U 6orsCj9k81mZvHR1UuFvj40AhK2yEguQ843TQZlSFk6I+MFLOZX9GocuR6ihRYZ0VtiEp8LiZDOjo v9EI3HNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZCx7-0000000FsbK-3T2K; Thu, 03 Dec 2026 19:58:49 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZCwu-0000000FsRF-1y3x for linux-amlogic@lists.infradead.org; Thu, 03 Dec 2026 19:58:39 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4bba5e17cbeso1755025e9.1 for ; Thu, 03 Dec 2026 11:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796327915; x=1796932715; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GopA6D57tKmilboL2qPGbnCtcRGwULbbrIQ71vPF3JI=; b=Vza24fL7eETzOGxw3/1UMDyWH4ovyN8a4sswZsNsGCRlNtuS8jahBH/VfMAXp+ZzZ3 GfAx4ifUqFfoQkk9NN6sJ2i10Ri/pp8sXbnGAh4C5uRMEzTkxDQUFtCB19qMRu1uVUv3 N9f33o/Z8WHH9mpZGVzctBHnKRzkOW8Cbk79eD9xfFdgQW7ul3H8nfVTdBZ8zh1MCxPK JvXgf3YBmI7DKC/KtkocKsMIjvLWykQK9Ixu6SjqrjfmV8vlEMve3A9KdeD2aYmGIHuP up8ZA7OmGPkBCJQ8cLbt+GQj7JR4erabM8CpJTRIA7QCI/rzeWUHQygwqY8zuwNBvJoz 1j5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796327915; x=1796932715; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GopA6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hqBzwguapwsQMNb/I+8RSJf WVRMG7Nqvtj21FAdMnMb7JuLWFpwCC2+EC1lrP1aoN5D1p/+lXirm8LianRNK17DdLfTiekHWIB 8BzYfONUOsn6Ya/Pf1Nms0jaBgUF2Gw3KpgyUh5PJEFNk+qOJuJJWNLGEXMyPYyejq9+kmYkt2P aOEm08H4qLIJKhiOuld84B+wpRziT6TYXbbaKgFR+96j9nOYCDU= X-Received: by 2002:a05:600c:310f:b0:4b5:d95c:2378 with SMTP id 5b1f17b1804b1-4bb8881f9b7mr921722095e9.34.1796327914573; Thu, 03 Dec 2026 11:58:34 -0800 (PST) Received: from [127.0.1.1] ([2a01:e0a:e50:3860::e1d1:d182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00df154sm109336975e9.14.2026.12.03.11.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 11:58:34 -0800 (PST) From: Guillaume La Roque Date: Thu, 03 Dec 2026 20:55:50 +0100 Subject: [PATCH v3 2/9] drm/meson: isolate primary plane scaler setup X-Archived-By: MIME-Version: 1.0 Message-Id: <20261203-meson-g12a-osd2-v3-2-2cf76729b5d5@baylibre.com> References: <20261203-meson-g12a-osd2-v3-0-2cf76729b5d5@baylibre.com> In-Reply-To: <20261203-meson-g12a-osd2-v3-0-2cf76729b5d5@baylibre.com> To: Neil Armstrong , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Simona Vetter , linux-kernel@vger.kernel.org, Guillaume La Roque X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1796327911; l=9126; i=glaroque@baylibre.com; s=20261019; h=from:subject:message-id; bh=wK0hats8+YHEqEc6jkcqbdmgRQNY1K9k0oS3jWTwvL4=; b=0u2rb36rMaFgMLFaDd2Zk7NGMZrhAl1Qs7p7sTA2Ax8CHDZ1G7JoR/nMqMV5Xy24VG3uS89F1 fQxOokK1b3zCleS/auDzhh1owYP4sm3ZtHOrQ99SgASeeOT28KdQ+Ey X-Developer-Key: i=glaroque@baylibre.com; a=ed25519; pk=nMpSg4NT6M6q143E089emouMc+MXpHO9CWmnEUfjhjI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_115836_560848_27983155 X-CRM114-Status: GOOD ( 16.04 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 --- 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 7174093227fd..0506e29b6ef3 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; /* @@ -241,103 +345,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane, /* Use the pixel's alpha */ priv->viu.osd1_ctrl_stat2 &= ~OSD_REPLACE_EN; - /* 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), @@ -354,6 +362,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; -- 2.34.1 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic