From patchwork Sun May 20 17:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ayaka X-Patchwork-Id: 10413563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3647A60365 for ; Sun, 20 May 2018 17:18:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 919ED28623 for ; Sun, 20 May 2018 17:18:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 830252862A; Sun, 20 May 2018 17:18:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0210F28623 for ; Sun, 20 May 2018 17:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Vv4PzATzzbXWuvOiJIIbJrJQs0sHjRKUDWdV4PVHbtU=; b=hMqMYiEXiJcBdLsEYzt7yCFQaL fGy/air8Y295VJ9nr2VqCnFV6OtNNIeStHEkZGAC+OFnz20zG/avv1B6Rn19ECGDwpaWMZoWs76EM ZnUzEcNjZGdkUoNtovJcIfwRmCAgnwA9fQqWK59kq7yKMj1K9dc6+JLSM7oPaKiYLjYrUrlHlmuew WMs0hVuJhd+FIV8BfrhchHsg5dcr1hgZ2Or94btjs92PNQquhR2Bgt7DSnmTsxc4Hg7e3pvm0AL/O dpZVDoX6O4v3ngiK7I7UFBE/gvk+/WSuXtGXBQ+Syywgo0GCLa4zc1ZaRevuhj9cpSvsm+kNofGCB M37zwzvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKRyh-0004cH-NV; Sun, 20 May 2018 17:18:39 +0000 Received: from kozue.soulik.info ([2001:19f0:7000:8404:5054:ff:fe75:428f]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKRxr-0003tR-3g; Sun, 20 May 2018 17:17:49 +0000 Received: from misaki.sumomo.pri (unknown [IPv6:2001:470:b30d:2:ec4:7aff:fe92:7ff4]) by kozue.soulik.info (Postfix) with ESMTPA id 5DF00100F36; Mon, 21 May 2018 02:17:39 +0900 (JST) From: Randy Li To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/rockchip: Support 10 bits yuv format in vop Date: Mon, 21 May 2018 01:17:05 +0800 Message-Id: <20180520171705.29690-3-ayaka@soulik.info> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180520171705.29690-1-ayaka@soulik.info> References: <20180520171705.29690-1-ayaka@soulik.info> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180520_101747_401433_C95BB639 X-CRM114-Status: GOOD ( 12.14 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, airlied@linux.ie, gustavo@padovan.org, Randy Li , maarten.lankhorst@linux.intel.com, linux-kernel@vger.kernel.org, hjc@rock-chips.com, linux-rockchip@lists.infradead.org, seanpaul@chromium.org, nicolas.dufresne@collabora.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The rockchip use fully packed pixel format variants for YUV 10bits. This patch only make the VOP accept this pixel format, but it doesn't add the converting data path for the color gamuts that the target display are supported. Signed-off-by: Randy Li --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 27 +++++++++++++++++++++++++-- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 1 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 2121345a61af..6a54b20501ac 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -232,6 +232,7 @@ static enum vop_data_format vop_convert_format(uint32_t format) case DRM_FORMAT_BGR565: return VOP_FMT_RGB565; case DRM_FORMAT_NV12: + case DRM_FORMAT_NV12_10LE40: return VOP_FMT_YUV420SP; case DRM_FORMAT_NV16: return VOP_FMT_YUV422SP; @@ -249,6 +250,17 @@ static bool is_yuv_support(uint32_t format) case DRM_FORMAT_NV12: case DRM_FORMAT_NV16: case DRM_FORMAT_NV24: + case DRM_FORMAT_NV12_10LE40: + return true; + default: + return false; + } +} + +static bool is_yuv_10bit(uint32_t format) +{ + switch (format) { + case DRM_FORMAT_NV12_10LE40: return true; default: return false; @@ -711,6 +723,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, dma_addr_t dma_addr; uint32_t val; bool rb_swap; + bool is_10_bits = false; int win_index = VOP_WIN_TO_INDEX(vop_win); int format; @@ -728,6 +741,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane, return; } + is_10_bits = is_yuv_10bit(fb->format->format); + obj = rockchip_fb_get_gem_obj(fb, 0); rk_obj = to_rockchip_obj(obj); @@ -742,7 +757,11 @@ 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]; + if (is_10_bits) + offset = (src->x1 >> 16) * (fb->format->cpp[0] * 5 / 4); + else + offset = (src->x1 >> 16) * fb->format->cpp[0]; + offset += (src->y1 >> 16) * fb->pitches[0]; dma_addr = rk_obj->dma_addr + offset + fb->offsets[0]; @@ -753,6 +772,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, VOP_WIN_SET(vop, win, format, format); VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4)); VOP_WIN_SET(vop, win, yrgb_mst, dma_addr); + VOP_WIN_SET(vop, win, fmt_10, is_10_bits); if (is_yuv_support(fb->format->format)) { int hsub = drm_format_horz_chroma_subsampling(fb->format->format); int vsub = drm_format_vert_chroma_subsampling(fb->format->format); @@ -761,7 +781,10 @@ static void vop_plane_atomic_update(struct drm_plane *plane, uv_obj = rockchip_fb_get_gem_obj(fb, 1); rk_uv_obj = to_rockchip_obj(uv_obj); - offset = (src->x1 >> 16) * bpp / hsub; + if (is_10_bits) + offset = (src->x1 >> 16) * (bpp * 5 / 4) / hsub; + else + offset = (src->x1 >> 16) * bpp / hsub; offset += (src->y1 >> 16) * fb->pitches[1] / vsub; dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1]; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h index 084acdd0019a..d9ec993f420a 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h @@ -131,6 +131,7 @@ struct vop_win_phy { struct vop_reg enable; struct vop_reg gate; struct vop_reg format; + struct vop_reg fmt_10; struct vop_reg rb_swap; struct vop_reg act_info; struct vop_reg dsp_info; diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c index 08023d3ecb76..5393886ddd95 100644 --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c @@ -50,6 +50,7 @@ static const uint32_t formats_win_full[] = { DRM_FORMAT_NV12, DRM_FORMAT_NV16, DRM_FORMAT_NV24, + DRM_FORMAT_NV12_10LE40, }; static const uint32_t formats_win_lite[] = { @@ -215,6 +216,7 @@ static const struct vop_win_phy rk3288_win01_data = { .nformats = ARRAY_SIZE(formats_win_full), .enable = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 0), .format = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 1), + .fmt_10 = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 4), .rb_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 12), .act_info = VOP_REG(RK3288_WIN0_ACT_INFO, 0x1fff1fff, 0), .dsp_info = VOP_REG(RK3288_WIN0_DSP_INFO, 0x0fff0fff, 0),