* Re: [PATCH] Input: atmel_mxt_ts: Add of node type to the i2c table
From: Wolfram Sang @ 2014-09-11 11:08 UTC (permalink / raw)
To: Nick Dyer
Cc: Javier Martinez Canillas, Sjoerd Simons, Lee Jones,
Dmitry Torokhov, linux-input, linux-kernel, linux-samsung-soc,
Bowens, Alan
In-Reply-To: <5411693A.3050300@itdev.co.uk>
[-- Attachment #1: Type: text/plain, Size: 3293 bytes --]
Funny timing. I am just reviewing the series from Lee and also stumbled
over modaliases, too...
On Thu, Sep 11, 2014 at 10:19:54AM +0100, Nick Dyer wrote:
> On 11/09/14 09:38, Javier Martinez Canillas wrote:
> > To expand on what Sjoerd already said and just to be sure everyone is on the
> > same page.
> >
> > The problem is that right now the driver reports the following modalias:
> >
> > # cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
> > i2c:maxtouch
> >
> > but if you look at the module information, that is not a valid alias:
> >
> > # modinfo atmel_mxt_ts | grep alias
> > alias: i2c:mXT224
> > alias: i2c:atmel_mxt_tp
> > alias: i2c:atmel_mxt_ts
> > alias: i2c:qt602240_ts
> > alias: of:N*T*Catmel,maxtouch*
> >
> > which means that udev/kmod can't load the module automatically based on the
> > alias information.
> >
> > The aliases are filled by both MODULE_DEVICE_TABLE(i2c, mxt_id) and
> > MODULE_DEVICE_TABLE(of, mxt_of_match) so after Sjoerd's patch:
> >
> > # cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
> > i2c:maxtouch
> >
> > # modinfo atmel_mxt_ts | grep alias
> > alias: i2c:mXT224
> > alias: i2c:maxtouch
> > alias: i2c:atmel_mxt_tp
> > alias: i2c:atmel_mxt_ts
> > alias: i2c:qt602240_ts
> >
> > which matches the reported uevent so the module will be auto-loaded.
> >
> > This is because the I2C subsystem hardcodes i2c:<client->name>, if you look at
> > drivers/i2c/i2c-core.c:
> >
> > /* uevent helps with hotplug: modprobe -q $(MODALIAS) */
> > static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
> > {
> > ...
> > if (add_uevent_var(env, "MODALIAS=%s%s",
> > I2C_MODULE_PREFIX, client->name))
> > ...
> > }
> >
> > I've looked at Lee's series and AFAICT that remains the same so I second
> > Sjoerd that module auto-loading will continue to be broken.
I think the above code in the i2c core needs a fix. Will have a closer
look after lunch.
> The i2c aliases are a bit confusing. The original device the driver was
> written for was called qt602240, which was renamed by Atmel to mXT224 when
> the chip series was called "maXTouch". The driver now actually supports
> many other chips which aren't listed (more than 20 devices that I've
> personally tested). I could add them all, but it would be an extremely long
> list. It may be preferable to use the generic name maXTouch.
This is probably true for some more I2C devices. Like RTCs being
compatible or, most prominent, EEPROMS. I don't want to have a list of
all vendors producing 24c02s if they are all compatible. If generic
entries are frowned upon, I'd agree on a "first come, first served" policy:
Somebody provides one compatible-property with the vendor which happens
to be on that board, and the others have to reuse that
compatible-property since they are, well, compatible.
> So I think the sensible thing to do here would be to add "maxtouch" to the
> i2c list to fix the module autoload issue.
This is a workaround. It would make sense, however, to add it because we
want to support i2c_board_info structures.
Regards,
Wolfram
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: [PATCH] Input: atmel_mxt_ts: Add of node type to the i2c table
From: Javier Martinez Canillas @ 2014-09-11 9:54 UTC (permalink / raw)
To: Nick Dyer, Sjoerd Simons, Lee Jones, Wolfram Sang
Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-samsung-soc,
Bowens, Alan
In-Reply-To: <5411693A.3050300@itdev.co.uk>
Hello Nick,
On 09/11/2014 11:19 AM, Nick Dyer wrote:
>
> Thanks for the clear explanation.
>
> The i2c aliases are a bit confusing. The original device the driver was
> written for was called qt602240, which was renamed by Atmel to mXT224 when
> the chip series was called "maXTouch". The driver now actually supports
> many other chips which aren't listed (more than 20 devices that I've
> personally tested). I could add them all, but it would be an extremely long
> list. It may be preferable to use the generic name maXTouch.
>
> So I think the sensible thing to do here would be to add "maxtouch" to the
> i2c list to fix the module autoload issue.
>
While this will actually fix the module auto-load issue on the atmel driver,
I'm concerned that the I2C core is not reporting the correct module
'of:N*T*Catmel,maxtouch*' alias when probing using DT.
Since as Lee said on his cover letter for the mentioned series [0], an I2C ID
table shouldn't be mandatory for drivers that only support DT based platforms
(e.g: a driver that depends on OF) but in that case I2C module auto-loading
would not work AFAICT.
Best regards,
Javier
[0]: https://lkml.org/lkml/2014/6/20/199
^ permalink raw reply
* Re: [PATCH] Input: atmel_mxt_ts: Add of node type to the i2c table
From: Nick Dyer @ 2014-09-11 9:19 UTC (permalink / raw)
To: Javier Martinez Canillas, Sjoerd Simons, Lee Jones, Wolfram Sang
Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-samsung-soc,
Bowens, Alan
In-Reply-To: <54115F6E.3010007@collabora.co.uk>
On 11/09/14 09:38, Javier Martinez Canillas wrote:
> To expand on what Sjoerd already said and just to be sure everyone is on the
> same page.
>
> The problem is that right now the driver reports the following modalias:
>
> # cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
> i2c:maxtouch
>
> but if you look at the module information, that is not a valid alias:
>
> # modinfo atmel_mxt_ts | grep alias
> alias: i2c:mXT224
> alias: i2c:atmel_mxt_tp
> alias: i2c:atmel_mxt_ts
> alias: i2c:qt602240_ts
> alias: of:N*T*Catmel,maxtouch*
>
> which means that udev/kmod can't load the module automatically based on the
> alias information.
>
> The aliases are filled by both MODULE_DEVICE_TABLE(i2c, mxt_id) and
> MODULE_DEVICE_TABLE(of, mxt_of_match) so after Sjoerd's patch:
>
> # cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
> i2c:maxtouch
>
> # modinfo atmel_mxt_ts | grep alias
> alias: i2c:mXT224
> alias: i2c:maxtouch
> alias: i2c:atmel_mxt_tp
> alias: i2c:atmel_mxt_ts
> alias: i2c:qt602240_ts
>
> which matches the reported uevent so the module will be auto-loaded.
>
> This is because the I2C subsystem hardcodes i2c:<client->name>, if you look at
> drivers/i2c/i2c-core.c:
>
> /* uevent helps with hotplug: modprobe -q $(MODALIAS) */
> static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
> {
> ...
> if (add_uevent_var(env, "MODALIAS=%s%s",
> I2C_MODULE_PREFIX, client->name))
> ...
> }
>
> I've looked at Lee's series and AFAICT that remains the same so I second
> Sjoerd that module auto-loading will continue to be broken.
Thanks for the clear explanation.
The i2c aliases are a bit confusing. The original device the driver was
written for was called qt602240, which was renamed by Atmel to mXT224 when
the chip series was called "maXTouch". The driver now actually supports
many other chips which aren't listed (more than 20 devices that I've
personally tested). I could add them all, but it would be an extremely long
list. It may be preferable to use the generic name maXTouch.
So I think the sensible thing to do here would be to add "maxtouch" to the
i2c list to fix the module autoload issue.
^ permalink raw reply
* [PATCH 3/3] psmouse: Add support for detecting FocalTech PS/2 touchpads
From: Hans de Goede @ 2014-09-11 8:50 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Peter Hutterer, Benjamin Tissoires, linux-input, Hans de Goede
In-Reply-To: <1410425447-9575-1-git-send-email-hdegoede@redhat.com>
The Asus X450 and X550 laptops use a PS/2 touchpad from a new manufacturer
called FocalTech:
https://bugzilla.kernel.org/show_bug.cgi?id=77391
https://bugzilla.redhat.com/show_bug.cgi?id=1110011
The protocol for these devices is not known at this time, but even without
knowing the protocol they need some special handling. They get upset by some
of our other PS/2 device probing, and once upset generate random mouse events
making things unusable even with an external mouse.
This patch adds detection of these devices based on their pnp ids, and when
they are detected, treats them as a bare ps/2 mouse. Doing things this way
they at least work in their ps/2 mouse emulation mode.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/mouse/Makefile | 2 +-
drivers/input/mouse/focaltech.c | 44 ++++++++++++++++++++++++++++++++++++++
drivers/input/mouse/focaltech.h | 21 ++++++++++++++++++
drivers/input/mouse/psmouse-base.c | 10 +++++++++
4 files changed, 76 insertions(+), 1 deletion(-)
create mode 100644 drivers/input/mouse/focaltech.c
create mode 100644 drivers/input/mouse/focaltech.h
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index c25efdb..dda507f 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_MOUSE_SYNAPTICS_I2C) += synaptics_i2c.o
obj-$(CONFIG_MOUSE_SYNAPTICS_USB) += synaptics_usb.o
obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o
-psmouse-objs := psmouse-base.o synaptics.o
+psmouse-objs := psmouse-base.o synaptics.o focaltech.o
psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
psmouse-$(CONFIG_MOUSE_PS2_ELANTECH) += elantech.o
diff --git a/drivers/input/mouse/focaltech.c b/drivers/input/mouse/focaltech.c
new file mode 100644
index 0000000..d83a235
--- /dev/null
+++ b/drivers/input/mouse/focaltech.c
@@ -0,0 +1,44 @@
+/*
+ * Focaltech TouchPad PS/2 mouse driver
+ *
+ * Copyright (c) 2014 Red Hat Inc.
+ *
+ * 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.
+ *
+ * Red Hat authors:
+ *
+ * Hans de Goede <hdegoede@redhat.com>
+ */
+
+/*
+ * The Focaltech PS/2 touchpad protocol is unknown. This drivers deals with
+ * detection only, to avoid further detection attempts confusing the touchpad
+ * this way it at least works in PS/2 mouse compatibility mode.
+ */
+
+#include <linux/device.h>
+#include <linux/libps2.h>
+#include "psmouse.h"
+
+static const char * const focaltech_pnp_ids[] = {
+ "FLT0101",
+ "FLT0102",
+ "FLT0103",
+ NULL
+};
+
+int focaltech_detect(struct psmouse *psmouse, bool set_properties)
+{
+ if (!psmouse_matches_pnp_id(psmouse, focaltech_pnp_ids))
+ return -ENODEV;
+
+ if (set_properties) {
+ psmouse->vendor = "FocalTech";
+ psmouse->name = "FocalTech Touchpad in mouse emulation mode";
+ }
+
+ return 0;
+}
diff --git a/drivers/input/mouse/focaltech.h b/drivers/input/mouse/focaltech.h
new file mode 100644
index 0000000..0d0fc49
--- /dev/null
+++ b/drivers/input/mouse/focaltech.h
@@ -0,0 +1,21 @@
+/*
+ * Focaltech TouchPad PS/2 mouse driver
+ *
+ * Copyright (c) 2014 Red Hat Inc.
+ *
+ * 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.
+ *
+ * Red Hat authors:
+ *
+ * Hans de Goede <hdegoede@redhat.com>
+ */
+
+#ifndef _FOCALTECH_H
+#define _FOCALTECH_H
+
+int focaltech_detect(struct psmouse *psmouse, bool set_properties);
+
+#endif
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 02e68c3..2c8c8e2 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -35,6 +35,7 @@
#include "elantech.h"
#include "sentelic.h"
#include "cypress_ps2.h"
+#include "focaltech.h"
#define DRIVER_DESC "PS/2 mouse driver"
@@ -722,6 +723,13 @@ static int psmouse_extensions(struct psmouse *psmouse,
{
bool synaptics_hardware = false;
+/* Always check for focaltech, this is safe as it uses pnp-id matching */
+ if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
+ /* Not supported yet, use bare protocol */
+ psmouse_max_proto = max_proto = PSMOUSE_PS2;
+ goto reset_to_defaults;
+ }
+
/*
* We always check for lifebook because it does not disturb mouse
* (it only checks DMI information).
@@ -873,6 +881,8 @@ static int psmouse_extensions(struct psmouse *psmouse,
}
}
+reset_to_defaults:
+
/*
* Reset to defaults in case the device got confused by extended
* protocol probes. Note that we follow up with full reset because
--
2.1.0
^ permalink raw reply related
* [PATCH 2/3] psmouse: Add psmouse_matches_pnp_id helper function
From: Hans de Goede @ 2014-09-11 8:50 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Peter Hutterer, Benjamin Tissoires, linux-input, Hans de Goede
In-Reply-To: <1410425447-9575-1-git-send-email-hdegoede@redhat.com>
The matches_pnp_id function from the synaptics driver is useful for other
drivers too. Make it a generic psmouse helper function.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/mouse/psmouse-base.c | 14 ++++++++++++++
drivers/input/mouse/psmouse.h | 1 +
drivers/input/mouse/synaptics.c | 17 +++--------------
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index b4e1f01..02e68c3 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -462,6 +462,20 @@ static int psmouse_poll(struct psmouse *psmouse)
PSMOUSE_CMD_POLL | (psmouse->pktsize << 8));
}
+/*
+ * psmouse_matches_pnp_id - check if psmouse matches one of the passed in ids.
+ */
+bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
+{
+ int i;
+
+ if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4))
+ for (i = 0; ids[i]; i++)
+ if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i]))
+ return true;
+
+ return false;
+}
/*
* Genius NetMouse magic init.
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 2f0b39d..f4cf664 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -108,6 +108,7 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse);
int psmouse_activate(struct psmouse *psmouse);
int psmouse_deactivate(struct psmouse *psmouse);
+bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]);
struct psmouse_attribute {
struct device_attribute dattr;
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index e8573c6..854caca 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -185,18 +185,6 @@ static const char * const topbuttonpad_pnp_ids[] = {
NULL
};
-static bool matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
-{
- int i;
-
- if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4))
- for (i = 0; ids[i]; i++)
- if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i]))
- return true;
-
- return false;
-}
-
/*****************************************************************************
* Synaptics communications functions
****************************************************************************/
@@ -362,7 +350,8 @@ static int synaptics_resolution(struct psmouse *psmouse)
}
for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
- if (matches_pnp_id(psmouse, min_max_pnpid_table[i].pnp_ids)) {
+ if (psmouse_matches_pnp_id(psmouse,
+ min_max_pnpid_table[i].pnp_ids)) {
priv->x_min = min_max_pnpid_table[i].x_min;
priv->x_max = min_max_pnpid_table[i].x_max;
priv->y_min = min_max_pnpid_table[i].y_min;
@@ -1456,7 +1445,7 @@ static void set_input_params(struct psmouse *psmouse,
if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
- if (matches_pnp_id(psmouse, topbuttonpad_pnp_ids))
+ if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids))
__set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit);
/* Clickpads report only left button */
__clear_bit(BTN_RIGHT, dev->keybit);
--
2.1.0
^ permalink raw reply related
* [PATCH 1/3] i8042: Also store the aux firmware id in multi-plexed aux ports
From: Hans de Goede @ 2014-09-11 8:50 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Peter Hutterer, Benjamin Tissoires, linux-input, Hans de Goede
So that firmware-id matching can be used with multiplexed aux ports too.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/serio/i8042.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 3807c3e..f5a98af 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1254,6 +1254,8 @@ static int __init i8042_create_aux_port(int idx)
} else {
snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx);
snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1);
+ strlcpy(serio->firmware_id, i8042_aux_firmware_id,
+ sizeof(serio->firmware_id));
}
port->serio = serio;
--
2.1.0
^ permalink raw reply related
* Re: [PATCH] Handle spurious backslash key repeats on some keyboards
From: Fredrik Hallenberg @ 2014-09-11 8:50 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: David Herrmann, Jiri Kosina, open list:HID CORE LAYER
In-Reply-To: <20140910225134.GH38736@core.coreip.homeip.net>
>> The nicest fix, obviously, is to blacklist keys that are not
>> physically present on the keyboard. But I assume the keyboard reports
>
> Hmm, somebody could still load keymap with duplicate keycodes though...
>
The HID mapping is hardcoded, so only key code 43 will have this
problem regardless of user keymaps.
Regarding blacklisting it would be good but I don't think there is any
way to know in advance which key (0x31 or 0x32) the keyboard actually
uses. If anybody has ideas on how this could be done let me know.
Jiri, do you still think this should be a hardware specific quirk?
^ permalink raw reply
* [PATCH] i8042: Add nomux quirk for Avatar AVIU-145A6
From: Hans de Goede @ 2014-09-11 8:46 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Hugo P, linux-input, Hans de Goede, stable
The sys_vendor / product_name are somewhat generic unfortunately, so this
may lead to some false positives. But nomux usually does no harm, where as
not having it clearly is causing problems on the Avatar AVIU-145A6.
https://bugzilla.kernel.org/show_bug.cgi?id=77391
Cc: stable@vger.kernel.org
Reported-by: Hugo P <saurosii@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/serio/i8042-x86ia64io.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 2f08daa..713e3dd 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -465,6 +465,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
},
},
+ {
+ /* Avatar AVIU-145A6 */
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
+ },
+ },
{ }
};
--
2.1.0
^ permalink raw reply related
* Re: [PATCH] Input: atmel_mxt_ts: Add of node type to the i2c table
From: Javier Martinez Canillas @ 2014-09-11 8:38 UTC (permalink / raw)
To: Sjoerd Simons, Lee Jones, Wolfram Sang
Cc: Dmitry Torokhov, Nick Dyer, linux-input, linux-kernel,
linux-samsung-soc
In-Reply-To: <1410422429.2857.16.camel@collabora.co.uk>
Hello Lee,
On 09/11/2014 10:00 AM, Sjoerd Simons wrote:
>> > >
>> > > -static const struct of_device_id mxt_of_match[] = {
>> > > - { .compatible = "atmel,maxtouch", },
>> > > - {},
>> > > -};
>> > > -MODULE_DEVICE_TABLE(of, mxt_of_match);
>> > > -
>> > > static const struct i2c_device_id mxt_id[] = {
>> > > { "qt602240_ts", 0 },
>> > > { "atmel_mxt_ts", 0 },
>> > > { "atmel_mxt_tp", 0 },
>> > > + { "maxtouch", 0 },
>> > > { "mXT224", 0 },
>> > > { }
>> > > };
>> > > @@ -2286,7 +2281,6 @@ static struct i2c_driver mxt_driver = {
>> > > .driver = {
>> > > .name = "atmel_mxt_ts",
>> > > .owner = THIS_MODULE,
>> > > - .of_match_table = of_match_ptr(mxt_of_match),
>> > > .pm = &mxt_pm_ops,
>> > > },
>> > > .probe = mxt_probe,
>> > >
>> >
>> > I see that Lee is working to allow the I2C subsystem to not need an I2C ID
>> > table to match [0]. I'll let Lee to comment what the future plans are and if
>> > his series are going to solve your issue since I'm not that familiar with the
>> > I2C core.
>>
>> It's wrong to expect DT to probe these devices without a compatible
>> string. It does so at the moment, but this is a bi-product and not
>> the correct method.
>
> Ok, which means removing the mxt_of_match table in this patch is wrong..
> I'll fix that for for a V2.
>
> However that makes adding the "maxtouch" string to the i2c device table
> somewhat cumbersome as it only gets added in this case to ensure
> module-autoloading can happen as the modalias presented to userspace is
> going still going to be i2c:maxtouch.
>
> Tbh, the bigger problem this is pointing out is that for I2C devices
> with only an OF compability tring module auto-loading is broken...
>
To expand on what Sjoerd already said and just to be sure everyone is on the
same page.
The problem is that right now the driver reports the following modalias:
# cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
i2c:maxtouch
but if you look at the module information, that is not a valid alias:
# modinfo atmel_mxt_ts | grep alias
alias: i2c:mXT224
alias: i2c:atmel_mxt_tp
alias: i2c:atmel_mxt_ts
alias: i2c:qt602240_ts
alias: of:N*T*Catmel,maxtouch*
which means that udev/kmod can't load the module automatically based on the
alias information.
The aliases are filled by both MODULE_DEVICE_TABLE(i2c, mxt_id) and
MODULE_DEVICE_TABLE(of, mxt_of_match) so after Sjoerd's patch:
# cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
i2c:maxtouch
# modinfo atmel_mxt_ts | grep alias
alias: i2c:mXT224
alias: i2c:maxtouch
alias: i2c:atmel_mxt_tp
alias: i2c:atmel_mxt_ts
alias: i2c:qt602240_ts
which matches the reported uevent so the module will be auto-loaded.
This is because the I2C subsystem hardcodes i2c:<client->name>, if you look at
drivers/i2c/i2c-core.c:
/* uevent helps with hotplug: modprobe -q $(MODALIAS) */
static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
{
...
if (add_uevent_var(env, "MODALIAS=%s%s",
I2C_MODULE_PREFIX, client->name))
...
}
I've looked at Lee's series and AFAICT that remains the same so I second
Sjoerd that module auto-loading will continue to be broken.
Best regards,
Javier
^ permalink raw reply
* Re: [PATCH 1/4 v2] HID: wacom - Add default permission defines for sysfs attributes
From: Jiri Kosina @ 2014-09-11 8:26 UTC (permalink / raw)
To: Ping Cheng; +Cc: killertofu, linux-input, Ping Cheng, Paul A. Tessier
In-Reply-To: <1410378005-14464-1-git-send-email-pingc@wacom.com>
I have applied the whole series to hid.git#for-3.18/wacom. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* Re: [PATCH] Input: atmel_mxt_ts: Add of node type to the i2c table
From: Sjoerd Simons @ 2014-09-11 8:00 UTC (permalink / raw)
To: Lee Jones, Wolfram Sang
Cc: Javier Martinez Canillas, Dmitry Torokhov, Nick Dyer, linux-input,
linux-kernel, linux-samsung-soc
In-Reply-To: <20140910092832.GM30307@lee--X1>
[-- Attachment #1: Type: text/plain, Size: 2935 bytes --]
Hey Lee,
On Wed, 2014-09-10 at 10:28 +0100, Lee Jones wrote:
> On Tue, 09 Sep 2014, Javier Martinez Canillas wrote:
>
> > [adding Lee Jones to cc list since I'm referring on a series he posted]
> >
> > Hello Sjoerd,
> >
> > On 09/09/2014 09:52 AM, Sjoerd Simons wrote:
> > > For i2c devices in OF the modalias exposed to userspace is i2c:<node
> > > type>, for the Maxtouch driver this is i2c:maxtouch.
> > >
> > > Add maxtouch to the i2c id table such that userspace can correctly
> > > load the module for the device and drop the OF table as it's not
> > > needed for i2c devices.
> > >
> > > Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> > > ---
> > > drivers/input/touchscreen/atmel_mxt_ts.c | 8 +-------
> > > 1 file changed, 1 insertion(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> > > index db178ed..57ff26d 100644
> > > --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> > > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> > > @@ -2267,16 +2267,11 @@ static int mxt_resume(struct device *dev)
> > >
> > > static SIMPLE_DEV_PM_OPS(mxt_pm_ops, mxt_suspend, mxt_resume);
> > >
> > > -static const struct of_device_id mxt_of_match[] = {
> > > - { .compatible = "atmel,maxtouch", },
> > > - {},
> > > -};
> > > -MODULE_DEVICE_TABLE(of, mxt_of_match);
> > > -
> > > static const struct i2c_device_id mxt_id[] = {
> > > { "qt602240_ts", 0 },
> > > { "atmel_mxt_ts", 0 },
> > > { "atmel_mxt_tp", 0 },
> > > + { "maxtouch", 0 },
> > > { "mXT224", 0 },
> > > { }
> > > };
> > > @@ -2286,7 +2281,6 @@ static struct i2c_driver mxt_driver = {
> > > .driver = {
> > > .name = "atmel_mxt_ts",
> > > .owner = THIS_MODULE,
> > > - .of_match_table = of_match_ptr(mxt_of_match),
> > > .pm = &mxt_pm_ops,
> > > },
> > > .probe = mxt_probe,
> > >
> >
> > I see that Lee is working to allow the I2C subsystem to not need an I2C ID
> > table to match [0]. I'll let Lee to comment what the future plans are and if
> > his series are going to solve your issue since I'm not that familiar with the
> > I2C core.
>
> It's wrong to expect DT to probe these devices without a compatible
> string. It does so at the moment, but this is a bi-product and not
> the correct method.
Ok, which means removing the mxt_of_match table in this patch is wrong..
I'll fix that for for a V2.
However that makes adding the "maxtouch" string to the i2c device table
somewhat cumbersome as it only gets added in this case to ensure
module-autoloading can happen as the modalias presented to userspace is
going still going to be i2c:maxtouch.
Tbh, the bigger problem this is pointing out is that for I2C devices
with only an OF compability tring module auto-loading is broken...
--
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]
^ permalink raw reply
* [PATCH v2] HID: rmi: check sanity of the incoming report
From: Andrew Duggan @ 2014-09-11 1:02 UTC (permalink / raw)
To: linux-input, linux-kernel; +Cc: Benjamin Tissoires, Jiri Kosina, Andrew Duggan
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
In the Dell XPS 13 9333, it appears that sometimes the bus get confused
and corrupts the incoming data. It fills the input report with the
sentinel value "ff". Synaptics told us that such behavior does not comes
from the touchpad itself, so we filter out such reports here.
Unfortunately, we can not simply discard the incoming data because they
may contain useful information. Most of the time, the misbehavior is
quite near the end of the report, so we can still use the valid part of
it.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1123584
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
Here is a v2 based of Benjamin's patch with the feedback from the list.
I added size checks to rmi_f11_input_event and rmi_f30_input_event. For F30 I
print a message it any data is missing so that a user is notified if a button click
doesn't get reported. Also, I decided to only warn once if a corrupted report is
received. Based on the data I have seen I don't think dropped reports will be a
significanly noticible issue. But, I also added a debug message which could be turned on
if soneone wants to see exactly how often incomplete reports are being received.
drivers/hid/hid-rmi.c | 44 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 578bbe6..54966ca 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -320,10 +320,7 @@ static int rmi_f11_input_event(struct hid_device *hdev, u8 irq, u8 *data,
int offset;
int i;
- if (size < hdata->f11.report_size)
- return 0;
-
- if (!(irq & hdata->f11.irq_mask))
+ if (!(irq & hdata->f11.irq_mask) || size <= 0)
return 0;
offset = (hdata->max_fingers >> 2) + 1;
@@ -332,9 +329,19 @@ static int rmi_f11_input_event(struct hid_device *hdev, u8 irq, u8 *data,
int fs_bit_position = (i & 0x3) << 1;
int finger_state = (data[fs_byte_position] >> fs_bit_position) &
0x03;
+ int position = offset + 5 * i;
+
+ if (position + 5 > size) {
+ /* partial report, go on with what we received */
+ printk_once(KERN_WARNING
+ "%s %s: Detected incomplete finger report. Finger reports may occasionally get dropped on this platform.\n",
+ dev_driver_string(&hdev->dev),
+ dev_name(&hdev->dev));
+ hid_dbg(hdev, "Incomplete finger report\n");
+ break;
+ }
- rmi_f11_process_touch(hdata, i, finger_state,
- &data[offset + 5 * i]);
+ rmi_f11_process_touch(hdata, i, finger_state, &data[position]);
}
input_mt_sync_frame(hdata->input);
input_sync(hdata->input);
@@ -352,6 +359,11 @@ static int rmi_f30_input_event(struct hid_device *hdev, u8 irq, u8 *data,
if (!(irq & hdata->f30.irq_mask))
return 0;
+ if (size < (int)hdata->f30.report_size) {
+ hid_warn(hdev, "Click Button pressed, but the click data is missing\n");
+ return 0;
+ }
+
for (i = 0; i < hdata->gpio_led_count; i++) {
if (test_bit(i, &hdata->button_mask)) {
value = (data[i / 8] >> (i & 0x07)) & BIT(0);
@@ -412,9 +424,29 @@ static int rmi_read_data_event(struct hid_device *hdev, u8 *data, int size)
return 1;
}
+static int rmi_check_sanity(struct hid_device *hdev, u8 *data, int size)
+{
+ int valid_size = size;
+ /*
+ * On the Dell XPS 13 9333, the bus sometimes get confused and fills
+ * the report with a sentinel value "ff". Synaptics told us that such
+ * behavior does not comes from the touchpad itself, so we filter out
+ * such reports here.
+ */
+
+ while ((data[valid_size - 1] == 0xff) && valid_size > 0)
+ valid_size--;
+
+ return valid_size;
+}
+
static int rmi_raw_event(struct hid_device *hdev,
struct hid_report *report, u8 *data, int size)
{
+ size = rmi_check_sanity(hdev, data, size);
+ if (size < 2)
+ return 0;
+
switch (data[0]) {
case RMI_READ_DATA_REPORT_ID:
return rmi_read_data_event(hdev, data, size);
--
1.9.1
^ permalink raw reply related
* Re: [PATCH] Handle spurious backslash key repeats on some keyboards
From: Dmitry Torokhov @ 2014-09-10 22:51 UTC (permalink / raw)
To: David Herrmann; +Cc: Fredrik Hallenberg, Jiri Kosina, open list:HID CORE LAYER
In-Reply-To: <CANq1E4Q0oiAxDB7osAMrqs=OGEys6GzZh8GDj9B8jAEpxX7now@mail.gmail.com>
On Wed, Sep 10, 2014 at 04:22:13PM +0200, David Herrmann wrote:
> Hi
>
> On Wed, Sep 10, 2014 at 1:13 PM, Fredrik Hallenberg
> <megahallon@gmail.com> wrote:
> > The keyboards in question have n-key rollover, this seems to be
> > implemented by sending every single key id every time the keyboard is
> > polled, this includes several keys that does not exist physically for
> > example 0x31. This may be a bit excessive but not broken. If I press
> > a-key and '-key in rapid succession, I get the following events
> > (omitting all other keys):
> >
> > VALUE 1 CODE 30 HID 0x4
> > VALUE 0 CODE 43 HID 0x31
> > VALUE 0 CODE 43 HID 0x32
> > Output: a
> >
> > VALUE 1 CODE 30 HID 0x4
> > VALUE 0 CODE 43 HID 0x31 - 43 is up
> > VALUE 1 CODE 43 HID 0x32 - 43 is down
> > Output: '
> >
> > VALUE 0 CODE 30 HID 0x4
> > VALUE 0 CODE 43 HID 0x31 - 43 is up
> > VALUE 1 CODE 43 HID 0x32 - 43 is down
> > Output: '
> >
> > VALUE 0 CODE 30 HID 0x4
> > VALUE 0 CODE 43 HID 0x31 - 43 is up
> > VALUE 1 CODE 43 HID 0x32 - 43 is down
> > Output: '
> >
> > So even though the keyboard is behaving a bit weird the problem is in
> > the kernel as it will interpret 0x31 and 0x32 as the same key.
>
> Thanks for the information! Please include that in follow-up
> commit-messages so others can see it as well. I don't think a report
> descriptor is needed, anymore.
>
> This indeed explains the problem. We only track keys on the keycode
> level, not scancode level. Therefore, you get weird key-up or
> key-repeat events depending on the scan-order.
>
> The nicest fix, obviously, is to blacklist keys that are not
> physically present on the keyboard. But I assume the keyboard reports
Hmm, somebody could still load keymap with duplicate keycodes though...
>
> either key depending on the model (standard vs. European). Given that
> this key is indeed special as we only have a single keycode for it, we
> probably need some quirk like yours. I'd like to hear Dmitry's
> comments on this, maybe he has had similar problems with non-HID
> keyboards.
Hmm, I do not think we have a good story for duplicate keycodes for
drivers that send entire state as opposed to just changed bits.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH V2 2/2] Input: misc: introduce palmas-pwrbutton
From: Dmitry Torokhov @ 2014-09-10 21:13 UTC (permalink / raw)
To: Nishanth Menon
Cc: Murphy, Dan, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
In-Reply-To: <53F64217.5020303@ti.com>
Hi Nishanth,
On Thu, Aug 21, 2014 at 02:01:43PM -0500, Nishanth Menon wrote:
> On 08/21/2014 01:03 PM, Dmitry Torokhov wrote:
>
> I believe I have taken care of other concerns on v2, but..Arrgh.. I
> did not reply to this comment..
> > BTW, I do not think you need to use of_node_get/put here, it's not going anywhere.
> It has been mentioned as a good practice to ensure we use get_put in
> to ensure reference count is appropriately maintained. So, I have'nt
> changed that in v3.
You only need to maintain reference count if you pass the handle on.
Otherwise you'd have to do get/put every time you dereference something.
Anyway, I did a few changes to the driver (no need to store current
state, do not fre einput device after unregister, etc.), could you
please tell me if the version below still works for you?
Thanks.
--
Dmitry
Input: introduce palmas-pwrbutton
From: Nishanth Menon <nm@ti.com>
Many palmas family of PMICs have support for interrupt based power button.
This allows the device to notify the processor of external push button
events over the shared palmas interrupt. However, this event is generated
only during a "press" operation. Software is supposed to poll(sigh!) for
detecting a release event.
The PMIC also supports ability to power off independent of the software
decisions when the button is pressed for a long duration if the PMIC is
appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's own.
Based on original work done by Girish S Ghongdemath <girishsg@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
.../bindings/input/ti,palmas-pwrbutton.txt | 36 ++
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1
drivers/input/misc/palmas-pwrbutton.c | 330 ++++++++++++++++++++
4 files changed, 377 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
diff --git a/Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt b/Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
new file mode 100644
index 0000000..a3dde8c
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
@@ -0,0 +1,36 @@
+Texas Instruments Palmas family power button module
+
+This module is part of the Palmas family of PMICs. For more details
+about the whole chip see:
+Documentation/devicetree/bindings/mfd/palmas.txt.
+
+This module provides a simple power button event via an Interrupt.
+
+Required properties:
+- compatible: should be one of the following
+ - "ti,palmas-pwrbutton": For Palmas compatible power on button
+- interrupt-parent: Parent interrupt device, must be handle of palmas node.
+- interrupts: Interrupt number of power button submodule on device.
+
+Optional Properties:
+
+- ti,palmas-long-press-seconds: Duration in seconds which the power
+ button should be kept pressed for Palmas to power off automatically.
+ NOTE: This depends on OTP support and POWERHOLD signal configuration
+ on platform. Valid values are 6, 8, 10 and 12.
+- ti,palmas-pwron-debounce-milli-seconds: Duration in milliseconds
+ which the power button should be kept pressed for Palmas to register
+ a press for debouncing purposes. NOTE: This depends on specific
+ Palmas variation capability. Valid values are 15, 100, 500 and 1000.
+
+Example:
+
+&palmas {
+ palmas_pwr_button: pwrbutton {
+ compatible = "ti,palmas-pwrbutton";
+ interrupt-parent = <&tps659038>;
+ interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
+ ti,palmas-long-press-seconds = <12>;
+ ti,palmas-pwron-debounce-milli-seconds = <15>;
+ };
+};
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 51891f6..36382e5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -451,6 +451,16 @@ config HP_SDC_RTC
Say Y here if you want to support the built-in real time clock
of the HP SDC controller.
+config INPUT_PALMAS_PWRBUTTON
+ tristate "Palmas Power button Driver"
+ depends on MFD_PALMAS
+ help
+ Say Y here if you want to enable power key reporting via the
+ Palmas family of PMICs.
+
+ To compile this driver as a module, choose M here. The module will
+ be called palmas_pwrbutton.
+
config INPUT_PCF50633_PMU
tristate "PCF50633 PMU events"
depends on MFD_PCF50633
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index e0cee17..e8b84d2 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o
obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o
obj-$(CONFIG_INPUT_MMA8450) += mma8450.o
obj-$(CONFIG_INPUT_MPU3050) += mpu3050.o
+obj-$(CONFIG_INPUT_PALMAS_PWRBUTTON) += palmas-pwrbutton.o
obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o
obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o
diff --git a/drivers/input/misc/palmas-pwrbutton.c b/drivers/input/misc/palmas-pwrbutton.c
new file mode 100644
index 0000000..3f90211
--- /dev/null
+++ b/drivers/input/misc/palmas-pwrbutton.c
@@ -0,0 +1,330 @@
+/*
+ * Texas Instruments' Palmas Power Button Input Driver
+ *
+ * Copyright (C) 2012-2014 Texas Instruments Incorporated - http://www.ti.com/
+ * Girish S Ghongdemath
+ * Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/palmas.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define PALMAS_LPK_TIME_MASK 0x0c
+#define PALMAS_PWRON_DEBOUNCE_MASK 0x03
+#define PALMAS_PWR_KEY_Q_TIME_MS 20
+
+/**
+ * struct palmas_pwron - Palmas power on data
+ * @palmas: pointer to palmas device
+ * @input_dev: pointer to input device
+ * @input_work: work for detecting release of key
+ * @irq: irq that we are hooked on to
+ */
+struct palmas_pwron {
+ struct palmas *palmas;
+ struct input_dev *input_dev;
+ struct delayed_work input_work;
+ int irq;
+};
+
+/**
+ * struct palmas_pwron_config - configuration of palmas power on
+ * @long_press_time_val: value for long press h/w shutdown event
+ * @pwron_debounce_val: value for debounce of power button
+ */
+struct palmas_pwron_config {
+ u8 long_press_time_val;
+ u8 pwron_debounce_val;
+};
+
+/**
+ * palmas_power_button_work() - Detects the button release event
+ * @work: work item to detect button release
+ */
+static void palmas_power_button_work(struct work_struct *work)
+{
+ struct palmas_pwron *pwron = container_of(work,
+ struct palmas_pwron,
+ input_work.work);
+ struct input_dev *input_dev = pwron->input_dev;
+ unsigned int reg;
+ int error;
+
+ error = palmas_read(pwron->palmas, PALMAS_INTERRUPT_BASE,
+ PALMAS_INT1_LINE_STATE, ®);
+ if (error) {
+ dev_err(input_dev->dev.parent,
+ "Cannot read palmas PWRON status: %d\n", error);
+ } else if (reg & BIT(1)) {
+ /* The button is released, report event. */
+ input_report_key(input_dev, KEY_POWER, 0);
+ input_sync(input_dev);
+ } else {
+ /* The button is still depressed, keep checking. */
+ schedule_delayed_work(&pwron->input_work,
+ msecs_to_jiffies(PALMAS_PWR_KEY_Q_TIME_MS));
+ }
+}
+
+/**
+ * pwron_irq() - button press isr
+ * @irq: irq
+ * @palmas_pwron: pwron struct
+ *
+ * Return: IRQ_HANDLED
+ */
+static irqreturn_t pwron_irq(int irq, void *palmas_pwron)
+{
+ struct palmas_pwron *pwron = palmas_pwron;
+ struct input_dev *input_dev = pwron->input_dev;
+
+ input_report_key(input_dev, KEY_POWER, 1);
+ pm_wakeup_event(input_dev->dev.parent, 0);
+ input_sync(input_dev);
+
+ mod_delayed_work(system_wq, &pwron->input_work,
+ msecs_to_jiffies(PALMAS_PWR_KEY_Q_TIME_MS));
+
+ return IRQ_HANDLED;
+}
+
+/**
+ * palmas_pwron_params_ofinit() - device tree parameter parser
+ * @dev: palmas button device
+ * @config: configuration params that this fills up
+ */
+static void palmas_pwron_params_ofinit(struct device *dev,
+ struct palmas_pwron_config *config)
+{
+ struct device_node *np;
+ u32 val;
+ int i, error;
+ u8 lpk_times[] = { 6, 8, 10, 12 };
+ int pwr_on_deb_ms[] = { 15, 100, 500, 1000 };
+
+ memset(config, 0, sizeof(*config));
+
+ /* Default config parameters */
+ config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
+
+ np = dev->of_node;
+ if (!np)
+ return;
+
+ error = of_property_read_u32(np, "ti,palmas-long-press-seconds", &val);
+ if (!error) {
+ for (i = 0; i < ARRAY_SIZE(lpk_times); i++) {
+ if (val <= lpk_times[i]) {
+ config->long_press_time_val = i;
+ break;
+ }
+ }
+ }
+
+ error = of_property_read_u32(np,
+ "ti,palmas-pwron-debounce-milli-seconds",
+ &val);
+ if (!error) {
+ for (i = 0; i < ARRAY_SIZE(pwr_on_deb_ms); i++) {
+ if (val <= pwr_on_deb_ms[i]) {
+ config->pwron_debounce_val = i;
+ break;
+ }
+ }
+ }
+
+ dev_info(dev, "h/w controlled shutdown duration=%d seconds\n",
+ lpk_times[config->long_press_time_val]);
+}
+
+/**
+ * palmas_pwron_probe() - probe
+ * @pdev: platform device for the button
+ *
+ * Return: 0 for successful probe else appropriate error
+ */
+static int palmas_pwron_probe(struct platform_device *pdev)
+{
+ struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
+ struct device *dev = &pdev->dev;
+ struct input_dev *input_dev;
+ struct palmas_pwron *pwron;
+ struct palmas_pwron_config config;
+ int val;
+ int error;
+
+ palmas_pwron_params_ofinit(dev, &config);
+
+ pwron = kzalloc(sizeof(*pwron), GFP_KERNEL);
+ if (!pwron)
+ return -ENOMEM;
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ dev_err(dev, "Can't allocate power button\n");
+ error = -ENOMEM;
+ goto err_free_mem;
+ }
+
+ input_dev->name = "palmas_pwron";
+ input_dev->phys = "palmas_pwron/input0";
+ input_dev->dev.parent = dev;
+
+ input_set_capability(input_dev, EV_KEY, KEY_POWER);
+
+ /*
+ * Setup default hardware shutdown option (long key press)
+ * and debounce.
+ */
+ val = config.long_press_time_val << __ffs(PALMAS_LPK_TIME_MASK);
+ val |= config.pwron_debounce_val << __ffs(PALMAS_PWRON_DEBOUNCE_MASK);
+ error = palmas_update_bits(palmas, PALMAS_PMU_CONTROL_BASE,
+ PALMAS_LONG_PRESS_KEY,
+ PALMAS_LPK_TIME_MASK |
+ PALMAS_PWRON_DEBOUNCE_MASK,
+ val);
+ if (error) {
+ dev_err(dev, "LONG_PRESS_KEY_UPDATE failed: %d\n", error);
+ goto err_free_input;
+ }
+
+ pwron->palmas = palmas;
+ pwron->input_dev = input_dev;
+
+ INIT_DELAYED_WORK(&pwron->input_work, palmas_power_button_work);
+
+ pwron->irq = platform_get_irq(pdev, 0);
+ error = request_threaded_irq(pwron->irq, NULL, pwron_irq,
+ IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW,
+ dev_name(dev), pwron);
+ if (error) {
+ dev_err(dev, "Can't get IRQ for pwron: %d\n", error);
+ goto err_free_input;
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ dev_err(dev, "Can't register power button: %d\n", error);
+ goto err_free_irq;
+ }
+
+ platform_set_drvdata(pdev, pwron);
+ device_init_wakeup(dev, true);
+
+ return 0;
+
+err_free_irq:
+ cancel_delayed_work_sync(&pwron->input_work);
+ free_irq(pwron->irq, pwron);
+err_free_input:
+ input_free_device(input_dev);
+err_free_mem:
+ kfree(pwron);
+ return error;
+}
+
+/**
+ * palmas_pwron_remove() - Cleanup on removal
+ * @pdev: platform device for the button
+ *
+ * Return: 0
+ */
+static int palmas_pwron_remove(struct platform_device *pdev)
+{
+ struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+
+ free_irq(pwron->irq, pwron);
+ cancel_delayed_work_sync(&pwron->input_work);
+
+ input_unregister_device(pwron->input_dev);
+ kfree(pwron);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+/**
+ * palmas_pwron_suspend() - suspend handler
+ * @dev: power button device
+ *
+ * Cancel all pending work items for the power button, setup irq for wakeup
+ *
+ * Return: 0
+ */
+static int palmas_pwron_suspend(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+
+ cancel_delayed_work_sync(&pwron->input_work);
+
+ if (device_may_wakeup(dev))
+ enable_irq_wake(pwron->irq);
+
+ return 0;
+}
+
+/**
+ * palmas_pwron_resume() - resume handler
+ * @dev: power button device
+ *
+ * Just disable the wakeup capability of irq here.
+ *
+ * Return: 0
+ */
+static int palmas_pwron_resume(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+
+ if (device_may_wakeup(dev))
+ disable_irq_wake(pwron->irq);
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(palmas_pwron_pm,
+ palmas_pwron_suspend, palmas_pwron_resume);
+
+#ifdef CONFIG_OF
+static struct of_device_id of_palmas_pwr_match[] = {
+ { .compatible = "ti,palmas-pwrbutton" },
+ { },
+};
+
+MODULE_DEVICE_TABLE(of, of_palmas_pwr_match);
+#endif
+
+static struct platform_driver palmas_pwron_driver = {
+ .probe = palmas_pwron_probe,
+ .remove = palmas_pwron_remove,
+ .driver = {
+ .name = "palmas_pwrbutton",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(of_palmas_pwr_match),
+ .pm = &palmas_pwron_pm,
+ },
+};
+module_platform_driver(palmas_pwron_driver);
+
+MODULE_ALIAS("platform:palmas-pwrbutton");
+MODULE_DESCRIPTION("Palmas Power Button");
+MODULE_LICENSE("GPL V2");
+MODULE_AUTHOR("Texas Instruments Inc.");
^ permalink raw reply related
* [git pull] Input updates for 3.17-rc4
From: Dmitry Torokhov @ 2014-09-10 21:08 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel, linux-input
[-- Attachment #1: Type: text/plain, Size: 2332 bytes --]
[ Not sure how I managed to send previous request as a reply, resending
signed just in case... ]
Hi Linus,
Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus
or
master.kernel.org:/pub/scm/linux/kernel/git/dtor/input.git for-linus
to receive updates for the input subsystem. You will get an update to
Synaptics PS/2 driver to handle "ForcePads" (currently found in HP
EliteBook 1040 laptops), a change for Elan PS/2 driver to detect newer
touchpads, bunch of devices get annotated as Trackpoint and/or Pointer
to help userspace classify and handle them, plus assorted driver fixes.
Changelog:
---------
Dmitry Torokhov (1):
Input: synaptics - add support for ForcePads
Hans de Goede (3):
Input: elantech - fix detection of touchpad on ASUS s301l
Input: add INPUT_PROP_POINTING_STICK property
Input: add missing POINTER / DIRECT properties to a bunch of drivers
John Sung (1):
Input: serport - add compat handling for SPIOCSTYPE ioctl
Klaus Goger (1):
Input: cap1106 - fix register definition
Lothar Waßmann (1):
Input: matrix_keypad - use request_any_context_irq()
Masanari Iida (1):
Input: wm971x - fix typo in module parameter description
Nick Dyer (1):
Input: atmel_mxt_ts - downgrade warning about empty interrupts
Stephen Warren (1):
Input: atmel_mxt_ts - fix double free of input device
Diffstat:
--------
drivers/input/keyboard/cap1106.c | 4 +-
drivers/input/keyboard/matrix_keypad.c | 9 +++--
drivers/input/mouse/alps.c | 4 ++
drivers/input/mouse/elantech.c | 11 ++++++
drivers/input/mouse/psmouse-base.c | 2 +
drivers/input/mouse/synaptics.c | 68 ++++++++++++++++++++++++--------
drivers/input/mouse/synaptics.h | 11 ++++++
drivers/input/mouse/synaptics_usb.c | 6 +++
drivers/input/mouse/trackpoint.c | 3 ++
drivers/input/serio/serport.c | 45 +++++++++++++++++----
drivers/input/touchscreen/atmel_mxt_ts.c | 25 +++++++++---
drivers/input/touchscreen/wm9712.c | 2 +-
drivers/input/touchscreen/wm9713.c | 2 +-
include/uapi/linux/input.h | 1 +
14 files changed, 156 insertions(+), 37 deletions(-)
--
Dmitry
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: [git pull] Input updates for 3.17-rc4
From: Dmitry Torokhov @ 2014-09-10 21:04 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel, linux-input
In-Reply-To: <20140815061242.GA23913@core.coreip.homeip.net>
Hi Linus,
Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus
or
master.kernel.org:/pub/scm/linux/kernel/git/dtor/input.git for-linus
to receive updates for the input subsystem. You will get an update to
Synaptics PS/2 driver to handle "ForcePads" (currently found in HP
EliteBook 1040 laptops), a change for Elan PS/2 driver to detect newer
touchpads, bunch of devices get annotated as Trackpoint and/or Pointer
to help userspace classify and handle them, plus assorted driver fixes.
Changelog:
---------
Dmitry Torokhov (1):
Input: synaptics - add support for ForcePads
Hans de Goede (3):
Input: elantech - fix detection of touchpad on ASUS s301l
Input: add INPUT_PROP_POINTING_STICK property
Input: add missing POINTER / DIRECT properties to a bunch of drivers
John Sung (1):
Input: serport - add compat handling for SPIOCSTYPE ioctl
Klaus Goger (1):
Input: cap1106 - fix register definition
Lothar Waßmann (1):
Input: matrix_keypad - use request_any_context_irq()
Masanari Iida (1):
Input: wm971x - fix typo in module parameter description
Nick Dyer (1):
Input: atmel_mxt_ts - downgrade warning about empty interrupts
Stephen Warren (1):
Input: atmel_mxt_ts - fix double free of input device
Diffstat:
--------
drivers/input/keyboard/cap1106.c | 4 +-
drivers/input/keyboard/matrix_keypad.c | 9 +++--
drivers/input/mouse/alps.c | 4 ++
drivers/input/mouse/elantech.c | 11 ++++++
drivers/input/mouse/psmouse-base.c | 2 +
drivers/input/mouse/synaptics.c | 68 ++++++++++++++++++++++++--------
drivers/input/mouse/synaptics.h | 11 ++++++
drivers/input/mouse/synaptics_usb.c | 6 +++
drivers/input/mouse/trackpoint.c | 3 ++
drivers/input/serio/serport.c | 45 +++++++++++++++++----
drivers/input/touchscreen/atmel_mxt_ts.c | 25 +++++++++---
drivers/input/touchscreen/wm9712.c | 2 +-
drivers/input/touchscreen/wm9713.c | 2 +-
include/uapi/linux/input.h | 1 +
14 files changed, 156 insertions(+), 37 deletions(-)
--
Dmitry
--
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: [PATCH] input: atkbd - Fix broken keyboard in another LG laptop
From: Dmitry Torokhov @ 2014-09-10 20:52 UTC (permalink / raw)
To: Jaime Velasco Juan; +Cc: linux-input, stable, Sheng-Liang Song
In-Reply-To: <1410372374-11591-1-git-send-email-jsagarribay@gmail.com>
Hi Jamie,
On Wed, Sep 10, 2014 at 07:06:14PM +0100, Jaime Velasco Juan wrote:
> This model has the same quirk as others, see 3d725caa9dcc "Input:
> atkbd - fix keyboard not working on some LG laptops"
>
How about the patch below instead?
Thanks!
--
Dmitry
Input: atkbd - do not try 'deactivate' keyboard on any LG laptops
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
We are getting more and more reports about LG laptops not having
functioning keyboard if we try to deactivate keyboard during probe.
Given that having keyboard deactivated is merely "nice to have"
instead of a hard requirement for probing, let's disable it on all
LG boxes instead of trying to hunt down particular models.
This change is prompted by patches trying to add "LG Electronics"/"ROCKY"
and "LG Electronics"/"LW60-F27B" to the DMI list.
https://bugzilla.kernel.org/show_bug.cgi?id=77051
Cc: stable@vger.kernel.org
Reported-by: Jaime Velasco Juan <jsagarribay@gmail.com>
Reported-by: Georgios Tsalikis <georgios@tsalikis.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/keyboard/atkbd.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 2dd1d0d..6f5d795 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -1791,14 +1791,6 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
- DMI_MATCH(DMI_PRODUCT_NAME, "LW25-B7HV"),
- },
- .callback = atkbd_deactivate_fixup,
- },
- {
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
- DMI_MATCH(DMI_PRODUCT_NAME, "P1-J273B"),
},
.callback = atkbd_deactivate_fixup,
},
^ permalink raw reply related
* [PATCH 4/4 v2] HID: wacom - enable LED support for Wireless Intuos5/Pro
From: Ping Cheng @ 2014-09-10 19:41 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng
And associate all LED/OLED to PAD device
Signed-off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/wacom_sys.c | 52 +++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index f911f97..91fb3c3 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -17,6 +17,7 @@
#define WAC_MSG_RETRIES 5
+#define WAC_CMD_WL_LED_CONTROL 0x03
#define WAC_CMD_LED_CONTROL 0x20
#define WAC_CMD_ICON_START 0x21
#define WAC_CMD_ICON_XFER 0x23
@@ -490,8 +491,14 @@ static int wacom_led_control(struct wacom *wacom)
{
unsigned char *buf;
int retval;
+ unsigned char report_id = WAC_CMD_LED_CONTROL;
+ int buf_size = 9;
- buf = kzalloc(9, GFP_KERNEL);
+ if (wacom->wacom_wac.pid) { /* wireless connected */
+ report_id = WAC_CMD_WL_LED_CONTROL;
+ buf_size = 13;
+ }
+ buf = kzalloc(buf_size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -505,9 +512,16 @@ static int wacom_led_control(struct wacom *wacom)
int ring_led = wacom->led.select[0] & 0x03;
int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03;
int crop_lum = 0;
-
- buf[0] = WAC_CMD_LED_CONTROL;
- buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led);
+ unsigned char led_bits = (crop_lum << 4) | (ring_lum << 2) | (ring_led);
+
+ buf[0] = report_id;
+ if (wacom->wacom_wac.pid) {
+ wacom_get_report(wacom->hdev, HID_FEATURE_REPORT,
+ buf, buf_size, WAC_CMD_RETRIES);
+ buf[0] = report_id;
+ buf[4] = led_bits;
+ } else
+ buf[1] = led_bits;
}
else {
int led = wacom->led.select[0] | 0x4;
@@ -516,14 +530,14 @@ static int wacom_led_control(struct wacom *wacom)
wacom->wacom_wac.features.type == WACOM_24HD)
led |= (wacom->led.select[1] << 4) | 0x40;
- buf[0] = WAC_CMD_LED_CONTROL;
+ buf[0] = report_id;
buf[1] = led;
buf[2] = wacom->led.llv;
buf[3] = wacom->led.hlv;
buf[4] = wacom->led.img_lum;
}
- retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 9,
+ retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size,
WAC_CMD_RETRIES);
kfree(buf);
@@ -1036,6 +1050,7 @@ static void wacom_unregister_inputs(struct wacom *wacom)
input_unregister_device(wacom->wacom_wac.pad_input);
wacom->wacom_wac.input = NULL;
wacom->wacom_wac.pad_input = NULL;
+ wacom_destroy_leds(wacom);
}
static int wacom_register_inputs(struct wacom *wacom)
@@ -1073,10 +1088,17 @@ static int wacom_register_inputs(struct wacom *wacom)
error = input_register_device(pad_input_dev);
if (error)
goto fail3;
+
+ error = wacom_initialize_leds(wacom);
+ if (error)
+ goto fail4;
}
return 0;
+fail4:
+ input_unregister_device(pad_input_dev);
+ pad_input_dev = NULL;
fail3:
input_unregister_device(input_dev);
input_dev = NULL;
@@ -1151,6 +1173,7 @@ static void wacom_wireless_work(struct work_struct *work)
wacom_wac1->features.name);
wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
wacom_wac1->shared->type = wacom_wac1->features.type;
+ wacom_wac1->pid = wacom_wac->pid;
error = wacom_register_inputs(wacom1);
if (error)
goto fail;
@@ -1171,6 +1194,7 @@ static void wacom_wireless_work(struct work_struct *work)
"%s (WL) Pad",wacom_wac2->features.name);
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
"%s (WL) Pad", wacom_wac2->features.name);
+ wacom_wac2->pid = wacom_wac->pid;
error = wacom_register_inputs(wacom2);
if (error)
goto fail;
@@ -1353,21 +1377,17 @@ static int wacom_probe(struct hid_device *hdev,
goto fail1;
}
- error = wacom_initialize_leds(wacom);
- if (error)
- goto fail2;
-
if (!(features->quirks & WACOM_QUIRK_MONITOR) &&
(features->quirks & WACOM_QUIRK_BATTERY)) {
error = wacom_initialize_battery(wacom);
if (error)
- goto fail3;
+ goto fail2;
}
if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
error = wacom_register_inputs(wacom);
if (error)
- goto fail4;
+ goto fail3;
}
if (hdev->bus == BUS_BLUETOOTH) {
@@ -1385,7 +1405,7 @@ static int wacom_probe(struct hid_device *hdev,
error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
if (error) {
hid_err(hdev, "hw start failed\n");
- goto fail5;
+ goto fail4;
}
if (features->quirks & WACOM_QUIRK_MONITOR)
@@ -1398,11 +1418,10 @@ static int wacom_probe(struct hid_device *hdev,
return 0;
- fail5: if (hdev->bus == BUS_BLUETOOTH)
+ fail4: if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_unregister_inputs(wacom);
- fail4: wacom_destroy_battery(wacom);
- fail3: wacom_destroy_leds(wacom);
+ fail3: wacom_destroy_battery(wacom);
fail2: wacom_remove_shared_data(wacom_wac);
fail1: kfree(wacom);
hid_set_drvdata(hdev, NULL);
@@ -1420,7 +1439,6 @@ static void wacom_remove(struct hid_device *hdev)
if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_destroy_battery(wacom);
- wacom_destroy_leds(wacom);
wacom_remove_shared_data(&wacom->wacom_wac);
hid_set_drvdata(hdev, NULL);
--
1.9.1
^ permalink raw reply related
* [PATCH 3/4 v2] HID: wacom - remove report_id from wacom_get_report interface
From: Ping Cheng @ 2014-09-10 19:41 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng
It is assigned in buf[0] anyway.
Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/wacom_sys.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 4a7b9c8..f911f97 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -26,13 +26,13 @@
#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
-static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id,
- void *buf, size_t size, unsigned int retries)
+static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
+ size_t size, unsigned int retries)
{
int retval;
do {
- retval = hid_hw_raw_request(hdev, id, buf, size, type,
+ retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
HID_REQ_GET_REPORT);
} while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
@@ -258,7 +258,7 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
length, 1);
if (error >= 0)
error = wacom_get_report(hdev, HID_FEATURE_REPORT,
- report_id, rep_data, length, 1);
+ rep_data, length, 1);
} while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
kfree(rep_data);
--
1.9.1
^ permalink raw reply related
* [PATCH 2/4 v2] HID: wacom - Clean up of sysfs
From: Ping Cheng @ 2014-09-10 19:40 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng, Paul A. Tessier
changed to scnprintf(buf, PAGE_SIZE, ... ) as suggested in sysfs.txt
for show functions
Signed-off-by: Paul A. Tessier <phernost@gmail.com>
Signed-Off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
v2: Move actual permission to patch one.
drivers/hid/wacom_sys.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 950a205..4a7b9c8 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -605,7 +605,8 @@ static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
{ \
struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
struct wacom *wacom = hid_get_drvdata(hdev); \
- return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
+ return scnprintf(buf, PAGE_SIZE, "%d\n", \
+ wacom->led.select[SET_ID]); \
} \
static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
wacom_led##SET_ID##_select_show, \
@@ -644,8 +645,15 @@ static ssize_t wacom_##name##_luminance_store(struct device *dev, \
return wacom_luminance_store(wacom, &wacom->led.field, \
buf, count); \
} \
+static ssize_t wacom_##name##_luminance_show(struct device *dev, \
+ struct device_attribute *attr, char *buf) \
+{ \
+ struct wacom *wacom = dev_get_drvdata(dev); \
+ return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
+} \
static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
- NULL, wacom_##name##_luminance_store)
+ wacom_##name##_luminance_show, \
+ wacom_##name##_luminance_store)
DEVICE_LUMINANCE_ATTR(status0, llv);
DEVICE_LUMINANCE_ATTR(status1, hlv);
--
1.9.1
^ permalink raw reply related
* [PATCH 1/4 v2] HID: wacom - Add default permission defines for sysfs attributes
From: Ping Cheng @ 2014-09-10 19:40 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng, Paul A. Tessier
RW : ug=rw,o=r
WO : ug=w
And enabled reading relavent sysfs attributes.
Signed-off-by: Paul A. Tessier <phernost@gmail.com>
Signed-Off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
v2: Integrate actual permission with defines.
drivers/hid/wacom_sys.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index f0db7ec..950a205 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -23,6 +23,9 @@
#define WAC_CMD_ICON_BT_XFER 0x26
#define WAC_CMD_RETRIES 10
+#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
+#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
+
static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id,
void *buf, size_t size, unsigned int retries)
{
@@ -604,7 +607,7 @@ static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
struct wacom *wacom = hid_get_drvdata(hdev); \
return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
} \
-static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
+static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
wacom_led##SET_ID##_select_show, \
wacom_led##SET_ID##_select_store)
@@ -641,7 +644,7 @@ static ssize_t wacom_##name##_luminance_store(struct device *dev, \
return wacom_luminance_store(wacom, &wacom->led.field, \
buf, count); \
} \
-static DEVICE_ATTR(name##_luminance, S_IWUSR, \
+static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
NULL, wacom_##name##_luminance_store)
DEVICE_LUMINANCE_ATTR(status0, llv);
@@ -683,7 +686,7 @@ static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
{ \
return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
} \
-static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \
+static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \
NULL, wacom_btnimg##BUTTON_ID##_store)
DEVICE_BTNIMG_ATTR(0);
@@ -989,7 +992,7 @@ static ssize_t wacom_store_speed(struct device *dev,
return count;
}
-static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP,
+static DEVICE_ATTR(speed, DEV_ATTR_RW_PERM,
wacom_show_speed, wacom_store_speed);
static struct input_dev *wacom_allocate_input(struct wacom *wacom)
--
1.9.1
^ permalink raw reply related
* Re: [PATCH 1/4] HID: wacom - Add default permission defines for sysfs attributes
From: Benjamin Tissoires @ 2014-09-10 18:59 UTC (permalink / raw)
To: Ping Cheng
Cc: Jiri Kosina, Jason Gerecke, linux-input, Ping Cheng,
Paul A. Tessier
In-Reply-To: <1410374404-25832-1-git-send-email-pingc@wacom.com>
On Wed, Sep 10, 2014 at 2:40 PM, Ping Cheng <pinglinux@gmail.com> wrote:
> RW : ug=rw,o=r
> WO : ug=w
>
> Signed-off-by: Paul A. Tessier <phernost@gmail.com>
> Signed-Off-by: Ping Cheng <pingc@wacom.com>
> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
> drivers/hid/wacom_sys.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index f0db7ec..2ce102b 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -23,6 +23,9 @@
> #define WAC_CMD_ICON_BT_XFER 0x26
> #define WAC_CMD_RETRIES 10
>
> +#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
> +#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
> +
I guess you missed the correct split with 2/4 :)
Please also add in this patch where these defines are used.
Cheers,
Benjamin
> static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id,
> void *buf, size_t size, unsigned int retries)
> {
> --
> 1.9.1
>
> --
> 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
* [PATCH 4/4] HID: wacom - enable LED support for Wireless Intuos5/Pro
From: Ping Cheng @ 2014-09-10 18:41 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng
And associate all LED/OLED to PAD device
Signed-off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/wacom_sys.c | 52 +++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index f911f97..91fb3c3 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -17,6 +17,7 @@
#define WAC_MSG_RETRIES 5
+#define WAC_CMD_WL_LED_CONTROL 0x03
#define WAC_CMD_LED_CONTROL 0x20
#define WAC_CMD_ICON_START 0x21
#define WAC_CMD_ICON_XFER 0x23
@@ -490,8 +491,14 @@ static int wacom_led_control(struct wacom *wacom)
{
unsigned char *buf;
int retval;
+ unsigned char report_id = WAC_CMD_LED_CONTROL;
+ int buf_size = 9;
- buf = kzalloc(9, GFP_KERNEL);
+ if (wacom->wacom_wac.pid) { /* wireless connected */
+ report_id = WAC_CMD_WL_LED_CONTROL;
+ buf_size = 13;
+ }
+ buf = kzalloc(buf_size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -505,9 +512,16 @@ static int wacom_led_control(struct wacom *wacom)
int ring_led = wacom->led.select[0] & 0x03;
int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03;
int crop_lum = 0;
-
- buf[0] = WAC_CMD_LED_CONTROL;
- buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led);
+ unsigned char led_bits = (crop_lum << 4) | (ring_lum << 2) | (ring_led);
+
+ buf[0] = report_id;
+ if (wacom->wacom_wac.pid) {
+ wacom_get_report(wacom->hdev, HID_FEATURE_REPORT,
+ buf, buf_size, WAC_CMD_RETRIES);
+ buf[0] = report_id;
+ buf[4] = led_bits;
+ } else
+ buf[1] = led_bits;
}
else {
int led = wacom->led.select[0] | 0x4;
@@ -516,14 +530,14 @@ static int wacom_led_control(struct wacom *wacom)
wacom->wacom_wac.features.type == WACOM_24HD)
led |= (wacom->led.select[1] << 4) | 0x40;
- buf[0] = WAC_CMD_LED_CONTROL;
+ buf[0] = report_id;
buf[1] = led;
buf[2] = wacom->led.llv;
buf[3] = wacom->led.hlv;
buf[4] = wacom->led.img_lum;
}
- retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 9,
+ retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size,
WAC_CMD_RETRIES);
kfree(buf);
@@ -1036,6 +1050,7 @@ static void wacom_unregister_inputs(struct wacom *wacom)
input_unregister_device(wacom->wacom_wac.pad_input);
wacom->wacom_wac.input = NULL;
wacom->wacom_wac.pad_input = NULL;
+ wacom_destroy_leds(wacom);
}
static int wacom_register_inputs(struct wacom *wacom)
@@ -1073,10 +1088,17 @@ static int wacom_register_inputs(struct wacom *wacom)
error = input_register_device(pad_input_dev);
if (error)
goto fail3;
+
+ error = wacom_initialize_leds(wacom);
+ if (error)
+ goto fail4;
}
return 0;
+fail4:
+ input_unregister_device(pad_input_dev);
+ pad_input_dev = NULL;
fail3:
input_unregister_device(input_dev);
input_dev = NULL;
@@ -1151,6 +1173,7 @@ static void wacom_wireless_work(struct work_struct *work)
wacom_wac1->features.name);
wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
wacom_wac1->shared->type = wacom_wac1->features.type;
+ wacom_wac1->pid = wacom_wac->pid;
error = wacom_register_inputs(wacom1);
if (error)
goto fail;
@@ -1171,6 +1194,7 @@ static void wacom_wireless_work(struct work_struct *work)
"%s (WL) Pad",wacom_wac2->features.name);
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
"%s (WL) Pad", wacom_wac2->features.name);
+ wacom_wac2->pid = wacom_wac->pid;
error = wacom_register_inputs(wacom2);
if (error)
goto fail;
@@ -1353,21 +1377,17 @@ static int wacom_probe(struct hid_device *hdev,
goto fail1;
}
- error = wacom_initialize_leds(wacom);
- if (error)
- goto fail2;
-
if (!(features->quirks & WACOM_QUIRK_MONITOR) &&
(features->quirks & WACOM_QUIRK_BATTERY)) {
error = wacom_initialize_battery(wacom);
if (error)
- goto fail3;
+ goto fail2;
}
if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
error = wacom_register_inputs(wacom);
if (error)
- goto fail4;
+ goto fail3;
}
if (hdev->bus == BUS_BLUETOOTH) {
@@ -1385,7 +1405,7 @@ static int wacom_probe(struct hid_device *hdev,
error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
if (error) {
hid_err(hdev, "hw start failed\n");
- goto fail5;
+ goto fail4;
}
if (features->quirks & WACOM_QUIRK_MONITOR)
@@ -1398,11 +1418,10 @@ static int wacom_probe(struct hid_device *hdev,
return 0;
- fail5: if (hdev->bus == BUS_BLUETOOTH)
+ fail4: if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_unregister_inputs(wacom);
- fail4: wacom_destroy_battery(wacom);
- fail3: wacom_destroy_leds(wacom);
+ fail3: wacom_destroy_battery(wacom);
fail2: wacom_remove_shared_data(wacom_wac);
fail1: kfree(wacom);
hid_set_drvdata(hdev, NULL);
@@ -1420,7 +1439,6 @@ static void wacom_remove(struct hid_device *hdev)
if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_destroy_battery(wacom);
- wacom_destroy_leds(wacom);
wacom_remove_shared_data(&wacom->wacom_wac);
hid_set_drvdata(hdev, NULL);
--
1.9.1
^ permalink raw reply related
* [PATCH 3/4] HID: wacom - remove report_id from wacom_get_report interface
From: Ping Cheng @ 2014-09-10 18:41 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng
It is assigned in buf[0] anyway.
Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/wacom_sys.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 4a7b9c8..f911f97 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -26,13 +26,13 @@
#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
-static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id,
- void *buf, size_t size, unsigned int retries)
+static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
+ size_t size, unsigned int retries)
{
int retval;
do {
- retval = hid_hw_raw_request(hdev, id, buf, size, type,
+ retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
HID_REQ_GET_REPORT);
} while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
@@ -258,7 +258,7 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
length, 1);
if (error >= 0)
error = wacom_get_report(hdev, HID_FEATURE_REPORT,
- report_id, rep_data, length, 1);
+ rep_data, length, 1);
} while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
kfree(rep_data);
--
1.9.1
^ permalink raw reply related
* [PATCH 2/4] HID: wacom - enable reading relavent sysfs attributes
From: Ping Cheng @ 2014-09-10 18:40 UTC (permalink / raw)
To: jkosina; +Cc: killertofu, linux-input, Ping Cheng, Paul A. Tessier
changed to scnprintf(buf, PAGE_SIZE, ... ) as suggested in sysfs.txt
for show functions
Signed-off-by: Paul A. Tessier <phernost@gmail.com>
Signed-Off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/wacom_sys.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 2ce102b..4a7b9c8 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -605,9 +605,10 @@ static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
{ \
struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
struct wacom *wacom = hid_get_drvdata(hdev); \
- return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
+ return scnprintf(buf, PAGE_SIZE, "%d\n", \
+ wacom->led.select[SET_ID]); \
} \
-static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
+static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
wacom_led##SET_ID##_select_show, \
wacom_led##SET_ID##_select_store)
@@ -644,8 +645,15 @@ static ssize_t wacom_##name##_luminance_store(struct device *dev, \
return wacom_luminance_store(wacom, &wacom->led.field, \
buf, count); \
} \
-static DEVICE_ATTR(name##_luminance, S_IWUSR, \
- NULL, wacom_##name##_luminance_store)
+static ssize_t wacom_##name##_luminance_show(struct device *dev, \
+ struct device_attribute *attr, char *buf) \
+{ \
+ struct wacom *wacom = dev_get_drvdata(dev); \
+ return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
+} \
+static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
+ wacom_##name##_luminance_show, \
+ wacom_##name##_luminance_store)
DEVICE_LUMINANCE_ATTR(status0, llv);
DEVICE_LUMINANCE_ATTR(status1, hlv);
@@ -686,7 +694,7 @@ static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
{ \
return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
} \
-static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \
+static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \
NULL, wacom_btnimg##BUTTON_ID##_store)
DEVICE_BTNIMG_ATTR(0);
@@ -992,7 +1000,7 @@ static ssize_t wacom_store_speed(struct device *dev,
return count;
}
-static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP,
+static DEVICE_ATTR(speed, DEV_ATTR_RW_PERM,
wacom_show_speed, wacom_store_speed);
static struct input_dev *wacom_allocate_input(struct wacom *wacom)
--
1.9.1
^ 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