Adding Touch Screen Support

4,973 views
Skip to first unread message

George Ioakimedes

unread,
Jan 18, 2013, 11:45:55 AM1/18/13
to cubie...@googlegroups.com
I'm trying to work on adding in 4-wire touch screen support so when the Cubie Baseboard ships there's at least some initial support for the "features" it provides. 

Not knowing yet where to look to enable the native A10 touch screen support I thought I'd start with a common USB-to-4-wire controller board based on a EETI eGTouch chip (which seems rather common). I haven't found any Android drivers but in their documentation they talk about patching the kernel module and enabling the following modules:
  • EVDEV
  • UINPUT
  • HIDRAW (USB Interface)
Looks like I need to learn some Android but in the mean time I thought I'd ask if anyone knows if any of the "test" images already have these modules added.

My goal is hopefully gather enough information in this thread that can then be added to the Wiki.

Lawrence Sheed

unread,
Jan 19, 2013, 2:19:01 AM1/19/13
to cubie...@googlegroups.com
Not sure this will help you, but i2c (twi) config is via FEX

http://linux-sunxi.org/Fex_Guide#9._capacitive_screen_.28capacitor_tp.29

If you haven't seen that, might be a help as you can see what chips are supported out of box

Any particular need for 4 wire over i2c ?



Lawrence Sheed

COMPUTER SOLUTIONS
Room 401-402 Han Wen Xuan Building 2
No.14, 955 Yan An Middle Road 
Shanghai China 200040


Tel:
       +86 400 820 0919
Fax:      +86 21 62890700
Mobile:  +86 13901 802 269
Skype:  computersolutions.cn

--
You received this message because you are subscribed to the Google Groups "Cubieboard" group.
To unsubscribe from this group, send email to cubieboard+...@googlegroups.com.
Visit this group at http://groups.google.com/group/cubieboard?hl=en.
 
 

Lawrence Sheed

unread,
Jan 19, 2013, 2:49:18 AM1/19/13
to cubie...@googlegroups.com
I just went to look at the data sheet, I realise that I'm a silly monkey, as it is 4 wire.

http://dl.linux-sunxi.org/A10/A10%20Datasheet%20-%20v1.00%20(2011-08-22).pdf
->  Internal 4-wire touch panel controller with pressure sensor and 2-point touch

Should be just a matter of picking a controller chip from the ones listed in the FEX page, and hooking up though (or writing code to support controller chip of choice)


#define SUNXI_TP_BASE 0X01C25000

So a grep of the kernel source for SUNXI_TP_BASE to see how its being init'd for various controllers may be the way forward.


So, 

1 - Config the Chip set via FEX 
2 - init ports accordingly + kernel config for your hardware.
3- wire up hardware?



Lawrence Sheed

COMPUTER SOLUTIONS
Room 401-402 Han Wen Xuan Building 2
No.14, 955 Yan An Middle Road 
Shanghai China 200040


Tel:
       +86 400 820 0919
Fax:      +86 21 62890700
Mobile:  +86 13901 802 269
Skype:  computersolutions.cn

Lawrence Sheed

unread,
Jan 19, 2013, 3:05:30 AM1/19/13
to cubie...@googlegroups.com
Although I'm at the risk of spamming with repeated posts  - 

I also found this good for reference  - https://github.com/cnxsoft/a10-config

Has a list of the various configs for devices using the A10.
Good to see clearly how to config a given hardware from the boot loader e.g. the CTP settings for the various panel controllers etc.

I'll stop now :)




Lawrence Sheed

COMPUTER SOLUTIONS
Room 401-402 Han Wen Xuan Building 2
No.14, 955 Yan An Middle Road 
Shanghai China 200040


Tel:
       +86 400 820 0919
Fax:      +86 21 62890700
Mobile:  +86 13901 802 269
Skype:  computersolutions.cn

George Ioakimedes

unread,
Jan 19, 2013, 10:45:05 AM1/19/13
to cubie...@googlegroups.com
From the Fex Guide we find the following parameters for a resistive touch panel:

8. resistive screen (resistive tp)

[rtp_para]

?
1
2
3
4
5
6
7
rtp_used = 0
rtp_screen_size = 7
rtp_regidity_level = 7
rtp_press_threshold_enable = 0
rtp_press_threshold = 0x1f40
rtp_sensitive_level = 0xf
rtp_exchange_x_y_flag = 0

and from onda_n507h5.fex I see this configuration:
;----------------------------------------------------------------------------------
;rtp_screen_size : 表屏幕尺寸,以斜对角方向长度为准,以寸为单位
;tp_regidity_level : 表屏幕的硬度,以指覆按压,抬起时开始计时,多少个10ms时间单位之后,硬件采集不到数据为准;
; 通常,我们建议的屏,5寸屏设为5,7寸屏设为7,
; 对于某些供应商提供的屏,硬度可能不合要求,需要适度调整
;rtp_press_threshold_enable: whether press threshold is enable or not. 0 is suggested.
;rtp_press_threshold : only when rtp_press_threshold_enable == 1, this para take effect.
; between 0 and 0xFFFFFF is supported.more bigger, more sensitive, 0x1f40 is suggested.
;rtp_sensitive_level : between 0 and 0xf is supported.more bigger, more sensitive, 0xf is suggested.
;rtp_exchange_x_y_flag : in some case, x, y need to be exchanged, at that situation, 1 is setted.
; normally, 0 is setted.
;----------------------------------------------------------------------------------
[rtp_para]
rtp_used = 1
rtp_screen_size = 7
rtp_regidity_level = 7
rtp_press_threshold_enable = 0
rtp_press_threshold = 0x1f40
rtp_sensitive_level = 0xf
rtp_exchange_x_y_flag = 0

;----------------------------------------------------------------------------------
A Google translate of the Chinese yields this:

rtp_screen_size: the table screen size, subject to the oblique length of the diagonal direction inch
; tp_regidity_level: the hardness of the menu screen, to refer to the cover pressing to lift start timing, the number of 10ms time units, hardware acquisition is less than the data subject;
; Usually, we recommend that screen, 5-inch screen is set to 5,7 inch screen is set to 7,
; For some suppliers screen, hardness may be undesirable, require a modest adjustment


So I think this is a great start and if confirmed to work it can be added to the Wiki

George Ioakimedes

unread,
Jan 29, 2013, 12:48:30 AM1/29/13
to cubie...@googlegroups.com
Today I got some minor success with touch screen. You do have to configure the FEX file (although for some reason it would only work if I said the size was 5, 15 would break things). You also have to compile and load the SUN4I_TS module in your kenel:

CONFIG_TOUCHSCREEN_SUN4I_TS=y

After that I found a few useful threads on the internet:


After a little work to get the tslib loaded I was able to successfully run ts_calibrate.

When I went to try and get things working for X11 is where I'm struggling. Currently if I go to use the touch screen I get an error message that LightDM exited and at that point I lose the touch screen, mouse, and keyboard. Through the serial port I can reload lightdm (sudo start lightdm) and sometimes I get to the login screen and sometimes I get to the desktop but I can never use any input devices so obviously I messed something up.

Which one of you gurus can help get this figured out?

George Ioakimedes

unread,
Jan 29, 2013, 8:02:32 PM1/29/13
to cubie...@googlegroups.com
Just a quick note to let everyone know that I now have touch screen working in Ubuntu Desktop! As soon as I can come up for air I'll try to document the steps needed.

Cleaning things up now and moving on to the next hurdle...

dydy Dorin

unread,
May 13, 2013, 9:10:42 AM5/13/13
to cubie...@googlegroups.com
please make some time to document.

i really need this

Michael

unread,
May 14, 2013, 7:40:37 AM5/14/13
to cubie...@googlegroups.com

George Ioakimedes

unread,
May 14, 2013, 10:28:54 AM5/14/13
to cubie...@googlegroups.com
Yes, those were the posts that I followed but as usual things did not go smoothly for me. I found my notes from back in January and I must be getting old because they don't help me remember what I had to change to get this to work. I do remember it's not a big difference from these posts and perhaps they have been updated since January when I was working on it.

