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 v7 33/54] drm/omap: hdmi4: Move mode set, enable and disable operations to bridge
Date: Sat, 22 Feb 2020 17:00:45 +0200	[thread overview]
Message-ID: <20200222150106.22919-34-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20200222150106.22919-1-laurent.pinchart@ideasonboard.com>

Move the omap_dss_device .set_timings(), .enable() and .disable()
operations to the drm_bridge functions. As the drm_bridge for the HDMI
encoder is unconditionally registered and attached, those operations
will be called at the appropriate time.

The omapdss device .set_infoframe() and .set_hdmi_mode() operations have
no equivalent in drm_bridge. Thir content is thus moved to the bridge
.enable() operation as the data they store is not needed before the HDMI
encoder gets enabled.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
Changes since v5:

- Rebased on top of drm_bridge_state

Changes since v2:

- Detail .set_infoframe() and .set_hdmi_mode() handling in the commit
  message
---
 drivers/gpu/drm/omapdrm/dss/hdmi4.c | 206 +++++++++++++++-------------
 1 file changed, 111 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 67994287447b..a8d13a081a9a 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -28,6 +28,9 @@
 #include <sound/omap-hdmi-audio.h>
 #include <media/cec.h>
 
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_state_helper.h>
+
 #include "omapdss.h"
 #include "hdmi4_core.h"
 #include "hdmi4_cec.h"
@@ -237,20 +240,6 @@ static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 	hdmi_power_off_core(hdmi);
 }
 
-static void hdmi_display_set_timings(struct omap_dss_device *dssdev,
-				     const struct drm_display_mode *mode)
-{
-	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-
-	mutex_lock(&hdmi->lock);
-
-	drm_display_mode_to_videomode(mode, &hdmi->cfg.vm);
-
-	dispc_set_tv_pclk(hdmi->dss->dispc, mode->clock * 1000);
-
-	mutex_unlock(&hdmi->lock);
-}
-
 static int hdmi_dump_regs(struct seq_file *s, void *p)
 {
 	struct omap_hdmi *hdmi = s->private;
@@ -284,62 +273,6 @@ static void hdmi_stop_audio_stream(struct omap_hdmi *hd)
 	hdmi_wp_audio_enable(&hd->wp, false);
 }
 
-static void hdmi_display_enable(struct omap_dss_device *dssdev)
-{
-	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-	unsigned long flags;
-	int r;
-
-	DSSDBG("ENTER hdmi_display_enable\n");
-
-	mutex_lock(&hdmi->lock);
-
-	r = hdmi_power_on_full(hdmi);
-	if (r) {
-		DSSERR("failed to power on device\n");
-		goto done;
-	}
-
-	if (hdmi->audio_configured) {
-		r = hdmi4_audio_config(&hdmi->core, &hdmi->wp,
-				       &hdmi->audio_config,
-				       hdmi->cfg.vm.pixelclock);
-		if (r) {
-			DSSERR("Error restoring audio configuration: %d", r);
-			hdmi->audio_abort_cb(&hdmi->pdev->dev);
-			hdmi->audio_configured = false;
-		}
-	}
-
-	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
-	if (hdmi->audio_configured && hdmi->audio_playing)
-		hdmi_start_audio_stream(hdmi);
-	hdmi->display_enabled = true;
-	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
-
-done:
-	mutex_unlock(&hdmi->lock);
-}
-
-static void hdmi_display_disable(struct omap_dss_device *dssdev)
-{
-	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-	unsigned long flags;
-
-	DSSDBG("Enter hdmi_display_disable\n");
-
-	mutex_lock(&hdmi->lock);
-
-	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
-	hdmi_stop_audio_stream(hdmi);
-	hdmi->display_enabled = false;
-	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
-
-	hdmi_power_off_full(hdmi);
-
-	mutex_unlock(&hdmi->lock);
-}
-
 int hdmi4_core_enable(struct hdmi_core_data *core)
 {
 	struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
@@ -491,39 +424,14 @@ static void hdmi_lost_hotplug(struct omap_dss_device *dssdev)
 	hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
 }
 
-static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
-		const struct hdmi_avi_infoframe *avi)
-{
-	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-
-	hdmi->cfg.infoframe = *avi;
-	return 0;
-}
-
-static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
-		bool hdmi_mode)
-{
-	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-
-	hdmi->cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
-	return 0;
-}
-
 static const struct omap_dss_device_ops hdmi_ops = {
 	.connect		= hdmi_connect,
 	.disconnect		= hdmi_disconnect,
 
-	.enable			= hdmi_display_enable,
-	.disable		= hdmi_display_disable,
-
-	.set_timings		= hdmi_display_set_timings,
-
 	.read_edid		= hdmi_read_edid,
 
 	.hdmi = {
 		.lost_hotplug		= hdmi_lost_hotplug,
-		.set_infoframe		= hdmi_set_infoframe,
-		.set_hdmi_mode		= hdmi_set_hdmi_mode,
 	},
 };
 
