Hi all
We are using ads7846 on our custom mx51 board(without battery). What I modified is :
1) make sure the touchscreen name is ads7846, and change TARGET_TS_DEVICE := "mxc_ts" to TARGET_TS_DEVICE := "ads7846" in the file device/fsl/imx5x/BoardConfigCommon.mk
2) with getevent, I got :
# getevent
add device 1: /dev/input/event1
name: "mxc_power_key"
add device 2: /dev/input/event0
name: "mxckpd"
could not get driver version for /dev/input/mice, Not a typewriter
add device 3: /dev/input/event2
name: "ads7846"
could not get driver version for /dev/input/mouse0, Not a typewriter
/dev/input/event2: 0001 014a 000calib xc = 392, x = 6177, yc = 300, y = 6589
00001
/dev/input/event2: 0003 0000 00000188
/dev/input/event2: 0003 0001 0000012c
/dev/input/event2: 0003 0018 00003a2d
/dev/input/event2: 0000 0000 00000000
calib xc = 379, x = 6241, yc = 297, y = 6572
/dev/input/event2: 0003 0000 0000017b
/dev/input/event2: 0003 0001 00000129
/dev/input/event2: 0003 0018 00003a3c
/dev/input/event2: 0000 0000 00000000
calib xc = 388, x = 6198, yc = 299, y = 6583
/dev/input/event2: 0003 0000 00000184
/dev/input/event2: 0003 0001 0000012b
/dev/input/event2: 0003 0018 00003a32
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0001 014a 00000000
/dev/input/event2: 0003 0018 00000000
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0001 014a 000calib xc = 397, x = 6161, yc = 385, y = 7243
00001
/dev/input/event2: 0003 0000 0000018d
/dev/input/event2: 0003 0001 00000181
/dev/input/event2: 0003 0018 00003a32
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0001 014a 00000000
/dev/input/event2: 0003 0018 00000000
/dev/input/event2: 0000 0000 00000000
3) I calibrated the touch screen, and got the points that seem right.
I can draw lines on the screen when using tslib under Linux.
I cannot get the right action under android(there seems to be some actions, but not correct). here is part of the logcat information.
V/EventHub( 1969): /dev/input/evcalib xc = 381, x = 6233, yc = 338, y = 6878
ent2 got: t0=37, t1=644371, type=1, code=330, v=1
V/EventHub( 1969): iev.code=330 keyCode=0 flags=0x00000000 err=-19
D/InputReader( 1969): Input event: device=0x10002 type=0x1 scancode=330 keycode=0 value=1
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=651758, type=3, code=0, v=381
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=0 keycode=0 value=381
V/EventHub( 1969calib xc = 380, x = 6237, yc = 343, y = 6921
): /dev/input/event2 got: t0=37, t1=651951, type=3, code=1, v=338
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=1 keycode=1 value=338
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=652158, type=3, code=24, v=14910
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=24 keycode=24 value=14910
V/EventHub( 1calib xc = 378, x = 6249, yc = 344, y = 6928
969): /dev/input/event2 got: t0=37, t1=652369, type=0, code=0, v=0
D/InputReader( 1969): Input event: device=0x10002 type=0x0 scancode=0 keycode=0 value=0clicked
I/InputReader( 1969): Device reconfigured: id=0x10002, name=ads7846, display size is now 800x480
I/InputManager-Callbacks( 1969): No virtual keys found for device ads7846.
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=690437, type=3, code=0, v=380
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=0 keycode=0 value=380
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=690817, type=3, code=1, v=343
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=1 keycode=1 value=343
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=691053, type=3, code=24, v=14923
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=24 keycode=24 value=14923
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=691275, type=0, code=0, v=0
D/InputReader( 1969): Input event: device=0x10002 type=0x0 scancode=0 keycode=0 value=0
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=724994, type=3, code=0, v=378
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=0 keycode=0 value=378
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=725253, type=3, code=1, v=344
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=1 keycode=1 value=344
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=725468, type=3, code=24, v=14927
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=24 keycode=24 value=14927
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=725681, type=0, code=0, v=0
D/InputReader( 1969): Input event: device=0x10002 type=0x0 scancode=0 keycode=0 value=0
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=805270, type=1, code=330, v=0
V/EventHub( 1969): iev.code=330 keyCode=0 flags=0x00000000 err=-19
D/InputReader( 1969): Input event: device=0x10002 type=0x1 scancode=330 keycode=0 value=0
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=805283, type=3, code=24, v=0
D/InputReader( 1969): Input event: device=0x10002 type=0x3 scancode=24 keycode=24 value=0
V/EventHub( 1969): /dev/input/event2 got: t0=37, t1=805291, type=0, code=0, v=0
D/InputReader( 1969): Input event: device=0x10002 type=0x0 scancode=0 keycode=0 value=0
Can anyone help me on this?
Thanks
已解决! 转到解答。
I solved this.
In the file frameworks/base/libs/ui/InputReader.cpp, I made these changes:
void TouchInputMapper::dispatchTouch(nsecs_t when, uint32_t policyFlags,
TouchData* touch, BitSet32 idBits, uint32_t changedId, uint32_t pointerCount,
int32_t motionEventAction)
LOGD("in.x is %d, in.y is %d\n", in.x, in.y);
// X and Y
float x = float(in.x - mLocked.xOrigin - mRawAxes.x.getRange()*a) * mLocked.xScale / (1-2*a);
float y = float(in.y - mLocked.yOrigin- mRawAxes.y.getRange()*a) * mLocked.yScale / (1-2*a);
LOGD("f.x is %f, f.y is %f\n", x, y);
I found that the mLocked.xScale is 4095, which is supposed to be 800( The LCD is 800x480).
I modified the ads7846 related file in the kernel source code.
Make sure that the x_max is 800 and the y_max is 480 in the file arch/arm/mach-mx5/mx51_babbage.c
static struct ads7846_platform_data ads_info = {
#if 1
.x_max = 800,
.y_max = 480,
.x_plate_ohms = 180,
.pressure_max = 15000,
.debounce_max = 5,
.debounce_tol = 4,
.debounce_rep = 1,
.get_pendown_state = ads7843_pendown_state,
.keep_vref_on = 1,
.settle_delay_usecs = 150,
.wakeup = true,
I solved this.
In the file frameworks/base/libs/ui/InputReader.cpp, I made these changes:
void TouchInputMapper::dispatchTouch(nsecs_t when, uint32_t policyFlags,
TouchData* touch, BitSet32 idBits, uint32_t changedId, uint32_t pointerCount,
int32_t motionEventAction)
LOGD("in.x is %d, in.y is %d\n", in.x, in.y);
// X and Y
float x = float(in.x - mLocked.xOrigin - mRawAxes.x.getRange()*a) * mLocked.xScale / (1-2*a);
float y = float(in.y - mLocked.yOrigin- mRawAxes.y.getRange()*a) * mLocked.yScale / (1-2*a);
LOGD("f.x is %f, f.y is %f\n", x, y);
I found that the mLocked.xScale is 4095, which is supposed to be 800( The LCD is 800x480).
I modified the ads7846 related file in the kernel source code.
Make sure that the x_max is 800 and the y_max is 480 in the file arch/arm/mach-mx5/mx51_babbage.c
static struct ads7846_platform_data ads_info = {
#if 1
.x_max = 800,
.y_max = 480,
.x_plate_ohms = 180,
.pressure_max = 15000,
.debounce_max = 5,
.debounce_tol = 4,
.debounce_rep = 1,
.get_pendown_state = ads7843_pendown_state,
.keep_vref_on = 1,
.settle_delay_usecs = 150,
.wakeup = true,