From: "Andy Yan" <andyshrk@163.com>
To: "Konstantin Shabanov" <mail@etehtsea.me>
Cc: "Sandy Huang" <hjc@rock-chips.com>,
"Heiko Stübner" <heiko@sntech.de>,
"Andy Yan" <andy.yan@rock-chips.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>,
"Dan Callaghan" <djc@djc.id.au>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
"Daniel Stone" <daniel@fooishbar.org>
Subject: Re:[PATCH V5 RESEND] drm/rockchip: Reject AFBC for res >2560 on rk3399
Date: Tue, 1 Jul 2025 10:55:00 +0800 (CST) [thread overview]
Message-ID: <3682f894.3077.197c3e8c232.Coremail.andyshrk@163.com> (raw)
In-Reply-To: <20250604090054.7070-1-mail@etehtsea.me>
Hello Konstanin and Daniel,
At 2025-06-04 17:00:53, "Konstantin Shabanov" <mail@etehtsea.me> wrote:
>As it isn't supported by rk3399. From the datasheet[1]
>("1.2.10 Video IN/OUT", "Display Interface", p. 17):
>
> Support AFBC function co-operation with GPU
> * support 2560x1600 UI
>
>Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
>Reported-by: Dan Callaghan <djc@djc.id.au>
>Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7968
>
>[1]: https://opensource.rock-chips.com/images/d/d7/Rockchip_RK3399_Datasheet_V2.1-20200323.pdf
>---
> V4 -> V5: Extract AFBC support check into drv
> V3 -> V4: Correct redundant header inclusion
> V2 -> V3: Run check only on rk3399
> V1 -> V2: Move the check to the fb_create callback
>
> AFBC check is implemented in a similar manner as in the malidp driver.
> Resend of the https://lore.kernel.org/all/20250521160556.14346-2-mail@etehtsea.me/.
>
> drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 16 ++++++++++++++++
> drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 ++
> drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 3 +++
> 3 files changed, 21 insertions(+)
>
>diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>index 180fad5d49ad..9fb04022b2f3 100644
>--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>@@ -42,6 +42,8 @@
> #define DRIVER_MAJOR 1
> #define DRIVER_MINOR 0
>
>+#define RK3399_AFBC_MAX_WIDTH 2560
>+
> static const struct drm_driver rockchip_drm_driver;
>
> /*
>@@ -350,6 +352,20 @@ int rockchip_drm_endpoint_is_subdriver(struct device_node *ep)
> return false;
> }
>
>+bool rockchip_verify_afbc_framebuffer_size(struct drm_device *dev,
>+ const struct drm_mode_fb_cmd2 *mode_cmd)
>+{
>+ if (of_machine_is_compatible("rockchip,rk3399") &&
>+ mode_cmd->width > RK3399_AFBC_MAX_WIDTH) {
>+ DRM_DEBUG_KMS("AFBC is not supported for the width %d (max %d)\n",
>+ mode_cmd->width,
>+ RK3399_AFBC_MAX_WIDTH);
>+ return false;
>+ }
>+
>+ return true;
>+}
>+
> static void rockchip_drm_match_remove(struct device *dev)
> {
> struct device_link *link;
>diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
>index c183e82a42a5..5dabceaa4fd6 100644
>--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
>+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
>@@ -86,6 +86,8 @@ int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);
> int rockchip_drm_encoder_set_crtc_endpoint_id(struct rockchip_encoder *rencoder,
> struct device_node *np, int port, int reg);
> int rockchip_drm_endpoint_is_subdriver(struct device_node *ep);
>+bool rockchip_verify_afbc_framebuffer_size(struct drm_device *dev,
>+ const struct drm_mode_fb_cmd2 *mode_cmd);
> extern struct platform_driver cdn_dp_driver;
> extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
> extern struct platform_driver dw_hdmi_qp_rockchip_pltfm_driver;
>diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>index 5829ee061c61..f0527f12f568 100644
>--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>@@ -52,6 +52,9 @@ rockchip_fb_create(struct drm_device *dev, struct drm_file *file,
> }
>
I found that when calling drm_gem_fb_init_with_funcs earlier, drm_any_plane_has_format would be called.
bool drm_plane_has_format(struct drm_plane *plane,
u32 format, u64 modifier)
{
unsigned int i;
for (i = 0; i < plane->format_count; i++) {
if (format == plane->format_types[i])
break;
}
if (i == plane->format_count)
return false;
if (plane->funcs->format_mod_supported) {
if (!plane->funcs->format_mod_supported(plane, format, modifier))
return false;
} else {
if (!plane->modifier_count)
If we extend the format_mod_supported by pass down fb, we still can do this
check by format_mod_supported at the fb create state ?
> if (drm_is_afbc(mode_cmd->modifier[0])) {
>+ if (!rockchip_verify_afbc_framebuffer_size(dev, mode_cmd))
>+ return ERR_PTR(-EINVAL);
>+
> ret = drm_gem_fb_afbc_init(dev, mode_cmd, afbc_fb);
> if (ret) {
> drm_framebuffer_put(&afbc_fb->base);
>
>base-commit: 685c407f168cb49a12cc703230d1e2d62767bfd2
>--
>2.49.0
prev parent reply other threads:[~2025-07-01 2:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 9:00 [PATCH " Konstantin Shabanov
2025-06-04 12:21 ` Daniel Stone
2025-07-01 2:55 ` Andy Yan [this message]
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=3682f894.3077.197c3e8c232.Coremail.andyshrk@163.com \
--to=andyshrk@163.com \
--cc=airlied@gmail.com \
--cc=andy.yan@rock-chips.com \
--cc=daniel@fooishbar.org \
--cc=djc@djc.id.au \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mail@etehtsea.me \
--cc=mripard@kernel.org \
--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®