* tsc2005 touchscreen: implement disable attribute
@ 2014-11-09 11:56 Pavel Machek
2014-11-09 12:40 ` Sebastian Reichel
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2014-11-09 11:56 UTC (permalink / raw)
To: pali.rohar, sre, sre, kernel list, linux-arm-kernel, linux-omap,
tony, khilman, aaro.koskinen, freemangordon, B38611, jg1.han,
linux-input
Implement disable attribute for tsc2005 touchscreen. It is useful to
avoid wakeups when phone is in the pocket.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
[This is from Pali's n900 tree that is GPL, so that is okay, but maybe
I should get his sign-off here?]
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 52380b6..ec1c276 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -147,6 +147,7 @@ struct tsc2005 {
unsigned int x_plate_ohm;
+ bool disabled;
bool opened;
bool suspended;
@@ -384,6 +385,48 @@ static void __tsc2005_enable(struct tsc2005 *ts)
}
+static ssize_t tsc2005_disable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct spi_device *spi = to_spi_device(dev);
+ struct tsc2005 *ts = spi_get_drvdata(spi);
+
+ return sprintf(buf, "%u\n", ts->disabled);
+}
+
+static ssize_t tsc2005_disable_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct spi_device *spi = to_spi_device(dev);
+ struct tsc2005 *ts = spi_get_drvdata(spi);
+ unsigned long val;
+ int error;
+
+ error = kstrtoul(buf, 10, &val);
+ if (error)
+ return error;
+
+ mutex_lock(&ts->mutex);
+
+ if (!ts->suspended && ts->opened) {
+ if (val) {
+ if (!ts->disabled)
+ __tsc2005_disable(ts);
+ } else {
+ if (ts->disabled)
+ __tsc2005_enable(ts);
+ }
+ }
+
+ ts->disabled = !!val;
+
+ mutex_unlock(&ts->mutex);
+
+ return count;
+}
+static DEVICE_ATTR(disable, 0664, tsc2005_disable_show, tsc2005_disable_store);
+
static ssize_t tsc2005_selftest_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -466,6 +509,7 @@ out:
static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL);
static struct attribute *tsc2005_attrs[] = {
+ &dev_attr_disable.attr,
&dev_attr_selftest.attr,
NULL
};
@@ -551,7 +595,7 @@ static int tsc2005_open(struct input_dev *input)
mutex_lock(&ts->mutex);
- if (!ts->suspended)
+ if (!ts->suspended && !ts->disabled)
__tsc2005_enable(ts);
ts->opened = true;
@@ -567,7 +611,7 @@ static void tsc2005_close(struct input_dev *input)
mutex_lock(&ts->mutex);
- if (!ts->suspended)
+ if (!ts->suspended && !ts->disabled)
__tsc2005_disable(ts);
ts->opened = false;
@@ -781,7 +825,7 @@ static int tsc2005_suspend(struct device *dev)
mutex_lock(&ts->mutex);
- if (!ts->suspended && ts->opened)
+ if (!ts->suspended && !ts->disabled && ts->opened)
__tsc2005_disable(ts);
ts->suspended = true;
@@ -798,7 +842,7 @@ static int tsc2005_resume(struct device *dev)
mutex_lock(&ts->mutex);
- if (ts->suspended && ts->opened)
+ if (ts->suspended && !ts->disabled && ts->opened)
__tsc2005_enable(ts);
ts->suspended = false;
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: tsc2005 touchscreen: implement disable attribute
2014-11-09 11:56 tsc2005 touchscreen: implement disable attribute Pavel Machek
@ 2014-11-09 12:40 ` Sebastian Reichel
2014-11-09 12:49 ` Pali Rohár
0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2014-11-09 12:40 UTC (permalink / raw)
To: Pavel Machek
Cc: pali.rohar, kernel list, linux-arm-kernel, linux-omap, tony,
khilman, aaro.koskinen, freemangordon, B38611, jg1.han,
linux-input
[-- Attachment #1: Type: text/plain, Size: 326 bytes --]
Hi,
On Sun, Nov 09, 2014 at 12:56:37PM +0100, Pavel Machek wrote:
> Implement disable attribute for tsc2005 touchscreen. It is useful to
> avoid wakeups when phone is in the pocket.
I don't think this should be some driver specific sysfs node.
Instead a generic method from the input subsystem should be
used.
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: tsc2005 touchscreen: implement disable attribute
2014-11-09 12:40 ` Sebastian Reichel
@ 2014-11-09 12:49 ` Pali Rohár
2014-11-09 20:01 ` Dmitry Torokhov
0 siblings, 1 reply; 5+ messages in thread
From: Pali Rohár @ 2014-11-09 12:49 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Pavel Machek, kernel list, linux-arm-kernel, linux-omap, tony,
khilman, aaro.koskinen, freemangordon, B38611, jg1.han,
linux-input, Dmitry Torokhov
[-- Attachment #1: Type: Text/Plain, Size: 1017 bytes --]
On Sunday 09 November 2014 13:40:25 Sebastian Reichel wrote:
> Hi,
>
> On Sun, Nov 09, 2014 at 12:56:37PM +0100, Pavel Machek wrote:
> > Implement disable attribute for tsc2005 touchscreen. It is
> > useful to avoid wakeups when phone is in the pocket.
>
> I don't think this should be some driver specific sysfs node.
> Instead a generic method from the input subsystem should be
> used.
>
> -- Sebastian
Yes. I would like to see generic method to turn off input device
(or just "mute" it if device does not support turn off). Similar
problem is also on laptops or other portable devices. E.g when I
close LID of my laptop I want to turn off internal input devices
(keyboard, touchpad, trackstick) without need to unload evdev
Xserver drivers (or killing Xserver). Another use case is to turn
off keyboard (also from kernel tty on Ctrl+Alt+Fx) which cannot
be unplugged (internal laptop keyboard).
CCed Dmitry, what do you think about it?
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: tsc2005 touchscreen: implement disable attribute
2014-11-09 12:49 ` Pali Rohár
@ 2014-11-09 20:01 ` Dmitry Torokhov
2014-11-10 9:14 ` Pali Rohár
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2014-11-09 20:01 UTC (permalink / raw)
To: Pali Rohár
Cc: Sebastian Reichel, Pavel Machek, kernel list, linux-arm-kernel,
linux-omap, tony, khilman, aaro.koskinen, freemangordon, B38611,
jg1.han, linux-input
On Sun, Nov 09, 2014 at 01:49:19PM +0100, Pali Rohár wrote:
> On Sunday 09 November 2014 13:40:25 Sebastian Reichel wrote:
> > Hi,
> >
> > On Sun, Nov 09, 2014 at 12:56:37PM +0100, Pavel Machek wrote:
> > > Implement disable attribute for tsc2005 touchscreen. It is
> > > useful to avoid wakeups when phone is in the pocket.
> >
> > I don't think this should be some driver specific sysfs node.
> > Instead a generic method from the input subsystem should be
> > used.
> >
> > -- Sebastian
>
> Yes. I would like to see generic method to turn off input device
> (or just "mute" it if device does not support turn off). Similar
> problem is also on laptops or other portable devices. E.g when I
> close LID of my laptop I want to turn off internal input devices
> (keyboard, touchpad, trackstick) without need to unload evdev
> Xserver drivers (or killing Xserver). Another use case is to turn
> off keyboard (also from kernel tty on Ctrl+Alt+Fx) which cannot
> be unplugged (internal laptop keyboard).
>
> CCed Dmitry, what do you think about it?
Actually I'd like it to be not limited to input devices but rater try
doing it at the device core level, if possible. I am sure there are IIO
and other devices that could be forcibly turned off/put into low power
mode under certain circumstances.
There were some talks about it with Rafael, but we never come with
anything concrete.
Thanks.
--
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 [flat|nested] 5+ messages in thread
* Re: tsc2005 touchscreen: implement disable attribute
2014-11-09 20:01 ` Dmitry Torokhov
@ 2014-11-10 9:14 ` Pali Rohár
0 siblings, 0 replies; 5+ messages in thread
From: Pali Rohár @ 2014-11-10 9:14 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Sebastian Reichel, Pavel Machek, kernel list, linux-arm-kernel,
linux-omap, tony, khilman, aaro.koskinen, freemangordon, B38611,
jg1.han, linux-input
[-- Attachment #1: Type: Text/Plain, Size: 1678 bytes --]
On Sunday 09 November 2014 21:01:42 Dmitry Torokhov wrote:
> On Sun, Nov 09, 2014 at 01:49:19PM +0100, Pali Rohár wrote:
> > On Sunday 09 November 2014 13:40:25 Sebastian Reichel wrote:
> > > Hi,
> > >
> > > On Sun, Nov 09, 2014 at 12:56:37PM +0100, Pavel Machek
wrote:
> > > > Implement disable attribute for tsc2005 touchscreen. It
> > > > is useful to avoid wakeups when phone is in the pocket.
> > >
> > > I don't think this should be some driver specific sysfs
> > > node. Instead a generic method from the input subsystem
> > > should be used.
> > >
> > > -- Sebastian
> >
> > Yes. I would like to see generic method to turn off input
> > device (or just "mute" it if device does not support turn
> > off). Similar problem is also on laptops or other portable
> > devices. E.g when I close LID of my laptop I want to turn
> > off internal input devices (keyboard, touchpad, trackstick)
> > without need to unload evdev Xserver drivers (or killing
> > Xserver). Another use case is to turn off keyboard (also
> > from kernel tty on Ctrl+Alt+Fx) which cannot be unplugged
> > (internal laptop keyboard).
> >
> > CCed Dmitry, what do you think about it?
>
> Actually I'd like it to be not limited to input devices but
> rater try doing it at the device core level, if possible. I
> am sure there are IIO and other devices that could be
> forcibly turned off/put into low power mode under certain
> circumstances.
>
> There were some talks about it with Rafael, but we never come
> with anything concrete.
>
> Thanks.
Ok. What about adding sysfs node disable which accept value 0/1?
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-10 9:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09 11:56 tsc2005 touchscreen: implement disable attribute Pavel Machek
2014-11-09 12:40 ` Sebastian Reichel
2014-11-09 12:49 ` Pali Rohár
2014-11-09 20:01 ` Dmitry Torokhov
2014-11-10 9:14 ` Pali Rohár
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).