From: Yongbang Shi <shiyongbang@huawei.com>
To: Thomas Zimmermann <tzimmermann@suse.de>, <tiantao6@hisilicon.com>,
<kong.kongxinwei@hisilicon.com>, <sumit.semwal@linaro.org>,
<yongqin.liu@linaro.org>, <jstultz@google.com>,
<maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
<airlied@gmail.com>, <simona@ffwll.ch>
Cc: <dri-devel@lists.freedesktop.org>,
Rongrong Zou <zourongrong@gmail.com>,
Sean Paul <seanpaul@chromium.org>,
Dmitry Baryshkov <lumag@kernel.org>, <stable@vger.kernel.org>,
<shiyongbang@huawei.com>,
"Liangjian(Jim,Kunpeng Solution Development Dept)"
<liangjian010@huawei.com>, Chenjianmin <chenjianmin@huawei.com>,
"fengsheng (A)" <fengsheng5@huawei.com>
Subject: Re: [PATCH 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state()
Date: Thu, 16 Apr 2026 14:53:47 +0800 [thread overview]
Message-ID: <7fd5022a-9a5d-4976-9d4a-1e0fa2022eae@huawei.com> (raw)
In-Reply-To: <20260413085037.17491-2-tzimmermann@suse.de>
> 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. If the plane
> is not visible, it clears the corresponding 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.
>
> 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);
The last parameter, "can_update_disabled", if set to true, causes the
condition "if (!crtc_state->enable && !can_update_disabled)" in the
function `drm_atomic_helper_check_plane_state` to always evaluate to
false, meaning `crtc_state->enable` will not be checked. This differs
from the behavior prior to the modification.
before:
- crtc_state->enable(true) --> continue check
- crtc_state->enable(false) --> return 0(atomic check success)
after:
- crtc_state->enable(true) --> _helper_check_plane_ -> continue check
- crtc_state->enable(false) --> _helper_check_plane_ -> continue check
> + 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;
> - }
> -
The purpose of this check is to ensure that the right and bottom
boundaries of the plane do not extend beyond the crtc. In
`drm_atomic_helper_check_plane_state`, `drm_mode_get_hv_timing` is
called to retrieve the crtc boundaries, and `drm_rect_clip_scaled` is
used to clip the plane, any portions extending beyond the right and
bottom boundaries are discarded.
I'd like to confirm that my understanding is correct? previously, the
check failed if the plane exceeded the boundaries, but now, after
`drm_atomic_helper_check_plane_state` is called, the plane is clipped to
fit within the boundaries.
in function drm_rect_clip_scaled:
diff = dst->x2 - clip->x2;
if (diff > 0) {
...
dst->x2 -= diff;
}
diff = dst->y2 - clip->y2;
if (diff > 0) {
...
dst->y2 -= diff;
}
Thanks.
Best regards
Yongbang.
> 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;
> }
>
next prev parent reply other threads:[~2026-04-16 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260413085037.17491-1-tzimmermann@suse.de>
2026-04-13 8:40 ` [PATCH 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state() Thomas Zimmermann
2026-04-16 6:53 ` Yongbang Shi [this message]
2026-04-16 9:41 ` Thomas Zimmermann
2026-04-16 13:22 ` Yongbang Shi
2026-04-17 6:17 ` Thomas Zimmermann
2026-04-17 7:08 ` Yongbang Shi
2026-04-13 8:40 ` [PATCH 2/4] drm/hibmc: Fix list of formats on the primary plane Thomas Zimmermann
2026-04-15 3:19 ` Yongbang Shi
2026-04-15 6:09 ` Thomas Zimmermann
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=7fd5022a-9a5d-4976-9d4a-1e0fa2022eae@huawei.com \
--to=shiyongbang@huawei.com \
--cc=airlied@gmail.com \
--cc=chenjianmin@huawei.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fengsheng5@huawei.com \
--cc=jstultz@google.com \
--cc=kong.kongxinwei@hisilicon.com \
--cc=liangjian010@huawei.com \
--cc=lumag@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=seanpaul@chromium.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tiantao6@hisilicon.com \
--cc=tzimmermann@suse.de \
--cc=yongqin.liu@linaro.org \
--cc=zourongrong@gmail.com \
/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