All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 3/3] drm/i915: Send hotplug event if edid had changed.
       [not found] <20190627065945.6996-1-stanislav.lisovskiy@intel.com>
@ 2019-06-27  7:02 ` Stanislav Lisovskiy
  2019-06-27  8:48 ` Stanislav Lisovskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Lisovskiy @ 2019-06-27  7:02 UTC (permalink / raw)
  To: intel-gfx; +Cc: daniel.vetter, martin.peres, dri-devel

Added edid checking to dp and hdmi edid setting functions, which
are called from detect hooks. The result currently is propagated
to calling layer using drm_connector->change_counter(proposed by Daniel Vetter).
drm_helper_hpd_irq_event and intel_encoder_hotplug are currently both
responsible for checking if this counter or connection status is changed.

There are conflicting parts in drm and i915 which attempt
to do the same job - drm_helper_hpd_irq_event attempts to
check connector status changes and then call hotplug,
just as i915_hotplug_work_func, which calls encoder->hotplug
hook which in turn calls generic intel_encoder_hotplug function
which attempts to probe if output has changed.
Looks like both needs to be changed, so added edid checking
also to intel_encoder_hotplug function which is called both
for hdmi and dp.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105540
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c      | 16 +++++++++++++++-
 drivers/gpu/drm/i915/display/intel_hdmi.c    | 16 +++++++++++++---
 drivers/gpu/drm/i915/display/intel_hotplug.c | 20 +++++++++++++++-----
 3 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 4336df46fe78..d259dd9ee7be 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5510,10 +5510,24 @@ static void
 intel_dp_set_edid(struct intel_dp *intel_dp)
 {
 	struct intel_connector *intel_connector = intel_dp->attached_connector;
+	struct drm_connector *connector = &intel_connector->base;
 	struct edid *edid;
+	struct edid *old_edid;
 
-	intel_dp_unset_edid(intel_dp);
 	edid = intel_dp_get_edid(intel_dp);
+	old_edid = intel_connector->detect_edid;
+
+	if (!drm_edid_are_equal(edid, old_edid)) {
+		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Edid was changed! Updating blob property.\n",
+		    connector->base.id, connector->name);
+
+		connector->change_counter += 1;
+		DRM_DEBUG_KMS("Updating change counter to %llu\n", connector->change_counter);
+
+		intel_connector_update_modes(&intel_connector->base, edid);
+	}
+
+	intel_dp_unset_edid(intel_dp);
 	intel_connector->detect_edid = edid;
 
 	intel_dp->has_audio = drm_detect_monitor_audio(edid);
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 0ebec69bbbfc..6c851c360b35 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -2503,7 +2503,7 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
 	intel_wakeref_t wakeref;
-	struct edid *edid;
+	struct edid *edid, *old_edid;
 	bool connected = false;
 	struct i2c_adapter *i2c;
 
@@ -2524,11 +2524,22 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 
 	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS, wakeref);
 
+	old_edid = to_intel_connector(connector)->detect_edid;
+
+	if (!drm_edid_are_equal(edid, old_edid)) {
+		intel_connector_update_modes(connector, edid);
+		DRM_DEBUG_KMS("Updating change counter to %llu\n", connector->change_counter);
+		connector->change_counter += 1;
+
+		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Edid was changed! Updating blob property.\n",
+		    connector->base.id, connector->name);
+	}
+	intel_hdmi_unset_edid(connector);
 	to_intel_connector(connector)->detect_edid = edid;
+
 	if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) {
 		intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
 		intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
-
 		connected = true;
 	}
 
@@ -2555,7 +2566,6 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
 	    !intel_digital_port_connected(encoder))
 		goto out;
 
-	intel_hdmi_unset_edid(connector);
 
 	if (intel_hdmi_set_edid(connector))
 		status = connector_status_connected;
diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
index ea3de4acc850..b976431f1ce5 100644
--- a/drivers/gpu/drm/i915/display/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
@@ -271,23 +271,33 @@ bool intel_encoder_hotplug(struct intel_encoder *encoder,
 {
 	struct drm_device *dev = connector->base.dev;
 	enum drm_connector_status old_status;
+	uint64_t old_change_counter;
+	bool ret = false;
 
 	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
 	old_status = connector->base.status;
 
+	old_change_counter = connector->base.change_counter;
+
 	connector->base.status =
 		drm_helper_probe_detect(&connector->base, NULL, false);
 
-	if (old_status == connector->base.status)
-		return false;
+	if (old_change_counter != connector->base.change_counter)
+		ret = true;
 
-	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
+	if (old_status != connector->base.status)
+		ret = true;
+
+	if (ret) {
+		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s(change counter %llu)\n",
 		      connector->base.base.id,
 		      connector->base.name,
 		      drm_get_connector_status_name(old_status),
-		      drm_get_connector_status_name(connector->base.status));
+		      drm_get_connector_status_name(connector->base.status),
+		      connector->base.change_counter);
+	}
 
-	return true;
+	return ret;
 }
 
 static bool intel_encoder_has_hpd_pulse(struct intel_encoder *encoder)
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v1 3/3] drm/i915: Send hotplug event if edid had changed.
       [not found] <20190627065945.6996-1-stanislav.lisovskiy@intel.com>
  2019-06-27  7:02 ` [PATCH v1 3/3] drm/i915: Send hotplug event if edid had changed Stanislav Lisovskiy
@ 2019-06-27  8:48 ` Stanislav Lisovskiy
  2019-06-27 14:01   ` Jani Nikula
  1 sibling, 1 reply; 3+ messages in thread
From: Stanislav Lisovskiy @ 2019-06-27  8:48 UTC (permalink / raw)
  To: dri-devel; +Cc: daniel.vetter, martin.peres, Stanislav.Lisovskiy, jani.saarinen

Added edid checking to dp and hdmi edid setting functions, which
are called from detect hooks. The result currently is propagated
to calling layer using drm_connector->change_counter(proposed by Daniel Vetter).
drm_helper_hpd_irq_event and intel_encoder_hotplug are currently both
responsible for checking if this counter or connection status is changed.

There are conflicting parts in drm and i915 which attempt
to do the same job - drm_helper_hpd_irq_event attempts to
check connector status changes and then call hotplug,
just as i915_hotplug_work_func, which calls encoder->hotplug
hook which in turn calls generic intel_encoder_hotplug function
which attempts to probe if output has changed.
Looks like both needs to be changed, so added edid checking
also to intel_encoder_hotplug function which is called both
for hdmi and dp.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105540
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c      | 16 +++++++++++++++-
 drivers/gpu/drm/i915/display/intel_hdmi.c    | 16 +++++++++++++---
 drivers/gpu/drm/i915/display/intel_hotplug.c | 20 +++++++++++++++-----
 3 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 4336df46fe78..d259dd9ee7be 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5510,10 +5510,24 @@ static void
 intel_dp_set_edid(struct intel_dp *intel_dp)
 {
 	struct intel_connector *intel_connector = intel_dp->attached_connector;
+	struct drm_connector *connector = &intel_connector->base;
 	struct edid *edid;
+	struct edid *old_edid;
 
-	intel_dp_unset_edid(intel_dp);
 	edid = intel_dp_get_edid(intel_dp);
+	old_edid = intel_connector->detect_edid;
+
+	if (!drm_edid_are_equal(edid, old_edid)) {
+		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Edid was changed! Updating blob property.\n",
+		    connector->base.id, connector->name);
+
+		connector->change_counter += 1;
+		DRM_DEBUG_KMS("Updating change counter to %llu\n", connector->change_counter);
+
+		intel_connector_update_modes(&intel_connector->base, edid);
+	}
+
+	intel_dp_unset_edid(intel_dp);
 	intel_connector->detect_edid = edid;
 
 	intel_dp->has_audio = drm_detect_monitor_audio(edid);
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 0ebec69bbbfc..6c851c360b35 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -2503,7 +2503,7 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
 	intel_wakeref_t wakeref;
-	struct edid *edid;
+	struct edid *edid, *old_edid;
 	bool connected = false;
 	struct i2c_adapter *i2c;
 
@@ -2524,11 +2524,22 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 
 	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS, wakeref);
 
+	old_edid = to_intel_connector(connector)->detect_edid;
+
+	if (!drm_edid_are_equal(edid, old_edid)) {
+		intel_connector_update_modes(connector, edid);
+		DRM_DEBUG_KMS("Updating change counter to %llu\n", connector->change_counter);
+		connector->change_counter += 1;
+
+		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Edid was changed! Updating blob property.\n",
+		    connector->base.id, connector->name);
+	}
+	intel_hdmi_unset_edid(connector);
 	to_intel_connector(connector)->detect_edid = edid;
+
 	if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) {
 		intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
 		intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
-
 		connected = true;
 	}
 
@@ -2555,7 +2566,6 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
 	    !intel_digital_port_connected(encoder))
 		goto out;
 
-	intel_hdmi_unset_edid(connector);
 
 	if (intel_hdmi_set_edid(connector))
 		status = connector_status_connected;
diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
index ea3de4acc850..b976431f1ce5 100644
--- a/drivers/gpu/drm/i915/display/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
@@ -271,23 +271,33 @@ bool intel_encoder_hotplug(struct intel_encoder *encoder,
 {
 	struct drm_device *dev = connector->base.dev;
 	enum drm_connector_status old_status;
+	uint64_t old_change_counter;
+	bool ret = false;
 
 	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
 	old_status = connector->base.status;
 
+	old_change_counter = connector->base.change_counter;
+
 	connector->base.status =
 		drm_helper_probe_detect(&connector->base, NULL, false);
 
-	if (old_status == connector->base.status)
-		return false;
+	if (old_change_counter != connector->base.change_counter)
+		ret = true;
 
-	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
+	if (old_status != connector->base.status)
+		ret = true;
+
+	if (ret) {
+		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s(change counter %llu)\n",
 		      connector->base.base.id,
 		      connector->base.name,
 		      drm_get_connector_status_name(old_status),
-		      drm_get_connector_status_name(connector->base.status));
+		      drm_get_connector_status_name(connector->base.status),
+		      connector->base.change_counter);
+	}
 
-	return true;
+	return ret;
 }
 
 static bool intel_encoder_has_hpd_pulse(struct intel_encoder *encoder)
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 3/3] drm/i915: Send hotplug event if edid had changed.
  2019-06-27  8:48 ` Stanislav Lisovskiy