Feel free to post back if you have questions following those posts and hopefully I can help. We should also add this to the Wiki but I was in the middle of a big project at the time and didn't do it.


--
You received this message because you are subscribed to a topic in the Google Groups "Cubieboard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cubieboard/2X5z6KLuvUI/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to cubieboard+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Silverio Diquigiovanni

unread,
May 15, 2013, 2:51:37 AM5/15/13
to cubie...@googlegroups.com
To have a working 4 wire resistive touchscreen in cubieboard with Android openbox is a very silly question (how already described in previous posts).

  1. you have to modify FEX (for 7 inch display) file with:

  1. [rtp_para]
    rtp_used = 1
    rtp_screen_size = 7
  1. rtp_regidity_level = 5
  1. rtp_press_threshold_enable = 0
    rtp_press_threshold = 0x1f40
    rtp_sensitive_level = 0xf
    rtp_exchange_x_y_flag = 0

  1. you have to modify /kernel/allwinner/common/arch/arm/configs/cubieboard_defconfig with:

    CONFIG_TOUCHSCREEN_SUN4I_TS=y

    if you would to add statically the touchscreen support or:

    CONFIG_TOUCHSCREEN_SUN4I_TS=m

    if you would to create a loadable module to add in init sequence.

  2. you have to modify /device/allwinner/crane-common/ProductCommon.ml adding bold line to enable TSCalibration2 to build:

    u3gmonitor \
    chat \
    TSCalibration2 \
    TvdVideo \
    TvdFileManager \
    TvdSettings \
    Phone

  3. you have to build the android openbox and store all in nand or SD (if you are running your android OS there).

  4. you have to connect the 4 wire touch screen on related 4 pins of U14 Header (YP_TP/YN_TP/XP_TP/XN_TP).

First time you will boot android the TSCalibration2 application will be automatically executed before you Launcher2 will be run,
so you are sure that touch was OK (you can escape that clicking with a USB mouse and do the procedure in later time).

I next days I will try to use a capacitive multi-touch screen using USB (not I2C) HID layer.
The touch digitizer board will be a PenMount 1201 that is in my desk by weeks waiting the right USB connector by supplier ... sigh
Will follow results and steps of test when all working fine :)

I hope this help you.
Silverio (shineworld)

Mat Oldaker

unread,
May 29, 2013, 7:11:00 AM5/29/13
to cubie...@googlegroups.com
Is there a pre-built Android image available for download which has the necessary changes to enable the touchscreen support, I can see the instructions here how to make the changes, but why re-invent the wheel if it's already been done by someone.

Any info would be appreciated

Cheers
Mat

Silverio Diquigiovanni

unread,
May 29, 2013, 8:04:26 AM5/29/13
to cubie...@googlegroups.com
At home I've a openbox 2.2 modified to work with resistive touchscreen (4 wire) and with HID device like PenMount 1201 USB touch screen.

Unfortunately every build is tailored to a specific hardware (like mine).

What could go fine for you should be .ko modules to use resistive or HID touchscreen that I can send you but you will have to modify your script.bin (script.fex) to meet your hardware (like display size, enabling of resistive touch, etc).

George Ioakimedes

unread,
May 29, 2013, 8:59:16 AM5/29/13
to cubie...@googlegroups.com
What size touch screen are you using? With 15" I found that TSCalibration2 would fail in Android.


--

Silverio Diquigiovanni

unread,
May 29, 2013, 9:52:09 AM5/29/13
to cubie...@googlegroups.com
I'm using 7", 9.5" and 12" screens, BUT higher resolution is 800x600 on 12".
They are industrial monitors where contrast & light are more important than pixels density, so I haven't problems with resistive touch and TSCalibration2.

George Ioakimedes

unread,
May 29, 2013, 12:40:51 PM5/29/13
to cubie...@googlegroups.com
I've only tried 15.6" and what I found was that the touch would be offset from the actual touch point. On the right side of the screen it would be correct but as you moved to the left the offset would begin to increase until at the left side you would be off by ~1". Because of this offset I could never get TSCalibration to complete because I assume the offset was too large for the program to handle.

