From patchwork Tue Dec 4 14:22:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10712031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C99181057 for ; Tue, 4 Dec 2018 14:41:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8DA12BA86 for ; Tue, 4 Dec 2018 14:41:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4E072BAAF; Tue, 4 Dec 2018 14:41:25 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 614782BAFF for ; Tue, 4 Dec 2018 14:41:25 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=H3NU2Q3fJtaRMTR2vpzNRs53immgdmv6qw74iLjSUrk=; b=MBwbVXFaNwO+96 M/WTiUvbAvnBYiFVA1sZXEObjff2HHVaCeyFJHV5yPA2n8bZRwQzBh68ZTDcOkV6qTQvkU9mZ+z7M 3Jsub0g1NQzttbkjkvSMPregYeATLc4zPGnJ7G9N0Jlm8hICf7T20T9N8otJwKc+6vMwwE8ORa44v UIYm3vhIG8rBndSdCMOKu1JVuikyTOCPMK3kbKbHtN9S0j5JdoZi1PewmKldToNHhOXcaEl+8m5+1 aS7RB5DS10oa3qLv0LxuZf2EP2j95JqV3O9oYogKz7/S0fWfjwWC4l+FmbKBgp97kZUW1X7QhZ079 h6hZjwAhNJ1u4TDqK6Zw==; 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 1gUBt4-0005eN-TI; Tue, 04 Dec 2018 14:41:22 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUBbd-0007fg-3O for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 14:23:28 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id F1B3520731; Tue, 4 Dec 2018 15:23:09 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-79-44.w90-88.abo.wanadoo.fr [90.88.21.44]) by mail.bootlin.com (Postfix) with ESMTPSA id 03F9220A60; Tue, 4 Dec 2018 15:22:39 +0100 (CET) From: Paul Kocialkowski To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/21] drm/sun4i: frontend: Determine input format based on colorspace Date: Tue, 4 Dec 2018 15:22:02 +0100 Message-Id: <20181204142218.16284-6-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204142218.16284-1-paul.kocialkowski@bootlin.com> References: <20181204142218.16284-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_062322_012140_8F45E6B5 X-CRM114-Status: GOOD ( 14.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Maxime Ripard , Maarten Lankhorst , linux-sunxi@googlegroups.com, Paul Kocialkowski , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , Sean Paul Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Since all the RGB input formats have the same value for the DATA_FMT field of the INPUT_FMT register, we can group them when the format is known to be RGB. Here, we assume that a non-YUV format is RGB, because the hardware does not support any other colorspace than RGB and YUV. Pass the full DRM format info structure to check whether the format uses a YUV colorspace. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index c436fa97928f..d0eca4b8784d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -104,16 +104,16 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, } EXPORT_SYMBOL(sun4i_frontend_update_buffer); -static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) +static int +sun4i_frontend_drm_format_to_input_fmt(const struct drm_format_info *format, + u32 *val) { - switch (fmt) { - case DRM_FORMAT_XRGB8888: + if (!format->is_yuv) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB; - return 0; - - default: + else return -EINVAL; - } + + return 0; } static int @@ -190,8 +190,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, u32 in_fmt_val, in_mod_val, in_ps_val; int ret; - ret = sun4i_frontend_drm_format_to_input_fmt(format->format, - &in_fmt_val); + ret = sun4i_frontend_drm_format_to_input_fmt(format, &in_fmt_val); if (ret) { DRM_DEBUG_DRIVER("Invalid input format\n"); return ret;