From nobody Tue Sep 29 02:34:58 2026 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EB2D353EE0 for ; Thu, 13 Aug 2026 06:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786603895; cv=none; b=t/OBfGobsn8rPPyEitJTtsIFyMosgJdcT4GltLrRyDL0pwYZwS9msU4TOOlIlty2/DCQKQK9KrBlt1CuUxKNlwwiveOVDKvzJ9gJcyUR3A37WeAcGi5kq1ZfIqaFvTh2YMIQLiYKxV+9erSx2V39YpiHpaw3S92qy/cmXTaYYDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786603895; c=relaxed/simple; bh=JzxL5R3+DS8sX91F4mleJJHvP91dg0P2HVIU1JgEUYM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GNzU6CIPV5kNXPZYU2MuB/rAw/k6GNyBOQhmDP65X8Q64ANeDOdKx8Gh5qrPlf9MWLK18WKz4LZ6F34i1Te5aLBklVnrenuJLHcv1GxWiNM75xp4SUemieK5d4PL7aNyVFWDJY93Y9g+1Fpu643H13ytHgBtOv5mdZwzkx1v/cI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=CVIWc9l3; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CVIWc9l3" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-381c51fde6bso551837a91.2 for ; Wed, 12 Aug 2026 23:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1786603893; x=1787208693; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=j+N9yE6d7rB5JmWfr2wLA+1fKPLxUmtPAdPhKfD0XGE=; b=CVIWc9l3jaPDCmehcCjnvoqigx5uhDEZ5ikcvi2npzSr4Jwn/cjpzCQPRgy8aH2sOy KgIYr3WMWecfwGfU+QKAmemEbPBOIaJEorkoptFNu0D7BBDD0jgwlGRc9f/veudh1phZ P/ZozOSOv08GmzLNILXPcmGBE5Ks70OIsnqRw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786603893; x=1787208693; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=j+N9yE6d7rB5JmWfr2wLA+1fKPLxUmtPAdPhKfD0XGE=; b=dVUPxfTbWARiZ3ciZ6Vw4JGW0tVSj91rn0Jpa+978XgT+wTzOATSDGL2qlnwhdMZAh tklph2b7T52chEWMGE71DBEBsfWVgAyBYRHMb0e4WREA+x06QCB4lYcxoHf4WSCjE1IQ skgT11Kl9fBXZVYwkZJ5IsCBFQq05T/kORLXsRxuc3/nlnLXYE28J14AO8gO/Ivvu3lR UbB1knb9abslu/AM9QPGWs5E3lF4anDIr8YIsKaJw63zrYPPOQYgrJm1cFRG+Q9fl0PL vOFkvx93fDK9MCYuUlp/9RXrcG5d1qLWC9aQnhsAH3CJwZA2iqTLOnx8MCFI0oC2VliC DavQ== X-Forwarded-Encrypted: i=1; AHgh+RqV94DTdA04S/7avrtiIfygnDsW5brCt2pmXT9TC/xaTfKcZHtWQmBmG7KjBIZZod2TXL3uI94CFpwacTE=@vger.kernel.org X-Gm-Message-State: AOJu0YzdlKF1XSMhAQIy6/2tntKhJtX8/ho0dfbgf7tGrGL6whmDTu3P BaXKEDXN3Aygt+AzKkg3dDilqodtORPpuxdpxCIv+pKnXKy/Bmzyp0wOPfRwhjULmw== X-Gm-Gg: AR+sD139xNlwMenUg/g7HjkhKCpwhuXefgQImDPwbeRd6U5tCwkAHt8yQm3IN0CogLB 3DMueGA34I0JVBImJISoSaM7s5rCU4epq+792xifoUZG1RcVaZhYykTp1svxApnR7N8sWD0IkQv Ar85MHje+guQpun1rC4BwSTbvCcurlHkEtK3pU5BmgWzChW6J1uXsp76r3pKMf4eVNUEyIilna0 jOi9yZBq4JKYpFdWsSeyjnIcu+9eGTnM0yiGsc5eskti64UbdNJK9Dh5hiOppZtoYbNs8nnZ9Se GkTdUSBBXp3/CpnApDyntg/0VfqaW+LcYPd+Mt9WoyXw7BIMnUqXjvB3+fFidn88bSui1YlxZXu XWUl4QUFMJHj5YHdRH5tfqCw0SExlkmCq1n1gmj9MAL+en4/5D5UjfYIR8xtrVWeMdo1sDwpavm fD0jwfkp56Zs0Y/qnv5cZbn/PsILI7hsypVwQ0VqUuANIDYPv5Q1zVzAXCJQGaTD5rLuMqcZwt9 KUyvnieh0laO7bJ7X8b0+5GcrhDfdpzAtIuMTZi6Y0W X-Received: by 2002:a17:90b:4d08:b0:38d:dfd1:7a8 with SMTP id 98e67ed59e1d1-3931dfd7b73mr4150306a91.2.1786603893446; Wed, 12 Aug 2026 23:51:33 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:61f:1b11:5c48:d758]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3931f44de1esm1694814a91.13.2026.08.12.23.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 23:51:32 -0700 (PDT) From: Chen-Yu Tsai To: Icenowy Zheng , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] drm/verisilicon: Switch to drm_fb_dma_get_addr() for framebuffer addresses Date: Thu, 13 Aug 2026 14:51:26 +0800 Message-ID: <20260813065127.341349-1-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.691.gc56d675ccc-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The verisilicon driver has a custom framebuffer address calculating helper that the common drm_fb_dma_get_addr() can substitute. Differences from drm_fb_dma_get_addr(): - Uses drm_format_info_min_pitch() to calculate the horizontal offset; however the driver does not support any of the blocked formats, so this just ends up being the same as in drm_fb_dma_get_addr(): "cpp[plane] * y" - Uses clipped source coordinates instead of non-clipped coordinates as in drm_fb_dma_get_addr(); For the primary plane this doesn't matter, since the primary plane must match the output, i.e. it cannot be clipped. Also this driver doesn't support scaling. For the cursor plane this seems wrong, as the clipping seems to be done by the hardware, and thus the buffer address should be unclipped. As such, it should be fine to use the common helper and drop the custom code. Tested-by: Icenowy Zheng Reviewed-by: Icenowy Zheng Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor planes") Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Dropped vs_fb_get_dma_addr() prototype from header (Sashiko) Changes since v1: - Fixed compile issues Compile tested by me. I do not have the hardware. Icenowy tested on actual hardware. --- drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 4 +++- drivers/gpu/drm/verisilicon/vs_plane.c | 20 ------------------- drivers/gpu/drm/verisilicon/vs_plane.h | 2 -- .../gpu/drm/verisilicon/vs_primary_plane.c | 7 ++++++- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c b/drivers/gpu/dr= m/verisilicon/vs_cursor_plane.c index fa4f601dd0c8..59778433ae84 100644 --- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c +++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -176,7 +177,8 @@ static void vs_cursor_plane_atomic_update(struct drm_pl= ane *plane, break; } =20 - dma_addr =3D vs_fb_get_dma_addr(fb, &state->src); + /* hardware handles clipping as seen below */ + dma_addr =3D drm_fb_dma_get_gem_addr(fb, state, 0); =20 regmap_write(dc->regs, VSDC_CURSOR_ADDRESS(output), lower_32_bits(dma_addr)); diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/veris= ilicon/vs_plane.c index d81f7b8f4c65..38b8b536eccb 100644 --- a/drivers/gpu/drm/verisilicon/vs_plane.c +++ b/drivers/gpu/drm/verisilicon/vs_plane.c @@ -107,26 +107,6 @@ int drm_format_to_vs_format(u32 drm_format, struct vs_= format *vs_format) return 0; } =20 -dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb, - const struct drm_rect *src_rect) -{ - struct drm_gem_dma_object *gem; - dma_addr_t dma_addr; - - /* Get the physical address of the buffer in memory */ - gem =3D drm_fb_dma_get_gem_obj(fb, 0); - - /* Compute the start of the displayed memory */ - dma_addr =3D gem->dma_addr + fb->offsets[0]; - - /* Fixup framebuffer address for src coordinates */ - dma_addr +=3D drm_format_info_min_pitch(fb->format, 0, - src_rect->x1 >> 16); - dma_addr +=3D (src_rect->y1 >> 16) * fb->pitches[0]; - - return dma_addr; -} - struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane) { struct vs_plane_state *vs_state, *vs_state_old; diff --git a/drivers/gpu/drm/verisilicon/vs_plane.h b/drivers/gpu/drm/veris= ilicon/vs_plane.h index 32ed1d70f3b8..e4f82f1fc6e9 100644 --- a/drivers/gpu/drm/verisilicon/vs_plane.h +++ b/drivers/gpu/drm/verisilicon/vs_plane.h @@ -75,8 +75,6 @@ static inline struct vs_plane_state *to_vs_plane_state(st= ruct drm_plane_state *s } =20 int drm_format_to_vs_format(u32 drm_format, struct vs_format *vs_format); -dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb, - const struct drm_rect *src_rect); =20 struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane); void vs_plane_destroy_state(struct drm_plane *plane, diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/d= rm/verisilicon/vs_primary_plane.c index 1f2be41ae496..2750016a7f2c 100644 --- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c +++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -126,7 +127,11 @@ static void vs_primary_plane_atomic_update(struct drm_= plane *plane, VSDC_FB_CONFIG_UV_SWIZZLE_EN, vs_state->format.uv_swizzle); =20 - dma_addr =3D vs_fb_get_dma_addr(fb, &state->src); + /* + * Primary plane cannot be moved, no clipping is involved, + * so the non-clipped framebuffer address can be used. + */ + dma_addr =3D drm_fb_dma_get_gem_addr(fb, state, 0); =20 regmap_write(dc->regs, VSDC_FB_ADDRESS(output), lower_32_bits(dma_addr)); --=20 2.55.0.691.gc56d675ccc-goog