Re: [ibm-acpi-devel] [PATCH 5/7] input: Add keycodes used by Lenovo Carbon X1 2014

2015-02-20 Thread Bastien Nocera
Hey Dmitry,

On Fri, 2015-02-20 at 10:40 -0800, Dmitry Torokhov wrote:
> On Fri, Feb 20, 2015 at 10:04:04AM -0500, Benjamin Tissoires wrote:
> > On Fri, Feb 20, 2015 at 9:44 AM, Bastien Nocera  wrote:
> > > Signed-off-by: Bastien Nocera 
> > > ---
> > >  include/uapi/linux/input.h | 10 ++
> > >  1 file changed, 10 insertions(+)
> > >
> > > diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> > > index b0a8130..affe40e 100644
> > > --- a/include/uapi/linux/input.h
> > > +++ b/include/uapi/linux/input.h
> > > @@ -740,6 +740,16 @@ struct input_keymap_entry {
> > >  #define KEY_BRIGHTNESS_MIN 0x250   /* Set Brightness to 
> > > Minimum */
> > >  #define KEY_BRIGHTNESS_MAX 0x251   /* Set Brightness to 
> > > Maximum */
> > >
> > > +#define KEY_CLIPPING_TOOL  0x252   /* Screenshot clipping 
> > > tool */
> 
> Do we have users for this?

Bearing in mind that most of those keys won't be usable in X11, but
should be in Wayland, it might take a little while to actually get used,
but I would add support for this "clipping tool" key in GNOME. Most
likely to start a screenshoting tool in selection mode.

> > > +#define KEY_CLOUD  0x253   /* Cloud Settings */
> 
> Just no. What is cloud settings? Use KEY_VENDOR if you must for this vendor
> "added value" junk they come up on keyboards year after year. It used to be
> WWW, not cloud, I bet in 2016 someone will come up with "IoT"-dedicated key.

The button actually looks like a Cloud, see page 46 of this guide:
http://www.lenovo.com/shop/americas/content/user_guides/x1carbon_2_ug_en.pdf

In GNOME, I would make this start the "Online Accounts" configuration.
I'm fine with renaming it, but I would prefer something more precise
than KEY_VENDOR. KEY_WWW would be fine by me.

> > > +#define KEY_CAMERA_GESTURES0x254   /* Toggle Camera gestures 
> > > */

This wouldn't get used directly in GNOME.

> > > +#define KEY_NEW_TAB0x255   /* Open a new tab */

This would get used.

> > > +#define KEY_MICUP  0x256   /* Microphone Up */
> > > +#define KEY_MICDOWN0x257   /* Microphone Down */

Those would get used as well.

> > > +#define KEY_MICCANCEL_MODE 0x258   /* Toggle Microphone 
> > > cancellation mode */
> > > +#define KEY_CAMERA_ZOOM_MODE   0x259   /* Toggle camera zoom 
> > > mode */

These 2 wouldn't get used directly in GNOME.

> > > +#define KEY_ROTATE_DISPLAY 0x25a   /* Rotate screen by 90 
> > > degrees */
> > > +
> > 
> > This one should be acked by Dmitry (in CC)
> > 
> 
> Some of these (like microphone volume up/down) are generic and reasonable, but
> I need to know if there will be any users for these newly defined keys.

Answers to this in-line above. I'm fine with replacing the keycodes for
those keys with something that more or less corresponds to the
pictograms, especially the "Toggle voice-recognition" and "Toggle
camera-gestures function" are present in all the keyboard modes.

Cheers


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 5/7] input: Add keycodes used by Lenovo Carbon X1 2014

2015-02-20 Thread Dmitry Torokhov
On Fri, Feb 20, 2015 at 10:04:04AM -0500, Benjamin Tissoires wrote:
> On Fri, Feb 20, 2015 at 9:44 AM, Bastien Nocera  wrote:
> > Signed-off-by: Bastien Nocera 
> > ---
> >  include/uapi/linux/input.h | 10 ++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> > index b0a8130..affe40e 100644
> > --- a/include/uapi/linux/input.h
> > +++ b/include/uapi/linux/input.h
> > @@ -740,6 +740,16 @@ struct input_keymap_entry {
> >  #define KEY_BRIGHTNESS_MIN 0x250   /* Set Brightness to 
> > Minimum */
> >  #define KEY_BRIGHTNESS_MAX 0x251   /* Set Brightness to 
> > Maximum */
> >
> > +#define KEY_CLIPPING_TOOL  0x252   /* Screenshot clipping tool 
> > */

Do we have users for this?

> > +#define KEY_CLOUD  0x253   /* Cloud Settings */

Just no. What is cloud settings? Use KEY_VENDOR if you must for this vendor
"added value" junk they come up on keyboards year after year. It used to be
WWW, not cloud, I bet in 2016 someone will come up with "IoT"-dedicated key.

> > +#define KEY_CAMERA_GESTURES0x254   /* Toggle Camera gestures */
> > +#define KEY_NEW_TAB0x255   /* Open a new tab */
> > +#define KEY_MICUP  0x256   /* Microphone Up */
> > +#define KEY_MICDOWN0x257   /* Microphone Down */
> > +#define KEY_MICCANCEL_MODE 0x258   /* Toggle Microphone 
> > cancellation mode */
> > +#define KEY_CAMERA_ZOOM_MODE   0x259   /* Toggle camera zoom mode 
> > */
> > +#define KEY_ROTATE_DISPLAY 0x25a   /* Rotate screen by 90 
> > degrees */
> > +
> 
> This one should be acked by Dmitry (in CC)
> 

Some of these (like microphone volume up/down) are generic and reasonable, but
I need to know if there will be any users for these newly defined keys.

Thanks.

-- 
Dmitry

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 4/6] thinkpad_acpi: Add support for more adaptive kbd buttons

