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

drm/omap: dss: Move display type validation to initialization time

The display type is validated when the display is connected to the DSS
output. We already have all the information we need for validation when
initializing the outputs. Move validation to output initialization to
simplify pipeline connection handling.
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 79ddb2f0
......@@ -620,24 +620,13 @@ static int dpi_connect(struct omap_dss_device *src,
if (r)
return r;
r = omapdss_output_set_device(dst, dst->next);
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
goto err_mgr_disconnect;
dss_mgr_disconnect(dst);
return r;
}
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r)
goto err_output_unset;
return 0;
err_output_unset:
omapdss_output_unset_device(dst);
err_mgr_disconnect:
dss_mgr_disconnect(dst);
return r;
}
static void dpi_disconnect(struct omap_dss_device *src,
......@@ -664,6 +653,7 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
{
struct omap_dss_device *out = &dpi->output;
u32 port_num = 0;
int r;
of_property_read_u32(port, "reg", &port_num);
dpi->id = port_num <= 2 ? port_num : 0;
......@@ -696,6 +686,13 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r;
}
omapdss_device_register(out);
return 0;
......
......@@ -4890,24 +4890,13 @@ static int dsi_connect(struct omap_dss_device *src,
if (r)
return r;
r = omapdss_output_set_device(dst, dst->next);
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
goto err_mgr_disconnect;
dss_mgr_disconnect(dst);
return r;
}
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r)
goto err_output_unset;
return 0;
err_output_unset:
omapdss_output_unset_device(dst);
err_mgr_disconnect:
dss_mgr_disconnect(dst);
return r;
}
static void dsi_disconnect(struct omap_dss_device *src,
......@@ -5147,6 +5136,7 @@ static const struct component_ops dsi_component_ops = {
static int dsi_init_output(struct dsi_data *dsi)
{
struct omap_dss_device *out = &dsi->output;
int r;
out->dev = dsi->dev;
out->id = dsi->module_id == 0 ?
......@@ -5166,6 +5156,13 @@ static int dsi_init_output(struct dsi_data *dsi)
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r;
}
omapdss_device_register(out);
return 0;
......
......@@ -437,24 +437,13 @@ static int hdmi_connect(struct omap_dss_device *src,
if (r)
return r;
r = omapdss_output_set_device(dst, dst->next);
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
goto err_mgr_disconnect;
dss_mgr_disconnect(dst);
return r;
}
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r)
goto err_output_unset;
return 0;
err_output_unset:
omapdss_output_unset_device(dst);
err_mgr_disconnect:
dss_mgr_disconnect(dst);
return r;
}
static void hdmi_disconnect(struct omap_dss_device *src,
......@@ -717,6 +706,7 @@ static const struct component_ops hdmi4_component_ops = {
static int hdmi4_init_output(struct omap_hdmi *hdmi)
{
struct omap_dss_device *out = &hdmi->output;
int r;
out->dev = &hdmi->pdev->dev;
out->id = OMAP_DSS_OUTPUT_HDMI;
......@@ -734,6 +724,13 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r;
}
omapdss_device_register(out);
return 0;
......
......@@ -442,24 +442,13 @@ static int hdmi_connect(struct omap_dss_device *src,
if (r)
return r;
r = omapdss_output_set_device(dst, dst->next);
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
goto err_mgr_disconnect;
dss_mgr_disconnect(dst);
return r;
}
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r)
goto err_output_unset;
return 0;
err_output_unset:
omapdss_output_unset_device(dst);
err_mgr_disconnect:
dss_mgr_disconnect(dst);
return r;
}
static void hdmi_disconnect(struct omap_dss_device *src,
......@@ -709,6 +698,7 @@ static const struct component_ops hdmi5_component_ops = {
static int hdmi5_init_output(struct omap_hdmi *hdmi)
{
struct omap_dss_device *out = &hdmi->output;
int r;
out->dev = &hdmi->pdev->dev;
out->id = OMAP_DSS_OUTPUT_HDMI;
......@@ -726,6 +716,13 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r;
}
omapdss_device_register(out);
return 0;
......
......@@ -521,8 +521,7 @@ int omap_dss_get_num_overlays(void);
#define for_each_dss_output(d) \
while ((d = omapdss_device_get_next(d, OMAP_DSS_DEVICE_TYPE_OUTPUT)) != NULL)
int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev);
int omapdss_output_validate(struct omap_dss_device *out);
int omapdss_output_unset_device(struct omap_dss_device *out);
typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
......
......@@ -26,23 +26,16 @@
static DEFINE_MUTEX(output_lock);
int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev)
int omapdss_output_validate(struct omap_dss_device *out)
{
int r = 0;
mutex_lock(&output_lock);
if (out->output_type != dssdev->type) {
if (out->next && out->output_type != out->next->type) {
dev_err(out->dev, "output type and display type don't match\n");
r = -EINVAL;
return -EINVAL;
}
mutex_unlock(&output_lock);
return r;
return 0;
}
EXPORT_SYMBOL(omapdss_output_set_device);
EXPORT_SYMBOL(omapdss_output_validate);
int omapdss_output_unset_device(struct omap_dss_device *out)
{
......
......@@ -261,24 +261,13 @@ static int sdi_connect(struct omap_dss_device *src,
if (r)
return r;
r = omapdss_output_set_device(dst, dst);
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
goto err_mgr_disconnect;
dss_mgr_disconnect(dst);
return r;
}
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r)
goto err_output_unset;
return 0;
err_output_unset:
omapdss_output_unset_device(dst);
err_mgr_disconnect:
dss_mgr_disconnect(dst);
return r;
}
static void sdi_disconnect(struct omap_dss_device *src,
......@@ -304,6 +293,7 @@ static const struct omap_dss_device_ops sdi_ops = {
static int sdi_init_output(struct sdi_device *sdi)
{
struct omap_dss_device *out = &sdi->output;
int r;
out->dev = &sdi->pdev->dev;
out->id = OMAP_DSS_OUTPUT_SDI;
......@@ -322,6 +312,13 @@ static int sdi_init_output(struct sdi_device *sdi)
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r;
}
omapdss_device_register(out);
return 0;
......
......@@ -700,24 +700,13 @@ static int venc_connect(struct omap_dss_device *src,
if (r)
return r;
r = omapdss_output_set_device(dst, dst->next);
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
goto err_mgr_disconnect;
dss_mgr_disconnect(dst);
return r;
}
r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r)
goto err_output_unset;
return 0;
err_output_unset:
omapdss_output_unset_device(dst);
err_mgr_disconnect:
dss_mgr_disconnect(dst);
return r;
}
static void venc_disconnect(struct omap_dss_device *src,
......@@ -787,6 +776,7 @@ static const struct component_ops venc_component_ops = {
static int venc_init_output(struct venc_device *venc)
{
struct omap_dss_device *out = &venc->output;
int r;
out->dev = &venc->pdev->dev;
out->id = OMAP_DSS_OUTPUT_VENC;
......@@ -804,6 +794,13 @@ static int venc_init_output(struct venc_device *venc)
return PTR_ERR(out->next);
}
r = omapdss_output_validate(out);
if (r) {
omapdss_device_put(out->next);
out->next = NULL;
return r;
}
omapdss_device_register(out);
return 0;
......
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