acpi: tie ACPI backlight devices to PCI devices if possible
authorMatthew Garrett <mjg@redhat.com>
Tue, 22 Mar 2011 23:30:25 +0000 (16:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Mar 2011 00:44:00 +0000 (17:44 -0700)
Dual-GPU machines may provide more than one ACPI backlight interface.  Tie
the backlight device to the GPU in order to allow userspace to identify
the correct interface.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Tested-by: Sedat Dilek <sedat.dilek@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/acpi/video.c

index a9eec8c95a1f6ddd411d454b3e9afd7877df9ebb..a18e497f1c3ca92722fd5f8bc8e36bb774d7b982 100644 (file)
@@ -782,6 +782,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 
        if (acpi_video_backlight_support()) {
                struct backlight_properties props;
+               struct pci_dev *pdev;
+               acpi_handle acpi_parent;
+               struct device *parent = NULL;
                int result;
                static int count = 0;
                char *name;
@@ -794,10 +797,20 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                        return;
                count++;
 
+               acpi_get_parent(device->dev->handle, &acpi_parent);
+
+               pdev = acpi_get_pci_dev(acpi_parent);
+               if (pdev) {
+                       parent = &pdev->dev;
+                       pci_dev_put(pdev);
+               }
+
                memset(&props, 0, sizeof(struct backlight_properties));
                props.type = BACKLIGHT_FIRMWARE;
                props.max_brightness = device->brightness->count - 3;
-               device->backlight = backlight_device_register(name, NULL, device,
+               device->backlight = backlight_device_register(name,
+                                                             parent,
+                                                             device,
                                                              &acpi_backlight_ops,
                                                              &props);
                kfree(name);