2015-02-20 Thread Bastien Nocera
On Thu, 2015-02-19 at 21:35 -0800, Darren Hart wrote:
> On Wed, Feb 18, 2015 at 09:53:48PM +0100, Bastien Nocera wrote:
> > This commit adds new elements to the ThinkPad keymaps, and
> > will send key events for keys for which an input.h declaration
> > exists.
> > 
> > Signed-off-by: Bastien Nocera 
> > ---
> >  drivers/platform/x86/thinkpad_acpi.c | 80 
> > +++-
> >  1 file changed, 79 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/platform/x86/thinkpad_acpi.c 
> > b/drivers/platform/x86/thinkpad_acpi.c
> > index 562d958..a47a56a 100644
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> > @@ -1911,6 +1911,27 @@ enum {   /* hot key scan codes (derived from 
> > ACPI DSDT) */
> > TP_ACPI_HOTKEYSCAN_UNK7,
> > TP_ACPI_HOTKEYSCAN_UNK8,
> >  
> > +   TP_ACPI_HOTKEYSCAN_MUTE2,
> > +   TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO,
> > +   TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL,
> > +   TP_ACPI_HOTKEYSCAN_CLOUD,
> > +   TP_ACPI_HOTKEYSCAN_UNK9,
> > +   TP_ACPI_HOTKEYSCAN_VOICE,
> > +   TP_ACPI_HOTKEYSCAN_UNK10,
> > +   TP_ACPI_HOTKEYSCAN_GESTURES,
> > +   TP_ACPI_HOTKEYSCAN_UNK11,
> > +   TP_ACPI_HOTKEYSCAN_UNK12,
> > +   TP_ACPI_HOTKEYSCAN_UNK13,
> > +   TP_ACPI_HOTKEYSCAN_CONFIG,
> > +   TP_ACPI_HOTKEYSCAN_NEW_TAB,
> > +   TP_ACPI_HOTKEYSCAN_RELOAD,
> > +   TP_ACPI_HOTKEYSCAN_BACK,
> > +   TP_ACPI_HOTKEYSCAN_MIC_DOWN,
> > +   TP_ACPI_HOTKEYSCAN_MIC_UP,
> > +   TP_ACPI_HOTKEYSCAN_MIC_CANCELLATION,
> > +   TP_ACPI_HOTKEYSCAN_CAMERA_MODE,
> > +   TP_ACPI_HOTKEYSCAN_ROTATE_DISPLAY,
> > +
> > /* Hotkey keymap size */
> > TPACPI_HOTKEY_MAP_LEN
> >  };
> > @@ -3171,6 +3192,13 @@ static int __init hotkey_init(struct ibm_init_struct 
> > *iibm)
> > /* (assignments unknown, please report if found) */
> > KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > +
> > +   /* no assignments, only used for Adaptive keyboards */
> 
> Sentence formatting please.

Done.

> > +   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > +   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > +   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > +   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > +   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
> > },
> >  
> > /* Generic keymap for Lenovo ThinkPads */
> > @@ -3227,6 +3255,33 @@ static int __init hotkey_init(struct ibm_init_struct 
> > *iibm)
> >  
> > /* Extra keys in use since the X240 / T440 / T540 */
> > KEY_CONFIG, KEY_SEARCH, KEY_SCALE, KEY_FILE,
> > +
> > +   /* Adaptive keyboard keycodes for Carbon X1 2014,
> > +* The first item in this list is the Mute button
> > +* which is emitted with 0x103 through
> > +* adaptive_keyboard_hotkey_notify_hotkey ()
> > +* when the sound symbol is held
> > +* We'll need to offset those by 0x20 */
> 
> Please follow CodingStyle with /* and */ on their own lines. Also, wrapping is
> strange, as is capitalization, etc.  Please terminate sentences with periods,
> and only capitalize the beginning of sentences or proper nouns.

Done.

