[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1569398801-92201-3-git-send-email-hjc@rock-chips.com>
Date: Wed, 25 Sep 2019 16:06:39 +0800
From: Sandy Huang <hjc@...k-chips.com>
To: dri-devel@...ts.freedesktop.org, Sandy Huang <hjc@...k-chips.com>,
Heiko Stübner <heiko@...ech.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>
Cc: Ayan.Halder@....com, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] drm/rockchip: Add vop_format_get_bpp to get format bpp
For 10bit yuv format, we need to get format bpp each plane, so we
Add vop_format_get_bpp() to instead of format->cpp[];
Signed-off-by: Sandy Huang <hjc@...k-chips.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 2f821c5..ce5b45d 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -249,6 +249,25 @@ static bool has_rb_swapped(uint32_t format)
}
}
+static int vop_format_get_bpp(u32 format, u8 plane)
+{
+ const struct drm_format_info *info;
+
+ info = drm_format_info(format);
+ if (!info || plane >= info->num_planes)
+ return 0;
+
+ if (info->cpp[0] == 0) {
+ /* only support DRM_FORMAT_NVxx_10 now */
+ if (plane == 0)
+ return 10;
+ else
+ return 20;
+ }
+
+ return info->cpp[plane] * 8;
+}
+
static enum vop_data_format vop_convert_format(uint32_t format)
{
switch (format) {
@@ -832,7 +851,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
dsp_sty = dest->y1 + crtc->mode.vtotal - crtc->mode.vsync_start;
dsp_st = dsp_sty << 16 | (dsp_stx & 0xffff);
- offset = (src->x1 >> 16) * fb->format->cpp[0];
+ offset = (src->x1 >> 16) *
+ vop_format_get_bpp(fb->format->format, 0) / 8;
offset += (src->y1 >> 16) * fb->pitches[0];
dma_addr = rk_obj->dma_addr + offset + fb->offsets[0];
@@ -859,12 +879,12 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
if (is_yuv) {
int hsub = fb->format->hsub;
int vsub = fb->format->vsub;
- int bpp = fb->format->cpp[1];
+ int bpp = vop_format_get_bpp(fb->format->format, 1);
uv_obj = fb->obj[1];
rk_uv_obj = to_rockchip_obj(uv_obj);
- offset = (src->x1 >> 16) * bpp / hsub;
+ offset = (src->x1 >> 16) * bpp / 8 / hsub;
offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
--
2.7.4
Powered by blists - more mailing lists