Francis Rowe (info@gluglug.org.uk) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6731
-gerrit
commit 166a0dc810ab32923126cb3c0dfb4b250543fe87 Author: Vladimir Serbinenko phcoder@gmail.com Date: Fri Aug 22 01:55:50 2014 +0200
i945: Reimplement backlight control in northbridge-generic way.
This implementation is usable on all lvds lcds on i945, possibly more.
More importantly this implementation respects ACPI and so is properly detected by both Linux and Windows.
Change-Id: If02b11e91cc0f04bc5f2b24f46398b263ad59315 Signed-off-by: Vladimir Serbinenko phcoder@gmail.com --- src/mainboard/apple/macbook21/acpi/video.asl | 53 ----------- src/mainboard/apple/macbook21/devicetree.cb | 1 - src/mainboard/apple/macbook21/dsdt.asl | 6 +- src/mainboard/getac/p470/acpi/ec.asl | 2 +- src/mainboard/ibase/mb899/acpi/video.asl | 42 --------- src/mainboard/intel/d945gclf/acpi/video.asl | 42 --------- src/mainboard/kontron/986lcd-m/acpi/video.asl | 42 --------- src/mainboard/lenovo/t60/acpi/video.asl | 55 ----------- src/mainboard/lenovo/t60/dsdt.asl | 5 +- src/mainboard/lenovo/x60/acpi/video.asl | 55 ----------- src/mainboard/lenovo/x60/cmos.default | 1 - src/mainboard/lenovo/x60/cmos.layout | 2 +- src/mainboard/lenovo/x60/devicetree.cb | 1 - src/mainboard/lenovo/x60/dsdt.asl | 5 +- src/mainboard/roda/rk886ex/acpi/video.asl | 44 --------- src/northbridge/intel/i945/acpi/i945.asl | 6 -- src/northbridge/intel/i945/acpi/igd.asl | 129 +++++++++++++++++++++++++- src/northbridge/intel/i945/chip.h | 1 - src/northbridge/intel/i945/gma.c | 8 +- 19 files changed, 139 insertions(+), 361 deletions(-)
diff --git a/src/mainboard/apple/macbook21/acpi/video.asl b/src/mainboard/apple/macbook21/acpi/video.asl deleted file mode 100644 index 50a0947..0000000 --- a/src/mainboard/apple/macbook21/acpi/video.asl +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (c) 2011 Sven Schnelle svens@stackframe.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; version 2 of - * the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#include "smi.h" - -Device (DSPC) -{ - Name (_ADR, 0x00020001) - OperationRegion (DSPC, PCI_Config, 0x00, 0x100) - Field (DSPC, ByteAcc, NoLock, Preserve) - { - Offset (0xf4), - BRTC, 8 - } - - Method(BRTD, 0, NotSerialized) - { - Store(BRTC, Local0) - if (LGreater (Local0, 15)) - { - Subtract(Local0, 16, Local0) - Store(Local0, BRTC) - } - } - - Method(BRTU, 0, NotSerialized) - { - Store (BRTC, Local0) - if (LLess(Local0, 0xff)) - { - Add (Local0, 16, Local0) - Store(Local0, BRTC) - } - } -} diff --git a/src/mainboard/apple/macbook21/devicetree.cb b/src/mainboard/apple/macbook21/devicetree.cb index a3dfe3a..41acd1a 100644 --- a/src/mainboard/apple/macbook21/devicetree.cb +++ b/src/mainboard/apple/macbook21/devicetree.cb @@ -25,7 +25,6 @@ chip northbridge/intel/i945 register "gpu_hotplug" = "0x00000220" register "gpu_lvds_use_spread_spectrum_clock" = "1" register "gpu_lvds_is_dual_channel" = "0" - register "gpu_backlight" = "0x1280128"
device cpu_cluster 0 on chip cpu/intel/socket_mFCPGA478 diff --git a/src/mainboard/apple/macbook21/dsdt.asl b/src/mainboard/apple/macbook21/dsdt.asl index 5ba7b09..7b56589 100644 --- a/src/mainboard/apple/macbook21/dsdt.asl +++ b/src/mainboard/apple/macbook21/dsdt.asl @@ -19,9 +19,7 @@ * MA 02110-1301 USA */
-#define BRIGHTNESS_UP \DSPC.BRTU -#define BRIGHTNESS_DOWN \DSPC.BRTD -#define ACPI_VIDEO_DEVICE _SB.PCI0.GFX0 +#define DISPLAY_DEVICE_2_IS_LCD_SCREEN 1
DefinitionBlock( "dsdt.aml", @@ -29,7 +27,7 @@ DefinitionBlock( 0x03, // DSDT revision: ACPI v3.0 "COREv4", // OEM id "COREBOOT", // OEM table id - 0x20090419 // OEM revision + 0x20090429 // OEM revision ) { // Some generic macros diff --git a/src/mainboard/getac/p470/acpi/ec.asl b/src/mainboard/getac/p470/acpi/ec.asl index b8e2954..4de725e 100644 --- a/src/mainboard/getac/p470/acpi/ec.asl +++ b/src/mainboard/getac/p470/acpi/ec.asl @@ -187,7 +187,7 @@ Device(EC0) { Store(0x3f, HOTK) If(IGDS) { - HKDS(10) + Notify (_SB.PCI0.GFX0, 0x82) } Else { TRAP(0xE1) } diff --git a/src/mainboard/ibase/mb899/acpi/video.asl b/src/mainboard/ibase/mb899/acpi/video.asl deleted file mode 100644 index cca1a3b..0000000 --- a/src/mainboard/ibase/mb899/acpi/video.asl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2007-2009 coresystems GmbH - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// Brightness write -Method (BRTW, 1, Serialized) -{ - // TODO -} - -// Hot Key Display Switch -Method (HKDS, 1, Serialized) -{ - // TODO -} - -// Lid Switch Display Switch -Method (LSDS, 1, Serialized) -{ - // TODO -} - -// Brightness Notification -Method(BRTN,1,Serialized) -{ - // TODO (no displays defined yet) -} diff --git a/src/mainboard/intel/d945gclf/acpi/video.asl b/src/mainboard/intel/d945gclf/acpi/video.asl deleted file mode 100644 index 7baf995..0000000 --- a/src/mainboard/intel/d945gclf/acpi/video.asl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2007-2009 coresystems GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// Brightness write -Method (BRTW, 1, Serialized) -{ - // TODO -} - -// Hot Key Display Switch -Method (HKDS, 1, Serialized) -{ - // TODO -} - -// Lid Switch Display Switch -Method (LSDS, 1, Serialized) -{ - // TODO -} - -// Brightness Notification -Method(BRTN,1,Serialized) -{ - // TODO (no displays defined yet) -} diff --git a/src/mainboard/kontron/986lcd-m/acpi/video.asl b/src/mainboard/kontron/986lcd-m/acpi/video.asl deleted file mode 100644 index cca1a3b..0000000 --- a/src/mainboard/kontron/986lcd-m/acpi/video.asl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2007-2009 coresystems GmbH - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// Brightness write -Method (BRTW, 1, Serialized) -{ - // TODO -} - -// Hot Key Display Switch -Method (HKDS, 1, Serialized) -{ - // TODO -} - -// Lid Switch Display Switch -Method (LSDS, 1, Serialized) -{ - // TODO -} - -// Brightness Notification -Method(BRTN,1,Serialized) -{ - // TODO (no displays defined yet) -} diff --git a/src/mainboard/lenovo/t60/acpi/video.asl b/src/mainboard/lenovo/t60/acpi/video.asl deleted file mode 100644 index 9a458e9..0000000 --- a/src/mainboard/lenovo/t60/acpi/video.asl +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (c) 2011 Sven Schnelle svens@stackframe.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; version 2 of - * the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#include "smi.h" - -Device (DSPC) -{ - Name (_ADR, 0x00020001) - OperationRegion (DSPC, PCI_Config, 0x00, 0x100) - Field (DSPC, ByteAcc, NoLock, Preserve) - { - Offset (0xf4), - BRTC, 8 - } - - Method(BRTD, 0, NotSerialized) - { - Trap(SMI_BRIGHTNESS_DOWN) - Store(BRTC, Local0) - if (LGreater (Local0, 15)) - { - Subtract(Local0, 16, Local0) - Store(Local0, BRTC) - } - } - - Method(BRTU, 0, NotSerialized) - { - Trap(SMI_BRIGHTNESS_UP) - Store (BRTC, Local0) - if (LLess(Local0, 0xff)) - { - Add (Local0, 16, Local0) - Store(Local0, BRTC) - } - } -} diff --git a/src/mainboard/lenovo/t60/dsdt.asl b/src/mainboard/lenovo/t60/dsdt.asl index 4122917..8611f45 100644 --- a/src/mainboard/lenovo/t60/dsdt.asl +++ b/src/mainboard/lenovo/t60/dsdt.asl @@ -20,9 +20,10 @@ */
#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 +#define DISPLAY_DEVICE_2_IS_LCD_SCREEN 1
DefinitionBlock( "dsdt.aml", diff --git a/src/mainboard/lenovo/x60/acpi/video.asl b/src/mainboard/lenovo/x60/acpi/video.asl deleted file mode 100644 index b38d82b..0000000 --- a/src/mainboard/lenovo/x60/acpi/video.asl +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (c) 2011 Sven Schnelle svens@stackframe.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; version 2 of - * the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#include "smi.h" - -Device (DSPC) -{ - Name (_ADR, 0x00020001) - OperationRegion (DSPC, PCI_Config, 0x00, 0x100) - Field (DSPC, ByteAcc, NoLock, Preserve) - { - Offset (0xf4), - BRTC, 8 - } - - Method(BRTD, 0, NotSerialized) - { - Store(BRTC, Local0) - if (LGreater (Local0, 15)) - { - Subtract(Local0, 16, Local0) - Store(Local0, BRTC) - Trap(SMI_SAVE_CMOS) - } - } - - Method(BRTU, 0, NotSerialized) - { - Store (BRTC, Local0) - if (LLess(Local0, 0xff)) - { - Add (Local0, 16, Local0) - Store(Local0, BRTC) - Trap(SMI_SAVE_CMOS) - } - } -} diff --git a/src/mainboard/lenovo/x60/cmos.default b/src/mainboard/lenovo/x60/cmos.default index 0185e94..e0b992c 100644 --- a/src/mainboard/lenovo/x60/cmos.default +++ b/src/mainboard/lenovo/x60/cmos.default @@ -9,7 +9,6 @@ boot_default=0x40 cmos_defaults_loaded=Yes lpt=Enable volume=0x3 -tft_brightness=0xff first_battery=Primary bluetooth=Enable wlan=Enable diff --git a/src/mainboard/lenovo/x60/cmos.layout b/src/mainboard/lenovo/x60/cmos.layout index a74d793..80301fb 100644 --- a/src/mainboard/lenovo/x60/cmos.layout +++ b/src/mainboard/lenovo/x60/cmos.layout @@ -108,7 +108,7 @@ entries 1052 4 r 0 C1DRT1
1064 8 h 0 volume -1072 8 h 0 tft_brightness +#1072 8 r 0 unused 1080 1 e 9 first_battery 1081 1 e 1 bluetooth 1082 1 e 1 wwan diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb index fcf7c29..518daf8 100644 --- a/src/mainboard/lenovo/x60/devicetree.cb +++ b/src/mainboard/lenovo/x60/devicetree.cb @@ -25,7 +25,6 @@ chip northbridge/intel/i945 register "gpu_hotplug" = "0x00000220" register "gpu_lvds_use_spread_spectrum_clock" = "1" register "gpu_lvds_is_dual_channel" = "0" - register "gpu_backlight" = "0x1280128"
device cpu_cluster 0 on chip cpu/intel/socket_mFCPGA478 diff --git a/src/mainboard/lenovo/x60/dsdt.asl b/src/mainboard/lenovo/x60/dsdt.asl index 4122917..8611f45 100644 --- a/src/mainboard/lenovo/x60/dsdt.asl +++ b/src/mainboard/lenovo/x60/dsdt.asl @@ -20,9 +20,10 @@ */
#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 +#define DISPLAY_DEVICE_2_IS_LCD_SCREEN 1
DefinitionBlock( "dsdt.aml", diff --git a/src/mainboard/roda/rk886ex/acpi/video.asl b/src/mainboard/roda/rk886ex/acpi/video.asl deleted file mode 100644 index 3536913..0000000 --- a/src/mainboard/roda/rk886ex/acpi/video.asl +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2007-2009 coresystems GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; version 2 of - * the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -// Brightness write -Method (BRTW, 1, Serialized) -{ - // TODO -} - -// Hot Key Display Switch -Method (HKDS, 1, Serialized) -{ - // TODO -} - -// Lid Switch Display Switch -Method (LSDS, 1, Serialized) -{ - // TODO -} - -// Brightness Notification -Method(BRTN,1,Serialized) -{ - // TODO (no displays defined yet) -} diff --git a/src/northbridge/intel/i945/acpi/i945.asl b/src/northbridge/intel/i945/acpi/i945.asl index 6a34b94..4eac006 100644 --- a/src/northbridge/intel/i945/acpi/i945.asl +++ b/src/northbridge/intel/i945/acpi/i945.asl @@ -100,9 +100,3 @@ Device (PDRC)
// Integrated graphics 0:2.0 #include "igd.asl" - -Scope () -{ - // backlight control, display switching, lid - #include "acpi/video.asl" -} diff --git a/src/northbridge/intel/i945/acpi/igd.asl b/src/northbridge/intel/i945/acpi/igd.asl index 9399554..47b66a7 100644 --- a/src/northbridge/intel/i945/acpi/igd.asl +++ b/src/northbridge/intel/i945/acpi/igd.asl @@ -23,6 +23,22 @@ Device (GFX0) { Name (_ADR, 0x00020000)
+ OperationRegion (GFXC, PCI_Config, 0x00, 0x0100) + Field (GFXC, DWordAcc, NoLock, Preserve) + { + Offset (0x10), + BAR0, 32 + } + + OperationRegion (GFRG, SystemMemory, And (BAR0, 0xfffffff0), 0x400000) + Field (GFRG, DWordAcc, NoLock, Preserve) + { + Offset (0x61250), + CR1, 32, + BCLV, 16, + BCLM, 16, + } + /* Display Output Switching */ Method (_DOS, 1) { @@ -145,6 +161,116 @@ Device (GFX0) } }
+#ifdef DISPLAY_DEVICE_2_IS_LCD_SCREEN + Device (LCD0) + { + /* Device Unique ID */ + Method(_ADR, 0, Serialized) + { + If(LEqual(DID2, 0)) { + Return (2) + } Else { + Return (And(0xffff, DID2)) + } + } + + Method(_DCS, 0) + { + Return (0x1f) + } + + Method(_DGS, 0) + { + Return(1) + } + + Name (BRCT, 0) + + Name (BRIG, Package (0x12) + { + 0x61, + 0x61, + 0xf, + 0x13, + 0x19, + 0x1f, + 0x23, + 0x29, + 0x2f, + 0x35, + 0x39, + 0x3f, + 0x45, + 0x4b, + 0x4f, + 0x55, + 0x5b, + 0x61 + }) + + Method (_BCL, 0, NotSerialized) + { + Store (1, BRCT) + Return (BRIG) + } + + Method (_BCM, 1, NotSerialized) + { + Store (ShiftLeft (Arg0, 4), ^^BCLV) + Store (0x80000000, ^^CR1) + Store (ShiftLeft (0x61, 4), ^^BCLM) + } + Method (_BQC, 0, NotSerialized) + { + Store (^^BCLV, Local0) + ShiftRight (Local0, 4, Local0) + Return (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))) + } + } + } +#else + Device(DD02) { /* Device Unique ID */ @@ -187,7 +313,7 @@ Device (GFX0) } } } - +#endif
Device(DD03) { @@ -319,5 +445,4 @@ Device (GFX0) } } } - } diff --git a/src/northbridge/intel/i945/chip.h b/src/northbridge/intel/i945/chip.h index 9e25ecc..b0b45ca 100644 --- a/src/northbridge/intel/i945/chip.h +++ b/src/northbridge/intel/i945/chip.h @@ -1,6 +1,5 @@ struct northbridge_intel_i945_config { u32 gpu_hotplug; - u32 gpu_backlight; int gpu_lvds_use_spread_spectrum_clock; int gpu_lvds_is_dual_channel; }; diff --git a/src/northbridge/intel/i945/gma.c b/src/northbridge/intel/i945/gma.c index 9b0dbd2..909f40d 100644 --- a/src/northbridge/intel/i945/gma.c +++ b/src/northbridge/intel/i945/gma.c @@ -308,7 +308,7 @@ static int intel_gma_init(struct northbridge_intel_i945_config *conf, write32(pmmio + FW_BLC, 0x011d0109); write32(pmmio + FW_BLC2, 0x00000102); write32(pmmio + FW_BLC_SELF, FW_BLC_SELF_EN_MASK); - write32(pmmio + BLC_PWM_CTL, conf->gpu_backlight); + write32(pmmio + BLC_PWM_CTL, 0x6100610);
edid.bytes_per_line = (edid.bytes_per_line + 63) & ~63; write32(pmmio + DSPADDR(0), 0); @@ -471,17 +471,13 @@ static void gma_func0_disable(struct device *dev) static void gma_func1_init(struct device *dev) { u32 reg32; - u8 val;
/* IGD needs to be Bus Master, also enable IO accesss */ reg32 = pci_read_config32(dev, PCI_COMMAND); pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
- if (get_option(&val, "tft_brightness") == CB_SUCCESS) - pci_write_config8(dev, 0xf4, val); - else - pci_write_config8(dev, 0xf4, 0xff); + pci_write_config8(dev, 0xf4, 0xff); }
static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device)