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 29919606A693 for ; Thu, 3 Dec 2026 19:22:12 +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=OAjmQVUe; 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=GOniLoMR 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=yXDOK5bj6xgvb4MvEUstO3aOjtni8LUvdj6iy9zFGPY=; b=OAjmQVUeFl18lYsCsrdwTeEu6q BhJ6yHAk37ndK6J0c6MbWKJmPz6KelpsRSyuaXmlqM5n2lBC4S07kZl2hnUglyH1+SQRogNbOLGpo VyIjopDAsrSaL19WV9KlxeySWog0IkLowel4BrHmuoNB4flCmshQfKpa5gHJ3xcRc2SblQLhBiNsY Sjo3LxqHCbED9tPU88CDzOyDUDbQyDltAtagIBaAZ5PXfbvxG9g2q9ayIMoOMNLZwXq0J7ItTbcPA WFKUjYR6tc0MiRb53qA/QC7A76nEWAaotxmFxkgTdzTtTbM5i5Xe9ifcYm0yud172yoGyqKILzlNI BSZNqjtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZCNe-0000000FlX8-4BAF; Thu, 03 Dec 2026 19:22:11 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZCNZ-0000000FlTR-1eSE for linux-amlogic@lists.infradead.org; Thu, 03 Dec 2026 19:22:09 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-48e47347279so140666f8f.1 for ; Thu, 03 Dec 2026 11:22:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796325723; x=1796930523; 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=dQM65kVIqq/00l/WE+7UmfFEGvXiWaQhj/N+eUJaMMk=; b=GOniLoMRCJo2yHHFRSSDdP+J8+pzTBqQ6OR7TIgJnBMUKA8PiqcmZT4L49o+0+x2Bf gKMApLApP4h94Poy7gVCJs2froUwPOh8vtLs3rmD3U4HcSoX/Iw9/MThcEiFPps+YQTQ FrvpoyeTA1YuLJrmqoKReiIebmXVavUmsIioY6yl/a61p9Y7PvSydbOZtL2Qrv+63QJi iWZc6E7i9PgzC//Zc5txqHR6XKCll2i52zlRr29w5SgP0ioOy1ap/LwCEmBxxPCEsf2Y NIg88W38vImJhCyszBIZ3FeoaONuQOaU7iSvAdU7xe/m0FbjTovPu9F4tNQhC8So1H2l DZRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796325723; x=1796930523; 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=dQM65kVIqq/00l/WE+7UmfFEGvXiWaQhj/N+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ltf4Np TMSotmk6LHluTjkLkX2wGQU64aexibcPI+DRZLakUwvl6dAaxurZoHYJkqdTLE7BmPKUBanD7YR AfIUdM6JRaGXxwMwP/uzUrFhmLk7+Q7jPWeY3hWuZDkXz8oPq4Sb/ixHBuvIcmm8+JquCconeGX 6lKrCsBzp01N4g7QTJwE7CRaiZ7LrOMh8SrZu/Fw2iAUYzKzASM= X-Received: by 2002:a5d:5888:0:b0:490:a481:7ac8 with SMTP id ffacd0b85a97d-4abb532ea79mr82320294f8f.29.1796325723469; Thu, 03 Dec 2026 11:22:03 -0800 (PST) Received: from [127.0.1.1] ([2a01:e0a:e50:3860::e1d1:d182]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1723b8a92sm878935f8f.19.2026.12.03.11.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 11:22:03 -0800 (PST) From: Guillaume La Roque Date: Thu, 03 Dec 2026 20:21:48 +0100 Subject: [PATCH v2 2/9] drm/meson: isolate primary plane scaler setup X-Archived-By: MIME-Version: 1.0 Message-Id: <20261203-meson-g12a-osd2-v2-2-8a4a57d32e20@baylibre.com> References: <20261203-meson-g12a-osd2-v2-0-8a4a57d32e20@baylibre.com> In-Reply-To: <20261203-meson-g12a-osd2-v2-0-8a4a57d32e20@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 , Guillaume La Roque X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1796325720; l=9060; i=glaroque@baylibre.com; s=20261019; h=from:subject:message-id; bh=dipGLjhDOApxTgINUML+nj5GrWnZ9gs03y+ni9wBeNY=; b=BdcPdjU/euxN1CsfO5VFUrKdiI08lMRtMOSPvocvqrZ5vbxP3W2iHyzmO9DNgy5If9bIT5RxD mmH3/hBXydRANJ1xHyl4LOvYlukyj60dibHNlQ1l+NGcG7ztYkg3qBM 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_112205_495143_240A1DD1 X-CRM114-Status: GOOD ( 15.80 ) 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 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; -- 2.34.1 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic