intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: resurrect panel lid handling
@ 2012-11-16 19:34 Daniel Vetter
  2012-11-20 13:50 ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2012-11-16 19:34 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

But disabled by default. This essentially reverts

commit bcd5023c961a44c7149936553b6929b2b233dd27
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Mar 14 14:17:55 2011 +1000

    drm/i915: disable opregion lid detection for now

but leaves the autodetect mode disabled. There's also the explicit lid
status option added in

commit fca874092597ef946b8f07031d8c31c58b212144
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 17 13:44:48 2011 +0000

    drm/i915: Add a module parameter to ignore lid status

Which overloaded the meaning for the panel_ignore_lid parameter even
more. To fix up this mess, give the non-negative numbers 0,1 the
original meaning back and use negative numbers to force a given state.
So now we have

1  - disable autodetect, return unknown
0  - enable autodetect
-1 - force to disconnected/lid closed
-2 - force to connected/lid open

v2: My C programmer license has been revoked ...

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=27622
Tested-by: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.c    |    6 +++---
 drivers/gpu/drm/i915/intel_panel.c |   18 +++++++-----------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index a3d754d..f5b505a 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -47,11 +47,11 @@ MODULE_PARM_DESC(modeset,
 unsigned int i915_fbpercrtc __always_unused = 0;
 module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
 
-int i915_panel_ignore_lid __read_mostly = 0;
+int i915_panel_ignore_lid __read_mostly = 1;
 module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
 MODULE_PARM_DESC(panel_ignore_lid,
-		"Override lid status (0=autodetect [default], 1=lid open, "
-		"-1=lid closed)");
+		"Override lid status (0=autodetect, 1=autodetect disabled [default], "
+		"-1=force lid closed, -2=force lid open)");
 
 unsigned int i915_powersave __read_mostly = 1;
 module_param_named(powersave, i915_powersave, int, 0600);
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 41d4635..4e77a83 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -275,7 +275,7 @@ static void intel_panel_actually_set_backlight(struct drm_device *dev, u32 level
 	}
 
 	tmp = I915_READ(BLC_PWM_CTL);
-	if (INTEL_INFO(dev)->gen < 4) 
+	if (INTEL_INFO(dev)->gen < 4)
 		level <<= 1;
 	tmp &= ~BACKLIGHT_DUTY_CYCLE_MASK;
 	I915_WRITE(BLC_PWM_CTL, tmp | level);
@@ -374,24 +374,20 @@ static void intel_panel_init_backlight(struct drm_device *dev)
 enum drm_connector_status
 intel_panel_detect(struct drm_device *dev)
 {
-#if 0
 	struct drm_i915_private *dev_priv = dev->dev_private;
-#endif
 
-	if (i915_panel_ignore_lid)
-		return i915_panel_ignore_lid > 0 ?
-			connector_status_connected :
-			connector_status_disconnected;
+	if (i915_panel_ignore_lid == -2)
+		return connector_status_connected;
+	else if (i915_panel_ignore_lid == -1)
+		return connector_status_disconnected;
+	else if (i915_panel_ignore_lid == 1)
+		return connector_status_unknown;
 
-	/* opregion lid state on HP 2540p is wrong at boot up,
-	 * appears to be either the BIOS or Linux ACPI fault */
-#if 0
 	/* Assume that the BIOS does not lie through the OpRegion... */
 	if (dev_priv->opregion.lid_state)
 		return ioread32(dev_priv->opregion.lid_state) & 0x1 ?
 			connector_status_connected :
 			connector_status_disconnected;
-#endif
 
 	return connector_status_unknown;
 }
-- 
1.7.10.4

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

* [PATCH] drm/i915: resurrect panel lid handling
  2012-11-16 19:34 [PATCH] drm/i915: resurrect panel lid handling Daniel Vetter
@ 2012-11-20 13:50 ` Daniel Vetter
  2012-11-20 13:59   ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2012-11-20 13:50 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

But disabled by default. This essentially reverts

commit bcd5023c961a44c7149936553b6929b2b233dd27
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Mar 14 14:17:55 2011 +1000

    drm/i915: disable opregion lid detection for now

but leaves the autodetect mode disabled. There's also the explicit lid
status option added in

commit fca874092597ef946b8f07031d8c31c58b212144
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 17 13:44:48 2011 +0000

    drm/i915: Add a module parameter to ignore lid status

Which overloaded the meaning for the panel_ignore_lid parameter even
more. To fix up this mess, give the non-negative numbers 0,1 the
original meaning back and use negative numbers to force a given state.
So now we have

1  - disable autodetect, return unknown
0  - enable autodetect
-1 - force to disconnected/lid closed
-2 - force to connected/lid open

v2: My C programmer license has been revoked ...

v3: Beautify the code a bit, as suggested by Chris Wilson.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=27622
Tested-by: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.c    |    6 +++---
 drivers/gpu/drm/i915/intel_panel.c |   25 +++++++++++--------------
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index a3d754d..f5b505a 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -47,11 +47,11 @@ MODULE_PARM_DESC(modeset,
 unsigned int i915_fbpercrtc __always_unused = 0;
 module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
 
-int i915_panel_ignore_lid __read_mostly = 0;
+int i915_panel_ignore_lid __read_mostly = 1;
 module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
 MODULE_PARM_DESC(panel_ignore_lid,
-		"Override lid status (0=autodetect [default], 1=lid open, "
-		"-1=lid closed)");
+		"Override lid status (0=autodetect, 1=autodetect disabled [default], "
+		"-1=force lid closed, -2=force lid open)");
 
 unsigned int i915_powersave __read_mostly = 1;
 module_param_named(powersave, i915_powersave, int, 0600);
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 41d4635..c758ad2 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -275,7 +275,7 @@ static void intel_panel_actually_set_backlight(struct drm_device *dev, u32 level
 	}
 
 	tmp = I915_READ(BLC_PWM_CTL);
-	if (INTEL_INFO(dev)->gen < 4) 
+	if (INTEL_INFO(dev)->gen < 4)
 		level <<= 1;
 	tmp &= ~BACKLIGHT_DUTY_CYCLE_MASK;
 	I915_WRITE(BLC_PWM_CTL, tmp | level);
@@ -374,26 +374,23 @@ static void intel_panel_init_backlight(struct drm_device *dev)
 enum drm_connector_status
 intel_panel_detect(struct drm_device *dev)
 {
-#if 0
 	struct drm_i915_private *dev_priv = dev->dev_private;
-#endif
-
-	if (i915_panel_ignore_lid)
-		return i915_panel_ignore_lid > 0 ?
-			connector_status_connected :
-			connector_status_disconnected;
 
-	/* opregion lid state on HP 2540p is wrong at boot up,
-	 * appears to be either the BIOS or Linux ACPI fault */
-#if 0
 	/* Assume that the BIOS does not lie through the OpRegion... */
-	if (dev_priv->opregion.lid_state)
+	if (!i915_panel_ignore_lid && dev_priv->opregion.lid_state) {
 		return ioread32(dev_priv->opregion.lid_state) & 0x1 ?
 			connector_status_connected :
 			connector_status_disconnected;
-#endif
+	}
 
-	return connector_status_unknown;
+	switch (i915_panel_ignore_lid) {
+	case -2:
+		return connector_status_connected;
+	case -1:
+		return connector_status_disconnected;
+	default:
+		return connector_status_unknown;
+	}
 }
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-- 
1.7.10.4

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

* Re: [PATCH] drm/i915: resurrect panel lid handling
  2012-11-20 13:50 ` Daniel Vetter
