From 8103ef1b5f471fe5e50cd4e1fc17cf3be4682d79 Mon Sep 17 00:00:00 2001 From: Andrzej Hajda Date: Mon, 24 Nov 2014 14:12:46 +0900 Subject: [PATCH] drm/exynos/mixer: embed manager into private context exynos_drm_manager is used by internal Exynos DRM framework for representing crtc. As it should be mapped 1:1 to fimd private context it seems more reasonable to embed it directly in that context. As a result further code simplification will be possible. Moreover it will be possible to handle multiple mixer devices in the system. Signed-off-by: Andrzej Hajda Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_mixer.c | 100 +++++++++++++------------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index a41c84ee3a2d..1b1fd82ec262 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -40,8 +40,6 @@ #include "exynos_drm_iommu.h" #include "exynos_mixer.h" -#define get_mixer_manager(dev) platform_get_drvdata(to_platform_device(dev)) - #define MIXER_WIN_NR 3 #define MIXER_DEFAULT_WIN 0 @@ -86,6 +84,7 @@ enum mixer_version_id { }; struct mixer_context { + struct exynos_drm_manager manager; struct platform_device *pdev; struct device *dev; struct drm_device *drm_dev; @@ -1187,11 +1186,6 @@ static struct exynos_drm_manager_ops mixer_manager_ops = { .win_disable = mixer_win_disable, }; -static struct exynos_drm_manager mixer_manager = { - .type = EXYNOS_DISPLAY_TYPE_HDMI, - .ops = &mixer_manager_ops, -}; - static struct mixer_drv_data exynos5420_mxr_drv_data = { .version = MXR_VER_128_0_0_184, .is_vp_enabled = 0, @@ -1249,13 +1243,45 @@ MODULE_DEVICE_TABLE(of, mixer_match_types); static int mixer_bind(struct device *dev, struct device *manager, void *data) { - struct platform_device *pdev = to_platform_device(dev); + struct mixer_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - struct mixer_context *ctx; - struct mixer_drv_data *drv; int ret; - dev_info(dev, "probe start\n"); + ret = mixer_initialize(&ctx->manager, drm_dev); + if (ret) + return ret; + + ret = exynos_drm_crtc_create(&ctx->manager); + if (ret) { + mixer_mgr_remove(&ctx->manager); + return ret; + } + + pm_runtime_enable(dev); + + return 0; +} + +static void mixer_unbind(struct device *dev, struct device *master, void *data) +{ + struct mixer_context *ctx = dev_get_drvdata(dev); + + mixer_mgr_remove(&ctx->manager); + + pm_runtime_disable(dev); +} + +static const struct component_ops mixer_component_ops = { + .bind = mixer_bind, + .unbind = mixer_unbind, +}; + +static int mixer_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mixer_drv_data *drv; + struct mixer_context *ctx; + int ret; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) { @@ -1265,8 +1291,12 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) mutex_init(&ctx->mixer_mutex); + ctx->manager.type = EXYNOS_DISPLAY_TYPE_HDMI; + ctx->manager.ops = &mixer_manager_ops; + if (dev->of_node) { const struct of_device_id *match; + match = of_match_node(mixer_match_types, dev->of_node); drv = (struct mixer_drv_data *)match->data; } else { @@ -1281,58 +1311,30 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) ctx->mxr_ver = drv->version; init_waitqueue_head(&ctx->wait_vsync_queue); atomic_set(&ctx->wait_vsync_event, 0); + ctx->manager.ctx = ctx; - mixer_manager.ctx = ctx; - ret = mixer_initialize(&mixer_manager, drm_dev); - if (ret) - return ret; - - platform_set_drvdata(pdev, &mixer_manager); - ret = exynos_drm_crtc_create(&mixer_manager); - if (ret) { - mixer_mgr_remove(&mixer_manager); - return ret; - } - - pm_runtime_enable(dev); - - return 0; -} - -static void mixer_unbind(struct device *dev, struct device *master, void *data) -{ - struct exynos_drm_manager *mgr = dev_get_drvdata(dev); - - dev_info(dev, "remove successful\n"); - - mixer_mgr_remove(mgr); - - pm_runtime_disable(dev); -} - -static const struct component_ops mixer_component_ops = { - .bind = mixer_bind, - .unbind = mixer_unbind, -}; - -static int mixer_probe(struct platform_device *pdev) -{ - int ret; + platform_set_drvdata(pdev, ctx); ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, - mixer_manager.type); + ctx->manager.type); if (ret) return ret; ret = component_add(&pdev->dev, &mixer_component_ops); - if (ret) + if (ret) { exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); + return ret; + } + + pm_runtime_enable(dev); return ret; } static int mixer_remove(struct platform_device *pdev) { + pm_runtime_disable(&pdev->dev); + component_del(&pdev->dev, &mixer_component_ops); exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC);