Skip to contentSkip to conversation

drm/exynos: more cleanup with super device support

RFC PATCH New Inki Dae 1 participant 5 messages Mar 3, 2014

Subsystems (4)
lore
Share & tools
lore

Inki Dae

author maintainer
#0 lore raw

cover drm/exynos: more cleanup with super device support

This patch series cleans up exynos drm framework and kms sub drivers using the component framework[1]. This is based on top of below Andrezej's patch series[2].

And you can find git repository related to this patch series below,
https://git.kernel.org/cgit/linux/kernel/git/daeinki/drm-exynos.git/log/?h=exynos-drm-next-todo

We have patch sets not posted yet and these patch sets will be posted by Andrezej Hajda and Tomasz Stanislawski soon. So this cleanup series would be rebased on top of them again.

This post is just for RFC.

Thanks,
Inki Dae

[1] http://lists.freedesktop.org/archives/dri-devel/2014-January/051249.html
[2] http://comments.gmane.org/gmane.linux.kernel.samsung-soc/27044

Inki Dae (3):
drm/exynos: fix unnecessary resource cleanup drm/exynos: add super device support
drm/exynos: register platform driver at each kms sub drivers

 drivers/gpu/drm/exynos/exynos_dp_core.c  |   46 ++++--
 drivers/gpu/drm/exynos/exynos_drm_core.c |  204 +----------------------
 drivers/gpu/drm/exynos/exynos_drm_crtc.c |   17 ++
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |    4 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  266 +++++++++++++-----------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |   57 ++-----
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  |   49 ++++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |   49 ++++--
 drivers/gpu/drm/exynos/exynos_drm_vidi.c |   61 +++++--
 drivers/gpu/drm/exynos/exynos_hdmi.c     |   47 ++++--
 drivers/gpu/drm/exynos/exynos_mixer.c    |   55 ++++--
 11 files changed, 376 insertions(+), 479 deletions(-)
Signature · 1 line
1.7.9.5
author maintainer
#1 lore raw

RFC PATCH 1/3 drm/exynos: fix unnecessary resource cleanup

This patch removes unnecessary drm_mode_config_cleanup call.

---
 drivers/gpu/drm/exynos/exynos_drm_drv.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +2 -3
index cba25b1..de010b1 100644
@@ -66,7 +66,7 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
 	ret = drm_create_iommu_mapping(dev);
 	if (ret < 0) {
 		DRM_ERROR("failed to create iommu mapping.\n");
-		goto err_crtc;
+		goto err_free_private;
 	}
 
 	drm_mode_config_init(dev);
@@ -124,8 +124,7 @@ err_manager_cleanup:
 err_mode_config_cleanup:
 	drm_mode_config_cleanup(dev);
 	drm_release_iommu_mapping(dev);
-err_crtc:
-	drm_mode_config_cleanup(dev);
+err_free_private:
 	kfree(private);
 
 	return ret;
Signature · 1 line
1.7.9.5
author maintainer
#2 lore raw

RFC PATCH 2/3 drm/exynos: add super device support

In reply to Inki Dae

This patch adds super device support to bind sub drivers using device tree.

For this, we should add a super device node to each machine dt files like below example,

	exynos-drm {
		crtcs = <&fimd>;
		connectors = <&dsi>;
	};

crtcs propery can declare crtc device nodes, fimd and mixer. And connectors propery can declare connector device nodes, MIPI-DSI, eDP, and HDMI.

With this patch, we can resolve the probing order issue without some lists. So this patch also removes unnecessary lists and stuff related to these lists.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c  |   45 ++++---
 drivers/gpu/drm/exynos/exynos_drm_core.c |  204 +----------------------------
 drivers/gpu/drm/exynos/exynos_drm_crtc.c |   17 +++
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |    4 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  209 ++++++++++++++++--------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |   57 +++-----
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  |   48 ++++---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |   48 +++++--
 drivers/gpu/drm/exynos/exynos_drm_vidi.c |   61 +++++++--
 drivers/gpu/drm/exynos/exynos_hdmi.c     |   46 ++++---
 drivers/gpu/drm/exynos/exynos_mixer.c    |   54 ++++++--
 11 files changed, 374 insertions(+), 419 deletions(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +28 -17
index a59bca9..cb9aa58 100644
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/of.h>
+#include <linux/component.h>
 #include <linux/phy/phy.h>
 #include <video/of_display_timing.h>
 #include <video/of_videomode.h>
@@ -969,16 +970,6 @@ static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
 	.best_encoder = exynos_dp_best_encoder,
 };
 
