linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm] ACPI video: only one ACPI bus video device is allowed for one VGA controller
@ 2009-07-15  9:18 Zhang Rui
  2009-07-15 14:31 ` Henrique de Moraes Holschuh
  2009-08-30  2:18 ` Len Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Zhang Rui @ 2009-07-15  9:18 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Zhang, Rui, hector


Only one ACPI video bus device for a VGA controller.

Some buggy BIOS exports multiple ACPI video bus devices for the same
VGA controller, and multiple backlight control methods as well.
This messes up the ACPI video backlight control.
http://bugzilla.kernel.org/show_bug.cgi?id=13577

With this patch applied, only the first ACPI video bus device
under a PCI device node is bind to ACPI video driver.

The questions is that, we never notice this kind of devices before,
thus I'm not sure this won't break any laptops.

I suggest we put this patch in ACPI test tree first.

Tested-by: Hector Martin <hector@marcansoft.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/video.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -2195,11 +2195,43 @@ static int acpi_video_resume(struct acpi
 	return AE_OK;
 }
 
+static acpi_status
+acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
+			void **return_value)
+{
+	struct acpi_device *device = context;
+	struct acpi_device *sibling;
+	int result;
+
+	if (handle == device->handle)
+		return AE_CTRL_TERMINATE;
+
+	result = acpi_bus_get_device(handle, &sibling);
+	if (result)
+		return AE_OK;
+
+	/* only one ACPI bus video device under a PCI device */
+	if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
+		return AE_ALREADY_EXISTS;
+
+	return AE_OK;
+}
+
 static int acpi_video_bus_add(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
 	struct input_dev *input;
 	int error;
+	acpi_status status;
+
+	status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
+				device->parent->handle, 1,
+				acpi_video_bus_match, device, NULL);
+	if (status == AE_ALREADY_EXISTS) {
+		printk(KERN_WARNING PREFIX, "Duplicate ACPI video bus "
+				"devices for the same VGA controller\n");
+		return -ENODEV;
+	}
 
 	video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
 	if (!video)



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

end of thread, other threads:[~2009-08-30  2:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-15  9:18 [PATCH -mm] ACPI video: only one ACPI bus video device is allowed for one VGA controller Zhang Rui
2009-07-15 14:31 ` Henrique de Moraes Holschuh
2009-07-15 21:59   ` Hector Martin
2009-07-16  2:37     ` Zhang Rui
2009-07-16 11:49       ` Henrique de Moraes Holschuh
2009-07-16 12:10         ` Hector Martin
2009-08-30  2:18 ` Len Brown

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).