Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH 3/3] Input: 88pm860x-ts: fix child-node lookup
From: Dmitry Torokhov @ 2018-01-09  1:35 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-input, linux-kernel, stable, Haojian Zhuang
In-Reply-To: <20171111154339.16875-3-johan@kernel.org>

On Sat, Nov 11, 2017 at 04:43:39PM +0100, Johan Hovold wrote:
> Fix child node-lookup during probe, which ended up searching the whole
> device tree depth-first starting at parent rather than just matching on
> its children.
> 
> To make things worse, the parent node was prematurely freed, while the
> child node was leaked.
> 
> Fixes: 2e57d56747e6 ("mfd: 88pm860x: Device tree support")
> Cc: stable <stable@vger.kernel.org>     # 3.7
> Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied, thank you.

> ---
>  drivers/input/touchscreen/88pm860x-ts.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
> index 7ed828a51f4c..3486d9403805 100644
> --- a/drivers/input/touchscreen/88pm860x-ts.c
> +++ b/drivers/input/touchscreen/88pm860x-ts.c
> @@ -126,7 +126,7 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
>  	int data, n, ret;
>  	if (!np)
>  		return -ENODEV;
> -	np = of_find_node_by_name(np, "touch");
> +	np = of_get_child_by_name(np, "touch");
>  	if (!np) {
>  		dev_err(&pdev->dev, "Can't find touch node\n");
>  		return -EINVAL;
> @@ -144,13 +144,13 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
>  	if (data) {
>  		ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data);
>  		if (ret < 0)
> -			return -EINVAL;
> +			goto err_put_node;
>  	}
>  	/* set tsi prebias time */
>  	if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) {
>  		ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data);
>  		if (ret < 0)
> -			return -EINVAL;
> +			goto err_put_node;
>  	}
>  	/* set prebias & prechg time of pen detect */
>  	data = 0;
> @@ -161,10 +161,18 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
>  	if (data) {
>  		ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data);
>  		if (ret < 0)
> -			return -EINVAL;
> +			goto err_put_node;
>  	}
>  	of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x);
> +
> +	of_node_put(np);
> +
>  	return 0;
> +
> +err_put_node:
> +	of_node_put(np);
> +
> +	return -EINVAL;
>  }
>  #else
>  #define pm860x_touch_dt_init(x, y, z)	(-1)
> -- 
> 2.15.0
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 1/3] Input: twl4030-vibra: fix sibling-node lookup
From: Dmitry Torokhov @ 2018-01-09  1:36 UTC (permalink / raw)
  To: Johan Hovold
  Cc: linux-input, linux-kernel, stable, Peter Ujfalusi, Marek Belisko
In-Reply-To: <20180108135502.GF11344@localhost>

On Mon, Jan 08, 2018 at 02:55:02PM +0100, Johan Hovold wrote:
> On Mon, Dec 11, 2017 at 11:21:21AM +0100, Johan Hovold wrote:
> > On Sat, Nov 11, 2017 at 04:43:37PM +0100, Johan Hovold wrote:
> > > A helper purported to look up a child node based on its name was using
> > > the wrong of-helper and ended up prematurely freeing the parent of-node
> > > while searching the whole device tree depth-first starting at the parent
> > > node.
> > > 
> > > Fixes: 64b9e4d803b1 ("input: twl4030-vibra: Support for DT booted kernel")
> > > Fixes: e661d0a04462 ("Input: twl4030-vibra - fix ERROR: Bad of_node_put() warning")
> > > Cc: stable <stable@vger.kernel.org>     # 3.7
> > > Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > > Cc: Marek Belisko <marek@goldelico.com>
> > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > ---
> > 
> > Just wanted to send a reminder about this series. I believe these bugs
> > need to be fixes regardless of whether MFD-core eventually provides some
> > means of avoiding such lookups in cell drivers (i.e. the discussion
> > which appears to have stalled).
> 
> Another month, another reminder: Will you pick this series up for 4.16,
> Dmitry?

Sorry, I was hoping we'd have some movement in MFD... Applied all 3,
thank you.

-- 
Dmitry

^ permalink raw reply

* Re: [RFC PATCH] input: Add disable sysfs entry for every input device
From: Peter Hutterer @ 2018-01-09  1:51 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Bastien Nocera, Ivaylo Dimitrov, Dmitry Torokhov,
	Sebastian Reichel, Pavel Machek, Mauro Carvalho Chehab,
	Chuck Ebbert, Henrik Rydberg, linux-input, linux-kernel
In-Reply-To: <20170105124808.GF31083@pali>

On Thu, Jan 05, 2017 at 01:48:08PM +0100, Pali Rohár wrote:
> On Wednesday 04 January 2017 15:37:35 Bastien Nocera wrote:
> > On Wed, 2017-01-04 at 09:43 +0200, Ivaylo Dimitrov wrote:
> > > 
> > > On  3.01.2017 13:21, Bastien Nocera wrote:
> > > > On Mon, 2017-01-02 at 18:09 +0100, Pali Rohár wrote:
> > > > > On Monday 02 January 2017 16:27:05 Bastien Nocera wrote:
> > > > > > On Sun, 2016-12-25 at 11:04 +0100, Pali Rohár wrote:
> > > > > > > This patch allows user to disable events from any input
> > > > > > > device so
> > > > > > > events
> > > > > > > would not be delivered to userspace.
> > > > > > > 
> > > > > > > Currently there is no way to disable particular input device
> > > > > > > by
> > > > > > > kernel.
> > > > > > > User for different reasons would need it for integrated PS/2
> > > > > > > keyboard or
> > > > > > > touchpad in notebook or touchscreen on mobile device to
> > > > > > > prevent
> > > > > > > sending
> > > > > > > events. E.g. mobile phone in pocket or broken integrated PS/2
> > > > > > > keyboard.
> > > > > > > 
> > > > > > > This is just a RFC patch, not tested yet. Original post about
> > > > > > > motivation
> > > > > > > about this patch is there: https://lkml.org/lkml/2014/11/29/9
> > > > > > > 2
> > > > > > 
> > > > > > Having implemented something of that ilk in user-space (we
> > > > > > automatically disable touch devices when the associated screen
> > > > > > is
> > > > > > turned off/suspended), I think this might need more thought.
> > > > > 
> > > > > How to implement such thing in userspace? I think you cannot do
> > > > > that
> > > > > without rewriting every one userspace application which uses
> > > > > input.
> > > > > 
> > > > > > What happens when a device is opened and the device disabled
> > > > > 
> > > > > through
> > > > > > sysfs, are the users revoked?
> > > > > 
> > > > > Applications will not receive events. Same as if input device
> > > > > does
> > > > > not
> > > > > generates events.
> > > > > 
> > > > > > Does this put the device in suspend in the same way that
> > > > > > closing
> > > > > 
> > > > > the
> > > > > > device's last user does?
> > > > > 
> > > > > Current code not (this is just RFC prototype), but it should be
> > > > > possible
> > > > > to implement.
> > > > > 
> > > > > > Is this not better implemented in user-space at the session
> > > > > > level,
> > > > > > where it knows about which output corresponds to which input
> > > > > 
> > > > > device?
> > > > > 
> > > > > How to do that without rewriting existing applications?
> > > > > 
> > > > > > Is this useful enough to disable misbehaving devices on
> > > > > > hardware,
> > > > > 
> > > > > so
> > > > > > that the device is not effective on boot?
> > > > > 
> > > > > In case integrated device is absolutely unusable and generates
> > > > > always
> > > > > random events, it does not solve problem at boot time.
> > > > > 
> > > > > But more real case is laptop with closed LID press buttons and
> > > > > here
> > > > > it
> > > > > is useful.
> > > > 
> > > > There's usually a display manager in between the application and
> > > > the
> > > > input device. Whether it's X.org, or a Wayland compositor. Even
> > > > David's
> > > >  https://github.com/dvdhrm/kmscon could help for console
> > > > applications.
> > > > 
> > > 
> > > I think the use cases are not clearly explained, will try to:
> > > 
> > > 1. Imagine you have a mobile phone, with a touchscreen, a slide 
> > > keyboard, a keyboard-slide sensor, a proximity sensor and a couple of 
> > > GPIOs, set-up as gpio keys. And you want to carry that phone in your 
> > > pocket, without being worried that it will pick-up an incoming call by 
> > > itself while in the pocket, so:
> > > 
> > > - slide keyboard is closed, you "lock" the phone before put it in your 
> > > pocket - in that state, touchscreen and most of the gpio-keys should be 
> > > "disabled", so no touches are registered waking-up the device without need.
> > > - a call comes, proximity gets "enabled", but TS should stay disabled as 
> > > proximity detects "the phone is in a pocket"
> > > - you get your phone out of your pocket - proximity detects no more 
> > > obstacles, so now TS has to be enabled giving you a chance to pick up 
> > > the incoming call.
> > > 
> > > "disabling" of gpio-keys is clear, but how to make TS and proximity 
> > > inactive when needed? Sure, touches can be simply ignored (by using 
> > > xinput "Device Enabled" 0 on x11), same for proximity, but keep in mind 
> > > this is a battery-operated device, so we don't want CPU wake-ups with no 
> > > need.
> > 
> > I'm pretty certain that the libinput or evdev Xorg drivers would close
> > the underlying device so that it can go into power save.
> 
> When they close evdev device? At least I need to explicitly call xinput.

yeah, because setting that property is the way to tell X that we don't need
to listen for events on that device. so we close the fd. libinput has the
"send events" API which does the same in most cases.

the only other way to tell X that you don't care about events from devices
is to VT-switch away, then we also close all fds.

Cheers,
   Peter