> > +   KEY_RESERVED,/* Mute held, 0x103 */
> > +   KEY_BRIGHTNESS_MIN,  /* Backlight off */
> > +   KEY_RESERVED,/* Clipping tool */
> > +   KEY_RESERVED,/* Cloud */
> > +   KEY_RESERVED,
> > +   KEY_VOICECOMMAND,/* Voice */
> > +   KEY_RESERVED,
> > +   KEY_RESERVED,/* Gestures */
> > +   KEY_RESERVED,
> > +   KEY_RESERVED,
> > +   KEY_RESERVED,
> > +   KEY_CONFIG,  /* Settings */
> > +   KEY_RESERVED,/* New tab */
> > +   KEY_REFRESH, /* Reload */
> > +   KEY_BACK,/* Back */
> > +   KEY_RESERVED,/* Microphone down */
> > +   KEY_RESERVED,/* Microphone up */
> > +   KEY_RESERVED,/* Microphone cancellation */
> > +   KEY_RESERVED,/* Camera mode */
> > +   KEY_RESERVED,/* Rotate display, 0x116 */
> > },
> > };
> >  
> > @@ -3526,6 +3581,8 @@ const int adaptive_keyboard_modes[] = {
> >  
> >  #define DFR_CHANGE_ROW 0x101
> >  #define DFR_SHOW_QUICKVIEW_ROW 0x102
> > +#define FIRST_ADAPTIVE_KEY 0x103
> > +#define ADAPTIVE_KEY_OFFSET0x020
> >  
> >  /* press Fn key a while second, it will switch to Function Mode. Then
> >   * release Fn key, previous mode be restored.
> > @@ -3581,6 +3638,7 @@ static bool 
> > adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
> >  {
> > u32 current_mode = 0;
> > int new_mode = 0;
> > +   int keycode;
> >  
> > switch (scancode) {
> > case DFR_CHANGE_ROW:
> > @@ -3613,7 +367

[ibm-acpi-devel] [PATCH 2/7] thinkpad_acpi: Factor out get/set adaptive kbd mode

2015-02-20 Thread Bastien Nocera
Move the getting/setting of the adaptive keyboard mode to separate
functions, so that we can reuse them later through sysfs attributes.

Signed-off-by: Bastien Nocera 
---
 drivers/platform/x86/thinkpad_acpi.c | 61 ++--
 1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index c1f4daf..d395d3f 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3482,6 +3482,32 @@ const int adaptive_keyboard_modes[] = {
 static bool adaptive_keyboard_mode_is_saved;
 static int adaptive_keyboard_prev_mode;
 
+static int adaptive_keyboard_get_mode(void)
+{
+   int mode = 0;
+
+   if (!acpi_evalf(hkey_handle, &mode, "GTRW", "dd", 0)) {
+   pr_err("Cannot read adaptive keyboard mode\n");
+   return -EIO;
+   }
+
+   return mode;
+}
+
+static int adaptive_keyboard_set_mode(int new_mode)
+{
+   if (new_mode < 0 ||
+   new_mode > LAYFLAT_MODE)
+   return -EINVAL;
+
+   if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd", new_mode)) {
+   pr_err("Cannot set adaptive keyboard mode\n");
+   return -EIO;
+   }
+
+   return 0;
+}
+
 static int adaptive_keyboard_get_next_mode(int mode)
 {
size_t i;
@@ -3511,39 +3537,28 @@ static bool 
adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
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");
+   current_mode = adaptive_keyboard_get_mode();
+   if (current_mode < 0)
return false;
-   } else {
-   new_mode = adaptive_keyboard_get_next_mode(
-   current_mode);
-   }
+   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");
+   if (adaptive_keyboard_set_mode(new_mode) < 0)
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");
+   current_mode = adaptive_keyboard_get_mode();
+   if (current_mode < 0)
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;
-   }
-   }
+   adaptive_keyboard_prev_mode = current_mode;
+   adaptive_keyboard_mode_is_saved = true;
+
+   if (adaptive_keyboard_set_mode (FUNCTION_MODE) < 0)
+   return false;
return true;
 
default:
-- 
2.1.0



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 1/7] thinkpad_acpi: Remember adaptive kbd presence

2015-02-20 Thread Bastien Nocera
Rather than checking on each suspend and resume whether the laptop
has an adaptive keyboard, check when the driver is initialised.

Signed-off-by: Bastien Nocera 
---
 drivers/platform/x86/thinkpad_acpi.c | 37 ++--
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index c3d11fa..c1f4daf 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -318,6 +318,7 @@ static struct {
u32 sensors_pdrv_attrs_registered:1;
u32 sensors_pdev_attrs_registered:1;
u32 hotkey_poll_active:1;
+   u32 has_adaptive_kbd:1;
 } tp_features;
 
 static struct {
@@ -3226,6 +3227,15 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
if (!tp_features.hotkey)
return 1;
 
+   /*
+* Check if we have an adaptive keyboard, like on the
+* Lenovo Carbon X1 2014 (2nd Gen).
+*/
+   if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
+   if ((hkeyv >> 8) == 2)
+   tp_features.has_adaptive_kbd = true;
+   }
+
quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable,
 ARRAY_SIZE(tpacpi_hotkey_qtable));
 
@@ -3834,28 +3844,21 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 
event)
 
 static void hotkey_suspend(void)
 {
-   int hkeyv;
-
/* Do these on suspend, we get the events on early resume! */
hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE;
hotkey_autosleep_ack = 0;
 
/* save previous mode of adaptive keyboard of X1 Carbon */
-   if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-   if ((hkeyv >> 8) == 2) {
-   if (!acpi_evalf(hkey_handle,
-   &adaptive_keyboard_prev_mode,
-   "GTRW", "dd", 0)) {
-   pr_err("Cannot read adaptive keyboard mode.\n");
-   }
+   if (tp_features.has_adaptive_kbd) {
+   if (!acpi_evalf(hkey_handle, &adaptive_keyboard_prev_mode,
+   "GTRW", "dd", 0)) {
+   pr_err("Cannot read adaptive keyboard mode.\n");
}
}
 }
 
 static void hotkey_resume(void)
 {
-   int hkeyv;
-
tpacpi_disable_brightness_delay();
 
if (hotkey_status_set(true) < 0 ||
@@ -3870,14 +3873,10 @@ static void hotkey_resume(void)
hotkey_poll_setup_safe(false);
 
/* restore previous mode of adapive keyboard of X1 Carbon */
-   if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-   if ((hkeyv >> 8) == 2) {
-   if (!acpi_evalf(hkey_handle,
-   NULL,
-   "STRW", "vd",
-   adaptive_keyboard_prev_mode)) {
-   pr_err("Cannot set adaptive keyboard mode.\n");
-   }
+   if (tp_features.has_adaptive_kbd) {
+   if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd",
+   adaptive_keyboard_prev_mode)) {
+   pr_err("Cannot set adaptive keyboard mode.\n");
}
}
 }
-- 
2.1.0



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 3/7] thinkpad_acpi: Add adaptive_kbd_mode sysfs attr

