2006-05-18 07:07:04

by Harald Welte

[permalink] [raw]
Subject: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Hi!

After a lot of struggle, I've finally managed to get my new PCAP2
touchscreen driver for the OpenEZX (http://www.openezx.org/) project
into a somewhat working state. This means all the hardware-related bits
such as ADC reading and IRQ handling works, and it reports some values
to the upper layers.

It uses the standard input core api and should thus theoretically behave
like any other touchscreen.

Since I've never even owned a linux-driven touchscreen before, let aside
written a ts driver (though plenty of other drivers) yet, there are some
questions that maybe somebody on this list can reply to.

0) What kind of X/Y/Pressure values should I return? Are they supposed
to be scaled to the X/Y resolution of the LCD? As of now, I return
X_ABS, Y_ABS and PRESSURE values between 0 and 1000 (each).

However, the coordinates are actually inverted, so '0,0' corresponds
to the lower right corner of the screen, whereas '1000,1000' is the
upper left corner. Shall I invert them (i.e. return 1000-coord')?

1) where does touchscreen calibration happen? The EZX phones (like many
other devices, I believe) only contain resistive touchscreens that
appear pretty uncalibrated. I'm sure the factory-set calibration
data must be stored somewhere in flash, but it's definitely handled
in the proprietary EZX userland, since their old kernel driver
doesn't have any calibration related bits.

2) what about the 'button' event. In addition to the pressure (which is
about 300 for regular stylus use, > 400 if you press hard and > 600 if
you use yourfinger), some existing TS drivers return a button press.
Is it up to me to decide after which pressure level to consider the
button to be pressed / released?

Looking forward to your replies.

I've attached the current status of pcap_ts.c to this file. It will use
a number of symbols only present in the -ezx5 kernel. This is not
intended for any kind of mainlinie inclusion, reports on coding style or
the like. All will happen at its time.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus


Attachments:
(No filename) (0.00 B)
(No filename) (189.00 B)
Download all attachments

2006-05-18 09:52:47

by Richard Purdie

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Hi,

On Thu, 2006-05-18 at 09:07 +0200, Harald Welte wrote:
> 0) What kind of X/Y/Pressure values should I return? Are they supposed
> to be scaled to the X/Y resolution of the LCD? As of now, I return
> X_ABS, Y_ABS and PRESSURE values between 0 and 1000 (each).
>
> However, the coordinates are actually inverted, so '0,0' corresponds
> to the lower right corner of the screen, whereas '1000,1000' is the
> upper left corner. Shall I invert them (i.e. return 1000-coord')?

Just send the raw data to userspace. Any translations needed can be
handled in userspace by the calibration program. You probably want to
have a look at tslib: http://cvs.arm.linux.org.uk/cgi/viewcvs.cgi/tslib/

The range of the values also doesn't really matter and scaling would
again get handled in userspace.

> 1) where does touchscreen calibration happen? The EZX phones (like many
> other devices, I believe) only contain resistive touchscreens that
> appear pretty uncalibrated. I'm sure the factory-set calibration
> data must be stored somewhere in flash, but it's definitely handled
> in the proprietary EZX userland, since their old kernel driver
> doesn't have any calibration related bits.

Calibration happens in userspace and tslib stores the result
in /etc/pointercal. If you device has this data stored in hardware, you
could have a userspace app translate that data into such a file,
otherwise, you can run a calibration program such as ts_calibrate (from
tslib) or something like xtscal.

> 2) what about the 'button' event. In addition to the pressure (which is
> about 300 for regular stylus use, > 400 if you press hard and > 600 if
> you use yourfinger), some existing TS drivers return a button press.
> Is it up to me to decide after which pressure level to consider the
> button to be pressed / released?

If the user is pressing the screen at all, its a button event and
release is when they stop touching the screen. I'd try not to make it
depend upon pressure but it will depend on the hardware to a degree.

Admittedly, tslib doesn't do much with pressure information at the
moment but tslib would the the correct place to handle pressure rather
than have every kernel touchscreen driver doing it.

For debugging, I'd highly recommend the test tools in tslib (ts_print,
ts_calibrate and ts_test). Use them in that order, checking for sane
output with ts_print first, get a working calibration second and finally
prove its working with ts_test. I found them to be very useful when
developing corgi_ts.

I'm told you're thinking about using OpenEmbedded and would highly
recommend it. It should easily be able to provide a known working
userspace with tslib and these tools in.

Regards,

Richard



2006-05-18 10:42:00