@@ -543,6 +451,108 @@ static int hdmi4_bridge_attach(struct drm_bridge *bridge,
 				 bridge, flags);
 }
 
+static void hdmi4_bridge_mode_set(struct drm_bridge *bridge,
+				  const struct drm_display_mode *mode,
+				  const struct drm_display_mode *adjusted_mode)
+{
+	struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
+
+	mutex_lock(&hdmi->lock);
+
+	drm_display_mode_to_videomode(adjusted_mode, &hdmi->cfg.vm);
+
+	dispc_set_tv_pclk(hdmi->dss->dispc, adjusted_mode->clock * 1000);
+
+	mutex_unlock(&hdmi->lock);
+}
+
+static void hdmi4_bridge_enable(struct drm_bridge *bridge,
+				struct drm_bridge_state *bridge_state)
+{
+	struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
+	struct drm_atomic_state *state = bridge_state->base.state;
+	struct drm_connector_state *conn_state;
+	struct drm_connector *connector;
+	struct drm_crtc_state *crtc_state;
+	unsigned long flags;
+	int ret;
+
+	/*
+	 * None of these should fail, as the bridge can't be enabled without a
+	 * valid CRTC to connector path with fully populated new states.
+	 */
+	connector = drm_atomic_get_new_connector_for_encoder(state,
+							     bridge->encoder);
+	if (WARN_ON(!connector))
+		return;
+	conn_state = drm_atomic_get_new_connector_state(state, connector);
+	if (WARN_ON(!conn_state))
+		return;
+	crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
+	if (WARN_ON(!crtc_state))
+		return;
+
+	hdmi->cfg.hdmi_dvi_mode = connector->display_info.is_hdmi
+				? HDMI_HDMI : HDMI_DVI;
+
+	if (connector->display_info.is_hdmi) {
+		const struct drm_display_mode *mode;
+		struct hdmi_avi_infoframe avi;
+
+		mode = &crtc_state->adjusted_mode;
+		ret = drm_hdmi_avi_infoframe_from_display_mode(&avi, connector,
+							       mode);
+		if (ret == 0)
+			hdmi->cfg.infoframe = avi;
+	}
+
+	mutex_lock(&hdmi->lock);
+
+	ret = hdmi_power_on_full(hdmi);
+	if (ret) {
+		DSSERR("failed to power on device\n");
+		goto done;
+	}
+
+	if (hdmi->audio_configured) {
+		ret = hdmi4_audio_config(&hdmi->core, &hdmi->wp,
+					 &hdmi->audio_config,
+					 hdmi->cfg.vm.pixelclock);
+		if (ret) {
+			DSSERR("Error restoring audio configuration: %d", ret);
+			hdmi->audio_abort_cb(&hdmi->pdev->dev);
+			hdmi->audio_configured = false;
+		}
+	}
+
+	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
+	if (hdmi->audio_configured && hdmi->audio_playing)
+		hdmi_start_audio_stream(hdmi);
+	hdmi->display_enabled = true;
+	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
+
+done:
+	mutex_unlock(&hdmi->lock);
+}
+
+static void hdmi4_bridge_disable(struct drm_bridge *bridge,
+				 struct drm_bridge_state *bridge_state)
+{
+	struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
+	unsigned long flags;
+
+	mutex_lock(&hdmi->lock);
+
+	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
+	hdmi_stop_audio_stream(hdmi);
+	hdmi->display_enabled = false;
+	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
+
+	hdmi_power_off_full(hdmi);
+
+	mutex_unlock(&hdmi->lock);
+}
+
 static struct edid *hdmi4_bridge_read_edid(struct omap_hdmi *hdmi,
 					   struct drm_connector *connector)
 {
@@ -559,6 +569,12 @@ static struct edid *hdmi4_bridge_get_edid(struct drm_bridge *bridge,
 
 static const struct drm_bridge_funcs hdmi4_bridge_funcs = {
 	.attach = hdmi4_bridge_attach,
+	.mode_set = hdmi4_bridge_mode_set,
+	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+	.atomic_reset = drm_atomic_helper_bridge_reset,
+	.atomic_enable = hdmi4_bridge_enable,
+	.atomic_disable = hdmi4_bridge_disable,
 	.get_edid = hdmi4_bridge_get_edid,
 };
 
-- 
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-22 15:02 UTC|newest]

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