All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Boris Brezillon <bbrezillon@kernel.org>
Subject: [PATCH v6 29/51] drm/omap: hdmi5: Register a drm_bridge for EDID read
Date: Sun, 16 Feb 2020 23:02:46 +0200	[thread overview]
Message-ID: <20200216210308.17312-30-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20200216210308.17312-1-laurent.pinchart@ideasonboard.com>

In order to integrate with a chain of drm_bridge, the internal HDMI5
encoder has to expose the EDID read operation through the drm_bridge
API. Register a bridge at initialisation time to do so.

For the time being make the next bridge in the chain optional as the
HDMI output is still based on omap_dss_device. The create_connector
argument to the bridge attach function is also ignored for the same
reason. This will be changed later when removing the related
omapdrm-specific display drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
Changes since v2:

- Unregister bridge if output initialisation fails
---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 79 ++++++++++++++++++++++++++---
 1 file changed, 73 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 2b02b0a11696..e7fe2a24a3e1 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -388,8 +388,10 @@ static void hdmi_disconnect(struct omap_dss_device *src,
 
 #define MAX_EDID	512
 
-static struct edid *hdmi_read_edid_data(struct hdmi_core_data *core)
+static struct edid *hdmi_read_edid_data(struct omap_hdmi *hdmi,
+					struct drm_connector *connector)
 {
+	struct hdmi_core_data *core = &hdmi->core;
 	int max_ext_blocks = 3;
 	int r, n, i;
 	u8 *edid;
@@ -421,9 +423,12 @@ static struct edid *hdmi_read_edid_data(struct hdmi_core_data *core)
 	return NULL;
 }
 
-static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev)
+static struct edid *
+hdmi_do_read_edid(struct omap_hdmi *hdmi,
+		  struct edid *(*read)(struct omap_hdmi *hdmi,
+				       struct drm_connector *connector),
+		  struct drm_connector *connector)
 {
-	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	struct edid *edid;
 	bool need_enable;
 	int idlemode;
@@ -447,7 +452,7 @@ static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev)
 
 	hdmi5_core_ddc_init(&hdmi->core);
 
-	edid = hdmi_read_edid_data(&hdmi->core);
+	edid = read(hdmi, connector);
 
 	hdmi5_core_ddc_uninit(&hdmi->core);
 
@@ -462,6 +467,12 @@ static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev)
 	return (struct edid *)edid;
 }
 
+static struct edid *hdmi_read_edid(struct omap_dss_device *dssdev)
+{
+	return hdmi_do_read_edid(dssdev_to_hdmi(dssdev), hdmi_read_edid_data,
+				 NULL);
+}
+
 static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
 		const struct hdmi_avi_infoframe *avi)
 {
@@ -497,6 +508,56 @@ static const struct omap_dss_device_ops hdmi_ops = {
 	},
 };
 
+/* -----------------------------------------------------------------------------
+ * DRM Bridge Operations
+ */
+
+static int hdmi5_bridge_attach(struct drm_bridge *bridge,
+			       enum drm_bridge_attach_flags flags)
+{
+	struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
+
+	if (!hdmi->output.next_bridge)
+		return 0;
+
+	return drm_bridge_attach(bridge->encoder, hdmi->output.next_bridge,
+				 bridge, flags);
+}
+
+static struct edid *hdmi5_bridge_read_edid(struct omap_hdmi *hdmi,
+					   struct drm_connector *connector)
+{
+	return drm_do_get_edid(connector, hdmi5_core_ddc_read, &hdmi->core);
+}
+
+static struct edid *hdmi5_bridge_get_edid(struct drm_bridge *bridge,
+					  struct drm_connector *connector)
+{
+	struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
+
+	return hdmi_do_read_edid(hdmi, hdmi5_bridge_read_edid, connector);
+}
+
+static const struct drm_bridge_funcs hdmi5_bridge_funcs = {
+	.attach = hdmi5_bridge_attach,
+	.get_edid = hdmi5_bridge_get_edid,
+};
+
+static void hdmi5_bridge_init(struct omap_hdmi *hdmi)
+{
+	hdmi->bridge.funcs = &hdmi5_bridge_funcs;
+	hdmi->bridge.of_node = hdmi->pdev->dev.of_node;
+	hdmi->bridge.ops = DRM_BRIDGE_OP_EDID;
+	hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
+
+	drm_bridge_add(&hdmi->bridge);
+}
+
+static void hdmi5_bridge_cleanup(struct omap_hdmi *hdmi)
+{
+	drm_bridge_remove(&hdmi->bridge);
+}
+
 /* -----------------------------------------------------------------------------
  * Audio Callbacks
  */
@@ -679,6 +740,8 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
 	struct omap_dss_device *out = &hdmi->output;
 	int r;
 
+	hdmi5_bridge_init(hdmi);
+
 	out->dev = &hdmi->pdev->dev;
 	out->id = OMAP_DSS_OUTPUT_HDMI;
 	out->type = OMAP_DISPLAY_TYPE_HDMI;
@@ -689,9 +752,11 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
 	out->of_port = 0;
 	out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
 
-	r = omapdss_device_init_output(out, NULL);
-	if (r < 0)
+	r = omapdss_device_init_output(out, &hdmi->bridge);
+	if (r < 0) {
+		hdmi5_bridge_cleanup(hdmi);
 		return r;
+	}
 
 	omapdss_device_register(out);
 
@@ -704,6 +769,8 @@ static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
 
 	omapdss_device_unregister(out);
 	omapdss_device_cleanup_output(out);
