触摸TP,gt9xx调试分享

板子:rk3568
平台:android11

1.添加驱动

驱动文件列表:

-rw-rw-r-- 1 vtlk vtlk  17979 1020 14:04  goodix_tool.c
-rw-rw-r-- 1 vtlk vtlk    965 711 16:52 'GT9110P(2020)V71_Config_20201028_170326.cfg'
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  GT9110P_Config_20160217_1526_2048_97.cfg
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  GT9271_Config_20170526.cfg
-rw-rw-r-- 1 vtlk vtlk  87561 1020 15:30  gt9xx.c
-rw-rw-r-- 1 vtlk vtlk   1853 711 16:52  gt9xx_cfg.h
-rw-rw-r-- 1 vtlk vtlk 224220 1020 11:38  gt9xx_firmware.h
-rw-rw-r-- 1 vtlk vtlk  14656 1020 15:13  gt9xx.h
-rw-rw-r-- 1 vtlk vtlk 106042 1020 11:38  gt9xx_update.c
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  HLS-0102-1398V1-1060-GT911_Config_20201204_V66.cfg
-rw-rw-r-- 1 vtlk vtlk    152 1020 15:45  Makefile
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  WGJ10162B_GT9271_1060_Config_20140821_1341110X42.cfg
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  WGJ10162_GT9271_Config_20140820_182456.cfg
-rw-rw-r-- 1 vtlk vtlk   1366 711 16:52  WGJ10187_GT910_Config_20140623_104014_0X41.cfg
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  WGJ10187_GT9271_Config_20140623_104014_0X41.cfg
-rwxrwxr-x 1 vtlk vtlk    929 711 16:52  WGJ89006B_GT911_Config_20140625_085816_0X43.cfg
-rw-rw-r-- 1 vtlk vtlk    929 711 16:52  WGJ89006B_GT9271_Config_20140625_085816_0X41.cfg

首先是设备树配置:

&i2c1 {
	status = "okay";

	gt928:gt928@14 {
		compatible = "goodix,gt9xx";//"goodix,gt928";
		status = "okay";
		reg = <0x14>;
		pinctrl-names = "default";
		pinctrl-0 = <&gt928_reset_pin &gt928_int_pin>;
		interrupt-parent = <&gpio0>;
		interrupts = <RK_PB5 IRQ_TYPE_EDGE_FALLING>;
		touch-gpio = <&gpio0 RK_PB5 0>;
		reset-gpio = <&gpio0 RK_PB6 0>;
		max-x = <800>;
		max-y = <1280>;
		tp-size = <928>;
	};
};

这里的touch-gpio,reset-gpio,max-x,max-y,tp-size是根据probe代码里获取设备树属性来确定的,drivers/input/touchscreen/gt9xx/gt9xx.c中probe部分代码如下:

static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    s32 ret = -1;
    struct goodix_ts_data *ts;
    u16 version_info;
    
    struct device_node *np = client->dev.of_node;
    enum of_gpio_flags rst_flags, pwr_flags;
    u32 val;
	
	...
	
    if (of_property_read_u32(np, "tp-size", &val)) {
    	dev_err(&client->dev, "no max-x defined\n");
    	return -EINVAL;
    }

	ts->tp_regulator = devm_regulator_get(&client->dev, "tp");
	if (IS_ERR(ts->tp_regulator)) {
		dev_err(&client->dev, "failed to get regulator, %ld\n",
			PTR_ERR(ts->tp_regulator));
		return PTR_ERR(ts->tp_regulator);
	}

	ret = regulator_enable(ts->tp_regulator);
	if (ret < 0)
		GTP_ERROR("failed to enable tp regulator\n");
	msleep(20);

    ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, (enum of_gpio_flags *)(&ts->irq_flags));
    ts->rst_pin = of_get_named_gpio_flags(np, "reset-gpio", 0, &rst_flags);
    ts->pwr_pin = of_get_named_gpio_flags(np, "power-gpio", 0, &pwr_flags);
    //ts->tp_select_pin = of_get_named_gpio_flags(np, "tp-select-gpio", 0, &tp_select_flags);
    if (of_property_read_u32(np, "max-x", &val)) {
    	dev_err(&client->dev, "no max-x defined\n");
    	return -EINVAL;
    }
    //ts->abs_x_max = val;
    if (of_property_read_u32(np, "max-y", &val)) {
    	dev_err(&client->dev, "no max-y defined\n");
    	return -EINVAL;
    }
    //ts->abs_y_max = val;
    if (of_property_read_u32(np, "configfile-num", &val)) {
	    ts->cfg_file_num = 0;
    } else {
	    ts->cfg_file_num = val;
    }
    ts->pendown =PEN_RELEASE;
    ts->client = client;
    
   ...
   
    if (of_property_read_bool(np, "wakeup-source"))
    {
        device_init_wakeup(&client->dev, 1);
        enable_irq_wake(ts->irq);
    }
    
	...
}

这里的max-x,max-y是屏幕尺寸对应触摸最大范围;touch-gpio,reset-gpio,分别表示对应的中断检测脚和复位脚;tp-size对应的是正反转的,我这里是直接在gt9xx.c修改全局变量所以tp-size根据需要来配置就可以了;
其次就是在deconfig文件中添加编译

CONFIG_TOUCHSCREEN_GT9XX=y

编译好后download到板子上,成功后的log:

[    1.129428] goodix_ts_probe() start
[    1.129483] Goodix-TS 1-0014: 1-0014 supply tp not found, using dummy regulator
[    1.129565] Goodix-TS 1-0014: Linked as a consumer to regulator.0
[    1.320703] input: goodix-ts as /devices/platform/fe5a0000.i2c/i2c-1/1-0014/input/input1

被注册成输入设备1了
或者使用命令 adb shell getevent 打开输入检测,触摸屏幕会在终端上打印触摸坐标信息,如:

vtlk:~$adb shell getevent
add device 1: /dev/input/event1
  name:     "goodix-ts"
add device 2: /dev/input/event3
  name:     "gpio-keys"
add device 3: /dev/input/event0
  name:     "rk805 pwrkey"
add device 4: /dev/input/event2
  name:     "adc-keys"
add device 5: /dev/input/event4
  name:     "rk-headset"
/dev/input/event1: 0001 014a 00000001
/dev/input/event1: 0003 0035 000002e8
/dev/input/event1: 0003 0036 0000021f
/dev/input/event1: 0003 0030 00000020
/dev/input/event1: 0003 0032 00000020
/dev/input/event1: 0003 0039 00000000
/dev/input/event1: 0000 0002 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0003 0035 000002e8

2.问题

对应的x和y轴的相反,可以修改drivers/input/touchscreen/gt9xx/gt9xx.c中的全局变量:

static u8 gtp_change_x2y = FALSE;

如果只是x左右相反或折y方向的上下相反可以修改如下量个变量

static u8 gtp_x_reverse = TRUE;
static u8 gtp_y_reverse = TRUE;

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