* [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
@ 2011-09-20 14:17 Simon Farnsworth
2011-09-20 14:18 ` Simon Farnsworth
2011-09-20 16:27 ` Keith Packard
0 siblings, 2 replies; 7+ messages in thread
From: Simon Farnsworth @ 2011-09-20 14:17 UTC (permalink / raw)
To: Keith Packard; +Cc: intel-gfx
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 <ajax@redhat.com> on IRC.
Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
---
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(-)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 375690b..a72d31d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -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);
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index aa94110..27a1ead 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1208,74 +1208,31 @@ static bool intel_sdvo_get_capabilities(struct intel_sdvo *intel_sdvo, struct in
return true;
}
-/* No use! */
-#if 0
-struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB)
-{
- struct drm_connector *connector = NULL;
- struct intel_sdvo *iout = NULL;
- struct intel_sdvo *sdvo;
-
- /* find the sdvo connector */
- list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
- iout = to_intel_sdvo(connector);
-
- if (iout->type != INTEL_OUTPUT_SDVO)
- continue;
-
- sdvo = iout->dev_priv;
-
- if (sdvo->sdvo_reg == SDVOB && sdvoB)
- return connector;
-
- if (sdvo->sdvo_reg == SDVOC && !sdvoB)
- return connector;
-
- }
-
- return NULL;
-}
-
-int intel_sdvo_supports_hotplug(struct drm_connector *connector)
+static int intel_sdvo_supports_hotplug(struct intel_sdvo *intel_sdvo)
{
u8 response[2];
- u8 status;
- struct intel_sdvo *intel_sdvo;
- DRM_DEBUG_KMS("\n");
-
- if (!connector)
- return 0;
-
- intel_sdvo = to_intel_sdvo(connector);
return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
&response, 2) && response[0];
}
-void intel_sdvo_set_hotplug(struct drm_connector *connector, int on)
+static void intel_sdvo_enable_hotplug(struct intel_encoder *encoder)
{
+ struct intel_sdvo *intel_sdvo = to_intel_sdvo(&encoder->base);
u8 response[2];
u8 status;
- struct intel_sdvo *intel_sdvo = to_intel_sdvo(connector);
intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
intel_sdvo_read_response(intel_sdvo, &response, 2);
- 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);
- intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
- } else {
- response[0] = 0;
- response[1] = 0;
- intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
- }
+ intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
intel_sdvo_read_response(intel_sdvo, &response, 2);
}
-#endif
static bool
intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo)
@@ -2045,6 +2002,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
{
struct drm_encoder *encoder = &intel_sdvo->base.base;
struct drm_connector *connector;
+ struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
struct intel_connector *intel_connector;
struct intel_sdvo_connector *intel_sdvo_connector;
@@ -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;
+ intel_sdvo_enable_hotplug(intel_encoder);
+ }
+ else
+ connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
connector->connector_type = DRM_MODE_CONNECTOR_DVID;
--
1.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 14:17 [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI Simon Farnsworth
@ 2011-09-20 14:18 ` Simon Farnsworth
2011-09-20 16:27 ` Keith Packard
1 sibling, 0 replies; 7+ messages in thread
From: Simon Farnsworth @ 2011-09-20 14:18 UTC (permalink / raw)
To: Keith Packard; +Cc: intel-gfx
On Tuesday 20 September 2011, Simon Farnsworth <simon.farnsworth@onelan.co.uk>
wrote:
> 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 <ajax@redhat.com> on IRC.
>
> Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
> ---
> 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.
--
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 14:17 [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI Simon Farnsworth
2011-09-20 14:18 ` Simon Farnsworth
@ 2011-09-20 16:27 ` Keith Packard
2011-09-20 16:38 ` Simon Farnsworth
1 sibling, 1 reply; 7+ messages in thread
From: Keith Packard @ 2011-09-20 16:27 UTC (permalink / raw)
To: Simon Farnsworth; +Cc: intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 1832 bytes --]
On Tue, 20 Sep 2011 15:17:38 +0100, Simon Farnsworth <simon.farnsworth@onelan.co.uk> wrote:
> - 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);
...
> + 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.
> @@ -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.
--
keith.packard@intel.com
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 16:27 ` Keith Packard
@ 2011-09-20 16:38 ` Simon Farnsworth
2011-09-20 16:55 ` Keith Packard
0 siblings, 1 reply; 7+ messages in thread
From: Simon Farnsworth @ 2011-09-20 16:38 UTC (permalink / raw)
To: Keith Packard; +Cc: intel-gfx
On Tuesday 20 September 2011, Keith Packard <keithp@keithp.com> wrote:
> On Tue, 20 Sep 2011 15:17:38 +0100, Simon Farnsworth
<simon.farnsworth@onelan.co.uk> wrote:
> > - 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);
>
> ...
>
> > + 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.
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.
>
> > @@ -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.
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.
--
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 16:38 ` Simon Farnsworth
@ 2011-09-20 16:55 ` Keith Packard
2011-09-20 16:57 ` Simon Farnsworth
0 siblings, 1 reply; 7+ messages in thread
From: Keith Packard @ 2011-09-20 16:55 UTC (permalink / raw)
To: Simon Farnsworth; +Cc: intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 1248 bytes --]
On Tue, 20 Sep 2011 17:38:37 +0100, Simon Farnsworth <simon.farnsworth@onelan.co.uk> wrote:
> 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?
> 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'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.
--
keith.packard@intel.com
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 16:55 ` Keith Packard
@ 2011-09-20 16:57 ` Simon Farnsworth
2011-09-20 17:05 ` Keith Packard
0 siblings, 1 reply; 7+ messages in thread
From: Simon Farnsworth @ 2011-09-20 16:57 UTC (permalink / raw)
To: Keith Packard; +Cc: intel-gfx
On Tuesday 20 September 2011, Keith Packard <keithp@keithp.com> wrote:
> On Tue, 20 Sep 2011 17:38:37 +0100, Simon Farnsworth
<simon.farnsworth@onelan.co.uk> wrote:
> > 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.
> > 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.
--
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 16:57 ` Simon Farnsworth
@ 2011-09-20 17:05 ` Keith Packard
0 siblings, 0 replies; 7+ messages in thread
From: Keith Packard @ 2011-09-20 17:05 UTC (permalink / raw)
To: Simon Farnsworth; +Cc: intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 512 bytes --]
On Tue, 20 Sep 2011 17:57:21 +0100, Simon Farnsworth <simon.farnsworth@onelan.co.uk> wrote:
> 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.
> 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.
--
keith.packard@intel.com
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-09-20 17:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-20 14:17 [PATCH] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI Simon Farnsworth
2011-09-20 14:18 ` Simon Farnsworth
2011-09-20 16:27 ` Keith Packard
2011-09-20 16:38 ` Simon Farnsworth
2011-09-20 16:55 ` Keith Packard
2011-09-20 16:57 ` Simon Farnsworth
2011-09-20 17:05 ` Keith Packard
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.