From patchwork Tue Nov 18 15:26:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 5331181 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 540F8C11AC for ; Tue, 18 Nov 2014 15:27:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31176201E4 for ; Tue, 18 Nov 2014 15:26:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F398C200E7 for ; Tue, 18 Nov 2014 15:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757214AbaKRP0w (ORCPT ); Tue, 18 Nov 2014 10:26:52 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:26693 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757219AbaKRP0v (ORCPT ); Tue, 18 Nov 2014 10:26:51 -0500 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NF800MBKQWM3930@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Wed, 19 Nov 2014 00:26:46 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.116]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 25.8F.19034.6356B645; Wed, 19 Nov 2014 00:26:46 +0900 (KST) X-AuditID: cbfee691-f79b86d000004a5a-0e-546b653635ba Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 5E.31.20081.6356B645; Wed, 19 Nov 2014 00:26:46 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.83.67]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NF800D1LQWLLG30@mmp1.samsung.com>; Wed, 19 Nov 2014 00:26:46 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, linux-samsung-soc@vger.kernel.org, Inki Dae Subject: [RFC PATCH 3/3] drm/exynos: make vidi driver to be independent module Date: Wed, 19 Nov 2014 00:26:44 +0900 Message-id: <1416324404-28153-4-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416324404-28153-1-git-send-email-inki.dae@samsung.com> References: <1416324404-28153-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsWyRsSkRNcsNTvE4OJiQ4vecyeZLK58fc9m Men+BBaLGef3MTmweGz/9oDV4373cSaPvi2rGD0+b5ILYInisklJzcksSy3St0vgypi+9yZj wVfziin961gbGB/pdTFyckgImEjc6lvEBGGLSVy4t56ti5GLQ0hgKaPErHfT2GGKDj1tZoRI LGKU+HntFzNIQkigm0ni/yEFEJtNQFVi4or7bCC2iICyxN+JqxhBbGaBKInlh5eCDRIW8JO4 8fUaC4jNAlTf2f8NbDOvgIvEo53zgGo4gJYpSMyZZANicgq4SvT+ZAMxhYAq/l+VBLlAQuA7 m8SVX8uhpghIfJt8iAWiU1Zi0wFmiIslJQ6uuMEygVF4ASPDKkbR1ILkguKk9CJTveLE3OLS vHS95PzcTYzAwD3979nEHYz3D1gfYhTgYFTi4U2YmhUixJpYVlyZe4jRFGjDRGYp0eR8YHzk lcQbGpsZWZiamBobmVuaKYnz6kj/DBYSSE8sSc1OTS1ILYovKs1JLT7EyMTBKdXAyLOs1zzl smfOO54iFuWPij1WZ2ZUpj0WLyyZdCpB+/lG8ySx09J3j/Cfm37GSXXiuSkzuj6Gb9/69Wjy rJrDG/6/CZeo0mzdwDDZ5d16N32HlDv24qtUtvQ1GPfcEXxdEmfz+t20u6eCrcqa26pTw3ne c970i171t8leP47712KuiUGWm3kmK7EUZyQaajEXFScCAG5kZ/JXAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeLIzCtJLcpLzFFi42I5/e+xgK5ZanaIwdZrGha9504yWVz5+p7N YtL9CSwWM87vY3Jg8dj+7QGrx/3u40wefVtWMXp83iQXwBLVwGiTkZqYklqkkJqXnJ+SmZdu q+QdHO8cb2pmYKhraGlhrqSQl5ibaqvk4hOg65aZA7RTSaEsMacUKBSQWFyspG+HaUJoiJuu BUxjhK5vSBBcj5EBGkhYw5gxfe9NxoKv5hVT+texNjA+0uti5OSQEDCROPS0mRHCFpO4cG89 WxcjF4eQwCJGiZ/XfjGDJIQEupkk/h9SALHZBFQlJq64zwZiiwgoS/yduAqsmVkgSmL54aXs ILawgJ/Eja/XWEBsFqD6zv5vTCA2r4CLxKOd84BqOICWKUjMmWQDYnIKuEr0/mQDMYWAKv5f lZzAyLuAkWEVo2hqQXJBcVJ6rqFecWJucWleul5yfu4mRnBcPJPawbiyweIQowAHoxIPb8LU rBAh1sSy4srcQ4wSHMxKIrznuoFCvCmJlVWpRfnxRaU5qcWHGE2BTprILCWanA+M2bySeENj EzMjSyNzQwsjY3Mlcd4DrdaBQgLpiSWp2ampBalFMH1MHJxSDYx5adqfeX+c07S+2B7t7LY+ PTnCPHjN6oeWLzdUH7G038XZMEn51j+1O7t9JWTntdu1Cxm+b2kSX7t2lWAl96u8wC/b1oqG i4lM3Gwn7b1K5USRj67SD0Ovr8qO+W8zp3PuYK+J9M/yMO4IWC7oNPmjvrKKZthqSQYpc6F7 0wIPfMqQeuXTpcRSnJFoqMVcVJwIAAUhwzKhAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes vidi driver to be independent module. For this, it removes register codes to vidi driver from exynos_drm_drv module and adds module_init/exit for vidi driver so that this driver can be called independently. In addition, this patch adds component support to vidi driver, which is required for modularity. Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 12 +---- drivers/gpu/drm/exynos/exynos_drm_drv.h | 9 ---- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 81 +++++++++++++++++++----------- 3 files changed, 54 insertions(+), 48 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 7f1186e..3ac39b6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -608,19 +608,12 @@ static int exynos_drm_init(void) if (IS_ERR(exynos_drm_pdev)) return PTR_ERR(exynos_drm_pdev); - ret = exynos_drm_probe_vidi(); - if (ret < 0) - goto err_unregister_pd; - ret = platform_driver_register(&exynos_drm_platform_driver); if (ret) - goto err_remove_vidi; + goto err_unregister_pd; return 0; -err_remove_vidi: - exynos_drm_remove_vidi(); - err_unregister_pd: platform_device_unregister(exynos_drm_pdev); @@ -630,9 +623,6 @@ err_unregister_pd: static void exynos_drm_exit(void) { platform_driver_unregister(&exynos_drm_platform_driver); - - exynos_drm_remove_vidi(); - platform_device_unregister(exynos_drm_pdev); } diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 5b3305c..7c2ba06 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -310,14 +310,6 @@ exynos_dpi_probe(struct device *dev) { return NULL; } static inline int exynos_dpi_remove(struct device *dev) { return 0; } #endif -#ifdef CONFIG_DRM_EXYNOS_VIDI -int exynos_drm_probe_vidi(void); -void exynos_drm_remove_vidi(void); -#else -static inline int exynos_drm_probe_vidi(void) { return 0; } -static inline void exynos_drm_remove_vidi(void) {} -#endif - /* This function creates a encoder and a connector, and initializes them. */ int exynos_drm_create_enc_conn(struct drm_device *dev, struct exynos_drm_display *display); @@ -333,5 +325,4 @@ extern int exynos_drm_non_kms_register(unsigned int device_type); extern void exynos_drm_non_kms_unregister(unsigned int device_type); extern struct platform_driver exynos_drm_common_hdmi_driver; -extern struct platform_driver vidi_driver; #endif diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 50faf91..e1153aa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -14,6 +14,7 @@ #include #include +#include #include @@ -48,10 +49,10 @@ struct vidi_win_data { struct vidi_context { struct drm_device *drm_dev; + struct platform_device *pdev; struct drm_crtc *crtc; struct drm_encoder *encoder; struct drm_connector connector; - struct exynos_drm_subdrv subdrv; struct vidi_win_data win_data[WINDOWS_NR]; struct edid *raw_edid; unsigned int clkdiv; @@ -561,14 +562,13 @@ static struct exynos_drm_display vidi_display = { .ops = &vidi_display_ops, }; -static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev) +static int vidi_bind(struct device *dev, struct device *master, void *data) { - struct exynos_drm_manager *mgr = get_vidi_mgr(dev); - struct vidi_context *ctx = mgr->ctx; - struct drm_crtc *crtc = ctx->crtc; + struct drm_crtc *crtc = vidi_manager.crtc; + struct drm_device *drm_dev = data; int ret; - vidi_mgr_initialize(mgr, drm_dev); + vidi_mgr_initialize(&vidi_manager, drm_dev); ret = exynos_drm_crtc_create(&vidi_manager); if (ret) { @@ -586,20 +586,42 @@ static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev) return 0; } +static void vidi_unbind(struct device *dev, struct device *master, + void *data) +{ +} + +static const struct component_ops vidi_component_ops = { + .bind = vidi_bind, + .unbind = vidi_unbind, +}; + static int vidi_probe(struct platform_device *pdev) { - struct exynos_drm_subdrv *subdrv; struct vidi_context *ctx; int ret; + ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, + vidi_manager.type); + if (ret) + return ret; + + ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR, + vidi_display.type); + if (ret) + goto err_del_crtc_component; + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); - if (!ctx) - return -ENOMEM; + if (!ctx) { + ret = -ENOMEM; + goto err_del_conn_component; + } ctx->default_win = 0; INIT_WORK(&ctx->work, vidi_fake_vblank_handler); + ctx->pdev = pdev; vidi_manager.ctx = ctx; vidi_display.ctx = ctx; @@ -607,23 +629,21 @@ static int vidi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &vidi_manager); - subdrv = &ctx->subdrv; - subdrv->dev = &pdev->dev; - subdrv->probe = vidi_subdrv_probe; - - ret = exynos_drm_subdrv_register(subdrv); - if (ret < 0) { - dev_err(&pdev->dev, "failed to register drm vidi device\n"); - return ret; - } - ret = device_create_file(&pdev->dev, &dev_attr_connection); - if (ret < 0) { - exynos_drm_subdrv_unregister(subdrv); + if (ret < 0) DRM_INFO("failed to create connection sysfs.\n"); - } - return 0; + ret = component_add(&pdev->dev, &vidi_component_ops); + if (ret) + goto err_del_conn_component; + + return ret; + +err_del_conn_component: + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); +err_del_crtc_component: + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); + return ret; } static int vidi_remove(struct platform_device *pdev) @@ -638,6 +658,10 @@ static int vidi_remove(struct platform_device *pdev) return -EINVAL; } + component_del(&pdev->dev, &vidi_component_ops); + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); + return 0; } @@ -650,7 +674,7 @@ struct platform_driver vidi_driver = { }, }; -int exynos_drm_probe_vidi(void) +static int exynos_drm_vidi_init(void) { struct platform_device *pdev; int ret; @@ -668,12 +692,13 @@ int exynos_drm_probe_vidi(void) return ret; } -void exynos_drm_remove_vidi(void) +void exynos_drm_vidi_exit(void) { struct vidi_context *ctx = vidi_manager.ctx; - struct exynos_drm_subdrv *subdrv = &ctx->subdrv; - struct platform_device *pdev = to_platform_device(subdrv->dev); platform_driver_unregister(&vidi_driver); - platform_device_unregister(pdev); + platform_device_unregister(ctx->pdev); } + +module_init(exynos_drm_vidi_init); +module_exit(exynos_drm_vidi_exit);