Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3214380imu; Sat, 24 Nov 2018 00:16:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/WF4dFAt1l6oeF2a9MCSLahJl8ojle/56xIk9wI/P7hAAoKTC1MLQae8adk47lI1he00mXy X-Received: by 2002:a63:c503:: with SMTP id f3mr16686199pgd.431.1543047376650; Sat, 24 Nov 2018 00:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047376; cv=none; d=google.com; s=arc-20160816; b=DAwV5iW5Yute5WtaJE600woES1R1xFXmOukk3eZt1ChOWt20CI2fshI6zjPvjVZjW5 XJzZFDST0ibGIMLHeZ1IKsaOyLNB0KvoZm5UziM/5FHDB5m/KbYURfYVSXcz+sqvDaVL B9PtWfb450kOjtooxRUQoX7MIYGzt/e+8P7ZSL0jVMBF80yIYGUb08Tut7+5jnB3LnBS qcRiiD2rO1TJdOnG/hHCSjPQ7KRZISHqxmNJvfKudy6So6dovBPl9B7zZAcPtJcHmj0g UMVMtn8jSD76Crb1jwepiRZywCHXD7IyLGX3JLMwB7g/Vj/D7Ne/y2tm6y/Etc7Sou+a Vs5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=oYZqrorxdLOQRZPI7cgeswvaohdUT1MLFVbzO6wNeqs=; b=WNmaL2cFYKqbkG3Y6Y6+9MCHbsf4rIm7DKGcg4/ngRkbCAX+v1y1VCNabRlVOG5WVg oi4LmU8vh6tMCpD8l0LKzKSb3RFzSThIfTxiRPRoJbdLHXr9QCGVd7U5ODuFkBQA72j9 8AIl+Al7gKBF0jwvbqs4NCdeb3IRCYmDs6qyQKtdsRzH55Fq0s4N1C4h7/wHSlN0qXSj YIP6MbnN/LxDlFoblr7nJlSLAZybhaEKeMey4nDTri9Swrrflx4Z87l22UVNQhl0nDTJ 883S66n7La46kPFBdnCSDz22nZ0tKIPZ/O4eCrIJ17avWKN7HE+whWbOExa6kdLd+YRj IhZQ== 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 c68-v6si59672297pfa.267.2018.11.24.00.16.02; Sat, 24 Nov 2018 00:16:16 -0800 (PST) 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 S2502771AbeKWUK2 (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:28 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49421 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390496AbeKWUK1 (ORCPT ); Fri, 23 Nov 2018 15:10:27 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id A6B2920E0E; Fri, 23 Nov 2018 10:26:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 8484120E13; Fri, 23 Nov 2018 10:26:34 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter , Paul Kocialkowski Subject: [PATCH v2 27/43] drm/sun4i: frontend: Add support for semi-planar YUV input formats Date: Fri, 23 Nov 2018 10:24:59 +0100 Message-Id: <20181123092515.2511-28-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Semi-planar YUV formats use two distinct planes, one for luminance and one for chrominance. To add support for them, we need to configure the second line stride and buffer address registers to setup the second YUV plane. New definitions are introduced to configure the input format register for the YUV420 and YUV422 semi-planar formats. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 52 +++++++++++++++++++++++--- drivers/gpu/drm/sun4i/sun4i_frontend.h | 6 +++ drivers/gpu/drm/sun4i/sun4i_layer.c | 4 ++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index f443e8e1d8ec..e31438e5cabd 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -118,11 +118,23 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD0_REG, fb->pitches[0]); + if (fb->format->num_planes > 1) + regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD1_REG, + fb->pitches[1]); + /* Set the physical address of the buffer in memory */ paddr = drm_fb_cma_get_gem_addr(fb, state, 0); paddr -= PHYS_OFFSET; - DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr); + DRM_DEBUG_DRIVER("Setting buffer #0 address to %pad\n", &paddr); regmap_write(frontend->regs, SUN4I_FRONTEND_BUF_ADDR0_REG, paddr); + + if (fb->format->num_planes > 1) { + paddr = drm_fb_cma_get_gem_addr(fb, state, 1); + paddr -= PHYS_OFFSET; + DRM_DEBUG_DRIVER("Setting buffer #1 address to %pad\n", &paddr); + regmap_write(frontend->regs, SUN4I_FRONTEND_BUF_ADDR1_REG, + paddr); + } } EXPORT_SYMBOL(sun4i_frontend_update_buffer); @@ -130,6 +142,8 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) { if (!drm_format_is_yuv(fmt)) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB; + else if (drm_format_is_yuv_sampling_420(fmt)) + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV420; else if (drm_format_is_yuv_sampling_422(fmt)) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422; else @@ -140,12 +154,20 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) { - if (drm_format_num_planes(fmt) == 1) + int num_planes = drm_format_num_planes(fmt); + + switch (num_planes) { + case 1: *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED; - else - return -EINVAL; + return 0; - return 0; + case 2: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR; + return 0; + + default: + return -EINVAL; + } } static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) @@ -155,6 +177,22 @@ static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX; return 0; + case DRM_FORMAT_NV12: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UV; + return 0; + + case DRM_FORMAT_NV16: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UV; + return 0; + + case DRM_FORMAT_NV21: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VU; + return 0; + + case DRM_FORMAT_NV61: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VU; + return 0; + case DRM_FORMAT_UYVY: *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UYVY; return 0; @@ -198,6 +236,10 @@ static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) static const uint32_t sun4i_frontend_formats[] = { DRM_FORMAT_BGRX8888, + DRM_FORMAT_NV12, + DRM_FORMAT_NV16, + DRM_FORMAT_NV21, + DRM_FORMAT_NV61, DRM_FORMAT_UYVY, DRM_FORMAT_VYUY, DRM_FORMAT_XRGB8888, diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 399755939a28..7d01b4f09b75 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -22,17 +22,23 @@ #define SUN4I_FRONTEND_BYPASS_CSC_EN BIT(1) #define SUN4I_FRONTEND_BUF_ADDR0_REG 0x020 +#define SUN4I_FRONTEND_BUF_ADDR1_REG 0x024 #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 +#define SUN4I_FRONTEND_LINESTRD1_REG 0x044 #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR (2 << 8) #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422 (1 << 4) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV420 (2 << 4) #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4) #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UYVY 0 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YUYV 1 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VYUY 2 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YVYU 3 +#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UV 0 +#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VU 1 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX 0 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 6155eca6b1bd..80c718f06ce8 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -136,6 +136,10 @@ static const uint32_t sun4i_layer_formats[] = { DRM_FORMAT_RGBA4444, DRM_FORMAT_RGB888, DRM_FORMAT_RGB565, + DRM_FORMAT_NV12, + DRM_FORMAT_NV16, + DRM_FORMAT_NV21, + DRM_FORMAT_NV61, DRM_FORMAT_UYVY, DRM_FORMAT_VYUY, DRM_FORMAT_XRGB8888, -- 2.19.1