Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79107f27 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Tomi Valkeinen
Browse files

drm/omap: Add support for drm_bridge



Hook up drm_bridge support in the omapdrm driver. Despite the recent
extensive preparation work, this is a rather intrusive change, as the
management of outputs needs to be adapted through the driver to handle
both omap_dss_device and drm_bridge.

Connector creation is skipped when using a drm_bridge, as the bridge
creates the connector internally. This creates issues with systems that
split connector operations (such as modes retrieval and hot-plug
detection) across different bridges. These systems can't be supported
using drm_bridge for now (their support through the omap_dss_device
infrastructure is not affected), this will be fixed in subsequent
changes.

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 163f7a35
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_graph.h>
#include <linux/platform_device.h>

#include "dss.h"
#include "omapdss.h"
@@ -156,7 +157,7 @@ struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from)
			goto done;
		}

		if (dssdev->id && dssdev->next)
		if (dssdev->id && (dssdev->next || dssdev->bridge))
			goto done;
	}

@@ -184,7 +185,18 @@ int omapdss_device_connect(struct dss_device *dss,
{
	int ret;

	dev_dbg(dst->dev, "connect\n");
	dev_dbg(&dss->pdev->dev, "connect(%s, %s)\n",
		src ? dev_name(src->dev) : "NULL",
		dst ? dev_name(dst->dev) : "NULL");

	if (!dst) {
		/*
		 * The destination is NULL when the source is connected to a
		 * bridge instead of a DSS device. Stop here, we will attach the
		 * bridge later when we will have a DRM encoder.
		 */
		return src && src->bridge ? 0 : -EINVAL;
	}

	if (omapdss_device_is_connected(dst))
		return -EBUSY;
@@ -204,7 +216,16 @@ EXPORT_SYMBOL_GPL(omapdss_device_connect);
void omapdss_device_disconnect(struct omap_dss_device *src,
			       struct omap_dss_device *dst)
{
	dev_dbg(dst->dev, "disconnect\n");
	struct dss_device *dss = src ? src->dss : dst->dss;

	dev_dbg(&dss->pdev->dev, "disconnect(%s, %s)\n",
		src ? dev_name(src->dev) : "NULL",
		dst ? dev_name(dst->dev) : "NULL");

	if (!dst) {
		WARN_ON(!src->bridge);
		return;
	}

	if (!dst->id && !omapdss_device_is_connected(dst)) {
		WARN_ON(!dst->display);
+1 −0
Original line number Diff line number Diff line
@@ -410,6 +410,7 @@ struct omap_dss_device {

	struct dss_device *dss;
	struct omap_dss_device *next;
	struct drm_bridge *bridge;

	struct list_head list;

+15 −6
Original line number Diff line number Diff line
@@ -20,25 +20,34 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_graph.h>

#include "dss.h"
#include "omapdss.h"

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);
	struct device_node *remote_node;

	remote_node = of_graph_get_remote_node(out->dev->of_node, 0, 0);
	if (!remote_node) {
		dev_dbg(out->dev, "failed to find video sink\n");
		return 0;
	}

	out->next = omapdss_find_device_by_node(remote_node);
	out->bridge = of_drm_find_bridge(remote_node);

	of_node_put(remote_node);

	if (out->next && out->type != out->next->type) {
		dev_err(out->dev, "output type and display type don't match\n");
		omapdss_device_put(out->next);
		out->next = NULL;
		return -EINVAL;
	}

	return 0;
	return out->next || out->bridge ? 0 : -EPROBE_DEFER;
}
EXPORT_SYMBOL(omapdss_device_init_output);

+11 −5
Original line number Diff line number Diff line
@@ -299,9 +299,16 @@ static const struct drm_connector_helper_funcs omap_connector_helper_funcs = {
	.mode_valid = omap_connector_mode_valid,
};

static int omap_connector_get_type(struct omap_dss_device *display)
static int omap_connector_get_type(struct omap_dss_device *output)
{
	switch (display->type) {
	struct omap_dss_device *display;
	enum omap_display_type type;

	display = omapdss_display_get(output);
	type = display->type;
	omapdss_device_put(display);

	switch (type) {
	case OMAP_DISPLAY_TYPE_HDMI:
		return DRM_MODE_CONNECTOR_HDMIA;
	case OMAP_DISPLAY_TYPE_DVI:
@@ -324,14 +331,13 @@ static int omap_connector_get_type(struct omap_dss_device *display)
/* initialize connector */
struct drm_connector *omap_connector_init(struct drm_device *dev,
					  struct omap_dss_device *output,
					  struct omap_dss_device *display,
					  struct drm_encoder *encoder)
{
	struct drm_connector *connector = NULL;
	struct omap_connector *omap_connector;
	struct omap_dss_device *dssdev;

	DBG("%s", display->name);
	DBG("%s", output->name);

	omap_connector = kzalloc(sizeof(*omap_connector), GFP_KERNEL);
	if (!omap_connector)
@@ -344,7 +350,7 @@ struct drm_connector *omap_connector_init(struct drm_device *dev,
	connector->doublescan_allowed = 0;

	drm_connector_init(dev, connector, &omap_connector_funcs,
			   omap_connector_get_type(display));
			   omap_connector_get_type(output));
	drm_connector_helper_add(connector, &omap_connector_helper_funcs);

	/*
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ struct omap_dss_device;

struct drm_connector *omap_connector_init(struct drm_device *dev,
					  struct omap_dss_device *output,
					  struct omap_dss_device *display,
					  struct drm_encoder *encoder);
bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
void omap_connector_enable_hpd(struct drm_connector *connector);
Loading