[coreboot-gerrit] Change in coreboot[master]: [WIP]ec/lenovo/h8: Add nvram option to set mute button behavior

Arthur Heymans (Code Review) gerrit at coreboot.org
Thu Aug 10 18:21:23 CEST 2017


Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/20944


Change subject: [WIP]ec/lenovo/h8: Add nvram option to set mute button behavior
......................................................................

[WIP]ec/lenovo/h8: Add nvram option to set mute button behavior

The mute button can behave in several ways: as a hardware mute of
which the OS is not aware or as a regular key that generates
scancodes.

Do we want all modes configurable in nvram? mode1 is a bit weird and
when supported I think mode3 is better than mode0.

TODO: hook up this parameter nvram of all thinkpads...

Change-Id: Ic7979d5868e0df0c02d96e238ee879c1f1fec359
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
M src/ec/lenovo/h8/h8.c
M src/mainboard/lenovo/x200/cmos.layout
2 files changed, 36 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/20944/1

diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c
index 5ea4a2c..f734155 100644
--- a/src/ec/lenovo/h8/h8.c
+++ b/src/ec/lenovo/h8/h8.c
@@ -128,6 +128,35 @@
 		ec_clr_bit(0x3a, 0);
 }
 
+
+enum mute_key_mode {
+	/*
+	 * Mute button asserts EC (HW) mute, volume buttons unmute
+	 * This means the mute button can mute without the OS or
+	 * the firmware knowing.
+	 */
+	MUTE_KEY_MODE_EC_ASSERT = 0,
+	/*
+	 *If the EC is in mute (e.g. bit0 0x3a) then all volume keys works
+	 * as scancodes for mute, pressing volume buttons for a long time
+	 * changes the volume. In non EC mute mode all buttons simply generate
+	 * scancode.
+	 */
+	MUTE_KEY_MODE_SCAN_ALL_MUTE = 1,
+	/* All volume buttons generate scancodes. */
+	MUTE_KEY_MODE_SCAN_ONLY = 2,
+	/* Only on later thinkpads. The mute button toggles EC mute. */
+	MUTE_KEY_MODE_TOGGLE = 3,
+};
+
+static void h8_set_mute_key_mode(enum mute_key_mode mode)
+{
+	if (mode & 1)
+		ec_set_bit(0x03, 5);
+	if (mode & 2)
+		ec_set_bit(0x03, 6);
+}
+
 void h8_enable_event(int event)
 {
 	if (event < 0 || event > 127)
@@ -318,6 +347,10 @@
 
 	h8_set_audio_mute(0);
 
+	if (get_option(&val, "mute_key_mode") != CB_SUCCESS)
+		val = 0;
+	h8_set_mute_key_mode(val);
+
 #if !IS_ENABLED(CONFIG_H8_DOCK_EARLY_INIT)
 	h8_mainboard_init_dock();
 #endif
diff --git a/src/mainboard/lenovo/x200/cmos.layout b/src/mainboard/lenovo/x200/cmos.layout
index f3cfe70..65056df 100644
--- a/src/mainboard/lenovo/x200/cmos.layout
+++ b/src/mainboard/lenovo/x200/cmos.layout
@@ -71,6 +71,7 @@
 426         1       e       1        power_management_beeps
 427         1       e       1        low_battery_beep
 428         1       e       1        uwb
+429         2       e       12       mute_key_mode
 
 # coreboot config options: bootloader
 432         512       s       0        boot_devices
@@ -132,6 +133,8 @@
 11    10    160M
 11    11    224M
 11    12    352M
+12    0     Hardware
+12    2     Scancode
 
 # -----------------------------------------------------------------
 checksums

-- 
To view, visit https://review.coreboot.org/20944
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7979d5868e0df0c02d96e238ee879c1f1fec359
Gerrit-Change-Number: 20944
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170810/d290158f/attachment-0001.html>


More information about the coreboot-gerrit mailing list