Re: Check for ACPI backlight support otherwise use vendor ACPIdrivers - version 4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 04 August 2008 08:09:52 Yves-Alexis Perez wrote:
> On lun, 2008-08-04 at 09:16 +0800, Zhang Rui wrote:
> > I think you're using the laptop that this patch does break.
> > Please try acpi_backlight=vendor.
>
> When booting to single user with acpi_backlight=vendor, thinkpad-acpi
> takes over backlight:
>
> Aug  4 07:54:38 hidalgo kernel: thinkpad_acpi: ThinkPad ACPI Extras v0.21
> Aug  4 07:54:38 hidalgo kernel: thinkpad_acpi: http://ibm-acpi.sf.net/
> Aug  4 07:54:38 hidalgo kernel: thinkpad_acpi: ThinkPad BIOS 7LETB9WW (2.19
> ), EC 7KHT24WW-1.08 Aug  4 07:54:38 hidalgo kernel: thinkpad_acpi: Lenovo
> ThinkPad T61, model 8897CTO Aug  4 07:54:38 hidalgo kernel: thinkpad_acpi:
> radio switch found; radios are enabled Aug  4 07:54:38 hidalgo kernel:
> thinkpad_acpi: This ThinkPad has standard ACPI backlight brightness
> control, supported by the ACPI video driver Aug  4 07:54:38 hidalgo kernel:
> thinkpad_acpi: Disabling thinkpad-acpi brightness events by default... Aug 
> 4 07:54:38 hidalgo kernel: Registered led device: tpacpi::thinklight Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi::power Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi:orange:batt Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi:green:batt Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi::dock_active Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi::bay_active Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi::dock_batt Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi::unknown_led Aug  4
> 07:54:38 hidalgo kernel: Registered led device: tpacpi::standby Aug  4
> 07:54:38 hidalgo kernel: thinkpad_acpi: Standard ACPI backlight interface
> not available, thinkpad_acpi driver will take over control Aug  4 07:54:38
> hidalgo kernel: thinkpad_acpi: detected a 16-level brightness capable
> ThinkPad Aug  4 07:54:38 hidalgo kernel: input: ThinkPad Extra Buttons as
> /devices/virtual/input/input6 Aug  4 07:54:38 hidalgo kernel: usb 1-1: new
> full speed USB device using uhci_hcd and address 4 Aug  4 07:54:38 hidalgo
> kernel: usb 1-1: configuration #1 chosen from 1 choice
>
> But when in user mode, brightness keys doesn't do anything either.
> Echo'ing to /proc/acpi/ibm/brightness doesn't work, but echoing
> to /sys/class/backlight/thinkpad_screen/brightness works.
That /proc/acpi/ibm/brightness does not and
/sys/class/backlight/thinkpad_screen/brightness 
works is strange, this should be a bug?

I wonder whether /proc/acpi/ibm/brightness can be removed soon, people had
some time to make use of the generic interface.

What you describe very much reminds me when I tested on a ThinkPad with an IGD
device. I removed the check for IGD devices in favour of a working IGD driver.

Attached patch might help you (with acpi_backlight=vendor)?
You should be able to apply this on my latest patchset, but use this patch
instead of the thinkpad_acpi one.

> Cat'ing /proc/acpi/events still gives:
> video LCD0 00000086 00000000
> video LCD0 00000087 00000000
>
> At one time I get the 750ms delay, but I don't have the
> ibm/hotkey HKEY 00000080 00005010 at all.
Hmm, on my machine it was 1010 and 1011 key event values for up/down
brightness. If you do not see those, the patch might not work.

> In X, same thing, no brightness keys, but xbacklight does work in
> standard mode (“kernel”).
>
> (btw it seems my mails don't reach linux-acpi, I don't really know why
> and postmaster don't answer, maybe they didn't have my mail either).

I expect you have an IGD device and this should by default be served by
Matthew's/Hong's patches. Matthew said something about a needed peace
that came in in latest BIOSes? But I expect you already run on the latest?
If not, you should update.

        Thomas



diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 85c3d2c..c9ed761 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -93,6 +93,11 @@ long acpi_is_video_device(struct acpi_device *device)
 	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy)))
 		video_caps |= ACPI_VIDEO_DEVICE_POSTING;
 
