From patchwork Wed Mar 20 13:07:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861601 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 A430E15AC for ; Wed, 20 Mar 2019 13:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A58C28B7B for ; Wed, 20 Mar 2019 13:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8861F28BA9; Wed, 20 Mar 2019 13:07: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19A0B28BF1 for ; Wed, 20 Mar 2019 13:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbfCTNHY (ORCPT ); Wed, 20 Mar 2019 09:07:24 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55209 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727757AbfCTNHY (ORCPT ); Wed, 20 Mar 2019 09:07:24 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130723euoutp01af6a58015791192deefe49d5b02f4c83~NrJ53aiTH0183101831euoutp01v; Wed, 20 Mar 2019 13:07:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190320130723euoutp01af6a58015791192deefe49d5b02f4c83~NrJ53aiTH0183101831euoutp01v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087243; bh=TyKT6bah+kd2Dl9KQ7/ARjwuR+1go7zEaegsvg3AlHE=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=sN5HE9tzrGToB1dwSG7/kjoQBNNUob6/rfIiK0lAYLYo5CXzTQINmUmnaKtHOBFlZ ibWUwPX44KeeTT3/FxKwDxwuT9m6a210tC/ejtr6dG6jX8oNPwRWUrh/+8tX2UGBFP QEdSBzNJYRfwe4rYykOH7BjjvphFMlcRbOsOatlo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130722eucas1p2f667e03368b8a5f4b32c108263bc90b8~NrJ5fWjZ10270202702eucas1p2Z; Wed, 20 Mar 2019 13:07:22 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 52.A1.04294.A0B329C5; Wed, 20 Mar 2019 13:07:22 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130722eucas1p201e6452c3329fdbbc651051da9b14155~NrJ44ODzX1479814798eucas1p2Y; Wed, 20 Mar 2019 13:07:22 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-cf-5c923b0ad19b Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 0C.AF.04284.A0B329C5; Wed, 20 Mar 2019 13:07:22 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0POO004P71RZN460@eusync1.samsung.com>; Wed, 20 Mar 2019 13:07:22 +0000 (GMT) From: Andrzej Hajda To: Inki Dae Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, Krzysztof Kozlowski Subject: [PATCH v2 RESEND 24/24] drm/exynos/gscaler: fix handling YVU420 pixel format Date: Wed, 20 Mar 2019 14:07:07 +0100 Message-id: <20190320130707.25161-25-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20190320130707.25161-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsWy7djPc7pc1pNiDC62y1rcWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6Mpi+72AqaFSum/JnM0sDYKtPFyMkhIWAisenfWjYQW0hgBaPE2y2FXYxc QPZnIHvOJXaYotdL9rFCJJYxSvyYs5AZwvnPKLG8o48JpIpNQFPi7+abYKNEBJQlVu1rZwcp Yhb4zSgxffk2IIedQ1ggXGKHBUgJi4CqxO7bn5lBbF4BS4mNxx8zQyyTl1i94QCYzQkUfzjn P9gYCYFGNon3G58wdjFyADkuEiv/CkDUy0h0dhxkgrDrJe6vaGGGqO9glNi6YSfUUGuJw8cv soLYzAJ8EpO2TWeGmMMr0dEmBFHiIfH41EGov3oYJW4f72GfwCixgJFhFaN4amlxbnpqsVFe arlecWJucWleul5yfu4mRmBsnf53/MsOxl1/kg4xCnAwKvHwXng+IUaINbGsuDL3EKMEB7OS CG+E0qQYId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzVDA+ihQTSE0tSs1NTC1KLYLJMHJxSDYys mg0Nm6o2Mx19sHPJ41O7yre/c9y+be9uwU9cqnJnjdwEjp9bkO7MyD79ynqb13O32K5w2WBv H3mw5+K9277WLm9XVjkdnruha6WEwYP5coo7qjI13BVKVLy3Mpnwsizf9j8q7+oqlrfazRxf XPwvveFOPt/ocuZDiLa34vK2m9Gpz0WXvVJTYinOSDTUYi4qTgQAoMvBdqkCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmluLIzCtJLcpLzFFi42I5/e/4ZV0u60kxBu9mM1ncWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6Mpi+72AqaFSum/JnM0sDYKtPFyMkhIWAi8XrJPtYuRi4OIYEljBJnnrcz QTiNTBJ7brQyg1SxCWhK/N18kw3EFhFQlli1r50dpIhZ4DejxOcZX8GKhAXCJXYt/MUEYrMI qErsvv0ZLM4rYCmx8fhjZoh18hKrNxwAszmB4g/n/GcHsYUELCQWn7jLOIGRZwEjwypGkdTS 4tz03GJDveLE3OLSvHS95PzcTYzAoNl27OfmHYyXNgYfYhTgYFTi4a14OiFGiDWxrLgy9xCj BAezkghvhNKkGCHelMTKqtSi/Pii0pzU4kOM0hwsSuK85w0qo4QE0hNLUrNTUwtSi2CyTByc Ug2MrmFO4TJHbt7OSkqItnzqM09gPnPwm94f6svFdha8jD+sf4zl0gmukILF0oZLF/zRlpvz y2/+HuPI045Pj609tuWATOTTFWsVbvzZyn153uuc37tOzt0l9OCPh4LWpcLMKWuShc0Cgy1l TvyPXuPTxfBP5Hrx43f//3yPLI2dnPpn+xSXfZfORCqxFGckGmoxFxUnAgBLs54jFgIAAA== X-CMS-MailID: 20190320130722eucas1p201e6452c3329fdbbc651051da9b14155 CMS-TYPE: 201P X-CMS-RootMailID: 20190320130722eucas1p201e6452c3329fdbbc651051da9b14155 References: <20190320130707.25161-1-a.hajda@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP YVU420 requires swapping addresses of U and V planes. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_gsc.c | 52 ++++++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c index c7a97d053ab1..f75739e8bc55 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c @@ -535,10 +535,8 @@ static void gsc_src_set_fmt(struct gsc_context *ctx, u32 fmt, bool tiled) cfg |= GSC_IN_YUV422_3P; break; case DRM_FORMAT_YUV420: - cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_3P); - break; case DRM_FORMAT_YVU420: - cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_3P); + cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_3P); break; case DRM_FORMAT_NV12: cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_2P); @@ -658,13 +656,32 @@ static void gsc_src_set_buf_seq(struct gsc_context *ctx, u32 buf_id, gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK); } +/* returns HW plane index based on pixel format */ +static int gsc_hw_plane_index(int index, u32 format) +{ + switch (format) { + case DRM_FORMAT_YVU420: + switch (index) { + case 0: return 0; + case 1: return 2; + case 2: return 1; + } + default: + return index; + } +} + static void gsc_src_set_addr(struct gsc_context *ctx, u32 buf_id, struct exynos_drm_ipp_buffer *buf) { + int idx; + /* address register set */ gsc_write(buf->dma_addr[0], GSC_IN_BASE_ADDR_Y(buf_id)); - gsc_write(buf->dma_addr[1], GSC_IN_BASE_ADDR_CB(buf_id)); - gsc_write(buf->dma_addr[2], GSC_IN_BASE_ADDR_CR(buf_id)); + idx = gsc_hw_plane_index(1, buf->format->format); + gsc_write(buf->dma_addr[idx], GSC_IN_BASE_ADDR_CB(buf_id)); + idx = gsc_hw_plane_index(2, buf->format->format); + gsc_write(buf->dma_addr[idx], GSC_IN_BASE_ADDR_CR(buf_id)); gsc_src_set_buf_seq(ctx, buf_id, true); } @@ -722,10 +739,8 @@ static void gsc_dst_set_fmt(struct gsc_context *ctx, u32 fmt, bool tiled) cfg |= GSC_OUT_YUV422_3P; break; case DRM_FORMAT_YUV420: - cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_3P); - break; case DRM_FORMAT_YVU420: - cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_3P); + cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_3P); break; case DRM_FORMAT_NV12: cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_2P); @@ -985,10 +1000,13 @@ static void gsc_dst_set_buf_seq(struct gsc_context *ctx, u32 buf_id, static void gsc_dst_set_addr(struct gsc_context *ctx, u32 buf_id, struct exynos_drm_ipp_buffer *buf) { - /* address register set */ + int i; + gsc_write(buf->dma_addr[0], GSC_OUT_BASE_ADDR_Y(buf_id)); - gsc_write(buf->dma_addr[1], GSC_OUT_BASE_ADDR_CB(buf_id)); - gsc_write(buf->dma_addr[2], GSC_OUT_BASE_ADDR_CR(buf_id)); + i = gsc_hw_plane_index(1, buf->format->format); + gsc_write(buf->dma_addr[i], GSC_OUT_BASE_ADDR_CB(buf_id)); + i = gsc_hw_plane_index(2, buf->format->format); + gsc_write(buf->dma_addr[i], GSC_OUT_BASE_ADDR_CR(buf_id)); gsc_dst_set_buf_seq(ctx, buf_id, true); } @@ -1238,10 +1256,14 @@ static void gsc_update_plane(struct exynos_drm_plane *plane) gsc_write(BIT(16) * cropped_w / scaled_w, GSC_MAIN_H_RATIO); gsc_write(BIT(16) * cropped_h / scaled_h, GSC_MAIN_V_RATIO); gsc_write(exynos_drm_fb_dma_addr(fb, 0), GSC_IN_BASE_ADDR_Y(0)); - if (fb->format->num_planes > 1) - gsc_write(exynos_drm_fb_dma_addr(fb, 1), GSC_IN_BASE_ADDR_CB(0)); - if (fb->format->num_planes > 2) - gsc_write(exynos_drm_fb_dma_addr(fb, 2), GSC_IN_BASE_ADDR_CR(0)); + if (fb->format->num_planes > 1) { + i = gsc_hw_plane_index(1, fb->format->format); + gsc_write(exynos_drm_fb_dma_addr(fb, i), GSC_IN_BASE_ADDR_CB(0)); + } + if (fb->format->num_planes > 2) { + i = gsc_hw_plane_index(2, fb->format->format); + gsc_write(exynos_drm_fb_dma_addr(fb, i), GSC_IN_BASE_ADDR_CR(0)); + } gsc_src_set_fmt(ctx, fb->format->format, fb->modifier); gsc_write(scaled_w * scaled_h, GSC_SMART_IF_PIXEL_NUM); gsc_write(GSC_ENABLE_SFR_UPDATE | GSC_ENABLE_ON, GSC_ENABLE);