2015-02-20 Thread Bastien Nocera
On Fri, 2015-02-20 at 17:27 +0200, Mika Westerberg wrote:
> On Fri, Feb 20, 2015 at 04:22:07PM +0100, Bastien Nocera wrote:
> > On Fri, 2015-02-20 at 17:20 +0200, Mika Westerberg wrote:
> > > On Fri, Feb 20, 2015 at 03:44:22PM +0100, Bastien Nocera wrote:
> > > > Add a sysfs attribute to allow privileged users to change the keyboard
> > > > mode. This could be used by desktop environments to change the keyboard
> > > > mode depending on the application focused, as the Windows application
> > > > does.
> > > 
> > > If you are adding new sysfs attributes, you should document them as well
> > > in Documentation/ABI/*.
> > 
> > None of the thinkpad_acpi sysfs attributes are documented there, or I'm
> > missing something obvious.
> 
> Perhaps it is good time to start documenting them? :-)

I'm not going to do that. If I were, I would remove a large majority of
them to cut down on the size of the driver. 10k lines of code and
supporting 10+ years of ThinkPads turned the driver into a monster.


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 3/7] thinkpad_acpi: Add adaptive_kbd_mode sysfs attr

2015-02-20 Thread Bastien Nocera
On Fri, 2015-02-20 at 17:20 +0200, Mika Westerberg wrote:
> On Fri, Feb 20, 2015 at 03:44:22PM +0100, Bastien Nocera wrote:
> > Add a sysfs attribute to allow privileged users to change the keyboard
> > mode. This could be used by desktop environments to change the keyboard
> > mode depending on the application focused, as the Windows application
> > does.
> 
> If you are adding new sysfs attributes, you should document them as well
> in Documentation/ABI/*.

None of the thinkpad_acpi sysfs attributes are documented there, or I'm
missing something obvious.


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 5/7] input: Add keycodes used by Lenovo Carbon X1 2014

2015-02-20 Thread Bastien Nocera
Signed-off-by: Bastien Nocera 
---
 include/uapi/linux/input.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index b0a8130..affe40e 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -740,6 +740,16 @@ struct input_keymap_entry {
 #define KEY_BRIGHTNESS_MIN 0x250   /* Set Brightness to Minimum */
 #define KEY_BRIGHTNESS_MAX 0x251   /* Set Brightness to Maximum */
 
+#define KEY_CLIPPING_TOOL  0x252   /* Screenshot clipping tool */
+#define KEY_CLOUD  0x253   /* Cloud Settings */
+#define KEY_CAMERA_GESTURES0x254   /* Toggle Camera gestures */
+#define KEY_NEW_TAB0x255   /* Open a new tab */
+#define KEY_MICUP  0x256   /* Microphone Up */
+#define KEY_MICDOWN0x257   /* Microphone Down */
+#define KEY_MICCANCEL_MODE 0x258   /* Toggle Microphone 
cancellation mode */
+#define KEY_CAMERA_ZOOM_MODE   0x259   /* Toggle camera zoom mode */
+#define KEY_ROTATE_DISPLAY 0x25a   /* Rotate screen by 90 degrees 
*/
+
 #define KEY_KBDINPUTASSIST_PREV0x260
 #define KEY_KBDINPUTASSIST_NEXT0x261
 #define KEY_KBDINPUTASSIST_PREVGROUP   0x262
-- 
2.1.0



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 7/7] thinkpad_acpi: use DEVICE_ATTR_* macros

2015-02-20 Thread Bastien Nocera
Use the DEVICE_ATTR_RW macro to reduce boiler plate and move the
attribute declaration to get rid of function signatures.

Signed-off-by: Bastien Nocera 
---
 drivers/platform/x86/thinkpad_acpi.c | 72 ++--
 1 file changed, 20 insertions(+), 52 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 535095d..4b31492 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2668,9 +2668,7 @@ static ssize_t hotkey_enable_store(struct device *dev,
return count;
 }
 
