* [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
@ 2011-09-20 17:31 Simon Farnsworth
2011-09-20 19:43 ` Keith Packard
0 siblings, 1 reply; 6+ messages in thread
From: Simon Farnsworth @ 2011-09-20 17:31 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 the unnumbered v4:
* At Keith Packard's request, store the required hotplug bits in
struct intel_sdvo and just call SET_ACTIVE_HOT_PLUG to enable
hotplug interrupts.
* Add some comments to explain why I'm doing things that reviewers
didn't think was obvious, so that the next person to examine this
area doesn't get confused.
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 | 88 ++++++++++++-------------------------
2 files changed, 29 insertions(+), 62 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..5813538 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -92,6 +92,11 @@ struct intel_sdvo {
*/
uint16_t attached_output;
+ /*
+ * Hotplug activation bits for this device
+ */
+ uint8_t hotplug_active[2];
+
/**
* This is used to select the color range of RBG outputs in HDMI mode.
* It is only valid when using TMDS encoding and 8 bit per color mode.
@@ -1208,74 +1213,20 @@ 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)
{
- 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_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);
- }
+ struct intel_sdvo *intel_sdvo = to_intel_sdvo(&encoder->base);
- intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
- intel_sdvo_read_response(intel_sdvo, &response, 2);
+ intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &intel_sdvo->hotplug_active, 2);
}
-#endif
static bool
intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo)
@@ -2045,6 +1996,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 +2014,17 @@ 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_sdvo->hotplug_active[0] |= 1 << device;
+ /* Some SDVO devices have one-shot hotplug interrupts.
+ * Ensure that they get re-enabled when an interrupt happens.
+ */
+ 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;
@@ -2569,6 +2531,14 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps))
goto err;
+ /* Set up hotplug command - note paranoia about contents of reply.
+ * We simply clear out the bits we understand, and hope that
+ * the rest are in good shape for the hardware.
+ */
+ intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
+ &intel_sdvo->hotplug_active, 2);
+ intel_sdvo->hotplug_active[0] &= 0x3;
+
if (intel_sdvo_output_setup(intel_sdvo,
intel_sdvo->caps.output_flags) != true) {
DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",
--
1.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 17:31 [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI Simon Farnsworth
@ 2011-09-20 19:43 ` Keith Packard
2011-09-21 9:08 ` Simon Farnsworth
0 siblings, 1 reply; 6+ messages in thread
From: Keith Packard @ 2011-09-20 19:43 UTC (permalink / raw)
To: Simon Farnsworth; +Cc: intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 676 bytes --]
On Tue, 20 Sep 2011 18:31:25 +0100, Simon Farnsworth <simon.farnsworth@onelan.co.uk> wrote:
> + /* Set up hotplug command - note paranoia about contents of reply.
> + * We simply clear out the bits we understand, and hope that
> + * the rest are in good shape for the hardware.
> + */
> + intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
> + &intel_sdvo->hotplug_active, 2);
> + intel_sdvo->hotplug_active[0] &= 0x3;
> +
This appears to unconditionally set the bits for devices 0 and 1, making
the dvi-specific code that sets the device bit irrelevant. I think you
just want to set hotplug_active to 0.
--
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] 6+ messages in thread
* Re: [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-20 19:43 ` Keith Packard
@ 2011-09-21 9:08 ` Simon Farnsworth
2011-09-21 14:58 ` Keith Packard
0 siblings, 1 reply; 6+ messages in thread
From: Simon Farnsworth @ 2011-09-21 9:08 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 18:31:25 +0100, Simon Farnsworth
<simon.farnsworth@onelan.co.uk> wrote:
> > + /* Set up hotplug command - note paranoia about contents of reply.
> > + * We simply clear out the bits we understand, and hope that
> > + * the rest are in good shape for the hardware.
> > + */
> > + intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
> > + &intel_sdvo->hotplug_active, 2);
> > + intel_sdvo->hotplug_active[0] &= 0x3;
> > +
>
> This appears to unconditionally set the bits for devices 0 and 1, making
> the dvi-specific code that sets the device bit irrelevant. I think you
> just want to set hotplug_active to 0.
I'm clearing the bits (&= not |=). I could respin setting it to 0, but that
takes me even further from the old (commented out) code, and I'd really want
someone to check SDVO specs before doing that.
--
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-21 9:08 ` Simon Farnsworth
@ 2011-09-21 14:58 ` Keith Packard
2011-09-21 15:18 ` Simon Farnsworth
0 siblings, 1 reply; 6+ messages in thread
From: Keith Packard @ 2011-09-21 14:58 UTC (permalink / raw)
To: Simon Farnsworth; +Cc: intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 910 bytes --]
On Wed, 21 Sep 2011 10:08:13 +0100, Simon Farnsworth <simon.farnsworth@onelan.co.uk> wrote:
> I'm clearing the bits (&= not |=). I could respin setting it to 0, but that
> takes me even further from the old (commented out) code, and I'd really want
> someone to check SDVO specs before doing that.
What I see the code doing is asking whether devices 0 and 1 *could*
support hotplug and then unconditionally setting the devices for which
we *want* hotplug to that.
I think you should set the list of devices requesting hotplug to be the
intersection of the set of devices which *could* do hotplug and the
set of devices for which we *want* hotplug.
That seems like it would be achieved by just clearing the set of devices
that we will request hotplug for and then checking which ones are
supported and incrementally adding those to the hotplug_active set.
--
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] 6+ messages in thread
* Re: [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-21 14:58 ` Keith Packard
@ 2011-09-21 15:18 ` Simon Farnsworth
2011-09-21 15:47 ` Keith Packard
0 siblings, 1 reply; 6+ messages in thread
From: Simon Farnsworth @ 2011-09-21 15:18 UTC (permalink / raw)
To: Keith Packard; +Cc: intel-gfx
On Wednesday 21 September 2011, Keith Packard <keithp@keithp.com> wrote:
> On Wed, 21 Sep 2011 10:08:13 +0100, Simon Farnsworth
<simon.farnsworth@onelan.co.uk> wrote:
> > I'm clearing the bits (&= not |=). I could respin setting it to 0, but
> > that takes me even further from the old (commented out) code, and I'd
> > really want someone to check SDVO specs before doing that.
>
> What I see the code doing is asking whether devices 0 and 1 *could*
> support hotplug and then unconditionally setting the devices for which
> we *want* hotplug to that.
>
> I think you should set the list of devices requesting hotplug to be the
> intersection of the set of devices which *could* do hotplug and the
> set of devices for which we *want* hotplug.
>
> That seems like it would be achieved by just clearing the set of devices
> that we will request hotplug for and then checking which ones are
> supported and incrementally adding those to the hotplug_active set.
I think I see my mistake - but I'd like to check before I do a v6 of this
patch.
I'm ANDing the value returned by hardware with 3 - I should be ANDing it with
an appropriate ~3. The rest of the code (setting those bits in
intel_sdvo_dvi_init based on what functions I have) should be OK.
Essentially, I'm fairly confident based on empirical evidence that bit 0 is HPD
for device 0 (as my SDVO devices both return 0x01 in that byte). I don't know
what the rest of the bits mean, but it seems like a reasonable guess that bit
1 is HPD for device 1, so I'm acting accordingly.
I would still like someone with the spec to go over what I'm doing - this
seems appropriate, but *all* I have to test against are two different
motherboards with "integrated" DVI-D that turns out to be an SDVO device.
I have no documentation for SDVO - all of this is based on the existing code
with hints from ajax; it could be complete nonsense for anything other than
the two devices I have.
--
Simon Farnsworth
Software Engineer
ONELAN Limited
http://www.onelan.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI
2011-09-21 15:18 ` Simon Farnsworth
@ 2011-09-21 15:47 ` Keith Packard
0 siblings, 0 replies; 6+ messages in thread
From: Keith Packard @ 2011-09-21 15:47 UTC (permalink / raw)
To: Simon Farnsworth; +Cc: intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 931 bytes --]
On Wed, 21 Sep 2011 16:18:55 +0100, Simon Farnsworth <simon.farnsworth@onelan.co.uk> wrote:
> I'm ANDing the value returned by hardware with 3 - I should be ANDing it with
> an appropriate ~3. The rest of the code (setting those bits in
> intel_sdvo_dvi_init based on what functions I have) should be OK.
Oh, that's a good point. I'd say that you shouldn't change any bits you
don't know about.
So, fetch the current active hotplug value and then clear bits 0 and 1
so that we change only those.
> I would still like someone with the spec to go over what I'm doing - this
> seems appropriate, but *all* I have to test against are two different
> motherboards with "integrated" DVI-D that turns out to be an SDVO
> device.
Yeah, I've been digging around for an SDVO spec, but it's buried as it
contains a pile of stuff for macro-vision and other content protection
bits.
--
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] 6+ messages in thread
end of thread, other threads:[~2011-09-21 15:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-20 17:31 [PATCHv5] drm/i915: Enable SDVO hotplug interrupts for HDMI and DVI Simon Farnsworth
2011-09-20 19:43 ` Keith Packard
2011-09-21 9:08 ` Simon Farnsworth
2011-09-21 14:58 ` Keith Packard
2011-09-21 15:18 ` Simon Farnsworth
2011-09-21 15:47 ` 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.