> And Xorg and libinput are not only applications/libraries which uses
> linux evdev. There are more...
> 
> E.g. in case of N900 there is mce which is not doing it.
> 
> > FWIW, your example is incomplete, as you'd probably want the
> > touchscreen to be usable even if the keyboard is folded in by pressing
> > the power button, and using the touchscreen only.
> 
> Maybe with combination of ambient light sensor for detection if phone is
> in pocket or not...
> 
> > > 2. The same device, "locked", but this time with slide keyboard opened:
> > > 
> > > - both keyboard and TS should be "disabled" so no touches neither key 
> > > presses wake-up the system. Only the power-button (or some other, 
> > > doesn't matter) should be enabled to activate the device.
> > 
> > Which is what disabling the device in Xorg should do.
> 
> You are expecting here that only Xorg is used... which does not have to
> be truth (and in more cases really is not).
> 
> > > There are more use-cases similar to the above as well as use-cases for 
> > > laptops, but I hope you're getting the idea.
> > > 
> > > Also, the interface to "disable" an input devices should be independent 
> > > to whether you use X11, wayland or your application draws directly to 
> > > the framebuffer.
> > 
> > I implemented behaviour similar to those at the session level, using D-
> > Bus to gather data from the various sensors and peripherals. In
> > addition, it also knows about the state of the display, which you
> > wouldn't have available at another level. This also means that it works
> > as expected for multi-user setups (which I understand isn't your
> > concern).
> > 
> > I don't doubt that the use cases should be catered for, I essentially
> > did that same work without kernel changes for GNOME. What I doubt is
> > the fuzzy semantics, the fact that the device is kept opened but no
> > data is sent (that's not power saving), that whether users are revoked
> > or should be revoked isn't clear, and that the goal is basically to
> > work around stupid input handling when at the console. When running a
> > display manager, this is all avoided.
> > 
> > If this were to go through, then the semantics and behaviour needs to
> > be better explained, power saving actually made possible, and make sure
> > that libinput can proxy that state to the users on the console. Or an
> > ioctl added to the evdev device to disable them.
> 
> -- 
> Pali Rohár
> pali.rohar@gmail.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply

* Re: [RFC PATCH] input: Add disable sysfs entry for every input device
From: Peter Hutterer @ 2018-01-09  2:04 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Bastien Nocera, Dmitry Torokhov, Ivaylo Dimitrov,
	Sebastian Reichel, Pavel Machek, Mauro Carvalho Chehab,
	Chuck Ebbert, Henrik Rydberg, linux-input, linux-kernel
In-Reply-To: <20180103093133.u7wszegjk2msxryl@pali>

On Wed, Jan 03, 2018 at 10:31:33AM +0100, Pali Rohár wrote:
> On Wednesday 03 January 2018 02:47:29 Bastien Nocera wrote:
> > On Tue, 2018-01-02 at 22:54 +0100, Pali Rohár wrote:
> > > On Wednesday 04 January 2017 15:37:35 Bastien Nocera wrote:
> > > > I don't doubt that the use cases should be catered for, I
> > > > essentially
> > > > did that same work without kernel changes for GNOME. What I doubt
> > > > is
> > > > the fuzzy semantics, the fact that the device is kept opened but no
> > > > data is sent (that's not power saving), that whether users are
> > > > revoked
> > > > or should be revoked isn't clear, and that the goal is basically to
> > > > work around stupid input handling when at the console. When running
> > > > a
> > > > display manager, this is all avoided.
> > > > 
> > > > If this were to go through, then the semantics and behaviour needs
> > > > to
> > > > be better explained, power saving actually made possible, and make
> > > > sure
> > > > that libinput can proxy that state to the users on the console. Or
> > > > an
> > > > ioctl added to the evdev device to disable them.
> > > 
> > > So, do you mean to implement this "disable" action as ioctl for
> > > particular /dev/input/event* device (instead of sysfs entry)?
> > 
> > Yes, so the device can be powered down without the device node being
> > closed and made unavailable. I don't know whether that's something
> > that's already possible for all cases, but there's already
> > opportunistic in a lot of drivers and subsystems.
> > 
> > This opens up a whole new wave of potential problems, but it's a more
> > generally useful mechanism, I would think.
> 
> Ok. How should API for this ioctl looks like? And do you have an idea
> for name of that ioctl?
> 
> Dmitry, what do you think about it? It is acceptable for you?

first: sysfs files are pretty terrible because writing to them requires root
and we don't have the benefit of logind. so for any sysfs toggle expect
a nicely integrated userspace solution to be less than optimal.

besides: 99% of the above is figuring out the policy *when* to disable the
device. disabling it is trivial by just closing the evdev nodes and tbh I
don't think we (in userspace) should care about whether the device is
powered down or now, it should be the default assumption that it is powered
down when not in use.

for the cases where you must keep the device open but you don't want events, 
EVIOCSMASK is likely the best solution. improving the kernel so it powers
down the device when the mask excludes all events (and there are no other
listeners) could be an interesting task.

right now, I really question the need for another ioctl.

Cheers,
   Peter

^ permalink raw reply

* Re: [PATCH] Input: stmfts,s6sy671 - add SPDX identifier
From: Andi Shyti @ 2018-01-09  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Andi Shyti, Philippe Ombredanne
In-Reply-To: <20180105164958.csojn6vhy72bwoac@dtor-ws>

Hi Dmitry,

On Fri, Jan 05, 2018 at 08:49:58AM -0800, Dmitry Torokhov wrote:
> Hi Andi,
> 
> On Fri, Jan 05, 2018 at 06:57:15PM +0900, Andi Shyti wrote:
> > Hi Dmitry,
> > 
> > this is a kind ping, would you also mind giving me a feedback to
> 
> Yes, sorry. Could you please split the patch for each driver
> individually? Also, until we have an update to the CodingStyle doc
> mandating the C++ style comments, I'd prefer keeping the original style
> of comments. So // for the SPDX line and /* */ for the rest.

I was actually following Linus guideline [1] [2]. I also had the
same discussion previously in another context [3].

Please let me know if you still want a mixed style of comments in
the next patch.

Thanks,
Andi

[1] https://marc.info/?l=linux-kernel&m=151163713125320&w=2
    ...
    └-> https://marc.info/?l=linux-kernel&m=151163867325641&w=2
        ...
        └-> https://marc.info/?l=linux-kernel&m=151163867325641&w=2

[2] https://marc.info/?l=linux-kernel&m=150964359922353
[3] https://marc.info/?l=linux-kernel&m=151312974503109&w=2

^ permalink raw reply

* Re: [PATCH 1/3] Input: twl4030-vibra: fix sibling-node lookup
From: Johan Hovold @ 2018-01-09  9:21 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Johan Hovold, linux-input, linux-kernel, stable, Peter Ujfalusi,
	Marek Belisko
In-Reply-To: <20180109013638.vjeou77idumazgcq@dtor-ws>

On Mon, Jan 08, 2018 at 05:36:38PM -0800, Dmitry Torokhov wrote:
> On Mon, Jan 08, 2018 at 02:55:02PM +0100, Johan Hovold wrote:
> > On Mon, Dec 11, 2017 at 11:21:21AM +0100, Johan Hovold wrote:
> > > On Sat, Nov 11, 2017 at 04:43:37PM +0100, Johan Hovold wrote:
> > > > A helper purported to look up a child node based on its name was using
> > > > the wrong of-helper and ended up prematurely freeing the parent of-node
> > > > while searching the whole device tree depth-first starting at the parent
> > > > node.
> > > > 
> > > > Fixes: 64b9e4d803b1 ("input: twl4030-vibra: Support for DT booted kernel")
> > > > Fixes: e661d0a04462 ("Input: twl4030-vibra - fix ERROR: Bad of_node_put() warning")
> > > > Cc: stable <stable@vger.kernel.org>     # 3.7
> > > > Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > > > Cc: Marek Belisko <marek@goldelico.com>
> > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > ---
> > > 
> > > Just wanted to send a reminder about this series. I believe these bugs
> > > need to be fixes regardless of whether MFD-core eventually provides some
> > > means of avoiding such lookups in cell drivers (i.e. the discussion
> > > which appears to have stalled).
> > 
> > Another month, another reminder: Will you pick this series up for 4.16,
> > Dmitry?
> 
> Sorry, I was hoping we'd have some movement in MFD... Applied all 3,
> thank you.

No worries. The MFD changes can be done as follow-ons (when people can
find some spare cycles). I agree with the general direction.

Thanks,
Johan

^ permalink raw reply

* Loan & Project Funding
From: Abdul Mohammed Suleman @ 2018-01-09  9:41 UTC (permalink / raw)


Good day,

I give loans to private and public organizations at very low and
considerate interest rates with flexible Loan Terms and conditions.

Contact me if interested.

Best regards,
Mr. Abdul

^ permalink raw reply

* [PATCH] HID: uhid: use strlcpy() instead of strncpy()
From: Xiongfeng Wang @ 2018-01-09 12:23 UTC (permalink / raw)
  To: benjamin.tissoires, jikos; +Cc: linux-input, linux-kernel, wangxiongfeng2

From: Xiongfeng Wang <xiongfeng.wang@linaro.org>

gcc-8 reports

drivers/hid/uhid.c: In function 'uhid_dev_create2':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' output may
be truncated copying 127 bytes from a string of length 127
[-Wstringop-truncation]

The compiler require that the input param 'len' of strncpy() should be
greater than the length of the src string, so that '\0' is copied as
well. We can just use strlcpy() to avoid this warning.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
---
 drivers/hid/uhid.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 6f819f1..0315ddd 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -496,12 +496,12 @@ static int uhid_dev_create2(struct uhid_device *uhid,
 		goto err_free;
 	}
 
-	len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1;
-	strncpy(hid->name, ev->u.create2.name, len);
-	len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)) - 1;
-	strncpy(hid->phys, ev->u.create2.phys, len);
-	len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)) - 1;
-	strncpy(hid->uniq, ev->u.create2.uniq, len);
+	len = min(sizeof(hid->name), sizeof(ev->u.create2.name));
+	strlcpy(hid->name, ev->u.create2.name, len);
+	len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys));
+	strlcpy(hid->phys, ev->u.create2.phys, len);
+	len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq));
+	strlcpy(hid->uniq, ev->u.create2.uniq, len);
 
 	hid->ll_driver = &uhid_hid_driver;
 	hid->bus = ev->u.create2.bus;
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH resend v4] Input: silead - Add support for capactive home button
From: Hans de Goede @ 2018-01-09 14:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Benjamin Tissoires; +Cc: Hans de Goede, linux-input

Hi Dmitry,

Now that this patch has an ack from Rob for the DT bits, this is ready
to be queued up for 4.16 AFAICT.

Regards,

Hans

^ permalink raw reply

