[PATCHv2 43/56] drm/omap: bind components with drm_device argument
Sebastian Reichel
sebastian.reichel at collabora.com
Mon Feb 24 23:21:13 UTC 2020
This fixes the omapdrm driver to call component_bind_all()
with drm_device as data argument as recommended in the
DRM component helper usage text.
After this patch DRM functionality can be implemented directly
in the components resulting in a simpler driver stack by removing
one layer of abstraction.
Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
---
drivers/gpu/drm/omapdrm/dss/dss.c | 27 +++++++++++++++++----------
drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 +++
drivers/gpu/drm/omapdrm/omap_drv.c | 15 +++++++++++----
3 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 4438947326ea..a0b37d9b62ea 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1301,26 +1301,35 @@ static const struct soc_device_attribute dss_soc_devices[] = {
{ /* sentinel */ }
};
+int dss_bind_components(struct dss_device *dss, struct drm_device *drm_dev)
+{
+ struct platform_device *pdev = dss->pdev;
+
+ return component_bind_all(&pdev->dev, drm_dev);
+}
+EXPORT_SYMBOL(dss_bind_components);
+
+void dss_unbind_components(struct dss_device *dss, struct drm_device *drm_dev)
+{
+ struct platform_device *pdev = dss->pdev;
+
+ component_unbind_all(&pdev->dev, drm_dev);
+}
+EXPORT_SYMBOL(dss_unbind_components);
+
static int dss_bind(struct device *dev)
{
struct dss_device *dss = dev_get_drvdata(dev);
struct platform_device *drm_pdev;
struct dss_pdata pdata;
- int r;
-
- r = component_bind_all(dev, NULL);
- if (r)
- return r;
pm_set_vt_switch(0);
pdata.dss = dss;
drm_pdev = platform_device_register_data(NULL, "omapdrm", 0,
&pdata, sizeof(pdata));
- if (IS_ERR(drm_pdev)) {
- component_unbind_all(dev, NULL);
+ if (IS_ERR(drm_pdev))
return PTR_ERR(drm_pdev);
- }
dss->drm_pdev = drm_pdev;
@@ -1332,8 +1341,6 @@ static void dss_unbind(struct device *dev)
struct dss_device *dss = dev_get_drvdata(dev);
platform_device_unregister(dss->drm_pdev);
-
- component_unbind_all(dev, NULL);
}
static const struct component_master_ops dss_component_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9f8aefaadefe..45f5c46712eb 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -526,4 +526,7 @@ const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
bool omapdss_stack_is_ready(void);
void omapdss_gather_components(struct device *dev);
+int dss_bind_components(struct dss_device *dss, struct drm_device *drm_dev);
+void dss_unbind_components(struct dss_device *dss, struct drm_device *drm_dev);
+
#endif /* __OMAP_DRM_DSS_H */
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 579f9d80fec9..c47e63e94a2e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -237,8 +237,6 @@ static int omap_modeset_init(struct drm_device *dev)
if (!omapdss_stack_is_ready())
return -EPROBE_DEFER;
- drm_mode_config_init(dev);
-
ret = omap_modeset_init_properties(dev);
if (ret < 0)
return ret;
@@ -605,10 +603,15 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
ddev = drm_dev_alloc(&omap_drm_driver, dev);
if (IS_ERR(ddev))
return PTR_ERR(ddev);
-
- priv->ddev = ddev;
ddev->dev_private = priv;
+ drm_mode_config_init(ddev);
+
+ ret = dss_bind_components(pdata->dss, ddev);
+ if (ret)
+ goto err_ddev_deinit;
+
+ priv->ddev = ddev;
priv->dev = dev;
priv->dss = pdata->dss;
priv->dispc = dispc_get_dispc(priv->dss);
@@ -673,6 +676,8 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
destroy_workqueue(priv->wq);
omap_disconnect_pipelines(ddev);
omap_crtc_pre_uninit(priv);
+ dss_unbind_components(priv->dss, ddev);
+err_ddev_deinit:
drm_dev_put(ddev);
return ret;
}
@@ -700,6 +705,8 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
omap_disconnect_pipelines(ddev);
omap_crtc_pre_uninit(priv);
+ dss_unbind_components(priv->dss, ddev);
+
drm_dev_put(ddev);
}
--
2.25.0
More information about the dri-devel
mailing list