All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard
@ 2014-03-11 11:01 Shuduo Sang
  2014-03-31 14:49 ` Pavel Machek
  2014-03-31 17:49 ` Henrique de Moraes Holschuh
  0 siblings, 2 replies; 6+ messages in thread
From: Shuduo Sang @ 2014-03-11 11:01 UTC (permalink / raw)
  To: ibm-acpi, matthew.garrett, ibm-acpi-devel, platofor-driver-x86,
	linux-kernel
  Cc: bruce.ma


Resend patch V4. Support Thinkpad X1 Carbon 2nd generation's adaptive
keyboard.

Hi Henrique, could you please have a chance to review it?

Thanks,
Shuduo


>From b153a7b14791c6e01892c0e274e23eefd625fb8d Mon Sep 17 00:00:00 2001
From: Shuduo Sang <sangshuduo@gmail.com>
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.

Signed-off-by: Bruce Ma <bruce.ma@canonical.com>
Signed-off-by: Shuduo Sang <shuduo.sang@canonical.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 102
+++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

diff --git a/drivers/platform/x86/thinkpad_acpi.c
b/drivers/platform/x86/thinkpad_acpi.c
index defb6af..f4978fa 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -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
+};
+
+const 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)
+{
+	size_t 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, &current_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;
 }
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard
  2014-03-11 11:01 [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard Shuduo Sang
@ 2014-03-31 14:49 ` Pavel Machek
       [not found]   ` <CA+BAWBSqF=tL9cRm2oDb3hRMxebFV69BrgzfTbcvaGjRfKnrMw@mail.gmail.com>
  2014-03-31 17:49 ` Henrique de Moraes Holschuh
  1 sibling, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2014-03-31 14:49 UTC (permalink / raw)
  To: Shuduo Sang
  Cc: ibm-acpi, matthew.garrett, ibm-acpi-devel, platofor-driver-x86,
	linux-kernel, bruce.ma

Hi!

> Resend patch V4. Support Thinkpad X1 Carbon 2nd generation's adaptive
> keyboard.
> 
> Hi Henrique, could you please have a chance to review it?

As far as I can tell... thinkpad just has small display above its function keys (right?).

Would it be possible to support it as a display? (/dev/fb1)?

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard
       [not found]   ` <CA+BAWBSqF=tL9cRm2oDb3hRMxebFV69BrgzfTbcvaGjRfKnrMw@mail.gmail.com>
@ 2014-03-31 15:12     ` Pavel Machek
       [not found]       ` <20140331151258.GA8380-5NIqAleC692hcjWhqY66xCZi+YwRKgec@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2014-03-31 15:12 UTC (permalink / raw)
  To: Shuduo Sang
  Cc: ibm-acpi, matthew.garrett, ibm-acpi-devel, platofor-driver-x86,
	linux-kernel, Bruce Ma

On Mon 2014-03-31 23:00:36, Shuduo Sang wrote:
> On Mon, Mar 31, 2014 at 10:49 PM, Pavel Machek <pavel@ucw.cz> wrote:
> 
> > Hi!
> >
> > > Resend patch V4. Support Thinkpad X1 Carbon 2nd generation's adaptive
> > > keyboard.
> > >
> > > Hi Henrique, could you please have a chance to review it?
> >
> > As far as I can tell... thinkpad just has small display above its function
> > keys (right?).
> >
> > Would it be possible to support it as a display? (/dev/fb1)?
> >
> 
> Not possible so far.

Can you elaborate?

Is the problem that hw only supports few fixed images for that display?
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard
       [not found]       ` <20140331151258.GA8380-5NIqAleC692hcjWhqY66xCZi+YwRKgec@public.gmane.org>
@ 2014-03-31 15:25         ` Shuduo Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Shuduo Sang @ 2014-03-31 15:25 UTC (permalink / raw)
  To: Pavel Machek
  Cc: matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA,
	ibm-acpi-N3TV7GIv+o9fyO9Q7EP/yw,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	platform-driver-x86-u79uwXL29TY76Z2rM5mHXA,
	ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Bruce Ma


[-- Attachment #1.1: Type: text/plain, Size: 935 bytes --]

On Mon, Mar 31, 2014 at 11:12 PM, Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org> wrote:

> On Mon 2014-03-31 23:00:36, Shuduo Sang wrote:
> > On Mon, Mar 31, 2014 at 10:49 PM, Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org> wrote:
> >
> > > Hi!
> > >
> > > > Resend patch V4. Support Thinkpad X1 Carbon 2nd generation's adaptive
> > > > keyboard.
> > > >
> > > > Hi Henrique, could you please have a chance to review it?
> > >
> > > As far as I can tell... thinkpad just has small display above its
> function
> > > keys (right?).
> > >
> > > Would it be possible to support it as a display? (/dev/fb1)?
> > >
> >
> > Not possible so far.
>
> Can you elaborate?
>
> Is the problem that hw only supports few fixed images for that display?
>

No such interface can do that.



>
> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures)
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
>

[-- Attachment #1.2: Type: text/html, Size: 1958 bytes --]

[-- Attachment #2: Type: text/plain, Size: 79 bytes --]

------------------------------------------------------------------------------

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard
  2014-03-11 11:01 [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard Shuduo Sang
  2014-03-31 14:49 ` Pavel Machek
@ 2014-03-31 17:49 ` Henrique de Moraes Holschuh
       [not found]   ` <1396288189.17715.101062725.0503948F-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Henrique de Moraes Holschuh @ 2014-03-31 17:49 UTC (permalink / raw)
  To: Shuduo Sang, matthew.garrett, ibm-acpi-devel,
	platform-driver-x86, linux-kernel
  Cc: bruce.ma

On Tue, Mar 11, 2014, at 8:01, Shuduo Sang wrote:
> Resend patch V4. Support Thinkpad X1 Carbon 2nd generation's adaptive
> keyboard.
> 
> Hi Henrique, could you please have a chance to review it?

I am unable to do a full review right now, but we can always adjust
minor details of the feature with later patches and the previous reviews
did help clean up the feature.

However: as far as I am concerned, this is an experimental feature until
it matures for a while.  I'd rather we plug this somehow to the
thinkpad-acpi input map, for example.

Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard
       [not found]   ` <1396288189.17715.101062725.0503948F-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
@ 2014-04-01  0:32     ` Shuduo Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Shuduo Sang @ 2014-04-01  0:32 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA, Bruce Ma,
	platform-driver-x86-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f


[-- Attachment #1.1: Type: text/plain, Size: 1460 bytes --]

On Tue, Apr 1, 2014 at 1:49 AM, Henrique de Moraes Holschuh
<hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>wrote:

> On Tue, Mar 11, 2014, at 8:01, Shuduo Sang wrote:
> > Resend patch V4. Support Thinkpad X1 Carbon 2nd generation's adaptive
> > keyboard.
> >
> > Hi Henrique, could you please have a chance to review it?
>
> I am unable to do a full review right now, but we can always adjust
> minor details of the feature with later patches and the previous reviews
> did help clean up the feature.
>
> However: as far as I am concerned, this is an experimental feature until
> it matures for a while.  I'd rather we plug this somehow to the
> thinkpad-acpi input map, for example.
>
>
Yes, I tried to use input map but worry old logic need change many since
the new event number
is far to old. The functionality is verified well and get official
recognised by Lenovo.


> Acked-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
>

There are two more patches for X1 carbon adaptive keyboard need review.

[PATCH] save and restore adaptive keyboard mode for suspend and, resume
[PATCH] support thinkpad HKEY interface version 0x200

They are verified by me and other X1 carbon users.

Thanks Henrique.



>
> --
>   "One disk to rule them all, One disk to find them. One disk to bring
>   them all and in the darkness grind them. In the Land of Redmond
>   where the shadows lie." -- The Silicon Valley Tarot
>   Henrique Holschuh
>

[-- Attachment #1.2: Type: text/html, Size: 2748 bytes --]

[-- Attachment #2: Type: text/plain, Size: 79 bytes --]

------------------------------------------------------------------------------

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-01  0:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11 11:01 [PATCH V4 RESEND] Support Thinkpad X1 Carbon 2nd gen's adaptive keyboard Shuduo Sang
2014-03-31 14:49 ` Pavel Machek
     [not found]   ` <CA+BAWBSqF=tL9cRm2oDb3hRMxebFV69BrgzfTbcvaGjRfKnrMw@mail.gmail.com>
2014-03-31 15:12     ` Pavel Machek
     [not found]       ` <20140331151258.GA8380-5NIqAleC692hcjWhqY66xCZi+YwRKgec@public.gmane.org>
2014-03-31 15:25         ` Shuduo Sang
2014-03-31 17:49 ` Henrique de Moraes Holschuh
     [not found]   ` <1396288189.17715.101062725.0503948F-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
2014-04-01  0:32     ` Shuduo Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.