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

drm/omap: dss: Move src and dst check and set to connection handlers

The encoders duplicate the same omap_dss_device src and dst fields set
and checks in their connect and disconnect handlers. Move the code to
the connect and disconnect wrappers.
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 73fc0ac4
......@@ -51,9 +51,6 @@ static int opa362_connect(struct omap_dss_device *dssdev,
return r;
}
dst->src = dssdev;
dssdev->dst = dst;
ddata->in = in;
return 0;
}
......@@ -64,13 +61,6 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
dst->src = NULL;
dssdev->dst = NULL;
omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in);
......
......@@ -47,9 +47,6 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
return r;
}
dst->src = dssdev;
dssdev->dst = dst;
ddata->in = in;
return 0;
}
......@@ -60,13 +57,6 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
dst->src = NULL;
dssdev->dst = NULL;
omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in);
......
......@@ -55,9 +55,6 @@ static int tpd_connect(struct omap_dss_device *dssdev,
return r;
}
dst->src = dssdev;
dssdev->dst = dst;
gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1);
gpiod_set_value_cansleep(ddata->ls_oe_gpio, 1);
......@@ -74,17 +71,9 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0);
gpiod_set_value_cansleep(ddata->ls_oe_gpio, 0);
dst->src = NULL;
dssdev->dst = NULL;
omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in);
......
......@@ -105,15 +105,27 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
int omapdss_device_connect(struct omap_dss_device *src,
struct omap_dss_device *dst)
{
int ret;
dev_dbg(src->dev, "connect\n");
if (omapdss_device_is_connected(src))
return -EBUSY;
if (src->driver)
return src->driver->connect(src);
ret = src->driver->connect(src);
else
return src->ops->connect(src, dst);
ret = src->ops->connect(src, dst);
if (ret < 0)
return ret;
if (dst) {
dst->src = src;
src->dst = dst;
}
return 0;
}
EXPORT_SYMBOL_GPL(omapdss_device_connect);
......@@ -127,6 +139,14 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
return;
}
if (dst) {
if (WARN_ON(dst != src->dst))
return;
dst->src = NULL;
src->dst = NULL;
}
if (src->driver)
src->driver->disconnect(src);
else
......
......@@ -671,11 +671,6 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
{
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&dpi->output, dssdev);
......
......@@ -4990,11 +4990,6 @@ static void dsi_disconnect(struct omap_dss_device *dssdev,
{
struct dsi_data *dsi = to_dsi_data(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&dsi->output, dssdev);
......
......@@ -478,11 +478,6 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
{
struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&hdmi->output, dssdev);
......
......@@ -481,11 +481,6 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
{
struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&hdmi->output, dssdev);
......
......@@ -391,6 +391,9 @@ struct omap_dss_device {
struct module *owner;
struct omap_dss_device *src;
struct omap_dss_device *dst;
struct list_head list;
struct list_head panel_list;
......@@ -409,8 +412,6 @@ struct omap_dss_device {
enum omap_display_caps caps;
struct omap_dss_device *src;
enum omap_dss_display_state state;
/* OMAP DSS output specific fields */
......@@ -426,9 +427,6 @@ struct omap_dss_device {
/* the port number in the DT node */
int port_num;
/* dynamic fields */
struct omap_dss_device *dst;
};
struct omap_dss_driver {
......
......@@ -47,9 +47,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
goto err;
}
out->dst = dssdev;
dssdev->src = out;
mutex_unlock(&output_lock);
return 0;
......@@ -81,9 +78,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
goto err;
}
out->dst->src = NULL;
out->dst = NULL;
mutex_unlock(&output_lock);
return 0;
......
......@@ -301,11 +301,6 @@ static void sdi_disconnect(struct omap_dss_device *dssdev,
{
struct sdi_device *sdi = dssdev_to_sdi(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&sdi->output, dssdev);
......
......@@ -740,11 +740,6 @@ static void venc_disconnect(struct omap_dss_device *dssdev,
{
struct venc_device *venc = dssdev_to_venc(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&venc->output, dssdev);
......
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