From patchwork Thu Nov 20 10:24:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 5347321 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B7289F2F1 for ; Thu, 20 Nov 2014 10:25:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2FB42020E for ; Thu, 20 Nov 2014 10:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBB00200F2 for ; Thu, 20 Nov 2014 10:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757868AbaKTKZA (ORCPT ); Thu, 20 Nov 2014 05:25:00 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:57018 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757545AbaKTKYx (ORCPT ); Thu, 20 Nov 2014 05:24:53 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFC00LGK29EFV20@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 20 Nov 2014 19:24:51 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 14.F1.18484.271CD645; Thu, 20 Nov 2014 19:24:50 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-a8-546dc1721701 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 96.29.20081.271CD645; Thu, 20 Nov 2014 19:24:50 +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 <0NFC000N029CT7B0@mmp1.samsung.com>; Thu, 20 Nov 2014 19:24:50 +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 v3 3/4] drm/exynos: make vidi driver to be independent driver Date: Thu, 20 Nov 2014 19:24:47 +0900 Message-id: <1416479088-29371-4-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416479088-29371-1-git-send-email-inki.dae@samsung.com> References: <1416479088-29371-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsWyRsSkULfoYG6Iwf0+C4vecyeZLK58fc9m Men+BBaLGef3MTmweGz/9oDV4373cSaPvi2rGD0+b5ILYInisklJzcksSy3St0vgyrix/j9L wRaLin/TdrA2MPbpdzFyckgImEj0zLrJBGGLSVy4t56ti5GLQ0hgKaPErCed7DBFa1bdY4dI LGKUePT1AguE080ksWv9erB2NgFViYkr7rOB2CICyhJ/J65iBLGZBaIklh9eCjZJWCBYYsmp EywgNgtQ/bzDS8B6eQVcJN7cXglUwwG0TUFiziQbkDCngKvE7ytr2EDCQkAlP9dKgKyVEPjN JtHW+JoZYoyAxLfJh1ggWmUlNh1ghrhZUuLgihssExiFFzAyrGIUTS1ILihOSi8y1itOzC0u zUvXS87P3cQIDN7T/57172C8e8D6EKMAB6MSDy+HWW6IEGtiWXFl7iFGU6ANE5mlRJPzgTGS VxJvaGxmZGFqYmpsZG5ppiTOu1DqZ7CQQHpiSWp2ampBalF8UWlOavEhRiYOTqkGRvNXLK57 9KJX8efyJeulP9nBH5lq+Jr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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 driver. 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 so that this driver can be bound independently. Changelog v3: - none Changelog v2: - none 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);