Skip to contentSkip to conversation

drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI

PATCH In review Simon Farnsworth 2 participants 7 messages Sep 20, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI

I was seeing a nasty 5 frame glitch every 10 seconds, caused by the poll for connection on DVI attached by SDVO.

As my SDVO DVI supports hotplug detect interrupts, the fix is to enable them, and hook them in to the various bits of driver infrastructure so that they work reliably.

With lots of help from Adam Jackson <[email protected]> on IRC.

---
Changes from v3:

* As per Chris Wilson's comment, move the hotplug enable from intel_sdvo_init to intel_sdvo_dvi_init. Should correctly enable HPD if only one of a multifunction SDVO pair supports HPD.

Changes from v2:

* Stylistic cleanups requested by Chris Wilson in review:
* Make intel_sdvo_find_connector cleaner
* Rename intel_sdvo_set_hotplug to intel_sdvo_enable_hotplug (reflects functionality better)
* Remove intel_sdvo_do_hotplug

Changes from first version:

* Don't call intel_sdvo_supports_hotplug twice - pick up the setting in connector->polled instead (suggested by Keith Packard in review).

* Change subject prefix to drm/i915

 drivers/gpu/drm/i915/intel_drv.h  |    3 --
 drivers/gpu/drm/i915/intel_sdvo.c |   64 ++++++++-----------------------------
 2 files changed, 14 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +0 -3
index 375690b..a72d31d 100644
@@ -337,9 +337,6 @@ extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
 					   struct drm_connector *connector,
 					   struct intel_load_detect_pipe *old);
 
-extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);
-extern int intel_sdvo_supports_hotplug(struct drm_connector *connector);
-extern void intel_sdvo_set_hotplug(struct drm_connector *connector, int enable);
 extern void intelfb_restore(void);
 extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
 				    u16 blue, int regno);
drivers/gpu/drm/i915/intel_sdvo.c +14 -50

101 lines not on this page · raw message

Signature · 1 line
1.7.6
#1 lore raw
Quoted 9 lines · Simon Farnsworth

I was seeing a nasty 5 frame glitch every 10 seconds, caused by the poll for connection on DVI attached by SDVO.

As my SDVO DVI supports hotplug detect interrupts, the fix is to enable them, and hook them in to the various bits of driver infrastructure so that they work reliably.

With lots of help from Adam Jackson <[email protected]> on IRC.

Quoted 8 lines

---
Changes from v3:

* As per Chris Wilson's comment, move the hotplug enable from intel_sdvo_init to intel_sdvo_dvi_init. Should correctly enable HPD if only one of a multifunction SDVO pair supports HPD.

Note that I forgot to update the subject line - this is patch v4.

Signature · 4 lines
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
#2 lore raw
In reply to Simon Farnsworth
Quoted 5 lines · Simon Farnsworth
drivers/gpu/drm/i915/intel_sdvo.c +2 -3
-	if (on) {
-		intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0);
-		status = intel_sdvo_read_response(intel_sdvo, &response, 2);
+	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0);
+	status = intel_sdvo_read_response(intel_sdvo, &response, 2);

...

drivers/gpu/drm/i915/intel_sdvo.c static bool intel_sdvo_get_capabilities(struct intel_sdvo *intel_sdvo, struct in · line 1231

Quoted 1 line
drivers/gpu/drm/i915/intel_sdvo.c +1 -0
+	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);

You are unconditionally enabling hotplug on all devices, I think you want to take the desired device as an argument to this function and add it to the set of active hotplug devices instead. You've just gotten the active hotplug value above, so removing the call to GET_HOT_PLUG_SUPPORT and doing:

  	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
  	intel_sdvo_read_response(intel_sdvo, &response, 2);
        response[0] |= (1 << device);

	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);

should do what you want.

drivers/gpu/drm/i915/intel_sdvo.c intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) · line 2025

Quoted 8 lines
drivers/gpu/drm/i915/intel_sdvo.c +3 -1
@@ -2062,7 +2020,13 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
 
 	intel_connector = &intel_sdvo_connector->base;
 	connector = &intel_connector->base;
-	connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
+	if (intel_sdvo_supports_hotplug(intel_sdvo) & (1 << device)) {
+		connector->polled = DRM_CONNECTOR_POLL_HPD;
+		intel_encoder->hot_plug = intel_sdvo_enable_hotplug;

The encoder->hot_plug function is what is called when the hotplug interrupt is detected. The only current user is the DisplayPort driver which uses this to signal link retraining. You definitely don't want or need to call intel_sdvo_enable_hotplug at that point.

Signature · 1 line
[email protected]

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 1 line · Keith Packard

On Tue, 20 Sep 2011 15:17:38 +0100, Simon Farnsworth

Quoted 2 lines · <[email protected]> wrote:

Review

Quoted 2 lines
(quoted diff) +0 -2
-	if (on) {
-		intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, 

NULL,

Quoted 18 lines
Quoted 3 lines

0); - status = intel_sdvo_read_response(intel_sdvo, &response, 2);

(quoted diff) +1 -0
+	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL,

0); + status = intel_sdvo_read_response(intel_sdvo, &response, 2);