-static struct device_attribute dev_attr_hotkey_enable =
-   __ATTR(hotkey_enable, S_IWUSR | S_IRUGO,
-   hotkey_enable_show, hotkey_enable_store);
+static DEVICE_ATTR_RW(hotkey_enable);
 
 /* sysfs hotkey mask --- */
 static ssize_t hotkey_mask_show(struct device *dev,
@@ -2706,9 +2704,7 @@ static ssize_t hotkey_mask_store(struct device *dev,
return (res) ? res : count;
 }
 
-static struct device_attribute dev_attr_hotkey_mask =
-   __ATTR(hotkey_mask, S_IWUSR | S_IRUGO,
-   hotkey_mask_show, hotkey_mask_store);
+static DEVICE_ATTR_RW(hotkey_mask);
 
 /* sysfs hotkey bios_enabled --- */
 static ssize_t hotkey_bios_enabled_show(struct device *dev,
@@ -2718,8 +2714,7 @@ static ssize_t hotkey_bios_enabled_show(struct device 
*dev,
return sprintf(buf, "0\n");
 }
 
-static struct device_attribute dev_attr_hotkey_bios_enabled =
-   __ATTR(hotkey_bios_enabled, S_IRUGO, hotkey_bios_enabled_show, NULL);
+static DEVICE_ATTR_RO(hotkey_bios_enabled);
 
 /* sysfs hotkey bios_mask -- */
 static ssize_t hotkey_bios_mask_show(struct device *dev,
@@ -2731,8 +2726,7 @@ static ssize_t hotkey_bios_mask_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_orig_mask);
 }
 
-static struct device_attribute dev_attr_hotkey_bios_mask =
-   __ATTR(hotkey_bios_mask, S_IRUGO, hotkey_bios_mask_show, NULL);
+static DEVICE_ATTR_RO(hotkey_bios_mask);
 
 /* sysfs hotkey all_mask --- */
 static ssize_t hotkey_all_mask_show(struct device *dev,
@@ -2743,8 +2737,7 @@ static ssize_t hotkey_all_mask_show(struct device *dev,
hotkey_all_mask | hotkey_source_mask);
 }
 
-static struct device_attribute dev_attr_hotkey_all_mask =
-   __ATTR(hotkey_all_mask, S_IRUGO, hotkey_all_mask_show, NULL);
+static DEVICE_ATTR_RO(hotkey_all_mask);
 
 /* sysfs hotkey recommended_mask --- */
 static ssize_t hotkey_recommended_mask_show(struct device *dev,
@@ -2756,9 +2749,7 @@ static ssize_t hotkey_recommended_mask_show(struct device 
*dev,
& ~hotkey_reserved_mask);
 }
 
-static struct device_attribute dev_attr_hotkey_recommended_mask =
-   __ATTR(hotkey_recommended_mask, S_IRUGO,
-   hotkey_recommended_mask_show, NULL);
+static DEVICE_ATTR_RO(hotkey_recommended_mask);
 
 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
 
@@ -2813,9 +2804,7 @@ static ssize_t hotkey_source_mask_store(struct device 
*dev,
return (rc < 0) ? rc : count;
 }
 
-static struct device_attribute dev_attr_hotkey_source_mask =
-   __ATTR(hotkey_source_mask, S_IWUSR | S_IRUGO,
-   hotkey_source_mask_show, hotkey_source_mask_store);
+static DEVICE_ATTR_RW(hotkey_source_mask);
 
 /* sysfs hotkey hotkey_poll_freq --- */
 static ssize_t hotkey_poll_freq_show(struct device *dev,
@@ -2847,9 +2836,7 @@ static ssize_t hotkey_poll_freq_store(struct device *dev,
return count;
 }
 
-static struct device_attribute dev_attr_hotkey_poll_freq =
-   __ATTR(hotkey_poll_freq, S_IWUSR | S_IRUGO,
-   hotkey_poll_freq_show, hotkey_poll_freq_store);
+static DEVICE_ATTR_RW(hotkey_poll_freq);
 
 #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
 
@@ -2870,8 +2857,7 @@ static ssize_t hotkey_radio_sw_show(struct device *dev,
(res == TPACPI_RFK_RADIO_OFF) ? 0 : 1);
 }
 
-static struct device_attribute dev_attr_hotkey_radio_sw =
-   __ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL);
+static DEVICE_ATTR_RO(hotkey_radio_sw);
 
 static void hotkey_radio_sw_notify_change(void)
 {
@@ -2893,8 +2879,7 @@ static ssize_t hotkey_tablet_mode_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
 }
 
-static struct device_attribute dev_attr_hotkey_tablet_mode =
-   __ATTR(hotkey_tablet_mode, S_IRUGO, hotkey_tablet_mode_show, NULL);
+static DEVICE_ATTR_RO(hotkey_tablet_mode);
 
 static void hotkey_tablet_mode_notify_change(void)
 {
@@ -2911,8 +2896,7 @@ static ssize_t hotkey_wakeup_reason_show(struct device 
*dev,
return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_wakeup_reason);
 }
 
-static struct device_attribute dev_attr_hotkey_wakeu

[ibm-acpi-devel] [PATCH 4/7] thinkpad_acpi: Add support for more adaptive kbd buttons

2015-02-20 Thread Bastien Nocera
This commit adds new elements to the ThinkPad keymaps, and
will send key events for keys for which an input.h declaration
exists.

Signed-off-by: Bastien Nocera 
---
 drivers/platform/x86/thinkpad_acpi.c | 80 +++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 2030c54..57130a1 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1911,6 +1911,27 @@ enum {   /* hot key scan codes (derived from ACPI DSDT) 
*/
TP_ACPI_HOTKEYSCAN_UNK7,
TP_ACPI_HOTKEYSCAN_UNK8,
 
+   TP_ACPI_HOTKEYSCAN_MUTE2,
+   TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO,
+   TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL,
+   TP_ACPI_HOTKEYSCAN_CLOUD,
+   TP_ACPI_HOTKEYSCAN_UNK9,
+   TP_ACPI_HOTKEYSCAN_VOICE,
+   TP_ACPI_HOTKEYSCAN_UNK10,
+   TP_ACPI_HOTKEYSCAN_GESTURES,
+   TP_ACPI_HOTKEYSCAN_UNK11,
+   TP_ACPI_HOTKEYSCAN_UNK12,
+   TP_ACPI_HOTKEYSCAN_UNK13,
+   TP_ACPI_HOTKEYSCAN_CONFIG,
+   TP_ACPI_HOTKEYSCAN_NEW_TAB,
+   TP_ACPI_HOTKEYSCAN_RELOAD,
+   TP_ACPI_HOTKEYSCAN_BACK,
+   TP_ACPI_HOTKEYSCAN_MIC_DOWN,
+   TP_ACPI_HOTKEYSCAN_MIC_UP,
+   TP_ACPI_HOTKEYSCAN_MIC_CANCELLATION,
+   TP_ACPI_HOTKEYSCAN_CAMERA_MODE,
+   TP_ACPI_HOTKEYSCAN_ROTATE_DISPLAY,
+
/* Hotkey keymap size */
TPACPI_HOTKEY_MAP_LEN
 };