by Michael 'Mickey' Lauer

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Am Donnerstag, den 18.05.2006, 10:52 +0100 schrieb Richard Purdie:
> Just send the raw data to userspace. Any translations needed can be
> handled in userspace by the calibration program. You probably want to
> have a look at tslib: http://cvs.arm.linux.org.uk/cgi/viewcvs.cgi/tslib/

Right. We have very good experience with tslib. The kdrive xserver
supports it and we recently added tslib support to Qt/Embedded (Opie)
and to Evas (EFL).

> Calibration happens in userspace and tslib stores the result
> in /etc/pointercal. If you device has this data stored in hardware, you
> could have a userspace app translate that data into such a file,
> otherwise, you can run a calibration program such as ts_calibrate (from
> tslib) or something like xtscal.

ts_calibrate does a good job. It's pretty easy to use the calibration
API and we have added customized calibration utilities in Opie, GPE and
E to make the calibration phase match the look and feel with the main
GUI.

> I'm told you're thinking about using OpenEmbedded and would highly
> recommend it. It should easily be able to provide a known working
> userspace with tslib and these tools in.

I agree.

--
Regards,

Mickey.
------------------------------------------------------------------
Dipl.-Inf. Michael 'Mickey' Lauer <[email protected]>
------------------------------------------------------------------


2006-05-18 10:58:46

by Harald Welte

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Hi Richard,

thanks for your prompt reply.

On Thu, May 18, 2006 at 10:52:27AM +0100, Richard Purdie wrote:
> Hi,
>
> On Thu, 2006-05-18 at 09:07 +0200, Harald Welte wrote:
> > 0) What kind of X/Y/Pressure values should I return? Are they supposed
> > to be scaled to the X/Y resolution of the LCD? As of now, I return
> > X_ABS, Y_ABS and PRESSURE values between 0 and 1000 (each).
> >
> > However, the coordinates are actually inverted, so '0,0' corresponds
> > to the lower right corner of the screen, whereas '1000,1000' is the
> > upper left corner. Shall I invert them (i.e. return 1000-coord')?
>
> Just send the raw data to userspace. Any translations needed can be
> handled in userspace by the calibration program. You probably want to
> have a look at tslib: http://cvs.arm.linux.org.uk/cgi/viewcvs.cgi/tslib/

ok, I'll investigate. Thanks for the hint.

> The range of the values also doesn't really matter and scaling would
> again get handled in userspace.

ok.

> Calibration happens in userspace and tslib stores the result
> in /etc/pointercal. If you device has this data stored in hardware, you
> could have a userspace app translate that data into such a file,
> otherwise, you can run a calibration program such as ts_calibrate (from
> tslib) or something like xtscal.

well, I guess re-calibrating using ts_calibrate will be easier than
trying to understand the proprietary calibration data format.

> If the user is pressing the screen at all, its a button event and
> release is when they stop touching the screen. I'd try not to make it
> depend upon pressure but it will depend on the hardware to a degree.

ok. I have observed that this specific hardware sometimes indicates a
pressure of '1' (out of a rage ~ 0...1000) even if the screen is not
pressed. So I think there should be some level (maybe 10/20), only
after this level of pressure has been reached it should report a button
press.

> Admittedly, tslib doesn't do much with pressure information at the
> moment but tslib would the the correct place to handle pressure rather
> than have every kernel touchscreen driver doing it.

ok, i see. perfectly makes sense.

> For debugging, I'd highly recommend the test tools in tslib (ts_print,
> ts_calibrate and ts_test). Use them in that order, checking for sane
> output with ts_print first, get a working calibration second and finally
> prove its working with ts_test. I found them to be very useful when
> developing corgi_ts.

thanks again, will do so later today.

> I'm told you're thinking about using OpenEmbedded and would highly
> recommend it. It should easily be able to provide a known working
> userspace with tslib and these tools in.

yes, I've actually managed to do a full task-bootstrap and task-gpe for
the device now (cross-compiled from my linuxppc64 quad-g5), and was
quite amazed that it almost worked out of the box.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus


Attachments:
(No filename) (3.06 kB)
(No filename) (189.00 B)
Download all attachments

2006-05-18 11:16:04

by Florent Thiery

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)