@ 2019-06-27 14:01   ` Jani Nikula
  0 siblings, 0 replies; 3+ messages in thread
From: Jani Nikula @ 2019-06-27 14:01 UTC (permalink / raw)
  To: Stanislav Lisovskiy, dri-devel
  Cc: Stanislav.Lisovskiy, daniel.vetter, martin.peres, jani.saarinen

On Thu, 27 Jun 2019, Stanislav Lisovskiy <stanislav.lisovskiy@intel.com> wrote:
> Added edid checking to dp and hdmi edid setting functions, which
> are called from detect hooks. The result currently is propagated
> to calling layer using drm_connector->change_counter(proposed by Daniel Vetter).
> drm_helper_hpd_irq_event and intel_encoder_hotplug are currently both
> responsible for checking if this counter or connection status is changed.
>
> There are conflicting parts in drm and i915 which attempt
> to do the same job - drm_helper_hpd_irq_event attempts to
> check connector status changes and then call hotplug,
> just as i915_hotplug_work_func, which calls encoder->hotplug
> hook which in turn calls generic intel_encoder_hotplug function
> which attempts to probe if output has changed.
> Looks like both needs to be changed, so added edid checking
> also to intel_encoder_hotplug function which is called both
> for hdmi and dp.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105540
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c      | 16 +++++++++++++++-
>  drivers/gpu/drm/i915/display/intel_hdmi.c    | 16 +++++++++++++---
>  drivers/gpu/drm/i915/display/intel_hotplug.c | 20 +++++++++++++++-----
>  3 files changed, 43 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 4336df46fe78..d259dd9ee7be 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -5510,10 +5510,24 @@ static void
>  intel_dp_set_edid(struct intel_dp *intel_dp)
>  {
>  	struct intel_connector *intel_connector = intel_dp->attached_connector;
> +	struct drm_connector *connector = &intel_connector->base;
>  	struct edid *edid;
> +	struct edid *old_edid;
>  
> -	intel_dp_unset_edid(intel_dp);
>  	edid = intel_dp_get_edid(intel_dp);
> +	old_edid = intel_connector->detect_edid;
> +
> +	if (!drm_edid_are_equal(edid, old_edid)) {
> +		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Edid was changed! Updating blob property.\n",
> +		    connector->base.id, connector->name);
> +
> +		connector->change_counter += 1;
> +		DRM_DEBUG_KMS("Updating change counter to %llu\n", connector->change_counter);
> +
> +		intel_connector_update_modes(&intel_connector->base, edid);
> +	}
> +
> +	intel_dp_unset_edid(intel_dp);
>  	intel_connector->detect_edid = edid;
>  
>  	intel_dp->has_audio = drm_detect_monitor_audio(edid);
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index 0ebec69bbbfc..6c851c360b35 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -2503,7 +2503,7 @@ intel_hdmi_set_edid(struct drm_connector *connector)
>  	struct drm_i915_private *dev_priv = to_i915(connector->dev);
>  	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
>  	intel_wakeref_t wakeref;
> -	struct edid *edid;
> +	struct edid *edid, *old_edid;
>  	bool connected = false;
>  	struct i2c_adapter *i2c;
>  
> @@ -2524,11 +2524,22 @@ intel_hdmi_set_edid(struct drm_connector *connector)
>  
>  	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS, wakeref);
>  
> +	old_edid = to_intel_connector(connector)->detect_edid;
> +
> +	if (!drm_edid_are_equal(edid, old_edid)) {
> +		intel_connector_update_modes(connector, edid);
> +		DRM_DEBUG_KMS("Updating change counter to %llu\n", connector->change_counter);
> +		connector->change_counter += 1;
> +
> +		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Edid was changed! Updating blob property.\n",
> +		    connector->base.id, connector->name);
> +	}
> +	intel_hdmi_unset_edid(connector);
>  	to_intel_connector(connector)->detect_edid = edid;
> +
>  	if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) {
>  		intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
>  		intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
> -
>  		connected = true;
>  	}
>  
> @@ -2555,7 +2566,6 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
>  	    !intel_digital_port_connected(encoder))
>  		goto out;
>  
> -	intel_hdmi_unset_edid(connector);
>  
>  	if (intel_hdmi_set_edid(connector))
>  		status = connector_status_connected;
> diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
> index ea3de4acc850..b976431f1ce5 100644
> --- a/drivers/gpu/drm/i915/display/intel_hotplug.c
> +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
> @@ -271,23 +271,33 @@ bool intel_encoder_hotplug(struct intel_encoder *encoder,
>  {
>  	struct drm_device *dev = connector->base.dev;
>  	enum drm_connector_status old_status;
> +	uint64_t old_change_counter;

Please use u64.

BR,
Jani.

> +	bool ret = false;
>  
>  	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
>  	old_status = connector->base.status;
>  
> +	old_change_counter = connector->base.change_counter;
> +
>  	connector->base.status =
>  		drm_helper_probe_detect(&connector->base, NULL, false);
>  
> -	if (old_status == connector->base.status)
> -		return false;
> +	if (old_change_counter != connector->base.change_counter)
> +		ret = true;
>  
> -	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
> +	if (old_status != connector->base.status)
> +		ret = true;
> +
> +	if (ret) {
> +		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s(change counter %llu)\n",
>  		      connector->base.base.id,
>  		      connector->base.name,
>  		      drm_get_connector_status_name(old_status),
> -		      drm_get_connector_status_name(connector->base.status));
> +		      drm_get_connector_status_name(connector->base.status),
> +		      connector->base.change_counter);
> +	}
>  
> -	return true;
> +	return ret;
>  }
>  
>  static bool intel_encoder_has_hpd_pulse(struct intel_encoder *encoder)

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-27 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20190627065945.6996-1-stanislav.lisovskiy@intel.com>
2019-06-27  7:02 ` [PATCH v1 3/3] drm/i915: Send hotplug event if edid had changed Stanislav Lisovskiy
2019-06-27  8:48 ` Stanislav Lisovskiy
2019-06-27 14:01   ` Jani Nikula

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.