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

drm/omap: Factor out common init/cleanup code for output devices

All the internal encoders share common init and cleanup code. Factor it
out to separate functions.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 56c9818d
...@@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port) ...@@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
out->ops = &dpi_ops; out->ops = &dpi_ops;
out->owner = THIS_MODULE; out->owner = THIS_MODULE;
out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); r = omapdss_device_init_output(out);
if (IS_ERR(out->next)) { if (r < 0)
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r; return r;
}
omapdss_device_register(out); omapdss_device_register(out);
...@@ -665,9 +655,8 @@ static void dpi_uninit_output_port(struct device_node *port) ...@@ -665,9 +655,8 @@ static void dpi_uninit_output_port(struct device_node *port)
struct dpi_data *dpi = port->data; struct dpi_data *dpi = port->data;
struct omap_dss_device *out = &dpi->output; struct omap_dss_device *out = &dpi->output;
if (out->next)
omapdss_device_put(out->next);
omapdss_device_unregister(out); omapdss_device_unregister(out);
omapdss_device_cleanup_output(out);
} }
static const struct soc_device_attribute dpi_soc_devices[] = { static const struct soc_device_attribute dpi_soc_devices[] = {
......
...@@ -5131,19 +5131,9 @@ static int dsi_init_output(struct dsi_data *dsi) ...@@ -5131,19 +5131,9 @@ static int dsi_init_output(struct dsi_data *dsi)
| DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_DE_HIGH
| DRM_BUS_FLAG_SYNC_NEGEDGE; | DRM_BUS_FLAG_SYNC_NEGEDGE;
out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); r = omapdss_device_init_output(out);
if (IS_ERR(out->next)) { if (r < 0)
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r; return r;
}
omapdss_device_register(out); omapdss_device_register(out);
...@@ -5154,9 +5144,8 @@ static void dsi_uninit_output(struct dsi_data *dsi) ...@@ -5154,9 +5144,8 @@ static void dsi_uninit_output(struct dsi_data *dsi)
{ {
struct omap_dss_device *out = &dsi->output; struct omap_dss_device *out = &dsi->output;
if (out->next)
omapdss_device_put(out->next);
omapdss_device_unregister(out); omapdss_device_unregister(out);
omapdss_device_cleanup_output(out);
} }
static int dsi_probe_of(struct dsi_data *dsi) static int dsi_probe_of(struct dsi_data *dsi)
......
...@@ -687,19 +687,9 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi) ...@@ -687,19 +687,9 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
out->of_ports = BIT(0); out->of_ports = BIT(0);
out->ops_flags = OMAP_DSS_DEVICE_OP_EDID; out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); r = omapdss_device_init_output(out);
if (IS_ERR(out->next)) { if (r < 0)
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r; return r;
}
omapdss_device_register(out); omapdss_device_register(out);
...@@ -710,9 +700,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi) ...@@ -710,9 +700,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
{ {
struct omap_dss_device *out = &hdmi->output; struct omap_dss_device *out = &hdmi->output;
if (out->next)
omapdss_device_put(out->next);
omapdss_device_unregister(out); omapdss_device_unregister(out);
omapdss_device_cleanup_output(out);
} }
static int hdmi4_probe_of(struct omap_hdmi *hdmi) static int hdmi4_probe_of(struct omap_hdmi *hdmi)
......
...@@ -671,19 +671,9 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi) ...@@ -671,19 +671,9 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
out->of_ports = BIT(0); out->of_ports = BIT(0);
out->ops_flags = OMAP_DSS_DEVICE_OP_EDID; out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); r = omapdss_device_init_output(out);
if (IS_ERR(out->next)) { if (r < 0)
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r; return r;
}
omapdss_device_register(out); omapdss_device_register(out);
...@@ -694,9 +684,8 @@ static void hdmi5_uninit_output(struct omap_hdmi *hdmi) ...@@ -694,9 +684,8 @@ static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
{ {
struct omap_dss_device *out = &hdmi->output; struct omap_dss_device *out = &hdmi->output;
if (out->next)
omapdss_device_put(out->next);
omapdss_device_unregister(out); omapdss_device_unregister(out);
omapdss_device_cleanup_output(out);
} }
static int hdmi5_probe_of(struct omap_hdmi *hdmi) static int hdmi5_probe_of(struct omap_hdmi *hdmi)
......
...@@ -493,7 +493,8 @@ int omap_dss_get_num_overlays(void); ...@@ -493,7 +493,8 @@ int omap_dss_get_num_overlays(void);
#define for_each_dss_output(d) \ #define for_each_dss_output(d) \
while ((d = omapdss_device_next_output(d)) != NULL) while ((d = omapdss_device_next_output(d)) != NULL)
struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from); struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from);
int omapdss_output_validate(struct omap_dss_device *out); int omapdss_device_init_output(struct omap_dss_device *out);
void omapdss_device_cleanup_output(struct omap_dss_device *out);
typedef void (*omap_dispc_isr_t) (void *arg, u32 mask); typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask); int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
......
...@@ -24,8 +24,15 @@ ...@@ -24,8 +24,15 @@
#include "dss.h" #include "dss.h"
#include "omapdss.h" #include "omapdss.h"
int omapdss_output_validate(struct omap_dss_device *out) int omapdss_device_init_output(struct omap_dss_device *out)
{ {
out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
if (IS_ERR(out->next)) {
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
if (out->next && out->output_type != out->next->type) { if (out->next && out->output_type != out->next->type) {
dev_err(out->dev, "output type and display type don't match\n"); dev_err(out->dev, "output type and display type don't match\n");
return -EINVAL; return -EINVAL;
...@@ -33,7 +40,14 @@ int omapdss_output_validate(struct omap_dss_device *out) ...@@ -33,7 +40,14 @@ int omapdss_output_validate(struct omap_dss_device *out)
return 0; return 0;
} }
EXPORT_SYMBOL(omapdss_output_validate); EXPORT_SYMBOL(omapdss_device_init_output);
void omapdss_device_cleanup_output(struct omap_dss_device *out)
{
if (out->next)
omapdss_device_put(out->next);
}
EXPORT_SYMBOL(omapdss_device_cleanup_output);
int dss_install_mgr_ops(struct dss_device *dss, int dss_install_mgr_ops(struct dss_device *dss,
const struct dss_mgr_ops *mgr_ops, const struct dss_mgr_ops *mgr_ops,
......
...@@ -281,19 +281,9 @@ static int sdi_init_output(struct sdi_device *sdi) ...@@ -281,19 +281,9 @@ static int sdi_init_output(struct sdi_device *sdi)
out->bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE /* 15.5.9.1.2 */ out->bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE /* 15.5.9.1.2 */
| DRM_BUS_FLAG_SYNC_POSEDGE; | DRM_BUS_FLAG_SYNC_POSEDGE;
out->next = omapdss_of_find_connected_device(out->dev->of_node, 1); r = omapdss_device_init_output(out);
if (IS_ERR(out->next)) { if (r < 0)
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r; return r;
}
omapdss_device_register(out); omapdss_device_register(out);
...@@ -302,9 +292,8 @@ static int sdi_init_output(struct sdi_device *sdi) ...@@ -302,9 +292,8 @@ static int sdi_init_output(struct sdi_device *sdi)
static void sdi_uninit_output(struct sdi_device *sdi) static void sdi_uninit_output(struct sdi_device *sdi)
{ {
if (sdi->output.next)
omapdss_device_put(sdi->output.next);
omapdss_device_unregister(&sdi->output); omapdss_device_unregister(&sdi->output);
omapdss_device_cleanup_output(&sdi->output);
} }
int sdi_init_port(struct dss_device *dss, struct platform_device *pdev, int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
......
...@@ -752,19 +752,9 @@ static int venc_init_output(struct venc_device *venc) ...@@ -752,19 +752,9 @@ static int venc_init_output(struct venc_device *venc)
out->owner = THIS_MODULE; out->owner = THIS_MODULE;
out->of_ports = BIT(0); out->of_ports = BIT(0);
out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); r = omapdss_device_init_output(out);
if (IS_ERR(out->next)) { if (r < 0)
if (PTR_ERR(out->next) != -EPROBE_DEFER)
dev_err(out->dev, "failed to find video sink\n");
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r; return r;
}
omapdss_device_register(out); omapdss_device_register(out);
...@@ -773,9 +763,8 @@ static int venc_init_output(struct venc_device *venc) ...@@ -773,9 +763,8 @@ static int venc_init_output(struct venc_device *venc)
static void venc_uninit_output(struct venc_device *venc) static void venc_uninit_output(struct venc_device *venc)
{ {
if (venc->output.next)
omapdss_device_put(venc->output.next);
omapdss_device_unregister(&venc->output); omapdss_device_unregister(&venc->output);
omapdss_device_cleanup_output(&venc->output);
} }
static int venc_probe_of(struct venc_device *venc) static int venc_probe_of(struct venc_device *venc)
......
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