* [PATCH resend v4] Input: silead - Add support for capactive home button found on some x86 tablets
From: Hans de Goede @ 2018-01-09 14:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Benjamin Tissoires
  Cc: Hans de Goede, linux-input, Rob Herring
In-Reply-To: <20180109143054.20963-1-hdegoede@redhat.com>

On some x86 tablets with a silead touchscreen the windows logo on the
front is a capacitive home button. Touching this button results in a touch
with bits 12-15 of the Y coordinates set, while normally only the lower 12
are used.

Detect this and report a KEY_LEFTMETA press when this happens. Note for
now we only respond to the Y coordinate bits 12-15 containing 0x01, on some
tablets *without* a capacative button I've noticed these bits containing
0x04 when crossing the edges of the screen.

Cc: Rob Herring <robh+dt@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Only enable support for the home-button if a "silead,home-button"
 boolean device-property is set on the device

Changes in v3:
-Document the new silead,home-button property in:
 Documentation/devicetree/bindings/input/touchscreen/goodix.txt

Changes in v4:
-Add Rob's Acked-by for the DT binding
---
 .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 +
 drivers/input/touchscreen/silead.c                 | 46 ++++++++++++++++------
 2 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
index 6aa625e0cb8d..84752de12412 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
@@ -23,6 +23,8 @@ Optional properties:
 - touchscreen-inverted-y  : See touchscreen.txt
 - touchscreen-swapped-x-y : See touchscreen.txt
 - silead,max-fingers	  : maximum number of fingers the touchscreen can detect
+- silead,home-button	  : Boolean, set to true on devices which have a
+			    capacitive home-button build into the touchscreen
 - vddio-supply		  : regulator phandle for controller VDDIO
 - avdd-supply		  : regulator phandle for controller AVDD
 
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index 531f22891462..ff7043f74a3d 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -56,7 +56,7 @@
 #define SILEAD_POINT_Y_MSB_OFF	0x01
 #define SILEAD_POINT_X_OFF	0x02
 #define SILEAD_POINT_X_MSB_OFF	0x03
-#define SILEAD_TOUCH_ID_MASK	0xF0
+#define SILEAD_EXTRA_DATA_MASK	0xF0
 
 #define SILEAD_CMD_SLEEP_MIN	10000
 #define SILEAD_CMD_SLEEP_MAX	20000
@@ -109,6 +109,9 @@ static int silead_ts_request_input_dev(struct silead_ts_data *data)
 			    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED |
 			    INPUT_MT_TRACK);
 
+	if (device_property_read_bool(dev, "silead,home-button"))
+		input_set_capability(data->input, EV_KEY, KEY_LEFTMETA);
+
 	data->input->name = SILEAD_TS_NAME;
 	data->input->phys = "input/ts";
 	data->input->id.bustype = BUS_I2C;
@@ -139,7 +142,8 @@ static void silead_ts_read_data(struct i2c_client *client)
 	struct input_dev *input = data->input;
 	struct device *dev = &client->dev;
 	u8 *bufp, buf[SILEAD_TS_DATA_LEN];
-	int touch_nr, error, i;
+	int touch_nr, softbutton, error, i;
+	bool softbutton_pressed = false;
 
 	error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_DATA,
 					      SILEAD_TS_DATA_LEN, buf);
@@ -148,21 +152,40 @@ static void silead_ts_read_data(struct i2c_client *client)
 		return;
 	}
 
-	touch_nr = buf[0];
-	if (touch_nr > data->max_fingers) {
+	if (buf[0] > data->max_fingers) {
 		dev_warn(dev, "More touches reported then supported %d > %d\n",
-			 touch_nr, data->max_fingers);
-		touch_nr = data->max_fingers;
+			 buf[0], data->max_fingers);
+		buf[0] = data->max_fingers;
 	}
 
+	touch_nr = 0;
 	bufp = buf + SILEAD_POINT_DATA_LEN;
-	for (i = 0; i < touch_nr; i++, bufp += SILEAD_POINT_DATA_LEN) {
-		/* Bits 4-7 are the touch id */
-		data->id[i] = (bufp[SILEAD_POINT_X_MSB_OFF] &
-			       SILEAD_TOUCH_ID_MASK) >> 4;
-		touchscreen_set_mt_pos(&data->pos[i], &data->prop,
+	for (i = 0; i < buf[0]; i++, bufp += SILEAD_POINT_DATA_LEN) {
+		softbutton = (bufp[SILEAD_POINT_Y_MSB_OFF] &
+			      SILEAD_EXTRA_DATA_MASK) >> 4;
+
+		if (softbutton) {
+			/*
+			 * For now only respond to softbutton == 0x01, some
+			 * tablets *without* a capacative button send 0x04
+			 * when crossing the edges of the screen.
+			 */
+			if (softbutton == 0x01)
+				softbutton_pressed = true;
+
+			continue;
+		}
+
+		/*
+		 * Bits 4-7 are the touch id, note not all models have
+		 * hardware touch ids so atm we don't use these.
+		 */
+		data->id[touch_nr] = (bufp[SILEAD_POINT_X_MSB_OFF] &
+				      SILEAD_EXTRA_DATA_MASK) >> 4;
+		touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop,
 			get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff,
 			get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff);
+		touch_nr++;
 	}
 
 	input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0);
@@ -178,6 +201,7 @@ static void silead_ts_read_data(struct i2c_client *client)
 	}
 
 	input_mt_sync_frame(input);
+	input_report_key(input, KEY_LEFTMETA, softbutton_pressed);
 	input_sync(input);
 }
 
-- 
2.14.3


^ permalink raw reply related

* Re: [PATCH] HID: asus: only support backlight when it's not driven by WMI
From: Andy Shevchenko @ 2018-01-09 19:32 UTC (permalink / raw)
  To: Daniel Drake
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input,
	Linux Upstreaming Team, Carlo Caione, Corentin Chary,
	acpi4asus-user, Platform Driver
In-Reply-To: <20180109012042.13947-1-drake@endlessm.com>

On Tue, Jan 9, 2018 at 3:20 AM, Daniel Drake <drake@endlessm.com> wrote:
> The Asus GL502VSK has the same 0B05:1837 keyboard as we've seen in
> several Republic of Gamers laptops.
>
> However, in this model, the keybard backlight control exposed by hid-asus
> has no effect on the keyboard backlight. Instead, the keyboard
> backlight is correctly driven by asus-wmi.
>
> With two keyboard backlight devices available (and only the acer-wmi
> one working), GNOME is picking the wrong one to drive in the UI.
>
> Avoid this problem by not creating the backlight interface when we
> detect a WMI-driven keyboard backlight.
>
> We have also tested Asus GL702VMK which does have the hid-asus
> backlight present, and it still works fine with this patch (WMI method
> call returns UNSUPPORTED_METHOD).

>  config HID_ASUS
>         tristate "Asus"
>         depends on LEDS_CLASS
> +       depends on ACPI_WMI

No, for sure.
Imagine someone who on possession of laptop where it's not needed
having old kernel configuration.
Building new kernel with old configuration will bring a regression.

Selection is also not a solution since we don't need all crap in
kernel because of some particular case.

So, NO.

> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c

> +#define ASUS_WMI_MGMT_GUID             "97845ED0-4E6D-11DE-8A39-0800200C9A66"
> +#define ASUS_WMI_METHODID_DSTS2                0x53545344 /* Device STatuS #2*/
> +#define ASUS_WMI_DEVID_KBD_BACKLIGHT   0x00050021
> +#define ASUS_WMI_UNSUPPORTED_METHOD    0xFFFFFFFE
> +#define ASUS_WMI_DSTS_PRESENCE_BIT     0x00010000

> +/* WMI-based keyboard backlight LED control (via asus-wmi driver) takes
> + * precedence. We only activate HID-based backlight control when the
> + * WMI control is not available.
> + */
> +static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
> +{

> +}

I have feelings that the code above should be located somewhere under
drivers/platform/x86.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply

* Re: [PATCH resend v4] Input: silead - Add support for capactive home button found on some x86 tablets
From: Dmitry Torokhov @ 2018-01-09 19:41 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Benjamin Tissoires, linux-input, Rob Herring
In-Reply-To: <20180109143054.20963-2-hdegoede@redhat.com>

On Tue, Jan 09, 2018 at 03:30:54PM +0100, Hans de Goede wrote:
> On some x86 tablets with a silead touchscreen the windows logo on the
> front is a capacitive home button. Touching this button results in a touch
> with bits 12-15 of the Y coordinates set, while normally only the lower 12
> are used.
> 
> Detect this and report a KEY_LEFTMETA press when this happens. Note for
> now we only respond to the Y coordinate bits 12-15 containing 0x01, on some
> tablets *without* a capacative button I've noticed these bits containing
> 0x04 when crossing the edges of the screen.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

