* [PATCH v2 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state()
[not found] <20260420121130.200133-1-tzimmermann@suse.de>
@ 2026-04-20 12:09 ` Thomas Zimmermann
2026-04-21 7:56 ` Yongbang Shi
2026-04-20 12:09 ` [PATCH v2 2/4] drm/hibmc: Fix list of formats on the primary plane Thomas Zimmermann
1 sibling, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2026-04-20 12:09 UTC (permalink / raw)
To: xinliang.liu, tiantao6, kong.kongxinwei, sumit.semwal,
yongqin.liu, jstultz, maarten.lankhorst, mripard, airlied, simona
Cc: dri-devel, Thomas Zimmermann, Rongrong Zou, Sean Paul,
Dmitry Baryshkov, Baihan Li, Yongbang Shi, stable
Call drm_atomic_helper_check_plane_state() from the primary plane's
atomic-check helper and replace the custom implementation.
All plane's implementations of atomic_check should call the shared
_check_plane_state() helper first. It adjusts the plane state for
correct positioning, rotation and scaling of the plane. Do this
even if the plane's CRTC has been disabled by setting the parameter
can_update_disabled. The original code returned early in this case,
but it's safe to so and cleaner to have all plane state initialized.
As we don't set can_position, drm_atomic_helper_check_plane_state()'s
visibility check tests if the plane covers all of the CRTC. This is
a small change from the original code, which tested if the plane is
exactly the size of the CRTC. With the new test, the plane still has
to cover all of the CRTC, but can be larger than the CRTC's size. A
later patch can fully implement this feature in hibmc.
If the plane is disabled, the helper clears the visibility flag in the
plane state. On errors or if the plane is not visible, the atomic-check
helper can return early. Implement all this in hibmc and drop the custom
code that does some of it.
v2:
- extend the commit description (Yongbang)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: da52605eea8f ("drm/hisilicon/hibmc: Add support for display engine")
Cc: Rongrong Zou <zourongrong@gmail.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Baihan Li <libaihan@huawei.com>
Cc: Yongbang Shi <shiyongbang@huawei.com>
Cc: <stable@vger.kernel.org> # v4.10+
---
.../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 46 ++++++-------------
1 file changed, 14 insertions(+), 32 deletions(-)
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 89bed78f1466..8fa2a95bcdd1 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -55,46 +55,28 @@ static const struct hibmc_dislay_pll_config hibmc_pll_table[] = {
static int hibmc_plane_atomic_check(struct drm_plane *plane,
struct drm_atomic_state *state)
{
- struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
- plane);
- struct drm_framebuffer *fb = new_plane_state->fb;
- struct drm_crtc *crtc = new_plane_state->crtc;
- struct drm_crtc_state *crtc_state;
- u32 src_w = new_plane_state->src_w >> 16;
- u32 src_h = new_plane_state->src_h >> 16;
-
- if (!crtc || !fb)
- return 0;
+ struct drm_plane_state *new_plane_state =
+ drm_atomic_get_new_plane_state(state, plane);
+ struct drm_crtc_state *new_crtc_state = NULL;
+ int ret;
- crtc_state = drm_atomic_get_crtc_state(state, crtc);
- if (IS_ERR(crtc_state))
- return PTR_ERR(crtc_state);
+ if (new_plane_state->crtc)
+ new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_state->crtc);
- if (src_w != new_plane_state->crtc_w || src_h != new_plane_state->crtc_h) {
- drm_dbg_atomic(plane->dev, "scale not support\n");
- return -EINVAL;
- }
-
- if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) {
- drm_dbg_atomic(plane->dev, "crtc_x/y of drm_plane state is invalid\n");
- return -EINVAL;
- }
-
- if (!crtc_state->enable)
+ ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state,
+ DRM_PLANE_NO_SCALING,
+ DRM_PLANE_NO_SCALING,
+ false, true);
+ if (ret)
+ return ret;
+ else if (!new_plane_state->visible)
return 0;
- if (new_plane_state->crtc_x + new_plane_state->crtc_w >
- crtc_state->adjusted_mode.hdisplay ||
- new_plane_state->crtc_y + new_plane_state->crtc_h >
- crtc_state->adjusted_mode.vdisplay) {
- drm_dbg_atomic(plane->dev, "visible portion of plane is invalid\n");
- return -EINVAL;
- }
-
if (new_plane_state->fb->pitches[0] % 128 != 0) {
drm_dbg_atomic(plane->dev, "wrong stride with 128-byte aligned\n");
return -EINVAL;
}
+
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/4] drm/hibmc: Fix list of formats on the primary plane
[not found] <20260420121130.200133-1-tzimmermann@suse.de>
2026-04-20 12:09 ` [PATCH v2 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state() Thomas Zimmermann
@ 2026-04-20 12:09 ` Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2026-04-20 12:09 UTC (permalink / raw)
To: xinliang.liu, tiantao6, kong.kongxinwei, sumit.semwal,
yongqin.liu, jstultz, maarten.lankhorst, mripard, airlied, simona
Cc: dri-devel, Thomas Zimmermann, Yongbang Shi, Rongrong Zou,
Sean Paul, Dmitry Baryshkov, Baihan Li, stable
Remove all formats from the primary plane that are unsupported for
various reasons.
* Formats with alpha channel: planes should not announce alpha channels
unless they support transparency. There's no transparency support in
the primary plane's implementation.
* Formats with BGR order. The common format is in RGB channel order.
There's no BGR support in the primary plane's implementation.
* RGB888: atomic_update programs the format from cpp[0] * 8 / 16. For
RGB888's cpp value of 3 this returns 1.5; rounded to 1. Programming
the value of 1 to HIBMC_CRT_DISP_CTL_FORMAT sets up RGB565. Hence, the
output is distorted. This can be tested by booting with video=1024x768-24.
Removing all unsupported formats leaves XRGB8888 and RGB565. Both of
which are supported and work correctly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: da52605eea8f ("drm/hisilicon/hibmc: Add support for display engine")
Reviewed-by: Yongbang Shi <shiyongbang@huawei.com>
Cc: Rongrong Zou <zourongrong@gmail.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Yongbang Shi <shiyongbang@huawei.com>
Cc: Baihan Li <libaihan@huawei.com>
Cc: <stable@vger.kernel.org> # v4.10+
---
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 8fa2a95bcdd1..c4f9ebd9250d 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -118,10 +118,8 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
}
static const u32 channel_formats1[] = {
- DRM_FORMAT_RGB565, DRM_FORMAT_BGR565, DRM_FORMAT_RGB888,
- DRM_FORMAT_BGR888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XBGR8888,
- DRM_FORMAT_RGBA8888, DRM_FORMAT_BGRA8888, DRM_FORMAT_ARGB8888,
- DRM_FORMAT_ABGR8888
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_RGB565,
};
static const struct drm_plane_funcs hibmc_plane_funcs = {
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state()
2026-04-20 12:09 ` [PATCH v2 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state() Thomas Zimmermann
@ 2026-04-21 7:56 ` Yongbang Shi
0 siblings, 0 replies; 3+ messages in thread
From: Yongbang Shi @ 2026-04-21 7:56 UTC (permalink / raw)
To: Thomas Zimmermann, xinliang.liu, tiantao6, kong.kongxinwei,
sumit.semwal, yongqin.liu, jstultz, maarten.lankhorst, mripard,
airlied, simona
Cc: dri-devel, Rongrong Zou, Sean Paul, Dmitry Baryshkov, Baihan Li,
stable, shiyongbang,
Liangjian(Jim,Kunpeng Solution Development Dept), Chenjianmin,
fengsheng (A)
> Call drm_atomic_helper_check_plane_state() from the primary plane's
> atomic-check helper and replace the custom implementation.
>
> All plane's implementations of atomic_check should call the shared
> _check_plane_state() helper first. It adjusts the plane state for
> correct positioning, rotation and scaling of the plane. Do this
> even if the plane's CRTC has been disabled by setting the parameter
> can_update_disabled. The original code returned early in this case,
> but it's safe to so and cleaner to have all plane state initialized.
>
> As we don't set can_position, drm_atomic_helper_check_plane_state()'s
> visibility check tests if the plane covers all of the CRTC. This is
> a small change from the original code, which tested if the plane is
> exactly the size of the CRTC. With the new test, the plane still has
> to cover all of the CRTC, but can be larger than the CRTC's size. A
> later patch can fully implement this feature in hibmc.
>
> If the plane is disabled, the helper clears the visibility flag in the
> plane state. On errors or if the plane is not visible, the atomic-check
> helper can return early. Implement all this in hibmc and drop the custom
> code that does some of it.
> > v2:
> - extend the commit description (Yongbang)
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: da52605eea8f ("drm/hisilicon/hibmc: Add support for display engine")
> Cc: Rongrong Zou <zourongrong@gmail.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Xinliang Liu <xinliang.liu@linaro.org>
> Cc: Dmitry Baryshkov <lumag@kernel.org>
> Cc: Baihan Li <libaihan@huawei.com>
> Cc: Yongbang Shi <shiyongbang@huawei.com>
> Cc: <stable@vger.kernel.org> # v4.10+
> ---
> .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 46 ++++++-------------
> 1 file changed, 14 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> index 89bed78f1466..8fa2a95bcdd1 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> @@ -55,46 +55,28 @@ static const struct hibmc_dislay_pll_config hibmc_pll_table[] = {
> static int hibmc_plane_atomic_check(struct drm_plane *plane,
> struct drm_atomic_state *state)
> {
> - struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> - plane);
> - struct drm_framebuffer *fb = new_plane_state->fb;
> - struct drm_crtc *crtc = new_plane_state->crtc;
> - struct drm_crtc_state *crtc_state;
> - u32 src_w = new_plane_state->src_w >> 16;
> - u32 src_h = new_plane_state->src_h >> 16;
> -
> - if (!crtc || !fb)
> - return 0;
> + struct drm_plane_state *new_plane_state =
> + drm_atomic_get_new_plane_state(state, plane);
> + struct drm_crtc_state *new_crtc_state = NULL;
> + int ret;
>
> - crtc_state = drm_atomic_get_crtc_state(state, crtc);
> - if (IS_ERR(crtc_state))
> - return PTR_ERR(crtc_state);
> + if (new_plane_state->crtc)
> + new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_state->crtc);
>
> - if (src_w != new_plane_state->crtc_w || src_h != new_plane_state->crtc_h) {
> - drm_dbg_atomic(plane->dev, "scale not support\n");
> - return -EINVAL;
> - }
> -
> - if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) {
> - drm_dbg_atomic(plane->dev, "crtc_x/y of drm_plane state is invalid\n");
> - return -EINVAL;
> - }
> -
> - if (!crtc_state->enable)
> + ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state,
> + DRM_PLANE_NO_SCALING,
> + DRM_PLANE_NO_SCALING,
> + false, true);
> + if (ret)
> + return ret;
> + else if (!new_plane_state->visible)
> return 0;
>
> - if (new_plane_state->crtc_x + new_plane_state->crtc_w >
> - crtc_state->adjusted_mode.hdisplay ||
> - new_plane_state->crtc_y + new_plane_state->crtc_h >
> - crtc_state->adjusted_mode.vdisplay) {
> - drm_dbg_atomic(plane->dev, "visible portion of plane is invalid\n");
> - return -EINVAL;
> - }
> -
> if (new_plane_state->fb->pitches[0] % 128 != 0) {
> drm_dbg_atomic(plane->dev, "wrong stride with 128-byte aligned\n");
> return -EINVAL;
> }
> +
> return 0;
> }
>
Reviewed-by: Yongbang Shi <shiyongbang@huawei.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-21 7:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260420121130.200133-1-tzimmermann@suse.de>
2026-04-20 12:09 ` [PATCH v2 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state() Thomas Zimmermann
2026-04-21 7:56 ` Yongbang Shi
2026-04-20 12:09 ` [PATCH v2 2/4] drm/hibmc: Fix list of formats on the primary plane Thomas Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox