Commit ec727e3f authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Tomi Valkeinen

drm/omap: dss: Add functions to connect and disconnect devices

The omap_dss_device objects model display components and are connected
at runtime to create display pipelines. The connect and disconnect
operations implemented by each component contain lots of duplicate code.
As a first step towards fixing this, create new functions to wrap the
direct calls to those operations and use them.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent b93109d7
...@@ -59,7 +59,7 @@ static int tvc_connect(struct omap_dss_device *dssdev) ...@@ -59,7 +59,7 @@ static int tvc_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -79,7 +79,7 @@ static void tvc_disconnect(struct omap_dss_device *dssdev) ...@@ -79,7 +79,7 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -72,7 +72,7 @@ static int dvic_connect(struct omap_dss_device *dssdev) ...@@ -72,7 +72,7 @@ static int dvic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -90,7 +90,7 @@ static void dvic_disconnect(struct omap_dss_device *dssdev) ...@@ -90,7 +90,7 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -69,7 +69,7 @@ static int hdmic_connect(struct omap_dss_device *dssdev) ...@@ -69,7 +69,7 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -89,7 +89,7 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev) ...@@ -89,7 +89,7 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -50,7 +50,7 @@ static int opa362_connect(struct omap_dss_device *dssdev, ...@@ -50,7 +50,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -82,7 +82,7 @@ static void opa362_disconnect(struct omap_dss_device *dssdev, ...@@ -82,7 +82,7 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
dst->src = NULL; dst->src = NULL;
dssdev->dst = NULL; dssdev->dst = NULL;
in->ops->disconnect(in, &ddata->dssdev); omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -44,7 +44,7 @@ static int tfp410_connect(struct omap_dss_device *dssdev, ...@@ -44,7 +44,7 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -74,7 +74,7 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev, ...@@ -74,7 +74,7 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
dst->src = NULL; dst->src = NULL;
dssdev->dst = NULL; dssdev->dst = NULL;
in->ops->disconnect(in, &ddata->dssdev); omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -49,7 +49,7 @@ static int tpd_connect(struct omap_dss_device *dssdev, ...@@ -49,7 +49,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -85,7 +85,7 @@ static void tpd_disconnect(struct omap_dss_device *dssdev, ...@@ -85,7 +85,7 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
dst->src = NULL; dst->src = NULL;
dssdev->dst = NULL; dssdev->dst = NULL;
in->ops->disconnect(in, &ddata->dssdev); omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -50,7 +50,7 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev) ...@@ -50,7 +50,7 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -68,7 +68,7 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev) ...@@ -68,7 +68,7 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -772,7 +772,7 @@ static int dsicm_connect(struct omap_dss_device *dssdev) ...@@ -772,7 +772,7 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
dev_err(dev, "Failed to connect to video source\n"); dev_err(dev, "Failed to connect to video source\n");
goto err_connect; goto err_connect;
...@@ -796,7 +796,7 @@ static int dsicm_connect(struct omap_dss_device *dssdev) ...@@ -796,7 +796,7 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
err_vc_id: err_vc_id:
in->ops->dsi.release_vc(in, ddata->channel); in->ops->dsi.release_vc(in, ddata->channel);
err_req_vc: err_req_vc:
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
err_connect: err_connect:
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -811,7 +811,7 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev) ...@@ -811,7 +811,7 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev)
return; return;
in->ops->dsi.release_vc(in, ddata->channel); in->ops->dsi.release_vc(in, ddata->channel);
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -131,7 +131,7 @@ static int lb035q02_connect(struct omap_dss_device *dssdev) ...@@ -131,7 +131,7 @@ static int lb035q02_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -151,7 +151,7 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev) ...@@ -151,7 +151,7 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -127,7 +127,7 @@ static int nec_8048_connect(struct omap_dss_device *dssdev) ...@@ -127,7 +127,7 @@ static int nec_8048_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -145,7 +145,7 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev) ...@@ -145,7 +145,7 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -73,7 +73,7 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev) ...@@ -73,7 +73,7 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -91,7 +91,7 @@ static void sharp_ls_disconnect(struct omap_dss_device *dssdev) ...@@ -91,7 +91,7 @@ static void sharp_ls_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -522,7 +522,7 @@ static int acx565akm_connect(struct omap_dss_device *dssdev) ...@@ -522,7 +522,7 @@ static int acx565akm_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -540,7 +540,7 @@ static void acx565akm_disconnect(struct omap_dss_device *dssdev) ...@@ -540,7 +540,7 @@ static void acx565akm_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -181,7 +181,7 @@ static int td028ttec1_panel_connect(struct omap_dss_device *dssdev) ...@@ -181,7 +181,7 @@ static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -199,7 +199,7 @@ static void td028ttec1_panel_disconnect(struct omap_dss_device *dssdev) ...@@ -199,7 +199,7 @@ static void td028ttec1_panel_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -352,7 +352,7 @@ static int tpo_td043_connect(struct omap_dss_device *dssdev) ...@@ -352,7 +352,7 @@ static int tpo_td043_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in); return PTR_ERR(in);
} }
r = in->ops->connect(in, dssdev); r = omapdss_device_connect(in, dssdev);
if (r) { if (r) {
omap_dss_put_device(in); omap_dss_put_device(in);
return r; return r;
...@@ -370,7 +370,7 @@ static void tpo_td043_disconnect(struct omap_dss_device *dssdev) ...@@ -370,7 +370,7 @@ static void tpo_td043_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev)) if (!omapdss_device_is_connected(dssdev))
return; return;
in->ops->disconnect(in, dssdev); omapdss_device_disconnect(in, dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);
ddata->in = NULL; ddata->in = NULL;
......
...@@ -102,6 +102,26 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src, ...@@ -102,6 +102,26 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
return NULL; return NULL;
} }
int omapdss_device_connect(struct omap_dss_device *src,
struct omap_dss_device *dst)
{
if (src->driver)
return src->driver->connect(src);
else
return src->ops->connect(src, dst);
}
EXPORT_SYMBOL_GPL(omapdss_device_connect);
void omapdss_device_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst)
{
if (src->driver)
src->driver->disconnect(src);
else
src->ops->disconnect(src, dst);
}
EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Components Handling * Components Handling
*/ */
......
...@@ -498,6 +498,10 @@ void omapdss_device_register(struct omap_dss_device *dssdev); ...@@ -498,6 +498,10 @@ void omapdss_device_register(struct omap_dss_device *dssdev);
void omapdss_device_unregister(struct omap_dss_device *dssdev); void omapdss_device_unregister(struct omap_dss_device *dssdev);
struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src, struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
unsigned int port); unsigned int port);
int omapdss_device_connect(struct omap_dss_device *src,
struct omap_dss_device *dst);
void omapdss_device_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst);
struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev); struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
void omap_dss_put_device(struct omap_dss_device *dssdev); void omap_dss_put_device(struct omap_dss_device *dssdev);
......
...@@ -159,7 +159,7 @@ static void omap_disconnect_dssdevs(struct drm_device *ddev) ...@@ -159,7 +159,7 @@ static void omap_disconnect_dssdevs(struct drm_device *ddev)
for (i = 0; i < priv->num_dssdevs; i++) { for (i = 0; i < priv->num_dssdevs; i++) {
struct omap_dss_device *dssdev = priv->dssdevs[i]; struct omap_dss_device *dssdev = priv->dssdevs[i];
dssdev->driver->disconnect(dssdev); omapdss_device_disconnect(dssdev, NULL);
priv->dssdevs[i] = NULL; priv->dssdevs[i] = NULL;
omap_dss_put_device(dssdev); omap_dss_put_device(dssdev);
} }
...@@ -189,7 +189,7 @@ static int omap_connect_dssdevs(struct drm_device *ddev) ...@@ -189,7 +189,7 @@ static int omap_connect_dssdevs(struct drm_device *ddev)
return -EPROBE_DEFER; return -EPROBE_DEFER;
for_each_dss_dev(dssdev) { for_each_dss_dev(dssdev) {
r = dssdev->driver->connect(dssdev); r = omapdss_device_connect(dssdev, NULL);
if (r == -EPROBE_DEFER) { if (r == -EPROBE_DEFER) {
omap_dss_put_device(dssdev); omap_dss_put_device(dssdev);
goto cleanup; goto cleanup;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment