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 <[email protected]>
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 19cb16a7daf9..fe73b365e547 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -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);
 }
 
-- 
2.54.0

Reply via email to