This was several months ago so I don't remember all the details but I believe I was making some posts and looking for some help. I do remember that the rtp_screen_size parameter was really used to adjust values based on screen size and that only 5 and 7 were valid numbers, anything else resulted in an error in the code.

Maybe the OpenBox distribution doesn't have the same problems that I was experiencing using the image from the Cubieboard.org page???


On Wed, May 29, 2013 at 6:52 AM, Silverio Diquigiovanni <silverio...@gmail.com> wrote:
I'm using 7", 9.5" and 12" screens, BUT higher resolution is 800x600 on 12".
They are industrial monitors where contrast & light are more important than pixels density, so I haven't problems with resistive touch and TSCalibration2.

--

Silverio Diquigiovanni

unread,
May 29, 2013, 4:44:22 PM5/29/13
to cubie...@googlegroups.com
Looking in sun4i-ts.c driver code you can see that rtp_screen_size is used only to set dual touch settings values so ... you can use 7 for 12 without issue (at least I've do that).
At least you have to manage the fake dualtouch system (not real dualtouch in resistive world).
I've changed some internal values...

However, at least for 3.0.52 that I'm looking, driver code is TERRIBLE, but work !

I've begun to put my hands on it ... 

I'm using TSCalibration2 and I don't know if it is different by you but, to be honest, I haven't yet calibrated 12", just light it touched and then used the mouse for all.
I will check the TSC2 code in next days...

Silverio Diquigiovanni

unread,
May 29, 2013, 4:57:59 PM5/29/13
to cubie...@googlegroups.com
Looking at https://github.com/mbrrg/olinuxino-a13/blob/master/android/lcd/sun4i-ts.patch ,for example, you can see
how in Olinuxino someone changed fixed 800 pixels info to a modifiable value or added support to a 4" display...

Message has been deleted

Mat Oldaker

unread,
May 29, 2013, 5:57:58 PM5/29/13
to cubie...@googlegroups.com
I have a 6.5" screen and touchscreen, it uses an eGalax usb controller. I've yet to try to connect connecting via the header pins. Connecting via usb it doesn't show up in dmesg on the stock cubie android, as it does when connected to my tablet and phone(although it was non functional).
Over the weekend I'll make the changes listed here and build android and see what I can get working, via either method.
The touchscreen did come with linux drivers, but I'm only interested in running Android on the cubie.

George Ioakimedes

unread,
May 29, 2013, 8:57:28 PM5/29/13
to cubie...@googlegroups.com
I found the original source code and the company that wrote TSCalibration2 and I emailed them but never heard back. I really would like to get this working and failed at one project I was working on back in January because of this. I'm more hardware than software so anything you guys can do would be greatly appreciated. I remember trying to modify the code and seeing changes but I was never able to make any real improvements.


--

Silverio Diquigiovanni

unread,
May 30, 2013, 2:31:08 AM5/30/13
to cubie...@googlegroups.com
Looking at http://www.lii-enac.fr/en/architecture/linux-input/multitouch-devices.html eGalax should be supported but much depends by its PID/VID.
Try to connect it to your linux machine in USB connector and then call "lsusb" to get its PID/VID, then check in the below list to see if covered:

<snapshot from openbox/kernel/....../hid-core.h & hid-core.h>

#define USB_VENDOR_ID_DWAV 0x0eef
#define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D 0x480d
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E 0x480e
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C 0x720c
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B 0x726b
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1 0x72a1
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA 0x72fa
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302 0x7302
#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001

{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
{ HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },

if your touchscreen is in the list to have it full working on cubieboard it's only necessary to change this line in cubieboard_defconfig:

   # CONFIG_HID_MULTITOUCH is not set

to

   CONFIG_HID_MULTITOUCH=m

PS: I've tried also =y to have in kernel but doesn't work.

and call/add "insmod hid-multitouch.ko" for example in init.rc





Silverio Diquigiovanni

unread,
May 30, 2013, 4:55:23 AM5/30/13
to cubie...@googlegroups.com
George,

sources of TSCalibration2 are in openbox/device/allwinner/common/packages/TSCalibration2 and how you can see, like sunxi4i-tc.c, are HARDLY coded to works with 800x480:

<resources>
  <integer name="p_limit">200</integer>
  <integer name="screen_max_width">800</integer>
  <integer name="sreen_max_height">480</integer>
</resources>

so if you have another display geometry is necessary to modify the code and rebuild... sigh...

PS: I guess that who wrote that code made for its needs and than for a 800x480 display. My first display was, for lucky case, just a 800x480 and all worked fine at first shot.

Mat Oldaker

unread,
Jun 15, 2013, 3:09:13 AM6/15/13
to cubie...@googlegroups.com

Now I've got my cubie and baseboard, I've experimented with setting up the touchscreen.  I've had no luck using the touch interface on the cubie baseboard and making the changes to the Android image as listed in a previos post, I get no response from the touch screen.  I have had limited success using the USB touch controller supplied with my 6.5" panel, with a modified android image.I can get the touchscreen to act similar to a touchpad, in that the pointer remains in its last position and moves with touch, but not like a touchscreen should and have the pointer appear under the stylus/finger etc.
The axis of the touchscreen is also reversed, but this is a common problem for egalax touch controllers, hopefully easy to resolve.
Has anyone experience any similar problems using a usb touch controller? or have a solution which may fix?
Cheers
Mat

Mat Oldaker

unread,
Jun 15, 2013, 8:30:25 AM6/15/13
to cubie...@googlegroups.com
I have had more success with the touchscreen, I have finally managed to get the cubie to read the *.idc file for the touchscreen which now makes it function as it should, however the calibration is off. it is accurate in the dead center of the screen but as i move away from center on either the x or y axis it becomes inaccurate. Swapping the y- and y+ wires into the controller solved the inverted y axis.  Because of the inaccurate touch in the corners, I am unable to calibrate using the calibrate utility.

George Ioakimedes

unread,
Jun 15, 2013, 6:03:00 PM6/15/13
to cubie...@googlegroups.com
That's the problem that I was running into earlier in the year. I've asked for this to be looked at since it seems the touch screen driver is not well written. I too also noticed that you have to invert the +/- touch screen connections when switching between Android and Linaro.

I tried in vain to find the bug in the code and recompile but I never did make any good progress.


On Sat, Jun 15, 2013 at 5:30 AM, Mat Oldaker <mat.ol...@gmail.com> wrote:
I have had more success with the touchscreen, I have finally managed to get the cubie to read the *.idc file for the touchscreen which now makes it function as it should, however the calibration is off. it is accurate in the dead center of the screen but as i move away from center on either the x or y axis it becomes inaccurate. Swapping the y- and y+ wires into the controller solved the inverted y axis.  Because of the inaccurate touch in the corners, I am unable to calibrate using the calibrate utility.

--
You received this message because you are subscribed to a topic in the Google Groups "Cubieboard" group.

To unsubscribe from this group and all its topics, send an email to cubieboard+...@googlegroups.com.

mahdichi

unread,
Jul 23, 2013, 4:30:01 AM7/23/13
to cubie...@googlegroups.com
hi everyone
i try enable 4 wire resistive touchscreen in cubieboard in linaro ubuntu
i follow below link and successfully compile tslib with A13 patch.
i can run ts_test and ts_calibrated 
but i can't config x to use it.

any idea ?

thanks in advance.

Dmytro Rybakov

unread,
Jun 3, 2014, 5:02:33 AM6/3/14
to cubie...@googlegroups.com
Hi, I have cubieboard 1 and I need to simulate touch events without actual device. But the Android Open TV that comes in NAND does not support touch device and does not contain drivers ( /dev/input/eventX does not contain touch device). Another question. After building Android TV with touch screen support the /dev/input/event which corresponds to touch device will be presented even if actual hardware is not connected. Is it true? 

среда, 15 мая 2013 г., 9:51:37 UTC+3 пользователь Silverio Diquigiovanni написал:
Reply all
Reply to author
Forward
0 new messages