Porting a touchscreen to JB

1,333 views
Skip to first unread message

ffxx68

unread,
Sep 19, 2012, 11:32:54 AM9/19/12
to android...@googlegroups.com
Porting to JB an Open Source Renesas-based tablet (https://groups.google.com/forum/?hl=en&fromgroups=#!forum/renesas-emev-osp) and having troubles with the touch screen.

While GB implementation perfectly supported the touch panels (PixCir or Goodix mdels, depending of hardware revision), with the JB build these have some issues. Touch enters in "Pointer" mode by default: a circle shows on screen the processed touch points, telling at least the driver is working, but I have to use two fingers to make it feel the touch. What's worst the touch point isn't calibrated, as the circle doesn't show up under my finger, but in a different place of the screen, as if wrong touch X and Y were captured.

What's strange, touch data are received correctly, e.g. I can read the touch position using "adb shell dump input":

...
      Last Raw Touch: pointerCount=1
        [0]: id=0, x=399, y=246, pressure=0, touchMajor=33, touchMinor=33, toolMajor=33, toolMinor=33, orientation=0, tiltX=0, tiltY=0, distance=0, toolType=1, isHovering=false
      Last Cooked Touch: pointerCount=1
        [0]: id=0, x=398.502, y=245.489, pressure=1.000, touchMajor=32.945, touchMinor=32.945, toolMajor=32.945, toolMinor=32.945, orientation=0.000, tilt=0.000, distance=0.000, toolType=1, isHovering=false
...

This is for example (with a Goodix device) while touching in the mid of screen (complete dump below). As it's a 800x480 7" one, reported X=399 and Y=246 are correct. But these looks like not being translated, or received by the main window (the locker screen in this case) and the circle is in a completely different position than the screen center.

I've checked the kernel driver, and it complies (as far as I could see) to the requirements also described in:

  http://source.android.com/tech/input/touch-devices.html

Both with the Goodix and Pixcir devices results are very similar. Also after adding a .idc configuration, as suggested on the same, results are similar, except that I can force the device to work in real Touchscreen mode (not Pointer - circle isn't shown).

Find in the following the full dump while touching in the mid of the screen:

------------------
$ adb shell dumpsys input
adb server is out of date.  killing...
* daemon started successfully *
INPUT MANAGER (dumpsys input)

Event Hub State:
  BuiltInKeyboardId: -2
  Devices:
    -1: Virtual
      Classes: 0x40000023
      Path: <virtual>
      Descriptor: a718a782d34bc767f4689c232d64d527998ea7fd
      Location:
      UniqueId: <virtual>
      Identifier: bus=0x0000, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Virtual.kcm
      ConfigurationFile:
      HaveKeyboardLayoutOverlay: false
    1: ekt2201
      Classes: 0x00000001
      Path: /dev/input/event1
      Descriptor: 54fb2efd84449f14715b8981fd0fd6fd2bcd1830
      Location:
      UniqueId:
      Identifier: bus=0x0018, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile:
      HaveKeyboardLayoutOverlay: false
    2: gt80x
      Classes: 0x00000014
      Path: /dev/input/event2
      Descriptor: 9e6143a1bc5dd41251b165ed559e32d49b5aad8f
      Location: input/ts)
      UniqueId:
      Identifier: bus=0x0018, vendor=0xdead, product=0xbeef, version=0x1103
      KeyLayoutFile:
      KeyCharacterMapFile:
      ConfigurationFile:
      HaveKeyboardLayoutOverlay: false
    3: gpio-keys
      Classes: 0x00000001
      Path: /dev/input/event0
      Descriptor: 485d69228e24f5e46da1598745890b214130dbc4
      Location: gpio-keys/input0
      UniqueId:
      Identifier: bus=0x0019, vendor=0x0001, product=0x0001, version=0x0100
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile:
      HaveKeyboardLayoutOverlay: false

Input Reader State:
  Device -1: Virtual
    Generation: 2
    IsExternal: false
    Sources: 0x00000301
    KeyboardType: 2
    Keyboard Input Mapper:
      Parameters:
        AssociatedDisplayId: -1
        OrientationAware: false
      KeyboardType: 2
      Orientation: 0
      KeyDowns: 0 keys currently down
      MetaState: 0x0
      DownTime: 0
  Device 1: ekt2201
    Generation: 8
    IsExternal: false
    Sources: 0x00000101
    KeyboardType: 1
    Keyboard Input Mapper:
      Parameters:
        AssociatedDisplayId: -1
        OrientationAware: false
      KeyboardType: 1
      Orientation: 0
      KeyDowns: 0 keys currently down
      MetaState: 0x0
      DownTime: 0
  Device 2: gt80x
    Generation: 10
    IsExternal: false
    Sources: 0x00002002
    KeyboardType: 0
    Motion Ranges:
      X: source=0x00002002, min=0.000, max=799.001, flat=0.000, fuzz=0.999
      Y: source=0x00002002, min=0.000, max=479.002, flat=0.000, fuzz=0.998
      PRESSURE: source=0x00002002, min=0.000, max=1.000, flat=0.000, fuzz=0.000
      SIZE: source=0x00002002, min=0.000, max=1.000, flat=0.000, fuzz=0.000
      TOUCH_MAJOR: source=0x00002002, min=0.000, max=932.952, flat=0.000, fuzz=0.000
      TOUCH_MINOR: source=0x00002002, min=0.000, max=932.952, flat=0.000, fuzz=0.000
      TOOL_MAJOR: source=0x00002002, min=0.000, max=932.952, flat=0.000, fuzz=0.000
      TOOL_MINOR: source=0x00002002, min=0.000, max=932.952, flat=0.000, fuzz=0.000
    Touch Input Mapper:
      Parameters:
        GestureMode: spots
        DeviceType: pointer
        AssociatedDisplay: id=0, isExternal=false
        OrientationAware: false
      Raw Touch Axes:
        X: min=0, max=800, flat=0, fuzz=0, resolution=0
        Y: min=0, max=480, flat=0, fuzz=0, resolution=0
        Pressure: unknown range
        TouchMajor: min=0, max=255, flat=0, fuzz=0, resolution=0
        TouchMinor: unknown range
        ToolMajor: min=0, max=255, flat=0, fuzz=0, resolution=0
        ToolMinor: unknown range
        Orientation: unknown range
        Distance: unknown range
        TiltX: unknown range
        TiltY: unknown range
        TrackingId: unknown range
        Slot: unknown range
      Calibration:
        touch.size.calibration: geometric
        touch.pressure.calibration: none
        touch.orientation.calibration: none
        touch.distance.calibration: none
      SurfaceWidth: 800px
      SurfaceHeight: 480px
      SurfaceOrientation: 0
      Translation and Scaling Factors:
        XScale: 0.999
        YScale: 0.998
        XPrecision: 1.001
        YPrecision: 1.002
        GeometricScale: 0.998
        PressureScale: 0.000
        SizeScale: 0.004
        OrientationCenter: 0.000
        OrientationScale: 0.000
        DistanceScale: 0.000
        HaveTilt: false
        TiltXCenter: 0.000
        TiltXScale: 0.000
        TiltYCenter: 0.000
        TiltYScale: 0.000
      Last Button State: 0x00000000
      Last Raw Touch: pointerCount=1
        [0]: id=0, x=399, y=246, pressure=0, touchMajor=33, touchMinor=33, toolMajor=33, toolMinor=33, orientation=0, tiltX=0, tiltY=0, distance=0, toolType=1, isHovering=false
      Last Cooked Touch: pointerCount=1
        [0]: id=0, x=398.502, y=245.489, pressure=1.000, touchMajor=32.945, touchMinor=32.945, toolMajor=32.945, toolMinor=32.945, orientation=0.000, tilt=0.000, distance=0.000, toolType=1, isHovering=false
      Pointer Gesture Detector:
        XMovementScale: 0.799
        YMovementScale: 0.799
        XZoomScale: 0.300
        YZoomScale: 0.300
        MaxSwipeWidth: 233.581085
  Device 3: gpio-keys
    Generation: 4
    IsExternal: false
    Sources: 0x00000101
    KeyboardType: 1
    Keyboard Input Mapper:
      Parameters:
        AssociatedDisplayId: -1
        OrientationAware: false
      KeyboardType: 1
      Orientation: 0
      KeyDowns: 1 keys currently down
      MetaState: 0x0
      DownTime: 839534522000
  Configuration:
    ExcludedDeviceNames: []
    VirtualKeyQuietTime: 0.0ms
    PointerVelocityControlParameters: scale=1.000, lowThreshold=500.000, highThreshold=3000.000, acceleration=3.000
    WheelVelocityControlParameters: scale=1.000, lowThreshold=15.000, highThreshold=50.000, acceleration=4.000
    PointerGesture:
      Enabled: true
      QuietInterval: 100.0ms
      DragMinSwitchSpeed: 50.0px/s
      TapInterval: 150.0ms
      TapDragInterval: 300.0ms
      TapSlop: 20.0px
      MultitouchSettleInterval: 100.0ms
      MultitouchMinDistance: 15.0px
      SwipeTransitionAngleCosine: 0.3
      SwipeMaxWidthRatio: 0.2
      MovementSpeedRatio: 0.8
      ZoomSpeedRatio: 0.3

Input Dispatcher State:
  DispatchEnabled: 1
  DispatchFrozen: 0
  FocusedApplication: name='AppWindowToken{411195e8 token=Token{4116c558 ActivityRecord{40fbe1e0 com.android.launcher/com.android.launcher2.Launcher}}}', dispatchingTimeout=5000.000ms
  FocusedWindow: name='Window{411240b8 Keyguard paused=false}'
  TouchDown: false
  TouchSplit: false
  TouchDeviceId: -1
  TouchSource: 0x00000000
  TouchedWindows: <none>
  Windows:
    0: name='Window{41266a38 RecentsPanel paused=false}', paused=false, hasFocus=false, hasWallpaper=false, visible=false, canReceiveKeys=false, flags=0x00820102, type=0x000007de, layer=161000, frame=[0,0][800,480], scale=1.000000, touchableRegion=[0,0][800,480], inputFeatures=0x00000000, ownerPid=277, ownerUid=10005, dispatchingTimeout=5000.000ms
    1: name='Window{41267b90 StatusBar paused=false}', paused=false, hasFocus=false, hasWallpaper=false, visible=true, canReceiveKeys=false, flags=0x01800048, type=0x000007d0, layer=151000, frame=[0,0][800,25], scale=1.000000, touchableRegion=[0,0][800,25], inputFeatures=0x00000000, ownerPid=277, ownerUid=10005, dispatchingTimeout=5000.000ms
    2: name='Window{411240b8 Keyguard paused=false}', paused=false, hasFocus=true, hasWallpaper=false, visible=true, canReceiveKeys=true, flags=0x04120800, type=0x000007d4, layer=111000, frame=[0,25][800,480], scale=1.000000, touchableRegion=[0,25][800,480], inputFeatures=0x00000000, ownerPid=220, ownerUid=1000, dispatchingTimeout=5000.000ms
    3: name='Window{41287280 com.android.systemui.ImageWallpaper paused=false}', paused=false, hasFocus=false, hasWallpaper=false, visible=true, canReceiveKeys=false, flags=0x00000318, type=0x000007dd, layer=21005, frame=[0,0][960,800], scale=1.000000, touchableRegion=[0,0][960,800], inputFeatures=0x00000000, ownerPid=277, ownerUid=10005, dispatchingTimeout=5000.000ms
    4: name='Window{41233ba0 com.android.launcher/com.android.launcher2.Launcher paused=false}', paused=false, hasFocus=false, hasWallpaper=false, visible=true, canReceiveKeys=true, flags=0x01910100, type=0x00000001, layer=21000, frame=[0,0][800,480], scale=1.000000, touchableRegion=[0,0][800,480], inputFeatures=0x00000000, ownerPid=315, ownerUid=10022, dispatchingTimeout=5000.000ms
  MonitoringChannels: <none>
  InboundQueue: <empty>
  Connections:
    0: channelName='411240b8 Keyguard (server)', windowName='Window{411240b8 Keyguard paused=false}', status=NORMAL, monitor=false, inputPublisherBlocked=false
      OutboundQueue: <empty>
      WaitQueue: <empty>
    1: channelName='41266a38 RecentsPanel (server)', windowName='Window{41266a38 RecentsPanel paused=false}', status=NORMAL, monitor=false, inputPublisherBlocked=false
      OutboundQueue: <empty>
      WaitQueue: <empty>
    2: channelName='41267b90 StatusBar (server)', windowName='Window{41267b90 StatusBar paused=false}', status=NORMAL, monitor=false, inputPublisherBlocked=false
      OutboundQueue: <empty>
      WaitQueue: <empty>
    3: channelName='41287280 com.android.systemui.ImageWallpaper (server)', windowName='Window{41287280 com.android.systemui.ImageWallpaper paused=false}', status=NORMAL, monitor=false, inputPublisherBlocked=false
      OutboundQueue: <empty>
      WaitQueue: <empty>
    4: channelName='41233ba0 com.android.launcher/com.android.launcher2.Launcher (server)', windowName='Window{41233ba0 com.android.launcher/com.android.launcher2.Launcher paused=false}', status=NORMAL, monitor=false, inputPublisherBlocked=false
      OutboundQueue: <empty>
      WaitQueue: <empty>
  AppSwitch: not pending
  Configuration:
    KeyRepeatDelay: 50.0ms
    KeyRepeatTimeout: 500.0ms

ffxx68

unread,
Sep 21, 2012, 8:39:41 AM9/21/12
to android...@googlegroups.com
Hi cnet,

yes, that's what I've also done. Indeed looks like the kernel driver isn't the main problem, I think...

Here's what I've achieved so far. I've introduced the .idc file for the touch device, so it gets recognized as an actual "touch" screen, not as a "pointer" pad. Then I've set the "showTouches" to true in the InputReader.cpp code, so to force showing of the touch position.

I've posted a brief recording of results on YouTube:

http://www.youtube.com/watch?v=XqebuAw5Jws&feature=youtu.be

As you can see from video, the touch is properly received by the EventHub module, but somehow it's not dispatched to the window, which is the locker screen in this case...

Also, I've enabled debug logging into InputReader.cpp and EventHub.cpp, but I can see messages in the logcat only from the latter, which is another mystery to me...

On Thursday, September 20, 2012 11:52:55 AM UTC-7, cneth wrote:
You need to add a .idc file for each TouchScreen that defines it's characteristics: 

ffxx68

unread,
Sep 24, 2012, 7:19:02 AM9/24/12
to android...@googlegroups.com
Hi Weston,

thanks for suggesting those debug tools. Here's my output

$ adb shell su -- getevent -lp /dev/input/event2
add device 1: /dev/input/event2
  name:     "gt80x"
  events:
    ABS (0003): ABS_HAT0X             : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0
                ABS_HAT1X             : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0
                ABS_HAT2Y             : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0
                ABS_HAT3X             : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0
                ABS_MT_TOUCH_MAJOR    : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                ABS_MT_WIDTH_MAJOR    : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                ABS_MT_POSITION_X     : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0
                ABS_MT_POSITION_Y     : value 0, min 0, max 480, fuzz 0, flat 0, resolution 0
  input props:
    <not available

And here's while touching onto the locker icon:

$ adb shell su -- getevent -lt /dev/input/event2
[     471.347113] EV_ABS       ABS_MT_POSITION_X    000002ae           
[     471.347143] EV_ABS       ABS_MT_POSITION_Y    00000120           
[     471.347143] EV_ABS       ABS_MT_TOUCH_MAJOR   0000001c           
[     471.347174] EV_ABS       ABS_MT_WIDTH_MAJOR   0000001c           
[     471.347174] EV_SYN       SYN_MT_REPORT        00000000           
[     471.362357] EV_SYN       SYN_REPORT           00000000           
[     471.367784] EV_ABS       ABS_MT_POSITION_X    000002ae           
[     471.368058] EV_ABS       ABS_MT_POSITION_Y    00000120           
[     471.368271] EV_ABS       ABS_MT_TOUCH_MAJOR   00000022           
[     471.368485] EV_ABS       ABS_MT_WIDTH_MAJOR   00000022           
[     471.368698] EV_SYN       SYN_MT_REPORT        00000000           
[     471.386808] EV_SYN       SYN_REPORT           00000000           
[     471.394887] EV_ABS       ABS_MT_POSITION_X    000002ae           
[     471.394918] EV_ABS       ABS_MT_POSITION_Y    00000120           
[     471.394918] EV_ABS       ABS_MT_TOUCH_MAJOR   00000023           
[     471.394918] EV_ABS       ABS_MT_WIDTH_MAJOR   00000023           
[     471.394948] EV_SYN       SYN_MT_REPORT        00000000           
[     471.394979] EV_SYN       SYN_REPORT           00000000           
...

I don't see anything wrong here. Is this correct? Indeed, 'PRESSURE' is missing, but TOUCH_MAJOR should work as well. Indeed, as I said and shown on video, I can see the touch circle shown on screen and moving under my finger. Issue is that the locker window doesn't look like "receiving" those events... I'm puzzled.


On Friday, 21 September 2012 08:25:07 UTC-7, Weston Weems wrote:
Are you sure the driver is sending up the correct events? Fire up get event with:
adb shell su -- getevent -lt /dev/input/event1

make sure the commands that are comming in, are what your idc/keymap are expecting... more info on that here:

Weston

ffxx68

unread,
Sep 25, 2012, 6:38:36 AM9/25/12
to android...@googlegroups.com
Got it! After reviewing a bit Linux input protocol docs:

http://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt

I modified the driver and now I have the correct sequence of messages, that makes the events being correctly received and processed:

[     200.790375] EV_ABS       ABS_MT_POSITION_X    000002a6           
[     200.790436] EV_ABS       ABS_MT_POSITION_Y    000000fd           
[     200.790436] EV_ABS       ABS_MT_TOUCH_MAJOR   00000027           
[     200.790436] EV_ABS       ABS_MT_PRESSURE      00000027           
[     200.790436] EV_SYN       SYN_MT_REPORT        00000000           
[     200.810070] EV_SYN       SYN_REPORT           00000000        
... (moving touch)  
[     200.814704] EV_ABS       ABS_MT_POSITION_X    000002a6           
[     200.814734] EV_ABS       ABS_MT_POSITION_Y    000000fd           
[     200.814765] EV_ABS       ABS_MT_TOUCH_MAJOR   00000021           
[     200.814765] EV_ABS       ABS_MT_PRESSURE      00000021           
[     200.814765] EV_SYN       SYN_MT_REPORT        00000000           
[     200.831716] EV_SYN       SYN_REPORT           00000000     
... (touch released)     
[     200.837173] EV_SYN       SYN_MT_REPORT        00000000           
[     200.848149] EV_SYN       SYN_MT_REPORT        00000000           
[     200.848423] EV_SYN       SYN_REPORT           00000000   

sarika baby

unread,
Sep 28, 2012, 6:29:56 AM9/28/12
to wwe...@gmail.com, android...@googlegroups.com
Hello,
   Even i am also facing a similar issues, can you please tell me what protocol changes u have done in kernel driver or HAL.

Thanks
Abhiram

On Thu, Sep 27, 2012 at 12:00 AM, Weston Weems <wwe...@gmail.com> wrote:
Glad to hear... congrats!



--
SarikA

ffxx68

unread,
Sep 29, 2012, 2:27:09 AM9/29/12
to android...@googlegroups.com

vm

unread,
Apr 16, 2014, 4:05:22 PM4/16/14
to android...@googlegroups.com
On Saturday, September 29, 2012 12:27:09 AM UTC-6, ffxx68 wrote:
Hi sarika, have a look at the diffs here:
 https://github.com/Renesas-EMEV2/RenesasEV2-BSPGB-Kernel/commit/910c76b7bbd631ba8e4384b57cb1c201fbdd2f05

That link is no longer valid.  Do you have the diff posted anywhere else?  (Yeah I know, it's been quite a while since you've posted this)
Reply all
Reply to author
Forward
0 new messages