[PATCH 3/4] Input - synaptics: remove TOPBUTTONPAD property for Lenovos 2015

2015-01-28 Thread Benjamin Tissoires
The 2015 series of the Lenovo thinkpads added back the hardware buttons
on top of the touchpad for the trackstick.

Unfortunately, they are wired to the touchpad, and not the trackstick.
Thus, they are seen as extra buttons from the kernel point of view.

This leads to a problem in user space because extra buttons on synaptics
devices used to be used as scroll up/down buttons. So in the end, the
experience for the user is scroll events for buttons left and right
when using the trackstick. Yay!
Still, this user space problem will be fixed in the user space, and
the kernel will only handle the TOPBUTTONPAD property - which was not
a good idea to introduce in the kernel in the first place, I concede.

Furthermore, Lenovo kept using the PNPIDs that are supposed to be
5 buttons touchpads, so the new laptops also have the
INPUT_PROP_TOPBUTTONPAD. Yay again!

Insteead of manually removing each of the new ones, or hoping that we
know all the current ones, we can consider that the PNPIDs list that
were given contains touchpads that have the trackstick buttons, either
physically wired to them, or emulated with the top software button
property.

Thanks to the extra buttons capability, we can reliably detect the
physical buttons from the software ones, and so we can remove the
TOPBUTTONPAD property even if it was declared as such.

Cc: sta...@vger.kernel.org
Signed-off-by: Benjamin Tissoires benjamin.tissoi...@redhat.com
---
 drivers/input/mouse/synaptics.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index d58863b..4f05c9f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -1129,7 +1129,8 @@ static void set_input_params(struct psmouse *psmouse,
 
if (SYN_CAP_CLICKPAD(priv-ext_cap_0c)) {
__set_bit(INPUT_PROP_BUTTONPAD, dev-propbit);
-   if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids))
+   if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) 
+   !test_bit(BTN_0, dev-keybit))
__set_bit(INPUT_PROP_TOPBUTTONPAD, dev-propbit);
/* Clickpads report only left button */
__clear_bit(BTN_RIGHT, dev-keybit);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] Input - synaptics: Remove X1 Carbon 3rd gen from the topbuttonpad list

2015-01-28 Thread Benjamin Tissoires
Lenovo decided to switch back to physical buttons for the trackstick
on their latest series. The PNPId list was provided before they reverted
back to physical buttons, so it contains the new models too.
We can know from the touchpad capabilities that the touchpad has physical
buttons, so removing the ids from the list is not mandatory. It is still
nicer to remove the wrong ids, so start by removing the X1 Carbon 3rd gen,
with the PNPId of LEN0048.

Signed-off-by: Benjamin Tissoires benjamin.tissoi...@redhat.com
---
 drivers/input/mouse/synaptics.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 4f05c9f..b2944ee 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -173,7 +173,6 @@ static const char * const topbuttonpad_pnp_ids[] = {
LEN0045,
LEN0046,
LEN0047,
-   LEN0048,
LEN0049,
LEN2000,
LEN2001, /* Edge E431 */
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] Input - synaptics: fix middle button on Lenovo 2015 products

2015-01-28 Thread Benjamin Tissoires
On the X1 Carbon 3rd gen (with a 2015 broadwell cpu), the physical middle
button of the trackstick (attached to the touchpad serio device, of course)
seems to get lost.

Actually, the touchpads reports 3 extra buttons, which falls in the switch
below to the '2' case. Let's handle the case of odd numbers also, so that
the middle button finds its way back.

