From: "Henrik Rydberg" <rydberg@euromail.se>
To: Olivier Sobrie <olivier@sobrie.be>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org,
Jan Paesmans <jan.paesmans@gmail.com>
Subject: Re: [PATCH] ili210x: Add support for Ilitek ILI210x based touchscreens
Date: Tue, 6 Mar 2012 10:25:02 +0100 [thread overview]
Message-ID: <20120306092502.GA26689@polaris.bitmath.org> (raw)
In-Reply-To: <20120306075721.GA32325@hposo>
> > > +static irqreturn_t ili210x_irq(int irq, void *irq_data)
> > > +{
> > > + struct ili210x *priv = irq_data;
> > > + struct i2c_client *client = priv->client;
> > > + struct input_dev *input = priv->input;
> > > + struct device *dev = &client->dev;
> > > + struct touchdata touchdata;
> > > + int rc;
> > > +
> > > + do {
> > > + rc = ili210x_read_reg(client, REG_TOUCHDATA, &touchdata,
> > > + sizeof(touchdata));
> > > + if (rc < 0) {
> > > + dev_err(dev, "Unable to get touchdata, err = %d\n",
> > > + rc);
> > > + goto end;
> > > + }
> > > +
> > > + ili210x_report_events(input, &touchdata);
> > > +
> > > + usleep_range(100, 1000);
> > > + mod_timer(&priv->timer, jiffies + TS_PEN_UP_TIMEOUT);
> > > + } while (get_pendown_state(priv) && !priv->stopped);
> >
> > It looks odd to loop in an irq handler, even if it is threaded. What
> > is the pdata->get_pendown_state() doing?
> I agree. The reason of the loop is for edge triggered interrupt.
>
> On my hardware I don't have support for level triggered irq. I'm working
> with edge triggered interrupts.
> In the pdata structure I give to the driver it set irq_flags to
> IRQF_TRIGGER_FALLING and the get_pendown_state function implemented is the
> following:
> static int get_pendown_state(void)
> {
> return gpio_get_value(GPIO_TOUCHSCREEN_IRQ) ? 0 : 1;
> }
> The get_pendown_state() function will look at the irq line to see if it's
> still low meaning there is a finger on the screen.
> If it is the case, we loop, otherwise we exit from the thread and the timer
> will fire after TS_PEN_UP_TIMEOUT.
>
> On the contrary if working with a level triggered interrupt, i.e. with
> irqflags set to IRQF_TRIGGER_LOW, there is no need to add the
> get_pendown_state function and the thread will exit after each touch read.
> In this case the usleep_range() is even not needed...
>
> I agree it's maybe not the best solution... Do I've to use something else
> like a workqueue or something else?
I see, tricky. From the code, it looks like you could skip the loop
and start a workqueue there instead. The work function could then poll
touch frames until the gpio line goes high again. This would also give
you a predictable frame rate without the usleep(). The polldev
implementation might be a good template.
Regarding timer vs workqueue, I am not sure how much could be run in
interrupt context here. You could probably skip the threaded irq
either way, if it is only there to start a poll. Dmitry?
Thanks,
Henrik
next prev parent reply other threads:[~2012-03-06 9:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 13:40 [PATCH] ili210x: Add support for Ilitek ILI210x based touchscreens Olivier Sobrie
2012-03-05 16:48 ` Henrik Rydberg
2012-03-06 7:57 ` Olivier Sobrie
2012-03-06 9:25 ` Henrik Rydberg [this message]
2012-03-06 13:20 ` Olivier Sobrie
2012-03-06 13:42 ` Henrik Rydberg
2012-03-06 13:58 ` Olivier Sobrie
2012-03-06 15:01 ` Olivier Sobrie
2012-03-06 15:51 ` Henrik Rydberg
2012-03-07 7:00 ` Olivier Sobrie
2012-03-07 7:05 ` [PATCH v3] " Olivier Sobrie
2012-03-07 8:44 ` Dmitry Torokhov
2012-03-07 10:11 ` Olivier Sobrie
2012-03-08 9:29 ` [PATCH v4] " Olivier Sobrie
2012-03-17 6:58 ` Dmitry Torokhov
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=20120306092502.GA26689@polaris.bitmath.org \
--to=rydberg@euromail.se \
--cc=dmitry.torokhov@gmail.com \
--cc=jan.paesmans@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=olivier@sobrie.be \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.