> ---
> Changes in v2:
> -Only enable support for the home-button if a "silead,home-button"
>  boolean device-property is set on the device
> 
> Changes in v3:
> -Document the new silead,home-button property in:
>  Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> 
> Changes in v4:
> -Add Rob's Acked-by for the DT binding
> ---
>  .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 +
>  drivers/input/touchscreen/silead.c                 | 46 ++++++++++++++++------
>  2 files changed, 37 insertions(+), 11 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> index 6aa625e0cb8d..84752de12412 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
> @@ -23,6 +23,8 @@ Optional properties:
>  - touchscreen-inverted-y  : See touchscreen.txt
>  - touchscreen-swapped-x-y : See touchscreen.txt
>  - silead,max-fingers	  : maximum number of fingers the touchscreen can detect
> +- silead,home-button	  : Boolean, set to true on devices which have a
> +			    capacitive home-button build into the touchscreen
>  - vddio-supply		  : regulator phandle for controller VDDIO
>  - avdd-supply		  : regulator phandle for controller AVDD
>  
> diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
> index 531f22891462..ff7043f74a3d 100644
> --- a/drivers/input/touchscreen/silead.c
> +++ b/drivers/input/touchscreen/silead.c
> @@ -56,7 +56,7 @@
>  #define SILEAD_POINT_Y_MSB_OFF	0x01
>  #define SILEAD_POINT_X_OFF	0x02
>  #define SILEAD_POINT_X_MSB_OFF	0x03
> -#define SILEAD_TOUCH_ID_MASK	0xF0
> +#define SILEAD_EXTRA_DATA_MASK	0xF0
>  
>  #define SILEAD_CMD_SLEEP_MIN	10000
>  #define SILEAD_CMD_SLEEP_MAX	20000
> @@ -109,6 +109,9 @@ static int silead_ts_request_input_dev(struct silead_ts_data *data)
>  			    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED |
>  			    INPUT_MT_TRACK);
>  
> +	if (device_property_read_bool(dev, "silead,home-button"))
> +		input_set_capability(data->input, EV_KEY, KEY_LEFTMETA);
> +
>  	data->input->name = SILEAD_TS_NAME;
>  	data->input->phys = "input/ts";
>  	data->input->id.bustype = BUS_I2C;
> @@ -139,7 +142,8 @@ static void silead_ts_read_data(struct i2c_client *client)
>  	struct input_dev *input = data->input;
>  	struct device *dev = &client->dev;
>  	u8 *bufp, buf[SILEAD_TS_DATA_LEN];
> -	int touch_nr, error, i;
> +	int touch_nr, softbutton, error, i;
> +	bool softbutton_pressed = false;
>  
>  	error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_DATA,
>  					      SILEAD_TS_DATA_LEN, buf);
> @@ -148,21 +152,40 @@ static void silead_ts_read_data(struct i2c_client *client)
>  		return;
>  	}
>  
> -	touch_nr = buf[0];
> -	if (touch_nr > data->max_fingers) {
> +	if (buf[0] > data->max_fingers) {
>  		dev_warn(dev, "More touches reported then supported %d > %d\n",
> -			 touch_nr, data->max_fingers);
> -		touch_nr = data->max_fingers;
> +			 buf[0], data->max_fingers);
> +		buf[0] = data->max_fingers;
>  	}
>  
> +	touch_nr = 0;
>  	bufp = buf + SILEAD_POINT_DATA_LEN;
> -	for (i = 0; i < touch_nr; i++, bufp += SILEAD_POINT_DATA_LEN) {
> -		/* Bits 4-7 are the touch id */
> -		data->id[i] = (bufp[SILEAD_POINT_X_MSB_OFF] &
> -			       SILEAD_TOUCH_ID_MASK) >> 4;
> -		touchscreen_set_mt_pos(&data->pos[i], &data->prop,
> +	for (i = 0; i < buf[0]; i++, bufp += SILEAD_POINT_DATA_LEN) {
> +		softbutton = (bufp[SILEAD_POINT_Y_MSB_OFF] &
> +			      SILEAD_EXTRA_DATA_MASK) >> 4;
> +
> +		if (softbutton) {
> +			/*
> +			 * For now only respond to softbutton == 0x01, some
> +			 * tablets *without* a capacative button send 0x04
> +			 * when crossing the edges of the screen.
> +			 */
> +			if (softbutton == 0x01)
> +				softbutton_pressed = true;
> +
> +			continue;
> +		}
> +
> +		/*
> +		 * Bits 4-7 are the touch id, note not all models have
> +		 * hardware touch ids so atm we don't use these.
> +		 */
> +		data->id[touch_nr] = (bufp[SILEAD_POINT_X_MSB_OFF] &
> +				      SILEAD_EXTRA_DATA_MASK) >> 4;
> +		touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop,
>  			get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff,
>  			get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff);
> +		touch_nr++;
>  	}
>  
>  	input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0);
> @@ -178,6 +201,7 @@ static void silead_ts_read_data(struct i2c_client *client)
>  	}
>  
>  	input_mt_sync_frame(input);
> +	input_report_key(input, KEY_LEFTMETA, softbutton_pressed);
>  	input_sync(input);
>  }
>  
> -- 
> 2.14.3
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] HID: asus: only support backlight when it's not driven by WMI
From: Daniel Drake @ 2018-01-09 19:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input,
	Linux Upstreaming Team, Carlo Caione, Corentin Chary,
	acpi4asus-user, Platform Driver
In-Reply-To: <CAHp75Veyrzh+gV_8ff7TRqWpVx4h+2Qg05j9OpNXCH+E1+hsQg@mail.gmail.com>

On Tue, Jan 9, 2018 at 1:32 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> Imagine someone who on possession of laptop where it's not needed
> having old kernel configuration.
> Building new kernel with old configuration will bring a regression.
>
> Selection is also not a solution since we don't need all crap in
> kernel because of some particular case.
>
> So, NO.

If I can't use depends nor select, then what options are left? What
alternative solutions do you have in mind?

Thanks
Daniel

^ permalink raw reply

* Re: [PATCH] Input: cyapa - remove duplicated macro definitions
From: Dmitry Torokhov @ 2018-01-09 19:46 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: linux-input, linux-kernel
In-Reply-To: <20180108215402.25612-1-linux@rasmusvillemoes.dk>

On Mon, Jan 08, 2018 at 10:54:02PM +0100, Rasmus Villemoes wrote:
> Apart from whitespace differences, this block of macros is repeated
> twice:
> 
> $ x=./drivers/input/mouse/cyapa_gen3.c; diff -w -u <(sed -n '139,181p' $x) <(sed -n '182,224p' $x)
> $
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Applied, thank you.

> ---
>  drivers/input/mouse/cyapa_gen3.c | 43 ----------------------------------------
>  1 file changed, 43 deletions(-)
> 
> diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c
> index 1cbfa4a6e830..076dda4a66da 100644
> --- a/drivers/input/mouse/cyapa_gen3.c
> +++ b/drivers/input/mouse/cyapa_gen3.c
> @@ -136,49 +136,6 @@ static const u8 bl_exit[] = { 0x00, 0xff, 0xa5, 0x00, 0x01, 0x02, 0x03, 0x04,
>  		0x05, 0x06, 0x07 };
>  
>  
> - /* for byte read/write command */
> -#define CMD_RESET      0
> -#define CMD_POWER_MODE 1
> -#define CMD_DEV_STATUS 2
> -#define CMD_REPORT_MAX_BASELINE 3
> -#define CMD_REPORT_MIN_BASELINE 4
> -#define SMBUS_BYTE_CMD(cmd) (((cmd) & 0x3f) << 1)
> -#define CYAPA_SMBUS_RESET         SMBUS_BYTE_CMD(CMD_RESET)
> -#define CYAPA_SMBUS_POWER_MODE    SMBUS_BYTE_CMD(CMD_POWER_MODE)
> -#define CYAPA_SMBUS_DEV_STATUS    SMBUS_BYTE_CMD(CMD_DEV_STATUS)
> -#define CYAPA_SMBUS_MAX_BASELINE  SMBUS_BYTE_CMD(CMD_REPORT_MAX_BASELINE)
> -#define CYAPA_SMBUS_MIN_BASELINE  SMBUS_BYTE_CMD(CMD_REPORT_MIN_BASELINE)
> -
> - /* for group registers read/write command */
> -#define REG_GROUP_DATA 0
> -#define REG_GROUP_CMD 2
> -#define REG_GROUP_QUERY 3
> -#define SMBUS_GROUP_CMD(grp) (0x80 | (((grp) & 0x07) << 3))
> -#define CYAPA_SMBUS_GROUP_DATA	 SMBUS_GROUP_CMD(REG_GROUP_DATA)
> -#define CYAPA_SMBUS_GROUP_CMD	 SMBUS_GROUP_CMD(REG_GROUP_CMD)
> -#define CYAPA_SMBUS_GROUP_QUERY	 SMBUS_GROUP_CMD(REG_GROUP_QUERY)
> -
> - /* for register block read/write command */
> -#define CMD_BL_STATUS 0
> -#define CMD_BL_HEAD 1
> -#define CMD_BL_CMD 2
> -#define CMD_BL_DATA 3
> -#define CMD_BL_ALL 4
> -#define CMD_BLK_PRODUCT_ID 5
> -#define CMD_BLK_HEAD 6
> -#define SMBUS_BLOCK_CMD(cmd) (0xc0 | (((cmd) & 0x1f) << 1))
> -
> -/* register block read/write command in bootloader mode */
> -#define CYAPA_SMBUS_BL_STATUS  SMBUS_BLOCK_CMD(CMD_BL_STATUS)
> -#define CYAPA_SMBUS_BL_HEAD    SMBUS_BLOCK_CMD(CMD_BL_HEAD)
> -#define CYAPA_SMBUS_BL_CMD     SMBUS_BLOCK_CMD(CMD_BL_CMD)
> -#define CYAPA_SMBUS_BL_DATA    SMBUS_BLOCK_CMD(CMD_BL_DATA)
> -#define CYAPA_SMBUS_BL_ALL     SMBUS_BLOCK_CMD(CMD_BL_ALL)
> -
> -/* register block read/write command in operational mode */
> -#define CYAPA_SMBUS_BLK_PRODUCT_ID SMBUS_BLOCK_CMD(CMD_BLK_PRODUCT_ID)
> -#define CYAPA_SMBUS_BLK_HEAD SMBUS_BLOCK_CMD(CMD_BLK_HEAD)
> -
>   /* for byte read/write command */
>  #define CMD_RESET 0
>  #define CMD_POWER_MODE 1
> -- 
> 2.15.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] HID: asus: only support backlight when it's not driven by WMI
From: Andy Shevchenko @ 2018-01-09 19:58 UTC (permalink / raw)
  To: Daniel Drake
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input,
	Linux Upstreaming Team, Carlo Caione, Corentin Chary,
	acpi4asus-user, Platform Driver
In-Reply-To: <CAD8Lp46gbny3mV2CgWnrJnEpZpNo-P-GgKA5-DypykbmGoUhQg@mail.gmail.com>

On Tue, Jan 9, 2018 at 9:41 PM, Daniel Drake <drake@endlessm.com> wrote:
> On Tue, Jan 9, 2018 at 1:32 PM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
>> Imagine someone who on possession of laptop where it's not needed
>> having old kernel configuration.
>> Building new kernel with old configuration will bring a regression.
>>
>> Selection is also not a solution since we don't need all crap in
>> kernel because of some particular case.
>>
>> So, NO.
>
> If I can't use depends nor select, then what options are left? What
> alternative solutions do you have in mind?

If you would able to move code under corresponding WMI driver, make it
use any means of autodetection (it looks like you found a way via
checking return code of method call) and
then rely on distributions that they enable necessary modules
(HID_ASUS, ASUS_WMI or alike).

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply

* Re: [PATCH] synaptics: fix rmi4 bus dependencies
From: Dmitry Torokhov @ 2018-01-09 22:19 UTC (permalink / raw)
  To: Andrew Duggan; +Cc: Matteo Croce, linux-input
In-Reply-To: <204b8c3f-ec33-4400-33ff-fe39e9ca5702@synaptics.com>

On Tue, Jan 02, 2018 at 11:37:07AM -0800, Andrew Duggan wrote:
> On 01/02/2018 11:21 AM, Dmitry Torokhov wrote:
> > On Tue, Jan 02, 2018 at 08:16:09PM +0100, Matteo Croce wrote:
> > > Make MOUSE_PS2_SYNAPTICS_SMBUS select MOUSE_PS2_SYNAPTICS because if
> > > the latter is disabled the detection and switching code isn't being run.
> > Hmm, it should. In synaptics.c:
> > 
> > #if defined(CONFIG_MOUSE_PS2_SYNAPTICS) || \
> >      defined(CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS)
> > 
> > int synaptics_init(struct psmouse *psmouse)
> > {
> > 	struct synaptics_device_info info;
> > 	int error;
> > 	int retval;
> > 
> > 	psmouse_reset(psmouse);
> > ...
> > }
> > 
> > The intent was to allow disabling the PS/2 portion of Synaptics driver
> > while retaining the switching to SMbus capability.
> 
> Oh, I suggested to Matteo that this patch might be needed off list. I
> clearly didn't look closely enough to see that MOUSE_PS2_SYNAPTICS_SMBUS is
> intended to be able to be used independently of MOUSE_PS2_SYNAPTICS.
> 
> However, he did seem to see behavior where the mode switch did not occur
> when MOUSE_PS2_SYNAPTICS was disabled, but MOUSE_PS2_SYNAPTICS_SMBUS was
> enabled. That will need to be investigated further.

OK, I see what the problem is. Could you please try the version below?

Thanks.

-- 
Dmitry


Input: psmouse - fix Synaptics detection when protocol is disabled

When Synaptics protocol is disabled, we still need to ytry and detect the
hardware, so we can switch to SMBus device if SMbus is detected, or we know
that it is Synaptics device and reset it properly for the bare PS/2
protocol.

Fixes: c378b5119eb0 ("Input: psmouse - factor out common protocol probing code")
Reported-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/mouse/psmouse-base.c |   34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index f3eb407a3b7d..cbe12671f784 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -984,6 +984,21 @@ static void psmouse_apply_defaults(struct psmouse *psmouse)
 	psmouse->pt_deactivate = NULL;
 }
 
