support Thinkpad X1 Carbon's adaptive keyboard
Subsystems (2)
PATCH v2 1/1 support Thinkpad X1 Carbon's adaptive keyboard
Hi,
Support Thinkpad X1 Carbon's Adaptive keyboard patch version 2 is here.
Modified V1 patch's code according to Bjorn's comment.
Thanks,
Shuduo
From fd2ab11002f3e5cb7fb9b26452db170e9835cde1 Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboard
Thinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
(quoted diff) +0 -0
b/drivers/platform/x86/thinkpad_acpi.c
index defb6af..fe2db4d 100644
drivers/platform/x86/thinkpad_acpi.c +102 -0
114 lines not on this page · raw message
Signature · 1 line
1.9.0
On 2014-03-03 at 17:31:08 +0100, Shuduo Sang <[email protected]> wrote:
[...]
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3469
Quoted 5 lines
drivers/platform/x86/thinkpad_acpi.c +5
-0+/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +bool adaptive_keyboard_mode_is_saved; +int adaptive_keybarod_prev_mode;
These should probably be made static, since they're only used inside the module.
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3474
Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +4
-0+static int adaptive_keyboard_get_next_mode (int mode) +{ +int i; +int max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ;
sizeof and thus ARRAY_SIZE returns a size_t, so i and max_mode could be of type size_t as well.
Quoted 86 lines
drivers/platform/x86/thinkpad_acpi.c +67
-0+ +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + } + +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey (unsigned int scancode) +{ +u32 current_mode =0 ; +int new_mode =0 ; + +switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keybarod_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + new_mode =adaptive_keyboard_get_next_mode ( + current_mode); + } + } + +if (!acpi_evalf (hkey_handle,NULL ,"STRW" ,"vd" , new_mode)) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true; + +case DFR_SHOW_QUICKVIEW_ROW : +if (!acpi_evalf (hkey_handle, + &adaptive_keybarod_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + adaptive_keyboard_mode_is_saved = true; + +if (!acpi_evalf (hkey_handle, +NULL ,"STRW" ,"vd" ,FUNCTION_MODE )) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true; + }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; }Signature · 7 lines
1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Hi Tobias,
Thanks for your comments.
Shuduo
Quoted 11 lines · Tobias Klauser
On 2014-03-03 at 17:31:08 +0100, Shuduo Sang <[email protected]> wrote:
[...]drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3469
Quoted 5 lines
drivers/platform/x86/thinkpad_acpi.c +5
-0+/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +bool adaptive_keyboard_mode_is_saved; +int adaptive_keybarod_prev_mode;These should probably be made static, since they're only used inside the module.
Yes. Let me fix it in V3.
Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3474
Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +4
-0+static int adaptive_keyboard_get_next_mode (int mode) +{ +int i; +int max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ;sizeof and thus
ARRAY_SIZEreturns asize_t, so i andmax_modecould be of typesize_tas well.
Agree. Will fix in V3.
Quoted 86 lines
Quoted 86 lines
drivers/platform/x86/thinkpad_acpi.c +67
-0+ +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + } + +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey (unsigned int scancode) +{ +u32 current_mode =0 ; +int new_mode =0 ; + +switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keybarod_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + new_mode =adaptive_keyboard_get_next_mode ( + current_mode); + } + } + +if (!acpi_evalf (hkey_handle,NULL ,"STRW" ,"vd" , new_mode)) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true; + +case DFR_SHOW_QUICKVIEW_ROW : +if (!acpi_evalf (hkey_handle, + &adaptive_keybarod_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + adaptive_keyboard_mode_is_saved = true; + +if (!acpi_evalf (hkey_handle, +NULL ,"STRW" ,"vd" ,FUNCTION_MODE )) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true; + }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; }Signature · 7 lines
1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
PATCH v3 1/1 support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
In reply to Tobias KlauserSubmit patch V3 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
Thanks,
Shuduo
From 2b8175e69deee661d97d371b2422a9c192fefd52 Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboard
Thinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
(quoted diff) +0 -0
b/drivers/platform/x86/thinkpad_acpi.c
index defb6af..6664dcd 100644
drivers/platform/x86/thinkpad_acpi.c +102 -0
114 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [PATCH V3] support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
Quoted 3 lines · Shuduo Sang
Submit patch V3 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
It seems like I missed one in the previous comment, sorry. Also one of the previous comments was only partially addressed in this updated patch. See below for the comments...
Quoted 39 lines
Thanks,
ShuduoFrom
2b8175e69deee661d97d371b2422a9c192fefd52Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboardThinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
Signed-off-by Bruce Ma <[email protected]>Signed-off-by Shuduo Sang <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)drivers/platform/x86/thinkpad_acpi.c +11
-0@@ -3437,6 +3437,106 @@ err_exit:return (res <0 )? res :1 ; } +/* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser +* mode, Web conference mode, Function mode and Lay-flat mode. +* We support Home mode and Function mode currently. +* +* Will consider support rest of modes in future. +* +*/ +enum ADAPTIVE_KEY_MODE { +HOME_MODE , +WEB_BROWSER_MODE , +WEB_CONFERENCE_MODE ,
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3460
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+FUNCTION_MODE , + LAYFLAT_MODE +}; + +int adaptive_keyboard_modes[] = { +HOME_MODE , +/* WEB_BROWSER_MODE = 2, +WEB_CONFERENCE_MODE = 3, */ +FUNCTION_MODE +};
This array can be made be static const.
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3473
Quoted 13 lines
drivers/platform/x86/thinkpad_acpi.c +13
-0+ +#define DFR_CHANGE_ROW 0x101 +#define DFR_SHOW_QUICKVIEW_ROW 0x102 + +/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +static bool adaptive_keyboard_mode_is_saved; +static int adaptive_keyboard_prev_mode; + +static int adaptive_keyboard_get_next_mode (int mode) +{ +int i;
This should be size_t as well, as mentioned in the previous comment.
Quoted 81 lines
drivers/platform/x86/thinkpad_acpi.c +68
-0+size_t max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ; + +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + } + +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey (unsigned int scancode) +{ +u32 current_mode =0 ; +int new_mode =0 ; + +switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keyboard_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + new_mode =adaptive_keyboard_get_next_mode ( + current_mode); + } + } + +if (!acpi_evalf (hkey_handle,NULL ,"STRW" ,"vd" , new_mode)) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true; + +case DFR_SHOW_QUICKVIEW_ROW : +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + adaptive_keyboard_mode_is_saved = true; + +if (!acpi_evalf (hkey_handle, +NULL ,"STRW" ,"vd" ,FUNCTION_MODE )) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true; + }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; }Signature · 1 line
1.9.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH V3] support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
OK. I will modify them in V4. :)
Quoted 156 lines · Tobias Klauser
Quoted 3 lines · Shuduo Sang
Submit patch V3 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
It seems like I missed one in the previous comment, sorry. Also one of the previous comments was only partially addressed in this updated patch. See below for the comments...
Quoted 39 lines
Thanks,
ShuduoFrom
2b8175e69deee661d97d371b2422a9c192fefd52Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboardThinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
Signed-off-by Bruce Ma <[email protected]>Signed-off-by Shuduo Sang <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)drivers/platform/x86/thinkpad_acpi.c +11
-0@@ -3437,6 +3437,106 @@ err_exit:return (res <0 )? res :1 ; } +/* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser +* mode, Web conference mode, Function mode and Lay-flat mode. +* We support Home mode and Function mode currently. +* +* Will consider support rest of modes in future. +* +*/ +enum ADAPTIVE_KEY_MODE { +HOME_MODE , +WEB_BROWSER_MODE , +WEB_CONFERENCE_MODE ,drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3460
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+FUNCTION_MODE , + LAYFLAT_MODE +}; + +int adaptive_keyboard_modes[] = { +HOME_MODE , +/* WEB_BROWSER_MODE = 2, +WEB_CONFERENCE_MODE = 3, */ +FUNCTION_MODE +};This array can be made be static const.
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3473
Quoted 13 lines
drivers/platform/x86/thinkpad_acpi.c +13
-0+ +#define DFR_CHANGE_ROW 0x101 +#define DFR_SHOW_QUICKVIEW_ROW 0x102 + +/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +static bool adaptive_keyboard_mode_is_saved; +static int adaptive_keyboard_prev_mode; + +static int adaptive_keyboard_get_next_mode (int mode) +{ +int i;This should be
size_tas well, as mentioned in the previous comment.Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +6
-0+size_t max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ; + +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + }drivers/platform/x86/thinkpad_acpi.c err_exit:
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+ +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned intscancode)
Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +4
-0+{ +u32 current_mode =0 ; +int new_mode =0 ; +drivers/platform/x86/thinkpad_acpi.c err_exit:
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keyboard_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { + pr_err("Cannot read adaptive keyboardmode\n");
drivers/platform/x86/thinkpad_acpi.c err_exit:
Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c +8
-0+return false; + } else { + new_mode =adaptive_keyboard_get_next_mode ( + current_mode); + } + } + + if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd",
new_mode)) {Quoted 7 lines
drivers/platform/x86/thinkpad_acpi.c +7
-0+pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true; + +case DFR_SHOW_QUICKVIEW_ROW :drivers/platform/x86/thinkpad_acpi.c err_exit:
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + } else { + adaptive_keyboard_mode_is_saved = true; + + if (!acpi_evalf(hkey_handle, + NULL, "STRW", "vd",
FUNCTION_MODE)) {drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3529
Quoted 1 line
drivers/platform/x86/thinkpad_acpi.c +1
-0+ pr_err("Cannot set adaptive keyboardmode\n");
Quoted 17 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true;
Quoted 9 lines
Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c +2
-1+ }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; } --1.9.0
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
ibm-acpi-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel
Re: [PATCH V3] support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
In reply to Shuduo SangHello,
This is just a trivial comment.
Quoted 100 lines · Shuduo Sang
Submit patch V3 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
Thanks,
ShuduoFrom
2b8175e69deee661d97d371b2422a9c192fefd52Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboardThinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
Signed-off-by Bruce Ma <[email protected]>Signed-off-by Shuduo Sang <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)drivers/platform/x86/thinkpad_acpi.c +67
-0@@ -3437,6 +3437,106 @@ err_exit:return (res <0 )? res :1 ; } +/* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser +* mode, Web conference mode, Function mode and Lay-flat mode. +* We support Home mode and Function mode currently. +* +* Will consider support rest of modes in future. +* +*/ +enum ADAPTIVE_KEY_MODE { +HOME_MODE , +WEB_BROWSER_MODE , +WEB_CONFERENCE_MODE , +FUNCTION_MODE , +LAYFLAT_MODE +}; + +int adaptive_keyboard_modes[] = { +HOME_MODE , +/* WEB_BROWSER_MODE = 2, +WEB_CONFERENCE_MODE = 3, */ +FUNCTION_MODE +}; + +#define DFR_CHANGE_ROW 0x101 +#define DFR_SHOW_QUICKVIEW_ROW 0x102 + +/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +static bool adaptive_keyboard_mode_is_saved; +static int adaptive_keyboard_prev_mode; + +static int adaptive_keyboard_get_next_mode (int mode) +{ +int i; +size_t max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ; + +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + } + +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey (unsigned int scancode) +{ +u32 current_mode =0 ; +int new_mode =0 ; + +switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keyboard_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + new_mode = adaptive_keyboard_get_next_mode(
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3516
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10
-0+ current_mode); + } + } + +if (!acpi_evalf (hkey_handle,NULL ,"STRW" ,"vd" , new_mode)) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true;
Isn't the blank line above return statement unnecessary?
Quoted 43 lines
drivers/platform/x86/thinkpad_acpi.c +25
-1+ +case DFR_SHOW_QUICKVIEW_ROW : +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + adaptive_keyboard_mode_is_saved = true; + +if (!acpi_evalf (hkey_handle, +NULL ,"STRW" ,"vd" ,FUNCTION_MODE )) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true; + }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; } --1.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V3] support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
Quoted 109 lines · SeongJae Park
Hello,
This is just a trivial comment.Quoted 104 lines · Shuduo Sang
Submit patch V3 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
Thanks,
ShuduoFrom
2b8175e69deee661d97d371b2422a9c192fefd52Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboardThinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
Signed-off-by Bruce Ma <[email protected]>Signed-off-by Shuduo Sang <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)drivers/platform/x86/thinkpad_acpi.c +71
-0@@ -3437,6 +3437,106 @@ err_exit:return (res <0 )? res :1 ; } +/* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser +* mode, Web conference mode, Function mode and Lay-flat mode. +* We support Home mode and Function mode currently. +* +* Will consider support rest of modes in future. +* +*/ +enum ADAPTIVE_KEY_MODE { +HOME_MODE , +WEB_BROWSER_MODE , +WEB_CONFERENCE_MODE , +FUNCTION_MODE , +LAYFLAT_MODE +}; + +int adaptive_keyboard_modes[] = { +HOME_MODE , +/* WEB_BROWSER_MODE = 2, +WEB_CONFERENCE_MODE = 3, */ +FUNCTION_MODE +}; + +#define DFR_CHANGE_ROW 0x101 +#define DFR_SHOW_QUICKVIEW_ROW 0x102 + +/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +static bool adaptive_keyboard_mode_is_saved; +static int adaptive_keyboard_prev_mode; + +static int adaptive_keyboard_get_next_mode (int mode) +{ +int i; +size_t max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ; + +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + } + +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey (unsigned int scancode) +{ +u32 current_mode =0 ; +int new_mode =0 ; + +switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keyboard_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + new_mode =adaptive_keyboard_get_next_mode ( + current_mode); + } + } +
Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3516
Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +6
-0+if (!acpi_evalf (hkey_handle,NULL ,"STRW" ,"vd" , new_mode)) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true;Isn't the blank line above return statement unnecessary?
Doesn't it look clearly? :)
Quoted 43 lines
Quoted 43 lines
drivers/platform/x86/thinkpad_acpi.c +25
-1+ +case DFR_SHOW_QUICKVIEW_ROW : +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + adaptive_keyboard_mode_is_saved = true; + +if (!acpi_evalf (hkey_handle, +NULL ,"STRW" ,"vd" ,FUNCTION_MODE )) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true; + }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; } --1.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V3] support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
Quoted 122 lines · Shuduo Sang
Quoted 109 lines · SeongJae Park
Hello,
This is just a trivial comment.Quoted 104 lines · Shuduo Sang
Submit patch V3 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
Thanks,
ShuduoFrom
2b8175e69deee661d97d371b2422a9c192fefd52Mon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboardThinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
Signed-off-by Bruce Ma <[email protected]>Signed-off-by Shuduo Sang <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)drivers/platform/x86/thinkpad_acpi.c +71
-0@@ -3437,6 +3437,106 @@ err_exit:return (res <0 )? res :1 ; } +/* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser +* mode, Web conference mode, Function mode and Lay-flat mode. +* We support Home mode and Function mode currently. +* +* Will consider support rest of modes in future. +* +*/ +enum ADAPTIVE_KEY_MODE { +HOME_MODE , +WEB_BROWSER_MODE , +WEB_CONFERENCE_MODE , +FUNCTION_MODE , +LAYFLAT_MODE +}; + +int adaptive_keyboard_modes[] = { +HOME_MODE , +/* WEB_BROWSER_MODE = 2, +WEB_CONFERENCE_MODE = 3, */ +FUNCTION_MODE +}; + +#define DFR_CHANGE_ROW 0x101 +#define DFR_SHOW_QUICKVIEW_ROW 0x102 + +/* press Fn key a while second, it will switch to Function Mode. Then +* release Fn key, previous mode be restored. +*/ +static bool adaptive_keyboard_mode_is_saved; +static int adaptive_keyboard_prev_mode; + +static int adaptive_keyboard_get_next_mode (int mode) +{ +int i; +size_t max_mode =ARRAY_SIZE (adaptive_keyboard_modes) -1 ; + +for (i =0 ; i <= max_mode; i++) { +if (adaptive_keyboard_modes[i] == mode) +break ; + } + +if (i >= max_mode) + i =0 ; +else + i++; + +return adaptive_keyboard_modes[i]; +} + +static bool adaptive_keyboard_hotkey_notify_hotkey (unsigned int scancode) +{ +u32 current_mode =0 ; +int new_mode =0 ; + +switch (scancode) { +case DFR_CHANGE_ROW : +if (adaptive_keyboard_mode_is_saved) { + new_mode = adaptive_keyboard_prev_mode; + adaptive_keyboard_mode_is_saved = false; + }else { +if (!acpi_evalf ( + hkey_handle, ¤t_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + new_mode =adaptive_keyboard_get_next_mode ( + current_mode); + } + } +Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c err_exit: · line 3516
Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +6
-0+if (!acpi_evalf (hkey_handle,NULL ,"STRW" ,"vd" , new_mode)) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + +return true;Isn't the blank line above return statement unnecessary?
Quoted 1 line
Doesn't it look clearly? :)
Well, I thought it might be unintended blank line because the return statement in below case doesn't have blank line. Anyway, I agree if it was your intention.
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
drivers/platform/x86/thinkpad_acpi.c +25
-1+ +case DFR_SHOW_QUICKVIEW_ROW : +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode\n" ); +return false; + }else { + adaptive_keyboard_mode_is_saved = true; + +if (!acpi_evalf (hkey_handle, +NULL ,"STRW" ,"vd" ,FUNCTION_MODE )) { +pr_err ("Cannot set adaptive keyboard mode\n" ); +return false; + } + } +return true; + +default : +return false; + } +} +static bool hotkey_notify_hotkey (const u32 hkey,bool *send_acpi_ev,bool *ignore_acpi_ev)@@ -3456,6 +3556,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *ignore_acpi_ev = true; }return true; + }else { +return adaptive_keyboard_hotkey_notify_hotkey (scancode); }return false; } --1.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH v4 1/1 support Thinkpad X1 Carbon 2nd generation's adaptive keyboard
In reply to Tobias KlauserSubmit patch V4 to support Adaptive Keyboard on Thinkpad X1 Carbon 2nd generation according to Tobias's comments.
Thanks,
Shuduo
Quoted 1 line
From
b153a7b14791c6e01892c0e274e23eefd625fb8dMon Sep 17 00:00:00 2001
From: Shuduo Sang <[email protected]>
Date: Mon, 3 Mar 2014 14:29:32 +0800
Subject: [PATCH] support thinkpad X1 Carbon's adaptive keyboard
Thinkpad X1 Carbon's adaptive keyboard has five modes including Home mode, Web browser mode, Web conference mode, Function mode and Lay-flat mode. We support Home mode and Function mode currently.
--- drivers/platform/x86/thinkpad_acpi.c | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
(quoted diff) +0 -0
b/drivers/platform/x86/thinkpad_acpi.c
index defb6af..f4978fa 100644
drivers/platform/x86/thinkpad_acpi.c +102 -0
114 lines not on this page · raw message
Signature · 9 lines
1.9.0 ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk