]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/i915: Use ACPI OpRegion to determine lid status
authorChris Wilson <chris@chris-wilson.co.uk>
Sun, 16 Jan 2011 19:37:30 +0000 (19:37 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 19 Jan 2011 12:32:21 +0000 (12:32 +0000)
Admittedly, trusting ACPI or the BIOS at all to be correct is littered
with numerous examples where it is wrong. Maybe, just maybe, we will
have better luck using the ACPI OpRegion lid status...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_opregion.c

index 5969f46ac2d6023740204c74e62d25265cfc736f..536368a434126f669235d97a56690d8f693a8c5c 100644 (file)
@@ -111,6 +111,7 @@ struct intel_opregion {
        struct opregion_swsci *swsci;
        struct opregion_asle *asle;
        void *vbt;
+       u32 __iomem *lid_state;
 };
 #define OPREGION_SIZE            (8*1024)
 
index ace8d5d30dd21b25b3f0390cdd2b8d13659f666e..fc6a0a9297c755cee260089808b8ab31196eea8f 100644 (file)
@@ -472,8 +472,15 @@ static enum drm_connector_status
 intel_lvds_detect(struct drm_connector *connector, bool force)
 {
        struct drm_device *dev = connector->dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
        enum drm_connector_status status = connector_status_connected;
 
+       /* 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;
+
        /* ACPI lid methods were generally unreliable in this generation, so
         * don't even bother.
         */
index f295a7aaadf9e54edb9cbe905739890e3c2edbe4..aeec83fc694095204021444bbaf452413bc16ea7 100644 (file)
@@ -488,6 +488,8 @@ int intel_opregion_setup(struct drm_device *dev)
        opregion->header = base;
        opregion->vbt = base + OPREGION_VBT_OFFSET;
 
+       opregion->lid_state = base + 0x01ac;
+
        mboxes = opregion->header->mboxes;
        if (mboxes & MBOX_ACPI) {
                DRM_DEBUG_DRIVER("Public ACPI methods supported\n");