[ltp] Re: [ibm-acpi-devel] thinkpad-acpi release 0.17-20071002 uploaded to ibm-acpi.sf.net

Henrique de Moraes Holschuh linux-thinkpad@linux-thinkpad.org
Wed, 3 Oct 2007 10:05:52 -0300


--LpQ9ahxlCli8rRTG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Better use this one instead...

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

--LpQ9ahxlCli8rRTG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch

commit 1b81ea7ba1dc07398e951cfdeacaf6cc6ad716eb
Author: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Date:   Wed Oct 3 10:03:32 2007 -0300

    ACPI: thinkpad-acpi: fix issues in brightness 16-levels support (v2)
    
    Fix some issues with the new 16-level brightness support.
    
    Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index b0ef877..a4884aa 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3584,25 +3584,24 @@ static int __init brightness_check_levels(void)
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *obj;
 
-	status = acpi_evaluate_object(vid_handle, "BCLL", NULL, &buffer);
+	if (!vid_handle) {
+		IBM_ACPIHANDLE_INIT(vid);
+	}
+
+	if (!vid_handle)
+		return 0;
+
+	/* Using BCLL would be better, but that is not a method, just
+	 * a package.  The safest way would be to get BCLL data, and
+	 * check the highest value in it, as it will be the max_level
+	 * of the EC brightness control */
+	status = acpi_evaluate_object(vid_handle, "_BCL", NULL, &buffer);
 	if (!ACPI_SUCCESS(status))
 		return 0;
 
-	status = 0;
 	obj = (union acpi_object *)buffer.pointer;
-
-	if (obj && obj->type == ACPI_TYPE_PACKAGE &&
-	    obj->package.count == 16) {
-		/*
-		 * We could actually parse them all, and get the minimum and
-		 * maximum levels used by the ACPI firmware if we wanted,
-		 * instead of this ugly hack of 16 levels or nothing...
-		 */
-		status = 1;
-	} else {
-		printk(IBM_ERR "unexpected return from BCLL\n");
-		printk(IBM_ERR "please report this to %s\n", IBM_MAIL);
-	}
+	status = (obj && obj->type == ACPI_TYPE_PACKAGE &&
+		  obj->package.count == 18);
 
 	kfree(buffer.pointer);
 	return status;
@@ -3693,6 +3692,7 @@ static int brightness_get(struct backlight_device *bd)
 		lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
 			 & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
 			>> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
+		lcmos &= (tp_features.bright_16levels)? 0x0f : 0x07;
 		level = lcmos;
 	}
 

--LpQ9ahxlCli8rRTG--