-static int exynos_dp_initialize(struct exynos_drm_display *display,
-				struct drm_device *drm_dev)
-{
-	struct exynos_dp_device *dp = display->ctx;
-
-	dp->drm_dev = drm_dev;
-
-	return 0;
-}
-
 static bool find_bridge(const char *compat, struct bridge_init *bridge)
 {
 	bridge->client = NULL;
@@ -1106,7 +1097,6 @@ static void exynos_dp_dpms(struct exynos_drm_display *display, int mode)
 }
 
 static struct exynos_drm_display_ops exynos_dp_display_ops = {
-	.initialize = exynos_dp_initialize,
 	.create_connector = exynos_dp_create_connector,
 	.dpms = exynos_dp_dpms,
 };
@@ -1230,8 +1220,10 @@ static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
 	return 0;
 }
 
-static int exynos_dp_probe(struct platform_device *pdev)
+static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
 {
+	struct platform_device *pdev = to_platform_device(dev);
+	struct drm_device *drm_dev = data;
 	struct resource *res;
 	struct exynos_dp_device *dp;
 
@@ -1293,21 +1285,40 @@ static int exynos_dp_probe(struct platform_device *pdev)
 	}
 	disable_irq(dp->irq);
 
+	dp->drm_dev = drm_dev;
 	exynos_dp_display.ctx = dp;
 
 	platform_set_drvdata(pdev, &exynos_dp_display);
-	exynos_drm_display_register(&exynos_dp_display);
 
-	return 0;
+	return exynos_drm_create_enc_conn(drm_dev, &exynos_dp_display);
 }
 
-static int exynos_dp_remove(struct platform_device *pdev)
+static void exynos_dp_unbind(struct device *dev, struct device *master,
+				void *data)
 {
-	struct exynos_drm_display *display = platform_get_drvdata(pdev);
+	struct exynos_drm_display *display = dev_get_drvdata(dev);
+	struct exynos_dp_device *dp = display->ctx;
+	struct drm_encoder *encoder = dp->encoder;
 
 	exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
-	exynos_drm_display_unregister(&exynos_dp_display);
 
+	encoder->funcs->destroy(encoder);
+	drm_connector_cleanup(&dp->connector);
+}
+
+static const struct component_ops exynos_dp_ops = {
+	.bind	= exynos_dp_bind,
+	.unbind	= exynos_dp_unbind,
+};
+
+static int exynos_dp_probe(struct platform_device *pdev)
+{
+	return component_add(&pdev->dev, &exynos_dp_ops);
+}
+
+static int exynos_dp_remove(struct platform_device *pdev)
+{
+	component_del(&pdev->dev, &exynos_dp_ops);
 	return 0;
 }
 
drivers/gpu/drm/exynos/exynos_drm_core.c +6 -198

223 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_crtc.c +17 -0
index 100a561..ce1054e 100644
@@ -367,6 +367,7 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager)
 		return -ENOMEM;
 	}
 
+	manager->crtc = &exynos_crtc->drm_crtc;
 	crtc = &exynos_crtc->drm_crtc;
 
 	private->crtc[manager->pipe] = crtc;
@@ -490,3 +491,19 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb)
 			manager->ops->wait_for_vblank(manager);
 	}
 }
+
+int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
+					unsigned int out_type)
+{
+	struct drm_crtc *crtc;
+
+	list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) {
+		struct exynos_drm_crtc *exynos_crtc;
+
+		exynos_crtc = to_exynos_crtc(crtc);
+		if (exynos_crtc->manager->type == out_type)
+			return exynos_crtc->manager->pipe;
+	}
+
+	return -EPERM;
+}
drivers/gpu/drm/exynos/exynos_drm_crtc.h +4 -0
index c27b66c..9f74b10 100644
@@ -32,4 +32,8 @@ void exynos_drm_crtc_plane_commit(struct drm_crtc *crtc, int zpos);
 void exynos_drm_crtc_plane_enable(struct drm_crtc *crtc, int zpos);
 void exynos_drm_crtc_plane_disable(struct drm_crtc *crtc, int zpos);
 
+/* This function gets pipe value to crtc device matched with out_type. */
+int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
+					unsigned int out_type);
+
 #endif
drivers/gpu/drm/exynos/exynos_drm_drv.c +115 -94

320 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_drv.h +18 -39

125 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_dsi.c +33 -15

