linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Richard Röjfors" <richard.rojfors@mocean-labs.com>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	kwangwoo.lee@gmail.com,
	Thierry Reding <thierry.reding@avionic-design.de>,
	Trilok Soni <soni.trilok@gmail.com>
Subject: [PATCH] tsc2007: ignore IRQ:s provoked when reading values
Date: Tue, 22 Sep 2009 15:45:49 +0200	[thread overview]
Message-ID: <4AB8D50D.5040204@mocean-labs.com> (raw)

This patch ignores IRQ:s provoked when reading values from the controller,
when the get_pendown_state callback is not implement. If this interrupt
is not ignored the driver ends up polling the device, since
the driver provokes new interrupts while reading values.

Signed-off-by: Richard Röjfors <richard.rojfors@mocean-labs.com>
---
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 4c51cb4..e594479 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -77,6 +77,7 @@ struct tsc2007 {
 	u16			x_plate_ohms;

 	bool			pendown;
+	bool			ignore_next_irq;
 	int			irq;

 	int			(*get_pendown_state)(void);
@@ -228,14 +229,35 @@ static void tsc2007_work(struct work_struct *work)
 	if (ts->pendown)
 		schedule_delayed_work(&ts->work,
 				      msecs_to_jiffies(TS_POLL_PERIOD));
-	else
+	else {
+		/* if we don't have the get pen down state callback we
+		 * ignore the next IRQ because it is provoked when we checked
+		 * the touch pressure.
+		 * If the user really touches the screen we will get a new
+		 * interrupt anyway so it is safe to ignore it
+		 *
+		 * This is basically implementing this part of the manual:
+		 * "In both cases previously listed, it is recommended that
+		 *  whenever the host writes to the TSC2007, the master
+		 *  processor masks the interrupt associated to PENIRQ.
+		 *  This masking prevents false triggering of interrupts when
+		 *  the PENIRQ line is disabled in the cases previously listed."
+		 */
+		if (!ts->get_pendown_state)
+			ts->ignore_next_irq = true;
 		enable_irq(ts->irq);
+	}
 }

 static irqreturn_t tsc2007_irq(int irq, void *handle)
 {
 	struct tsc2007 *ts = handle;

+	if (ts->ignore_next_irq) {
+		ts->ignore_next_irq = false;
+		return IRQ_HANDLED;
+	}
+
 	if (!ts->get_pendown_state || likely(ts->get_pendown_state())) {
 		disable_irq_nosync(ts->irq);
 		schedule_delayed_work(&ts->work,
--
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

                 reply	other threads:[~2009-09-22 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4AB8D50D.5040204@mocean-labs.com \
    --to=richard.rojfors@mocean-labs.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kwangwoo.lee@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=soni.trilok@gmail.com \
    --cc=thierry.reding@avionic-design.de \
    /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).