...

Quoted 2 lines
(quoted diff) +1 -0
+	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG,

&response, 2);

You are unconditionally enabling hotplug on all devices, I think you want to take the desired device as an argument to this function and add it to the set of active hotplug devices instead. You've just gotten the active hotplug value above, so removing the call to GET_HOT_PLUG_SUPPORT and doing:

  	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
  	intel_sdvo_read_response(intel_sdvo, &response, 2);
Quoted 6 lines

response[0] |= (1 << device);

intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response,
2);

should do what you want.

This interacts badly with the need I've found to call this function every time a hotplug interrupt comes through (explained below) - I'm not sure how to track back from the encoder (which gets the callback) to the SDVO device number.

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_sdvo.c +0 -0
@@ -2062,7 +2020,13 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo,
 int device)
 
 	intel_connector = &intel_sdvo_connector->base;
 	connector = &intel_connector->base;
 
Quoted 10 lines

drivers/gpu/drm/i915/intel_sdvo.c intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) · line 2025

Quoted 5 lines
(quoted diff) +0 -1
-	connector->polled = DRM_CONNECTOR_POLL_CONNECT |

DRM_CONNECTOR_POLL_DISCONNECT; + if
(intel_sdvo_supports_hotplug(intel_sdvo) & (1 << device)) {

drivers/gpu/drm/i915/intel_sdvo.c +2 -0
+		connector->polled = DRM_CONNECTOR_POLL_HPD;
+		intel_encoder->hot_plug = intel_sdvo_enable_hotplug;

The encoder->hot_plug function is what is called when the hotplug interrupt is detected. The only current user is the DisplayPort driver which uses this to signal link retraining. You definitely don't want or need to call intel_sdvo_enable_hotplug at that point.

If I don't call intel_sdvo_enable_hotplug at this point, I only get the one hotplug interrupt; it appears that the SDVO devices I have send their interrupt, then expect you to re-enable HPD interrupts before they will send another interrupt.

I'm not sure how best to handle this; my gut feeling is that there's no real harm enabling HPD interrupts on all ports that support it, even though I'm only processing HPD interrupts from DVI and HDMI ports. If you have better ideas, I'm happy to try them.

Signature · 4 lines
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
#4 lore raw
Quoted 4 lines · Simon Farnsworth

This interacts badly with the need I've found to call this function every time a hotplug interrupt comes through (explained below) - I'm not sure how to track back from the encoder (which gets the callback) to the SDVO device number.

You might store the desired hotplug bits in the intel_sdvo structure, and then use that in the enable function. The enable function should be able to just call SET_ACTIVE_HOT_PLUG with the desired value instead of making the four calls that it does now, right?

Quoted 4 lines

If I don't call intel_sdvo_enable_hotplug at this point, I only get the one hotplug interrupt; it appears that the SDVO devices I have send their interrupt, then expect you to re-enable HPD interrupts before they will send another interrupt.

ok, sounds good.

Quoted 4 lines

I'm not sure how best to handle this; my gut feeling is that there's no real harm enabling HPD interrupts on all ports that support it, even though I'm only processing HPD interrupts from DVI and HDMI ports. If you have better ideas, I'm happy to try them.

It probably is harmless, just seems a bit messy.

Signature · 1 line
[email protected]

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 1 line · Keith Packard

On Tue, 20 Sep 2011 17:38:37 +0100, Simon Farnsworth

Quoted 10 lines · <[email protected]> wrote:
Quoted 4 lines

This interacts badly with the need I've found to call this function every time a hotplug interrupt comes through (explained below) - I'm not sure how to track back from the encoder (which gets the callback) to the SDVO device number.

You might store the desired hotplug bits in the intel_sdvo structure, and then use that in the enable function. The enable function should be able to just call SET_ACTIVE_HOT_PLUG with the desired value instead of making the four calls that it does now, right?

Sounds perfectly reasonable to me. I'll whip up patch v5 before I head home tonight.

Quoted 7 lines
Quoted 4 lines

If I don't call intel_sdvo_enable_hotplug at this point, I only get the one hotplug interrupt; it appears that the SDVO devices I have send their interrupt, then expect you to re-enable HPD interrupts before they will send another interrupt.

ok, sounds good.

I'll add a comment to the code so that future reviewers understand why I'm doing it.

Signature · 4 lines
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
#6 lore raw
Quoted 2 lines · Simon Farnsworth

Sounds perfectly reasonable to me. I'll whip up patch v5 before I head home tonight.

Thanks much, I hate to bikeshed this far, but I doubt anyone else will ever go back and rework this code later on.

Quoted 2 lines

I'll add a comment to the code so that future reviewers understand why I'm doing it.

That's a great idea. Keep me from wondering next week what it's doing there.

Signature · 1 line
[email protected]

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx