[coreboot-gerrit] New patch to review for coreboot: 7c56b84 lenovo/x60: Implement ACPI video brightness control.

Michał Masłowski (mtjm@mtjm.eu) gerrit at coreboot.org
Wed Aug 20 22:07:13 CEST 2014


Michał Masłowski (mtjm at mtjm.eu) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6720

-gerrit

commit 7c56b845f8ab432b9cd4826a1fb77cc30a2dfa8b
Author: Michał Masłowski <mtjm at mtjm.eu>
Date:   Wed Aug 20 21:51:18 2014 +0200

    lenovo/x60: Implement ACPI video brightness control.
    
    DECB, INCB are copied from lenovo/x201.  Brightness levels are based
    on values used by the existing X60 code.
    
    Change-Id: I82bb9ba966a18a8295bf8771b6fed68d6ccdc81c
    Signed-off-by: Michał Masłowski <mtjm at mtjm.eu>
---
 src/mainboard/lenovo/x60/acpi/video.asl | 131 +++++++++++++++++++++++++++-----
 src/mainboard/lenovo/x60/dsdt.asl       |   4 +-
 2 files changed, 112 insertions(+), 23 deletions(-)

diff --git a/src/mainboard/lenovo/x60/acpi/video.asl b/src/mainboard/lenovo/x60/acpi/video.asl
index b38d82b..089680d 100644
--- a/src/mainboard/lenovo/x60/acpi/video.asl
+++ b/src/mainboard/lenovo/x60/acpi/video.asl
@@ -2,6 +2,7 @@
  * This file is part of the coreboot project.
  *
  * Copyright (c) 2011 Sven Schnelle <svens at stackframe.org>
+ * Copyright (c) 2013 Vladimir Serbinenko
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -21,35 +22,123 @@
 
 #include "smi.h"
 
-Device (DSPC)
+Scope (\_SB.PCI0.GFX0)
 {
-	Name (_ADR, 0x00020001)
-	OperationRegion (DSPC, PCI_Config, 0x00, 0x100)
-	Field (DSPC, ByteAcc, NoLock, Preserve)
+	Device (LCD0)
 	{
-		Offset (0xf4),
-		       BRTC, 8
-	}
+		Name (_ADR, 0x00020001)
+		Name (BRCT, 0)
 
-	Method(BRTD, 0, NotSerialized)
-	{
-		Store(BRTC, Local0)
-		if (LGreater (Local0, 15))
+		OperationRegion (DSPC, PCI_Config, 0x00, 0x100)
+		Field (DSPC, ByteAcc, NoLock, Preserve)
 		{
-			Subtract(Local0, 16, Local0)
-			Store(Local0, BRTC)
-			Trap(SMI_SAVE_CMOS)
+			Offset (0xf4),
+				BRTC, 8
 		}
-	}
 
-	Method(BRTU, 0, NotSerialized)
-	{
-		Store (BRTC, Local0)
-		if (LLess(Local0, 0xff))
+		// 0-100 values as used by ACPI.
+		Name (BRIG, Package (0x12)
+		{
+			100,
+			31,
+			6,
+			12,
+			18,
+			25,
+			31,
+			37,
+			44,
+			50,
+			56,
+			62,
+			69,
+			75,
+			81,
+			87,
+			94,
+			100,
+		})
+		// 0-255 values as used by legacy backlight brightness.
+		Name (BRIR, Package (0x12)
+		{
+			0xff,
+			0x4f,
+			0x0f,
+			0x1f,
+			0x2f,
+			0x3f,
+			0x4f,
+			0x5f,
+			0x6f,
+			0x7f,
+			0x8f,
+			0x9f,
+			0xaf,
+			0xbf,
+			0xcf,
+			0xdf,
+			0xef,
+			0xff,
+		})
+
+		Method (_BCL, 0, NotSerialized)
+		{
+			Store (1, BRCT)
+			Return (BRIG)
+		}
+
+		Method (_BCM, 1, NotSerialized)
 		{
-			Add (Local0, 16, Local0)
-			Store(Local0, BRTC)
+			Store (BRID (Arg0), Local0)
+			Store (DeRefOf(Index (BRIR, Local0)), BRTC)
 			Trap(SMI_SAVE_CMOS)
 		}
+		Method (_BQC, 0, NotSerialized)
+		{
+			Store (Match (BRIR, MEQ, BRTC, MTR, Zero, 2), Local0)
+			Return (DeRefOf(Index (BRIG, Local0)))
+		}
+
+		Method(BRID, 1, NotSerialized)
+		{
+			Store (Match (BRIG, MEQ, Arg0, MTR, Zero, 2), Local0)
+			If (LEqual (Local0, Ones))
+			{
+				Return (0x11)
+			}
+			Return (Local0)
+		}
+
+		/* Using Notify is the right way. But Windows doesn't handle
+		   it well. So use both method in a way to avoid double action.
+		 */
+		Method (DECB, 0, NotSerialized)
+		{
+			If (BRCT)
+			{
+				Notify (LCD0, 0x87)
+			} Else {
+				Store (BRID (_BQC ()), Local0)
+				If (LNotEqual (Local0, 2))
+				{
+					Decrement (Local0)
+				}
+				_BCM (DerefOf (Index (BRIG, Local0)))
+			}
+		}
+		Method (INCB, 0, NotSerialized)
+		{
+			If (BRCT)
+			{
+				Notify (LCD0, 0x86)
+			} Else {
+				Store (BRID (_BQC ()), Local0)
+				If (LNotEqual (Local0, 0x11))
+				{
+					Increment (Local0)
+				}
+				_BCM (DerefOf (Index (BRIG, Local0)))
+			}
+		}
 	}
 }
diff --git a/src/mainboard/lenovo/x60/dsdt.asl b/src/mainboard/lenovo/x60/dsdt.asl
index 4122917..7971d6a 100644
--- a/src/mainboard/lenovo/x60/dsdt.asl
+++ b/src/mainboard/lenovo/x60/dsdt.asl
@@ -20,8 +20,8 @@
  */
 
 #define THINKPAD_EC_GPE 28
-#define BRIGHTNESS_UP \DSPC.BRTU
-#define BRIGHTNESS_DOWN \DSPC.BRTD
+#define BRIGHTNESS_UP \_SB.PCI0.GFX0.LCD0.INCB
+#define BRIGHTNESS_DOWN \_SB.PCI0.GFX0.LCD0.DECB
 #define ACPI_VIDEO_DEVICE \_SB.PCI0.GFX0
 
 DefinitionBlock(



More information about the coreboot-gerrit mailing list