+static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool),
+			      struct psmouse *psmouse, bool allow_passthrough,
+			      bool set_properties)
+{
+	if (psmouse->ps2dev.serio->id.type == SERIO_PS_PSTHRU &&
+	    !allow_passthrough) {
+		return false;
+	}
+
+	if (set_properties)
+		psmouse_apply_defaults(psmouse);
+
+	return detect(psmouse, set_properties) == 0;
+}
+
 static bool psmouse_try_protocol(struct psmouse *psmouse,
 				 enum psmouse_type type,
 				 unsigned int *max_proto,
@@ -995,15 +1010,8 @@ static bool psmouse_try_protocol(struct psmouse *psmouse,
 	if (!proto)
 		return false;
 
-	if (psmouse->ps2dev.serio->id.type == SERIO_PS_PSTHRU &&
-	    !proto->try_passthru) {
-		return false;
-	}
-
-	if (set_properties)
-		psmouse_apply_defaults(psmouse);
-
-	if (proto->detect(psmouse, set_properties) != 0)
+	if (!psmouse_do_detect(proto->detect, psmouse, proto->try_passthru,
+			       set_properties))
 		return false;
 
 	if (set_properties && proto->init && init_allowed) {
@@ -1036,8 +1044,8 @@ static int psmouse_extensions(struct psmouse *psmouse,
 	 * Always check for focaltech, this is safe as it uses pnp-id
 	 * matching.
 	 */
-	if (psmouse_try_protocol(psmouse, PSMOUSE_FOCALTECH,
-				 &max_proto, set_properties, false)) {
+	if (psmouse_do_detect(focaltech_detect,
+			      psmouse, false, set_properties)) {
 		if (max_proto > PSMOUSE_IMEX &&
 		    IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) &&
 		    (!set_properties || focaltech_init(psmouse) == 0)) {
@@ -1083,8 +1091,8 @@ static int psmouse_extensions(struct psmouse *psmouse,
 	 * probing for IntelliMouse.
 	 */
 	if (max_proto > PSMOUSE_PS2 &&
-	    psmouse_try_protocol(psmouse, PSMOUSE_SYNAPTICS, &max_proto,
-				 set_properties, false)) {
+	    psmouse_do_detect(synaptics_detect,
+			      psmouse, false, set_properties)) {
 		synaptics_hardware = true;
 
 		if (max_proto > PSMOUSE_IMEX) {

^ permalink raw reply related

* [RFC PATCH] Fix modifier keys for Redragon Asura Keyboard
From: Robert Munteanu @ 2018-01-10  9:23 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Benjamin Tissoires, linux-kernel, linux-input, Robert Munteanu

The microdia family of keyboards uses a non-standard way of sending
modifier keys.

The down event always sets the first bit to 0x04 and the second keycode
to a custom value For instance, left shift sends the following bits

  04 02 00 00 00 00 00 00

while left control sends

  04 01 00 00 00 00 00 00

As a result all modifier keys are mapped to left shift and the keyboard is
non-functional in that respect. To solve the problem, we capture the
raw data in raw_event and manually generate the correct input events.

The keyboard functions mostly as expected now, with only a few minor
issues:

- two USB devices are detected instead of 1
- some key combinations are not triggered - e.g.
  left shift + left ctrl + p. However, the same combination is recognized
  with the right shift key.

Tested on Kernel 4.14.12

Changelog:

- v2: modifier keys work, some combinations are still troublesome
- v3: style cleanup, rebase on top of 4.14

Signed-off-by: Robert Munteanu <rombert@apache.org>
---
 drivers/hid/Kconfig        |   9 +++
 drivers/hid/Makefile       |   2 +-
 drivers/hid/hid-core.c     |   3 +
 drivers/hid/hid-ids.h      |   3 +
 drivers/hid/hid-microdia.c | 178 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 194 insertions(+), 1 deletion(-)
 create mode 100644 drivers/hid/hid-microdia.c

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 374301fcbc86..0033a81f0ad4 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -548,6 +548,15 @@ config HID_MAYFLASH
 	Say Y here if you have HJZ Mayflash PS3 game controller adapters
 	and want to enable force feedback support.
 
+config HID_MICRODIA
+	tristate "Microdia based keyboards"
+	depends on HID
+	default !EXPERT
+	---help---
+    Support for Microdia devices that are not compliant with the HID standard.
+
+    One known example if the Redragon Asura Keyboard.
+
 config HID_MICROSOFT
 	tristate "Microsoft non-fully HID-compliant devices"
 	depends on HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 235bd2a7b333..e66a305876c5 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_HID_LOGITECH_DJ)	+= hid-logitech-dj.o
 obj-$(CONFIG_HID_LOGITECH_HIDPP)	+= hid-logitech-hidpp.o
 obj-$(CONFIG_HID_MAGICMOUSE)	+= hid-magicmouse.o
 obj-$(CONFIG_HID_MAYFLASH)	+= hid-mf.o
+obj-$(CONFIG_HID_MICRODIA)  += hid-microdia.o
 obj-$(CONFIG_HID_MICROSOFT)	+= hid-microsoft.o
 obj-$(CONFIG_HID_MONTEREY)	+= hid-monterey.o
 obj-$(CONFIG_HID_MULTITOUCH)	+= hid-multitouch.o
@@ -121,4 +122,3 @@ obj-$(CONFIG_USB_KBD)		+= usbhid/
 
 obj-$(CONFIG_I2C_HID)		+= i2c-hid/
 
-obj-$(CONFIG_INTEL_ISH_HID)	+= intel-ish-hid/
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 330ca983828b..eeb325e3ff0d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2388,6 +2388,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
 #endif
 #if IS_ENABLED(CONFIG_HID_ZYDACRON)
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
+#endif
+#if IS_ENABLED(CONFIG_HID_MICRODIA)
+	{ HID_USB_DEVICE(USB_VENDOR_ID_MICRODIA,  USB_DEVICE_ID_REDRAGON_ASURA) },
 #endif
 	{ }
 };
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index be2e005c3c51..2edbf01361f1 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1161,4 +1161,7 @@
 #define USB_VENDOR_ID_UGTIZER			0x2179
 #define USB_DEVICE_ID_UGTIZER_TABLET_GP0610	0x0053
 
+#define USB_VENDOR_ID_MICRODIA          0x0c45
+#define USB_DEVICE_ID_REDRAGON_ASURA    0x760b
+
 #endif
diff --git a/drivers/hid/hid-microdia.c b/drivers/hid/hid-microdia.c
new file mode 100644
index 000000000000..a6119786859d
--- /dev/null
+++ b/drivers/hid/hid-microdia.c
@@ -0,0 +1,178 @@
+/*
+ *  HID driver for Microdia-based keyboards
+ *
+ *  Copyright (c) 2017 Robert Munteanu
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/input.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+#include <linux/log2.h>
+#include <linux/input-event-codes.h>
+
+#include "hid-ids.h"
+
+
+// The microdia family of keyboards uses a non-standard way of sending
+// modifier keys
+//
+// The down event always sets the first bit to 0x04 and the second keycode
+// to a custom value. For instance, left shift sends the following bits
+//
+//   04 02 00 00 00 00 00 00
+//
+// while left control sends
+//
+//   04 01 00 00 00 00 00 00
+//
+// Unfortunately these are all mapped to left shift and the keyboard is
+// non-functional in that respect. To solve the problem, we capture the
+// raw data in raw_event and manually generate the correct input events
+//
+// TODO
+//
+// 1. Some modifiers keys still don't work, e.g. Ctrl-Shift-P
+//    Interestingly enough, this happens when pressing the physical
+//    left shift key, but now when pressing the physical right shift key.
+//    hexdump does not show them either.
+// 2. A second USB keyboard is registered, but it should be removed
+// 3. Modifier keys sometimes get stuck, need to re-press to clear
+
+static int microdia_input_configured(struct hid_device *hdev,
+	struct hid_input *hi)
+{
+
+	hid_info(hdev, "Configuring input");
+
+	hid_set_drvdata(hdev, hi);
+
+	return 0;
+}
+
+static int microdia_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+		struct hid_field *field, struct hid_usage *usage,
+		unsigned long **bit, int *max)
+{
+	// do not map left shift since we will manually generate input
+	// events in microdia_raw_event
+	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_KEYBOARD)
+		if ((usage->hid & HID_USAGE) == 0xe1)
+			return -1;
+
+	return 0;
+}
+
+// array index of a modifier matches the bit index in the data payload
+// the modifier data is always stored in the second int
+// e.g. for left alt the 1 bit is set - 04 04 ...
+// TODO - second entry should be left shift, but that's not possible
+// since we ignore it in the mapping
+static int microdia_modifiers[7] = {
+		KEY_LEFTCTRL,
+		KEY_RIGHTSHIFT,
+		KEY_LEFTALT,
+		KEY_LEFTMETA,
+		KEY_RIGHTCTRL,
+		KEY_RIGHTSHIFT,
+		KEY_RIGHTALT
+};
+
+static int microdia_last_handled_modifier;
+
+static int microdia_raw_event(struct hid_device *hdev,
+		struct hid_report *report, u8 *data, int size)
+{
+	int i, changed_key, new_value, mapped_key;
+	struct hid_input *hi;
+
+	// 1. validate that we get 8 bits of the for 04 xx 00 00 00 00 00 00
+	if (size != 8) {
+		hid_info(hdev, "size is %d, ignoring\n", size);
+		return 0;
+	}
+
+	if (data[0] != 4) {
+		hid_info(hdev, "data[0] is %d, ignoring\n", data[0]);
+		return 0;
+	}
+
+	// TODO - can I somehow use a bit mask? data & 0x00ffffff != 0
+	for (i = 2; i < size; i++) {
+		if (data[i] != 0) {
+			hid_info(hdev, "data[%d] is %d, ignoring\n", i,
+				data[i]);
+			return 0;
+		}
+	}
+
+	// TODO - don't process the keyup event 04 00 00 00 00 00 00 00
+	// if we don't expect a modifier key 'up' event
+
+	// 2. detect based on previous data what key was pressed or depressed
+	// a key was pressed or depressed if its bit has a different value
+	// between this and the previous invocation. If the bit is set
+	// it was pressed
+
+	changed_key = data[1] ^ microdia_last_handled_modifier;
+	new_value = (data[1] & changed_key) != 0;
+	// TODO - is ilog2 really needed?
+	mapped_key = microdia_modifiers[ilog2(changed_key)];
+
+	hid_info(hdev, "Got payload 0x%x\n", data[1]);
+	hid_info(hdev, "Detected key %d value %d\n", changed_key, new_value);
+
+	// 3. report the key event and track what was sent
+	hi = hid_get_drvdata(hdev);
+
+	hid_info(hdev, "Reporting key %d with value %d\n", mapped_key,
+		new_value);
+	input_report_key(hi->input, mapped_key, new_value);
+
+	microdia_last_handled_modifier = data[1];
+
+	return 1;
+}
+
+static __u8 *microdia_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+	unsigned int *rsize)
+{
+
+	int i;
+
+	hid_info(hdev, "Report size is %d", *rsize);
+
+	for (i = 0 ; i < *rsize; i++)
+		hid_info(hdev, "%2d ", rdesc[i]);
+
+	hid_info(hdev, "\n");
+
+	return rdesc;
+}
+
+static const struct hid_device_id microdia_devices[] = {
+	{HID_USB_DEVICE(USB_VENDOR_ID_MICRODIA, USB_DEVICE_ID_REDRAGON_ASURA)},
+	{}
+};
+
+MODULE_DEVICE_TABLE(hid, microdia_devices);
+
+static struct hid_driver microdia_driver = {
+	.name = "microdia",
+	.input_mapping = microdia_input_mapping,
+	.id_table = microdia_devices,
+	.raw_event = microdia_raw_event,
+	.input_configured = microdia_input_configured,
+	.report_fixup = microdia_report_fixup,
+};
+
+module_hid_driver(microdia_driver);
+
+MODULE_LICENSE("GPL");
-- 
2.15.1

^ permalink raw reply related

* [PATCH] input: snvs_pwrkey: add clock support
From: Anson Huang @ 2018-01-10  9:10 UTC (permalink / raw)
  To: dmitry.torokhov, keescook, linux-input, linux-kernel

Add optional clock enable/disable support for the SNVS pwrkey,
which is required for accessing SNVS block on some i.MX SoCs
like i.MX7D.

If SNVS clock is required, it needs to be passed from dtb file
and SNVS pwrkey driver will enable it.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/input/keyboard/snvs_pwrkey.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index 53c768b..51642aa 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -43,6 +44,7 @@ struct pwrkey_drv_data {
 	int wakeup;
 	struct timer_list check_timer;
 	struct input_dev *input;
+	struct clk *clk;
 };
 
 static void imx_imx_snvs_check_for_events(struct timer_list *t)
@@ -129,6 +131,18 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	pdata->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(pdata->clk)) {
+		pdata->clk = NULL;
+	} else {
+		error = clk_prepare_enable(pdata->clk);
+		if (error) {
+			dev_err(&pdev->dev,
+				"Could not prepare or enable the snvs clock\n");
+			return error;
+		}
+	}
+
 	regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN);
 
 	/* clear the unexpected interrupt before driver ready */
@@ -139,7 +153,8 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 	input = devm_input_allocate_device(&pdev->dev);
 	if (!input) {
 		dev_err(&pdev->dev, "failed to allocate the input device\n");
-		return -ENOMEM;
+		error = -ENOMEM;
+		goto error_snvs_pwrkey_device_register;
 	}
 
 	input->name = pdev->name;
@@ -152,7 +167,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 	error = devm_add_action(&pdev->dev, imx_snvs_pwrkey_act, pdata);
 	if (error) {
 		dev_err(&pdev->dev, "failed to register remove action\n");
-		return error;
+		goto error_snvs_pwrkey_device_register;
 	}
 
 	error = devm_request_irq(&pdev->dev, pdata->irq,
@@ -161,13 +176,13 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 
 	if (error) {
 		dev_err(&pdev->dev, "interrupt not available.\n");
-		return error;
+		goto error_snvs_pwrkey_device_register;
 	}
 
 	error = input_register_device(input);
 	if (error < 0) {
 		dev_err(&pdev->dev, "failed to register input device\n");
-		return error;
+		goto error_snvs_pwrkey_device_register;
 	}
 
 	pdata->input = input;
@@ -176,6 +191,13 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 	device_init_wakeup(&pdev->dev, pdata->wakeup);
 
 	return 0;
+
+error_snvs_pwrkey_device_register:
+	if (pdata->clk)
+		clk_disable_unprepare(pdata->clk);
+
+	return error;
+
 }
 
 static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
-- 
1.9.1


^ permalink raw reply related

* [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
From: Dan Carpenter @ 2018-01-10  9:39 UTC (permalink / raw)
  To: Stefan Achatz
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, kernel-janitors

We get the "new_profile_index" value from the mouse device when we're
handling raw events.  Smatch taints it as untrusted data and complains
that we need a bounds check.  This seems like a reasonable warning
otherwise there is a small read beyond the end of the array.

Fixes: 0e70f97f257e ("HID: roccat: Add support for Kova[+] mouse")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
index 43617fb28b87..317c9c2c0a7c 100644
--- a/drivers/hid/hid-roccat-kovaplus.c
+++ b/drivers/hid/hid-roccat-kovaplus.c
@@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value)
 static void kovaplus_profile_activated(struct kovaplus_device *kovaplus,
 		uint new_profile_index)
 {
+	if (new_profile_index >= ARRAY_SIZE(kovaplus->profile_settings))
+		return;
 	kovaplus->actual_profile = new_profile_index;
 	kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level;
 	kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x;

^ permalink raw reply related

* [PATCH] Input: goodix - disable IRQs while suspended
From: Hans de Goede @ 2018-01-10 11:34 UTC (permalink / raw)
  To: Dmitry Torokhov, Bastien Nocera, Benjamin Tissoires
  Cc: Hans de Goede, linux-input

We should not try to do any i2c transfers before the controller is
resumed (which happens before our resume method gets called).

So we need to disable our IRQ while suspended to enforce this. The
code paths for devices with GPIOs for the int and reset pins already
disable the IRQ the through goodix_free_irq().

This commit also disables the IRQ while suspended for devices without
GPIOs for the int and reset pins.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/touchscreen/goodix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 69d0b8cbc71f..ecec8eb17f28 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -878,8 +878,10 @@ static int __maybe_unused goodix_suspend(struct device *dev)
 	int error;
 
 	/* We need gpio pins to suspend/resume */
-	if (!ts->gpiod_int || !ts->gpiod_rst)
+	if (!ts->gpiod_int || !ts->gpiod_rst) {
+		disable_irq(client->irq);
 		return 0;
+	}
 
 	wait_for_completion(&ts->firmware_loading_complete);
 
@@ -919,8 +921,10 @@ static int __maybe_unused goodix_resume(struct device *dev)
 	struct goodix_ts_data *ts = i2c_get_clientdata(client);
 	int error;
 
-	if (!ts->gpiod_int || !ts->gpiod_rst)
+	if (!ts->gpiod_int || !ts->gpiod_rst) {
+		enable_irq(client->irq);
 		return 0;
+	}
 
 	/*
 	 * Exit sleep mode by outputting HIGH level to INT pin
-- 
2.14.3


^ permalink raw reply related

* [RESEND PATCH v2] input: pxrc: new driver for PhoenixRC Flight Controller Adapter
From: Marcus Folkesson @ 2018-01-10 13:11 UTC (permalink / raw)
  To: Dmitry Torokhov, Jonathan Corbet, Marcus Folkesson,
	Tomohiro Yoshidomi, David Herrmann, Philippe Ombredanne,
	Kate Stewart, Greg Kroah-Hartman
  Cc: linux-input, linux-doc, linux-kernel

This driver let you plug in your RC controller to the adapter and
use it as input device in various RC simulators.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
v2:
	- Change module license to GPLv2 to match SPDX tag

 Documentation/input/devices/pxrc.rst |  57 ++++++++
 drivers/input/joystick/Kconfig       |   9 ++
 drivers/input/joystick/Makefile      |   1 +
 drivers/input/joystick/pxrc.c        | 254 +++++++++++++++++++++++++++++++++++
 4 files changed, 321 insertions(+)
 create mode 100644 Documentation/input/devices/pxrc.rst
 create mode 100644 drivers/input/joystick/pxrc.c

diff --git a/Documentation/input/devices/pxrc.rst b/Documentation/input/devices/pxrc.rst
new file mode 100644
index 000000000000..0ec466c58958
--- /dev/null
+++ b/Documentation/input/devices/pxrc.rst
@@ -0,0 +1,57 @@
+=======================================================
+pxrc - PhoenixRC Flight Controller Adapter
+=======================================================
+
+:Author: Marcus Folkesson <marcus.folkesson@gmail.com>
+
+This driver let you use your own RC controller plugged into the
+adapter that comes with PhoenixRC [1]_ or other compatible adapters.
+
+The adapter supports 7 analog channels and 1 digital input switch.
+
+Notes
+=====
+
+Many RC controllers is able to configure which stick goes to which channel.
+This is also configurable in most simulators, so a matching is not necessary.
+
+The driver is generating the following input event for analog channels:
+
++---------+----------------+
+| Channel |      Event     |
++=========+================+
+|     1   |  ABS_X         |
++---------+----------------+
+|     2   |  ABS_Y         |
++---------+----------------+
+|     3   |  ABS_RX        |
++---------+----------------+
+|     4   |  ABS_RY        |
++---------+----------------+
+|     5   |  ABS_TILT_X    |
++---------+----------------+
+|     6   |  ABS_TILT_Y    |
++---------+----------------+
+|     7   |  ABS_THROTTLE  |
++---------+----------------+
+
+The digital input switch is generated as an `BTN_A` event.
+
+Manual Testing
+==============
+
+To test this driver's functionality you may use `input-event` which is part of
+the `input layer utilities` suite [2]_.
+
+For example::
+
+    > modprobe pxrc
+    > input-events <devnr>
+
+To print all input events from input `devnr`.
+
+References
+==========
+
+.. [1] http://www.phoenix-sim.com/
+.. [2] https://www.kraxel.org/cgit/input/
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index f3c2f6ea8b44..18ab6dafff41 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -351,4 +351,13 @@ config JOYSTICK_PSXPAD_SPI_FF
 
 	  To drive rumble motor a dedicated power supply is required.
 
+config JOYSTICK_PXRC
+	tristate "PhoenixRC Flight Controller Adapter"
+	depends on USB_ARCH_HAS_HCD
+	select USB
+	help
+	  Say Y here if you want to use the PhoenixRC Flight Controller Adapter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pxrc.
 endif
diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
index 67651efda2e1..dd0492ebbed7 100644
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_JOYSTICK_JOYDUMP)		+= joydump.o
 obj-$(CONFIG_JOYSTICK_MAGELLAN)		+= magellan.o
 obj-$(CONFIG_JOYSTICK_MAPLE)		+= maplecontrol.o
 obj-$(CONFIG_JOYSTICK_PSXPAD_SPI)	+= psxpad-spi.o
+obj-$(CONFIG_JOYSTICK_PXRC)			+= pxrc.o
 obj-$(CONFIG_JOYSTICK_SIDEWINDER)	+= sidewinder.o
 obj-$(CONFIG_JOYSTICK_SPACEBALL)	+= spaceball.o
 obj-$(CONFIG_JOYSTICK_SPACEORB)		+= spaceorb.o
diff --git a/drivers/input/joystick/pxrc.c b/drivers/input/joystick/pxrc.c
new file mode 100644
index 000000000000..2bec99df97e2
--- /dev/null
+++ b/drivers/input/joystick/pxrc.c
@@ -0,0 +1,254 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for Phoenix RC Flight Controller Adapter
+ *
+ * Copyright (C) 2018 Marcus Folkesson <marcus.folkesson@gmail.com>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kref.h>
+#include <linux/uaccess.h>
+#include <linux/usb.h>
+#include <linux/mutex.h>
+#include <linux/input.h>
+
+#define PXRC_VENDOR_ID	(0x1781)
+#define PXRC_PRODUCT_ID	(0x0898)
+
+static const struct usb_device_id pxrc_table[] = {
+	{ USB_DEVICE(PXRC_VENDOR_ID, PXRC_PRODUCT_ID) },
+	{ }
+};
+MODULE_DEVICE_TABLE(usb, pxrc_table);
+
+struct usb_pxrc {
+	struct input_dev	*input_dev;
+	struct usb_device	*udev;
+	struct usb_interface	*interface;
+	struct usb_anchor	anchor;
+	__u8			epaddr;
+	char			phys[64];
+	unsigned char           *data;
+	size_t			bsize;
+	struct kref		kref;
+};
+
+#define to_pxrc_dev(d) container_of(d, struct usb_pxrc, kref)
+static void pxrc_delete(struct kref *kref)
+{
+	struct usb_pxrc *pxrc = to_pxrc_dev(kref);
+
+	usb_put_dev(pxrc->udev);
+}
+
+static void pxrc_usb_irq(struct urb *urb)
+{
+	struct usb_pxrc *pxrc = urb->context;
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ETIME:
+		/* this urb is timing out */
+		dev_dbg(&pxrc->interface->dev,
+			"%s - urb timed out - was the device unplugged?\n",
+			__func__);
+		return;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+	case -EPIPE:
+		/* this urb is terminated, clean up */
+		dev_dbg(&pxrc->interface->dev, "%s - urb shutting down with status: %d\n",
+			__func__, urb->status);
+		return;
+	default:
+		dev_dbg(&pxrc->interface->dev, "%s - nonzero urb status received: %d\n",
+			__func__, urb->status);
+		goto exit;
+	}
+
+	if (urb->actual_length == 8) {
+		input_report_abs(pxrc->input_dev, ABS_X, pxrc->data[0]);
+		input_report_abs(pxrc->input_dev, ABS_Y, pxrc->data[2]);
+		input_report_abs(pxrc->input_dev, ABS_RX, pxrc->data[3]);
+		input_report_abs(pxrc->input_dev, ABS_RY, pxrc->data[4]);
+		input_report_abs(pxrc->input_dev, ABS_TILT_X, pxrc->data[5]);
+		input_report_abs(pxrc->input_dev, ABS_TILT_Y, pxrc->data[6]);
+		input_report_abs(pxrc->input_dev, ABS_THROTTLE, pxrc->data[7]);
+
+		input_report_key(pxrc->input_dev, BTN_A, pxrc->data[1]);
+	}
+
+exit:
+	/* Resubmit to fetch new fresh URBs */
+	usb_anchor_urb(urb, &pxrc->anchor);
+	if (usb_submit_urb(urb, GFP_ATOMIC) < 0)
+		usb_unanchor_urb(urb);
+}
+
+static int pxrc_submit_intr_urb(struct usb_pxrc *pxrc)
+{
+	struct urb *urb;
+	unsigned int pipe;
+	int err;
+
+	urb = usb_alloc_urb(0, GFP_KERNEL);
+	if (!urb)
+		return -ENOMEM;
+
+	pipe = usb_rcvintpipe(pxrc->udev, pxrc->epaddr),
+	usb_fill_int_urb(urb, pxrc->udev, pipe, pxrc->data, pxrc->bsize,
+						pxrc_usb_irq, pxrc, 1);
+	usb_anchor_urb(urb, &pxrc->anchor);
+	err = usb_submit_urb(urb, GFP_KERNEL);
+	if (err < 0)
+		usb_unanchor_urb(urb);
+
+	usb_free_urb(urb);
+	return err;
+}
+
+static int pxrc_open(struct input_dev *input)
+{
+	struct usb_pxrc *pxrc = input_get_drvdata(input);
+	int err;
+
+	err = pxrc_submit_intr_urb(pxrc);
+	if (err < 0)
+		goto error;
+
+	kref_get(&pxrc->kref);
+	return 0;
+
+error:
+	usb_kill_anchored_urbs(&pxrc->anchor);
+	return err;
+}
+
+static void pxrc_close(struct input_dev *input)
+{
+	struct usb_pxrc *pxrc = input_get_drvdata(input);
+
+	usb_kill_anchored_urbs(&pxrc->anchor);
+	kref_put(&pxrc->kref, pxrc_delete);
+}
+
+static int pxrc_input_init(struct usb_pxrc *pxrc)
+{
+	pxrc->input_dev = devm_input_allocate_device(&pxrc->interface->dev);
+	if (pxrc->input_dev == NULL) {
+		dev_err(&pxrc->interface->dev, "couldn't allocate input device\n");
+		return -ENOMEM;
+	}
+
+	pxrc->input_dev->name = "PXRC Flight Controller Adapter";
+	pxrc->input_dev->phys = pxrc->phys;
+	pxrc->input_dev->id.bustype = BUS_USB;
+	pxrc->input_dev->id.vendor = PXRC_VENDOR_ID;
+	pxrc->input_dev->id.product = PXRC_PRODUCT_ID;
+	pxrc->input_dev->id.version = 0x01;
+
+	pxrc->input_dev->open = pxrc_open;
+	pxrc->input_dev->close = pxrc_close;
+
+	pxrc->input_dev->evbit[0] =	BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY);
+	pxrc->input_dev->absbit[0] =	BIT_MASK(ABS_X) |
+					BIT_MASK(ABS_Y) |
+					BIT_MASK(ABS_RY) |
+					BIT_MASK(ABS_RX) |
+					BIT_MASK(ABS_THROTTLE) |
+					BIT_MASK(ABS_TILT_X) |
+					BIT_MASK(ABS_TILT_Y);
+
+	pxrc->input_dev->keybit[BIT_WORD(BTN_JOYSTICK)] = BIT_MASK(BTN_A);
+
+	input_set_abs_params(pxrc->input_dev, ABS_X, 0, 255, 0, 0);
+	input_set_abs_params(pxrc->input_dev, ABS_Y, 0, 255, 0, 0);
+	input_set_abs_params(pxrc->input_dev, ABS_RX, 0, 255, 0, 0);
+	input_set_abs_params(pxrc->input_dev, ABS_RY, 0, 255, 0, 0);
+	input_set_abs_params(pxrc->input_dev, ABS_TILT_X, 0, 255, 0, 0);
+	input_set_abs_params(pxrc->input_dev, ABS_TILT_Y, 0, 255, 0, 0);
+	input_set_abs_params(pxrc->input_dev, ABS_THROTTLE, 0, 255, 0, 0);
+
+	input_set_drvdata(pxrc->input_dev, pxrc);
+
+	return input_register_device(pxrc->input_dev);
+}
+
+static int pxrc_probe(struct usb_interface *interface,
+		      const struct usb_device_id *id)
+{
+	struct usb_pxrc *pxrc;
+	struct usb_endpoint_descriptor *epirq;
+	int retval;
+
+	pxrc = devm_kzalloc(&interface->dev, sizeof(*pxrc), GFP_KERNEL);
+
+	if (!pxrc)
+		return -ENOMEM;
+
+	kref_init(&pxrc->kref);
+	init_usb_anchor(&pxrc->anchor);
+
+	pxrc->udev = usb_get_dev(interface_to_usbdev(interface));
+	pxrc->interface = interface;
+
+	/* Set up the endpoint information */
+	/* This device only has an interrupt endpoint */
+	retval = usb_find_common_endpoints(interface->cur_altsetting,
+			NULL, NULL, &epirq, NULL);
+	if (retval) {
+		dev_err(&interface->dev,
+			"Could not find endpoint\n");
+		goto error;
+	}
+
+	pxrc->bsize = usb_endpoint_maxp(epirq);
+	pxrc->epaddr = epirq->bEndpointAddress;
+	pxrc->data = devm_kmalloc(&interface->dev, pxrc->bsize, GFP_KERNEL);
+	if (!pxrc->data) {
+		retval = -ENOMEM;
+		goto error;
+	}
+
+	usb_set_intfdata(interface, pxrc);
+	usb_make_path(pxrc->udev, pxrc->phys, sizeof(pxrc->phys));
+
+	retval = pxrc_input_init(pxrc);
+	if (retval)
+		goto error;
+
+	return 0;
+
+error:
+	/* this frees allocated memory */
+	kref_put(&pxrc->kref, pxrc_delete);
+
+	return retval;
+}
+
+static void pxrc_disconnect(struct usb_interface *interface)
+{
+	struct usb_pxrc *pxrc = usb_get_intfdata(interface);
+
+	kref_put(&pxrc->kref, pxrc_delete);
+}
+
+static struct usb_driver pxrc_driver = {
+	.name =		"pxrc",
+	.probe =	pxrc_probe,
+	.disconnect =	pxrc_disconnect,
+	.id_table =	pxrc_table,
+};
+
+module_usb_driver(pxrc_driver);
+
+MODULE_AUTHOR("Marcus Folkesson <marcus.folkesson@gmail.com>");
+MODULE_DESCRIPTION("PhoenixRC Flight Controller Adapter");
+MODULE_LICENSE("GPL v2");
-- 
2.15.1

^ permalink raw reply related

* Re: [PATCH] Input: goodix - disable IRQs while suspended
From: Bastien Nocera @ 2018-01-10 14:14 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov, Benjamin Tissoires; +Cc: linux-input
In-Reply-To: <20180110113456.3091-1-hdegoede@redhat.com>

On Wed, 2018-01-10 at 12:34 +0100, Hans de Goede wrote:
> We should not try to do any i2c transfers before the controller is
> resumed (which happens before our resume method gets called).
> 
> So we need to disable our IRQ while suspended to enforce this. The
> code paths for devices with GPIOs for the int and reset pins already
> disable the IRQ the through goodix_free_irq().
> 
> This commit also disables the IRQ while suspended for devices without
> GPIOs for the int and reset pins.

Do disable_irq() and enable_irq() require to be paired, and if so, are
goodix_suspend() and goodix_resume() guaranteed to be paired?

Other than that, looks good to me. Please add the name of the device(s)
you tested this on in the changelog and add your tested-by, to show
it's not a "compile-only check" kind of commit.

Cheers

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/input/touchscreen/goodix.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c
> b/drivers/input/touchscreen/goodix.c
> index 69d0b8cbc71f..ecec8eb17f28 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -878,8 +878,10 @@ static int __maybe_unused goodix_suspend(struct
> device *dev)
>  	int error;
>  
>  	/* We need gpio pins to suspend/resume */
> -	if (!ts->gpiod_int || !ts->gpiod_rst)
> +	if (!ts->gpiod_int || !ts->gpiod_rst) {
> +		disable_irq(client->irq);
>  		return 0;
> +	}
>  
>  	wait_for_completion(&ts->firmware_loading_complete);
>  
> @@ -919,8 +921,10 @@ static int __maybe_unused goodix_resume(struct
> device *dev)
>  	struct goodix_ts_data *ts = i2c_get_clientdata(client);
>  	int error;
>  
> -	if (!ts->gpiod_int || !ts->gpiod_rst)
> +	if (!ts->gpiod_int || !ts->gpiod_rst) {
> +		enable_irq(client->irq);
>  		return 0;
> +	}
>  
>  	/*
>  	 * Exit sleep mode by outputting HIGH level to INT pin

^ permalink raw reply

* [PATCH] input: of_touchscreen: add MODULE_LICENSE
From: Arnd Bergmann @ 2018-01-10 16:31 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Arnd Bergmann, linux-input, linux-kernel

The lack of the MODULE_LICENSE tag can lead to a warning here:

WARNING: modpost: missing MODULE_LICENSE() in drivers/input/touchscreen/of_touchscreen.o

I'm adding a license and description tag, but no MODULE_AUTHOR()
as this file is a collection of standalone helper functions that
were all added by different developers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/input/touchscreen/of_touchscreen.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
index 8d7f9c8f2771..9642f103b726 100644
--- a/drivers/input/touchscreen/of_touchscreen.c
+++ b/drivers/input/touchscreen/of_touchscreen.c
@@ -13,6 +13,7 @@
 #include <linux/input.h>
 #include <linux/input/mt.h>
 #include <linux/input/touchscreen.h>
+#include <linux/module.h>
 
 static bool touchscreen_get_prop_u32(struct device *dev,
 				     const char *property,
@@ -185,3 +186,6 @@ void touchscreen_report_pos(struct input_dev *input,
 	input_report_abs(input, multitouch ? ABS_MT_POSITION_Y : ABS_Y, y);
 }
 EXPORT_SYMBOL(touchscreen_report_pos);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Device-tree helpers functions for touchscreen devices");
-- 
2.9.0

^ permalink raw reply related

* [PATCH v3] HID: sony: Fix up nyko core controller
From: Scott Moreau @ 2018-01-10 18:46 UTC (permalink / raw)
  To: linux-input; +Cc: Scott Moreau

This fixes missing d-pad axis broken since e19a267b99. The axis mapping for
the nyko controller has the d-pad as axis 0x39 instead of d-pad as buttons.
This is handled by the default hid mapping so we return 0 in sony_mapping.
This controller also has no accelerometer so avoid initializing it with
a condition in sony_input_configured() to setup these controllers.

Signed-off-by: Scott Moreau <oreaus@gmail.com>
---

Changed in v3:

- Added signoff

 drivers/hid/hid-sony.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index b9dc3ac..1be0a35 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1225,6 +1225,9 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi,
 	if (sc->quirks & NAVIGATION_CONTROLLER)
 		return navigation_mapping(hdev, hi, field, usage, bit, max);
 
+	if (sc->quirks & SINO_LITE_CONTROLLER)
+		return 0;
+
 	if (sc->quirks & SIXAXIS_CONTROLLER)
 		return sixaxis_mapping(hdev, hi, field, usage, bit, max);
 
@@ -2566,6 +2569,10 @@ static int sony_input_configured(struct hid_device *hdev,
 		}
 
 		sony_init_output_report(sc, sixaxis_send_output_report);
+	} else if (sc->quirks & SINO_LITE_CONTROLLER) {
+		hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID;
+
+		sony_init_output_report(sc, sixaxis_send_output_report);
 	} else if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
 		/*
 		 * The Sony Sixaxis does not handle HID Output Reports on the
-- 
2.7.4


^ permalink raw reply related

* Re: [PATCH] input: of_touchscreen: add MODULE_LICENSE
From: Dmitry Torokhov @ 2018-01-10 19:30 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-input, linux-kernel
In-Reply-To: <20180110163137.543730-1-arnd@arndb.de>

On Wed, Jan 10, 2018 at 05:31:26PM +0100, Arnd Bergmann wrote:
> The lack of the MODULE_LICENSE tag can lead to a warning here:
> 
> WARNING: modpost: missing MODULE_LICENSE() in drivers/input/touchscreen/of_touchscreen.o
> 
> I'm adding a license and description tag, but no MODULE_AUTHOR()
> as this file is a collection of standalone helper functions that
> were all added by different developers.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thank you.

> ---
>  drivers/input/touchscreen/of_touchscreen.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
> index 8d7f9c8f2771..9642f103b726 100644
> --- a/drivers/input/touchscreen/of_touchscreen.c
> +++ b/drivers/input/touchscreen/of_touchscreen.c
> @@ -13,6 +13,7 @@
>  #include <linux/input.h>
>  #include <linux/input/mt.h>
>  #include <linux/input/touchscreen.h>
> +#include <linux/module.h>
>  
>  static bool touchscreen_get_prop_u32(struct device *dev,
>  				     const char *property,
> @@ -185,3 +186,6 @@ void touchscreen_report_pos(struct input_dev *input,
>  	input_report_abs(input, multitouch ? ABS_MT_POSITION_Y : ABS_Y, y);
>  }
>  EXPORT_SYMBOL(touchscreen_report_pos);
> +
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("Device-tree helpers functions for touchscreen devices");
> -- 
> 2.9.0
> 

-- 
Dmitry

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox