From: Yongbang Shi <shiyongbang@huawei.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
<xinliang.liu@linaro.org>, <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>, <shiyongbang@huawei.com>,
Chenjianmin <chenjianmin@huawei.com>,
"Liangjian(Jim,Kunpeng Solution Development Dept)"
<liangjian010@huawei.com>,
"fengsheng (A)" <fengsheng5@huawei.com>
Subject: Re: [PATCH v3 3/4] drm/hibmc: Do not use cpp from struct drm_format_info
Date: Mon, 8 Jun 2026 14:25:50 +0800 [thread overview]
Message-ID: <e1ada2a4-ab28-4637-bb72-b8ca510292ee@huawei.com> (raw)
In-Reply-To: <20260601114756.51953-4-tzimmermann@suse.de>
Hi, Thomas.
> Replace uses of struct drm_format_info's cpp with appropriate interfaces.
> The cpp field contains the characters per pixel. It is deprecated and
> should be avoided.
>
> Calculate the line width in bytes with drm_format_info_min_pitch(). This
> is the preferred way of getting pixel and line sizes.
>
> Program HIB_CRT_DISP_CTL_FORMAT from the format's 4CC code instead of
> calculating the field's value from the cpp.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> index 2e6e189bec1a..79c33c778d2c 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> @@ -100,8 +100,8 @@ static int hibmc_plane_atomic_check(struct drm_plane *plane,
> static void hibmc_plane_atomic_update(struct drm_plane *plane,
> struct drm_atomic_commit *state)
> {
> - struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
> - plane);
> + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
> + struct drm_framebuffer *fb = new_state->fb;
> u32 reg;
> s64 gpu_addr = 0;
> u32 line_l;
> @@ -119,7 +119,7 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
>
> writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS);
>
> - reg = new_state->fb->width * (new_state->fb->format->cpp[0]);
> + reg = drm_format_info_min_pitch(fb->format, 0, fb->width);
>
> line_l = new_state->fb->pitches[0];
Since the variable `fb` was defined earlier, it can be used directly here without needing `new_state->fb`.
This function uses `new_state->fb` in two other places:
https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-next/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c?ref_type=heads#L129
https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-next/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c?ref_type=heads#L132
Thanks,
Yongbang.
> writel(HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_WIDTH, reg) |
> @@ -129,8 +129,14 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
> /* SET PIXEL FORMAT */
> reg = readl(priv->mmio + HIBMC_CRT_DISP_CTL);
> reg &= ~HIBMC_CRT_DISP_CTL_FORMAT_MASK;
> - reg |= HIBMC_FIELD(HIBMC_CRT_DISP_CTL_FORMAT,
> - new_state->fb->format->cpp[0] * 8 / 16);
> + switch (fb->format->format) {
> + case DRM_FORMAT_XRGB8888:
> + reg |= HIBMC_FIELD(HIBMC_CRT_DISP_CTL_FORMAT, 2);
> + break;
> + case DRM_FORMAT_RGB565:
> + reg |= HIBMC_FIELD(HIBMC_CRT_DISP_CTL_FORMAT, 1);
> + break;
> + }
> writel(reg, priv->mmio + HIBMC_CRT_DISP_CTL);
> }
>
next prev parent reply other threads:[~2026-06-08 6:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 11:45 [PATCH v3 0/4] drm/hibmc: Fix plane helpers and convert to gem-shmem Thomas Zimmermann
2026-06-01 11:45 ` [PATCH v3 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state() Thomas Zimmermann
2026-06-01 11:45 ` [PATCH v3 2/4] drm/hibmc: Fix list of formats on the primary plane Thomas Zimmermann
2026-06-01 11:45 ` [PATCH v3 3/4] drm/hibmc: Do not use cpp from struct drm_format_info Thomas Zimmermann
2026-06-08 6:25 ` Yongbang Shi [this message]
2026-06-01 11:45 ` [PATCH v3 4/4] drm/hibmc: Use gem-shmem with shadow-plane helpers for memory management Thomas Zimmermann
2026-06-08 13:42 ` Yongbang Shi
2026-06-10 9:09 ` Thomas Zimmermann
2026-06-11 9:12 ` Yongbang Shi
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=e1ada2a4-ab28-4637-bb72-b8ca510292ee@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=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=sumit.semwal@linaro.org \
--cc=tiantao6@hisilicon.com \
--cc=tzimmermann@suse.de \
--cc=xinliang.liu@linaro.org \
--cc=yongqin.liu@linaro.org \
/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