From patchwork Fri Mar 1 12:20:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10835095 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 53EA818EC for ; Fri, 1 Mar 2019 12:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 435DC2097A for ; Fri, 1 Mar 2019 12:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CB782DA38; Fri, 1 Mar 2019 12:21: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=-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 A86EF2D8F5 for ; Fri, 1 Mar 2019 12:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387769AbfCAMVS (ORCPT ); Fri, 1 Mar 2019 07:21:18 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:39194 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388217AbfCAMVR (ORCPT ); Fri, 1 Mar 2019 07:21:17 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190301122115euoutp02cab259e9f4d353606c3e5b37ed6dedfe~H1RNOHaT32151021510euoutp028; Fri, 1 Mar 2019 12:21:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190301122115euoutp02cab259e9f4d353606c3e5b37ed6dedfe~H1RNOHaT32151021510euoutp028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1551442875; bh=TyKT6bah+kd2Dl9KQ7/ARjwuR+1go7zEaegsvg3AlHE=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=Ouy1aaGftnewHd2PZE0XduyMAE3/JC3nxzhM4TaVD5F0LuKVJTiaA76NC1FunJkP5 CwEBMzhM1YT6rterkebs1CNTajDjDZ5kbuax8JgTYPe6vgRPhS14TMMlLakW0YAbhu frBfr/XahqU07teYE8uDrQRsC2UyvoTkQRe1tSA8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190301122115eucas1p1fd59473e1d583057f4434436f03a225d~H1RM0hYFW2241322413eucas1p1j; Fri, 1 Mar 2019 12:21:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 4F.CC.04294.AB3297C5; Fri, 1 Mar 2019 12:21:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190301122114eucas1p2c257303e00546f399ee3e5f97962c28c~H1RMOkAsx1653016530eucas1p2y; Fri, 1 Mar 2019 12:21:14 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-18-5c7923bace95 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id BB.23.04284.AB3297C5; Fri, 1 Mar 2019 12:21:14 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PNO007ENSZ56Z20@eusync3.samsung.com>; Fri, 01 Mar 2019 12:21:14 +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 Subject: [PATCH 23/23] drm/exynos/gscaler: fix handling YVU420 pixel format Date: Fri, 01 Mar 2019 13:20:55 +0100 Message-id: <20190301122055.7135-24-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20190301122055.7135-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42LZduznOd1dypUxBlOaTSxurTvHarFxxnpW iytf37NZTLo/gcVixvl9TBZrj9xld2DzuN99nMmjb8sqRo/Pm+QCmKO4bFJSczLLUov07RK4 Mpq+7GIraFasmPJnMksDY6tMFyMHh4SAicSFXZldjFwcQgIrGCW6tzewQDifGSWuX57DClP0 f4MqRHwZo0Tb1inMEM5/RokFT3+xdTFycrAJaEr83XwTzBYRUJZYta+dHaSIWeASo8Trk92M IAlhAW+JlRs72EFsFgFVibd7zjOB2LwCFhI7NswBa5YQkJdYveEAM4jNCRQ/uLKdHSL+llVi ykwRCNtFYsbTM6wQtoxEZ8dBJgi7XqJp5hWw6yQEOhglTixeDjXUWuLw8YtgDcwCfBKTtk1n hniNV6KjTQiixENi0veNbBCfdTNKbFs0j3UC0IOMDKsYxVNLi3PTU4uN8lLL9YoTc4tL89L1 kvNzNzECI+n0v+NfdjDu+pN0iFGAg1GJhzfhZXmMEGtiWXFl7iFGCQ5mJRFePobKGCHelMTK qtSi/Pii0pzU4kOM0hwsSuK81QwPooUE0hNLUrNTUwtSi2CyTBycUg2MjtrvbQOU/x9NnVXk vvddJguv5SFb2TNSt2LLzBd3JBkufK3J+otDoDMure5afpO1PHPjxLht9sfP5Xi8Ojj3bor0 1Mlai/sPrT/11kn5hvWcEHeOpPMJt3Xs3y6/v9Dk3psdZb80HjZlWL+cNCdO3+2em3z/zZP/ ditmeprvNpx3y80jeNFmJZbijERDLeai4kQA35PwBqACAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xq7q7lCtjDBrapCxurTvHarFxxnpW iytf37NZTLo/gcVixvl9TBZrj9xld2DzuN99nMmjb8sqRo/Pm+QCmKO4bFJSczLLUov07RK4 Mpq+7GIraFasmPJnMksDY6tMFyMHh4SAicT/DapdjFwcQgJLGCVeXrnFCOE0Mkn0nmpi6mLk 5GAT0JT4u/kmG4gtIqAssWpfOztIEbPAFUaJ9m9d7CAJYQFviZUbO8BsFgFVibd7zoM18wpY SOzYMAesWUJAXmL1hgPMIDYnUPzgSpBBHEDbzCU2nY6awMizgJFhFaNIamlxbnpusaFecWJu cWleul5yfu4mRmBwbDv2c/MOxksbgw8xCnAwKvHwJrwsjxFiTSwrrsw9xCjBwawkwsvHUBkj xJuSWFmVWpQfX1Sak1p8iFGag0VJnPe8QWWUkEB6YklqdmpqQWoRTJaJg1OqgTFWQD9LoYzr Vlf5hZnZLXGytYcTE79nSnd67IuxY5+3SkI8eELyl0qr449SVPe83bVbNyzS11yPM5NnYUPP pbk9XPv5Fxgpda+ZpFCcdyNZ5ekiJ4ESSbmDUxeYyZbOUln8J/bNLI66UwXq7w+sORzlZqv0 b2nJk0deKx7PaF00RU1ur9KKbCWW4oxEQy3mouJEAJWUIO8KAgAA X-CMS-MailID: 20190301122114eucas1p2c257303e00546f399ee3e5f97962c28c CMS-TYPE: 201P X-CMS-RootMailID: 20190301122114eucas1p2c257303e00546f399ee3e5f97962c28c References: <20190301122055.7135-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);