Cc: sta...@vger.kernel.org
Signed-off-by: Benjamin Tissoires benjamin.tissoi...@redhat.com
---
 drivers/input/mouse/synaptics.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index f89de89..0d12664 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -689,7 +689,7 @@ static int synaptics_parse_hw_state(const unsigned char 
buf[],
 
if (SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap) 
((buf[0] ^ buf[3])  0x02)) {
-   switch (SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap)  ~0x01) 
{
+   switch (SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap)) {
default:
/*
 * if nExtBtn is greater than 8 it should be
@@ -698,15 +698,19 @@ static int synaptics_parse_hw_state(const unsigned char 
buf[],
break;
case 8:
hw-ext_buttons |= ((buf[5]  0x08)) ? 0x80 : 0;
+   case 7:
hw-ext_buttons |= ((buf[4]  0x08)) ? 0x40 : 0;
case 6:
hw-ext_buttons |= ((buf[5]  0x04)) ? 0x20 : 0;
+   case 5:
hw-ext_buttons |= ((buf[4]  0x04)) ? 0x10 : 0;
case 4:
hw-ext_buttons |= ((buf[5]  0x02)) ? 0x08 : 0;
+   case 3:
hw-ext_buttons |= ((buf[4]  0x02)) ? 0x04 : 0;
case 2:
hw-ext_buttons |= ((buf[5]  0x01)) ? 0x02 : 0;
+   case 1:
hw-ext_buttons |= ((buf[4]  0x01)) ? 0x01 : 0;
}
}
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] Input - synaptics: do not release extra buttons once they are pressed

2015-01-28 Thread Benjamin Tissoires
The current code releases the extra buttons right after they are pressed.
As soon as a new serio report comes in, the hw state is reset to 0
and so the buttons are released.

Check for the report type before acting on the current extra buttons
state.

Cc: sta...@vger.kernel.org
Signed-off-by: Benjamin Tissoires benjamin.tissoi...@redhat.com
---
 drivers/input/mouse/synaptics.c | 10 +++---
 drivers/input/mouse/synaptics.h |  3 +++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 0d12664..d58863b 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -688,7 +688,7 @@ static int synaptics_parse_hw_state(const unsigned char 
buf[],
}
 
if (SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap) 
-   ((buf[0] ^ buf[3])  0x02)) {
+   SYN_REPORT_EXT_BUTTONS(buf)) {
switch (SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap)) {
default:
/*
@@ -792,8 +792,12 @@ static void synaptics_report_buttons(struct psmouse 
*psmouse,
input_report_key(dev, BTN_BACK, hw-down);
}
 
-   for (i = 0; i  SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap); i++)
-   input_report_key(dev, BTN_0 + i, hw-ext_buttons  (1  i));
+   if (SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap) 
+   SYN_REPORT_EXT_BUTTONS(psmouse-packet)) {
+   for (i = 0; i  SYN_CAP_MULTI_BUTTON_NO(priv-ext_cap); i++)
+   input_report_key(dev, BTN_0 + i,
+hw-ext_buttons  (1  i));
+   }
 }
 
 static void synaptics_report_mt_data(struct psmouse *psmouse,
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 6faf9bb..0b2b711 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -115,6 +115,9 @@
 #define SYN_NEWABS_RELAXED 2
 #define SYN_OLDABS 3
 
+/* synaptics extended button packet */
+#define SYN_REPORT_EXT_BUTTONS(buf)(((buf)[0] ^ (buf)[3])  0x02)
+
 /* amount to fuzz position data when touchpad reports reduced filtering */
 #define SYN_REDUCED_FILTER_FUZZ8
 
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] New Lenovos 2015 touchpads: party time!

2015-01-28 Thread Benjamin Tissoires
Hi Dmitry,

Lenovo released their new models, and believe it or not, some kernel
work is required to support them!

We learned the lesson and we will try to maximize the effort in user space
through udev rules instead of polluting the kernel with exceptions.

Patches 1  2 are general fixes for synaptics that have been unnoticed
until this new models. They are marked as stable.

Patch 3 is a generic way to fix the PnpId list that was hardcoded in the
kernel. This one is also marked as stable so that distributions will not
have the top software buttons on devices that do not require it.

Patch 4 is a nice to have. It is not mandatory, so not CC-ed to stable,
it just reduced the PnpId list.

The good thing is that the reported min/max are correct, so the problems
with the first generation of the t440 touchpad have been fixed now (and
synaptics assured us that they will keep checking the quality of the PS/2
handling of their touchpads).

One last thing, I still did not manage to talk to the device over SMBus,
so we are still stuck with the PS/2 protocol and its limitations for this
series.