+
+	hdmi5_bridge_cleanup(hdmi);
 }
 
 static int hdmi5_probe_of(struct omap_hdmi *hdmi)
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-02-16 21:04 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-16 21:02 [PATCH v6 00/51] drm/omap: Replace custom display drivers with drm_bridge and drm_panel Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 01/51] video: hdmi: Change return type of hdmi_avi_infoframe_init() to void Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 02/51] drm/connector: Add helper to get a connector type name Laurent Pinchart
2020-02-17  9:43   ` Daniel Vetter
2020-02-21 14:15     ` Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 03/51] drm/edid: Add flag to drm_display_info to identify HDMI sinks Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 04/51] drm/bridge: Add connector-related bridge operations and data Laurent Pinchart
2020-02-17  9:53   ` Daniel Vetter
2020-02-18  1:21     ` Laurent Pinchart
2020-02-18  6:44       ` Daniel Vetter
2020-02-21 14:23         ` Laurent Pinchart
2020-02-21 17:05           ` Daniel Vetter
2020-02-21 17:18           ` Sam Ravnborg
2020-02-22  9:02             ` Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 05/51] drm/bridge: Add interlace_allowed flag to drm_bridge Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 06/51] drm/bridge: Extend bridge API to disable connector creation Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 07/51] drm/bridge: dumb-vga-dac: Rename internal symbols to simple-bridge Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 08/51] drm/bridge: dumb-vga-dac: Rename driver " Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 09/51] drm/bridge: simple-bridge: Add support for non-VGA bridges Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 10/51] drm/bridge: simple-bridge: Add support for enable GPIO Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 11/51] drm/bridge: simple-bridge: Add support for the TI OPA362 Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 12/51] drm/bridge: Add bridge driver for display connectors Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 13/51] drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 14/51] drm/bridge: panel: Implement bridge connector operations Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 15/51] drm/bridge: tfp410: Replace manual connector handling with bridge Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 16/51] drm/bridge: tfp410: Allow operation without drm_connector Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 17/51] drm: Add helper to create a connector for a chain of bridges Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 18/51] drm/omap: dss: Cleanup DSS ports on initialisation failure Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 19/51] drm/omap: Simplify HDMI mode and infoframe configuration Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 20/51] drm/omap: Factor out display type to connector type conversion Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 21/51] drm/omap: Use the drm_panel_bridge API Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 22/51] drm/omap: dss: Fix output next device lookup in DT Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 23/51] drm/omap: Add infrastructure to support drm_bridge local to DSS outputs Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 24/51] drm/omap: dss: Make omap_dss_device_ops optional Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 25/51] drm/omap: hdmi: Allocate EDID in the .read_edid() operation Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 26/51] drm/omap: hdmi4: Rework EDID read to isolate data read Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 27/51] drm/omap: hdmi5: " Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 28/51] drm/omap: hdmi4: Register a drm_bridge for EDID read Laurent Pinchart
2020-02-16 21:02 ` Laurent Pinchart [this message]
2020-02-16 21:02 ` [PATCH v6 30/51] drm/omap: hdmi4: Move mode set, enable and disable operations to bridge Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 31/51] drm/omap: hdmi5: " Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 32/51] drm/omap: hdmi4: Implement drm_bridge .hpd_notify() operation Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 33/51] drm/omap: dss: Remove .set_hdmi_mode() and .set_infoframe() operations Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 34/51] drm/omap: venc: Register a drm_bridge Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 35/51] drm/omap: Create connector for bridges Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 36/51] drm/omap: Switch the HDMI and VENC outputs to drm_bridge Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 37/51] drm/omap: Remove HPD, detect and EDID omapdss operations Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 38/51] drm/omap: hdmi: Remove omap_dss_device operations Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 39/51] drm/omap: venc: " Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 40/51] drm/omap: hdmi4: Simplify EDID read Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 41/51] drm/omap: hdmi5: " Laurent Pinchart
2020-02-16 21:02 ` [PATCH v6 42/51] drm/omap: dpi: Sort includes alphabetically Laurent Pinchart
2020-02-16 21:03 ` [PATCH v6 43/51] drm/omap: dpi: Reorder functions in sections Laurent Pinchart
2020-02-16 21:03 ` [PATCH v6 44/51] drm/omap: dpi: Simplify clock setting API Laurent Pinchart
2020-02-16 21:03 ` [PATCH v6 45/51] drm/omap: dpi: Register a drm_bridge Laurent Pinchart
2020-02-21 12:25   ` Tomi Valkeinen
2020-02-16 21:03 ` [PATCH v6 46/51] drm/omap: sdi: Sort includes alphabetically Laurent Pinchart
2020-02-16 21:03 ` [PATCH v6 47/51] drm/omap: sdi: Register a drm_bridge Laurent Pinchart
2020-02-16 21:03 ` [PATCH v6 48/51] drm/omap: Hardcode omap_connector type to DSI Laurent Pinchart
2020-02-21 12:20   ` Tomi Valkeinen
2020-02-16 21:03 ` [PATCH v6 49/51] drm/omap: dss: Remove unused omap_dss_device operations Laurent Pinchart
2020-02-20 21:39   ` Sebastian Reichel
2020-02-20 21:45     ` Laurent Pinchart
2020-02-22  3:13       ` Sebastian Reichel
2020-02-16 21:03 ` [PATCH v6 50/51] drm/omap: dss: Inline the omapdss_display_get() function Laurent Pinchart
2020-02-16 21:03 ` [PATCH v6 51/51] drm/omap: dss: Remove unused omapdss_of_find_connected_device() function Laurent Pinchart
2020-02-17 23:00 ` [PATCH v6 00/51] drm/omap: Replace custom display drivers with drm_bridge and drm_panel Sebastian Reichel
2020-02-17 23:16   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200216210308.17312-30-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=bbrezillon@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sam@ravnborg.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.