@@ -3169,6 +3190,13 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
/* (assignments unknown, please report if found) */
KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+
+   /* No assignments, only used for Adaptive keyboards. */
+   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+   KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
},
 
/* Generic keymap for Lenovo ThinkPads */
@@ -3225,6 +3253,35 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
 
/* Extra keys in use since the X240 / T440 / T540 */
KEY_CONFIG, KEY_SEARCH, KEY_SCALE, KEY_FILE,
+
+   /*
+* These are the adaptive keyboard keycodes for Carbon X1 2014.
+* The first item in this list is the Mute button which is
+* emitted with 0x103 through
+* adaptive_keyboard_hotkey_notify_hotkey() when the sound
+* symbol is held.
+* We'll need to offset those by 0x20.
+*/
+   KEY_RESERVED,/* Mute held, 0x103 */
+   KEY_BRIGHTNESS_MIN,  /* Backlight off */
+   KEY_RESERVED,/* Clipping tool */
+   KEY_RESERVED,/* Cloud */
+   KEY_RESERVED,
+   KEY_VOICECOMMAND,/* Voice */
+   KEY_RESERVED,
+   KEY_RESERVED,/* Gestures */
+   KEY_RESERVED,
+   KEY_RESERVED,
+   KEY_RESERVED,
+   KEY_CONFIG,  /* Settings */
+   KEY_RESERVED,/* New tab */
+   KEY_REFRESH, /* Reload */
+   KEY_BACK,/* Back */
+   KEY_RESERVED,/* Microphone down */
+   KEY_RESERVED,/* Microphone up */
+   KEY_RESERVED,/* Microphone cancellation */
+   KEY_RESERVED,/* Camera mode */
+   KEY_RESERVED,/* Rotate display, 0x116 */
},
};
 
@@ -3526,6 +3583,8 @@ const int adaptive_keyboard_modes[] = {
 
 #define DFR_CHANGE_ROW 0x101
 #define DFR_SHOW_QUICKVIEW_ROW 0x102
+#define FIRST_ADAPTIVE_KEY 0x103
+#define ADAPTIVE_KEY_OFFSET0x020
 
 /* press Fn key a while second, it will switch to Function Mode. Then
  * release Fn key, previous mode be restored.
@@ -3581,6 +3640,7 @@ static bool 
adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
 {
u32 current_mode = 0;
int new_mode = 0;
+   int keycode;
 
switch (scancode) {
case DFR_CHANGE_ROW:
@@ -3613,7 +3673,25 @@ static bool 
adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
return true;
 
default:
-   return false;
+   if (scancode < FIRST_ADAPTIVE_KEY || scancode > 
FIRST_ADAPTIVE_KEY +
+   TPACPI_HOTKEY_MAP_LEN - ADAPTIVE_KEY_OFFSET) {
+   pr_info("Unhandled adaptive keyboard key: 0x%x\n",
+   scancode);
+   return false;
+   }
+   keycode 

[ibm-acpi-devel] [PATCH 6/7] thinkpad_acpi: More Carbon X1 2014 keys

2015-02-20 Thread Bastien Nocera
Add support for newly added evdev keycodes.

Signed-off-by: Bastien Nocera 
---
 drivers/platform/x86/thinkpad_acpi.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 57130a1..535095d 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3264,24 +3264,24 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
 */
KEY_RESERVED,/* Mute held, 0x103 */
KEY_BRIGHTNESS_MIN,  /* Backlight off */
-   KEY_RESERVED,/* Clipping tool */
-   KEY_RESERVED,/* Cloud */
+   KEY_CLIPPING_TOOL,   /* Clipping tool */
+   KEY_CLOUD,   /* Cloud */
KEY_RESERVED,
KEY_VOICECOMMAND,/* Voice */
KEY_RESERVED,
-   KEY_RESERVED,/* Gestures */
+   KEY_CAMERA_GESTURES, /* Gestures */
KEY_RESERVED,
KEY_RESERVED,
KEY_RESERVED,
KEY_CONFIG,  /* Settings */
-   KEY_RESERVED,/* New tab */
+   KEY_NEW_TAB, /* New tab */
KEY_REFRESH, /* Reload */
KEY_BACK,/* Back */
-   KEY_RESERVED,/* Microphone down */
-   KEY_RESERVED,/* Microphone up */
-   KEY_RESERVED,/* Microphone cancellation */
-   KEY_RESERVED,/* Camera mode */
-   KEY_RESERVED,/* Rotate display, 0x116 */
+   KEY_MICUP,   /* Microphone down */
+   KEY_MICDOWN, /* Microphone up */
+   KEY_MICCANCEL_MODE,  /* Microphone cancellation */
+   KEY_CAMERA_ZOOM_MODE,/* Camera mode */
+   KEY_ROTATE_DISPLAY,  /* Rotate display, 0x116 */
},
};
 
-- 
2.1.0



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 3/7] thinkpad_acpi: Add adaptive_kbd_mode sysfs attr

2015-02-20 Thread Bastien Nocera
Add a sysfs attribute to allow privileged users to change the keyboard
mode. This could be used by desktop environments to change the keyboard
mode depending on the application focused, as the Windows application
does.

Signed-off-by: Bastien Nocera 
---
 drivers/platform/x86/thinkpad_acpi.c | 69 +++-
 1 file changed, 60 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index d395d3f..2030c54 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2917,6 +2917,57 @@ static void 
hotkey_wakeup_hotunplug_complete_notify_change(void)
 "wakeup_hotunplug_complete");
 }
 
+/* sysfs adaptive kbd mode - */
+
+static int adaptive_keyboard_get_mode(void);
+static int adaptive_keyboard_set_mode(int new_mode);
+
+enum ADAPTIVE_KEY_MODE {
+   HOME_MODE,
+   WEB_BROWSER_MODE,
+   WEB_CONFERENCE_MODE,
+   FUNCTION_MODE,
+   LAYFLAT_MODE
+};
+
+static ssize_t adaptive_kbd_mode_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   u32 current_mode;
+
+   current_mode = adaptive_keyboard_get_mode();
+   if (current_mode < 0)
+   return current_mode;
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", current_mode);
+}
+
+static ssize_t adaptive_kbd_mode_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   unsigned long t;
+   int res;
+
+   if (parse_strtoul(buf, LAYFLAT_MODE, &t))
+   return -EINVAL;
+
+   res = adaptive_keyboard_set_mode(t);
+   return (res < 0) ? res : count;
+}
+
+static DEVICE_ATTR_RW(adaptive_kbd_mode);
+
+static struct attribute *adaptive_kbd_attributes[] = {
+   &dev_attr_adaptive_kbd_mode.attr,
+   NULL
+};
+
+static const struct attribute_group adaptive_kbd_attr_group = {
+   .attrs = adaptive_kbd_attributes,
+};
+
 /* - */
 
 static struct attribute *hotkey_attributes[] __initdata = {
@@ -3232,8 +3283,13 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
 * Lenovo Carbon X1 2014 (2nd Gen).
 */
if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-   if ((hkeyv >> 8) == 2)
+   if ((hkeyv >> 8) == 2) {
tp_features.has_adaptive_kbd = true;
+   res = sysfs_create_group(&tpacpi_pdev->dev.kobj,
+   &adaptive_kbd_attr_group);
+   if (res)
+   goto err_exit;
+   }
}
 
quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable,
@@ -3446,6 +3502,9 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
 
 err_exit:
delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj);
+   sysfs_remove_group(&tpacpi_pdev->dev.kobj,
+   &adaptive_kbd_attr_group);
+
hotkey_dev_attributes = NULL;
 
return (res < 0) ? res : 1;
@@ -3458,14 +3517,6 @@ err_exit:
  * Will consider support rest of modes in future.
  *
  */