> As of now, I return
> X_ABS, Y_ABS and PRESSURE values between 0 and 1000 (each).
>
>
Are you kidding ??? Does the touchscreen support pressure sensitivity?
Normally it wouldn't, you'd have only two values... Because sensitivity
touchscreens really are rare... That's why wacom does use the pen to
report pressure info on their tablets
> 1) where does touchscreen calibration happen? The EZX phones (like many
> other devices, I believe) only contain resistive touchscreens that
> appear pretty uncalibrated. I'm sure the factory-set calibration
> data must be stored somewhere in flash, but it's definitely handled
> in the proprietary EZX userland, since their old kernel driver
> doesn't have any calibration related bits.
>
I would say touchscreen calibration = scaling (to resolution) +
reference points
> 2) what about the 'button' event. In addition to the pressure (which is
> about 300 for regular stylus use, > 400 if you press hard and > 600 if
> you use yourfinger), some existing TS drivers return a button press.
> Is it up to me to decide after which pressure level to consider the
> button to be pressed / released?
>
I would say the best would be to watch pressure evolution.... If it
springs from 0 to 400 in less than sotg like 200 ms, then you got the
"button" event. Is it feasable?

I got a question: does stylus usage on original A780 show the pressure
sensitivity?

Another one: you say you're workin on building X-e. Are you talking
about kdrive?


Regards,

Florent

2006-05-18 14:38:27

by Harald Welte

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

On Thu, May 18, 2006 at 01:16:16PM +0200, Florent Thiery wrote:
>
> > As of now, I return
> > X_ABS, Y_ABS and PRESSURE values between 0 and 1000 (each).
> >
> Are you kidding ??? Does the touchscreen support pressure sensitivity?
> Normally it wouldn't, you'd have only two values... Because
> sensitivity touchscreens really are rare... That's why wacom does
> use the pen to report pressure info on their tablets

No, this touchscreen actually has fairly reasonable pressure reporting.
I know that this is unusual. But I get reproducible numbers when trying
soft stylus press, hard stylus press. And things like finger touching.
Also I can actually distinguish a thumb from an index finger press ;)

> >1) where does touchscreen calibration happen? The EZX phones (like many
> > other devices, I believe) only contain resistive touchscreens that
> > appear pretty uncalibrated. I'm sure the factory-set calibration
> > data must be stored somewhere in flash, but it's definitely handled
> > in the proprietary EZX userland, since their old kernel driver
> > doesn't have any calibration related bits.
> >
> I would say touchscreen calibration = scaling (to resolution) + reference points

see the other comments. apparently that is left to userspace.

> I would say the best would be to watch pressure evolution.... If it
> springs from 0 to 400 in less than sotg like 200 ms, then you got the
> "button" event. Is it feasable?

that would require rerlatively small polling intervals. please note
that the hardware generates interrupts when pressure != 0. We could
start a high-granularity timer

> I got a question: does stylus usage on original A780 show the pressure
> sensitivity?

not that I've ever noted. But Motorola ignores many of the hardwares
capability..

> Another one: you say you're workin on building X-e. Are you talking about kdrive?

I have no idea, just replaying the package names that OE uses ;)

I now have Xfbdev running on the A780. Unfortunately due to some
strange black magic, the ts driver ceases to receive interrupts as soon
as X is started. reproducible. The same happens with ts_test.

ts_print works very good, though.

Will do more debugging

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus


Attachments:
(No filename) (2.39 kB)
(No filename) (189.00 B)
Download all attachments

2006-05-18 15:34:57

by Florent Thiery

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)


> No, this touchscreen actually has fairly reasonable pressure reporting.
> I know that this is unusual. But I get reproducible numbers when trying
> soft stylus press, hard stylus press. And things like finger touching.
> Also I can actually distinguish a thumb from an index finger press ;)
>
>
This is GREAT !!! because:
- with some embedded drawing app, you can paint !!! (this is interesting
for me)
- we can have a "finger" detection feature, which could allow do trigger
the switch to "finger mode" (bigger buttons etc)
> not that I've ever noted. But Motorola ignores many of the hardwares
> capability..
>
>
That's the purpose of openezx (and open source in general) to unleash
them :) What other hardware features could be improved?

Florent

2006-05-18 16:17:43

by Andy Ross

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Harald Welte wrote:
> 0) What kind of X/Y/Pressure values should I return? Are they supposed
> to be scaled to the X/Y resolution of the LCD? As of now, I return
> X_ABS, Y_ABS and PRESSURE values between 0 and 1000 (each).
>
> However, the coordinates are actually inverted, so '0,0' corresponds
> to the lower right corner of the screen, whereas '1000,1000' is the
> upper left corner. Shall I invert them (i.e. return 1000-coord')?

The native driver reports pressure as either 65535 or 0, and doesn't
(seem to) scale the x/y values at all. The uncalibrated values and
180 degree rotation (actually, my phone shows a slight rotation error
or a few pixels) are definitely reported to user space without
modification.

A matrix-based recalibrator will handle any orientation so long as the
corners are known, and so long as you report a pressure of zero
meaning "pen up" everything should be compatible regardless of the
units you choose.

Andy

2006-05-18 16:19:32

by Andy Ross

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Harald Welte wrote:
> No, this touchscreen actually has fairly reasonable pressure
> reporting. I know that this is unusual. But I get reproducible
> numbers when trying soft stylus press, hard stylus press.

Really? Maybe we have different hardware. I just checked again, and
all I can get out of my A780 is a boolean...

Andy

2006-05-18 16:27:58

by Harald Welte

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

On Thu, May 18, 2006 at 09:19:31AM -0700, Andy Ross wrote:
> Harald Welte wrote:
> > No, this touchscreen actually has fairly reasonable pressure
> > reporting. I know that this is unusual. But I get reproducible
> > numbers when trying soft stylus press, hard stylus press.
>
> Really? Maybe we have different hardware. I just checked again, and
> all I can get out of my A780 is a boolean...

with what? with the original motorola kernel? which values are you
looking at?

I am talking about my new driver, running on 2.6.16.13-ezx5, not about
what Motorola ships in their 2.4.x based firmware.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus


Attachments:
(No filename) (836.00 B)
(No filename) (189.00 B)
Download all attachments

2006-05-18 23:16:53

by Pavel Machek

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Hi!

> > Another one: you say you're workin on building X-e. Are you talking about kdrive?
>
> I have no idea, just replaying the package names that OE uses ;)
>
> I now have Xfbdev running on the A780. Unfortunately due to some
> strange black magic, the ts driver ceases to receive interrupts as soon
> as X is started. reproducible. The same happens with ts_test.

Just poll the touchscreen, then... I have similar problems with
battery hardware and touchscreen sharing ADCs on collie... but
hopefully Motorola did not do _that_ mistake.

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2006-05-18 23:27:40

by Harald Welte

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

On Fri, May 19, 2006 at 01:16:13AM +0200, Pavel Machek wrote:
> Hi!
>
> > > Another one: you say you're workin on building X-e. Are you talking about kdrive?
> >
> > I have no idea, just replaying the package names that OE uses ;)
> >
> > I now have Xfbdev running on the A780. Unfortunately due to some
> > strange black magic, the ts driver ceases to receive interrupts as soon
> > as X is started. reproducible. The same happens with ts_test.
>
> Just poll the touchscreen, then... I have similar problems with
> battery hardware and touchscreen sharing ADCs on collie... but
> hopefully Motorola did not do _that_ mistake.

oh yes, the ADC is multiplexed with dozens (well, actually 14) inputs.
But you can actually very carefully prorgram which ones to read into
what register, and have you notified once completed.

Oh, and to make it even better: The ADC is used by two processors, by
the Application Processor (that runs linux) and the Baseband Processor
;)

I've now fixed that interrupt problem, but I have some other issues in
the state machine that is required for alternating pressure/xy reads.

Confident that those things can be fixed, though.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus


Attachments:
(No filename) (1.37 kB)
(No filename) (189.00 B)
Download all attachments

2006-05-21 18:36:10

by Pavel Machek

[permalink] [raw]
Subject: Re: How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

Hi!
> > > > Another one: you say you're workin on building X-e. Are you talking about kdrive?
> > >
> > > I have no idea, just replaying the package names that OE uses ;)
> > >
> > > I now have Xfbdev running on the A780. Unfortunately due to some
> > > strange black magic, the ts driver ceases to receive interrupts as soon
> > > as X is started. reproducible. The same happens with ts_test.
> >
> > Just poll the touchscreen, then... I have similar problems with
> > battery hardware and touchscreen sharing ADCs on collie... but
> > hopefully Motorola did not do _that_ mistake.
>
> oh yes, the ADC is multiplexed with dozens (well, actually 14) inputs.
> But you can actually very carefully prorgram which ones to read into
> what register, and have you notified once completed.
>
> Oh, and to make it even better: The ADC is used by two processors, by
> the Application Processor (that runs linux) and the Baseband Processor
> ;)
>
> I've now fixed that interrupt problem, but I have some other issues in
> the state machine that is required for alternating pressure/xy reads.
>
> Confident that those things can be fixed, though.

Okay, looks like collie is clean&simple hardware compared to
*that*. Asymetric MultiProcessing cellphone...

Is there any work going on on higher levels of stack? gomunicator for
user interface... Something for multiplexing AT commands?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html