drm/i915: force mode set at lid open time
authorJesse Barnes <jbarnes@virtuousgeek.org>
Thu, 10 Sep 2009 22:28:03 +0000 (15:28 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 10 Sep 2009 23:10:00 +0000 (16:10 -0700)
Some laptop platforms will disable pipes and/or planes at lid close time
and not restore them when the lid is opened again.  So catch the lid
event, and if the lid was opened, force a mode restore.

Fixes fdo bug #21230.

Acked-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/Kconfig
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_lvds.c

index e4d971c8b9d0bebe015a80b975a05a5a9c0a9a6d..f831ea15929169af0f825343ec366974e9738932 100644 (file)
@@ -102,6 +102,7 @@ config DRM_I915
        select BACKLIGHT_CLASS_DEVICE if ACPI
        select INPUT if ACPI
        select ACPI_VIDEO if ACPI
+       select ACPI_BUTTON if ACPI
        help
          Choose this option if you have a system that has Intel 830M, 845G,
          852GM, 855GM 865G or 915G integrated graphics.  If M is selected, the
index df4597d9dac0d0339d81bfdac648c19baf231f48..f2b8d27aef2a6f4c519bbb6d6999683c56714b85 100644 (file)
@@ -222,6 +222,8 @@ typedef struct drm_i915_private {
        unsigned int edp_support:1;
        int lvds_ssc_freq;
 
+       struct notifier_block lid_notifier;
+
        int crt_ddc_bus; /* -1 = unknown, else GPIO to use for CRT DDC */
        struct drm_i915_fence_reg fence_regs[16]; /* assume 965 */
        int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
index cb5305ccb15ccb628ae13c74a531a455b0bd7d5a..92e0aae7070a97326eed3b5c32f55065e8040d77 100644 (file)
@@ -24,6 +24,8 @@
  *     Eric Anholt <eric@anholt.net>
  */
 
+#include <linux/module.h>
+#include <linux/input.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include "drmP.h"
index dafc0da1c256fa9acccc99f863c21cb6e4676f0c..e190ff792bf0ed676dfb333d99abe7f9cbeffdc1 100644 (file)
@@ -27,6 +27,7 @@
  *      Jesse Barnes <jesse.barnes@intel.com>
  */
 
+#include <acpi/button.h>
 #include <linux/dmi.h>
 #include <linux/i2c.h>
 #include "drmP.h"
@@ -632,6 +633,19 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
        return 0;
 }
 
+static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
+                           void *unused)
+{
+       struct drm_i915_private *dev_priv =
+               container_of(nb, struct drm_i915_private, lid_notifier);
+       struct drm_device *dev = dev_priv->dev;
+
+       if (acpi_lid_open())
+               drm_helper_resume_force_mode(dev);
+
+       return NOTIFY_OK;
+}
+
 /**
  * intel_lvds_destroy - unregister and free LVDS structures
  * @connector: connector to free
@@ -641,10 +655,14 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
  */
 static void intel_lvds_destroy(struct drm_connector *connector)
 {
+       struct drm_device *dev = connector->dev;
        struct intel_output *intel_output = to_intel_output(connector);
+       struct drm_i915_private *dev_priv = dev->dev_private;
 
        if (intel_output->ddc_bus)
                intel_i2c_destroy(intel_output->ddc_bus);
+       if (dev_priv->lid_notifier.notifier_call)
+               acpi_lid_notifier_unregister(&dev_priv->lid_notifier);
        drm_sysfs_connector_remove(connector);
        drm_connector_cleanup(connector);
        kfree(connector);
@@ -1011,6 +1029,11 @@ out:
                pwm |= PWM_PCH_ENABLE;
                I915_WRITE(BLC_PWM_PCH_CTL1, pwm);
        }
+       dev_priv->lid_notifier.notifier_call = intel_lid_notify;
+       if (acpi_lid_notifier_register(&dev_priv->lid_notifier)) {
+               DRM_DEBUG("lid notifier registration failed\n");
+               dev_priv->lid_notifier.notifier_call = NULL;
+       }
        drm_sysfs_connector_add(connector);
        return;