-enum ADAPTIVE_KEY_MODE {
-   HOME_MODE,
-   WEB_BROWSER_MODE,
-   WEB_CONFERENCE_MODE,
-   FUNCTION_MODE,
-   LAYFLAT_MODE
-};
-
 const int adaptive_keyboard_modes[] = {
HOME_MODE,
 /* WEB_BROWSER_MODE = 2,
-- 
2.1.0



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 3/6] thinkpad_acpi: Add adaptive_kbd_mode sysfs attr

2015-02-20 Thread Bastien Nocera
On Thu, 2015-02-19 at 21:28 -0800, Darren Hart wrote:
> On Wed, Feb 18, 2015 at 09:53:44PM +0100, Bastien Nocera wrote:
> 
> Commit message please.

Added.

> > Signed-off-by: Bastien Nocera 
> > ---
> >  drivers/platform/x86/thinkpad_acpi.c | 71 
> > +++-
> >  1 file changed, 62 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/thinkpad_acpi.c 
> > b/drivers/platform/x86/thinkpad_acpi.c
> > index a6dd017..562d958 100644
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> 
> ...
> 
> > +static struct device_attribute dev_attr_adaptive_kbd_mode =
> > +   __ATTR(adaptive_kbd_mode, S_IWUSR | S_IRUGO,
> > +   adaptive_kbd_mode_show, adaptive_kbd_mode_store);
> > +
> 
> Please use DEVICE_ATTR_RW() macros for new sysfs files.

Done.

> I'd very much like to see a cleanup of the driver to use these as well.
> 
> Henrique, your thoughts / preference?

Looks easy enough. I'll post the patch with the new series.


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 2/6] thinkpad_acpi: Factor out get/set adaptive kbd mode

2015-02-20 Thread Bastien Nocera
On Thu, 2015-02-19 at 21:22 -0800, Darren Hart wrote:
> On Wed, Feb 18, 2015 at 09:53:35PM +0100, Bastien Nocera wrote:
> 
> Please provide a commit message. There is always something to say beyond what 
> is
> in the subject. In this case, I suggest the motivation and justification for 
> the
> change.
> 
> While I appreciate the abstraction, it makes the code at the call site easier 
> to
> read, note that you added more code than you removed.
> 
> So, please provide a justificaiton.

Sure, done.

> Under no circumstances will I accept a patch without a commit message body.
> 
> > Signed-off-by: Bastien Nocera 
> > ---
> >  drivers/platform/x86/thinkpad_acpi.c | 61 
> > ++--
> >  1 file changed, 38 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/thinkpad_acpi.c 
> > b/drivers/platform/x86/thinkpad_acpi.c
> > index 80db3ce..a6dd017 100644
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> > @@ -3480,6 +3480,32 @@ const int adaptive_keyboard_modes[] = {
> >  static bool adaptive_keyboard_mode_is_saved;
> >  static int adaptive_keyboard_prev_mode;
> >  
> > +static int adaptive_keyboard_get_mode(void)
> > +{
> > +   u32 mode = 0;
> 
> acpi_evalf second argument takes an "int" and this function returns "int". Is
> there a reason to use u32 for mode?

Used int, done.

> > @@ -3509,39 +3535,28 @@ static bool 
> > adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
> > 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");
> > +   current_mode = adaptive_keyboard_get_mode();
> > +   if (current_mode < 0)
> > return false;
> > -   } else {
> > -   new_mode = adaptive_keyboard_get_next_mode(
> > -   current_mode);
> > -   }
> > +   new_mode = adaptive_keyboard_get_next_mode(
> > +   current_mode);
> 
> This now fits on one line I believe.

Nope, 81 characters. I've kept it as-is.


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 1/6] thinkpad_acpi: Remember adaptive kbd presence

2015-02-20 Thread Bastien Nocera
On Thu, 2015-02-19 at 21:08 -0800, Darren Hart wrote:
> On Wed, Feb 18, 2015 at 09:53:28PM +0100, Bastien Nocera wrote:
> > Rather than checking on each suspend and resume whether the laptop
> > has an adaptive keyboard, check when the driver is initialised.
> 
> Reasonable.
> 
> > 
> > Signed-off-by: Bastien Nocera 
> > ---
> >  drivers/platform/x86/thinkpad_acpi.c | 38 
> > ++--
> >  1 file changed, 19 insertions(+), 19 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/thinkpad_acpi.c 
> > b/drivers/platform/x86/thinkpad_acpi.c
> > index c3d11fa..80db3ce 100644
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> ...
> > @@ -3226,6 +3227,13 @@ static int __init hotkey_init(struct ibm_init_struct 
> > *iibm)
> > if (!tp_features.hotkey)
> > return 1;
> >  
> > +   /* does it have an adaptive keyboard, like
> > +* the Lenovo Carbon X1 2014 (2nd gen) */
> 
> Please follow CodingStyle here:
> 
> /*
>  * Sentence formatting.
>  * Second line.
>  */
> 
> The above is a question, just state what you're doing:
> 
> /*
>  * Check if we have an adaptive keyboard, like on the
>  * Lenovo Carbon X1 2014 (2nd Gen).
>  */

Done.

> > +   if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
> > +   if ((hkeyv >> 8) == 2)
> > +   tp_features.has_adaptive_kbd = true;
> > +   }
> > +
> > quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable,
> >  ARRAY_SIZE(tpacpi_hotkey_qtable));
> >  
> > @@ -3834,28 +3842,22 @@ static void hotkey_notify(struct ibm_struct *ibm, 
> > u32 event)
> >  
> >  static void hotkey_suspend(void)
> >  {
> > -   int hkeyv;
> > -
> > /* Do these on suspend, we get the events on early resume! */
> > hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE;
> > hotkey_autosleep_ack = 0;
> >  
> > /* save previous mode of adaptive keyboard of X1 Carbon */
> > -   if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
> > -   if ((hkeyv >> 8) == 2) {
> > -   if (!acpi_evalf(hkey_handle,
> > -   &adaptive_keyboard_prev_mode,
> > -   "GTRW", "dd", 0)) {
> > -   pr_err("Cannot read adaptive keyboard mode.\n");
> > -   }
> > +   if (tp_features.has_adaptive_kbd) {
> > +   if (!acpi_evalf(hkey_handle,
> > +   &adaptive_keyboard_prev_mode,
> > +   "GTRW", "dd", 0)) {
> > +   pr_err("Cannot read adaptive keyboard mode.\n");
> > }
> > }
> >  }
> >  
> >  static void hotkey_resume(void)
> >  {
> > -   int hkeyv;
> > -
> > tpacpi_disable_brightness_delay();
> >  
> > if (hotkey_status_set(true) < 0 ||
> > @@ -3870,14 +3872,12 @@ static void hotkey_resume(void)
> > hotkey_poll_setup_safe(false);
> >  
> > /* restore previous mode of adapive keyboard of X1 Carbon */
> > -   if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
> > -   if ((hkeyv >> 8) == 2) {
> > -   if (!acpi_evalf(hkey_handle,
> > -   NULL,
> > -   "STRW", "vd",
> > -   adaptive_keyboard_prev_mode)) {
> > -   pr_err("Cannot set adaptive keyboard mode.\n");
> > -   }
> > +   if (tp_features.has_adaptive_kbd) {
> > +   if (!acpi_evalf(hkey_handle,
> > +   NULL,
> > +   "STRW", "vd",
> > +   adaptive_keyboard_prev_mode)) {
> 
> You've saved a level of indentation, please group the arguments into fewer
> lines, should be two instead of four.
> 
> Otherwise, looks good.

Done.


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel