drm/hibmc: Do not use cpp from struct drm_format_info

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.

v4:
- introduce fb variable in separate patch (Yongbang)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Yongbang Shi <shiyongbang@huawei.com>
Link: https://patch.msgid.link/20260618123142.92298-5-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2026-06-18 14:28:42 +02:00
parent 47decb5e94
commit defd8ba932

View File

@ -119,7 +119,7 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS);
reg = fb->width * fb->format->cpp[0];
reg = drm_format_info_min_pitch(fb->format, 0, fb->width);
line_l = fb->pitches[0];
writel(HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_WIDTH, reg) |
@ -129,7 +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, 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);
}