TP调试记录

1. USB tp触摸不准

项目中用到一款触摸屏显示是正常的就是TP不准,触摸的方向也是正确的就是触摸位置不准,屏幕中央触摸位置相对还好,越往边沿越不准,下面是当插上USB tp时抓到了logcat日志:

03-06 03:23:18.449   442   513 I InputReader: Device reconfigured: id=8, name='ILITEK ILITEK-TP', size 1280x2048, orientation 0, mode 1, display id 0
03-06 03:23:18.450   442   513 I InputReader: Device added: id=8, eventHubId=7, name='ILITEK ILITEK-TP', descriptor='f1b4838838e240568fcbdd50c0f63be308c623ef',sources=0x00001002
03-06 03:23:18.450   442   461 I Pointer : Device Added: Input Device 8: ILITEK ILITEK-TP
03-06 03:23:18.450   442   461 I Pointer :   Descriptor: f1b4838838e240568fcbdd50c0f63be308c623ef
03-06 03:23:18.450   442   461 I Pointer :   Generation: 31
03-06 03:23:18.450   442   461 I Pointer :   Location: external
03-06 03:23:18.450   442   461 I Pointer :   Keyboard Type: none
03-06 03:23:18.450   442   461 I Pointer :   Has Vibrator: false
03-06 03:23:18.450   442   461 I Pointer :   Has mic: false
03-06 03:23:18.450   442   461 I Pointer :   Sources: 0x1002 ( touchscreen )
03-06 03:23:18.450   442   461 I Pointer :     AXIS_X: source=0x1002 min=0.0 max=1279.0 flat=0.0 fuzz=0.0 resolution=4.1403723
03-06 03:23:18.450   442   461 I Pointer :     AXIS_Y: source=0x1002 min=-624.0 max=1423.0 flat=0.0 fuzz=0.0 resolution=11.749283
03-06 03:23:18.450   442   461 I Pointer :     AXIS_PRESSURE: source=0x1002 min=0.0 max=1.0 flat=0.0 fuzz=0.0 resolution=0.0
03-06 03:23:18.451   442   512 I configuration_changed: 8

从插入USB TP的日志上可以看到范围是1280x2048,但是实际上是1280x800

添加idc配置文件:

touch.deviceType = touchScreen
device.internal = 1
touch.orientationAware = 1

keyboard.layout = qwerty
keyboard.characterMap = qwerty
keyboard.orientationAware = 1
keyboard.builtIn = 1

cursor.mode = navigation
cursor.orientationAware = 1

命名Vendor_222a_Product_0001.idc,格式如下:

Vendor_(VID)_Product_(PID)

显示分辨率偏小,本身是1280x800,识别成了1280x720,所以去掉过滤分辨率文件resolution_white.xml恢复正常,也可以在resolution_white.xml中添加,如下

diff --git a/resolution_white.xml b/resolution_white.xml
index 846938a..a1a9f1c 100755
--- a/resolution_white.xml
+++ b/resolution_white.xml
@@ -416,4 +416,20 @@
                <flags>5</flags>
                <vic>102</vic>
        </resolution>
+               <resolution> <!-- 1280x800P60 -->
+               <clock>74250</clock>
+               <hdisplay>1280</vdisplay>
+               <hsync_start>1300</vsync_start>
+               <hsync_end>1304</vsync_end>
+               <htotal>1314</vtotal>
+               <hskew>0</hskew>
+               <vdisplay>800</hdisplay>
+               <vsync_start>848</hsync_start>
+               <vsync_end>880</hsync_end>
+               <vtotal>960</htotal>
+               <vscan>0</vscan>
+               <vrefresh>60</vrefresh>
+               <flags>5</flags>
+               <vic>108</vic>
+       </resolution>
 </resolutions>

2 触摸位置不准方向不对

commit b497de3bed4f12beaa51cb8c1a69214ca993d7e9
Author: k.li <k.li@vantron.com>
Date:   Wed Mar 29 21:09:14 2023 +0800

    exchange usb tp x_y position for 10inch(date:03.29)
    
    Change-Id: Iaccabc31347dbaa3bad1da24eb5898bfd153f3ac

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index c20945ed1dc1..c0672d5a7e56 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -52,6 +52,8 @@ MODULE_LICENSE("GPL");
 
 #include "hid-ids.h"
 
+#define SWAP_X_Y_POS 1
+
 /* quirks to control the device */
 #define MT_QUIRK_NOT_SEEN_MEANS_UP	BIT(0)
 #define MT_QUIRK_SLOT_IS_CONTACTID	BIT(1)
@@ -473,13 +475,17 @@ static void mt_feature_mapping(struct hid_device *hdev,
 		break;
 	}
 }
-
+/* Swap x and y. 20201116 */
+#if SWAP_X_Y_POS
+int logical_maximum;
+#endif
 static void set_abs(struct input_dev *input, unsigned int code,
 		struct hid_field *field, int snratio)
 {
 	int fmin = field->logical_minimum;
 	int fmax = field->logical_maximum;
 	int fuzz = snratio ? (fmax - fmin) / snratio : 0;
+	logical_maximum = fmax;
 	input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
 	input_abs_set_res(input, code, hidinput_calc_abs_res(field, code));
 }
@@ -956,7 +962,20 @@ static int mt_touch_event(struct hid_device *hid, struct hid_field *field,
 
 	return 1;
 }
+#if SWAP_X_Y_POS
+static void swap_x_y(struct mt_usages *slot)
+{
+	 int swap = *slot->x;
+
+	//printk("vantron---- slot->x:%d   slot->y:%d  logical_maximum :%d \r\n",*slot->x,*slot->y,logical_maximum);
+	 *slot->x = *slot->y;
+	 *slot->y = logical_maximum - swap;
 
+	*slot->x = 9600 - *slot->x;
+	*slot->y = 9600 - *slot->y;
+	return;
+}
+#endif
 static int mt_process_slot(struct mt_device *td, struct input_dev *input,
 			    struct mt_application *app,
 			    struct mt_usages *slot)
@@ -1067,7 +1086,9 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,
 			major = major >> 1;
 			minor = minor >> 1;
 		}
-
+#if SWAP_X_Y_POS
+		swap_x_y(slot);
+#endif
 		input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x);
 		input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y);
 		input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx);

主要添加了swap_x_y函数,这里上报的位置并不是屏幕物理尺寸的实际位置,需要转换,同getevent -p命令可以看到触摸屏幕的注册信息,在set_abs函数中有相应的注册信息

你可能感兴趣的:(android驱动,android,git,驱动开发)