泰山派6寸触摸屏适配笔记

前言

之前在立创开源广场看到了个6寸的触摸屏,感觉这玩意比3.1寸大,又比10寸的便携,搞个小摆件还是不错的。由于自己用的内核是5.10.160+ubuntu22,设备树和驱动直接拷过来编译有错误,特地折腾一下。

设备树修改

tspi-rk3566-dsi-v10.dtsi

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/ {
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm5 0 25000 0>;
brightness-levels = <
0 20 20 20 20 20 20 20
21 21 21 21 21 21 21 21
22 22 22 22 22 22 22 22
23 23 23 23 23 23 23 23
24 24 24 24 24 24 24 24
25 25 25 25 25 25 25 25
26 26 26 26 26 26 26 26
27 27 27 27 27 27 27 27
28 28 28 28 28 28 28 28
29 29 29 29 29 29 29 29
30 30 30 30 30 30 30 30
31 31 31 31 31 31 31 31
32 32 32 32 32 32 32 32
33 33 33 33 33 33 33 33
34 34 34 34 34 34 34 34
35 35 35 35 35 35 35 35
36 36 36 36 36 36 36 36
37 37 37 37 37 37 37 37
38 38 38 38 38 38 38 38
39 39 39 39 39 39 39 39
40 40 40 40 40 40 40 40
41 41 41 41 41 41 41 41
42 42 42 42 42 42 42 42
43 43 43 43 43 43 43 43
44 44 44 44 44 44 44 44
45 45 45 45 45 45 45 45
46 46 46 46 46 46 46 46
47 47 47 47 47 47 47 47
48 48 48 48 48 48 48 48
49 49 49 49 49 49 49 49
50 50 50 50 50 50 50 50
51 51 51 51 51 51 51 51
256
>;
default-brightness-level = <192>;
};
};

&pwm5 {
status = "okay";
};

&i2c1 {
status = "okay";
ts@5d {
pinctrl-0 = <&touch_gpio>;
compatible = "goodix,gt9xx";
reg = <0x5d>;
tp-size = <911>;
max-x = <720>;
max-y = <1280>;
touch-gpio = <&gpio1 RK_PA0 IRQ_TYPE_LEVEL_LOW>;
reset-gpio = <&gpio1 RK_PA1 GPIO_ACTIVE_HIGH>;
};
};

&pinctrl {
dsi1 {
dsi1_rst_gpio: dsi1-rst-gpio {
rockchip,pins = <3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
};
touch_gpio: touch-gpio {
rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
};
};
};

/*
* video_phy1 needs to be enabled
* when dsi1 is enabled
*/
&dsi1 {
status = "okay";
};

&dsi1_in_vp0 {
status = "okay";
};

&dsi1_in_vp1 {
status = "disabled";
};

&video_phy1 {
status = "okay";
};

&route_dsi1 {
status = "okay";//wucaicheng mipi okay
connect = <&vp0_out_dsi1>;
};