@ 2012-11-20 13:59   ` Chris Wilson
  2012-11-20 15:33     ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2012-11-20 13:59 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

On Tue, 20 Nov 2012 14:50:08 +0100, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> But disabled by default. This essentially reverts
> 
> commit bcd5023c961a44c7149936553b6929b2b233dd27
> Author: Dave Airlie <airlied@redhat.com>
> Date:   Mon Mar 14 14:17:55 2011 +1000
> 
>     drm/i915: disable opregion lid detection for now
> 
> but leaves the autodetect mode disabled. There's also the explicit lid
> status option added in
> 
> commit fca874092597ef946b8f07031d8c31c58b212144
> Author: Chris Wilson <chris@chris-wilson.co.uk>
> Date:   Thu Feb 17 13:44:48 2011 +0000
> 
>     drm/i915: Add a module parameter to ignore lid status
> 
> Which overloaded the meaning for the panel_ignore_lid parameter even
> more. To fix up this mess, give the non-negative numbers 0,1 the
> original meaning back and use negative numbers to force a given state.
> So now we have
> 
> 1  - disable autodetect, return unknown
> 0  - enable autodetect
> -1 - force to disconnected/lid closed
> -2 - force to connected/lid open
> 
> v2: My C programmer license has been revoked ...
> 
> v3: Beautify the code a bit, as suggested by Chris Wilson.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=27622
> Tested-by: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

One day, I would like for lid state detection to be default, but as
always the hw manufacturers conspire against us. Out of curiousity, Dave
does your HP 2540p work yet?

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

(You could lose the enclosing { } around the single line statement.)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

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

* Re: [PATCH] drm/i915: resurrect panel lid handling
  2012-11-20 13:59   ` Chris Wilson
@ 2012-11-20 15:33     ` Daniel Vetter
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2012-11-20 15:33 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Daniel Vetter, Intel Graphics Development

On Tue, Nov 20, 2012 at 01:59:14PM +0000, Chris Wilson wrote:
> On Tue, 20 Nov 2012 14:50:08 +0100, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > But disabled by default. This essentially reverts
> > 
> > commit bcd5023c961a44c7149936553b6929b2b233dd27
> > Author: Dave Airlie <airlied@redhat.com>
> > Date:   Mon Mar 14 14:17:55 2011 +1000
> > 
> >     drm/i915: disable opregion lid detection for now
> > 
> > but leaves the autodetect mode disabled. There's also the explicit lid
> > status option added in
> > 
> > commit fca874092597ef946b8f07031d8c31c58b212144
> > Author: Chris Wilson <chris@chris-wilson.co.uk>
> > Date:   Thu Feb 17 13:44:48 2011 +0000
> > 
> >     drm/i915: Add a module parameter to ignore lid status
> > 
> > Which overloaded the meaning for the panel_ignore_lid parameter even
> > more. To fix up this mess, give the non-negative numbers 0,1 the
> > original meaning back and use negative numbers to force a given state.
> > So now we have
> > 
> > 1  - disable autodetect, return unknown
> > 0  - enable autodetect
> > -1 - force to disconnected/lid closed
> > -2 - force to connected/lid open
> > 
> > v2: My C programmer license has been revoked ...
> > 
> > v3: Beautify the code a bit, as suggested by Chris Wilson.
> > 
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=27622
> > Tested-by: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> One day, I would like for lid state detection to be default, but as
> always the hw manufacturers conspire against us. Out of curiousity, Dave
> does your HP 2540p work yet?
> 
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Queued for -next, thanks for the review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

end of thread, other threads:[~2012-11-20 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-16 19:34 [PATCH] drm/i915: resurrect panel lid handling Daniel Vetter
2012-11-20 13:50 ` Daniel Vetter
2012-11-20 13:59   ` Chris Wilson
2012-11-20 15:33     ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).