@@ -46,6 +46,9 @@
#include <acpi/acpi_drivers.h>
#include <linux/suspend.h>
#include <acpi/video.h>
+#if defined(CONFIG_DRM_I915) || defined(CONFIG_DRM_I915_MODULE)
+#include <drm/i915_drm.h>
+#endif
#define PREFIX "ACPI: "
@@ -2557,17 +2560,20 @@ static int __init intel_opregion_present(void)
{
#if defined(CONFIG_DRM_I915) || defined(CONFIG_DRM_I915_MODULE)
struct pci_dev *dev = NULL;
- u32 address;
+ int err;
for_each_pci_dev(dev) {
if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
continue;
if (dev->vendor != PCI_VENDOR_ID_INTEL)
continue;
- pci_read_config_dword(dev, 0xfc, &address);
- if (!address)
- continue;
- return 1;
+ err = intel_opregion_device_support(dev);
+ if (err == 0)
+ return 1;
+ else
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No opregion support"
+ " on Intel graphics card: %d\n",
+ err));
}
#endif
return 0;
@@ -26,6 +26,8 @@
*/
#include <linux/acpi.h>
+#include <linux/pci_ids.h>
+#include <linux/pci.h>
#include <acpi/video.h>
#include "drmP.h"
@@ -464,15 +466,43 @@ blind_set:
goto end;
}
-int intel_opregion_init(struct drm_device *dev, int resume)
+static int i915_opregion = 1;
+module_param_named(opregion, i915_opregion, int, 0400);
+MODULE_PARM_DESC(opregion, "opregion support (backlight,display output,..) "
+ "(1=on [default], 0=off, 2=force)");
+
+static const struct pci_device_id intel_opregion_blacklist[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_VGA_0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_VGA_1) },
+ { }
+};
+
+/* Returns zero if opregion device is supported or an error code if not */
+int intel_opregion_device_support(struct pci_dev *pdev)
{
- struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_opregion *opregion = &dev_priv->opregion;
+ struct intel_opregion opregion;
void *base;
u32 asls, mboxes;
- int err = 0;
+ int i, err = 0;
+
+ if (i915_opregion == 0)
+ return -ENODEV;
+
+ for (i = 0; intel_opregion_blacklist[i].device != 0; i++) {
+ if (pdev->device == intel_opregion_blacklist[i].device) {
+ if (i915_opregion != 2) {
+ DRM_INFO("opregion support blacklisted for"
+ " device %s, let video.ko handle it\n",
+ pci_name(pdev));
+ return -ENOTSUPP;
+ } else {
+ DRM_INFO("Force opregion on blacklisted"
+ " device %s\n", pci_name(pdev));
+ }
+ }
+ }
- pci_read_config_dword(dev->pdev, PCI_ASLS, &asls);
+ pci_read_config_dword(pdev, PCI_ASLS, &asls);
DRM_DEBUG_DRIVER("graphic opregion physical addr: 0x%x\n", asls);
if (asls == 0) {
DRM_DEBUG_DRIVER("ACPI OpRegion not supported!\n");
@@ -483,6 +513,43 @@ int intel_opregion_init(struct drm_device *dev, int resume)
if (!base)
return -ENOMEM;
+ opregion.header = base;
+ if (memcmp(opregion.header->signature, OPREGION_SIGNATURE, 16)) {
+ DRM_DEBUG_DRIVER("opregion signature mismatch\n");
+ err = -EINVAL;
+ goto out;
+ }
+
+ mboxes = opregion.header->mboxes;
+ if (!(mboxes & MBOX_ACPI)) {
+ DRM_DEBUG_DRIVER("Public ACPI methods not supported\n");
+ err = -ENOTSUPP;
+ goto out;
+ }
+
+out:
+ iounmap(opregion.header);
+ return err;
+}
+EXPORT_SYMBOL_GPL(intel_opregion_device_support);
+
+int intel_opregion_init(struct drm_device *dev, int resume)
+{
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ struct intel_opregion *opregion = &dev_priv->opregion;
+ void *base;
+ u32 asls, mboxes;
+ int err = 0;
+
+ err = intel_opregion_device_support(dev->pdev);
+ if (err)
+ return err;
+
+ pci_read_config_dword(dev->pdev, PCI_ASLS, &asls);
+ base = ioremap(asls, OPREGION_SZ);
+ if (!base)
+ return -ENOMEM;
+
opregion->header = base;
if (memcmp(opregion->header->signature, OPREGION_SIGNATURE, 16)) {
DRM_DEBUG_DRIVER("opregion signature mismatch\n");
@@ -40,6 +40,7 @@ extern bool i915_gpu_raise(void);
extern bool i915_gpu_lower(void);
extern bool i915_gpu_busy(void);
extern bool i915_gpu_turbo_disable(void);
+extern int intel_opregion_device_support(struct pci_dev *pdev);
#endif
/* Each region is a minimum of 16k, and there are at most 255 of them.
@@ -2675,6 +2675,8 @@
#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0
#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2
#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
+#define PCI_DEVICE_ID_INTEL_SCH_VGA_0 0x8108
+#define PCI_DEVICE_ID_INTEL_SCH_VGA_1 0x8109
#define PCI_DEVICE_ID_INTEL_SCH_LPC 0x8119
#define PCI_DEVICE_ID_INTEL_SCH_IDE 0x811a
#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4