Cheers,
Benjamin

Benjamin Tissoires (4):
  Input - synaptics: fix middle button on Lenovo 2015 products
  Input - synaptics: do not release extra buttons once they are pressed
  Input - synaptics: remove TOPBUTTONPAD property for Lenovos 2015
  Input - synaptics: Remove X1 Carbon 3rd gen from the topbuttonpad list

 drivers/input/mouse/synaptics.c | 20 ++--
 drivers/input/mouse/synaptics.h |  3 +++
 2 files changed, 17 insertions(+), 6 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] Make sure touch arbitration is applied consistently across devices

2015-01-28 Thread Ping Cheng
stylus_in_proximity is used to make sure no touch event is sent while pen
is in proximity. touch_down is used to make sure a touch up event is sent
when pen comes into proximity while touch is down.

Two touch routines didn't store touch_down. One touch routine forgot to
check stylus_in_proximity before sending touch events. This patch fixes
those issues.

Signed-off-by: Ping Cheng pi...@wacom.com
---
v2: added commit comments as reqested by Jiri. No code update.
---
 drivers/hid/wacom_wac.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index f886149..6d490f6 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1042,7 +1042,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
 
for (i = 0; i  contacts_to_send; i++) {
int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1;
-   bool touch = data[offset]  0x1  
!wacom-shared-stylus_in_proximity;
+   bool touch = (data[offset]  0x1)  
!wacom-shared-stylus_in_proximity;
int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
 
if (slot  0)
@@ -1072,6 +1072,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
if (wacom-num_contacts_left = 0)
wacom-num_contacts_left = 0;
 
+   wacom-shared-touch_down = (wacom-num_contacts_left  0);
return 1;
 }
 
@@ -1100,7 +1101,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
 
for (i = 0; i  contacts_to_send; i++) {
int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
-   bool touch = data[offset]  0x1;
+   bool touch = (data[offset]  0x1)  
!wacom-shared-stylus_in_proximity;
int id = get_unaligned_le16(data[offset + 1]);
int slot = input_mt_get_slot_by_key(input, id);
 
@@ -1122,6 +1123,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
if (wacom-num_contacts_left  0)
wacom-num_contacts_left = 0;
 
+   wacom-shared-touch_down = (wacom-num_contacts_left  0);
return 1;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/3] mfd: max8997: add regmap support

2015-01-28 Thread Robert Baldyga
Hi,

The first version of this patchset was send to kernel list almost 9
months ago and still I don't have all needed Acks. The missing ones are
for changes in INPUT and RTC subsystems.

Dmitry, Alessandro, could you please have a look at this patches and
give your Acks?

Best regards,
Robert Baldyga

On 11/12/2014 08:23 AM, Robert Baldyga wrote:
 This patchset modifies max8997 driver and associated function drivers to use
 register maps instead of operating directly on i2c bus. This change allowed
 to simplify irq handling, and to move some initializations to individual
 function drivers. Hence now when some functions are not enabled, their i2c
 clients, regmaps and irqs are not registered.
 
 Because patches are under review for very long time and I still don't have
 all needed Acks, I'm resending this series rebased to the latest next branch.
 
 Best regards
 Robert Baldyga
 Samsung RD Institute Poland
 
 Changelog:
 
 v5:
 - rebase patches to last next branch
 
 v4:
 - remove patch moving regmap handling to function drivers
 
 v3: https://lkml.org/lkml/2014/3/13/101
 - fix error handling
 - fix deinitializations order
 - move muic irq enum values renaming to separate patch
 
 v2: https://lkml.org/lkml/2014/3/12/237
 - rebase patches on Lee Jones' MFD tree
 - add missing selects in Kconfig
 - add missing deinitializations
 - add interrupt disabling when suspend
 - few minor changes and typo fixes
 
 v1: https://lkml.org/lkml/2014/3/11/291
 
 Robert Baldyga (3):
   mfd: max8997: use regmap to access registers
   mfd: max8997: handle IRQs using regmap
   mfd: max8997: change irq names to upper case
 
  drivers/extcon/extcon-max8997.c |  66 +++---
  drivers/input/misc/max8997_haptic.c |  34 ++--
  drivers/leds/leds-max8997.c |  13 +-
  drivers/mfd/Kconfig |   3 +-
  drivers/mfd/Makefile|   2 +-
  drivers/mfd/max8997-irq.c   | 387 
 
  drivers/mfd/max8997.c   | 245 +++
  drivers/power/max8997_charger.c |  33 +--
  drivers/regulator/max8997.c |  87 
  drivers/rtc/rtc-max8997.c   |  58 +++---
  include/linux/mfd/max8997-private.h |  82 ++--
  11 files changed, 381 insertions(+), 629 deletions(-)
  delete mode 100644 drivers/mfd/max8997-irq.c
 

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Input: sun4i-ts: add thermal driver dependency

