Skip to contentSkip to conversation

How should Touchscreen Input Drives behave (OpenEZX pcap_ts)

PATCH Harald Welte 7 participants 13 messages May 18, 2006 – May 21, 2006 Input drivers

lore
Share & tools
lore
#0 lore raw

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.

Signature · 3 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus
drivers/input/touchscreen/Kconfig +12 -0
Index: linux-2.6.16.13-ezx3/drivers/input/touchscreen/Kconfig
===================================================================
@@ -108,4 +108,16 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called hp680_ts_input.
 
+config TOUCHSCREEN_PCAP
+	tristate "Motorola PCAP touchscreen"
+	depends on PXA_EZX_PCAP
+	help
+	  Say Y here if you have a Motorola EZX (E680, A780) telephone
+	  and want to support the built-in touchscreen.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called hp680_ts_input.
+
 endif
drivers/input/touchscreen/Makefile +1 -0
Index: linux-2.6.16.13-ezx3/drivers/input/touchscreen/Makefile
===================================================================
@@ -12,3 +12,4 @@
 obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
 obj-$(CONFIG_TOUCHSCREEN_MK712)	+= mk712.o
 obj-$(CONFIG_TOUCHSCREEN_HP600)	+= hp680_ts_input.o
+obj-$(CONFIG_TOUCHSCREEN_PCAP)	+= pcap_ts.o
drivers/input/touchscreen/pcap_ts.c new file +333 -0

333 lines not on this page · raw message

#1 lore raw

Hi,

Quoted 7 lines · Harald Welte

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.

Quoted 6 lines

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.

Quoted 5 lines

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

#2 lore raw

Am Donnerstag, den 18.05.2006, 10:52 +0100 schrieb Richard Purdie:

Quoted 3 lines

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).

Quoted 5 lines

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.

Quoted 3 lines

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.

Signature · 6 lines
Regards,

Mickey.
------------------------------------------------------------------
Dipl.-Inf. Michael 'Mickey' Lauer <[email protected]>
------------------------------------------------------------------
#3 lore raw
In reply to Richard Purdie

Hi Richard,

thanks for your prompt reply.

Quoted 7 lines · Richard Purdie

Hi,

Quoted 4 lines · Harald Welte

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).

Quoted 7 lines
Quoted 3 lines

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.

Quoted 2 lines

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

ok.

Quoted 5 lines

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.

Quoted 3 lines

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.

Quoted 3 lines

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.

Quoted 5 lines

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.

Quoted 3 lines

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.

Signature · 3 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus
#4 lore raw
In reply to Harald Welte
Quoted 5 lines

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

Quoted 7 lines

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

Quoted 6 lines

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

#5 lore raw
Quoted 8 lines · Florent Thiery
Quoted 4 lines

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 ;)

Quoted 8 lines
Quoted 7 lines

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.

Quoted 3 lines

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

Quoted 2 lines

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..

Quoted 1 line

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

Signature · 3 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus
#6 lore raw
Quoted 7 lines

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)

Quoted 4 lines

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

#7 lore raw
In reply to Harald Welte
Quoted 3 lines · Harald Welte

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

#8 lore raw
Quoted 7 lines · Andy Ross
Quoted 3 lines · Harald Welte

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.

Signature · 3 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus
#9 lore raw
In reply to Harald Welte

Hi!

Quoted 7 lines
Quoted 1 line

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

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw
Quoted 6 lines · Pavel Machek

Hi!

Quoted 4 lines
Quoted 1 line

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 ;)

Quoted 7 lines
Quoted 3 lines

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.

Signature · 3 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
We all know Linux is great...it does infinite loops in 5 seconds. -- Linus
#11 lore raw

Hi!

Quoted 16 lines
Quoted 11 lines
Quoted 7 lines
Quoted 1 line

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.

Quoted 8 lines

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

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#12 lore raw
In reply to Harald Welte
Quoted 7 lines · Harald Welte

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