From patchwork Fri Nov 23 09:24:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695467 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 89CA81709 for ; Fri, 23 Nov 2018 09:45:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 786402C2DE for ; Fri, 23 Nov 2018 09:45:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C47D2C34A; Fri, 23 Nov 2018 09:45:10 +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 0E0E42C2DE for ; Fri, 23 Nov 2018 09:45:10 +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=DZvFRop6ZbyWPpcQgppUj9+Y+DqvzX0ohT+IlARp3kU=; b=T46ve5BBax6RwY EDj0dG3xIocoqMQ5D96m1dnSoJrlkCEbFpuTG6i/vuDCZUVZs2VTd5AIH3sPxr2Or0wvE7Q4CjUGg 7X4ivb2zeTTOSGRzXNUxO28EGk2iUIW953MB/fX/+D2qjo7Gzu1gu+wFj1lR7JLBbGssTGdlGDyEy KCK7REsgNjDtNYTn6jtVNxDXezJCvUuPkf1aMOjEeH9FgHauusnxR504QeXkI4DSI3/OGV+G9zdXm Xoe9Os8N5+bnDvyvNc3BnabfuxqTdEzFkcqTqJcsJPsF0yV765T5LKlc/EohakoMS1bCjj6f2L7f4 I63Vtt9J72RSjGXVrKQQ==; 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 1gQ81M-0000g7-6C; Fri, 23 Nov 2018 09:45:08 +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 1gQ7je-0001mt-6n for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:26:53 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id E525B207AB; Fri, 23 Nov 2018 10:26:37 +0100 (CET) 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 95591207AB; Fri, 23 Nov 2018 10:26:27 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 01/43] drm/sun4i: Cleanup video/YUV source before enabling a layer Date: Fri, 23 Nov 2018 10:24:33 +0100 Message-Id: <20181123092515.2511-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012650_515444_D9E7C71F X-CRM114-Status: GOOD ( 11.16 ) 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 This adds a dedicated function for cleaning the video and YUV source channel layer enable bits. This function is called first on layer atomic update to make sure that there are no leftover bits from previous plane configuration that were not cleaned until now. It fixes issues when alternating between video and YUV planes, where both bits would be set eventually, leading to broken plane display. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 9 +++++++++ drivers/gpu/drm/sun4i/sun4i_backend.h | 2 ++ drivers/gpu/drm/sun4i/sun4i_layer.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index bf49c55b0f2c..67b4bb4f5365 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -395,6 +395,15 @@ int sun4i_backend_update_layer_zpos(struct sun4i_backend *backend, int layer, return 0; } +void sun4i_backend_cleanup_layer(struct sun4i_backend *backend, + int layer) +{ + regmap_update_bits(backend->engine.regs, + SUN4I_BACKEND_ATTCTL_REG0(layer), + SUN4I_BACKEND_ATTCTL_REG0_LAY_VDOEN | + SUN4I_BACKEND_ATTCTL_REG0_LAY_YUVEN, 0); +} + static bool sun4i_backend_plane_uses_scaler(struct drm_plane_state *state) { u16 src_h = state->src_h >> 16; diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.h b/drivers/gpu/drm/sun4i/sun4i_backend.h index e3d4c6035eb2..339dbff1cce4 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.h +++ b/drivers/gpu/drm/sun4i/sun4i_backend.h @@ -208,5 +208,7 @@ int sun4i_backend_update_layer_frontend(struct sun4i_backend *backend, int layer, uint32_t in_fmt); int sun4i_backend_update_layer_zpos(struct sun4i_backend *backend, int layer, struct drm_plane *plane); +void sun4i_backend_cleanup_layer(struct sun4i_backend *backend, + int layer); #endif /* _SUN4I_BACKEND_H_ */ diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 78f77af8805a..e0e37c2f1721 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -92,6 +92,8 @@ static void sun4i_backend_layer_atomic_update(struct drm_plane *plane, struct sun4i_backend *backend = layer->backend; struct sun4i_frontend *frontend = backend->frontend; + sun4i_backend_cleanup_layer(backend, layer->id); + if (layer_state->uses_frontend) { sun4i_frontend_init(frontend); sun4i_frontend_update_coord(frontend, plane); From patchwork Fri Nov 23 09:24:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695325 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 1A296175A for ; Fri, 23 Nov 2018 09:27:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 094FD2C3BB for ; Fri, 23 Nov 2018 09:27:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1BA72C3EC; Fri, 23 Nov 2018 09:27:34 +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 8914E2C3BB for ; Fri, 23 Nov 2018 09:27:34 +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=qCvfVvZv9ldFBvJ3/DKfJLSVZRudyFBXXVwxGhsCwsk=; b=KISuk377pn5I4n qImP9/Dz8flZhLdXCP2Y6XdxReL3Z6IalWL1bi9o3pUbLInHsomhizE+LMsa/dsu08eEAe4jmGv22 A5vW3IHY/yTH+Vy5jFIXc3RmT6awkum1maxAnp88N32lpznle7WWv2RF6rENNWjbJPpP0RUXJ3O7T YfsSZbN8I6f2BQfk07zL+N40w7vwZdSTJeMUeRCMv3LP0uPuCRWLjJwGdLemUS5t5WsTVF+x4d2dN bdbdi+jlG2JvWR5lBoNxhxEPDa5nZs2aq6bJ68O8utmtTFEZNGKZMNlqWePJWcQHzxPQc2k6v5kJX MhhXqF5NsJmEG5QTcaig==; 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 1gQ7kF-0002ZL-Op; Fri, 23 Nov 2018 09:27:27 +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 1gQ7je-0001mu-6f for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:26:53 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 34AA820F84; Fri, 23 Nov 2018 10:26:38 +0100 (CET) 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 D41F9207B0; Fri, 23 Nov 2018 10:26:27 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 02/43] drm/sun4i: frontend: Replace ARGB with XRGB as supported format Date: Fri, 23 Nov 2018 10:24:34 +0100 Message-Id: <20181123092515.2511-3-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012650_377360_D92162B7 X-CRM114-Status: GOOD ( 14.92 ) 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 The frontend documentation (for the A33) mentions that ARGB is supported as output, but with the alpha component always set to 0xff. In practice, this means that the alpha component cannot be preserved when going through the frontend. Since the information is lost, ARGB is not properly supported. As a result, expose the matching format supported by the frontend (both for input and output) as XRGB instead of ARGB. Since ARGB was the selected format for connecting the frontend to the backend, change it to XRGB to reflect this as well. The A31 and A80 SoCs apparently have a bit to enable proper alpha, but this is not supported at this point (see the comment already in the code). Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 3 +-- drivers/gpu/drm/sun4i/sun4i_layer.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index ddf6cfa6dd23..3ea925584891 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -107,7 +107,7 @@ EXPORT_SYMBOL(sun4i_frontend_update_buffer); static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) { switch (fmt) { - case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_XRGB8888: *val = 5; return 0; @@ -120,7 +120,6 @@ static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - case DRM_FORMAT_ARGB8888: *val = 2; return 0; diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index e0e37c2f1721..50bb16566f03 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -99,9 +99,9 @@ static void sun4i_backend_layer_atomic_update(struct drm_plane *plane, sun4i_frontend_update_coord(frontend, plane); sun4i_frontend_update_buffer(frontend, plane); sun4i_frontend_update_formats(frontend, plane, - DRM_FORMAT_ARGB8888); + DRM_FORMAT_XRGB8888); sun4i_backend_update_layer_frontend(backend, layer->id, - DRM_FORMAT_ARGB8888); + DRM_FORMAT_XRGB8888); sun4i_frontend_enable(frontend); } else { sun4i_backend_update_layer_formats(backend, layer->id, plane); From patchwork Fri Nov 23 09:24:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695287 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 90C8A1709 for ; Fri, 23 Nov 2018 09:26:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C0B22C3BB for ; Fri, 23 Nov 2018 09:26:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CF0A2C3EC; Fri, 23 Nov 2018 09:26:56 +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 27B212C3BB for ; Fri, 23 Nov 2018 09:26:56 +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=6LoiboapsgtUWBgLDiulWxwLxvdUdJXPlBo2gIoCng0=; b=dLGHm4QglaJtAU +bfEjS6YW9DpYF+4PJiGsF6dJWBS+RVuCu6G/2FfmgTbbM0b6Q3DHY0OaBQVQL+mzetW2DDNlGqi0 7CtkVIfo8ejjDveePWkZ7LXtslxdABrbimFUA1RcbROo1fmaX0ymNnxKEBkVEtUzjorHbUUtS2tgJ T8h9P97JcGfn0p0zcUZ2Hz2ArtPKhHsPo6rsYPKM0VGxZ09QXI0ayMrIcSPnVYwEGfOtdlqFT3G6p I8CB2qlcRPThJRqyVe9Y50OcWs4INrqUYZqNlLiNy4/Rx0HVsAcfOISPfXZBvK3/TVPMmKoG3Xj1J LWMbINMZsWEcvxSn5fzA==; 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 1gQ7jh-0001qC-Gn; Fri, 23 Nov 2018 09:26:53 +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 1gQ7je-0001mv-6S for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:26:51 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 6ECAD20F87; Fri, 23 Nov 2018 10:26:38 +0100 (CET) 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 1FFB9207BB; Fri, 23 Nov 2018 10:26:28 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 03/43] drm/sun4i: Add TODO comment about supporting scaling with the backend Date: Fri, 23 Nov 2018 10:24:35 +0100 Message-Id: <20181123092515.2511-4-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012650_374426_9D85A172 X-CRM114-Status: GOOD ( 12.03 ) 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 The backend allows integer-only scaling but can handle alpha components, unlike the frontend. It could be useful to add support for this eventually, so add a short TODO comment describing the situation. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 67b4bb4f5365..c3444246755b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -426,6 +426,11 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state) if (IS_ERR(backend->frontend)) return false; + /* + * TODO: The backend alone allows 2x and 4x integer scaling, including + * support for an alpha component (which the frontend doesn't support). + * Use the backend directly instead of the frontend in this case. + */ return sun4i_backend_plane_uses_scaler(state); } From patchwork Fri Nov 23 09:24:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695299 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 B1C71175A for ; Fri, 23 Nov 2018 09:27:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0AA32C3D8 for ; Fri, 23 Nov 2018 09:27:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94FCE2C47B; Fri, 23 Nov 2018 09:27:08 +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 3387B2C3D8 for ; Fri, 23 Nov 2018 09:27:08 +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=5bnkUw6E7cS/PU1zKgS+gNmmgUD3U5n83kEGKD4qKz0=; b=tXY4d6HXnswfaH 7fXVxAPlvOEa/XzOHCNrYyOP9vjxG+xjvaJJ+HXQ54QkMe4oCtmbRRwAygNgXrLe/8QYtHZCTv2/w 0FVcEV+cRaSDyMhfgJpKHbY2lmiWfBikoRfXk3TRTRN+tcugWF4Q/OIpq//6zlNnVduHxGWjJ/Mpp twr2V32uYTySq+08e5FdyyH3HCu6BTWz5fCtZny2/XPPU/bNPW0KIJTLWVwuOmD0Vo2wEZ5tHYn6h lkirpNyzf7nB4p/gcqEBx4FwnEEHdTkRqHKkv/94TxOJl7IzdTsu/N14wQD4lz6dd1H6EUNThlzWC dA2UhxgK0flSD4A5bbcg==; 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 1gQ7jo-0001zO-Ah; Fri, 23 Nov 2018 09:27:00 +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 1gQ7je-0001mw-6R for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:26:51 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id B70BF20F8D; Fri, 23 Nov 2018 10:26:38 +0100 (CET) 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 602EE20D29; Fri, 23 Nov 2018 10:26:28 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 04/43] drm/sun4i: backend: Add a helper and a list for supported formats Date: Fri, 23 Nov 2018 10:24:36 +0100 Message-Id: <20181123092515.2511-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012650_366711_C06E3A9C X-CRM114-Status: GOOD ( 13.53 ) 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 In order to check whether the backend supports a specific format, an explicit list and a related helper are introduced. The prototype of this helper is added to the header so that it can be called from sun4i_layer later (when introducing tiled mode support). Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/sun4i/sun4i_backend.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index c3444246755b..7dd24eb03f89 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -155,6 +155,33 @@ static int sun4i_backend_drm_format_to_layer(u32 format, u32 *mode) return 0; } +static const uint32_t sun4i_backend_formats[] = { + DRM_FORMAT_ARGB1555, + DRM_FORMAT_ARGB4444, + DRM_FORMAT_ARGB8888, + DRM_FORMAT_BGRX8888, + DRM_FORMAT_RGB565, + DRM_FORMAT_RGB888, + DRM_FORMAT_RGBA4444, + DRM_FORMAT_RGBA5551, + DRM_FORMAT_UYVY, + DRM_FORMAT_VYUY, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_YUYV, + DRM_FORMAT_YVYU, +}; + +bool sun4i_backend_format_is_supported(uint32_t fmt) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(sun4i_backend_formats); i++) + if (sun4i_backend_formats[i] == fmt) + return true; + + return false; +} + int sun4i_backend_update_layer_coord(struct sun4i_backend *backend, int layer, struct drm_plane *plane) { diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.h b/drivers/gpu/drm/sun4i/sun4i_backend.h index 339dbff1cce4..93db3af675b3 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.h +++ b/drivers/gpu/drm/sun4i/sun4i_backend.h @@ -198,6 +198,7 @@ engine_to_sun4i_backend(struct sunxi_engine *engine) void sun4i_backend_layer_enable(struct sun4i_backend *backend, int layer, bool enable); +bool sun4i_backend_format_is_supported(uint32_t fmt); int sun4i_backend_update_layer_coord(struct sun4i_backend *backend, int layer, struct drm_plane *plane); int sun4i_backend_update_layer_formats(struct sun4i_backend *backend, From patchwork Fri Nov 23 09:24:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695371 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 0C05617FE for ; Fri, 23 Nov 2018 09:28:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00812C3EC for ; Fri, 23 Nov 2018 09:28:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3E652C471; Fri, 23 Nov 2018 09:28:26 +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 6C0692C419 for ; Fri, 23 Nov 2018 09:28:26 +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=ZApDENDQIltjs6VppNf3uFplHH3rbSsoTMS1qdz7DYE=; b=DELChLeLxEnAjw xqwz6Uxv1/ph7NDs7OhHUbTiRZ9fhlIYJcNo2UPB06x5G37kDKhqNd7HxDwhmIbmGjkcUd8h05Jbj i5AOAJExGqpXjo7vJrQaUGwpwIQoGHxdMnrSFrmtJHjKAVfm1Vi4l5ld/X6EPF4bxikJ15AT8AG3Q xr52JcgmiuL1Ks/VT7k06jHb7HJyImMe2evvYp1ks+CNk1tMNni78IF8g6o+2oXwx+xAuH2RYmUWP ZEccAfEIx6Zin5N/FqmCDPU5EphfZxhOmO5HSGE4xjcACXbR0AM5AfyFQ/o6zUrTINiF32Ywwe3Sz /FSixmtt39RbrxDbmViA==; 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 1gQ7lA-0003qJ-HB; Fri, 23 Nov 2018 09:28:24 +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 1gQ7jq-0001q1-AV for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:12 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id CA3A520DBE; Fri, 23 Nov 2018 10:26:47 +0100 (CET) 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 A154720DBE; Fri, 23 Nov 2018 10:26:28 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 05/43] drm/sun4i: frontend: Add a helper and a list for supported formats Date: Fri, 23 Nov 2018 10:24:37 +0100 Message-Id: <20181123092515.2511-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_095543_FD356161 X-CRM114-Status: GOOD ( 13.63 ) 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 In order to check whether the frontend supports a specific format, an explicit list and a related helper are introduced. Just like in the backend, the prototype of the helper is added to the frontend header so that it can be used later on. The helper is also exported because it will be used outside of the frontend module. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 16 ++++++++++++++++ drivers/gpu/drm/sun4i/sun4i_frontend.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 3ea925584891..0f7f8c7b3402 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -128,6 +128,22 @@ static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) } } +static const uint32_t sun4i_frontend_formats[] = { + DRM_FORMAT_XRGB8888, +}; + +bool sun4i_frontend_format_is_supported(uint32_t fmt) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(sun4i_frontend_formats); i++) + if (sun4i_frontend_formats[i] == fmt) + return true; + + return false; +} +EXPORT_SYMBOL(sun4i_frontend_format_is_supported); + int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, struct drm_plane *plane, uint32_t out_fmt) { diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 02661ce81f3e..a9cb908ced16 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -95,5 +95,6 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, struct drm_plane *plane); int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, struct drm_plane *plane, uint32_t out_fmt); +bool sun4i_frontend_format_is_supported(uint32_t fmt); #endif /* _SUN4I_FRONTEND_H_ */ From patchwork Fri Nov 23 09:24:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695395 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 9C708175A for ; Fri, 23 Nov 2018 09:29:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BEC72C2AB for ; Fri, 23 Nov 2018 09:29:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CD322C2B9; Fri, 23 Nov 2018 09:29:30 +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 303352C2AB for ; Fri, 23 Nov 2018 09:29:30 +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=njIr9NwM29jLJ8hxA+HWkqOhmJLh9yHpuVQm47Gx+Og=; b=cxnGXUpYB3ZcWL 0BJGdC1vAlAFaD9D8vo0W3n1E2bI2GSX/S2WjunNZDLpO0e8ZO0pGYv93gqI7TZhOInDWHXOQNDli mlII2zPWh4pSfgvdLfXbcmTrv4//dr6pV9Nda+OFiG+eUJ8G/TZf/oRsWY6zCW4qBduX+Wh4y/Im6 4lt6SR8wOAKKm0L/WTLULFdBgA4Xwx4jt7lB1+McXx9mKtCPIJuxg9xjI7ZXzftG5E1E7yGLfulTo HTymf58ticnzQKzSEg5Kc6w2+hPu5ix3dOOfAL0+ProXjnhiE5hu0w5KSy8X+ysyHWfDq3lrtdqBc gZuBsfelEMca1fV2+TRA==; 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 1gQ7m2-00059I-PQ; Fri, 23 Nov 2018 09:29:18 +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 1gQ7jq-0001q0-AZ for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:14 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id C8825215DD; Fri, 23 Nov 2018 10:26:47 +0100 (CET) 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 E22B620DBF; Fri, 23 Nov 2018 10:26:28 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 06/43] drm/sun4i: backend: Refine the logic behind using the frontend Date: Fri, 23 Nov 2018 10:24:38 +0100 Message-Id: <20181123092515.2511-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_253182_FC1427A5 X-CRM114-Status: GOOD ( 15.09 ) 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 Checking that scaling is in use is not sufficient as a condition to decide to use the frontend. Since not all layer formats are supported by the frontend, we need to check for that support first. Then, the frontend must only be enabled if the backend doesn't support the format or that scaling is required. Signed-off-by:Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 7dd24eb03f89..735fea7ead0b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -449,16 +449,32 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state) { struct sun4i_layer *layer = plane_to_sun4i_layer(state->plane); struct sun4i_backend *backend = layer->backend; + uint32_t format = state->fb->format->format; if (IS_ERR(backend->frontend)) return false; + if (!sun4i_frontend_format_is_supported(format)) + return false; + + if (!sun4i_backend_format_is_supported(format)) + return true; + /* * TODO: The backend alone allows 2x and 4x integer scaling, including * support for an alpha component (which the frontend doesn't support). - * Use the backend directly instead of the frontend in this case. + * Use the backend directly instead of the frontend in this case, with + * another test to return false. + */ + + if (sun4i_backend_plane_uses_scaler(state)) + return true; + + /* + * Here the format is supported by both the frontend and the backend + * and no frontend scaling is required, so use the backend directly. */ - return sun4i_backend_plane_uses_scaler(state); + return false; } static void sun4i_backend_atomic_begin(struct sunxi_engine *engine, From patchwork Fri Nov 23 09:24:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695385 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 B70861709 for ; Fri, 23 Nov 2018 09:28:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4CD02C06D for ; Fri, 23 Nov 2018 09:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 982AF2C078; Fri, 23 Nov 2018 09:28:41 +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 325F02C06A for ; Fri, 23 Nov 2018 09:28:41 +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=crU66g7XCLhSk3AgxtNZ9tCzJklOgFX7yxmgRW9EcEg=; b=kYWYMukbLM26pT NanmKYu/RBDxTw0or/NZxvBstw1VCRMJzVGR6Vgg2dsO05+fLS5vLsBKoFXdJiaNKfhGsyefpK0Af 7/ImSZDclfTZTewQk20U/jyuml/t1gGveLSZpdzPVmbFdVtirgpBOmPDIV+8aBWhFNqvIWiKp3scx M42R5icq3k/5PfTd96ttRzZ7h8e4cohTGw2yW8N2kaf65RJduHOOOxQw9YBvSKTWP6qr1Zwfb7QZ5 4x6Cco/u5whPJ1yGzNfEWSKJHhXh1NDEKyum20I4yxkBbtWN0ysK7izJNWFVkcpx2GVS+f0owdhn0 FA8g+FGE2F0Imx/20FQQ==; 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 1gQ7lL-00046L-BF; Fri, 23 Nov 2018 09:28:35 +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 1gQ7jq-0001q2-AX for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:12 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 0BE35213F9; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 2E57420DC1; Fri, 23 Nov 2018 10:26:29 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 07/43] drm/sun4i: backend: Use a specific function to check if a plane is supported Date: Fri, 23 Nov 2018 10:24:39 +0100 Message-Id: <20181123092515.2511-8-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_147211_9F7F90A6 X-CRM114-Status: GOOD ( 15.00 ) 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 Before this patch, it is assumed that a plane is supported either through the frontend or through the backend alone. However, the DRM interface does not allow finely reporting our hardware capabilities and there are cases where neither are support. In particular, some plane formats are supported by the backend and not the frontend, so they can only be supported without scaling. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 735fea7ead0b..52caf561da0e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -477,6 +477,23 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state) return false; } +static bool sun4i_backend_plane_is_supported(struct drm_plane_state *state, + bool *uses_frontend) +{ + if (sun4i_backend_plane_uses_frontend(state)) { + *uses_frontend = true; + return true; + } + + *uses_frontend = false; + + /* Scaling is not supported without the frontend. */ + if (sun4i_backend_plane_uses_scaler(state)) + return false; + + return true; +} + static void sun4i_backend_atomic_begin(struct sunxi_engine *engine, struct drm_crtc_state *old_state) { @@ -517,14 +534,14 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, struct drm_framebuffer *fb = plane_state->fb; struct drm_format_name_buf format_name; - if (sun4i_backend_plane_uses_frontend(plane_state)) { + if (!sun4i_backend_plane_is_supported(plane_state, + &layer_state->uses_frontend)) + return -EINVAL; + + if (layer_state->uses_frontend) { DRM_DEBUG_DRIVER("Using the frontend for plane %d\n", plane->index); - - layer_state->uses_frontend = true; num_frontend_planes++; - } else { - layer_state->uses_frontend = false; } DRM_DEBUG_DRIVER("Plane FB format is %s\n", From patchwork Fri Nov 23 09:24:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695389 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 5227D1709 for ; Fri, 23 Nov 2018 09:29:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EB012C2B9 for ; Fri, 23 Nov 2018 09:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31A312C2B3; Fri, 23 Nov 2018 09:29:05 +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 C6F862C2AB for ; Fri, 23 Nov 2018 09:29:04 +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=guLMNWZZRSG+FzY3NTSKWD/vbbuMDHf/MMAyNGg5mvU=; b=LbP/MoyJfIneq1 1EKAbE5NLPkjEwoTQDJe5h404a+Wo54uY0PvKy/aZSjeKv1vsXANpVgmyM5BS2dQahbSSZkqR27Ov qkGnH2rrZCNtEYjgXM7VqLkU+Dunfl22o7w9uv+9g03feBUa0M/UIyJja2id4ngM4md1h5k3VnoVR XlSKT5dU9i0HjZ2AQMTGznmfzCLi+LwQyYjM6ZIOcL0Bx9QX9x9JaKlUj3YO1SbBX89K5RuWDUCLN I+yTj1H27hfaUE470oCzjMbpGSlZm9wHfHK0T+8oHSHXqTLwCSXHFUkGcVMO6evyuWNZwi1FaPD9a X+cSn4c/p6mnaGZxQ3LA==; 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 1gQ7lh-0004ey-64; Fri, 23 Nov 2018 09:28:57 +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 1gQ7jq-0001q3-Aa for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:12 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 12B1B20DC1; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 6E7BB20DC4; Fri, 23 Nov 2018 10:26:29 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 08/43] drm/fourcc: Add helper to check if a format uses a YUV colorspace Date: Fri, 23 Nov 2018 10:24:40 +0100 Message-Id: <20181123092515.2511-9-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_134182_EC9E2FB0 X-CRM114-Status: GOOD ( 12.86 ) 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 This adds a new helper to check whether the format described by its fourcc code uses a YUV colorspace, by returning the is_yuv entry for the DRM info entry matching that format. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- drivers/gpu/drm/drm_fourcc.c | 19 +++++++++++++++++++ include/drm/drm_fourcc.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index f523948c82b1..f85650c3463a 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -413,6 +413,25 @@ int drm_format_plane_height(int height, uint32_t format, int plane) } EXPORT_SYMBOL(drm_format_plane_height); +/** + * drm_format_is_yuv - check that the format uses a YUV colorspace + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format uses a YUV colorspace. + */ +bool drm_format_is_yuv(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return info->is_yuv; +} +EXPORT_SYMBOL(drm_format_is_yuv); + /** * drm_format_info_block_width - width in pixels of block. * @info: pixel format info diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index bcb389f04618..569b70483505 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -157,6 +157,7 @@ int drm_format_horz_chroma_subsampling(uint32_t format); int drm_format_vert_chroma_subsampling(uint32_t format); int drm_format_plane_width(int width, uint32_t format, int plane); int drm_format_plane_height(int height, uint32_t format, int plane); +bool drm_format_is_yuv(uint32_t format); unsigned int drm_format_info_block_width(const struct drm_format_info *info, int plane); unsigned int drm_format_info_block_height(const struct drm_format_info *info, From patchwork Fri Nov 23 09:24:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695341 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 6A28B1709 for ; Fri, 23 Nov 2018 09:28:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 585472C3BB for ; Fri, 23 Nov 2018 09:28:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BF8F2C3EC; Fri, 23 Nov 2018 09:28:05 +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 ED4402C3BB for ; Fri, 23 Nov 2018 09:28:04 +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=bCHp1qPG3Z54PLR1kYhQNQG9SWs3Gn3IpgEuJTcJbH0=; b=aXZMdDVP9Msict jsex23XKD8mtL3I3QfdPmev7eoWR5qtVHrnSbbXNjL03j965vILv09aI5tM85ZLOG3N7R582syzJq oywRI9uJcxsV+fYql6zp7xFeL/UogNA07IsE/v/qF61Lo2uQlJJ/3MPvWx/jLV7+4Qsk7Z3D5t5tG SQVt/0zXtMoA/6+d4IbVnYGEF7mzfjdFoSWTAfY3/kLnKzNWbS4NV3TnRUjzE4aGFUy+8YGpPqoM7 dPXz+YVAugFfEPobUD2zHfy7x7nsfteF/Crx7qv1rBZJnQpK3Bh3s9XSNV7rZ7p29xPmXI0eMaGPU cT5UjwP9qzo/ctvvGj+A==; 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 1gQ7ko-0003LO-3o; Fri, 23 Nov 2018 09:28:02 +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 1gQ7jq-0001qL-AT for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:07 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 4CFB920DC4; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 AF7F920DCB; Fri, 23 Nov 2018 10:26:29 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 09/43] drm/fourcc: Add format info helpers for checking YUV planes disposition Date: Fri, 23 Nov 2018 10:24:41 +0100 Message-Id: <20181123092515.2511-10-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012702_982758_82DE7A03 X-CRM114-Status: GOOD ( 10.90 ) 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 It is often useful to check whether the DRM format info retrieved from the DRM framebuffer matches a specific YUV planes disposition. This introduces helpers to quickly check that a provided format info matches a YUV format with a specific disposition, in commonly-used terminology. The intent of providing helpers taking the format info instead of the fourcc alone is to avoid the overhead of iterating through all formats when the whole format info structure is available. As a result, these helpers are very simple so they are made inline. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- include/drm/drm_fourcc.h | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 569b70483505..f43d5ba412fb 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -143,6 +143,48 @@ struct drm_format_name_buf { char str[32]; }; +/** + * drm_format_info_is_yuv_packed - check that the format info matches a YUV + * format with data laid in a single plane + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a packed YUV format. + */ +static inline bool +drm_format_info_is_yuv_packed(const struct drm_format_info *info) +{ + return info->is_yuv && info->num_planes == 1; +} + +/** + * drm_format_info_is_yuv_semiplanar - check that the format info matches a YUV + * format with data laid in two planes (luminance and chrominance) + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a semiplanar YUV format. + */ +static inline bool +drm_format_info_is_yuv_semiplanar(const struct drm_format_info *info) +{ + return info->is_yuv && info->num_planes == 2; +} + +/** + * drm_format_info_is_yuv_planar - check that the format info matches a YUV + * format with data laid in three planes (one for each YUV component) + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a planar YUV format. + */ +static inline bool +drm_format_info_is_yuv_planar(const struct drm_format_info *info) +{ + return info->is_yuv && info->num_planes == 3; +} + const struct drm_format_info *__drm_format_info(u32 format); const struct drm_format_info *drm_format_info(u32 format); const struct drm_format_info * From patchwork Fri Nov 23 09:24:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695387 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 EAB2D1709 for ; Fri, 23 Nov 2018 09:28:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA1812C078 for ; Fri, 23 Nov 2018 09:28:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA232C085; Fri, 23 Nov 2018 09:28:47 +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 604192C078 for ; Fri, 23 Nov 2018 09:28:47 +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=yUwRU4ZHRwAZZeYNIDjxP24xf8Kyj+uhNXHvr1Tqdc8=; b=X7H6QcpVkgXinM j9D2lnIaapRl2mvYiicu0jTssIRlnQ3nqPLYn5MvvUAOrDWZB/6IPlzCV5K6yLc9bb8HXlxbXbm2a NWSTSWr+kTdfBE/rVFr6CwDjIRQiZNgayVv9Tb0oRdmMTgZNQOvEQU3jSlZuLTsgzBcm7HpWMF2UK x1E4N41ntyYxfnuMEd4wrJOCALpf4qea6KavU2yor4IxiZen9FdpRElAR3CobZMzcqWZD9ktsTeZ9 kwSRUGYWNVGYFizT3AcD6+z+4TqxMoVhPcG5dSqJtMEFibulGFq6GPZYM6C8LAz83Zhrgw+ZD6FVm zm2W0NOLLb536M/d05YQ==; 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 1gQ7lV-0004L0-Pd; Fri, 23 Nov 2018 09:28:45 +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 1gQ7jq-0001qM-Ad for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:12 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 587DF20DCB; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 F166D20DD1; Fri, 23 Nov 2018 10:26:29 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 10/43] drm/fourcc: Add format helpers for checking YUV planes disposition Date: Fri, 23 Nov 2018 10:24:42 +0100 Message-Id: <20181123092515.2511-11-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_242161_C15E0A51 X-CRM114-Status: GOOD ( 11.93 ) 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 This introduces new format helpers that use the previously-introduced format info helpers for checking YUV planes disposition. Only the format fourcc is required by these helpers and the formats are iterated from the list. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- drivers/gpu/drm/drm_fourcc.c | 60 ++++++++++++++++++++++++++++++++++++ include/drm/drm_fourcc.h | 3 ++ 2 files changed, 63 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index f85650c3463a..b56e773f9f63 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -432,6 +432,66 @@ bool drm_format_is_yuv(uint32_t format) } EXPORT_SYMBOL(drm_format_is_yuv); +/** + * drm_format_is_yuv_packed - check that the format is a YUV format with data + * laid in a single plane + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a packed YUV format + */ +bool drm_format_is_yuv_packed(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_packed(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_packed); + +/** + * drm_format_is_yuv_semiplanar - check that the format is a YUV format with + * data laid in two planes (luminance and chrominance) + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a semiplanar YUV format + */ +bool drm_format_is_yuv_semiplanar(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_semiplanar(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_semiplanar); + +/** + * drm_format_is_yuv_planar - check that the format is a YUV format with data + * laid in three planes (one for each YUV component) + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a planar YUV format + */ +bool drm_format_is_yuv_planar(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_planar(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_planar); + /** * drm_format_info_block_width - width in pixels of block. * @info: pixel format info diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index f43d5ba412fb..b652b711df1a 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -200,6 +200,9 @@ int drm_format_vert_chroma_subsampling(uint32_t format); int drm_format_plane_width(int width, uint32_t format, int plane); int drm_format_plane_height(int height, uint32_t format, int plane); bool drm_format_is_yuv(uint32_t format); +bool drm_format_is_yuv_packed(uint32_t format); +bool drm_format_is_yuv_semiplanar(uint32_t format); +bool drm_format_is_yuv_planar(uint32_t format); unsigned int drm_format_info_block_width(const struct drm_format_info *info, int plane); unsigned int drm_format_info_block_height(const struct drm_format_info *info, From patchwork Fri Nov 23 09:24:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695393 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 D9814175A for ; Fri, 23 Nov 2018 09:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F6F2C28C for ; Fri, 23 Nov 2018 09:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC6D82C2AB; Fri, 23 Nov 2018 09:29:10 +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 5511A2C28C for ; Fri, 23 Nov 2018 09:29:10 +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=OCQG/rRFMQ5m1/gnBL1nZvhvKZ7EhY8A12wjXxrlnVw=; b=q/g38EbyAeLjdo BTBnIXrqf2wztrq2kFpjdVflb8JFPujId2v/J4/vk4uoWhcL4k6dRXOk+tfh44/jbc8Fy/7SG2TU7 yvEAW8cVojmv7YbIBVLVCpjFyJHUeg4QPz7Nl26SGAMwYbbjsTb1rOtyHmga6//gV0gnXRozhDMmr Da6ngJ73K78nwhBMpOG9D5hZYJhBFzac2lK+qav0+qpvm7/cN3zOaU8F+aaQdoW75PWRdLijjen7S ee2nPu8Y/3QihbBxauA02XogJECTjblwvC1g7eZtGmOsQ0IeFJEBYxjbvnD91NFBoZ65coQZehXg0 MuWXvpXS2WnCPNfQJXuw==; 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 1gQ7lr-0004uT-RO; Fri, 23 Nov 2018 09:29:07 +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 1gQ7jq-0001qN-AW for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:14 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 889E620DD1; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 3DDED20DD6; Fri, 23 Nov 2018 10:26:30 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 11/43] drm/fourcc: Add format info helpers for checking YUV sub-sampling Date: Fri, 23 Nov 2018 10:24:43 +0100 Message-Id: <20181123092515.2511-12-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_411441_D612354E X-CRM114-Status: UNSURE ( 9.92 ) X-CRM114-Notice: Please train this message. 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 Display engine drivers often need to distinguish between different types of YUV sub-sampling. This introduces helpers to check for common sub-sampling ratios in their commonly-used denomination from the DRM format info. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- include/drm/drm_fourcc.h | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index b652b711df1a..d170b7b323f7 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -185,6 +185,81 @@ drm_format_info_is_yuv_planar(const struct drm_format_info *info) return info->is_yuv && info->num_planes == 3; } +/** + * drm_format_info_is_yuv_sampling_410 - check that the format info matches a + * YUV format with 4:1:0 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:1:0 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_410(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 4 && info->vsub == 4; +} + +/** + * drm_format_info_is_yuv_sampling_411 - check that the format info matches a + * YUV format with 4:1:1 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:1:1 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_411(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 4 && info->vsub == 1; +} + +/** + * drm_format_info_is_yuv_sampling_420 - check that the format info matches a + * YUV format with 4:2:0 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:2:0 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_420(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 2 && info->vsub == 2; +} + +/** + * drm_format_info_is_yuv_sampling_422 - check that the format info matches a + * YUV format with 4:2:2 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:2:2 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_422(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 2 && info->vsub == 1; +} + +/** + * drm_format_info_is_yuv_sampling_444 - check that the format info matches a + * YUV format with 4:4:4 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:4:4 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_444(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 1 && info->vsub == 1; +} + const struct drm_format_info *__drm_format_info(u32 format); const struct drm_format_info *drm_format_info(u32 format); const struct drm_format_info * From patchwork Fri Nov 23 09:24:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695469 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 C8E1A5A4 for ; Fri, 23 Nov 2018 09:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B79412C2DE for ; Fri, 23 Nov 2018 09:45:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABF602C34A; Fri, 23 Nov 2018 09:45:19 +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 480452C2DE for ; Fri, 23 Nov 2018 09:45:19 +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=Ab1aj1OInv/yjiDlls3r18cGKYECMRMvOKnsmuAF5BI=; b=KVSpCtLYNb0+yr 2G9ywRgVJX0rl/Q9EAH4ccmdfwXBcI+YqwozuLKk+ImM6o5UXKWsrLNd2dxBfuJV884Ldzyd9D9M6 pTDSPmgAXgndr6+503viIFlFyY8yObhkJz0VhbW/JIyIdIxbMtkg4MGhGbxGbikzrKBCtciEgnGGt RJ0IKWlt50jqqiAoTLQWlU1jxtAGUkPj2Pc08cOs/0YyL1D1d/doab7CVgvtto8xFOp66QBkz6sTR oU4wDICffJPSa1+ymvRPT6FOnYb46DGJqxNocD0UxOc/JNaJ2Mb+82wu3zJpXbv0oK8htIMD2aO// dB0l76JvdzyedwPvvV+A==; 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 1gQ81M-0000n4-WA; Fri, 23 Nov 2018 09:45:09 +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 1gQ7jq-0001qO-Ac for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:19 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 90BD920DD6; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 7FA3420DD7; Fri, 23 Nov 2018 10:26:30 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 12/43] drm/fourcc: Add format helpers for checking YUV sub-sampling Date: Fri, 23 Nov 2018 10:24:44 +0100 Message-Id: <20181123092515.2511-13-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_378185_9CA7DAE1 X-CRM114-Status: GOOD ( 11.39 ) 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 This introduces new format helpers that use the previously-introduced format info helpers for checking YUV sub-sampling. Only the format fourcc is required by these helpers and the formats are iterated from the list. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/drm_fourcc.c | 105 +++++++++++++++++++++++++++++++++++ include/drm/drm_fourcc.h | 5 ++ 2 files changed, 110 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index b56e773f9f63..6d395c586ad5 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -492,6 +492,111 @@ bool drm_format_is_yuv_planar(uint32_t format) } EXPORT_SYMBOL(drm_format_is_yuv_planar); +/** + * drm_format_is_yuv_sampling_410 - check that the format is a YUV format with + * 4:1:0 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:1:0 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_410(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_410(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_410); + +/** + * drm_format_is_yuv_sampling_411 - check that the format is a YUV format with + * 4:1:1 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:1:1 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_411(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_411(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_411); + +/** + * drm_format_is_yuv_sampling_420 - check that the format is a YUV format with + * 4:2:0 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:2:0 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_420(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_420(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_420); + +/** + * drm_format_is_yuv_sampling_422 - check that the format is a YUV format with + * 4:2:2 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:2:2 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_422(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_422(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_422); + +/** + * drm_format_is_yuv_sampling_444 - check that the format is a YUV format with + * 4:4:4 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:4:4 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_444(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_444(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_444); + /** * drm_format_info_block_width - width in pixels of block. * @info: pixel format info diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index d170b7b323f7..cf082d8b6ad4 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -278,6 +278,11 @@ bool drm_format_is_yuv(uint32_t format); bool drm_format_is_yuv_packed(uint32_t format); bool drm_format_is_yuv_semiplanar(uint32_t format); bool drm_format_is_yuv_planar(uint32_t format); +bool drm_format_is_yuv_sampling_410(uint32_t format); +bool drm_format_is_yuv_sampling_411(uint32_t format); +bool drm_format_is_yuv_sampling_420(uint32_t format); +bool drm_format_is_yuv_sampling_422(uint32_t format); +bool drm_format_is_yuv_sampling_444(uint32_t format); unsigned int drm_format_info_block_width(const struct drm_format_info *info, int plane); unsigned int drm_format_info_block_height(const struct drm_format_info *info, From patchwork Fri Nov 23 09:24:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695339 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 B645A175A for ; Fri, 23 Nov 2018 09:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A39E92C3BB for ; Fri, 23 Nov 2018 09:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97A382C3EC; Fri, 23 Nov 2018 09:28:04 +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 535972C3BB for ; Fri, 23 Nov 2018 09:28:04 +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=RC44fKvHOLRXynikrZu5s1EZbZiO/IVwhmnYzgmZbM0=; b=Xuf+IGaavTXUxw c3GjX+/xFnCCGDRY0Xy+oo+/eSBwW1aB53ckg39UiDo1UatY85iUh3HDOt1Zlcy3S2D+FcGEzH/7s TPPiQ9bqf2wtWVlj+u7m4C/HPNgR2ZKyrTpsud61nx+cP7Q4U4FXZRHNfurf8bgcQDpZ1MfgA7a8c jacP/Qavu1CrJEHb95/eKtMVqvhHFCLSZw53yMPOx726psK98wHEm2qxi0vQNPoTgARDfbz/ni6gN w4ovjT4YRhgpa/TLLNUKFzBwitnZjdbSUpBzXW9BlnpQ2Ku3U8s8es2XjmGdtsB4HHkCdgn2XrMUD DBliueJn0JIo3JovB6AQ==; 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 1gQ7kd-00036V-EZ; Fri, 23 Nov 2018 09:27:51 +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 1gQ7jq-0001qd-Ab for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:06 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id CF99E20DD7; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 CCC9420DD8; Fri, 23 Nov 2018 10:26:30 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 13/43] drm/sun4i: backend: Use explicit fourcc helpers for packed YUV422 check Date: Fri, 23 Nov 2018 10:24:45 +0100 Message-Id: <20181123092515.2511-14-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012702_977220_D38795BC X-CRM114-Status: GOOD ( 12.43 ) 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 Checking for the number of planes is not sufficient to en ensure that the format is a packed YUV422. Use explicit fourcc helpers for the check instead. Signed-off-by: Paul Kocialkowski Acked-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_backend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 52caf561da0e..30d7bc76c0af 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -238,7 +238,8 @@ static int sun4i_backend_update_yuv_format(struct sun4i_backend *backend, SUN4I_BACKEND_ATTCTL_REG0_LAY_YUVEN); /* TODO: Add support for the multi-planar YUV formats */ - if (format->num_planes == 1) + if (drm_format_info_is_yuv_packed(format) && + drm_format_info_is_yuv_sampling_422(format)) val |= SUN4I_BACKEND_IYUVCTL_FBFMT_PACKED_YUV422; else DRM_DEBUG_DRIVER("Unsupported YUV format (0x%x)\n", fmt); From patchwork Fri Nov 23 09:24:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695373 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 D3F2C1709 for ; Fri, 23 Nov 2018 09:28:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35482C3BB for ; Fri, 23 Nov 2018 09:28:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7A422C419; Fri, 23 Nov 2018 09:28:27 +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 55E552C3BB for ; Fri, 23 Nov 2018 09:28:26 +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=6l2ZVu9x9d8oWjJlKngfPqD3y35XtGBedrfHJx9TRME=; b=dEML5SXhwJ9jRs JgR4zKS+awQtNAaxbf/v2XRC0dUxBCcdlXCsHkfe+4s3BfKZ1du1VeZdzPh5e3W2MLskS4BBVDLGk MjGmZNHOGrlQqykQAlb9Oi4LCyiOjqRLG/AiZhcPLZrdRJC0YKaaTEfh6vw9GUbDCWEkqp77Vt13R xu3GVDgmunV4vfGEaYnWdlUSENgVtf/V5QEs7TpcbSN4jdoldLsp2J8jgDz3SyRFBk60Jj9uDCPFO 1kV4lC7DuMTfaaSPJbLEOGKROx8PuhmwaiWCEQtniXhuySYe3sWDc/P14Cp2TPBW4PXXdK81PT3Lk P4s4opWN/tDTH1ftVXPw==; 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 1gQ7kz-0003bD-CJ; Fri, 23 Nov 2018 09:28:13 +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 1gQ7jq-0001qc-AY for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:11 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id D8E2C20DD8; Fri, 23 Nov 2018 10:26:48 +0100 (CET) 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 199DB20DD9; Fri, 23 Nov 2018 10:26:31 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 14/43] drm/sun4i: backend: Avoid counting YUV planes that use the frontend Date: Fri, 23 Nov 2018 10:24:46 +0100 Message-Id: <20181123092515.2511-15-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012703_064556_5C4D2CAE X-CRM114-Status: GOOD ( 14.01 ) 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 Our hardware has a limited number of YUV planes (usually 1) that can be supported using the backend only. However, YUV planes can also be supported by the frontend and must then not be counted when checking for that limitation. Only count the YUV plane when the frontend is not used. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 30d7bc76c0af..a39d8b75d76a 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -543,6 +543,11 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, DRM_DEBUG_DRIVER("Using the frontend for plane %d\n", plane->index); num_frontend_planes++; + } else { + if (fb->format->is_yuv) { + DRM_DEBUG_DRIVER("Plane FB format is YUV\n"); + num_yuv_planes++; + } } DRM_DEBUG_DRIVER("Plane FB format is %s\n", @@ -551,11 +556,6 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, if (fb->format->has_alpha || (plane_state->alpha != DRM_BLEND_ALPHA_OPAQUE)) num_alpha_planes++; - if (fb->format->is_yuv) { - DRM_DEBUG_DRIVER("Plane FB format is YUV\n"); - num_yuv_planes++; - } - DRM_DEBUG_DRIVER("Plane zpos is %d\n", plane_state->normalized_zpos); From patchwork Fri Nov 23 09:24:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695407 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 BD1CB14BD for ; Fri, 23 Nov 2018 09:31:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAEEA2C2D1 for ; Fri, 23 Nov 2018 09:31:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DC802C395; Fri, 23 Nov 2018 09:31:38 +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 3D3242C2D1 for ; Fri, 23 Nov 2018 09:31:38 +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=KYQOcXRL7a/qmAtS/8v+SBISYbqsjFl/EYMkOsBrNrY=; b=bjiN4FWahFgBoB lbiI+Z83c8KNqKoE5xaOEALA9YSkRKzb03hj8SUY5Qpv9RSEF2MJawVp2ETfyiPHyp1xwXMQlRvDM 1OxOwVG0SbmQo6XZJFnG0p2Oro0/9r7Fv+tcc93zecw86Dn0mBityh6lj2S5+DO5E2vDLNcVBkyX4 g9wRxsGyyF8px8zeaYpfNFJytzyWpilbXsjyH/NURuseoN/pkhUnPmi5dgZ1M5RbjuL6khR7tdcbM UVWRPMrOgp4COw98k0sW33tlkFzXNWZ0Zrlrh76uAREKUU+gHzExw2ZMuVRL09lxIc5ujcnedrQ1p gERk9ot0TAbE01gdlGKQ==; 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 1gQ7oG-0000yj-Au; Fri, 23 Nov 2018 09:31:36 +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 1gQ7jv-0001qd-5f for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:14 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id E7A7620F84; Fri, 23 Nov 2018 10:26:57 +0100 (CET) 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 5993F20DDE; Fri, 23 Nov 2018 10:26:31 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 15/43] drm/sun4i: Rename sun4i_backend_layer_formats to sun4i_layer_formats Date: Fri, 23 Nov 2018 10:24:47 +0100 Message-Id: <20181123092515.2511-16-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012708_057818_CB24A026 X-CRM114-Status: GOOD ( 12.73 ) 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 more formats can be supported by the frontend, rename the variable listing the layer formats to avoid suggesting that the backend itself supports all the listed formats. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_layer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 50bb16566f03..c3368b17e5f1 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -127,7 +127,7 @@ static const struct drm_plane_funcs sun4i_backend_layer_funcs = { .update_plane = drm_atomic_helper_update_plane, }; -static const uint32_t sun4i_backend_layer_formats[] = { +static const uint32_t sun4i_layer_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB1555, @@ -156,8 +156,8 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm, /* possible crtcs are set later */ ret = drm_universal_plane_init(drm, &layer->plane, 0, &sun4i_backend_layer_funcs, - sun4i_backend_layer_formats, - ARRAY_SIZE(sun4i_backend_layer_formats), + sun4i_layer_formats, + ARRAY_SIZE(sun4i_layer_formats), NULL, type, NULL); if (ret) { dev_err(drm->dev, "Couldn't initialize layer\n"); From patchwork Fri Nov 23 09:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695511 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 2DA98175A for ; Fri, 23 Nov 2018 10:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18F442C471 for ; Fri, 23 Nov 2018 10:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CE3C2C482; Fri, 23 Nov 2018 10:00:21 +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 90BB32C471 for ; Fri, 23 Nov 2018 10:00:20 +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=oHpgO1QbUnoL7L1sQ53fVVxuq4As6y8W8cOZhDl5qF4=; b=BjrPN1c55nMkvW 5U/G94JDz0puTQFPDEWjNTA2Y38DOiHzdmXfeHJXZtFNd5xOpdSKVRHnwzTI55U8rru7HBG55+MGj FdFhuvIKpFLkoZml6Pzkl5PWB2735ob+CwBrcJDWXJ0dVBLY8yDFAXUDenIKBtJl/WCUOqIzSWfCY 8E7gTaybjxMzGDrliZ58TSuTe1MIpUInV1C4MLeJdBdgNhWLC+kTk1H6+wl5EHYbl1bzuMsbOp1bC Uj4GL5st7Yys+TMWJkFeqScC2cXloKpAet+15d+FMsO7b22QQ/qdoc4Q4/AdKAyXq+0xMi9NzLBHc WgQrE2R05DRgQatAZwwA==; 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 1gQ8Fr-000291-O4; Fri, 23 Nov 2018 10:00:07 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kC-0002WS-MX for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:27:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jTrgK+OIzH9bUS3BzuYAB2JshKLKX8g0CkNBn/lSZus=; b=hKkJol9/XlCt91Ofw7lU9s500+ i5pnakNxleTkfBctsxE/eIZ5JVDgHqMegUyAyno7nER4seLTgHfCOeFnA4wwzE6ewziBUrq+bwaYP u/++rZmuYEKqrWGe1kojKXhnDbJX1ALEOJLyEIxe2QWUX30n+z/I5ClEkAiHBKXSxr63oODaxqmlq bsn08DUPNmI29HunQq78BX5/hg4MQ62HeIzWkcAbDJd6g5IP558E1y0L7n6n+c9loPGDA0yUJ5ruJ YMRMpPicP93orTwb5m91H6DJQ8sffMGg4J6giPWvhJI7jOmUpgLjEmKoEZnVOda0wjwqFucudyem6 9q4pUxzg==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kB-0006Wp-0Y for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id EA7CE20DDE; Fri, 23 Nov 2018 10:26:57 +0100 (CET) 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 99CA920DE1; Fri, 23 Nov 2018 10:26:31 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 16/43] drm/sun4i: frontend: Move CSC bypass setup to format update routine Date: Fri, 23 Nov 2018 10:24:48 +0100 Message-Id: <20181123092515.2511-17-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_042723_153380_3F9E8044 X-CRM114-Status: GOOD ( 10.81 ) 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 In order to support YUV to RGB conversion with the frontend (which is generally used for connecting with the backend), the CSC block must not be bypassed. As a result, the bit to enable CSC bypass is moved from the runtime resume routine to the format update routine, so that it can disabled when introducing support for YUV formats later. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 0f7f8c7b3402..f54b1c4a9264 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -177,6 +177,10 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE1_REG, 0x400); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE1_REG, 0x400); + regmap_update_bits(frontend->regs, SUN4I_FRONTEND_BYPASS_REG, + SUN4I_FRONTEND_BYPASS_CSC_EN, + SUN4I_FRONTEND_BYPASS_CSC_EN); + regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG, SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(1) | SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(in_fmt_val) | @@ -354,10 +358,6 @@ static int sun4i_frontend_runtime_resume(struct device *dev) SUN4I_FRONTEND_EN_EN, SUN4I_FRONTEND_EN_EN); - regmap_update_bits(frontend->regs, SUN4I_FRONTEND_BYPASS_REG, - SUN4I_FRONTEND_BYPASS_CSC_EN, - SUN4I_FRONTEND_BYPASS_CSC_EN); - sun4i_frontend_scaler_init(frontend); return 0; From patchwork Fri Nov 23 09:24:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695411 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 6665D14BD for ; Fri, 23 Nov 2018 09:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D0262C2D1 for ; Fri, 23 Nov 2018 09:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FC522C395; Fri, 23 Nov 2018 09:31:51 +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 38D2D2C357 for ; Fri, 23 Nov 2018 09:31:50 +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=1zrC4puxC4zyPl+Uh6vhJTNfanp+aKmcy4Z4oUFQdmc=; b=BaIyDfdgPY4cpr dBp2xKAyExIz0XfI20xh4o+slO9CjOZQ2WX4hZxcL2Gn+TRgkcvMM17ype6VId/3jShyfPJS17fUL MrZGggnJXQSsthBmzbOTqXuwis8Ei744sIMTimU5yCepJ+P880eIc3hJTD1EN6KmQvsu8DCZkTK/1 ECTcyn8Rba+rnXWDErPxymgNM0JtP3R5AugcLUtPVm8tBidpVHiq4xYURfNG2YtbE9/qTCAreGGcW sxU6KeAxw/BPnq0s+BNsThmTn4OwfyLPT9rUwrRLR1q1Q2nE3Bx5XWEH01h5P1pUQ0yKzwYwN0UWe 0d2SHTYlyNL7SPJACITw==; 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 1gQ7oR-0001Ex-S5; Fri, 23 Nov 2018 09:31:47 +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 1gQ7jv-0001qL-My for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:15 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id F288320DE1; Fri, 23 Nov 2018 10:26:57 +0100 (CET) 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 DA7D820DE4; Fri, 23 Nov 2018 10:26:31 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 17/43] drm/sun4i: frontend: Add helpers for input data mode and pixel sequence Date: Fri, 23 Nov 2018 10:24:49 +0100 Message-Id: <20181123092515.2511-18-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012708_715194_89C196CF X-CRM114-Status: GOOD ( 15.13 ) 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 This introduces new helpers for retrieving the input data mode and pixel sequence register field values based on the DRM format instead of hardcoding these. This makes it easier to add support for more formats. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 46 +++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index f54b1c4a9264..bb5977a466f3 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -116,6 +116,30 @@ 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) +{ + switch (fmt) { + case DRM_FORMAT_XRGB8888: + *val = 1; + return 0; + + default: + return -EINVAL; + } +} + +static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) +{ + switch (fmt) { + case DRM_FORMAT_XRGB8888: + *val = 1; + return 0; + + default: + return -EINVAL; + } +} + static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) { switch (fmt) { @@ -149,17 +173,29 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, { struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; + uint32_t format = fb->format->format; u32 out_fmt_val; - u32 in_fmt_val; + u32 in_fmt_val, in_mod_val, in_ps_val; int ret; - ret = sun4i_frontend_drm_format_to_input_fmt(fb->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; } + ret = sun4i_frontend_drm_format_to_input_mode(format, &in_mod_val); + if (ret) { + DRM_DEBUG_DRIVER("Invalid input mode\n"); + return ret; + } + + ret = sun4i_frontend_drm_format_to_input_sequence(format, &in_ps_val); + if (ret) { + DRM_DEBUG_DRIVER("Invalid pixel sequence\n"); + return ret; + } + ret = sun4i_frontend_drm_format_to_output_fmt(out_fmt, &out_fmt_val); if (ret) { DRM_DEBUG_DRIVER("Invalid output format\n"); @@ -182,9 +218,9 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, SUN4I_FRONTEND_BYPASS_CSC_EN); regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG, - SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(1) | + SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(in_mod_val) | SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(in_fmt_val) | - SUN4I_FRONTEND_INPUT_FMT_PS(1)); + SUN4I_FRONTEND_INPUT_FMT_PS(in_ps_val)); /* * TODO: It look like the A31 and A80 at least will need the From patchwork Fri Nov 23 09:24:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695493 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 8F11C5A4 for ; Fri, 23 Nov 2018 09:47:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4F92C2E1 for ; Fri, 23 Nov 2018 09:47:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E1302C2DE; Fri, 23 Nov 2018 09:47:02 +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 08BE82C2DE for ; Fri, 23 Nov 2018 09:47:02 +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=y+TYdjWMt1NAe0+5xmkCsrK66D1CC4oOjfk8n9TaG2Y=; b=nIaFmCLFA79QMv u7hJSvQJZw7bFctAKaEs2sRyv4sVcq7Bz8AwkjDkOg5n+MzM1xgWKypkqPEXj8affqERMJ9QJDp7X 72GxxZ5rZe1UI89rpnm6sbe8OrTvMnR/gcY/iV65te/4SYQuu3pw+WrrWt9uzjALhaXik6CRdTO7a BFzPE5G5CriuDeu88H0uF4degd3lfCbvlXq5MmCqCTPXHCg+GQq/zTmqHDpw6hr07/Ayx5KAwlTK9 ck177CeMMhe9HX2a7iD9aUMeU/XiZFNofonhve4Pi3gqXzfiJIoYSY6MGuckuXFKHnm25tBwJXwHL MLRuFLiq6S9il3MtEN8Q==; 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 1gQ82y-0003fc-L3; Fri, 23 Nov 2018 09:46:48 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7yr-0006J2-Ga for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:42:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nTymt5CN/7REVUE9mMa4eFZhjCtK0FzkooWPXA64EJo=; b=BXTXiWj6IUgOVD+Mwq+SjhdRK8 ZZUIYk8Xdeuh+V9s00zhVRMbq7N6uXRceVm5yznhgJC78hqPriqfhex950QNuL2nr3HV58fso3alo QalPNUdH0PxuKsPjTld9mvh4e6ZBIdN06i5/fu5++nP+4FuRytNvAkoL/xuPtwCySON1C+ttBG8Di Cd+gafDBdu+M9UuYe8ehlz3LCxpOi9qvwM8KZ60rBmPlzLAHtWDFohxxzFIfyLCby5NL8UR8YbeRQ MLWr2XtQQAcAwRqeKVMvFt2MZhdqvG7YUudlrK2JOqwU/qahSwolI1Q3hvE4yp/36BBm3RezXf7Km ccaz+rWQ==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k6-00068g-CH for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 00926207AB; Fri, 23 Nov 2018 10:26:57 +0100 (CET) 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 272CE20DE5; Fri, 23 Nov 2018 10:26:32 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 18/43] drm/sun4i: frontend: Add proper definitions for format registers Date: Fri, 23 Nov 2018 10:24:50 +0100 Message-Id: <20181123092515.2511-19-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_092718_502377_C29B4072 X-CRM114-Status: GOOD ( 14.80 ) 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 This introduces proper definitions for the input and output format configuration registers instead of a macro and raw values in the code, with the intent to increase code readability and reduce indirections. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 14 ++++++-------- drivers/gpu/drm/sun4i/sun4i_frontend.h | 8 ++++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index bb5977a466f3..a305b731b042 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -108,7 +108,7 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 5; + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB; return 0; default: @@ -120,7 +120,7 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 1; + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED; return 0; default: @@ -132,7 +132,7 @@ static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 1; + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB; return 0; default: @@ -144,7 +144,7 @@ static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 2; + *val = SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888; return 0; default: @@ -218,9 +218,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, SUN4I_FRONTEND_BYPASS_CSC_EN); regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG, - SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(in_mod_val) | - SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(in_fmt_val) | - SUN4I_FRONTEND_INPUT_FMT_PS(in_ps_val)); + in_mod_val | in_fmt_val | in_ps_val); /* * TODO: It look like the A31 and A80 at least will need the @@ -228,7 +226,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, * ARGB8888). */ regmap_write(frontend->regs, SUN4I_FRONTEND_OUTPUT_FMT_REG, - SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(out_fmt_val)); + out_fmt_val); return 0; } diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index a9cb908ced16..56bd5a3f9723 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -26,12 +26,12 @@ #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c -#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(mod) ((mod) << 8) -#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(fmt) ((fmt) << 4) -#define SUN4I_FRONTEND_INPUT_FMT_PS(ps) (ps) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c -#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(fmt) (fmt) +#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2 #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100 #define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1))) From patchwork Fri Nov 23 09:24:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695491 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 3F1395A4 for ; Fri, 23 Nov 2018 09:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27CC92C2DE for ; Fri, 23 Nov 2018 09:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A4122C34A; Fri, 23 Nov 2018 09:47:01 +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 BFA112C2DE for ; Fri, 23 Nov 2018 09:47:00 +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=RFRCaAjPlWMPpBbjUBeeoxy5+6kIiYfMgheYTZTVAy8=; b=pxCgi8g32Xk8wz m6xR1FpG3InvaKUeo7Tl+K1SpQO5vy8Xs6MCD+8lNGNJrJQ6Jn7ZT3quAL4nkFYNHg4ZONkCcGr1i UO5HZrprmNPZj80UlfuZolT0kXvkHl1wIzp4bOyeWhfYHuiRXRUNlbw2yoqi4eIEPP1ECi118E9DO XCOFXxhT7a2RyY0U6AxxxGw0WMtNy/xSUo1ThuQbqwCQYFG93a7LJAZjMAMFkYU+VbJOZIs0c9qjw fcs2c8nFkyaL18ZkPayJjVhnqhk47TcVtWOYFzC4NBi0YeZ9auUD17Wsj0KAXVrygyJUoB2SzHoG+ dHgfxlELSoTCxdsCO2Kg==; 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 1gQ839-0003tx-3S; Fri, 23 Nov 2018 09:46:59 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7yr-0006Cf-Va for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:42:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=spxlAilPFaq2Mbt+rC4f9EYr3haTFO3dP7Tv9H743zs=; b=I1LGQID/pYNVr6IX9H9Hocpbhk 6KBEKD+meXX5wdwnkyrOLuL1GkL+qdRc9UjrqCpivtSvz6KwxqnBN/hVJZC14Zy5ev039sV5uXTM7 btSpyi6w7JQYmQpT4cL3oel0hiZsiEXAraAx/20dZPVhtYwpJlegHqTOpPNjd/aN5/4FBb8c0JFAS gpuzOgLS+fPw1JPcliez2pEiqhiTHsf+5SebVWT5j+dHFhJh8RnMBTtO3R0gl0d3YQaSvDSVDYuMZ 6rAPwtiselobiqrjgUOvxqOt8bpPFhfaiqO+MnpVLlbkXJnpClmcQrNaQDeMghGtHxyJXpcOqKSDN nkl0w4+A==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k6-0006AV-CD for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 31BD820DEB; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 67B6220DEB; Fri, 23 Nov 2018 10:26:32 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 19/43] drm/sun4i: frontend: Determine input mode based on the number of planes Date: Fri, 23 Nov 2018 10:24:51 +0100 Message-Id: <20181123092515.2511-20-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_092718_493105_EDBE9B27 X-CRM114-Status: GOOD ( 13.54 ) 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 Use the number of planes associated with the DRM format to determine the input mode configuration instead of the format iteself. This way, the helper can be used for all packed formats without future changes. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index a305b731b042..a16697b0eac5 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -118,14 +118,12 @@ 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) { - switch (fmt) { - case DRM_FORMAT_XRGB8888: + if (drm_format_num_planes(fmt) == 1) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED; - return 0; - - default: + else return -EINVAL; - } + + return 0; } static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) From patchwork Fri Nov 23 09:24:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695441 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 C2DA5175A for ; Fri, 23 Nov 2018 09:43:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B142A2C298 for ; Fri, 23 Nov 2018 09:43:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4AC72C2AE; Fri, 23 Nov 2018 09:43:31 +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 4ED762C298 for ; Fri, 23 Nov 2018 09:43:31 +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=5UA2SnwjLExzvfBnZdJbos1Kt8phiqTiisXcJwsNZr0=; b=PIEd/RkEi2J0tX th+I1u/21I2Bflrr3BnhwjSFaOtc6QbWytpiOPfGqCPIwvPj7CK9cHPB+D0tqzrFVhSOIwgc0lDhE 2EaB2pJSjx0YcgfB4QMIwP54M0u2MreLh4phCiRkBn0Tk9EtnFWi1M8x+Fy77LtfGbR4augQfxGC7 w6RfRMHUds41vkkMiDhybqCQOenlIB9002qy4Bi+wqUgd2Ra8fN/TLReLOomf9YHdiHmKWeU0+V1g PcpS6+vqh0TEC21+XBASUWd8muUf/x6XjK/4QxSCHuVt72QK3D00xVFq7eUY2t/d9/ePziB2gATxj ZOZwDcWk24sszNHiWAmw==; 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 1gQ7zk-0007u0-Mr; Fri, 23 Nov 2018 09:43:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7ys-0006Xf-1Y for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:42:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QJSuzhnfg8k9oynXdbgpTf2Z7q/l61cQ8aTZkKk9m34=; b=pVjeFfeFDiEfZ785nsi+8gs0pY suVK+JZu90xHYA3nxKE7jS3/WqBqVG4JTQnqbf97N9qqMcPTBkjC5gRFubLS7L00asoqcSO6AyOfP LNCwDKlScj6s5fghyCF/kC3YGPZrqxkZdgt7fol/2lTjIKq/9t6bKMq+325RLPILmg1R1VNX2gxYU 5s7E1VMC1p7rUR4K/kXFtc46PBk5f4kYAvycUhIQeKouNqjk1/BTvho1+6DGUPwXof7W29dF0zhcD anZfKKAQkSwo1Zg2R3GXgILj/pM7TStgbzAJULm0JSLTN6oMYjbmiLWqCm1Ki9rN3gD/4n9epWs1l zQPE6nkg==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k6-0006AS-9l for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 23D3F20DE5; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 A8AD320DED; Fri, 23 Nov 2018 10:26:32 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 20/43] drm/sun4i: frontend: Determine input format based on colorspace Date: Fri, 23 Nov 2018 10:24:52 +0100 Message-Id: <20181123092515.2511-21-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_092718_441458_7455B99E X-CRM114-Status: GOOD ( 14.79 ) 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. Thus, we can use the associated common DRM helper. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index a16697b0eac5..7a8efbd516ac 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -106,14 +106,12 @@ EXPORT_SYMBOL(sun4i_frontend_update_buffer); static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) { - switch (fmt) { - case DRM_FORMAT_XRGB8888: + if (!drm_format_is_yuv(fmt)) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB; - return 0; - - default: + else return -EINVAL; - } + + return 0; } static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) From patchwork Fri Nov 23 09:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695415 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 89713175A for ; Fri, 23 Nov 2018 09:32:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 780B72C2D1 for ; Fri, 23 Nov 2018 09:32:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A35E2C395; Fri, 23 Nov 2018 09:32:22 +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 199E32C2D1 for ; Fri, 23 Nov 2018 09:32:22 +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=Rsv3zsH+OACaA5wirb1r8aqqHfacNydtQT0R5ZYDNgQ=; b=oCgQ2HEPUG+p7l +YpHMRIhU71eMdRjBY2QSRL/evAmBz8ipCwbWEFUiLw5W0b9HPFGqtFzGc4oToAaoEiK4HWJeDAcf Xm0IsPnTO0HAWH0FHbeTpjoG562bKBZqXmgIS+2aQRxck3hUFT+je/W6xZjhKXqnhuXfwYrjGiWRd Lj6lMZm5Y0JVYvlNeukd9zRWdKbpItB4dUxOeHO93RDNs+ZPqIt/AYvVNHG57bGnQkrwbRHSD668C 6reXiP61kTVaxvT1YaNqb5yJ2LqcPLWWC9MFvOpU5MdTAIMQhZbqabGYLpH7m3uwQgkLRNX6ZPuP+ 5XjKEjR0lIl+dOIRfwmw==; 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 1gQ7on-0001ir-4a; Fri, 23 Nov 2018 09:32:09 +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 1gQ7k0-0001q1-GI for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:16 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 30BD620DE4; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 EA25420DF0; Fri, 23 Nov 2018 10:26:32 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 21/43] drm/sun4i: frontend: Add support for the BGRX8888 input format Date: Fri, 23 Nov 2018 10:24:53 +0100 Message-Id: <20181123092515.2511-22-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012713_006159_1F815859 X-CRM114-Status: GOOD ( 13.08 ) 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 This introduces support for the BGRX8888 input format for the frontend, with its associated pixel sequence value definition. Other fields are already configured correctly as they no longer depend on the format's fourcc directly. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 5 +++++ drivers/gpu/drm/sun4i/sun4i_frontend.h | 1 + drivers/gpu/drm/sun4i/sun4i_layer.c | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 7a8efbd516ac..e579fcf63ab4 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -127,6 +127,10 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) { switch (fmt) { + case DRM_FORMAT_BGRX8888: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX; + return 0; + case DRM_FORMAT_XRGB8888: *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB; return 0; @@ -149,6 +153,7 @@ 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_XRGB8888, }; diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 56bd5a3f9723..2ee1bccf378a 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -28,6 +28,7 @@ #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8) #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX 0 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index c3368b17e5f1..6155eca6b1bd 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -131,6 +131,7 @@ static const uint32_t sun4i_layer_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB1555, + DRM_FORMAT_BGRX8888, DRM_FORMAT_RGBA5551, DRM_FORMAT_RGBA4444, DRM_FORMAT_RGB888, From patchwork Fri Nov 23 09:24:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695413 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 D7F9F175A for ; Fri, 23 Nov 2018 09:32:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E8D2C2D1 for ; Fri, 23 Nov 2018 09:32:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B47AE2C395; Fri, 23 Nov 2018 09:32:04 +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 47E1F2C2D1 for ; Fri, 23 Nov 2018 09:32:04 +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=NOQi5KTxIqYt8NS8FlPQVKZfTseHqnuQ/bdu7O00QrY=; b=kyIpCAzoTanDHF fx1REx2YywuRHCRY2YPWwpWQBrqybwPpHbOrl+hKiWpRuA2Og/WNFLT00DCQ7Rjd8BkrxE+tjgb7C GrXvIRTPu5QW2Y4ST+l/bBUk8FLKpC/YZmOF5wybL9Mf4n10i+t4WOLIjH/mfP/Nzb8vNl+VaJXXh aKCA8RdoViYy9phgpw/AyA8kWZH1TQTRRL/PdbExptCM7Yp5dSXMpMMI5vw/ByGxY1Yhi/0wJYOA8 Wo3I45DQPwZV7LPVLWCCksav0zoPAvlEIpmfy90GtxAI4yr1YLqXhAhjh7/oO5Boa91Cn6h7CrPO2 0Ls1PLn+MU0JABOQSIbw==; 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 1gQ7oc-0001U2-CQ; Fri, 23 Nov 2018 09:31:58 +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 1gQ7k0-0001qc-9U for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:16 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 2FA0720F87; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 3622D20DF3; Fri, 23 Nov 2018 10:26:33 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 22/43] drm/sun4i: frontend: Add support for the BGRX8888 output format Date: Fri, 23 Nov 2018 10:24:54 +0100 Message-Id: <20181123092515.2511-23-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012712_831015_323F6801 X-CRM114-Status: GOOD ( 12.11 ) 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 This introduces support for the BGRX8888 output format for the frontend, with its associated output format value definition. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 4 ++++ drivers/gpu/drm/sun4i/sun4i_frontend.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index e579fcf63ab4..7fa8fb3eb7aa 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -143,6 +143,10 @@ static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) { switch (fmt) { + case DRM_FORMAT_BGRX8888: + *val = SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_BGRX8888; + return 0; + case DRM_FORMAT_XRGB8888: *val = SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888; return 0; diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 2ee1bccf378a..800a193eebc2 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -32,6 +32,7 @@ #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c +#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_BGRX8888 1 #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2 #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100 From patchwork Fri Nov 23 09:24:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695417 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 3A47214BD for ; Fri, 23 Nov 2018 09:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 290892C2D1 for ; Fri, 23 Nov 2018 09:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D4AA2C395; Fri, 23 Nov 2018 09:32:23 +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 B2EBC2C2D1 for ; Fri, 23 Nov 2018 09:32:22 +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=bBCMocInYKNyVTgH3nxRAe4Nh0KS837/WdRiCDwry04=; b=tF5nkvAuX5yfil 8mqcn+l1aWA64aZnloiBYGnqg3sq3U6iSy3eaG4Va7RdN6AD7/aQ1ZnkUqu6b33GaIPbykJffXwtx hpOmJlZRkRLMATBgmZrzLADowp7HyIgTKLwsLOT4rdSCcOHvdMTCFkEf2zZScJlGW3q/bz210CKZ7 ufUI9QDtc+Be5hAxPGTJ8eV3GS4Hbq8LDFyDdKFjt81AaWIPHf4jyxkCWr3Cy52BjSHYrSxqXHuGy XeFzSI0LDsHyKIQop5+528SW7jcSmJxd1Lgh1Ph70yztwU2mhrK6F8Vpqm947X4DTPMlHnmyChku+ FxhIGh7Y9qD3pZz5uqqQ==; 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 1gQ7oz-0001zM-2R; Fri, 23 Nov 2018 09:32:21 +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 1gQ7k0-0001q2-Ql for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:18 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 5D23820DF0; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 7659720DF9; Fri, 23 Nov 2018 10:26:33 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 23/43] drm/sun4i: backend: Detail the YUV to RGB values coding explanation Date: Fri, 23 Nov 2018 10:24:55 +0100 Message-Id: <20181123092515.2511-24-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012713_266098_AA06311E X-CRM114-Status: GOOD ( 12.58 ) 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 From: Paul Kocialkowski The values in the BT601 YUV to RGB colorspace translation are not simply coded as multiples, but rather as fixed-point signed fractional values on a given number of bits. Add an explanation about that. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index a39d8b75d76a..986bdb64521c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -48,8 +48,12 @@ static const u32 sunxi_rgb2yuv_coef[12] = { /* * These coefficients are taken from the A33 BSP from Allwinner. * - * The formula is for each component, each coefficient being multiplied by - * 1024 and each constant being multiplied by 16: + * The first three values of each row are coded as 13-bit signed fixed-point + * numbers, with 10 bits for the fractional part. The fourth value is a + * constant coded as a 14-bit signed fixed-point number with 4 bits for the + * fractional part. + * + * The values in table order give the following colorspace translation: * G = 1.164 * Y - 0.391 * U - 0.813 * V + 135 * R = 1.164 * Y + 1.596 * V - 222 * B = 1.164 * Y + 2.018 * U + 276 From patchwork Fri Nov 23 09:24:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695513 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 A88DC18F0 for ; Fri, 23 Nov 2018 10:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 972B12C471 for ; Fri, 23 Nov 2018 10:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B79B2C477; Fri, 23 Nov 2018 10:00:21 +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 0C6AB2C47B for ; Fri, 23 Nov 2018 10:00:21 +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=bHfXoj/ubKvyGaRAZgdUGiZCBj+RM2pIta2Mb3TmOpc=; b=SwMjul8uTMcPnR BM7bS3cRFASawPpaejp9Lm/Ab4S5KRggUl2KylxtDIdk6gcyuGmQBcfn7BEEq41jyrVnQBjkssjsC Oy3Kr4dofMzynyyzcw/0zoHJ+Zusnuu8cXdzgW7j8ooM2b6OCBNVgS0/CZ92bAs04S6Rd+4NRbxNu V1cCav2khY2iUiKzl2m52qS6guor1thR5pmUdOF35iSZ2zanIdCBtbQcVs1NANSR2RjK/gHsu6i0z BXCcPYmwAiwAWwZh1z+TS7l9t7zgx78ZIUtBGuHlvXvoAXheP5iyGcVKZboBDkUJbxxVoil7mdzMh lr542gsETB2UoqnEhYTQ==; 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 1gQ8G2-0002cn-Ep; Fri, 23 Nov 2018 10:00:18 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kC-0002Ul-NY for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:27:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3EbVzJqAMu2EdWbYhleFyG5fTA9WG9n4xDSnUB8CEyk=; b=K2x+ju/48YJxu1RMUeGfWm4lv5 ZiVjgNMmcWlukJ1Zi2r5OOXZ214juRr9CKaJPPsvfJIp25aPw/8H5w0tZ3LNdmzVRUldUlIYhcI9O gg1t/usqX8OwG4AqnuZfFiMLCc6OYKs6tFV8PiovA9g7WO/y2KYHE8EqXA8gYmEQJ/z5kIuSZdpfe lI28nd+wJino0PSvpCXFpwYyMptKoDCw3Yg8n2P1gQpXUCf0OGVgFDiNnG7JwkXD/Q2imkqQq7t2r qlu28WcWjOzvmIarxVi4XsUZHjjXGjHI7xUv3ffga4YXcPUf42GDv1WxAJrInxdiN3ast8oGmxNNg PyB3Ue8w==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k8-0006XI-99 for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:22 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 6AA2920DF3; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 B756420DFB; Fri, 23 Nov 2018 10:26:33 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 24/43] drm/sun4i: frontend: Configure and enable YUV to RGB CSC when needed Date: Fri, 23 Nov 2018 10:24:56 +0100 Message-Id: <20181123092515.2511-25-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_042720_590109_D1805FCE X-CRM114-Status: GOOD ( 17.35 ) 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 In prevision of adding support for YUV formats, set the YUV to RGB colorspace conversion coefficients if required and don't bypass the CSC engine when converting. The BT601 coefficients from the A33 BSP are copied over from the backend code. Because of module inter-dependency, we can't have the frontend use these coefficients from the backend directly. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 39 ++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun4i_frontend.h | 2 ++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 7fa8fb3eb7aa..5626334c6e87 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -48,6 +48,28 @@ static const u32 sun4i_frontend_horz_coef[64] = { 0x03ff0000, 0x0000fd41, 0x01ff0000, 0x0000fe42, }; +/* + * These coefficients are taken from the A33 BSP from Allwinner. + * + * The first three values of each row are coded as 13-bit signed fixed-point + * numbers, with 10 bits for the fractional part. The fourth value is a + * constant coded as a 14-bit signed fixed-point number with 4 bits for the + * fractional part. + * + * The values in table order give the following colorspace translation: + * G = 1.164 * Y - 0.391 * U - 0.813 * V + 135 + * R = 1.164 * Y + 1.596 * V - 222 + * B = 1.164 * Y + 2.018 * U + 276 + * + * This seems to be a conversion from Y[16:235] UV[16:240] to RGB[0:255], + * following the BT601 spec. + */ +static const u32 sunxi_bt601_yuv2rgb_coef[12] = { + 0x000004a7, 0x00001e6f, 0x00001cbf, 0x00000877, + 0x000004a7, 0x00000000, 0x00000662, 0x00003211, + 0x000004a7, 0x00000812, 0x00000000, 0x00002eb1, +}; + static void sun4i_frontend_scaler_init(struct sun4i_frontend *frontend) { int i; @@ -181,6 +203,8 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, uint32_t format = fb->format->format; u32 out_fmt_val; u32 in_fmt_val, in_mod_val, in_ps_val; + unsigned int i; + u32 bypass; int ret; ret = sun4i_frontend_drm_format_to_input_fmt(format, &in_fmt_val); @@ -218,9 +242,20 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE1_REG, 0x400); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE1_REG, 0x400); + if (fb->format->is_yuv && !drm_format_is_yuv(out_fmt)) { + /* Setup the CSC engine for YUV to RGB conversion. */ + bypass = 0; + + for (i = 0; i < ARRAY_SIZE(sunxi_bt601_yuv2rgb_coef); i++) + regmap_write(frontend->regs, + SUN4I_FRONTEND_CSC_COEF_REG(i), + sunxi_bt601_yuv2rgb_coef[i]); + } else { + bypass = SUN4I_FRONTEND_BYPASS_CSC_EN; + } + regmap_update_bits(frontend->regs, SUN4I_FRONTEND_BYPASS_REG, - SUN4I_FRONTEND_BYPASS_CSC_EN, - SUN4I_FRONTEND_BYPASS_CSC_EN); + SUN4I_FRONTEND_BYPASS_CSC_EN, bypass); regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG, in_mod_val | in_fmt_val | in_ps_val); diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 800a193eebc2..fb097c34e160 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -35,6 +35,8 @@ #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_BGRX8888 1 #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2 +#define SUN4I_FRONTEND_CSC_COEF_REG(c) (0x070 + (0x4 * (c))) + #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100 #define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1))) From patchwork Fri Nov 23 09:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695471 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 4CE8B5A4 for ; Fri, 23 Nov 2018 09:45:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A9B72C2DE for ; Fri, 23 Nov 2018 09:45:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EF3B2C34A; Fri, 23 Nov 2018 09:45:22 +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 C680F2C2DE for ; Fri, 23 Nov 2018 09:45:21 +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=oPjaXYcxH5LHnk7GFFvHdOVeLQS75fHLfwAaisF7rtc=; b=YKhSxii+0eJ4DK MMiuPmFNJWsyHO7Sg8SJrIpuy4qeRRSycoZVB6gg87YA/C+dsi9Gnaz/61oRU3k+ntqwkcpTEYPie msna0tfFF6LJswI1GSJuNranw12y58Vi3KqApdQwN35drvAkrQcmy8VnJm+IOgRTk4qbzrAs0mZX2 zrrek99xyVq9J47pHF/nZ5S6CqNUMVOw+HVWpQZbBxEGMAUM9xt93YA1fUmeWGEsFo7Tlp8JPrYrq YI4e+w/abBfQHOsZQ0o323raQ0H1xxFXWwBguccfw6gI3G1JNsPG1gddsWce3lAX/go7y1TgT9xPa dl52GB3NDm+ixFTt9reg==; 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 1gQ81X-0001gr-UK; Fri, 23 Nov 2018 09:45:19 +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 1gQ7k0-0001q3-S1 for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:19 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 7126220DF9; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 039B220E00; Fri, 23 Nov 2018 10:26:33 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 25/43] drm/sun4i: frontend: Apply format sub-sampling to CH1 dimensions Date: Fri, 23 Nov 2018 10:24:57 +0100 Message-Id: <20181123092515.2511-26-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012713_572963_9E6C01F2 X-CRM114-Status: GOOD ( 11.67 ) 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 The frontend comes with two "channels", that can be configured independently. When used in YUV mode, the first channel (CH0) represents the luminance component while the second channel (CH1) represents the chrominance. In RGB mode, both have to be configured the same way. Use variables (with the YUV terminology) for each channel's dimensions, calculating the chroma dimensions from the luma dimensions and the sub-sampling factors from the format description. Since the configured size only has pixel precision, the fractional fixed-point part of the source size is dropped for both components to ensure that the scaling factors are accurate. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 5626334c6e87..4700133b96e0 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -276,16 +276,24 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; + struct drm_framebuffer *fb = state->fb; + uint32_t luma_width, luma_height; + uint32_t chroma_width, chroma_height; /* Set height and width */ DRM_DEBUG_DRIVER("Frontend size W: %u H: %u\n", state->crtc_w, state->crtc_h); + + luma_width = state->src_w >> 16; + luma_height = state->src_h >> 16; + + chroma_width = DIV_ROUND_UP(luma_width, fb->format->hsub); + chroma_height = DIV_ROUND_UP(luma_height, fb->format->vsub); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_INSIZE_REG, - SUN4I_FRONTEND_INSIZE(state->src_h >> 16, - state->src_w >> 16)); + SUN4I_FRONTEND_INSIZE(luma_height, luma_width)); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_INSIZE_REG, - SUN4I_FRONTEND_INSIZE(state->src_h >> 16, - state->src_w >> 16)); + SUN4I_FRONTEND_INSIZE(chroma_height, chroma_width)); regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_OUTSIZE_REG, SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w)); @@ -293,14 +301,14 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w)); regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZFACT_REG, - state->src_w / state->crtc_w); + (luma_width << 16) / state->crtc_w); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZFACT_REG, - state->src_w / state->crtc_w); + (chroma_width << 16) / state->crtc_w); regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTFACT_REG, - state->src_h / state->crtc_h); + (luma_height << 16) / state->crtc_h); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTFACT_REG, - state->src_h / state->crtc_h); + (chroma_height << 16) / state->crtc_h); regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, SUN4I_FRONTEND_FRM_CTRL_REG_RDY, From patchwork Fri Nov 23 09:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695439 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 7BE245A4 for ; Fri, 23 Nov 2018 09:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68FFE2C298 for ; Fri, 23 Nov 2018 09:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59D852C2AE; Fri, 23 Nov 2018 09:43: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 00F3A2C298 for ; Fri, 23 Nov 2018 09:43:24 +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=Yg/SCSsKAU6/tcxKmsEM7RKifsIbhO+G4CdGSccW/Vg=; b=EzmdQ4AMTEYVD8 IwWdQ2V6xPcQSsQymrKiE9X8urnLj/cwflsSlWe/kZWFLqqYBySklGYaqlxu/lP5pQ697NIJ7ZdZy 46HvDIgZ67WYswn4gr+zk1ncReOx+CihO0IaXVyRZIqCobkNWiOxjfzIoYv5HCFibucAMB15f/RID ndA3V4rvXugXvM/aD/Kq5SeOaIgw7/vs6/H2/wKaMWbiSF9XBCH7wgj7gKoLcibf1fhepxeUegk62 9hXqzFbFsZ+zVotIo3c9NFFmHqO9mEm8jtMdHqpx4EfkIPnEpq2F4VSg6gIW+dY0dBXIsuqUC8dQN uAVoGpgX6csNTv/HCweg==; 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 1gQ7zZ-0007dw-ME; Fri, 23 Nov 2018 09:43:17 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7yr-0006F7-Oj for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:42:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=beGg9asIcLvna18hAtvtDsqVW6jL/DNTWRbWYhXrLi8=; b=MHsJycPM5sqYwkbZw3PxesJfKg lu8T802l6LPTf76riy0B58MLIDDkAFUzx9fYP9g87XAaLKxtwJpOTlLg0CdqUS60Yg9Qv1JHqI96x FxkTTo1uJucBVl8/UG4RZEQN5ezKKhCRFreLUAkURz5M5p0/pn8bhB4qYlg+cME8a82r9fwnjIpq4 QvVZFxsIwVB9Ey8yCrDUvxDtkBKR+Gl5deLgP2udhyTrk+hxaWQEaLImin5c5ADvwgNX55rfpKBOD hM2LAWmYddqQCabkGeILQZ+TAME+uyR/npfn3bUwdVTtL5OKeuS1HudVhzeM+zNPNmctBgGdByq4f p6X9Ae8g==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k6-0006Ag-9i for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 7579520DFB; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 440F720E0E; 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 Subject: [PATCH v2 26/43] drm/sun4i: frontend: Add support for packed YUV422 input formats Date: Fri, 23 Nov 2018 10:24:58 +0100 Message-Id: <20181123092515.2511-27-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_092718_487686_310461D8 X-CRM114-Status: GOOD ( 13.60 ) 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 This introduces support for packed YUV formats with 4:2:2 sampling using the frontend. Definitions are introduced for the data format and pixel sequence input format register values. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/sun4i/sun4i_frontend.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 4700133b96e0..f443e8e1d8ec 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -130,6 +130,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_422(fmt)) + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422; else return -EINVAL; @@ -153,10 +155,26 @@ 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_UYVY: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_UYVY; + return 0; + + case DRM_FORMAT_VYUY: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_VYUY; + return 0; + case DRM_FORMAT_XRGB8888: *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB; return 0; + case DRM_FORMAT_YUYV: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YUYV; + return 0; + + case DRM_FORMAT_YVYU: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_YVYU; + return 0; + default: return -EINVAL; } @@ -180,7 +198,11 @@ 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_UYVY, + DRM_FORMAT_VYUY, DRM_FORMAT_XRGB8888, + DRM_FORMAT_YUYV, + DRM_FORMAT_YVYU, }; bool sun4i_frontend_format_is_supported(uint32_t fmt) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index fb097c34e160..399755939a28 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -27,7 +27,12 @@ #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422 (1 << 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_BGRX 0 #define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 From patchwork Fri Nov 23 09:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695419 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 C120F14BD for ; Fri, 23 Nov 2018 09:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8EE32C2D1 for ; Fri, 23 Nov 2018 09:32:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D15A2C395; Fri, 23 Nov 2018 09:32:26 +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 2B5DB2C2D1 for ; Fri, 23 Nov 2018 09:32:26 +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=Z2M1087JtyjXYbDDxUJdPH/yQd6xiGXxthvssLhCTCI=; b=i5OixsDLnoCW98 uf2daqhFXUkXJ5pGF8VkC6fFiEEu0gWx5M9bIDH9ljC7wnvDdiQSSmePEPWYZhZ61hkY0eNmw4ceZ FoX24GfSxocGNhaGRA0xfOQhyfQLqTEVjQKBxYM8lF6E3k01Tk7CZpQXSlNb/KZP6u3kuwpqNdKNI Axl5VaCsBlRnVgAx8EK+fhFRvJTTMXKfYN6clCmMEimN64zva/AGFWhCxjPmq+ya+/8d2wy60V5GQ 0h/y6T2UXEDz9OIAMm5+VQKk4YtuU9GPpv53ClP6uNED9x4q1uClvOjWB+7Pd/SJVbUiiv7G+mHVT /IdQo8gC/PORNbhQfoGQ==; 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 1gQ7p3-000278-Cd; Fri, 23 Nov 2018 09:32:25 +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 1gQ7k0-0001qM-U3 for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:20 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id A6B2920E0E; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012713_519074_9B7F86DF X-CRM114-Status: GOOD ( 16.76 ) 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 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, From patchwork Fri Nov 23 09:25:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695487 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 978165A4 for ; Fri, 23 Nov 2018 09:46:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82A4F2C2DE for ; Fri, 23 Nov 2018 09:46:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 747642C34A; Fri, 23 Nov 2018 09:46:39 +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 BB7652C2DE for ; Fri, 23 Nov 2018 09:46:38 +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=G8UQIn7Sj/ebOtrmf7Ro1mQAbVUkWlxzfSKDZLa4AqY=; b=D8mQDSsSQjgKr9 27L+hiq55b/YAQClic1d0uTwUXZFCaxJqJbHpqxE9oor8KMCpmMaCT+gw4/8Dc5tVpUpXgzYrsqjN RQ+l6NjgxzJtn87De8Lc+Exzvs00yeQNXmprEV+paUnEE4W2QXHZA57zYugs8gMxKkDXwjPUpFLa+ BNwpHuwcvFivK92pb4FuLe6so1abgBhSF9lYwsQtZrMwcuA+gH/4Hz9lPtFOpi3eWpu6q9fcVXpKI uHhzwDpzklxYsUf5pRqqwaPA4rrq77Nfzf3SNFydULCA+UwQX2GKk9Pk2xPMIJgBDq9dxdmUHVmqM cx7j0C3Ox5urJVctUlLQ==; 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 1gQ82m-0003Lz-EI; Fri, 23 Nov 2018 09:46:36 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kD-0002Xr-UL for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:27:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NltNcmeiW54eUN9p7fWKYUUuM30LooBUcMGtb98b1VU=; b=mt+khGl3lNWVgBHadSBk/vr92D tuACrRM9mas3VGTUGfh3gVvaAL+3eejfKbfz/kOffCQGGCJ1hkjr1bp7lRPTUYiAkxOe2L9SaYPn4 Du85DdImQuv3TcJypdyuY9rZXGKXtpGZZOWwfANa32V2vpPnrCSEYENNwvTdy6YMCbDVjD1DhmGrM 2sf1TjPZea1Am+xtuKazIMxfNoQFm3Wolwo66Q8AcimyiulxBqhznVdRmahqCvzI9fOHQcU0iubQP frC3x9kRD4WZEqCxR21ShHJEvAZKP43yN/ix6qwEhTtxCOHgcxWOrqTSxl+gk95Z0Vu3Y5RxF3F2P dt3Jpw/A==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kA-0006Xb-VQ for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:25 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id B232E20EB0; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 CA23B20E3C; 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 Subject: [PATCH v2 28/43] drm/sun4i: frontend: Add support for planar YUV input formats Date: Fri, 23 Nov 2018 10:25:00 +0100 Message-Id: <20181123092515.2511-29-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_042723_315434_295A5EF8 X-CRM114-Status: GOOD ( 19.81 ) 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 Planar YUV formats come with 3 distinct planes, which requires configuring the frontend line stride and address registers for the third plane. Our hardware only supports the YUV planes order and in order to support formats with a YVU plane order, a helper is introduced to indicate whether to invert the address of the two chroma planes. Missing definitions for YUV411 and YUV444 input format configuration are also introduced as support is added for these formats. For the input sequence part, no configuration is required for planar YUV formats so zero is returned in that case. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 54 +++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_frontend.h | 5 +++ drivers/gpu/drm/sun4i/sun4i_layer.c | 8 ++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index e31438e5cabd..001139417cf5 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -106,12 +106,27 @@ void sun4i_frontend_exit(struct sun4i_frontend *frontend) } EXPORT_SYMBOL(sun4i_frontend_exit); +static bool sun4i_frontend_format_chroma_requires_swap(uint32_t fmt) +{ + switch (fmt) { + case DRM_FORMAT_YVU411: + case DRM_FORMAT_YVU420: + case DRM_FORMAT_YVU422: + case DRM_FORMAT_YVU444: + return true; + + default: + return false; + } +} + void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; dma_addr_t paddr; + bool swap; /* Set the line width */ DRM_DEBUG_DRIVER("Frontend stride: %d bytes\n", fb->pitches[0]); @@ -122,6 +137,13 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD1_REG, fb->pitches[1]); + if (fb->format->num_planes > 2) + regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD2_REG, + fb->pitches[2]); + + /* Some planar formats require chroma channel swapping by hand. */ + swap = sun4i_frontend_format_chroma_requires_swap(fb->format->format); + /* Set the physical address of the buffer in memory */ paddr = drm_fb_cma_get_gem_addr(fb, state, 0); paddr -= PHYS_OFFSET; @@ -129,12 +151,20 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, 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 = drm_fb_cma_get_gem_addr(fb, state, swap ? 2 : 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); } + + if (fb->format->num_planes > 2) { + paddr = drm_fb_cma_get_gem_addr(fb, state, swap ? 1 : 2); + paddr -= PHYS_OFFSET; + DRM_DEBUG_DRIVER("Setting buffer #2 address to %pad\n", &paddr); + regmap_write(frontend->regs, SUN4I_FRONTEND_BUF_ADDR2_REG, + paddr); + } } EXPORT_SYMBOL(sun4i_frontend_update_buffer); @@ -142,10 +172,14 @@ 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_411(fmt)) + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV411; 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 if (drm_format_is_yuv_sampling_444(fmt)) + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV444; else return -EINVAL; @@ -165,6 +199,10 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR; return 0; + case 3: + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR; + return 0; + default: return -EINVAL; } @@ -172,6 +210,12 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) { + /* Planar formats have an explicit input sequence. */ + if (drm_format_is_yuv_planar(fmt)) { + *val = 0; + return 0; + } + switch (fmt) { case DRM_FORMAT_BGRX8888: *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_BGRX; @@ -243,7 +287,15 @@ static const uint32_t sun4i_frontend_formats[] = { DRM_FORMAT_UYVY, DRM_FORMAT_VYUY, DRM_FORMAT_XRGB8888, + DRM_FORMAT_YUV411, + DRM_FORMAT_YUV420, + DRM_FORMAT_YUV422, + DRM_FORMAT_YUV444, DRM_FORMAT_YUYV, + DRM_FORMAT_YVU411, + DRM_FORMAT_YVU420, + DRM_FORMAT_YVU422, + DRM_FORMAT_YVU444, DRM_FORMAT_YVYU, }; diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 7d01b4f09b75..54ec71a3e2f4 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -23,15 +23,20 @@ #define SUN4I_FRONTEND_BUF_ADDR0_REG 0x020 #define SUN4I_FRONTEND_BUF_ADDR1_REG 0x024 +#define SUN4I_FRONTEND_BUF_ADDR2_REG 0x028 #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 #define SUN4I_FRONTEND_LINESTRD1_REG 0x044 +#define SUN4I_FRONTEND_LINESTRD2_REG 0x048 #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c +#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR (0 << 8) #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_YUV444 (0 << 4) #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_YUV411 (3 << 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 diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 80c718f06ce8..2fb27819ad20 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -143,7 +143,15 @@ static const uint32_t sun4i_layer_formats[] = { DRM_FORMAT_UYVY, DRM_FORMAT_VYUY, DRM_FORMAT_XRGB8888, + DRM_FORMAT_YUV411, + DRM_FORMAT_YUV420, + DRM_FORMAT_YUV422, + DRM_FORMAT_YUV444, DRM_FORMAT_YUYV, + DRM_FORMAT_YVU411, + DRM_FORMAT_YVU420, + DRM_FORMAT_YVU422, + DRM_FORMAT_YVU444, DRM_FORMAT_YVYU, }; From patchwork Fri Nov 23 09:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695515 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 7456913AD for ; Fri, 23 Nov 2018 10:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 648012C471 for ; Fri, 23 Nov 2018 10:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 590D52C47B; Fri, 23 Nov 2018 10:00:24 +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 014132C471 for ; Fri, 23 Nov 2018 10:00:24 +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=39HZodmzpo7gvEk7rZUa38F0TrexR3AsilQymlZURIo=; b=uB+AIn1qTXHFMo FbV/eNKifiFOQXnDtQIryzfAgI1w0yRCPowmVU2D/WVb5CPNKtD37NcLjfm9kkRviHDKS8HXIss2n emJUdj15Fte40ctRCsiEzZhZHXt5o+DsIOnnViVAix82grm4VlG2iopctCs8MwzRmJ5aoHAmS7TzZ 5ABOt6yd1Ay/SIwb8GlTPlT27rnSi9a4OJ2//KWI0XJ4cWDGYwC6y4pYWHssaT6L6eRcJxeJ1o+oh A2nwl0m4bQzrWpaR7QtIuzikYUA0++8AEmZrKhIskcaVXCspIOmhIRoO+QDvec5k7fvyDroUsZtMx ikYeiFVKIxfs+C2AiMPA==; 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 1gQ8G5-0002iu-JC; Fri, 23 Nov 2018 10:00:21 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kD-0002WS-Ez for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:27:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ROtS7LYUu29YHaE2ZCPLNtKDBtEAoABvtSUe06zQspc=; b=mu+vvd1Q95jGyQ0OUBFnIhY/AS ZYOO1xCriHc839BIVgvIB9RN6sUhjVQxghEAs5Xw0/UPQ5NLfOlUJwBlJGR12zgUnj0CMiLXMY7wI eBguG/bACXKJirR3ACho0nhWWcFoy7wX56m/s6acriQZKt0M7QGt0VPKMegGVoSUS1bX66Rmakxio 439kJQHHPclmDwC9FrpFtiokb7/nRtwfmGlXzpuxq57Pcbb3f/opZ5CJ61X+74vfSdHcfdfeVe01I 3G1I55yeIc/p4Qg+0+kVbqocUoWBfgDxefSqQWh0GrHM1wlv/EZU2f/5WsgHiR7YZbmTfpSiRXBjW zY/7ZOKw==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kA-0006XK-Vj for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id AAD6920E13; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 1A5CC20EB0; Fri, 23 Nov 2018 10:26:35 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 29/43] drm/sun4i: Make pitch even for GEM dumb alloc as per hardware constraint Date: Fri, 23 Nov 2018 10:25:01 +0100 Message-Id: <20181123092515.2511-30-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_042723_128485_7CA0E53F X-CRM114-Status: GOOD ( 14.40 ) 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 Our hardware requires the pitch to be an even number when using YUV formats with the frontend. Implement a driver-specific callback for GEM dumb allocation that sets the pitch accordingly. Since only the bpp is passed (and not the format), we cannot really distinguish if this alignment is really required. Since it doesn't hurt to align the pitch anyway, always do it. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_drv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index ef773d36baf0..ccdeae6299eb 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -28,6 +28,16 @@ #include "sun4i_tcon.h" #include "sun8i_tcon_top.h" +static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, + struct drm_device *drm, + struct drm_mode_create_dumb *args) +{ + /* The hardware only allows even pitches for YUV buffers. */ + args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), 2); + + return drm_gem_cma_dumb_create_internal(file_priv, drm, args); +} + DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops); static struct drm_driver sun4i_drv_driver = { @@ -42,7 +52,7 @@ static struct drm_driver sun4i_drv_driver = { .minor = 0, /* GEM Operations */ - .dumb_create = drm_gem_cma_dumb_create, + .dumb_create = drm_sun4i_gem_dumb_create, .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, From patchwork Fri Nov 23 09:25: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: 10695397 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 E33AE1709 for ; Fri, 23 Nov 2018 09:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D23C62C2AB for ; Fri, 23 Nov 2018 09:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C688D2C2B9; Fri, 23 Nov 2018 09:29:54 +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 579652C2AB for ; Fri, 23 Nov 2018 09:29:54 +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=ENYUywZO/9BoBQ3rjBkZBSu+c6cKbwWRMSjl/906/gk=; b=JvLEY9ue1+KpCC +O/RrzmRnERxcyrgm2fqpbs1L4hbEv8q3tAxXh9an+VbbtLhhmrdBTxviXQ0ApJyGQmIq/ozmx2Ux 2vD/2Lei61FRK7C+blC1f/OJ8uy55Ohn+oTGCXYGqLq6HnYd/RgEOtLDPavvzJpdeZx096xxtkG09 42X0zMA3UJp6z+NugyImwBf00zZruPneZGqchZqxV0uRWcwmmqx6L3fZnEOyCmIUEhVBNv9QIkZI4 gf5TOSGj2lwpejt8PDldMpqWoavr6ZvVf9xl8CqExcWkGjZqsAXl00acAecE/BGxK6PJd+8w/tMS/ n9xfpS3M14FroCvhu7gw==; 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 1gQ7mb-0005vR-3K; Fri, 23 Nov 2018 09:29:53 +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 1gQ7k2-0001qN-H9 for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:20 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id B40EE20E3C; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 5BBF220EB2; Fri, 23 Nov 2018 10:26:35 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 30/43] drm/fourcc: Add definitions for Allwinner vendor and VPU tiled format Date: Fri, 23 Nov 2018 10:25:02 +0100 Message-Id: <20181123092515.2511-31-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012714_821514_24C68FD3 X-CRM114-Status: GOOD ( 11.14 ) 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 This introduces specific definitions for vendor Allwinner and its associated tiled format modifier. This modifier is used for the output format of the VPU, that can be imported directly with the display engine hardware supported by the sun4i-drm driver. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- include/uapi/drm/drm_fourcc.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index e7e48f1f4a74..841535172507 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -237,6 +237,8 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 +#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 + /* add more to the end as needed */ #define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) @@ -643,6 +645,20 @@ extern "C" { */ #define AFBC_FORMAT_MOD_SC (1ULL << 9) +/* + * Allwinner tiled modifier + * + * This tiling mode is implemented by the VPU found on all Allwinner platforms, + * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3 + * planes. + * + * With this tiling, the luminance samples are disposed in tiles representing + * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels. + * The pixel order in each tile is linear and the tiles are disposed linearly, + * both in row-major order. + */ +#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) + #if defined(__cplusplus) } #endif From patchwork Fri Nov 23 09:25:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695475 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 0B1E31709 for ; Fri, 23 Nov 2018 09:45:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECD232C2DE for ; Fri, 23 Nov 2018 09:45:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E130A2C324; Fri, 23 Nov 2018 09:45:36 +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 66AB32C2E1 for ; Fri, 23 Nov 2018 09:45:36 +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=moZzdHTW74/RSEV7UOFZYtiTsBBy8d6ocwHRRTZ7VIM=; b=JXrCZEfvNRy40P AgQw3FQ8nSFfCdDKixhEb1ATqezVIBXbfh0Ds1aXZhkiv9J1tA9+Rwojo6YtDn5qLX/ilczMEOwzl TMSXCrKRqxEWIYtDdGAmLXCgMNUyUtMerWnxPeWz6Wh6A6UsZ+dNAOWy/bifWpbAThHjyPwb5ezBM kHNnFqssEKNTWy+p6nlI2R/71B49Z7HnVESraLKInizGm9KR4E9bYmw8SETVS02c07akg4OoY0XsY 4eupsopG3tnCuW52nW0mlyz5lG9SWW6GaaG6lB1uHITvN7eemU4wYx1jfGSiyxj5N002ji7zy7uxC tLE7mu8tDuvgm2NG8jhw==; 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 1gQ81m-00020T-DT; Fri, 23 Nov 2018 09:45:34 +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 1gQ7k2-0001q0-Rj for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:21 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id ECCB62160D; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 9CAFA20EB7; Fri, 23 Nov 2018 10:26:35 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 31/43] drm/sun4i: Add a dedicated ioctl call for allocating tiled buffers Date: Fri, 23 Nov 2018 10:25:03 +0100 Message-Id: <20181123092515.2511-32-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012715_200326_5DD28E18 X-CRM114-Status: GOOD ( 20.44 ) 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 This introduces a dedicated ioctl for allocating buffers for the VPU tiling mode. It allows setting up buffers that comply to the hardware alignment requirements, by aligning the stride and height to 32 bytes. Only YUV semiplanar and planar formats are allowed by the ioctl, as the hardware does not support the tiling mode for other formats. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_drv.c | 89 +++++++++++++++++++++++++++++++ include/uapi/drm/sun4i_drm.h | 42 +++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 include/uapi/drm/sun4i_drm.h diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index ccdeae6299eb..5ae32973cf34 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "sun4i_drv.h" #include "sun4i_frontend.h" @@ -28,6 +29,92 @@ #include "sun4i_tcon.h" #include "sun8i_tcon_top.h" +int drm_sun4i_gem_create_tiled(struct drm_device *drm, void *data, + struct drm_file *file_priv) +{ + struct drm_sun4i_gem_create_tiled *args = data; + struct drm_gem_cma_object *cma_obj; + struct drm_gem_object *gem_obj; + uint32_t luma_stride, chroma_stride; + uint32_t luma_height, chroma_height; + uint32_t chroma_width; + const struct drm_format_info *info; + int ret; + + info = drm_format_info(args->format); + if (!info) + return -EINVAL; + + /* The tiled output format only applies to non-packed YUV formats. */ + if (!info->is_yuv || info->num_planes == 1) + return -EINVAL; + + memset(args->pitches, 0, sizeof(args->pitches)); + memset(args->offsets, 0, sizeof(args->offsets)); + + /* Stride and height are aligned to 32 bytes for our tiled format. */ + luma_stride = ALIGN(args->width, 32); + luma_height = ALIGN(args->height, 32); + + chroma_width = args->width; + + /* Semiplanar formats have both U and V data in their chroma plane. */ + if (drm_format_info_is_yuv_semiplanar(info)) + chroma_width *= 2; + + chroma_stride = ALIGN(DIV_ROUND_UP(chroma_width, info->hsub), 32); + chroma_height = ALIGN(DIV_ROUND_UP(args->height, info->vsub), 32); + + if (drm_format_info_is_yuv_semiplanar(info)) { + args->pitches[0] = luma_stride; + args->pitches[1] = chroma_stride; + + args->offsets[0] = 0; + args->offsets[1] = luma_stride * luma_height; + + args->size = luma_stride * luma_height + + chroma_stride * chroma_height; + } else if (drm_format_info_is_yuv_planar(info)) { + args->pitches[0] = luma_stride; + args->pitches[1] = chroma_stride; + args->pitches[2] = chroma_stride; + + args->offsets[0] = 0; + args->offsets[1] = luma_stride * luma_height; + args->offsets[2] = luma_stride * luma_height + + chroma_stride * chroma_height; + + args->size = luma_stride * luma_height + + chroma_stride * chroma_height * 2; + } else { + /* No support for other formats in tiled mode. */ + return -EINVAL; + } + + cma_obj = drm_gem_cma_create(drm, args->size); + if (IS_ERR(cma_obj)) + return PTR_ERR(cma_obj); + + gem_obj = &cma_obj->base; + + /* + * allocate a id of idr table where the obj is registered + * and handle has the id what user can see. + */ + ret = drm_gem_handle_create(file_priv, gem_obj, &args->handle); + /* drop reference from allocate - handle holds it now. */ + drm_gem_object_put_unlocked(gem_obj); + if (ret) + return ret; + + return PTR_ERR_OR_ZERO(cma_obj); +} + +static const struct drm_ioctl_desc sun4i_drv_ioctls[] = { + DRM_IOCTL_DEF_DRV(SUN4I_GEM_CREATE_TILED, drm_sun4i_gem_create_tiled, + DRM_UNLOCKED), +}; + static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, struct drm_device *drm, struct drm_mode_create_dumb *args) @@ -44,6 +131,8 @@ static struct drm_driver sun4i_drv_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, /* Generic Operations */ + .ioctls = sun4i_drv_ioctls, + .num_ioctls = ARRAY_SIZE(sun4i_drv_ioctls), .fops = &sun4i_drv_fops, .name = "sun4i-drm", .desc = "Allwinner sun4i Display Engine", diff --git a/include/uapi/drm/sun4i_drm.h b/include/uapi/drm/sun4i_drm.h new file mode 100644 index 000000000000..2c77584b057b --- /dev/null +++ b/include/uapi/drm/sun4i_drm.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* sun4i_drm.h + * + * Copyright (C) 2018 Paul Kocialkowski + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_SUN4I_DRM_H_ +#define _UAPI_SUN4I_DRM_H_ + +#include "drm.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +struct drm_sun4i_gem_create_tiled { + __u32 height; + __u32 width; + __u32 format; + /* handle, offsets, pitches, size will be returned */ + __u32 handle; + __u32 pitches[4]; + __u32 offsets[4]; + __u64 size; +}; + +#define DRM_SUN4I_GEM_CREATE_TILED 0x00 + +#define DRM_IOCTL_SUN4I_GEM_CREATE_TILED \ + DRM_IOWR(DRM_COMMAND_BASE + DRM_SUN4I_GEM_CREATE_TILED, \ + struct drm_sun4i_gem_create_tiled) + +#if defined(__cplusplus) +} +#endif + +#endif /* _UAPI_SUN4I_DRM_H_ */ From patchwork Fri Nov 23 09:25:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695401 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 B4794175A for ; Fri, 23 Nov 2018 09:30:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2D482C2B9 for ; Fri, 23 Nov 2018 09:30:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 972102C2C7; Fri, 23 Nov 2018 09:30:21 +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 3634D2C2B9 for ; Fri, 23 Nov 2018 09:30:21 +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=6ywjZf+jzHOqlryLroQ/2/kNCmKCm67xNUx4mVbTbck=; b=hyAsJTv0EBezfK c0fkNuK0/girZTTogh1nZuOdJbxOxq30+e+yirXrTzuqyQ8Hg2SnHsSJzjwNXqY7NsQ2fc9AfznrH bprzoP5H5VBEaAPiVbIyZxHuKeK67xYRnoNU5GZngXNFmuNocIh8E08PGkN5k54QN3xMmykRcbVW8 45lpfYOOXbnH12gTykmcuKGEmyFZ5kor2BGa2M/wMDHzU+7dasN+74pGHTf9sVDMDVKWU0ijTHTY1 ivBgi4o/tUohsJfd4NjTu+GOHfzL/Y32jyggwaNuiu1mFDAPJJpXs5bC6SytdLfr34Tt6RB6om36D YTEdepvDxkaXlQ8OWaJA==; 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 1gQ7n1-0007hd-9h; Fri, 23 Nov 2018 09:30:19 +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 1gQ7k3-0001qd-7x for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:21 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 0215720F10; Fri, 23 Nov 2018 10:26:59 +0100 (CET) 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 E1C8C20EB8; Fri, 23 Nov 2018 10:26:35 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 32/43] drm/sun4i: Pass modifier to backend and frontend format support helpers Date: Fri, 23 Nov 2018 10:25:04 +0100 Message-Id: <20181123092515.2511-33-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012715_610299_9B61A37A X-CRM114-Status: GOOD ( 12.40 ) 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 To prepare the introduction of tiled mode support, pass the framebuffer format modifier to the helpers dealing with format support. Since only linear mode is supported for now, add corresponding checks in each helper. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 10 +++++++--- drivers/gpu/drm/sun4i/sun4i_backend.h | 2 +- drivers/gpu/drm/sun4i/sun4i_frontend.c | 5 ++++- drivers/gpu/drm/sun4i/sun4i_frontend.h | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 986bdb64521c..bbadc2ab9f4d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -175,10 +175,13 @@ static const uint32_t sun4i_backend_formats[] = { DRM_FORMAT_YVYU, }; -bool sun4i_backend_format_is_supported(uint32_t fmt) +bool sun4i_backend_format_is_supported(uint32_t fmt, uint64_t modifier) { unsigned int i; + if (modifier != DRM_FORMAT_MOD_LINEAR) + return false; + for (i = 0; i < ARRAY_SIZE(sun4i_backend_formats); i++) if (sun4i_backend_formats[i] == fmt) return true; @@ -455,14 +458,15 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state) struct sun4i_layer *layer = plane_to_sun4i_layer(state->plane); struct sun4i_backend *backend = layer->backend; uint32_t format = state->fb->format->format; + uint64_t modifier = state->fb->modifier; if (IS_ERR(backend->frontend)) return false; - if (!sun4i_frontend_format_is_supported(format)) + if (!sun4i_frontend_format_is_supported(format, modifier)) return false; - if (!sun4i_backend_format_is_supported(format)) + if (!sun4i_backend_format_is_supported(format, modifier)) return true; /* diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.h b/drivers/gpu/drm/sun4i/sun4i_backend.h index 93db3af675b3..01f66463271b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.h +++ b/drivers/gpu/drm/sun4i/sun4i_backend.h @@ -198,7 +198,7 @@ engine_to_sun4i_backend(struct sunxi_engine *engine) void sun4i_backend_layer_enable(struct sun4i_backend *backend, int layer, bool enable); -bool sun4i_backend_format_is_supported(uint32_t fmt); +bool sun4i_backend_format_is_supported(uint32_t fmt, uint64_t modifier); int sun4i_backend_update_layer_coord(struct sun4i_backend *backend, int layer, struct drm_plane *plane); int sun4i_backend_update_layer_formats(struct sun4i_backend *backend, diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 001139417cf5..b78e0a208c95 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -299,10 +299,13 @@ static const uint32_t sun4i_frontend_formats[] = { DRM_FORMAT_YVYU, }; -bool sun4i_frontend_format_is_supported(uint32_t fmt) +bool sun4i_frontend_format_is_supported(uint32_t fmt, uint64_t modifier) { unsigned int i; + if (modifier != DRM_FORMAT_MOD_LINEAR) + return false; + for (i = 0; i < ARRAY_SIZE(sun4i_frontend_formats); i++) if (sun4i_frontend_formats[i] == fmt) return true; diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 54ec71a3e2f4..b209eacdf8c2 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -115,6 +115,6 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, struct drm_plane *plane); int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, struct drm_plane *plane, uint32_t out_fmt); -bool sun4i_frontend_format_is_supported(uint32_t fmt); +bool sun4i_frontend_format_is_supported(uint32_t fmt, uint64_t modifier); #endif /* _SUN4I_FRONTEND_H_ */ From patchwork Fri Nov 23 09:25:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695437 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 BEC775A4 for ; Fri, 23 Nov 2018 09:43:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACD9A2BE94 for ; Fri, 23 Nov 2018 09:43:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A07DD2BFC6; Fri, 23 Nov 2018 09:43:02 +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 793F22C06D for ; Fri, 23 Nov 2018 09:43:01 +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=gjBxergjkIrPkF2g/6f68bGD5p4iLb+HTqOCWYfTUJY=; b=AzuyrbovqYXpDy kHP+Z4H/coJjIU1hnye0EeNXlLs5BZdbvbn6Ir/Sc90vr2vfIGCpKraZO0KrYOyzrKuebchG/SIc4 AXfzr03y4iDNnDF5G8P+QbEFW67cKj2iBaT8BnjFVs92SxDCpgLzNTDF1+ImY/Mv8MrWNkAFvrynI kzGbkgp5B5VJMjBvRadhfaW4Wozx9V0jFqn9EXUvLS+uxAr6dAdlONbg9hj7HbvDfXakqM5U8Ba+g fATS4sxeX1QsQbIY+mVvdAYdADXdO1oN4F6j4h6NI0r99AwcCNl7o9Nt/5iYqyM9SY3tseNYpGbNw FSTV8XVOZj7xwSVB1Sfw==; 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 1gQ7zH-0007Ar-7t; Fri, 23 Nov 2018 09:42:59 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7yr-0006Dm-3X for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:42:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GkLrgYXYwSMpwuLWsdnOIwm3V2t7dWya3GzbV6GhLzU=; b=gv3PZNfLU0we5wB/0RwURbctYA E9NoV045HTzsWy5DxG8/a8DlBlaRZdVHTjsDh1JOYRov3YX/63nxCTXf4FYQoJDXo7BHzps8EOXjW d3k2rn65Of+9ai0cFdqG+ayH8YwPDkE+tnFpK6o0ieI8VkKhwb9RqdjTtfO06JQOh3pUYjghnPhI7 dQeVdWILu/803G9GEIy41nsbKcD4RKNmh5ZV1YRv8x7j4JwjLdf7WEezU0gRvCs3CF+EtnRYVE6T1 noRHH10I+TwF1Ts4JZcHeaThtAiM5h0t8WS2j4XyRH4rNjaOUx7yv9fIvNrnNMwo4nk8u4M7dbQdm UVD0Fh8Q==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k6-0006BR-CG for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:25 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 0C44720EB8; Fri, 23 Nov 2018 10:26:59 +0100 (CET) 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 2E69620EC0; Fri, 23 Nov 2018 10:26:36 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 33/43] drm/sun4i: frontend: Add support for tiled YUV input mode configuration Date: Fri, 23 Nov 2018 10:25:05 +0100 Message-Id: <20181123092515.2511-34-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_092718_535746_BEF75732 X-CRM114-Status: GOOD ( 14.75 ) 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 This introduces the data input mode definitions for the tiled YUV mode, that are used in the input mode helper if tiling is requested. The modifier is passed to the helper from the framebuffer to determine if tiling is requested. Only semiplanar and planar YUV formats are supported for tiling mode. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 14 ++++++++++---- drivers/gpu/drm/sun4i/sun4i_frontend.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index b78e0a208c95..efa1ff0802bd 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -186,9 +186,11 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) return 0; } -static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) +static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, + uint64_t modifier, u32 *val) { int num_planes = drm_format_num_planes(fmt); + bool tiled = (modifier == DRM_FORMAT_MOD_ALLWINNER_TILED); switch (num_planes) { case 1: @@ -196,11 +198,13 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) return 0; case 2: - *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR; + *val = tiled ? SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_SEMIPLANAR + : SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_SEMIPLANAR; return 0; case 3: - *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR; + *val = tiled ? SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_PLANAR + : SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR; return 0; default: @@ -320,6 +324,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; uint32_t format = fb->format->format; + uint64_t modifier = fb->modifier; u32 out_fmt_val; u32 in_fmt_val, in_mod_val, in_ps_val; unsigned int i; @@ -332,7 +337,8 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, return ret; } - ret = sun4i_frontend_drm_format_to_input_mode(format, &in_mod_val); + ret = sun4i_frontend_drm_format_to_input_mode(format, modifier, + &in_mod_val); if (ret) { DRM_DEBUG_DRIVER("Invalid input mode\n"); return ret; diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index b209eacdf8c2..ae53ee644694 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -33,6 +33,8 @@ #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PLANAR (0 << 8) #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_MOD_MB32_PLANAR (4 << 8) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_MB32_SEMIPLANAR (6 << 8) #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV444 (0 << 4) #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV422 (1 << 4) #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_YUV420 (2 << 4) From patchwork Fri Nov 23 09:25:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695485 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 F1E401709 for ; Fri, 23 Nov 2018 09:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF2EE2C2DE for ; Fri, 23 Nov 2018 09:46:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D05902C324; Fri, 23 Nov 2018 09:46:28 +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 61F122C2DE for ; Fri, 23 Nov 2018 09:46:28 +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=bY0XlHwjh5nmmPPMyOWx8ryV3k+xAvUJbOObaGPrQjc=; b=leTihzDQ7lmVA7 2RNR4C2cR6AeWaiih1r8htp5MZDo9I/y1PM3OKqu9AIun6S9+5vSF1iAaD9efMGWyO+zT8MvNMRP8 XENuTHpZtP47Kh1fBO/bH/SP4jWk7vTAiksrDQqncaoaqE5AzcVL3dmKnFCCDc47GAeyKW36kMRGA ATR13VPx0xoqIGS2FlVeGfQCUBCJ3nN9m76LO28vtuWijbcgClLAH79PCJkb/cBaUAEWsuhVJ62ef 96Lt1iqaig47ud5RGAh82qjXp+O+9JDheWBvfYAGr1hSF4hJIUXLwEv9SdZri6uTdfhbXwANns8sa bXdQ5z6VwMye6m/8HvdA==; 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 1gQ82X-00032B-ED; Fri, 23 Nov 2018 09:46:21 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7kD-0002Ul-F6 for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Nov 2018 09:27:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1vLlYOR3uHZdIAjkhRPGK48bqTBk2wZ2ydDd8Ddh4NI=; b=B2g2ryrmm4Ry1PfumfP7DSXj74 x0cpFmF+U2KRq8vZltEzLu2ZsccwXfbkM3O2/u/yG59VkfzWBggHNQ1PLZgxNCM2hjTuKJXPefz7N 38HVoFuqSpqfWZBn13dUEA4DHDrBZpyf+XLNbMYO1VzlOLdD6tKzcZ8G1TbHV1NNu+87lJBeJDrOZ XfA1B1NyaIjUG8uQlmkEISFO1HYUSOsRbA+7zCqqmn8Ufj8zewuLORdnGnU9hpzh6FMvXNt9zQ6RH +i9TnZQb8d59JoT2b6E/cN6Qfla/M4/N1GPi7fSSF0q2EDR1LjLeyh8i3hmdlSgR8i4s6178vGqno cOFHFl2g==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQ7k8-0006Xd-9Q for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:22 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id F1D852160C; Fri, 23 Nov 2018 10:26:58 +0100 (CET) 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 6F06A20F10; Fri, 23 Nov 2018 10:26:36 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 34/43] drm/sun4i: Add buffer stride and offset configuration for tiling mode Date: Fri, 23 Nov 2018 10:25:06 +0100 Message-Id: <20181123092515.2511-35-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_042720_597611_4807ED8C X-CRM114-Status: GOOD ( 17.31 ) 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 This introduces stride and offset configuration for the VPU tiling mode. Stride is calculated differently than it is for linear formats and an offset is calculated, for which new register definitions are introduced. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 54 ++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun4i_frontend.h | 7 ++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index efa1ff0802bd..3f76a5572449 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -125,21 +125,69 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, { struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; + unsigned int strides[3] = {}; + dma_addr_t paddr; bool swap; + if (fb->modifier == DRM_FORMAT_MOD_ALLWINNER_TILED) { + unsigned int width = state->src_w >> 16; + unsigned int offset; + + /* + * In MB32 tiled mode, the stride is defined as the distance + * between the start of the end line of the current tile and + * the start of the first line in the next vertical tile. + * + * Tiles are represented in row-major order, thus the end line + * of current tile starts at: 31 * 32 (31 lines of 32 cols), + * the next vertical tile starts at: 32-bit-aligned-width * 32 + * and the distance is: 32 * (32-bit-aligned-width - 31). + */ + + strides[0] = (fb->pitches[0] - 31) * 32; + + /* Offset of the bottom-right point in the end tile. */ + offset = (width + (32 - 1)) & (32 - 1); + + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF0_REG, + SUN4I_FRONTEND_TB_OFF_X1(offset)); + + if (fb->format->num_planes > 1) { + strides[1] = (fb->pitches[1] - 31) * 32; + + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF1_REG, + SUN4I_FRONTEND_TB_OFF_X1(offset)); + } + + if (fb->format->num_planes > 2) { + strides[2] = (fb->pitches[2] - 31) * 32; + + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF2_REG, + SUN4I_FRONTEND_TB_OFF_X1(offset)); + } + } else { + strides[0] = fb->pitches[0]; + + if (fb->format->num_planes > 1) + strides[1] = fb->pitches[1]; + + if (fb->format->num_planes > 2) + strides[2] = fb->pitches[2]; + } + /* Set the line width */ DRM_DEBUG_DRIVER("Frontend stride: %d bytes\n", fb->pitches[0]); regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD0_REG, - fb->pitches[0]); + strides[0]); if (fb->format->num_planes > 1) regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD1_REG, - fb->pitches[1]); + strides[1]); if (fb->format->num_planes > 2) regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD2_REG, - fb->pitches[2]); + strides[2]); /* Some planar formats require chroma channel swapping by hand. */ swap = sun4i_frontend_format_chroma_requires_swap(fb->format->format); diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index ae53ee644694..822d39ca4b8e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -25,6 +25,13 @@ #define SUN4I_FRONTEND_BUF_ADDR1_REG 0x024 #define SUN4I_FRONTEND_BUF_ADDR2_REG 0x028 +#define SUN4I_FRONTEND_TB_OFF0_REG 0x030 +#define SUN4I_FRONTEND_TB_OFF1_REG 0x034 +#define SUN4I_FRONTEND_TB_OFF2_REG 0x038 +#define SUN4I_FRONTEND_TB_OFF_X1(x1) ((x1) << 16) +#define SUN4I_FRONTEND_TB_OFF_Y0(y0) ((y0) << 8) +#define SUN4I_FRONTEND_TB_OFF_X0(x0) (x0) + #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 #define SUN4I_FRONTEND_LINESTRD1_REG 0x044 #define SUN4I_FRONTEND_LINESTRD2_REG 0x048 From patchwork Fri Nov 23 09:25:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695473 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 A2F3C5A4 for ; Fri, 23 Nov 2018 09:45:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89FEF2C2DE for ; Fri, 23 Nov 2018 09:45:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E7782C34A; Fri, 23 Nov 2018 09:45:36 +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 1B5622C2DE for ; Fri, 23 Nov 2018 09:45:36 +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=xcKYVdpL1m+fUFN/Qm/Gk+u412uHYqpnkFlbSEuYILk=; b=hl6yMvvmAeWfz9 LC/6TYffZu5rJ5jGSg6M/j/3fbjKDbIXYwA6CEqKW9c73ayr/8UYmIGpCWLc/88TFz0x0jVB86Onp tfvus86P173IE3ot3+qLArhQYrYWv8A4IU4aFTqwNnGfu2M1glCKY751t1oygieXg8hHNfYLePMDN K4EblAMt6XgpRonuGSMAy/i9dtEUBJs0paM+mdJcwLb4CgTkYZcW9BYeEBnHxFwSFeLjMxMT72KN0 54IGXoYA+6AEQu0cOnRWVKaYo9tp+QD4/Vh1dOjTx4W3hOZvJDrU6R/nb2G9XakDsVtccvUyNxUv2 ZxwBcTTqFAjzNjftSVUQ==; 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 1gQ81l-0001y2-N3; Fri, 23 Nov 2018 09:45:33 +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 1gQ7k3-0001qL-Gh for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:21 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 15E9221667; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 AF7B320F45; Fri, 23 Nov 2018 10:26:36 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 35/43] drm/sun4i: frontend: Add and use helper for checking tiling support Date: Fri, 23 Nov 2018 10:25:07 +0100 Message-Id: <20181123092515.2511-36-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012715_730002_FB1B16E7 X-CRM114-Status: GOOD ( 12.75 ) 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 This introduces a helper to check whether a frontend input format supports tiling mode. This helper is used when tiling is requested in the frontend format support helper. Only semiplanar and planar YUV formats are supported by the hardware. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 3f76a5572449..b9c18fa2fff3 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -120,6 +120,26 @@ static bool sun4i_frontend_format_chroma_requires_swap(uint32_t fmt) } } +static bool sun4i_frontend_format_supports_tiling(uint32_t fmt) +{ + switch (fmt) { + case DRM_FORMAT_NV12: + case DRM_FORMAT_NV16: + case DRM_FORMAT_NV21: + case DRM_FORMAT_NV61: + case DRM_FORMAT_YUV411: + case DRM_FORMAT_YUV420: + case DRM_FORMAT_YUV422: + case DRM_FORMAT_YVU420: + case DRM_FORMAT_YVU422: + case DRM_FORMAT_YVU411: + return true; + + default: + return false; + } +} + void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, struct drm_plane *plane) { @@ -355,7 +375,9 @@ bool sun4i_frontend_format_is_supported(uint32_t fmt, uint64_t modifier) { unsigned int i; - if (modifier != DRM_FORMAT_MOD_LINEAR) + if (modifier == DRM_FORMAT_MOD_ALLWINNER_TILED) + return sun4i_frontend_format_supports_tiling(fmt); + else if (modifier != DRM_FORMAT_MOD_LINEAR) return false; for (i = 0; i < ARRAY_SIZE(sun4i_frontend_formats); i++) From patchwork Fri Nov 23 09:25:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695477 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 73F795A4 for ; Fri, 23 Nov 2018 09:45:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 625E92C324 for ; Fri, 23 Nov 2018 09:45:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5386E2C3BB; Fri, 23 Nov 2018 09:45:58 +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 D34D22C324 for ; Fri, 23 Nov 2018 09:45:57 +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=DwssjzHBfwgHC5apZP7SdOT5aMNSumM/Up0frVcBz/A=; b=g/CNvIs8bZfP89 OxIbejsXzkVmISS7Ga0KPw/ARJGsbS7fQ1EyW/cq8ToHkXuuv0ZjgeCthsvxvaY13b+vHSyq0xm3P F+Nl7kEHoalFlR8DzeF61h2CnuqrACGUnY3BP0jHH4MzNOUQ5AkrjcL0ZF2ty2yhCyFLrMsvX5vPT cEtexC6i3FCf6poXQKBxDILSreod54YJMx1yDmm/N+zxrrxQ32VEt4Ok5wbQtRFaipUnCsxS54KGL PSiCU5JtslL5G4HfLqULrnqywoUWeklfeY82QeNAJWlvU7YQFJumliMnMgCIDgBly96dDkK0VAKgo 8/fwtP9f7Mr6KEEXxBFg==; 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 1gQ81z-0002IL-JL; Fri, 23 Nov 2018 09:45:47 +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 1gQ7k4-0001q1-SH for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 268F420F5D; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 EFDB220F4A; Fri, 23 Nov 2018 10:26:36 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 36/43] drm/sun4i: layer: Add tiled modifier support and helper Date: Fri, 23 Nov 2018 10:25:08 +0100 Message-Id: <20181123092515.2511-37-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012717_374740_F4A6A6B5 X-CRM114-Status: GOOD ( 13.56 ) 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 From: Paul Kocialkowski This introduces a list of supported modifiers for the driver, that includes the Allwinner tiled modifier, as well as a format_mod_supported callback. The callback uses both the backend and frontend helpers to indicate per-format modifier support (including for the linear modifier). Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_layer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 2fb27819ad20..a828572acdbb 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -113,6 +113,13 @@ static void sun4i_backend_layer_atomic_update(struct drm_plane *plane, sun4i_backend_layer_enable(backend, layer->id, true); } +static bool sun4i_layer_format_mod_supported(struct drm_plane *plane, + uint32_t format, uint64_t modifier) +{ + return sun4i_backend_format_is_supported(format, modifier) || + sun4i_frontend_format_is_supported(format, modifier); +} + static const struct drm_plane_helper_funcs sun4i_backend_layer_helper_funcs = { .atomic_disable = sun4i_backend_layer_atomic_disable, .atomic_update = sun4i_backend_layer_atomic_update, @@ -125,6 +132,7 @@ static const struct drm_plane_funcs sun4i_backend_layer_funcs = { .disable_plane = drm_atomic_helper_disable_plane, .reset = sun4i_backend_layer_reset, .update_plane = drm_atomic_helper_update_plane, + .format_mod_supported = sun4i_layer_format_mod_supported, }; static const uint32_t sun4i_layer_formats[] = { @@ -155,6 +163,12 @@ static const uint32_t sun4i_layer_formats[] = { DRM_FORMAT_YVYU, }; +static const uint64_t sun4i_layer_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_ALLWINNER_TILED, + DRM_FORMAT_MOD_INVALID +}; + static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm, struct sun4i_backend *backend, enum drm_plane_type type) @@ -171,7 +185,7 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm, &sun4i_backend_layer_funcs, sun4i_layer_formats, ARRAY_SIZE(sun4i_layer_formats), - NULL, type, NULL); + sun4i_layer_modifiers, type, NULL); if (ret) { dev_err(drm->dev, "Couldn't initialize layer\n"); return ERR_PTR(ret); From patchwork Fri Nov 23 09:25:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695403 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 11E8D175A for ; Fri, 23 Nov 2018 09:30:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00BB22C2C7 for ; Fri, 23 Nov 2018 09:30:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E92DE2C34A; Fri, 23 Nov 2018 09:30:41 +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 A48AB2C2D1 for ; Fri, 23 Nov 2018 09:30:41 +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=GrKcQVKkBGEhDVMoDKgM3zekPF4eUD0lGLp9aw8fExc=; b=WVvVgFu6k0FK6O 4CxtFLgMoSesdw9qXPGIFS3m/Lx8P/uVxJyQr/Kmt4K6YH7hYyzcjKxj8/nH8jF2RCtErRFghxkUS Z/KYXJ82FcqGGovI4zBhbXqznyStpQNs0TCYI+az/GJIrq67kP3kUdwJsDhcagr4NUQy8JHodrRNd gArtFtMLJn06SOWwFnwQB+TLtQCTNMrS2fcz5tIUV2yyt463LI0uus7CBklG66zk9CJa+R6ebis+9 31Faw88xJCeF8ZaXYLlzjdXMDV6jLo/ZOKEhBPca322wGK+Dvk/LX6e4JfZYGh0QFwZtMIdTbnVnl U5KrKOJhegr0SpdkfpnQ==; 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 1gQ7nM-00087L-4a; Fri, 23 Nov 2018 09:30:40 +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 1gQ7k4-0001qc-K5 for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 1C45A20F45; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 3C04220F5D; Fri, 23 Nov 2018 10:26:37 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 37/43] drm/sun4i: drv: Allow framebuffer modifiers in mode config Date: Fri, 23 Nov 2018 10:25:09 +0100 Message-Id: <20181123092515.2511-38-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012716_842897_2823CCFE X-CRM114-Status: GOOD ( 13.67 ) 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 From: Paul Kocialkowski This is the final step to indicate to the core that our driver supports framebuffer modifiers. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 5ae32973cf34..a041febe391a 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -186,6 +186,7 @@ static int sun4i_drv_bind(struct device *dev) } drm_mode_config_init(drm); + drm->mode_config.allow_fb_modifiers = true; ret = component_bind_all(drm->dev, drm); if (ret) { From patchwork Fri Nov 23 09:25:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695479 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 AFF8A5A4 for ; Fri, 23 Nov 2018 09:46:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DF752C324 for ; Fri, 23 Nov 2018 09:46:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91CC72C3BB; Fri, 23 Nov 2018 09:46:04 +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 4A9642C324 for ; Fri, 23 Nov 2018 09:46:04 +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=1cG4MTLkKJqrnGzGZ4GaSJJohTBQxFSM5BOwkX6yrak=; b=BFGdPawr8FyUv9 D8suBDyWHPW5ouQyKZ69jhJsFIg1K4WzexKvXFVWmSGW0IyCstnvEgIm/GXu378V9YAP96AiwPeDM 2IAXDznPu1xPEP5aDS6pYLFTJzgpV1EEEGY8+jTSPCJ44hU4sLhOu0VDgMJKRLsqQORVk2eczo9o6 TCV2pnZ9AIX9CaLDIZmPsCByRBoPXihgzcHMvhZfawTE2NkHfax3jd0qcJPqzkQcRMCHBB7Rng3jl tjWCsyL7gYlZNfXRreJCef91kEgLuSlNSanPCOyB1BI0tLsRbCMBSz1hz2B2p3Ttsrig/Z33c0E0X DjlrQNl8sAOe7wDq/bsg==; 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 1gQ82E-0002cL-LK; Fri, 23 Nov 2018 09:46:02 +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 1gQ7k6-0001q2-DY for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:23 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 29ADF20F4A; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 7CF3920F6A; Fri, 23 Nov 2018 10:26:37 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 38/43] drm/sun4i: Move access control before setting the register as documented Date: Fri, 23 Nov 2018 10:25:10 +0100 Message-Id: <20181123092515.2511-39-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012718_701200_7FA956E6 X-CRM114-Status: GOOD ( 12.09 ) 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, 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 From: Maxime Ripard Unlike what is currently being done, the ACCESS_CTRL bit documentation asks that this bit should be set before modifying any register. The code in the BSP also does this, so make sure we do this as well. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index b9c18fa2fff3..2c9dcb4ffde0 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -74,6 +74,10 @@ static void sun4i_frontend_scaler_init(struct sun4i_frontend *frontend) { int i; + regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, + SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL, + SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL); + for (i = 0; i < 32; i++) { regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZCOEF0_REG(i), sun4i_frontend_horz_coef[2 * i]); @@ -89,9 +93,6 @@ static void sun4i_frontend_scaler_init(struct sun4i_frontend *frontend) sun4i_frontend_vert_coef[i]); } - regmap_update_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, - SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL, - SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL); } int sun4i_frontend_init(struct sun4i_frontend *frontend) From patchwork Fri Nov 23 09:25:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695483 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 9A4A71709 for ; Fri, 23 Nov 2018 09:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 887AE2C324 for ; Fri, 23 Nov 2018 09:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CD022C3BB; Fri, 23 Nov 2018 09:46:20 +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 22E6B2C324 for ; Fri, 23 Nov 2018 09:46:20 +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=lIR00ftqS/m7kHm6OHvXqFS8dAR3Xe5MFYpNVM0VSaU=; b=mel/kt6f8lymdE ubsa9N+LHXHDQikNCId6Nh163a0Fy0wvY6/xTW3I+uw+Ms6No0Nng+i9piY90ToDkIJf6cXNRBFpW 4xe/xG3HH5/oATsZUyuF0v0SPBWGnOpt+6T07/Kznb/v0ieb11n2Bh3DK4nZEcZV9kxtG78DpBfd1 lQicetpvsxY4oP6+L6Y0n6nCjlk+hAr+W9jJsOFljjUPO0HcYwjPyCql/F36mua2BtrBM6625Yzqz m5H0y7qlff41/q3hM6sNJGXn3pOXO+lzjsrOuoy7c6cR4Ei1rXUS5M3hOwmJ/AbEuKHGv3O6Tyk6J c6opYHJwGrvNQFLlpATw==; 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 1gQ82U-0002vj-0I; Fri, 23 Nov 2018 09:46:18 +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 1gQ7k7-0001qO-GJ for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:25 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 3B30320F6A; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 BABA520F75; Fri, 23 Nov 2018 10:26:37 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 39/43] drm/sun4i: frontend: Add a quirk structure Date: Fri, 23 Nov 2018 10:25:11 +0100 Message-Id: <20181123092515.2511-40-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012719_943235_84E4ACD8 X-CRM114-Status: GOOD ( 15.88 ) 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, 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 From: Maxime Ripard The ACCESS_CTRL bit is not found on all the variants of the frontend, so let's introduce a structure that will hold whether or not we need to set it, and associate it with the compatible. This will be extended for further similar quirks later on. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 21 +++++++++++++++++---- drivers/gpu/drm/sun4i/sun4i_frontend.h | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 2c9dcb4ffde0..368391a9e5fd 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -74,9 +75,10 @@ static void sun4i_frontend_scaler_init(struct sun4i_frontend *frontend) { int i; - regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, - SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL, - SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL); + if (frontend->data->has_coef_access_ctrl) + regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, + SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL, + SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL); for (i = 0; i < 32; i++) { regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZCOEF0_REG(i), @@ -547,6 +549,10 @@ static int sun4i_frontend_bind(struct device *dev, struct device *master, frontend->dev = dev; frontend->node = dev->of_node; + frontend->data = of_device_get_match_data(dev); + if (!frontend->data) + return -ENODEV; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_ioremap_resource(dev, res); if (IS_ERR(regs)) @@ -659,8 +665,15 @@ static const struct dev_pm_ops sun4i_frontend_pm_ops = { .runtime_suspend = sun4i_frontend_runtime_suspend, }; +static const struct sun4i_frontend_data sun8i_a33_frontend = { + .has_coef_access_ctrl = true, +}; + const struct of_device_id sun4i_frontend_of_table[] = { - { .compatible = "allwinner,sun8i-a33-display-frontend" }, + { + .compatible = "allwinner,sun8i-a33-display-frontend", + .data = &sun8i_a33_frontend + }, { } }; EXPORT_SYMBOL(sun4i_frontend_of_table); diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 822d39ca4b8e..daf3fa5d01ba 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -100,6 +100,10 @@ struct drm_plane; struct regmap; struct reset_control; +struct sun4i_frontend_data { + bool has_coef_access_ctrl; +}; + struct sun4i_frontend { struct list_head list; struct device *dev; @@ -110,6 +114,8 @@ struct sun4i_frontend { struct clk *ram_clk; struct regmap *regs; struct reset_control *reset; + + const struct sun4i_frontend_data *data; }; extern const struct of_device_id sun4i_frontend_of_table[]; From patchwork Fri Nov 23 09:25:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695481 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 61DDA5A4 for ; Fri, 23 Nov 2018 09:46:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49BB22C324 for ; Fri, 23 Nov 2018 09:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DCDA2C3BB; Fri, 23 Nov 2018 09:46:16 +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 D37662C324 for ; Fri, 23 Nov 2018 09:46:15 +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=tmMUo/m+V9SYmtr1PS++3+OgPAv5YN/zytCFdQhIErU=; b=srgxmObJ8VkONU AIDeRUQoBfQvZUkvohx/txlnugImdpqJni4Mq8tJCdtC0bGGylSakBRP/3SndYoS85PZ70FWxebKF gLFeQSLSxbVUKunnEvdBtFvSp7vGiQEit9EYNZ2gFnte89v6T28wWYp/jvgKs2vuiDK+YputzXsh2 tf2YRiHdYsCy1YJoK42f9+wiK7sDh59T2KDK6CN3d2eKGvKNfW9kfpmorIg0Z7tXnPGvycf0HQPGC wY/+XLVNUkgKtUUIbe+gXN47AnZTkAUPr+NYdianPBD/wkwsprqGKvgygpbWHpJMI/R9PqiAdPWa+ dqW1AF7L/jAnvdmGofUA==; 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 1gQ82J-0002kW-2i; Fri, 23 Nov 2018 09:46:07 +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 1gQ7k7-0001q3-Vn for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:25 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 43C8E20F75; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 02AD220F7E; Fri, 23 Nov 2018 10:26:37 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 40/43] drm/sun4i: Set the coef_rdy bit right after the coef have been set Date: Fri, 23 Nov 2018 10:25:12 +0100 Message-Id: <20181123092515.2511-41-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012720_160354_6330A118 X-CRM114-Status: UNSURE ( 9.68 ) X-CRM114-Notice: Please train this message. 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, 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 From: Maxime Ripard The COEF_RDY bit is used to tell the hardware that new FIR filters coefficients have been written to the registers and that the hardware should take them into account starting next frame. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 368391a9e5fd..0e92f59efd49 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -95,6 +95,10 @@ static void sun4i_frontend_scaler_init(struct sun4i_frontend *frontend) sun4i_frontend_vert_coef[i]); } + regmap_write_bits(frontend->regs, + SUN4I_FRONTEND_FRM_CTRL_REG, + SUN4I_FRONTEND_FRM_CTRL_COEF_RDY, + SUN4I_FRONTEND_FRM_CTRL_COEF_RDY); } int sun4i_frontend_init(struct sun4i_frontend *frontend) From patchwork Fri Nov 23 09:25:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695489 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 B2DAA1709 for ; Fri, 23 Nov 2018 09:46:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A19E42C2DE for ; Fri, 23 Nov 2018 09:46:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 954D32C34A; Fri, 23 Nov 2018 09:46:47 +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 4C6F82C2DE for ; Fri, 23 Nov 2018 09:46:47 +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=jmtIi/ocXkdUNeMcIHz5f00lL0CNJMx9NyQAkkHLlds=; b=hrzm/JwcN1QGYA TUXQTktRjK/jP/yP7jIOajiUhL92NzXM9Mc5tzGDW/n+2GCHV74CNjhZ9uciAk2gEG4HBmCcPVOiA nUZY0XRXPZ0uLlM056Ir+fR89pO0f1vj3Q0gGrXOMyZsJt1pAIrZ463+iNLnquSwCdB2NkezBFron SHSgrtG6Rm9q3x58eOAR74uM3fqR9rrHvZQUgd8WpT5uqcpMEUrVZ82nBcRsdXVHFnI7GKQ8mdcau me5JM6/U82B21/WWY3wyVvhMJDLbhz3RWOBRcuxqr83MsO2tVdo0wqsXeAOs5Gjg/x+OMZkd9neXv D7EKL9J8xQ8gdH4GeyfQ==; 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 1gQ82n-0003Q9-TZ; Fri, 23 Nov 2018 09:46:37 +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 1gQ7k8-0001qM-JE for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:26 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 4BBD420F7E; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 3DB18207B0; Fri, 23 Nov 2018 10:26:38 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 41/43] drm/sun4i: Make COEF_RDY conditional Date: Fri, 23 Nov 2018 10:25:13 +0100 Message-Id: <20181123092515.2511-42-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012720_861189_B4E39F4B X-CRM114-Status: GOOD ( 12.57 ) 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, 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 From: Maxime Ripard The COEF_RDY bit isn't found in all the SoCs featuring some variant of the frontend. Add it to our quirks structure. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 9 +++++---- drivers/gpu/drm/sun4i/sun4i_frontend.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 0e92f59efd49..f50507ee6d75 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -95,10 +95,11 @@ static void sun4i_frontend_scaler_init(struct sun4i_frontend *frontend) sun4i_frontend_vert_coef[i]); } - regmap_write_bits(frontend->regs, - SUN4I_FRONTEND_FRM_CTRL_REG, - SUN4I_FRONTEND_FRM_CTRL_COEF_RDY, - SUN4I_FRONTEND_FRM_CTRL_COEF_RDY); + if (frontend->data->has_coef_rdy) + regmap_write_bits(frontend->regs, + SUN4I_FRONTEND_FRM_CTRL_REG, + SUN4I_FRONTEND_FRM_CTRL_COEF_RDY, + SUN4I_FRONTEND_FRM_CTRL_COEF_RDY); } int sun4i_frontend_init(struct sun4i_frontend *frontend) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index daf3fa5d01ba..3618993f8e49 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -102,6 +102,7 @@ struct reset_control; struct sun4i_frontend_data { bool has_coef_access_ctrl; + bool has_coef_rdy; }; struct sun4i_frontend { From patchwork Fri Nov 23 09:25:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695421 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 1ACE6175A for ; Fri, 23 Nov 2018 09:32:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07D2D2C357 for ; Fri, 23 Nov 2018 09:32:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFDB92C3BB; Fri, 23 Nov 2018 09:32:45 +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 859962C357 for ; Fri, 23 Nov 2018 09:32:45 +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=TxXugSFOtmYvski9CzALgJdOyFWEDbe1hveQzSEbsHs=; b=IQ+W7GNWJ5odQl HcCR+IyuGqdmDr6mhpbGH72+5oaK83rruHOH7P5oU39ro9rxmrepcBprxB8Nc5bjJH1bP2zlTlMjX jsago9aeDbxuXeUIQX3pwUP8Ik99e+VbWseIaLlrozjB6Ap2VZ3rLmbT1nD0v9MeZQWfJqDIQnHab npmZkasauTDs3RPqob0dAG7GjpPFP0KIUma1Pu1Ds4f0J5qtPSZ7NDCzAbO3w0DdmIPa4pGoR1UgV 7yc+J3I1XjQIut8HZjDIFZhbtH5RZxgYDqw88UQlOUtm87XzWuJ/UajENMaSMhB/d0s1NE8I+T/f7 9TxJayR82Me5AG3C0N/g==; 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 1gQ7pK-0002SI-Pe; Fri, 23 Nov 2018 09:32:42 +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 1gQ7k9-0001qN-7b for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:29 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 554D621668; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 78451207BB; Fri, 23 Nov 2018 10:26:38 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 42/43] drm/sun4i: frontend: Move the FIR filter phases to our quirks Date: Fri, 23 Nov 2018 10:25:14 +0100 Message-Id: <20181123092515.2511-43-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012721_581274_8C48A595 X-CRM114-Status: GOOD ( 14.38 ) 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, 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 From: Maxime Ripard The FIR filters phase depend on the SoC, so let's move it to our quirks structure instead of removing them. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 28 ++++++++++++++++++++------ drivers/gpu/drm/sun4i/sun4i_frontend.h | 5 +++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index f50507ee6d75..427c51029a9c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -438,12 +438,18 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, * I have no idea what this does exactly, but it seems to be * related to the scaler FIR filter phase parameters. */ - regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZPHASE_REG, 0x400); - regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZPHASE_REG, 0x400); - regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE0_REG, 0x400); - regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE0_REG, 0x400); - regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE1_REG, 0x400); - regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE1_REG, 0x400); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZPHASE_REG, + frontend->data->ch_phase[0].horzphase); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZPHASE_REG, + frontend->data->ch_phase[1].horzphase); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE0_REG, + frontend->data->ch_phase[0].vertphase[0]); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE0_REG, + frontend->data->ch_phase[1].vertphase[0]); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE1_REG, + frontend->data->ch_phase[0].vertphase[1]); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE1_REG, + frontend->data->ch_phase[1].vertphase[1]); if (fb->format->is_yuv && !drm_format_is_yuv(out_fmt)) { /* Setup the CSC engine for YUV to RGB conversion. */ @@ -671,6 +677,16 @@ static const struct dev_pm_ops sun4i_frontend_pm_ops = { }; static const struct sun4i_frontend_data sun8i_a33_frontend = { + .ch_phase = { + { + .horzphase = 0x400, + .vertphase = { 0x400, 0x400 }, + }, + { + .horzphase = 0x400, + .vertphase = { 0x400, 0x400 }, + }, + }, .has_coef_access_ctrl = true, }; diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index 3618993f8e49..45f5f4f3d06f 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -103,6 +103,11 @@ struct reset_control; struct sun4i_frontend_data { bool has_coef_access_ctrl; bool has_coef_rdy; + + struct { + u32 horzphase; + u32 vertphase[2]; + } ch_phase[2]; }; struct sun4i_frontend { From patchwork Fri Nov 23 09:25:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695423 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 A8A58175A for ; Fri, 23 Nov 2018 09:32:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92BC02C357 for ; Fri, 23 Nov 2018 09:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 825E62C3D8; Fri, 23 Nov 2018 09:32:58 +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 1AC0F2C357 for ; Fri, 23 Nov 2018 09:32:58 +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=Jgil9PLYz60gjqrH9D393Hc03u53NZNjYFFYXi7aKpE=; b=AdDrTz4tpCQv0C NRGiGP2djx8qgxePcz75Yv/pDeXwNTarEPUe76rx0/AVVqya8JDFzTVjAjYjZNIqG6PwTA29BKGAE WyUf9KL5ok10VvWb7oh8bXNgfsG/2OcKE90oZSwn9QKKWB/tDjXzhFLj7lZKr2H4FnjN435KyctXV 2WrPptY+k/ReznV3nZBbPpq0Tn8+SmgO+RSP0EZK3hpmq9zxGxlo44I9wtVIrFwzjEMeZmbbMIIOm HbmEXVsB5uVxjKIm9fc8oj2FbMPT/U0IDt6ub/ogP+W+IVQ6hFSpSgAOr2IVoHIWA89MVnNHGSvl1 GUhEc9uXUyuEN2QC1PRA==; 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 1gQ7pV-0002fv-4p; Fri, 23 Nov 2018 09:32:53 +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 1gQ7kA-0001qL-1b for linux-arm-kernel@lists.infradead.org; Fri, 23 Nov 2018 09:27:30 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 8380B20DD7; Fri, 23 Nov 2018 10:27:08 +0100 (CET) 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 B166720F80; Fri, 23 Nov 2018 10:26:38 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 43/43] drm/sun4i: frontend: Add A20-specific device-tree compatible and quirks Date: Fri, 23 Nov 2018 10:25:15 +0100 Message-Id: <20181123092515.2511-44-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_012722_333231_615D3767 X-CRM114-Status: GOOD ( 11.66 ) 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 This adds the appropriate device-tree compatible and quirk data for hooking frontend support for the A20. It supports the FIR coefficients ready bit but not the access control bit. It also takes different phase values than the A33 for these coefficients. The compatible is already used in the A20 device-tree and already documented in the device-tree bindings. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 427c51029a9c..4a9cb478167f 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -676,6 +676,20 @@ static const struct dev_pm_ops sun4i_frontend_pm_ops = { .runtime_suspend = sun4i_frontend_runtime_suspend, }; +static const struct sun4i_frontend_data sun7i_a20_frontend = { + .ch_phase = { + { + .horzphase = 0, + .vertphase = { 0, 0 }, + }, + { + .horzphase = 0xfc000, + .vertphase = { 0xfc000, 0xfc000 }, + }, + }, + .has_coef_rdy = true, +}; + static const struct sun4i_frontend_data sun8i_a33_frontend = { .ch_phase = { { @@ -691,6 +705,10 @@ static const struct sun4i_frontend_data sun8i_a33_frontend = { }; const struct of_device_id sun4i_frontend_of_table[] = { + { + .compatible = "allwinner,sun7i-a20-display-frontend", + .data = &sun7i_a20_frontend + }, { .compatible = "allwinner,sun8i-a33-display-frontend", .data = &sun8i_a33_frontend