92 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_fimd.c +35 -13

93 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_vidi.c +47 -14

120 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_hdmi.c +28 -18

96 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_mixer.c +43 -11

101 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author maintainer
#3 lore raw

RFC PATCH 2/3 drm/exynos: add super device support

From: Inki Dae <[email protected]>

This patch adds super device support to bind sub drivers using device tree.

For this, we should add a super device node to each machine dt files like below example,

	exynos-drm {
		compatible = "samsung,exynos-drm";
		crtcs = <&fimd>;
		connectors = <&dsi>;
	};

crtcs propery can declare crtc device nodes, fimd and mixer. And connectors propery can declare connector device nodes, MIPI-DSI, eDP, and HDMI.

With this patch, we can resolve the probing order issue without some lists. So this patch also removes unnecessary lists and stuff related to these lists.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c  |  45 ++++---
 drivers/gpu/drm/exynos/exynos_drm_core.c | 204 +-----------------------------
 drivers/gpu/drm/exynos/exynos_drm_crtc.c |  17 +++
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |   4 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  | 209 +++++++++++++++++--------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  57 +++------
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  |  48 ++++---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |  48 +++++--
 drivers/gpu/drm/exynos/exynos_drm_vidi.c |  61 ++++++---
 drivers/gpu/drm/exynos/exynos_hdmi.c     |  46 ++++---
 drivers/gpu/drm/exynos/exynos_mixer.c    |  54 ++++++--
 11 files changed, 374 insertions(+), 419 deletions(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +28 -17
index a59bca9..cb9aa58 100644
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/of.h>
+#include <linux/component.h>
 #include <linux/phy/phy.h>
 #include <video/of_display_timing.h>
 #include <video/of_videomode.h>
@@ -969,16 +970,6 @@ static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
 	.best_encoder = exynos_dp_best_encoder,
 };
 
-static int exynos_dp_initialize(struct exynos_drm_display *display,
-				struct drm_device *drm_dev)
-{
-	struct exynos_dp_device *dp = display->ctx;
-
-	dp->drm_dev = drm_dev;
-
-	return 0;
-}
-
 static bool find_bridge(const char *compat, struct bridge_init *bridge)
 {
 	bridge->client = NULL;
@@ -1106,7 +1097,6 @@ static void exynos_dp_dpms(struct exynos_drm_display *display, int mode)
 }
 
 static struct exynos_drm_display_ops exynos_dp_display_ops = {
-	.initialize = exynos_dp_initialize,
 	.create_connector = exynos_dp_create_connector,
 	.dpms = exynos_dp_dpms,
 };
@@ -1230,8 +1220,10 @@ static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
 	return 0;
 }
 
-static int exynos_dp_probe(struct platform_device *pdev)
+static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
 {
+	struct platform_device *pdev = to_platform_device(dev);
+	struct drm_device *drm_dev = data;
 	struct resource *res;
 	struct exynos_dp_device *dp;
 
@@ -1293,21 +1285,40 @@ static int exynos_dp_probe(struct platform_device *pdev)
 	}
 	disable_irq(dp->irq);
 
+	dp->drm_dev = drm_dev;
 	exynos_dp_display.ctx = dp;
 
 	platform_set_drvdata(pdev, &exynos_dp_display);
-	exynos_drm_display_register(&exynos_dp_display);
 
-	return 0;
+	return exynos_drm_create_enc_conn(drm_dev, &exynos_dp_display);
 }
 
-static int exynos_dp_remove(struct platform_device *pdev)
+static void exynos_dp_unbind(struct device *dev, struct device *master,
+				void *data)
 {
-	struct exynos_drm_display *display = platform_get_drvdata(pdev);
+	struct exynos_drm_display *display = dev_get_drvdata(dev);
+	struct exynos_dp_device *dp = display->ctx;
+	struct drm_encoder *encoder = dp->encoder;
 
 	exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
-	exynos_drm_display_unregister(&exynos_dp_display);
 
+	encoder->funcs->destroy(encoder);
+	drm_connector_cleanup(&dp->connector);
+}
+
+static const struct component_ops exynos_dp_ops = {
+	.bind	= exynos_dp_bind,
+	.unbind	= exynos_dp_unbind,
+};
+
+static int exynos_dp_probe(struct platform_device *pdev)
+{
+	return component_add(&pdev->dev, &exynos_dp_ops);
+}
+
+static int exynos_dp_remove(struct platform_device *pdev)
+{
+	component_del(&pdev->dev, &exynos_dp_ops);
 	return 0;
 }
 
