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 12A49606A320 for ; Mon, 30 Nov 2026 21:59:00 +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=POMKVN3H; 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=farTEGrO 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=POMKVN3HmSI9tmxKUNcxklxP2u TByKHu58cnCid3z6otBfoU4CVWlqsouAFqSsK0Xrryj4nzGMYXlRAIt0qhpBoknaqXZDIV8KQEtuQ fF0ilgfeYPGIbjV9Z5czGOu4lKrTZbaY9k+JsL/YfVMFgSqFbX7r8nkJ20mif0YKKpBy2MnQNlz8P CRciypuQLFw8jsuE9YzVNQKIW2VEYIrUkzhBaFdWEXr7JgJQ++XUl8Jm5YTGubTeal8GP/tmND6Q9 GN8XwSP6oUdJThsF2G6dobGten7XvTI++GamOxnzTeq7jXe+NoBLfhTC2UkgQNoCaRS0ltH36rCKH oDtR+p6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY9Ol-00000005vQY-2phr; Mon, 30 Nov 2026 21:58:59 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY9Oe-00000005vKx-3G7K for linux-amlogic@lists.infradead.org; Mon, 30 Nov 2026 21:58:54 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-491846221ffso9722959f8f.3 for ; Mon, 30 Nov 2026 13:58:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796075931; x=1796680731; 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=farTEGrOjpdvx5QcDlFfX1KzzcomUubCiYJj/MDByAXhNQsV8hnbU6SgGr/vKnph5x duxS2llojuIYR8RLE0xkdcIBap2guCVj651m6/6SW3CjW+hB6QjcO6kkqFKqnWmfXuEj ds4unSPwvVtc3zW0NT3Rbt1085CJokamRF0+AIlpNlH73ZGEi4X0WAT031xCrg7fgaz1 Pjz1wSWDfPibCRum/XyAwtaPoz1Ym/ELhkXGNHebDnLAYY3chEMRlDLOTycc8bQmOIeu ilb9V/KghMYZpS4pOaVruXDXlg1UjrlhlkjhDHLZXo9QqqTP9GWOFXqsauLYNr6nI7bj RDAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796075931; x=1796680731; 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+eUJaMMk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WVc+oHWZIBYoi6/qkDue+J0/iURS+6J8uK4l63hNuZ2LpRcR+a zgpVr7ssyHzStqsWG3J9it/LosnWXLyYpez2UQKi+qbwH+RrmlCqLFYM3sFHvoUMwYeHgYMnvTd G6Tqo7Kiyc+qWGY02b+4G8x29LIAT+LGFqLBF6dls4+lO6m3r0KZbdC59AB5PdI+XF58Zc/F X-Received: by 2002:a05:6000:2409:b0:48f:d7cd:a5af with SMTP id ffacd0b85a97d-4aba56f5488mr65996117f8f.0.1796075930883; Mon, 30 Nov 2026 13:58:50 -0800 (PST) Received: from [127.0.1.1] ([2a01:e0a:e50:3860::e1d1:d182]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6b9add26sm67416090f8f.44.2026.11.30.13.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 13:58:50 -0800 (PST) From: Guillaume La Roque Date: Mon, 30 Nov 2026 22:57:51 +0100 Subject: [PATCH 2/8] drm/meson: isolate primary plane scaler setup X-Archived-By: MIME-Version: 1.0 Message-Id: <20261130-meson-g12a-osd2-v1-2-aa982300c20e@baylibre.com> References: <20261130-meson-g12a-osd2-v1-0-aa982300c20e@baylibre.com> In-Reply-To: <20261130-meson-g12a-osd2-v1-0-aa982300c20e@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=1796075927; l=9060; i=glaroque@baylibre.com; s=20261019; h=from:subject:message-id; bh=dipGLjhDOApxTgINUML+nj5GrWnZ9gs03y+ni9wBeNY=; b=ykxmny07csgAQ8prI0dHTjOWq2rHfKKWpB3UY/kB+GZrIl2MtpIPCpURv9RqgrdzJf5m6axsz QOoz6+lMt7IAzZcT2JSDEKnhl8yZfk+ga/+Egm+5OEwXPFYJ9JBz3ek 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-20261130_135852_857774_60F37BA9 X-CRM114-Status: GOOD ( 16.39 ) 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