// STL6.0-1-2-A
&dsi1 {
status = "okay";
rockchip,lane-rate = <580>; //(720+8+8+16)*(1280+8+8+16)*60*3*8/3,+100mhz
dsi1_panel: panel@0 {
status = "okay";
compatible = "simple-panel-dsi";
reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&dsi1_rst_gpio>;
reg = <0>;
backlight = <&backlight>;
reset-delay-ms = <200>;
enable-delay-ms = <100>;
prepare-delay-ms = <20>;
unprepare-delay-ms = <20>;
disable-delay-ms = <20>;
init-delay-ms = <120>;
dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
dsi,format = <MIPI_DSI_FMT_RGB888>;
dsi,lanes = <3>;
/*
width-mm = <74>;
height-mm = <132>;*/
panel-init-sequence = [
// init code
// Set EXTC
39 00 04 B9 FF 83 94
// Set MIPI
39 00 03 BA 72 83
// Set Power HX5186 Mode
39 00 10 B1 6C 15 15 24 E4 11 F1 80 E4 97 23 80 C0 D2 58
// Set Display
39 00 0C B2 00 64 10 07 22 1C 08 08 1C 4D 00
// Set CYC
39 00 0D B4 00 FF 03 5A 03 5A 03 5A 01 6A 30 6A
// Set VDC
15 00 02 BC 07
// Set Power ption HX5186 Mode
39 00 04 BF 41 0E 01
// Set D3
39 00 1F D3 00 06 00 40 07 08 00 32 10 07 00 07 54 15 0F 05 04 02 12 10 05 07 33 33 0B 0B 37 10 07 07
// Set GIP,Forward
39 00 2D D5 04 05 06 07 00 01 02 03 20 21 22 23 18 18 18 18 18 18 18 18 19 19 18 18 18 18 1B 1B 1A 1A 18 18 18 18 18 18 18 18 18 18 18 18 18 18
// Set D6,Backward
39 00 2D D6 03 02 01 00 07 06 05 04 23 22 21 20 18 18 18 18 18 18 58 58 18 18 19 19 18 18 1B 1B 1A 1A 18 18 18 18 18 18 18 18 18 18 18 18 18 18
// Set Panel
15 00 02 CC 09 // 08: invert RGB
// Set VCOM
39 00 03 B6 51 51
// Set Gamma
39 00 2B E0 00 10 16 2D 33 3F 23 3E 07 0B 0D 17 0E 12 14 12 13 06 11 13 18 00 0F 16 2E 33 3F 23 3D 07 0B 0D 18 0F 12 14 12 14 07 11 12 17
// Set C0
39 00 03 C0 30 14
// Set TCON ption
39 00 05 C7 00 C0 40 C0
// Set SAP_L ption
15 00 02 DF 87
// Set SETOFFSET
15 00 02 D2 66
//
15 78 02 11 00
15 28 02 29 00
];

panel-exit-sequence = [
//05 00 01 28
//05 00 01 10
];

disp_timings1: display-timings {
native-mode = <&dsi1_timing0>;
dsi1_timing0: timing0 {
clock-frequency = <59197440>;// (720+8+8+16)*(1280+8+8+16)*60

hactive = <720>;
hfront-porch = <8>;
hback-porch = <8>;
hsync-len = <16>;

vactive = <1280>;
vfront-porch = <8>;
vback-porch = <8>;
vsync-len = <16>;

hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <0>;

swap-rb = <0>;
swap-rg = <0>;
swap-gb = <0>;
};
};

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
panel_in_dsi1: endpoint {
remote-endpoint = <&dsi1_out_panel>;
};
};
};
};

ports {
#address-cells = <1>;
#size-cells = <0>;

port@1 {
reg = <1>;
dsi1_out_panel: endpoint {
remote-endpoint = <&panel_in_dsi1>;
};
};
};

};

修改完设备树刷入内核就可以点屏了

折腾触摸

一开始在dmesg中看到goodix-ts驱动已加载的报错有点纳闷,后来看了一下内核的config,需要取消编译其他goodix的触屏驱动,只留下GT9XX

1
2
3
CONFIG_TOUCHSCREEN_GOODIX=n
CONFIG_TOUCHSCREEN_GT1X=n
CONFIG_TOUCHSCREEN_GT9XX=y

修改驱动,swap xy与翻转xy
修改gtp_touch_down函数
gt9xx.c

1
2
3
4
5
6
7
if (TRUE) {
if (gtp_x_reverse)
x = ts->abs_x_max - x;

if (gtp_y_reverse)
y = ts->abs_y_max - y;
}

初始化序列修改
gt9xx_cfg.h

1
2
3
4
5
6
/* CFG for GT911 */
u8 gtp_dat_gt11[] = {
/* <1200, 1920>*/
/*#include "WGJ89006B_GT911_Config_20140625_085816_0X43.cfg"*/
#include "6inch.cfg"
};

6inch.cfg

1
2
3
4
5
6
7
8
9
10
11
12
13
0x43, 0x00, 0x05, 0xD0, 0x02, 0x0A, 0x0D, 0x20, 0x01, 0x08, 0x28, 0x08, 0x50, 0x32, 0x03, 0x05,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x2C, 0x0E, 0x3C, 0x3E,
0x0C, 0x08, 0x00, 0x00, 0x00, 0x41, 0x03, 0x1D, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x33, 0x5A, 0x94, 0xC5, 0x02, 0x08, 0x00, 0x00, 0x04, 0xA0, 0x36, 0x00, 0x8B,
0x3C, 0x00, 0x7C, 0x43, 0x00, 0x6B, 0x4C, 0x00, 0x5F, 0x55, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0F, 0x10, 0x12, 0x13, 0x14, 0x16, 0x18, 0x1C, 0x1D,
0x1E, 0x1F, 0x20, 0x21, 0x22, 0x24, 0x26, 0x28, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x01

记录一下wayland libinput如何调试旋转触摸

安装 libinput-tools

1
apt install libinput-tools

查看输入debug信息

1
libinput debug-events

旋转触摸输入
默认

1
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0"' > /etc/udev/rules.d/libinput.rules

y轴反向

1
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 -1 1"' > /etc/udev/rules.d/libinput.rules

x轴反向

1
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 1 0"' > /etc/udev/rules.d/libinput.rules

x、y反向

1
echo 'ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1"' > /etc/udev/rules.d/libinput.rules

效果图

效果图

作者

ZhongHuihong

发布于

2024-05-26

更新于

2024-05-26

许可协议