From: Pavel Machek <pavel@ucw.cz>
To: Trilok Soni <soni.trilok@gmail.com>
Cc: Arve Hj?nnev?g <arve@android.com>,
kernel list <linux-kernel@vger.kernel.org>,
Brian Swetland <swetland@google.com>,
dmitry.torokhov@gmail.com, dtor@mail.ru,
linux-input@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
linux-i2c@vger.kernel.org
Subject: Threaded interrupts for synaptic touchscreen in HTC dream
Date: Tue, 21 Jul 2009 12:59:25 +0200 [thread overview]
Message-ID: <20090721105924.GK4133@elf.ucw.cz> (raw)
In-Reply-To: <5d5443650907151033w36008b71pe4b32bcea9489b75@mail.gmail.com>
Hi!
> > Do you have a link? (I replaced it with disable_irq_nosync, if that is
> > enough...)
> >
>
> link: http://patchwork.kernel.org/patch/35515/
Thanks!
Here's my attempt at that conversion; unfortunately I'm stuck in
2.6.29 for msm stuff, so I was not even able to compile-test it :-(.
Pavel
diff --git a/drivers/input/touchscreen/synaptics_i2c_rmi.c b/drivers/input/touchscreen/synaptics_i2c_rmi.c
index 771b710..4816262 100644
--- a/drivers/input/touchscreen/synaptics_i2c_rmi.c
+++ b/drivers/input/touchscreen/synaptics_i2c_rmi.c
@@ -13,6 +13,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
+ * http://www.synaptics.com/sites/default/files/511_000099_01F.pdf
*/
#include <linux/module.h>
@@ -34,7 +35,6 @@ struct synaptics_ts_data {
u16 addr;
struct i2c_client *client;
struct input_dev *input_dev;
- int use_irq;
struct hrtimer timer;
struct work_struct work;
u16 max[2];
@@ -87,6 +87,22 @@ static int synaptics_init_panel(struct synaptics_ts_data *ts)
static void decode_report(struct synaptics_ts_data *ts, u8 *buf)
{
+/*
+ * This sensor sends two 6-byte absolute finger reports, an optional
+ * 2-byte relative report followed by a status byte. This function
+ * reads the two finger reports and transforms the coordinates
+ * according the platform data so they can be aligned with the lcd
+ * behind the touchscreen. Typically we flip the y-axis since the
+ * sensor uses the bottom left corner as the origin, but if the sensor
+ * is mounted upside down the platform data will request that the
+ * x-axis should be flipped instead. The snap to inactive edge border
+ * are used to allow tapping the edges of the screen on the G1. The
+ * active area of the touchscreen is smaller than the lcd. When the
+ * finger gets close the edge of the screen we snap it to the
+ * edge. This allows ui elements at the edge of the screen to be hit,
+ * and it prevents hitting ui elements that are not at the edge of the
+ * screen when the finger is touching the edge.
+ */
int pos[2][2];
int f, a;
int base = 2;
@@ -144,7 +160,7 @@ static void decode_report(struct synaptics_ts_data *ts, u8 *buf)
input_sync(ts->input_dev);
}
-static void synaptics_ts_work_func(struct work_struct *work)
+static void synaptics_ts_work(struct synaptics_ts_data *ts)
{
int i;
int ret;
@@ -152,8 +168,6 @@ static void synaptics_ts_work_func(struct work_struct *work)
struct i2c_msg msg[2];
u8 start_reg = 0;
u8 buf[15];
- struct synaptics_ts_data *ts =
- container_of(work, struct synaptics_ts_data, work);
msg[0].addr = ts->client->addr;
msg[0].flags = 0;
@@ -164,7 +178,7 @@ static void synaptics_ts_work_func(struct work_struct *work)
msg[1].len = sizeof(buf);
msg[1].buf = buf;
- for (i = 0; i < ((ts->use_irq && !bad_data) ? 1 : 10); i++) {
+ for (i = 0; i < (!bad_data ? 1 : 10); i++) {
ret = i2c_transfer(ts->client->adapter, msg, 2);
if (ret < 0) {
pr_err("ts_work: i2c_transfer failed\n");
@@ -190,27 +204,20 @@ static void synaptics_ts_work_func(struct work_struct *work)
decode_report(ts, buf);
}
- if (ts->use_irq)
- enable_irq(ts->client->irq);
+ enable_irq(ts->client->irq);
}
-static enum hrtimer_restart synaptics_ts_timer_func(struct hrtimer *timer)
-{
- struct synaptics_ts_data *ts =
- container_of(timer, struct synaptics_ts_data, timer);
-
- queue_work(synaptics_wq, &ts->work);
- hrtimer_start(&ts->timer, ktime_set(0, 12500000), HRTIMER_MODE_REL);
- return HRTIMER_NORESTART;
+static irqreturn_t synaptics_ts_hardirq(int irq, void *dev_id)
+{
+ disable_irq_nosync(irq);
+ return IRQ_WAKE_THREAD;
}
static irqreturn_t synaptics_ts_irq_handler(int irq, void *dev_id)
{
struct synaptics_ts_data *ts = dev_id;
-
- disable_irq_nosync(ts->client->irq);
- queue_work(synaptics_wq, &ts->work);
+ synaptics_ts_work(ts);
return IRQ_HANDLED;
}
@@ -469,24 +476,21 @@ static int __devinit synaptics_ts_probe(
ts->input_dev->name);
goto err_input_register_device_failed;
}
- if (client->irq) {
- ret = request_irq(client->irq, synaptics_ts_irq_handler,
- 0, client->name, ts);
- if (ret == 0) {
- ret = i2c_set(ts, 0xf1, 0x01, "enable abs int");
- if (ret)
- free_irq(client->irq, ts);
- }
- if (ret == 0)
- ts->use_irq = 1;
- else
- dev_err(&client->dev, "request_irq failed\n");
- }
- if (!ts->use_irq) {
- hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- ts->timer.function = synaptics_ts_timer_func;
- hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
+
+ ret = request_threaded_irq(client->irq,
+ synatptics_ts_hardirq, synaptics_ts_irq_handler,
+ 0, client->name, ts);
+
+ if (ret)
+ pr_err("synaptics: could not register irq\n");
+
+
+ ret = i2c_set(ts, 0xf1, 0x01, "enable abs int");
+ if (ret) {
+ pr_err("synaptics: could not enable irq\n");
+ free_irq(client->irq, ts);
}
+
#ifdef CONFIG_HAS_EARLYSUSPEND
ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
ts->early_suspend.suspend = synaptics_ts_early_suspend;
@@ -495,7 +499,7 @@ static int __devinit synaptics_ts_probe(
#endif
pr_info("synaptics: Start touchscreen %s in %s mode\n",
- ts->input_dev->name, ts->use_irq ? "interrupt" : "polling");
+ ts->input_dev->name, "interrupt");
return 0;
@@ -517,10 +521,7 @@ static int synaptics_ts_remove(struct i2c_client *client)
#ifdef CONFIG_HAS_EARLYSUSPEND
unregister_early_suspend(&ts->early_suspend);
#endif
- if (ts->use_irq)
- free_irq(client->irq, ts);
- else
- hrtimer_cancel(&ts->timer);
+ free_irq(client->irq, ts);
input_unregister_device(ts->input_dev);
kfree(ts);
return 0;
@@ -532,12 +533,9 @@ static int synaptics_ts_suspend(struct i2c_client *client, pm_message_t mesg)
int ret;
struct synaptics_ts_data *ts = i2c_get_clientdata(client);
- if (ts->use_irq)
- disable_irq(client->irq);
- else
- hrtimer_cancel(&ts->timer);
+ disable_irq(client->irq);
ret = cancel_work_sync(&ts->work);
- if (ret && ts->use_irq) /* if work was pending disable-count is now 2 */
+ if (ret) /* if work was pending disable-count is now 2 */
enable_irq(client->irq);
i2c_set(ts, 0xf1, 0, "disable interrupt");
i2c_set(ts, 0xf0, 0x86, "deep sleep");
@@ -563,11 +561,8 @@ static int synaptics_ts_resume(struct i2c_client *client)
synaptics_init_panel(ts);
- if (ts->use_irq) {
- enable_irq(client->irq);
- i2c_set(ts, 0xf1, 0x01, "enable abs int");
- } else
- hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
+ enable_irq(client->irq);
+ i2c_set(ts, 0xf1, 0x01, "enable abs int");
return 0;
}
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2009-07-21 10:59 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090714100634.GA4054@elf.ucw.cz>
2009-07-14 10:20 ` Support for synaptic touchscreen in HTC dream Trilok Soni
[not found] ` <5d5443650907140320w334864f4uc1ee13ed32fdb874-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-15 13:36 ` Pavel Machek
[not found] ` <20090715133627.GA2538-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2009-07-15 17:33 ` Trilok Soni
[not found] ` <5d5443650907151033w36008b71pe4b32bcea9489b75-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-21 10:21 ` Pavel Machek
2009-07-21 10:34 ` Trilok Soni
[not found] ` <5d5443650907210334k3f562cebsc665511a161c8639-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-08-08 13:40 ` Synaptics touchscreen for HTC Dream: check that smbus is available Pavel Machek
[not found] ` <20090808134049.GA13083-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2009-08-17 23:47 ` Andrew Morton
[not found] ` <20090817164759.43c39f2d.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-08-21 14:23 ` Pavel Machek
2009-07-21 10:59 ` Pavel Machek [this message]
[not found] ` <20090721105924.GK4133-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2009-07-21 11:36 ` Threaded interrupts for synaptic touchscreen in HTC dream Mark Brown
[not found] ` <20090721113642.GC13286-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2009-07-21 12:18 ` Trilok Soni
2009-07-21 12:30 ` Trilok Soni
2009-07-21 12:49 ` Mark Brown
[not found] ` <20090721124933.GA5668-HF5t3jzXg/6ND3a5+9QAFujbO/Zr0HzV@public.gmane.org>
2009-07-21 16:04 ` Dmitry Torokhov
[not found] ` <20090721160436.GD4352-wUGeVx6es1+Q2O5dskk9LyLysJ1jNyTM@public.gmane.org>
2009-07-21 20:30 ` Thomas Gleixner
2009-07-21 20:58 ` Dmitry Torokhov
2009-07-21 21:48 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907212225030.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-21 22:25 ` Mark Brown
[not found] ` <20090721222547.GA1948-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2009-07-22 10:44 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907221022190.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 12:18 ` Mark Brown
2009-07-22 12:58 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907221427380.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 13:30 ` Peter Zijlstra
2009-07-22 14:18 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907221615480.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 14:32 ` Mark Brown
[not found] ` <20090722143211.GB29404-HF5t3jzXg/6ND3a5+9QAFujbO/Zr0HzV@public.gmane.org>
2009-07-22 14:52 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907221645240.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 14:56 ` Mark Brown
2009-07-22 15:15 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907221715260.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 15:56 ` Mark Brown
2009-07-22 16:57 ` David Brownell
[not found] ` <200907220957.16499.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-07-22 21:04 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0907222226270.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 21:57 ` Arve Hjønnevåg
[not found] ` <d6200be20907221457r4e2f6d29g57146586fd13776a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-22 22:15 ` David Brownell
2009-07-22 23:30 ` Arve Hjønnevåg
2009-07-22 22:09 ` David Brownell
2009-07-23 4:43 ` Dmitry Torokhov
2009-07-22 13:31 ` Mark Brown
2009-07-22 17:04 ` David Brownell
2009-07-22 17:08 ` Mark Brown
2009-07-22 16:04 ` Dmitry Torokhov
[not found] ` <20090722155811.GA2775-wUGeVx6es1+Q2O5dskk9LyLysJ1jNyTM@public.gmane.org>
2009-07-22 16:40 ` Thomas Gleixner
2009-07-22 16:57 ` Mark Brown
[not found] ` <alpine.LFD.2.00.0907221830410.2813-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-22 17:08 ` Dmitry Torokhov
2009-07-22 17:13 ` David Brownell
2009-07-22 16:51 ` David Brownell
2009-07-22 16:39 ` David Brownell
[not found] ` <200907220939.33399.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-07-22 16:43 ` Thomas Gleixner
2009-07-22 17:34 ` David Brownell
2009-07-22 16:50 ` Mark Brown
2009-07-22 17:41 ` David Brownell
2009-07-21 20:43 ` Daniel Ribeiro
2009-07-21 12:30 ` Mark Brown
2009-07-23 14:55 ` Pavel Machek
2009-07-15 21:33 ` Support " Arve Hjønnevåg
2009-07-21 10:40 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090721105924.GK4133@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=akpm@osdl.org \
--cc=arve@android.com \
--cc=dmitry.torokhov@gmail.com \
--cc=dtor@mail.ru \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=soni.trilok@gmail.com \
--cc=swetland@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).