Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp6777958imm; Sun, 20 May 2018 10:24:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrik1UFnwidhzGUssqE6S6ojn5GAk6reP3nUvE2iht1IqGonPLZmsqducH5taLD4u/3AabM X-Received: by 2002:a17:902:268:: with SMTP id 95-v6mr17565730plc.386.1526837048007; Sun, 20 May 2018 10:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526837047; cv=none; d=google.com; s=arc-20160816; b=mRy1HYyaaTObLRujl5INYF1Ozs6WaimqLPBzDDrCIwQp6UawR7T0KhQPnI19vEkOb7 tQfMCQ8NLlQ/YQfYCoAeyPBdgqOqmzKiW1RUl/sQrfpnMmBBpsDdEyy26VkNC3Ni89F9 2l31JkAKOHXMfvrIj7Clb79Zku2OkEW7Tx705uG8iuSvFC2cWVIiqNgxBD54CVCap/wE PoTMYe3A1VJbUvQ3a1AA6332HFPF918ZRVx0hZCQ04U4oyqqep/scaj3/B32A3iNN4zX CQp/XR72I00MhwAxnRGvAzh+tbRKxUdTD0JijD3uV2Uttka/RQJg+N3ti9Kp4vOvT61v UYyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TqaovfYg+TPzWtd1YkpEI3pGuWnnCKnCN6sU8N/yxt4=; b=McYCAx8of0IzyKM9jyfVyB1/yF8Q1g4c75u4P2QaxolWfYnWgrLNta08j6kIxmai1J vld0RAJBNo12/PPsk9ezgW15cPIxOn2UrBuSsGUMg1L85kK/RPzftKB0NEt4lCNh03w0 lZrAP9+SH/YgnYbrR0xQ0hpoQgSZCoBy4NZsYQqhfDEA33WRnmgntj1kfz02Bhczuzfr DC5OKXB2OrfiQQRnMJ3Fv41B9geRRToYAv1C+hDqkMz4lN76r8ieaSSFdxw4227V/BCB 6Ils0FnFJA4mbbiXbhyx8zCUUk39/WctWCetZVYsFTF/urHcA0gvdf9qgRa7mDZjz/8U OOfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b79-v6si12347344pfm.104.2018.05.20.10.23.41; Sun, 20 May 2018 10:24:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752655AbeETRXV (ORCPT + 99 others); Sun, 20 May 2018 13:23:21 -0400 Received: from kozue.soulik.info ([108.61.200.231]:37402 "EHLO kozue.soulik.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751990AbeETRXO (ORCPT ); Sun, 20 May 2018 13:23:14 -0400 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 Cc: Randy Li , hjc@rock-chips.com, heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, nicolas.dufresne@collabora.com, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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), -- 2.14.3