2015-01-28 Thread Arnd Bergmann
The sun4i-ts driver has had a dependency on the thermal code
since it was first merged, but this is not currently enforced
in Kconfig, so in some randconfig builds we get

drivers/built-in.o: In function `sun4i_ts_remove':
:(.text+0x2376f4): undefined reference to `thermal_zone_of_sensor_unregister'
drivers/built-in.o: In function `sun4i_ts_probe':
:(.text+0x237a94): undefined reference to `thermal_zone_of_sensor_register'
:(.text+0x237c00): undefined reference to `thermal_zone_of_sensor_unregister'

We need the dependency on THERMAL in order to ensure that this
driver becomes a loadable module if the thermal support itself
is modular, while the dependency on THERMAL_OF is a runtime dependency
and the driver will still build but not work if it is missing.

Signed-off-by: Arnd Bergmann a...@arndb.de
Fixes: 6decea7c5438e2 (Input: add driver for Allwinner sunxi SoC's rtp 
controller)

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 58917525126e..e2447f0063b7 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -943,6 +943,8 @@ config TOUCHSCREEN_SUN4I
tristate Allwinner sun4i resistive touchscreen controller support
depends on ARCH_SUNXI || COMPILE_TEST
depends on HWMON
+   depends on THERMAL
+   depends on THERMAL_OF || COMPILE_TEST
help
  This selects support for the resistive touchscreen controller
  found on Allwinner sunxi SoCs.

--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Input: sun4i-ts: add thermal driver dependency

2015-01-28 Thread Hans de Goede

Hi,

On 28-01-15 16:17, Arnd Bergmann wrote:

The sun4i-ts driver has had a dependency on the thermal code
since it was first merged,


The since it was first merged bit is not true, this is caused
by recent changes by ChenYu.

Other then that no objections from me against the proposed fix.

Regards,

Hans


 but this is not currently enforced

in Kconfig, so in some randconfig builds we get

drivers/built-in.o: In function `sun4i_ts_remove':
:(.text+0x2376f4): undefined reference to `thermal_zone_of_sensor_unregister'
drivers/built-in.o: In function `sun4i_ts_probe':
:(.text+0x237a94): undefined reference to `thermal_zone_of_sensor_register'
:(.text+0x237c00): undefined reference to `thermal_zone_of_sensor_unregister'

We need the dependency on THERMAL in order to ensure that this
driver becomes a loadable module if the thermal support itself
is modular, while the dependency on THERMAL_OF is a runtime dependency
and the driver will still build but not work if it is missing.

Signed-off-by: Arnd Bergmann a...@arndb.de
Fixes: 6decea7c5438e2 (Input: add driver for Allwinner sunxi SoC's rtp 
controller)

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 58917525126e..e2447f0063b7 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -943,6 +943,8 @@ config TOUCHSCREEN_SUN4I
tristate Allwinner sun4i resistive touchscreen controller support
depends on ARCH_SUNXI || COMPILE_TEST
depends on HWMON
+   depends on THERMAL
+   depends on THERMAL_OF || COMPILE_TEST
help
  This selects support for the resistive touchscreen controller
  found on Allwinner sunxi SoCs.


--
To unsubscribe from this list: send the line unsubscribe linux-input in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html