From patchwork Tue May 24 13:28:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9133581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A3D5B607D5 for ; Tue, 24 May 2016 13:29:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9552D27F2B for ; Tue, 24 May 2016 13:29:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88D092810D; Tue, 24 May 2016 13:29:33 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 E3AE727F2B for ; Tue, 24 May 2016 13:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755152AbcEXN2y (ORCPT ); Tue, 24 May 2016 09:28:54 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:47697 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753161AbcEXN2w (ORCPT ); Tue, 24 May 2016 09:28:52 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O7O00A5YO4029A0@mailout3.w1.samsung.com>; Tue, 24 May 2016 14:28:48 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-5f-574457104eaa Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 26.E8.04866.01754475; Tue, 24 May 2016 14:28:48 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O7O00CZCO3W1H90@eusync2.samsung.com>; Tue, 24 May 2016 14:28:48 +0100 (BST) From: Krzysztof Kozlowski To: Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , David Airlie , Kukjin Kim , Krzysztof Kozlowski , Mauro Carvalho Chehab , Marek Szyprowski , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org Cc: Bartlomiej Zolnierkiewicz , Kamil Debski Subject: [PATCH 1/2] drm/exynos: g2d: Add support for old S5Pv210 type Date: Tue, 24 May 2016 15:28:12 +0200 Message-id: <1464096493-13378-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPLMWRmVeSWpSXmKPExsVy+t/xK7oC4S7hBvsfq1n0njvJZLFxxnpW iytf37NZTLo/gcXixb2LLBY/Xl9gs3j9wtCi//FrZouzTW/YLTY9vsZqcXnXHDaLng1bWS1m nN/HZLH2yF12i9XPKixmTH7J5iDgsWlVJ5vH9m8PWD3udx9n8ti8pN5jS/9ddo++LasYPT5v kgtgj+KySUnNySxLLdK3S+DK+HHzB1PBIZWKKw9nsTYwzpLrYuTkkBAwkWh9eZMVwhaTuHBv PVsXIxeHkMBSRonfy++BJYQEGpkkPn2JBLHZBIwlNi9fAlYkIrCARWJL9wRmkASzQLzEta9r WEBsYQE3ie3X1oDFWQRUJZrffgUaxMHBK+AuMfsGB8QyOYmTxyazTmDkXsDIsIpRNLU0uaA4 KT3XSK84Mbe4NC9dLzk/dxMjJBi/7mBceszqEKMAB6MSD++KQudwIdbEsuLK3EOMEhzMSiK8 aWEu4UK8KYmVValF+fFFpTmpxYcYpTlYlMR5Z+56HyIkkJ5YkpqdmlqQWgSTZeLglGpgLJhV 0fXd6FVo19K2RybZsXdvb2W0S+l89En415pne1Zt+e39ry9EW0JaM1Ke8/n+iT+PFpa68lev vi9Q01tVW5Kh8Xf/6tB93vdz7j9Oe29zKT9n+SONaXGmDw4rPDsdwO72WFda3CD+BaeazAWZ uz/krUMcpI89uP/00ucZt39+KfobOffwJCWW4oxEQy3mouJEAN9BScZCAgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The non-DRM s5p-g2d driver supports two versions of G2D: v3.0 on S5Pv210 and v4.x on Exynos 4x12 (or newer). The driver for 3.0 device version is doing two things differently: 1. Before starting the render process, it invalidates caches (pattern, source buffer and mask buffer). Cache control is not present on v4.x device. 2. Scalling is done through StretchEn command (in BITBLT_COMMAND_REG register) instead of SRC_SCALE_CTRL_REG as in v4.x. However the exynos_drm_g2d driver does not implement the scalling so this difference can be eliminated. After adding support for v3.0 to exynos_drm_g2d driver, the old driver can be removed. Cc: Kyungmin Park Cc: Kamil Debski Signed-off-by: Krzysztof Kozlowski --- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 37 +++++++++++++++++++++++++++++++-- drivers/gpu/drm/exynos/exynos_drm_g2d.h | 7 +++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 493552368295..44d8b28e9d98 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,7 @@ #define G2D_SOFT_RESET 0x0000 #define G2D_INTEN 0x0004 #define G2D_INTC_PEND 0x000C +#define G2D_CACHECTL 0x0018 /* S5PV210 specific */ #define G2D_DMA_SFR_BASE_ADDR 0x0080 #define G2D_DMA_COMMAND 0x0084 #define G2D_DMA_STATUS 0x008C @@ -78,6 +80,11 @@ #define G2D_INTP_GCMD_FIN (1 << 1) #define G2D_INTP_SCMD_FIN (1 << 0) +/* G2D_CACHECTL, S5PV210 specific */ +#define G2D_CACHECTL_PATCACHE (BIT(2)) +#define G2D_CACHECTL_SRCBUFFER (BIT(1)) +#define G2D_CACHECTL_MASKBUFFER (BIT(0)) + /* G2D_DMA_COMMAND */ #define G2D_DMA_HALT (1 << 2) #define G2D_DMA_CONTINUE (1 << 1) @@ -245,6 +252,7 @@ struct g2d_data { unsigned long current_pool; unsigned long max_pool; + enum exynos_drm_g2d_type type; }; static int g2d_init_cmdlist(struct g2d_data *g2d) @@ -1125,6 +1133,13 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data, cmdlist->data[cmdlist->last++] = G2D_SRC_BASE_ADDR; cmdlist->data[cmdlist->last++] = 0; + if (g2d->type == EXYNOS_DRM_G2D_TYPE_3X) { + cmdlist->data[cmdlist->last++] = G2D_CACHECTL; + cmdlist->data[cmdlist->last++] = G2D_CACHECTL_PATCACHE | + G2D_CACHECTL_SRCBUFFER | + G2D_CACHECTL_MASKBUFFER; + } + /* * 'LIST_HOLD' command should be set to the DMA_HOLD_CMD_REG * and GCF bit should be set to INTEN register if user wants @@ -1369,10 +1384,20 @@ static int g2d_probe(struct platform_device *pdev) struct exynos_drm_subdrv *subdrv; int ret; + /* Sanity check, we can be instatiated only from DT */ + if (!dev->of_node) + return -EINVAL; + g2d = devm_kzalloc(dev, sizeof(*g2d), GFP_KERNEL); if (!g2d) return -ENOMEM; + g2d->type = (enum exynos_drm_g2d_type)of_device_get_match_data(dev); + if (g2d->type == EXYNOS_DRM_G2D_TYPE_UNKNOWN) { + dev_err(dev, "failed to get type of device\n"); + return -EINVAL; + } + g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab", sizeof(struct g2d_runqueue_node), 0, 0, NULL); if (!g2d->runqueue_slab) @@ -1535,8 +1560,16 @@ static const struct dev_pm_ops g2d_pm_ops = { }; static const struct of_device_id exynos_g2d_match[] = { - { .compatible = "samsung,exynos5250-g2d" }, - { .compatible = "samsung,exynos4212-g2d" }, + { + .compatible = "samsung,exynos5250-g2d", + .data = (void *)EXYNOS_DRM_G2D_TYPE_4X, + }, { + .compatible = "samsung,exynos4212-g2d", + .data = (void *)EXYNOS_DRM_G2D_TYPE_4X, + }, { + .compatible = "samsung,s5pv210-g2d", + .data = (void *)EXYNOS_DRM_G2D_TYPE_3X, + }, {}, }; MODULE_DEVICE_TABLE(of, exynos_g2d_match); diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.h b/drivers/gpu/drm/exynos/exynos_drm_g2d.h index 1a9c7ca8c15b..84ec8aff6f0a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.h +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.h @@ -7,6 +7,13 @@ * published by the Free Software Foundationr */ +enum exynos_drm_g2d_type { + EXYNOS_DRM_G2D_TYPE_UNKNOWN, + + EXYNOS_DRM_G2D_TYPE_3X, + EXYNOS_DRM_G2D_TYPE_4X, +}; + #ifdef CONFIG_DRM_EXYNOS_G2D extern int exynos_g2d_get_ver_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);