drivers/gpu/drm/exynos/exynos_drm_core.c +6 -198

223 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_crtc.c +17 -0
index 100a561..ce1054e 100644
@@ -367,6 +367,7 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager)
 		return -ENOMEM;
 	}
 
+	manager->crtc = &exynos_crtc->drm_crtc;
 	crtc = &exynos_crtc->drm_crtc;
 
 	private->crtc[manager->pipe] = crtc;
@@ -490,3 +491,19 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb)
 			manager->ops->wait_for_vblank(manager);
 	}
 }
+
+int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
+					unsigned int out_type)
+{
+	struct drm_crtc *crtc;
+
+	list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) {
+		struct exynos_drm_crtc *exynos_crtc;
+
+		exynos_crtc = to_exynos_crtc(crtc);
+		if (exynos_crtc->manager->type == out_type)
+			return exynos_crtc->manager->pipe;
+	}
+
+	return -EPERM;
+}
drivers/gpu/drm/exynos/exynos_drm_crtc.h +4 -0
index c27b66c..9f74b10 100644
@@ -32,4 +32,8 @@ void exynos_drm_crtc_plane_commit(struct drm_crtc *crtc, int zpos);
 void exynos_drm_crtc_plane_enable(struct drm_crtc *crtc, int zpos);
 void exynos_drm_crtc_plane_disable(struct drm_crtc *crtc, int zpos);
 
+/* This function gets pipe value to crtc device matched with out_type. */
+int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
+					unsigned int out_type);
+
 #endif
drivers/gpu/drm/exynos/exynos_drm_drv.c +115 -94

320 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_drv.h +18 -39

125 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_dsi.c +33 -15

92 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_fimd.c +35 -13

93 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_vidi.c +47 -14

120 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_hdmi.c +28 -18

96 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_mixer.c +43 -11

101 lines not on this page · raw message

Signature · 1 line
1.8.0.rc3.16.g8ead1bf
author maintainer
#4 lore raw

RFC PATCH 3/3 drm/exynos: register platform driver at each kms sub drivers

In reply to Inki Dae

This patch removes platform_driver_register() calls from exynos_drm_drv module, and call module_platform_driver() at each kms sub drivers instead.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c  |    1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |   62 ------------------------------
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  |    1 +
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |    1 +
 drivers/gpu/drm/exynos/exynos_hdmi.c     |    1 +
 drivers/gpu/drm/exynos/exynos_mixer.c    |    1 +
 6 files changed, 5 insertions(+), 62 deletions(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +1 -0
index cb9aa58..bf4996f 100644
@@ -1362,6 +1362,7 @@ struct platform_driver dp_driver = {
 		.of_match_table = exynos_dp_match,
 	},
 };
+module_platform_driver(dp_driver);
 
 MODULE_AUTHOR("Jingoo Han <[email protected]>");
 MODULE_DESCRIPTION("Samsung SoC DP Driver");
drivers/gpu/drm/exynos/exynos_drm_drv.c +0 -62

80 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_drm_dsi.c +1 -0
index 89e8585..a54149c 100644
@@ -1413,6 +1413,7 @@ struct platform_driver dsi_driver = {
 		   .of_match_table = exynos_dsi_of_match,
 	},
 };
+module_platform_driver(dsi_driver);
 
 MODULE_AUTHOR("Tomasz Figa <[email protected]>");
 MODULE_AUTHOR("Andrzej Hajda <[email protected]>");
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -0
index 8d41288..ea73d5a 100644
@@ -974,3 +974,4 @@ struct platform_driver fimd_driver = {
 		.of_match_table = fimd_driver_dt_match,
 	},
 };
+module_platform_driver(fimd_driver);
drivers/gpu/drm/exynos/exynos_hdmi.c +1 -0
index 712ce2d..12fdf55 100644
@@ -2108,3 +2108,4 @@ struct platform_driver hdmi_driver = {
 		.of_match_table = hdmi_match_types,
 	},
 };
+module_platform_driver(hdmi_driver);
drivers/gpu/drm/exynos/exynos_mixer.c +1 -0
index d46a262..12ef887 100644
@@ -1292,3 +1292,4 @@ struct platform_driver mixer_driver = {
 	.remove = mixer_remove,
 	.id_table	= mixer_driver_types,
 };
+module_platform_driver(mixer_driver);
Signature · 1 line
1.7.9.5