* [PATCH] Documentation: input: Add HID gadget driver's docs to Input subsystem
From: Shreeya Patel @ 2019-07-04 18:30 UTC (permalink / raw)
To: skhan, linux-kernel-mentees, dmitry.torokhov, corbet, gregkh,
linux-input, linux-doc, linux-kernel, linux-usb
Convert gadget_hid file to ReST format, in order to allow it to
be parsed by Sphinx.
Also move the file in the Input subsystem documentation so as to
put it in the right place.
Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
.../devices/gadget_hid.rst} | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
rename Documentation/{usb/gadget_hid.txt => input/devices/gadget_hid.rst} (96%)
diff --git a/Documentation/usb/gadget_hid.txt b/Documentation/input/devices/gadget_hid.rst
similarity index 96%
rename from Documentation/usb/gadget_hid.txt
rename to Documentation/input/devices/gadget_hid.rst
index 098d563040cc..132a8d6719f0 100644
--- a/Documentation/usb/gadget_hid.txt
+++ b/Documentation/input/devices/gadget_hid.rst
@@ -1,3 +1,5 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
===========================
Linux USB HID gadget driver
===========================
@@ -8,15 +10,15 @@ Introduction
The HID Gadget driver provides emulation of USB Human Interface
Devices (HID). The basic HID handling is done in the kernel,
and HID reports can be sent/received through I/O on the
-/dev/hidgX character devices.
+:file:`/dev/hidgX` character devices.
For more details about HID, see the developer page on
-http://www.usb.org/developers/hidpage/
+`<http://www.usb.org/developers/hidpage/>`_
Configuration
=============
-g_hid is a platform driver, so to use it you need to add
+*g_hid* is a platform driver, so to use it you need to add
struct platform_device(s) to your platform code defining the
HID function descriptors you want to use - E.G. something
like::
@@ -89,16 +91,16 @@ Send and receive HID reports
============================
HID reports can be sent/received using read/write on the
-/dev/hidgX character devices. See below for an example program
+:file:`/dev/hidgX` character devices. See below for an example program
to do this.
-hid_gadget_test is a small interactive program to test the HID
+*hid_gadget_test* is a small interactive program to test the HID
gadget driver. To use, point it at a hidg device and set the
device type (keyboard / mouse / joystick) - E.G.::
# hid_gadget_test /dev/hidg0 keyboard
-You are now in the prompt of hid_gadget_test. You can type any
+You are now in the prompt of *hid_gadget_test*. You can type any
combination of options and values. Available options and
values are listed at program start. In keyboard mode you can
send up to six values.
--
2.17.1
^ permalink raw reply related
* [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
To: Dan Murphy, linux-leds, linux-media, linux-arm-kernel,
linuxppc-dev, linux-nfs
Cc: linux-input, linux-kernel, netdev
These are all likely copy/paste defects where the field size of the
'copied to' array is incorrect.
Each patch in this series is independent.
Joe Perches (8):
Input: synaptics: Fix misuse of strlcpy
leds: as3645a: Fix misuse of strlcpy
media: m2m-deinterlace: Fix misuse of strscpy
media: go7007: Fix misuse of strscpy
net: ethernet: sun4i-emac: Fix misuse of strlcpy
net: nixge: Fix misuse of strlcpy
tty: hvcs: Fix odd use of strlcpy
nfsd: Fix misuse of strlcpy
drivers/input/mouse/synaptics.c | 2 +-
drivers/leds/leds-as3645a.c | 2 +-
drivers/media/platform/m2m-deinterlace.c | 2 +-
drivers/media/usb/go7007/snd-go7007.c | 2 +-
drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++--
drivers/net/ethernet/ni/nixge.c | 2 +-
drivers/tty/hvc/hvcs.c | 4 ++--
fs/nfsd/nfs4idmap.c | 2 +-
8 files changed, 10 insertions(+), 10 deletions(-)
--
2.15.0
^ permalink raw reply
* [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
To: linux-kernel; +Cc: Dmitry Torokhov, linux-input
In-Reply-To: <cover.1562283944.git.joe@perches.com>
Probable cut&paste typo - use the correct field size.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/input/mouse/synaptics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 1080c0c49815..00a0cf14f27f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -705,7 +705,7 @@ static void synaptics_pt_create(struct psmouse *psmouse)
serio->id.type = SERIO_PS_PSTHRU;
strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
- strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
+ strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->phys));
serio->write = synaptics_pt_write;
serio->start = synaptics_pt_start;
serio->stop = synaptics_pt_stop;
--
2.15.0
^ permalink raw reply related
* Re: [PATCH v2] HID: input: fix a4tech horizontal wheel custom usage
From: Nicolas Saenz Julienne @ 2019-07-05 10:28 UTC (permalink / raw)
To: Benjamin Tissoires, wbauer1
Cc: Jiri Kosina, Dmitry Torokhov, open list:HID CORE LAYER, lkml
In-Reply-To: <9ff9f804a2fa3abf1249a358f64c2d39a04c8ed1.camel@suse.de>
[-- Attachment #1: Type: text/plain, Size: 4206 bytes --]
On Fri, 2019-06-14 at 16:25 +0200, Nicolas Saenz Julienne wrote:
> On Fri, 2019-06-14 at 15:36 +0200, Benjamin Tissoires wrote:
> > Hi Wolfgang,
> >
> > On Thu, Jun 13, 2019 at 1:49 PM Wolfgang Bauer <wbauer@tmo.at> wrote:
> > > On Tuesday, 11. Juni 2019, 16:42:37 Benjamin Tissoires wrote:
> > > > On Tue, Jun 11, 2019 at 2:13 PM Nicolas Saenz Julienne
> > > >
> > > > <nsaenzjulienne@suse.de> wrote:
> > > > > NOTE: I CC'd Wolfgang as he's the one who can test this.
> > > >
> > > > I'll wait for Wolfram to confirm that the patch works before pushing
> > > > then.
> > >
> > > My name is Wolfgang, not Wolfram... ;-)
> >
> > ouch, sorry for that (I am more used to talk to the I2C maintainer
> > apparently)
> >
> > > But never mind.
> > >
> > > I tested the patch meanwhile on top of kernel 5.2.rc4, where the mouse
> > > wheel
> > > actually worked.
> >
> > Actually, I am a little bit lost here.
> >
> > The patch mentions a fix of c01908a14bf73, which is in 5.1 final.
> > So if your mouse works in 5.2.rc4, I am not sure how
> > HID-a4tech-fix-horizontal-scrolling.patch could break it.
> >
> > Could you be slightly more specific in what "works" and what doesn't?
>
> Hi Benjamin,
>
> First of all here's the descriptor:
> 0x05, 0x01, /* Usage Page (Desktop), */
> 0x09, 0x02, /* Usage (Mouse), */
> 0xA1, 0x01, /* Collection (Application), */
> 0x09, 0x01, /* Usage (Pointer), */
> 0xA1, 0x00, /* Collection (Physical), */
> 0x05, 0x09, /* Usage Page (Button), */
> 0x19, 0x01, /* Usage Minimum (01h), */
> 0x29, 0x08, /* Usage Maximum (08h), */
> 0x15, 0x00, /* Logical Minimum (0), */
> 0x25, 0x01, /* Logical Maximum (1), */
> 0x75, 0x01, /* Report Size (1), */
> 0x95, 0x08, /* Report Count (8), */
> 0x81, 0x02, /* Input (Variable), */
> 0x05, 0x01, /* Usage Page (Desktop), */
> 0x09, 0x30, /* Usage (X), */
> 0x09, 0x31, /* Usage (Y), */
> 0x09, 0x38, /* Usage (Wheel), */
> 0x09, 0xB8, /* Usage (B8h), */
> 0x15, 0x81, /* Logical Minimum (-127), */
> 0x25, 0x7F, /* Logical Maximum (127), */
> 0x75, 0x08, /* Report Size (8), */
> 0x95, 0x04, /* Report Count (4), */
> 0x81, 0x06, /* Input (Variable, Relative), */
> 0xC0, /* End Collection, */
> 0xC0 /* End Collection
>
>
> Sorry for the confusion, I'll try to explain the situation:
>
> In v5.2-rc4 without "HID-a4tech-fix-horizontal-scrolling.patch" the vertical
> wheel works out of luck as it's mapped to REL_WHEEL_HIGH_RES, which hid-a4tech
> ignores and lets hid-input process, the horizontal wheel is broken. On top of
> that Usage(0xB8) is also ignored by both hid-a4tech and hid-input as it isn't
> mapped to anything.
>
> There are two distinct bugs here:
> - High resolution wheel processing in hid-a4tech not being implemented,
> breaking horizontal wheels.
> - hid-a4tech not taking care of Usage(0xB8) correctly as it depended on it
> being mapped to "Rel.Misc". That behaviour changed in v5.1 with "HID:
> input: add mapping for "Toggle Display" key".
>
> Once high resolution wheel reports are fixed and handled in hid-a4tech's
> custom
> event, the mouse breaks as it's the processing of Usage(0xB8) that triggers
> the
> input_events, which is being ignored.
>
> You'll probably ask how come we didn't see this when
> "HID-a4tech-fix-horizontal-scrolling.patch" was merged. It's due to the fact
> it
> was tested on an older kernel, v5.0.15, that didn't contain "HID: input: add
> mapping for "Toggle Display" key"[1].
>
> So that's why I added that specific fix tag. For LTS kernels, it is possible
> that "Toggle Display" support was back-ported but not the high resolution
> wheels support.
Hi,
Any thoughts on this?
Regards,
Nicolas
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH 1/2] input: keyboard: gpio-keys-polled: use input name from pdata if available
From: Dmitry Torokhov @ 2019-07-07 6:14 UTC (permalink / raw)
To: Enrico Weigelt, metux IT consult; +Cc: linux-kernel, linux-input
In-Reply-To: <1561648031-15887-1-git-send-email-info@metux.net>
Hi Enrico,
On Thu, Jun 27, 2019 at 05:07:10PM +0200, Enrico Weigelt, metux IT consult wrote:
> Instead of hardcoding the input name to the driver name
> ('gpio-keys-polled'), allow the passing a name via platform data
> ('name' field was already present), but default to old behaviour
> in case of NULL.
>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> ---
> drivers/input/keyboard/gpio_keys_polled.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> index 1eafe6b..c168493 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -269,7 +269,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
>
> input = poll_dev->input;
>
> - input->name = pdev->name;
> + input->name = (pdata->name ? pdata->name : pdev->name);
> input->phys = DRV_NAME"/input0";
>
> input->id.bustype = BUS_HOST;
I also added fetching name from "label" device property ad applied,
thank you.
--
Dmitry
^ permalink raw reply
* [PATCH] Input: iforce - Remove empty multiline comments
From: Tim Schumacher @ 2019-07-08 2:50 UTC (permalink / raw)
To: linux-input; +Cc: linux-kernel, tglx, timschumi
Those are remnants of the SPDX identifier migration, which haven't been
removed properly.
Signed-off-by: Tim Schumacher <timschumi@gmx.de>
---
This is probably the highest level of cosmetic-only that a patch
can achieve, sorry for the noise.
CCing Thomas Gleixner, since the tool (is it a tool?) that makes
those SPDX changes would have room for improvement in that regard.
It seems to expect that all of the license information is contained
within the same comment block, which wasn't the case for the iforce
driver.
---
drivers/input/joystick/iforce/iforce-ff.c | 3 ---
drivers/input/joystick/iforce/iforce-main.c | 3 ---
drivers/input/joystick/iforce/iforce-packets.c | 3 ---
drivers/input/joystick/iforce/iforce-serio.c | 3 ---
drivers/input/joystick/iforce/iforce-usb.c | 3 ---
drivers/input/joystick/iforce/iforce.h | 3 ---
6 files changed, 18 deletions(-)
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c
index 2ed7da7d1f3e..4350927f7781 100644
--- a/drivers/input/joystick/iforce/iforce-ff.c
+++ b/drivers/input/joystick/iforce/iforce-ff.c
@@ -6,9 +6,6 @@
* USB/RS232 I-Force joysticks and wheels.
*/
-/*
- */
-
#include "iforce.h"
/*
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index 55f5b7bb4cac..8c2ffa43ce89 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -6,9 +6,6 @@
* USB/RS232 I-Force joysticks and wheels.
*/
-/*
- */
-
#include "iforce.h"
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <johann.deneux@gmail.com>");
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index 42cd9730e4cc..677a7773059d 100644
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -6,9 +6,6 @@
* USB/RS232 I-Force joysticks and wheels.
*/
-/*
- */
-
#include "iforce.h"
static struct {
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
index 65a4fe26324f..b3fff64d92dd 100644
--- a/drivers/input/joystick/iforce/iforce-serio.c
+++ b/drivers/input/joystick/iforce/iforce-serio.c
@@ -6,9 +6,6 @@
* USB/RS232 I-Force joysticks and wheels.
*/
-/*
- */
-
#include "iforce.h"
void iforce_serial_xmit(struct iforce *iforce)
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index f1569ae8381b..ec5058e05317 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -6,9 +6,6 @@
* USB/RS232 I-Force joysticks and wheels.
*/
-/*
- */
-
#include "iforce.h"
void iforce_usb_xmit(struct iforce *iforce)
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
index f1681706f526..32e91baf63f5 100644
--- a/drivers/input/joystick/iforce/iforce.h
+++ b/drivers/input/joystick/iforce/iforce.h
@@ -6,9 +6,6 @@
* USB/RS232 I-Force joysticks and wheels.
*/
-/*
- */
-
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/input.h>
--
2.22.0
^ permalink raw reply related
* Re: [PATCH] Input: iforce - Remove empty multiline comments
From: Thomas Gleixner @ 2019-07-08 6:01 UTC (permalink / raw)
To: Tim Schumacher; +Cc: linux-input, linux-kernel
In-Reply-To: <20190708025010.9318-1-timschumi@gmx.de>
On Mon, 8 Jul 2019, Tim Schumacher wrote:
> Those are remnants of the SPDX identifier migration, which haven't been
> removed properly.
>
> Signed-off-by: Tim Schumacher <timschumi@gmx.de>
> ---
> This is probably the highest level of cosmetic-only that a patch
> can achieve, sorry for the noise.
>
> CCing Thomas Gleixner, since the tool (is it a tool?) that makes
> those SPDX changes would have room for improvement in that regard.
> It seems to expect that all of the license information is contained
> within the same comment block, which wasn't the case for the iforce
> driver.
Right. I noticed too late, that these empty comments were left. Tool was
fixed for later patches.
Thanks for cleaning that up.
tglx
^ permalink raw reply
* [PATCH 07/14] Input: cyapa - Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
From: Fuqian Huang @ 2019-07-08 12:33 UTC (permalink / raw)
Cc: Dmitry Torokhov, linux-input, linux-kernel, Fuqian Huang
devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
drivers/input/mouse/cyapa.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index dfd3873513e4..e1d9ab558ecf 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -840,10 +840,9 @@ static int cyapa_prepare_wakeup_controls(struct cyapa *cyapa)
return error;
}
- error = devm_add_action(dev,
+ error = devm_add_action_or_reset(dev,
cyapa_remove_power_wakeup_group, cyapa);
if (error) {
- cyapa_remove_power_wakeup_group(cyapa);
dev_err(dev, "failed to add power cleanup action: %d\n",
error);
return error;
@@ -957,9 +956,8 @@ static int cyapa_start_runtime(struct cyapa *cyapa)
return error;
}
- error = devm_add_action(dev, cyapa_remove_power_runtime_group, cyapa);
+ error = devm_add_action_or_reset(dev, cyapa_remove_power_runtime_group, cyapa);
if (error) {
- cyapa_remove_power_runtime_group(cyapa);
dev_err(dev,
"failed to add power runtime cleanup action: %d\n",
error);
@@ -1298,9 +1296,8 @@ static int cyapa_probe(struct i2c_client *client,
return error;
}
- error = devm_add_action(dev, cyapa_disable_regulator, cyapa);
+ error = devm_add_action_or_reset(dev, cyapa_disable_regulator, cyapa);
if (error) {
- cyapa_disable_regulator(cyapa);
dev_err(dev, "failed to add disable regulator action: %d\n",
error);
return error;
@@ -1318,9 +1315,8 @@ static int cyapa_probe(struct i2c_client *client,
return error;
}
- error = devm_add_action(dev, cyapa_remove_sysfs_group, cyapa);
+ error = devm_add_action_or_reset(dev, cyapa_remove_sysfs_group, cyapa);
if (error) {
- cyapa_remove_sysfs_group(cyapa);
dev_err(dev, "failed to add sysfs cleanup action: %d\n", error);
return error;
}
--
2.11.0
^ permalink raw reply related
* [PATCH 08/14] Input: elan_i2c - Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
From: Fuqian Huang @ 2019-07-08 12:33 UTC (permalink / raw)
Cc: Dmitry Torokhov, linux-input, linux-kernel, Fuqian Huang
devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
drivers/input/mouse/elan_i2c_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 420efaab3860..a8d4f3bd09bf 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1234,9 +1234,8 @@ static int elan_probe(struct i2c_client *client,
return error;
}
- error = devm_add_action(dev, elan_remove_sysfs_groups, data);
+ error = devm_add_action_or_reset(dev, elan_remove_sysfs_groups, data);
if (error) {
- elan_remove_sysfs_groups(data);
dev_err(dev, "Failed to add sysfs cleanup action: %d\n",
error);
return error;
--
2.11.0
^ permalink raw reply related
* [PATCH 10/14] Input: auo-pixcir-ts - Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
From: Fuqian Huang @ 2019-07-08 12:33 UTC (permalink / raw)
Cc: Dmitry Torokhov, linux-input, linux-kernel, Fuqian Huang
devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
drivers/input/touchscreen/auo-pixcir-ts.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index 8e48fbda487a..8e9f3b7b8180 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -602,9 +602,8 @@ static int auo_pixcir_probe(struct i2c_client *client,
return error;
}
- error = devm_add_action(&client->dev, auo_pixcir_reset, ts);
+ error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts);
if (error) {
- auo_pixcir_reset(ts);
dev_err(&client->dev, "failed to register reset action, %d\n",
error);
return error;
--
2.11.0
^ permalink raw reply related
* [PATCH] Input: synaptics-rmi4 - remove the exporting of rmi_2d_sensor_set_input_params
From: Denis Efremov @ 2019-07-08 17:21 UTC (permalink / raw)
To: Andrew Duggan; +Cc: Denis Efremov, Dmitry Torokhov, linux-input, linux-kernel
The function rmi_2d_sensor_set_input_params is declared static and marked
EXPORT_SYMBOL_GPL, which is at best an odd combination. Because the
function is not used outside of the drivers/input/rmi4/rmi_2d_sensor.c
file it is defined in, this commit removes the EXPORT_SYMBOL_GPL() marking.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
drivers/input/rmi4/rmi_2d_sensor.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
index ea549efe4bc4..b7fe6eb35a4e 100644
--- a/drivers/input/rmi4/rmi_2d_sensor.c
+++ b/drivers/input/rmi4/rmi_2d_sensor.c
@@ -204,7 +204,6 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
if (sensor->topbuttonpad)
set_bit(INPUT_PROP_TOPBUTTONPAD, input->propbit);
}
-EXPORT_SYMBOL_GPL(rmi_2d_sensor_set_input_params);
int rmi_2d_sensor_configure_input(struct rmi_function *fn,
struct rmi_2d_sensor *sensor)
--
2.21.0
^ permalink raw reply related
* Re: [PATCH] HID: apple: Fix stuck function keys when using FN
From: João Moreno @ 2019-07-08 20:35 UTC (permalink / raw)
To: Benjamin Tissoires; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml
In-Reply-To: <CAO-hwJ+1FyaXj0iuCjvc5R-Kqdh6PNB7Un0ko1F_NV7-f5GMdw@mail.gmail.com>
Hi Benjamin,
No worries, also pretty busy over here. Didn't mean to press.
On Mon, 1 Jul 2019 at 10:32, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
>
> Hi João,
>
> On Sun, Jun 30, 2019 at 10:15 PM João Moreno <mail@joaomoreno.com> wrote:
> >
> > Hi Jiri & Benjamin,
> >
> > Let me know if you need something else to get this patch moving forward. This
> > fixes an issue I hit daily, it would be great to get it fixed.
>
> Sorry for the delay, I am very busy with internal corporate stuff, and
> I tried setting up a new CI system at home, and instead of spending a
> couple of ours, I am down to 2 weeks of hard work, without possibility
> to switch to the new right now :(
> Anyway.
>
> >
> > Thanks.
> >
> > On Mon, 10 Jun 2019 at 23:31, Joao Moreno <mail@joaomoreno.com> wrote:
> > >
> > > This fixes an issue in which key down events for function keys would be
> > > repeatedly emitted even after the user has raised the physical key. For
> > > example, the driver fails to emit the F5 key up event when going through
> > > the following steps:
> > > - fnmode=1: hold FN, hold F5, release FN, release F5
> > > - fnmode=2: hold F5, hold FN, release F5, release FN
>
> Ouch :/
>
Right?!
> > >
> > > The repeated F5 key down events can be easily verified using xev.
> > >
> > > Signed-off-by: Joao Moreno <mail@joaomoreno.com>
> > > ---
> > > drivers/hid/hid-apple.c | 21 +++++++++++----------
> > > 1 file changed, 11 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
> > > index 1cb41992aaa1..81867a6fa047 100644
> > > --- a/drivers/hid/hid-apple.c
> > > +++ b/drivers/hid/hid-apple.c
> > > @@ -205,20 +205,21 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
> > > trans = apple_find_translation (table, usage->code);
> > >
> > > if (trans) {
> > > - if (test_bit(usage->code, asc->pressed_fn))
> > > - do_translate = 1;
> > > - else if (trans->flags & APPLE_FLAG_FKEY)
> > > - do_translate = (fnmode == 2 && asc->fn_on) ||
> > > - (fnmode == 1 && !asc->fn_on);
> > > + int fn_on = value ? asc->fn_on :
> > > + test_bit(usage->code, asc->pressed_fn);
> > > +
> > > + if (!value)
> > > + clear_bit(usage->code, asc->pressed_fn);
> > > + else if (asc->fn_on)
> > > + set_bit(usage->code, asc->pressed_fn);
>
> I have the feeling that this is not the correct fix here.
>
> I might be wrong, but the following sequence might also mess up the
> driver state, depending on how the reports are emitted:
> - hold FN, hold F4, hold F5, release F4, release FN, release F5
>
I believe this should be fine. Following the code:
- hold FN, sets asc->fn_on to true
- hold F4, in the trans block fn_on will be true and we'll set the F4
bit in the bitmap
- hold F5, in the trans block fn_on will be true and we'll set the F5 bit
- release F4, in the trans block fn_on will be true (because of the bitmap) and
we'll clear the F4 bit
- release FN, asc->fn_on will be false, but it doesn't matter since...
- release F5, in the trans block we'll look into the bitmap (instead
of asc->fn_on),
so fn_on will be true and we'll clear the F5 bit
I tested it in practice using my changes:
Interestingly the Apple keyboard doesn't seem to emit an even for F5 when F4 is
pressed, seems like a hardware limitation. But F6 does work. So, when I execute
these events in that order, everything works as it should: xev reports
the following:
KeyPress F4
KeyPress F6
KeyRelease F4
KeyRelease F6
> The reason is that the driver only considers you have one key pressed
> with the modifier, and as the code changed its state based on the last
> value.
>
I believe the bitmap takes care of storing the FN state per key press. The
trick I did was to check on the global `asc->fn_on` state only when a key
is pressed, but check on the bitmap instead when it's released.
Let me know what you think. Am I missing something here?
Cheers,
João.
> IMO a better fix would:
>
> - keep the existing `trans` mapping lookout
> - whenever a `trans` mapping gets found:
> * get both translated and non-translated currently reported values
> (`test_bit(keycode, input_dev->key)`)
> * if one of them is set to true, then consider the keycode to be the
> one of the key (no matter fn_on)
> -> deal with `value` with the corrected keycode
> * if the key was not pressed:
> -> chose the keycode based on `fn_on` and `fnmode` states
> and report the key press event
>
> This should remove the nasty pressed_fn state which depends on the
> other pressed keys.
>
> Cheers,
> Benjamin
>
> > > +
> > > + if (trans->flags & APPLE_FLAG_FKEY)
> > > + do_translate = (fnmode == 2 && fn_on) ||
> > > + (fnmode == 1 && !fn_on);
> > > else
> > > do_translate = asc->fn_on;
> > >
> > > if (do_translate) {
> > > - if (value)
> > > - set_bit(usage->code, asc->pressed_fn);
> > > - else
> > > - clear_bit(usage->code, asc->pressed_fn);
> > > -
> > > input_event(input, usage->type, trans->to,
> > > value);
> > >
> > > --
> > > 2.19.1
> > >
^ permalink raw reply
* [PATCH] input: keyboard: sun4i-lradc-keys: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-07-09 17:57 UTC (permalink / raw)
To: hdegoede, dmitry.torokhov, maxime.ripard, wens, linux-input,
linux-arm-kernel
Cc: Nishka Dasgupta
Each iteration of for_each_child_of_node puts the previous
node, but in the case of a return from the middle of the loop, there is
no put, thus causing a memory leak. Hence add an of_node_put before the
return in three places.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
drivers/input/keyboard/sun4i-lradc-keys.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c
index 6ffdc26b9c89..4a796bed48ac 100644
--- a/drivers/input/keyboard/sun4i-lradc-keys.c
+++ b/drivers/input/keyboard/sun4i-lradc-keys.c
@@ -198,18 +198,21 @@ static int sun4i_lradc_load_dt_keymap(struct device *dev,
error = of_property_read_u32(pp, "channel", &channel);
if (error || channel != 0) {
dev_err(dev, "%pOFn: Inval channel prop\n", pp);
+ of_node_put(pp);
return -EINVAL;
}
error = of_property_read_u32(pp, "voltage", &map->voltage);
if (error) {
dev_err(dev, "%pOFn: Inval voltage prop\n", pp);
+ of_node_put(pp);
return -EINVAL;
}
error = of_property_read_u32(pp, "linux,code", &map->keycode);
if (error) {
dev_err(dev, "%pOFn: Inval linux,code prop\n", pp);
+ of_node_put(pp);
return -EINVAL;
}
--
2.19.1
^ permalink raw reply related
* [PATCH] input: keyboard: mtk-pmic-keys: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-07-09 18:00 UTC (permalink / raw)
To: matthias.bgg, dmitry.torokhov, linux-input, linux-arm-kernel,
linux-mediatek
Cc: Nishka Dasgupta
Each iteration of for_each_child_of_node puts the previous
node, but in the case of a return from the middle of the loop, there is
no put, thus causing a memory leak. Hence add an of_node_put before the
return in three places.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
drivers/input/keyboard/mtk-pmic-keys.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 746ff06eaf8d..62391d6c7da6 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -277,8 +277,10 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
keys->keys[index].irq = platform_get_irq(pdev, index);
- if (keys->keys[index].irq < 0)
+ if (keys->keys[index].irq < 0) {
+ of_node_put(child);
return keys->keys[index].irq;
+ }
error = of_property_read_u32(child,
"linux,keycodes", &keys->keys[index].keycode);
@@ -286,6 +288,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
dev_err(keys->dev,
"failed to read key:%d linux,keycode property: %d\n",
index, error);
+ of_node_put(child);
return error;
}
@@ -293,8 +296,10 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
keys->keys[index].wakeup = true;
error = mtk_pmic_key_setup(keys, &keys->keys[index]);
- if (error)
+ if (error) {
+ of_node_put(child);
return error;
+ }
index++;
}
--
2.19.1
^ permalink raw reply related
* [PATCH] input: touchscreen: add delay time to device power on
From: crag0715 @ 2019-07-10 2:58 UTC (permalink / raw)
Cc: mario_limonciello, chrome.os.engineering, Crag.Wang, Sangwon Jee,
Dmitry Torokhov, linux-input, linux-kernel
From: "Crag.Wang" <crag.wang@dell.com>
Delay time for MELFAS MIP4 controller is required at power on stage
regardless the existence of GPIO consumer lookup from devicetree or
ACPI device table.
There is an issue if GPIO ce is undefined in the ACPI results no delay
time for deive power on, the controller ended up in an abnormal state.
TEST=echo i2c-MLFS0000:00 > /sys/bus/i2c/drivers/mip4_ts/unbind
verify the touch function is off
echo i2c-MLFS0000:00 > /sys/bus/i2c/drivers/mip4_ts/bind
verify the touch function is on
Signed-off-by: Crag.Wang <crag.wang@dell.com>
---
drivers/input/touchscreen/melfas_mip4.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 430a2bc5f7ca..8e803658fb43 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -374,12 +374,11 @@ static int mip4_query_device(struct mip4_ts *ts)
static int mip4_power_on(struct mip4_ts *ts)
{
- if (ts->gpio_ce) {
+ if (ts->gpio_ce)
gpiod_set_value_cansleep(ts->gpio_ce, 1);
- /* Booting delay : 200~300ms */
- usleep_range(200 * 1000, 300 * 1000);
- }
+ /* Booting delay : 200~300ms */
+ usleep_range(200 * 1000, 300 * 1000);
return 0;
}
--
2.20.1
^ permalink raw reply related
* Re: [PATCH] input: touchscreen: add delay time to device power on
From: Crag Wang @ 2019-07-10 8:58 UTC (permalink / raw)
To: yjjung, jsj1012, leesh832
Cc: Mario Limonciello, chrome.os.engineering, Crag.Wang, Sangwon Jee,
Dmitry Torokhov, linux-input, linux-kernel
In-Reply-To: <20190710025859.6025-1-crag0715@gmail.com>
Adding more
On Wed, Jul 10, 2019 at 10:59 AM <crag0715@gmail.com> wrote:
>
> From: "Crag.Wang" <crag.wang@dell.com>
>
> Delay time for MELFAS MIP4 controller is required at power on stage
> regardless the existence of GPIO consumer lookup from devicetree or
> ACPI device table.
>
> There is an issue if GPIO ce is undefined in the ACPI results no delay
> time for deive power on, the controller ended up in an abnormal state.
>
> TEST=echo i2c-MLFS0000:00 > /sys/bus/i2c/drivers/mip4_ts/unbind
> verify the touch function is off
>
> echo i2c-MLFS0000:00 > /sys/bus/i2c/drivers/mip4_ts/bind
> verify the touch function is on
>
> Signed-off-by: Crag.Wang <crag.wang@dell.com>
> ---
> drivers/input/touchscreen/melfas_mip4.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
> index 430a2bc5f7ca..8e803658fb43 100644
> --- a/drivers/input/touchscreen/melfas_mip4.c
> +++ b/drivers/input/touchscreen/melfas_mip4.c
> @@ -374,12 +374,11 @@ static int mip4_query_device(struct mip4_ts *ts)
>
> static int mip4_power_on(struct mip4_ts *ts)
> {
> - if (ts->gpio_ce) {
> + if (ts->gpio_ce)
> gpiod_set_value_cansleep(ts->gpio_ce, 1);
>
> - /* Booting delay : 200~300ms */
> - usleep_range(200 * 1000, 300 * 1000);
> - }
> + /* Booting delay : 200~300ms */
> + usleep_range(200 * 1000, 300 * 1000);
>
> return 0;
> }
> --
> 2.20.1
>
^ permalink raw reply
* [PATCH] input: API for Setting a Timestamp from a Driver
From: Atif Niyaz @ 2019-07-10 23:04 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Atif Niyaz, Siarhei Vishniakou, linux-input, linux-kernel,
Atif Niyaz
Currently, evdev stamps time with timestamps acquired in
evdev_events. However, this timestamping may not be accurate in terms of
measuring when the actual event happened. This API allows any 3rd party
driver to be able to call input_set_timestamp, and provide a timestamp
that can be utilized in order to provide a more accurate sense of time
for the event
Signed-off-by: Atif Niyaz <atifniyaz@google.com>
---
drivers/input/evdev.c | 42 ++++++++++++++++--------------------------
drivers/input/input.c | 17 +++++++++++++++++
include/linux/input.h | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 26 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 867c2cfd0038..a331efa0a3f6 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -25,13 +25,6 @@
#include <linux/cdev.h>
#include "input-compat.h"
-enum evdev_clock_type {
- EV_CLK_REAL = 0,
- EV_CLK_MONO,
- EV_CLK_BOOT,
- EV_CLK_MAX
-};
-
struct evdev {
int open;
struct input_handle handle;
@@ -53,7 +46,7 @@ struct evdev_client {
struct fasync_struct *fasync;
struct evdev *evdev;
struct list_head node;
- unsigned int clk_type;
+ input_clk_t clk_type;
bool revoked;
unsigned long *evmasks[EV_CNT];
unsigned int bufsize;
@@ -150,16 +143,18 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
static void __evdev_queue_syn_dropped(struct evdev_client *client)
{
struct input_event ev;
- ktime_t time;
struct timespec64 ts;
+ ktime_t *time = input_get_timestamp(client->evdev->handle.dev);
- time = client->clk_type == EV_CLK_REAL ?
- ktime_get_real() :
- client->clk_type == EV_CLK_MONO ?
- ktime_get() :
- ktime_get_boottime();
+ switch (client->clk_type) {
+ case INPUT_CLK_REAL:
+ case INPUT_CLK_MONO:
+ ts = ktime_to_timespec64(time[client->clk_type]);
+ break;
+ default:
+ ts = ktime_to_timespec64(time[INPUT_CLK_BOOT]);
+ }
- ts = ktime_to_timespec64(time);
ev.input_event_sec = ts.tv_sec;
ev.input_event_usec = ts.tv_nsec / NSEC_PER_USEC;
ev.type = EV_SYN;
@@ -185,21 +180,21 @@ static void evdev_queue_syn_dropped(struct evdev_client *client)
spin_unlock_irqrestore(&client->buffer_lock, flags);
}
-static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
+static int evdev_set_clk_type(struct evdev_client *client, clockid_t clkid)
{
unsigned long flags;
- unsigned int clk_type;
+ input_clk_t clk_type;
switch (clkid) {
case CLOCK_REALTIME:
- clk_type = EV_CLK_REAL;
+ clk_type = INPUT_CLK_REAL;
break;
case CLOCK_MONOTONIC:
- clk_type = EV_CLK_MONO;
+ clk_type = INPUT_CLK_MONO;
break;
case CLOCK_BOOTTIME:
- clk_type = EV_CLK_BOOT;
+ clk_type = INPUT_CLK_BOOT;
break;
default:
return -EINVAL;
@@ -307,12 +302,7 @@ static void evdev_events(struct input_handle *handle,
{
struct evdev *evdev = handle->private;
struct evdev_client *client;
- ktime_t ev_time[EV_CLK_MAX];
-
- ev_time[EV_CLK_MONO] = ktime_get();
- ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
- ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
- TK_OFFS_BOOT);
+ ktime_t *ev_time = input_get_timestamp(handle->dev);
rcu_read_lock();
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7f3c5fcb9ed6..ae8b0ee58120 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1894,6 +1894,23 @@ void input_free_device(struct input_dev *dev)
}
EXPORT_SYMBOL(input_free_device);
+/**
+ * input_get_timestamp - get timestamp for input events
+ * @dev: input device to get timestamp from
+ *
+ * A valid timestamp is a timestamp of non-zero value.
+ */
+ktime_t *input_get_timestamp(struct input_dev *dev)
+{
+ const ktime_t invalid_timestamp = ktime_set(0, 0);
+
+ if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], ktime_zero)) {
+ input_set_timestamp(dev, ktime_get());
+ }
+ return dev->timestamp;
+}
+EXPORT_SYMBOL(input_get_timestamp);
+
/**
* input_set_capability - mark device as capable of a certain event
* @dev: device that is capable of emitting or accepting event
diff --git a/include/linux/input.h b/include/linux/input.h
index 510e78558c10..3929b62ccbe5 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -33,6 +33,14 @@ struct input_value {
__s32 value;
};
+enum input_clock_type {
+ INPUT_CLK_REAL = 0,
+ INPUT_CLK_MONO,
+ INPUT_CLK_BOOT,
+ INPUT_CLK_MAX
+};
+typedef enum input_clock_type input_clk_t;
+
/**
* struct input_dev - represents an input device
* @name: name of the device
@@ -114,6 +122,8 @@ struct input_value {
* @vals: array of values queued in the current frame
* @devres_managed: indicates that devices is managed with devres framework
* and needs not be explicitly unregistered or freed.
+ * @timestamp: storage for a timestamp set by input_set_timestamp called
+ * by a driver
*/
struct input_dev {
const char *name;
@@ -184,6 +194,8 @@ struct input_dev {
struct input_value *vals;
bool devres_managed;
+
+ ktime_t timestamp[INPUT_CLK_MAX];
};
#define to_input_dev(d) container_of(d, struct input_dev, dev)
@@ -382,6 +394,32 @@ void input_close_device(struct input_handle *);
int input_flush_device(struct input_handle *handle, struct file *file);
+/**
+ * input_set_timestamp - set timestamp for input events
+ * @dev: input device to set timestamp for
+ * @timestamp: the time at which the event has occurred
+ * in CLOCK_MONOTONIC
+ *
+ * This function is intended to provide to the input system a more
+ * accurate time of when an event actually occurred. The driver should
+ * call this function as soon as a timestamp is acquired ensuring
+ * clock conversions in input_set_timestamp are done correctly.
+ *
+ * The system entering a suspend between timestamp acquisition and
+ * calling input_set_timestamp can result in inaccurate conversions.
+ *
+ */
+static inline void input_set_timestamp(struct input_dev *dev,
+ ktime_t timestamp)
+{
+ dev->timestamp[INPUT_CLK_MONO] = timestamp;
+ dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp);
+ dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(
+ timestamp, TK_OFFS_BOOT);
+}
+
+ktime_t *input_get_timestamp(struct input_dev *dev);
+
void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
--
2.22.0.410.gd8fdbe21b5-goog
^ permalink raw reply related
* [PATCH] dt-bindings: input: Convert Allwinner LRADC to a schema
From: Maxime Ripard @ 2019-07-11 9:38 UTC (permalink / raw)
To: Mark Rutland, Rob Herring, Frank Rowand, Dmitry Torokhov
Cc: Maxime Ripard, devicetree, Chen-Yu Tsai, linux-arm-kernel,
linux-input
The Allwinner SoCs have an LRADC used to report keys and supported in
Linux, with a matching Device Tree binding.
Now that we have the DT validation in place, let's convert the device tree
bindings for that controller over to a YAML schemas.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
.../input/allwinner,sun4i-a10-lradc-keys.yaml | 95 +++++++++++++++++++
.../bindings/input/sun4i-lradc-keys.txt | 65 -------------
2 files changed, 95 insertions(+), 65 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml
delete mode 100644 Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
diff --git a/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml b/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml
new file mode 100644
index 000000000000..b3bd8ef7fbd6
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/allwinner,sun4i-a10-lradc-keys.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner A10 LRADC Device Tree Bindings
+
+maintainers:
+ - Chen-Yu Tsai <wens@csie.org>
+ - Maxime Ripard <maxime.ripard@bootlin.com>
+
+properties:
+ compatible:
+ oneOf:
+ - const: allwinner,sun4i-a10-lradc-keys
+ - const: allwinner,sun8i-a83t-r-lradc
+ - items:
+ - const: allwinner,sun50i-a64-lradc
+ - const: allwinner,sun8i-a83t-r-lradc
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ vref-supply:
+ description:
+ Regulator for the LRADC reference voltage
+
+patternProperties:
+ "^button-[0-9]+$":
+ type: object
+ properties:
+ label:
+ $ref: /schemas/types.yaml#/definitions/string
+ description: Descriptive name of the key
+
+ linux,code:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: Keycode to emit
+
+ channel:
+ allOf:
+ - $ref: /schemas/types.yaml#/definitions/uint32
+ - enum: [0, 1]
+ description: ADC Channel this key is attached to
+
+ voltage:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ Voltage in microvolts at LRADC input when this key is
+ pressed
+
+ required:
+ - label
+ - linux,code
+ - channel
+ - voltage
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - vref-supply
+
+additionalProperties: false
+
+examples:
+ - |
+ lradc: lradc@1c22800 {
+ compatible = "allwinner,sun4i-a10-lradc-keys";
+ reg = <0x01c22800 0x100>;
+ interrupts = <31>;
+ vref-supply = <®_vcc3v0>;
+
+ button-191 {
+ label = "Volume Up";
+ linux,code = <115>;
+ channel = <0>;
+ voltage = <191274>;
+ };
+
+ button-392 {
+ label = "Volume Down";
+ linux,code = <114>;
+ channel = <0>;
+ voltage = <392644>;
+ };
+ };
+
+...
diff --git a/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt b/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
deleted file mode 100644
index 507b737612ea..000000000000
--- a/Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-Allwinner sun4i low res adc attached tablet keys
-------------------------------------------------
-
-Required properties:
- - compatible: should be one of the following string:
- "allwinner,sun4i-a10-lradc-keys"
- "allwinner,sun8i-a83t-r-lradc"
- "allwinner,sun50i-a64-lradc", "allwinner,sun8i-a83t-r-lradc"
- - reg: mmio address range of the chip
- - interrupts: interrupt to which the chip is connected
- - vref-supply: powersupply for the lradc reference voltage
-
-Each key is represented as a sub-node of the compatible mentioned above:
-
-Required subnode-properties:
- - label: Descriptive name of the key.
- - linux,code: Keycode to emit.
- - channel: Channel this key is attached to, must be 0 or 1.
- - voltage: Voltage in µV at lradc input when this key is pressed.
-
-Example:
-
-#include <dt-bindings/input/input.h>
-
- lradc: lradc@1c22800 {
- compatible = "allwinner,sun4i-a10-lradc-keys";
- reg = <0x01c22800 0x100>;
- interrupts = <31>;
- vref-supply = <®_vcc3v0>;
-
- button@191 {
- label = "Volume Up";
- linux,code = <KEY_VOLUMEUP>;
- channel = <0>;
- voltage = <191274>;
- };
-
- button@392 {
- label = "Volume Down";
- linux,code = <KEY_VOLUMEDOWN>;
- channel = <0>;
- voltage = <392644>;
- };
-
- button@601 {
- label = "Menu";
- linux,code = <KEY_MENU>;
- channel = <0>;
- voltage = <601151>;
- };
-
- button@795 {
- label = "Enter";
- linux,code = <KEY_ENTER>;
- channel = <0>;
- voltage = <795090>;
- };
-
- button@987 {
- label = "Home";
- linux,code = <KEY_HOMEPAGE>;
- channel = <0>;
- voltage = <987387>;
- };
- };
--
2.21.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related
* [PATCH] Input: synaptics - enable RMI on ThinkPad T580
From: Kai-Heng Feng @ 2019-07-11 10:54 UTC (permalink / raw)
To: dmitry.torokhov
Cc: benjamin.tissoires, linux-input, linux-kernel, Kai-Heng Feng
Like the ThinkPad T560 case, now we can use RMI on T580 to have a more
responsive touchpad.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
drivers/input/mouse/synaptics.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index b8ec301025b7..eb3f642967ab 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -175,6 +175,7 @@ static const char * const smbus_pnp_ids[] = {
"LEN0092", /* X1 Carbon 6 */
"LEN0096", /* X280 */
"LEN0097", /* X280 -> ALPS trackpoint */
+ "LEN009b", /* T580 */
"LEN200f", /* T450s */
"LEN2054", /* E480 */
"LEN2055", /* E580 */
--
2.17.1
^ permalink raw reply related
* Re: [PATCH v3 3/3] iio: Add PAT9125 optical tracker sensor
From: Alexandre Mergnat @ 2019-07-11 19:39 UTC (permalink / raw)
To: Jonathan Cameron
Cc: robh+dt, mark.rutland, linux-kernel, linux-iio,
baylibre-upstreaming, Dmitry Torokhov, linux-input
In-Reply-To: <20190616163945.06bdbef0@archlinux>
Le dim. 16 juin 2019 à 17:39, Jonathan Cameron <jic23@kernel.org> a écrit :
>
> On Mon, 10 Jun 2019 11:29:45 +0200
> Alexandre Mergnat <amergnat@baylibre.com> wrote:
...
>
> > +/*
> > + * To detect if a new value is available, register status is checked. This
> > + * method is safer than using a flag on GPIO IRQ to track event while sampling
> > + * because falling edge is missed when device trig just after a read reg value
> > + * (that happen for fast motions or high CPI setting).
>
> So we have an edge triggered interrupt that doesn't have a 'minimum low'
> period? If so then the only safe way to handle it would be as a level
> interrupt. Can you do that here?
> (I once had the delights of a sensor like this tied to a edge sensitive only
> interrupt, but thankfully those are a rare thing these days).
>
Trigger level is the first setup I tried (and retried during
modifications) but it cannot
works despite of ONESHOT flag. I'm wrong or it's probably due to
nested_irq because
it works when I reset interrupt (by reading data) during one of the
IRQ thread, that what
I did in my V1 patch. I spent a lot of time to try to use level
trigger but this is the
best way I found to do it properly without corner cases.
The result with nested IRQ and low level trigger is a spamming IRQ
(probably due to IRQ no more masked during nested IRQ thread) who that stuck the
board because it hasn't time to make an I2C read to reset interrupt pin.
> > + * buffer mode and kernel warning due to nested IRQ thread,
> > + * this function must return 0.
> > + */
> > +static int pat9125_trig_try_reenable(struct iio_trigger *trig)
> > +{
> > + struct pat9125_data *data = iio_trigger_get_drvdata(trig);
> > + struct regmap *regmap = data->regmap;
> > + int status = 0;
> > +
> > + if (data->sampling) {
> > + regmap_read(regmap, PAT9125_MOTION_STATUS_REG, &status);
> > + if (status & PAT9125_VALID_MOTION_DATA_BIT) {
> > + data->sampling = false;
> So we only ever do 2 reads? Why can't we be unlucky on timing
> twice in a row?
That can works indefinitely, I tested for some retry in a row by
moving the chip fastly.
If the method blocked at 2 readings, I should have been stuck during this test.
If read status return "New data available", a new read value is done
through the same
process (that mean data->sampling put to true) thanks to nested IRQ
thread which will
call try_reenable again and then re-check pat9125 status.
^ permalink raw reply
* [PATCH] Input: gtco - bounds check collection indent level
From: Grant Hernandez @ 2019-07-11 22:22 UTC (permalink / raw)
To: dmitry.torokhov, linux-input; +Cc: linux-usb, Grant Hernandez, stable
The GTCO tablet input driver configures itself from an HID report sent
via USB during the initial enumeration process. Some debugging messages
are generated during the parsing. A debugging message indentation
counter is not bounds checked, leading to the ability for a specially
crafted HID report to cause '-' and null bytes be written past the end
of the indentation array. As long as the kernel has CONFIG_DYNAMIC_DEBUG
enabled, this code will not be optimized out. This was discovered
during code review after a previous syzkaller bug was found in this
driver.
Cc: stable@vger.kernel.org
Signed-off-by: Grant Hernandez <granthernandez@google.com>
---
drivers/input/tablet/gtco.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index 4b8b9d7aa75e..9771052ed027 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -78,6 +78,7 @@ Scott Hill shill@gtcocalcomp.com
/* Max size of a single report */
#define REPORT_MAX_SIZE 10
+#define MAX_COLLECTION_LEVELS 10
/* Bitmask whether pen is in range */
@@ -223,8 +224,7 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
char maintype = 'x';
char globtype[12];
int indent = 0;
- char indentstr[10] = "";
-
+ char indentstr[MAX_COLLECTION_LEVELS+1] = {0};
dev_dbg(ddev, "======>>>>>>PARSE<<<<<<======\n");
@@ -350,6 +350,12 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
case TAG_MAIN_COL_START:
maintype = 'S';
+ if (indent == MAX_COLLECTION_LEVELS) {
+ dev_err(ddev, "Collection level %d would exceed limit of %d\n",
+ indent+1, MAX_COLLECTION_LEVELS);
+ break;
+ }
+
if (data == 0) {
dev_dbg(ddev, "======>>>>>> Physical\n");
strcpy(globtype, "Physical");
@@ -369,8 +375,15 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report,
break;
case TAG_MAIN_COL_END:
- dev_dbg(ddev, "<<<<<<======\n");
maintype = 'E';
+
+ if (indent == 0) {
+ dev_err(ddev, "Collection level already at zero\n");
+ break;
+ }
+
+ dev_dbg(ddev, "<<<<<<======\n");
+
indent--;
for (x = 0; x < indent; x++)
indentstr[x] = '-';
--
2.22.0.410.gd8fdbe21b5-goog
^ permalink raw reply related
* [PATCH v2 0/3] mfd: mc13xxx: Fixes and enhancements for NXP's mc34708
From: Lukasz Majewski @ 2019-07-11 22:23 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
This patch set provides several enhancements to mc13xxx MFD family
of devices by introducing mc34708 as a separate device.
This IC has dedicated pen detection feature, which allows better
touchscreen experience.
This is the seconf version of this code (v2).
Discussion regarding v1 can be found here:
https://lkml.org/lkml/2018/4/12/351
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1661934.html
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1664296.html
Sascha Hauer (3):
mfd: mc13xxx: Add mc34708 adc support
input: touchscreen mc13xxx: Make platform data optional
input: touchscreen mc13xxx: Add mc34708 support
drivers/input/touchscreen/mc13783_ts.c | 74 ++++++++++++++++++++----
drivers/mfd/mc13xxx-core.c | 102 ++++++++++++++++++++++++++++++++-
drivers/mfd/mc13xxx.h | 3 +
include/linux/mfd/mc34708.h | 37 ++++++++++++
4 files changed, 204 insertions(+), 12 deletions(-)
create mode 100644 include/linux/mfd/mc34708.h
--
2.11.0
^ permalink raw reply
* [PATCH v2 1/3] mfd: mc13xxx: Add mc34708 adc support
From: Lukasz Majewski @ 2019-07-11 22:23 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190711222346.5245-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The mc34708 has an improved adc. The older variants will always convert
a fixed order of channels. The mc34708 can do up to eight conversions
in arbitrary channel order. Currently this extended feature is not
supported. We only support touchscreen conversions now, which will
be sampled in a data format compatible to the older chips in order
to keep the API between the mfd and the touchscreen driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v2:
- Change the return code patch when the mc13xxx ADC is performing conversion
- Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
defines
Changes from the original patches:
- ADC conversion functions prototypes added to fix build error
- Adjustments to make checkpatch clean (-ENOSYS, line over 80 char)
This patch applies on top of v5.2 - SHA1: 0ecfebd2b52404ae0c54a878c872bb93363ada36
---
drivers/mfd/mc13xxx-core.c | 102 +++++++++++++++++++++++++++++++++++++++++++-
drivers/mfd/mc13xxx.h | 3 ++
include/linux/mfd/mc34708.h | 37 ++++++++++++++++
3 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 include/linux/mfd/mc34708.h
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 1abe7432aad8..01473d6fda21 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -12,6 +12,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
+#include <linux/mfd/mc34708.h>
#include "mc13xxx.h"
@@ -45,6 +46,8 @@
#define MC13XXX_ADC2 45
+#define MC13XXX_ADC_WORKING (1 << 0)
+
void mc13xxx_lock(struct mc13xxx *mc13xxx)
{
if (!mutex_trylock(&mc13xxx->lock)) {
@@ -198,22 +201,30 @@ static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
maskval(revision, MC34708_REVISION_FAB));
}
+static int mc13xxx_adc_conversion(struct mc13xxx *, unsigned int,
+ unsigned int, u8, bool, unsigned int *);
+static int mc34708_adc_conversion(struct mc13xxx *, unsigned int,
+ unsigned int, u8, bool, unsigned int *);
+
/* These are only exported for mc13xxx-i2c and mc13xxx-spi */
struct mc13xxx_variant mc13xxx_variant_mc13783 = {
.name = "mc13783",
.print_revision = mc13xxx_print_revision,
+ .adc_do_conversion = mc13xxx_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13783);
struct mc13xxx_variant mc13xxx_variant_mc13892 = {
.name = "mc13892",
.print_revision = mc13xxx_print_revision,
+ .adc_do_conversion = mc13xxx_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892);
struct mc13xxx_variant mc13xxx_variant_mc34708 = {
.name = "mc34708",
.print_revision = mc34708_print_revision,
+ .adc_do_conversion = mc34708_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc34708);
@@ -249,7 +260,7 @@ static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data)
#define MC13XXX_ADC_WORKING (1 << 0)
-int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+static int mc13xxx_adc_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
unsigned int channel, u8 ato, bool atox,
unsigned int *sample)
{
@@ -358,6 +369,95 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
return ret;
}
+
+static int mc34708_adc_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample)
+{
+ int ret, i;
+ u32 adc0, adc3, adc1, old_adc0;
+ struct mc13xxx_adcdone_data adcdone_data = {
+ .mc13xxx = mc13xxx,
+ };
+
+ switch (mode) {
+ case MC13XXX_ADC_MODE_TS:
+ adc0 = MC34708_ADC0_TSEN | MC34708_ADC0_TSSTART |
+ MC34708_ADC0_TSSTOP(7);
+
+ adc1 = MC34708_ADC1_TSDLY1(0xf) |
+ MC34708_ADC1_TSDLY2(0xf) |
+ MC34708_ADC1_TSDLY3(0xf);
+
+ adc3 = MC34708_ADC3_TSSEL(0, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(1, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(2, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(3, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(4, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(5, MC34708_TS_R) |
+ MC34708_ADC3_TSSEL(6, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(7, MC34708_TS_R);
+ break;
+
+ case MC13XXX_ADC_MODE_SINGLE_CHAN:
+ case MC13XXX_ADC_MODE_MULT_CHAN:
+ default:
+ return -EINVAL;
+ }
+
+ init_completion(&adcdone_data.done);
+
+ mc13xxx_lock(mc13xxx);
+
+ if (mc13xxx->adcflags & MC13XXX_ADC_WORKING) {
+ mc13xxx_unlock(mc13xxx);
+ return -EBUSY;
+ }
+
+ mc13xxx->adcflags |= MC13XXX_ADC_WORKING;
+
+ mc13xxx_reg_read(mc13xxx, MC13XXX_ADC0, &old_adc0);
+
+ mc13xxx_irq_request(mc13xxx, MC34708_IRQ_TSDONE,
+ mc13xxx_handler_adcdone, __func__, &adcdone_data);
+ mc13xxx_irq_ack(mc13xxx, MC34708_IRQ_TSDONE);
+
+ mc13xxx_reg_write(mc13xxx, MC34708_ADC3, adc3);
+ mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
+ mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, adc0);
+
+ mc13xxx_unlock(mc13xxx);
+
+ ret = wait_for_completion_interruptible_timeout(&adcdone_data.done, HZ);
+
+ mc13xxx_lock(mc13xxx);
+
+ mc13xxx_irq_free(mc13xxx, MC34708_IRQ_TSDONE, &adcdone_data);
+
+ if (!ret) {
+ ret = -ETIMEDOUT;
+ goto out;
+ }
+
+ for (i = 0; i < 4; i++)
+ mc13xxx_reg_read(mc13xxx, MC34708_ADC4 + i, &sample[i]);
+
+out:
+ ret = mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, old_adc0);
+
+ mc13xxx->adcflags &= ~MC13XXX_ADC_WORKING;
+ mc13xxx_unlock(mc13xxx);
+
+ return ret;
+}
+
+int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample)
+{
+ return mc13xxx->variant->adc_do_conversion(mc13xxx, mode, channel, ato,
+ atox, sample);
+}
EXPORT_SYMBOL_GPL(mc13xxx_adc_do_conversion);
static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
index ce6eec52e8eb..0a79fbb8bcb4 100644
--- a/drivers/mfd/mc13xxx.h
+++ b/drivers/mfd/mc13xxx.h
@@ -19,6 +19,9 @@ struct mc13xxx;
struct mc13xxx_variant {
const char *name;
void (*print_revision)(struct mc13xxx *mc13xxx, u32 revision);
+ int (*adc_do_conversion)(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample);
};
extern struct mc13xxx_variant
diff --git a/include/linux/mfd/mc34708.h b/include/linux/mfd/mc34708.h
new file mode 100644
index 000000000000..c812104dc53d
--- /dev/null
+++ b/include/linux/mfd/mc34708.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2019
+ * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
+ */
+#ifndef __LINUX_MFD_MC34708_H
+#define __LINUX_MFD_MC34708_H
+
+#define MC34708_ADC3 46
+#define MC34708_ADC4 47
+
+#define MC34708_IRQ_TSDONE 1
+
+#define MC34708_ADC0_TSEN BIT(12)
+#define MC34708_ADC0_TSSTART BIT(13)
+#define MC34708_ADC0_TSCONT BIT(14)
+#define MC34708_ADC0_TSHOLD BIT(15)
+#define MC34708_ADC0_TSPENDETEN BIT(20)
+
+#define MC34708_ADC0_TSMASK (MC34708_ADC0_TSPENDETEN | \
+ MC34708_ADC0_TSEN | \
+ MC34708_ADC0_TSSTART | \
+ MC34708_ADC0_TSCONT | \
+ MC34708_ADC0_TSHOLD)
+
+#define MC34708_ADC0_TSSTOP(x) (((x) & 0x7) << 16)
+
+#define MC34708_ADC3_TSSEL(step, ch) ((ch) << (8 + 2 * (step)))
+#define MC34708_ADC1_TSDLY1(d) ((d) << 12)
+#define MC34708_ADC1_TSDLY2(d) ((d) << 16)
+#define MC34708_ADC1_TSDLY3(d) ((d) << 20)
+
+#define MC34708_TS_X 1
+#define MC34708_TS_Y 2
+#define MC34708_TS_R 3
+
+#endif /* __LINUX_MFD_MC34708_H */
--
2.11.0
^ permalink raw reply related
* [PATCH v2 2/3] input: touchscreen mc13xxx: Make platform data optional
From: Lukasz Majewski @ 2019-07-11 22:23 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190711222346.5245-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The platform data once was optional, make it optional again. This
is a first step towards device tree support for the mc13xxx touchscreen
driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v2:
- None
Changes from the original patch:
- Commit message typo fixes
---
drivers/input/touchscreen/mc13783_ts.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index ae0d978c83bf..edd49e44e0c9 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -35,7 +35,8 @@ struct mc13783_ts_priv {
struct mc13xxx *mc13xxx;
struct delayed_work work;
unsigned int sample[4];
- struct mc13xxx_ts_platform_data *touch;
+ u8 ato;
+ bool atox;
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -125,7 +126,7 @@ static void mc13783_ts_work(struct work_struct *work)
if (mc13xxx_adc_do_conversion(priv->mc13xxx,
mode, channel,
- priv->touch->ato, priv->touch->atox,
+ priv->ato, priv->atox,
priv->sample) == 0)
mc13783_ts_report_sample(priv);
}
@@ -169,6 +170,7 @@ static void mc13783_ts_close(struct input_dev *dev)
static int __init mc13783_ts_probe(struct platform_device *pdev)
{
struct mc13783_ts_priv *priv;
+ struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
int ret = -ENOMEM;
@@ -180,11 +182,10 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
- priv->touch = dev_get_platdata(&pdev->dev);
- if (!priv->touch) {
- dev_err(&pdev->dev, "missing platform data\n");
- ret = -ENODEV;
- goto err_free_mem;
+
+ if (pdata) {
+ priv->atox = pdata->atox;
+ priv->ato = pdata->ato;
}
idev->name = MC13783_TS_NAME;
--
2.11.0
^ permalink raw reply related
* [PATCH v2 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Lukasz Majewski @ 2019-07-11 22:23 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190711222346.5245-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The mc34708 has a different bit to enable pen detection. This
adds the driver data and devtype necessary to probe the device
and to distinguish between the mc13783 and the mc34708.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v2:
- Change nested if statements to a single one (with cr0 > ...)
- Replace hardcoded max resistance value (4080) with a generic driver data
value.
- Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
defines
- Define as driver data mask and value for accessing mc13xxx registers
Changes from the original patch:
- Simplify the mcXXXXX_set_pen_detection functions
- Fix checkpatch warnings
---
drivers/input/touchscreen/mc13783_ts.c | 59 +++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index edd49e44e0c9..8fd3d0e47f57 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -10,6 +10,7 @@
*/
#include <linux/platform_device.h>
#include <linux/mfd/mc13783.h>
+#include <linux/mfd/mc34708.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/input.h>
@@ -30,6 +31,8 @@ MODULE_PARM_DESC(sample_tolerance,
"is supposed to be wrong and is discarded. Set to 0 to "
"disable this check.");
+struct mc13xxx_driver_data;
+
struct mc13783_ts_priv {
struct input_dev *idev;
struct mc13xxx *mc13xxx;
@@ -37,6 +40,33 @@ struct mc13783_ts_priv {
unsigned int sample[4];
u8 ato;
bool atox;
+ struct mc13xxx_driver_data *drvdata;
+};
+
+enum mc13xxx_type {
+ MC13XXX_TYPE_MC13783,
+ MC13XXX_TYPE_MC34708,
+};
+
+struct mc13xxx_driver_data {
+ enum mc13xxx_type type;
+ int max_resistance;
+ u32 reg_mask;
+ u32 reg_value;
+};
+
+static struct mc13xxx_driver_data mc13783_driver_data = {
+ .type = MC13XXX_TYPE_MC13783,
+ .max_resistance = 4096,
+ .reg_mask = MC13XXX_ADC0_TSMOD_MASK,
+ .reg_value = MC13XXX_ADC0_TSMOD0,
+};
+
+static struct mc13xxx_driver_data mc34708_driver_data = {
+ .type = MC13XXX_TYPE_MC34708,
+ .max_resistance = 4080,
+ .reg_mask = MC34708_ADC0_TSMASK,
+ .reg_value = MC34708_ADC0_TSPENDETEN,
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -93,6 +123,10 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
cr0 = (cr0 + cr1) / 2;
+ if (priv->drvdata->type == MC13XXX_TYPE_MC34708 &&
+ cr0 > priv->drvdata->max_resistance)
+ cr0 = 0;
+
if (!cr0 || !sample_tolerance ||
(x2 - x0 < sample_tolerance &&
y2 - y0 < sample_tolerance)) {
@@ -102,14 +136,14 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
input_report_abs(idev, ABS_Y, y1);
dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
- x1, y1, 0x1000 - cr0);
+ x1, y1, priv->drvdata->max_resistance - cr0);
schedule_delayed_work(&priv->work, HZ / 50);
} else {
dev_dbg(&idev->dev, "report release\n");
}
input_report_abs(idev, ABS_PRESSURE,
- cr0 ? 0x1000 - cr0 : cr0);
+ cr0 ? priv->drvdata->max_resistance - cr0 : 0);
input_report_key(idev, BTN_TOUCH, cr0);
input_sync(idev);
} else {
@@ -146,7 +180,8 @@ static int mc13783_ts_open(struct input_dev *dev)
goto out;
ret = mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
- MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
+ priv->drvdata->reg_mask,
+ priv->drvdata->reg_value);
if (ret)
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
out:
@@ -160,7 +195,7 @@ static void mc13783_ts_close(struct input_dev *dev)
mc13xxx_lock(priv->mc13xxx);
mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
- MC13XXX_ADC0_TSMOD_MASK, 0);
+ priv->drvdata->reg_mask, 0);
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
mc13xxx_unlock(priv->mc13xxx);
@@ -172,6 +207,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
struct mc13783_ts_priv *priv;
struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
+ const struct platform_device_id *id = platform_get_device_id(pdev);
int ret = -ENOMEM;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -182,6 +218,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
+ priv->drvdata = (void *)id->driver_data;
if (pdata) {
priv->atox = pdata->atox;
@@ -228,7 +265,21 @@ static int mc13783_ts_remove(struct platform_device *pdev)
return 0;
}
+static const struct platform_device_id mc13xxx_ts_idtable[] = {
+ {
+ .name = "mc13783-ts",
+ .driver_data = (kernel_ulong_t)&mc13783_driver_data,
+ }, {
+ .name = "mc34708-ts",
+ .driver_data = (kernel_ulong_t)&mc34708_driver_data,
+ }, {
+ /* sentinel */
+ }
+};
+MODULE_DEVICE_TABLE(platform, mc13xxx_ts_idtable);
+
static struct platform_driver mc13783_ts_driver = {
+ .id_table = mc13xxx_ts_idtable,
.remove = mc13783_ts_remove,
.driver = {
.name = MC13783_TS_NAME,
--
2.11.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox