Skip to content

Single Touchscreen Driver Configuration

In the driver configuration process of this chapter, GT9XX is used as the operation example.

Driver Porting

Port the driver provided by the vendor into the SDK directory, modify and add it to the compilation files. Copy the driver files to the touch driver folder: $(SDK_DIR)\kernel-5.10\drivers\input\touchscreen.

Modify kconfig: Add the following

config TOUCHSCREEN_GT9XX
    tristate "GT9XX touchscreens support"

Modify Makefile: Add the following

obj-$(CONFIG_TOUCHSCREEN_GT9XX)     += gt9xx/

Add CONFIG_TOUCHSCREEN_GT9XX=y to the kernel configuration. The kernel configuration file is, for example, arch/arm64/configs/rockchip_defconfig. For defconfig files of different versions, please check the corresponding version file in the git history.

Kernel Device Tree Configuration

i2c_gt9xx configuration:

&i2c1 {
    status = "okay";
    gt9xx:gt9xx@5d {
        compatible = "goodix,gt9xx";
        status = "okay";
        reg = <0x5d>;

        gtp_resolution_x = <1024>;
        gtp_resolution_y = <600>;
        gtp_int_tarigger = <1>;
        gtp_change_x2y = <0>;
        gtp_overturn_x = <0>;
        gtp_overturn_y = <0>;
        gtp_send_cfg = <1>;
        gtp_touch_wakeup = <1>;
        goodix_rst_gpio = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>;
        goodix_irq_gpio = <&gpio3 RK_PA3 IRQ_TYPE_LEVEL_LOW>;
        pinctrl-names = "default";
        pinctrl-0 = <&touch3_gpio>;

        goodix,cfg-group0 = [
            4B 00 04 58 02 01 0D 00 01 08
            28 05 50 32 03 05 00 00 00 00
            00 00 00 00 00 00 00 8B 2A 0C
            17 15 31 0D 00 00 02 BA 03 2D
            00 00 00 00 00 03 00 00 00 00
            00 0F 41 94 C5 02 07 00 00 04
            9B 11 00 77 17 00 5C 1F 00 48
            2A 00 3B 38 00 3B 00 00 00 00
            00 00 00 00 00 00 00 00 00 00
            00 00 00 00 00 00 00 00 00 00
            00 00 00 00 00 00 00 00 00 00
            00 00 02 04 06 08 0A 0C 0E 10
            12 14 16 18 FF FF 00 00 00 00
            00 00 00 00 00 00 00 00 00 00
            00 00 00 02 04 06 08 0A 0C 0F
            10 12 13 16 18 1C 1D 1E 1F 20
            21 22 24 FF FF FF FF FF 00 00
            00 00 00 00 00 00 00 00 00 00
            00 00 00 00 B6 01
        ];
    };
};

Rotating Touch Orientation

Adjust the touchscreen orientation based on the device tree. The following orientations are only applicable to the GT9XX driver:

0 degrees (default)

gt9xx:gt9xx@5d {
    gtp_change_x2y = <0>;       
    gtp_overturn_x = <0>;
    gtp_overturn_y = <0>;
};

90 degrees

gt9xx:gt9xx@5d {
    gtp_change_x2y = <1>;
    gtp_overturn_x = <1>;
    gtp_overturn_y = <0>;
};

180 degrees

gt9xx:gt9xx@5d {
    gtp_change_x2y = <0>;
    gtp_overturn_x = <0>;
    gtp_overturn_y = <1>;
};

270 degrees

gt9xx:gt9xx@5d {
    gtp_change_x2y = <0>;
    gtp_overturn_x = <1>;
    gtp_overturn_y = <0>;
};