+	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "DRDY", &h_dummy))) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IGD device\n"));
+		video_caps |= ACPI_VIDEO_IGD;
+	}
+
 	/* Only check for backlight functionality if one of the above hit. */
 	if (video_caps)
 		acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle,
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index d3eb790..c68c6b1 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -240,6 +240,7 @@ static struct {
 	u32 light_status:1;
 	u32 bright_16levels:1;
 	u32 bright_acpimode:1;
+	u32 bright_igdmode:1;
 	u32 wan:1;
 	u32 fan_ctrl_status_undef:1;
 	u32 input_device_registered:1;
@@ -2353,6 +2354,9 @@ err_exit:
 	return (res < 0)? res : 1;
 }
 
+static struct backlight_device *ibm_backlight_device;
+static int brightness_update_status(struct backlight_device *bd);
+
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 {
 	u32 hkey;
@@ -2391,6 +2395,28 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 		case 1:
 			/* 0x1000-0x1FFF: key presses */
 			scancode = hkey & 0xfff;
+			if (tp_features.bright_igdmode) {
+				/* ToDo:
+				 * Is there an already defined key?
+				 */
+				if (hkey == 0x1011) {
+					if (ibm_backlight_device->
+					    props.brightness > 0) {
+						ibm_backlight_device->
+							props.brightness--;
+					}
+				} else if (hkey == 0x1010) {
+					if (ibm_backlight_device->
+					    props.brightness <
+					    ibm_backlight_device->
+					    props.max_brightness) {
+						ibm_backlight_device->
+							props.brightness++;
+					}
+				}
+				brightness_update_status(ibm_backlight_device);
+			}
+
 			if (scancode > 0 && scancode < 0x21) {
 				scancode--;
 				if (!(hotkey_source_mask & (1 << scancode))) {
@@ -4771,7 +4797,6 @@ enum {
 	TP_EC_BACKLIGHT_MAPSW = 0x20,
 };
 
-static struct backlight_device *ibm_backlight_device;
 static int brightness_mode;
 static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */
 
@@ -4910,7 +4935,7 @@ static struct backlight_ops ibm_backlight_data = {
 static int __init brightness_init(struct ibm_init_struct *iibm)
 {
 	int b;
-
+	long acpi_video_support;
 	vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
 
 	mutex_init(&brightness_mutex);
@@ -4922,17 +4947,43 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
 	 */
 	b = tpacpi_check_std_acpi_brightness_support();
 	if (b > 0) {
-		if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) {
-			printk(TPACPI_NOTICE
-			       "Lenovo BIOS switched to ACPI backlight "
-			       "control mode\n");
-		}
-		if (brightness_enable > 1) {
-			printk(TPACPI_NOTICE
-			       "standard ACPI backlight interface "
-			       "available, not loading native one...\n");
-			return 1;
-		}
+
+		if (acpi_video_backlight_support()) {
+			if (brightness_enable > 1) {
+				printk(TPACPI_NOTICE
+				       "standard ACPI backlight interface "
+				       "available, not loading native one.\n");
+				return 1;
+			} else if (brightness_enable == 1) {
+				printk(TPACPI_NOTICE
+				       "Backlight control force, even standard "
+				       "ACPI backlight interface available\n");
+			}
+		} else {
+			if (brightness_enable > 1) {
+				printk(TPACPI_NOTICE
+				       "Standard ACPI backlight interface "
+				       "available, but thinkpad_acpi driver "
+				       "will take over control\n");
+			}
+			/* We have an Integrated Graphics Device and BIOS
+			 * won't switch. By default the IGD driver should take
+			 * care about backlight and display output switching.
+			 * People can still run into this code path and let
+			 * thinkpad_acpi take over control by passing:
+			 * acpi_backlight=vendor or acpi_display_output=vendor
+			 * boot params.
+			 */
+			acpi_video_support = acpi_video_get_capabilities(NULL);
+			vdbg_printk(TPACPI_DBG_INIT, "XXXXXk\n");
+
+			if (acpi_video_support & ACPI_VIDEO_IGD) {
+				vdbg_printk(TPACPI_DBG_INIT, "IGD device"
+					    " detected - take over backlight"
+					    " switching\n");
+				tp_features.bright_igdmode = 1;
+			}
+ 		}
 	}
 
 	if (!brightness_enable) {
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index eb51726..cd012a3 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -214,6 +214,7 @@ extern bool wmi_has_guid(const char *guid);
 #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO			0x0200
 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR		0x0400
 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO		0x0800
+#define ACPI_VIDEO_IGD					0x1000
 
 #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
 
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux