[RK3399] 匯頂gt9xx觸摸屏在RK原始代碼調試


CPU:RK3399

系統:Android 7.1

觸摸屏:1024x768   8inch

觸摸IC:GT9271

 

基於RK3399,從瑞芯微服務器更新到最新的 Android 7.1 代碼中,瑞芯微已經將匯頂觸摸屏的代碼做了一些改動,與匯頂官方提供的不一致。

初步來看,瑞芯微更改后的代碼,為開發者提供了更多的便利。

比如:x/y坐標反了,x、y坐標鏡像了,這些問題開發者就可以解決,不用再聯系 FAE 修改配置文件。

 

1、將 gt9xx 文件夾添加到編譯中,修改 rockchip_defconfig 文件,或者在 kernel 中執行 make menuconfig 指令都可以

  新代碼中一般都默認支持了,不需要額外手動打開

CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_GT9XX=y

 

2、在 dts 文件中根據硬件原理圖修改觸屏參數

"tp-size” 這個參數表面看是 tp 的尺寸,實際好像是可以隨意定義,在代碼中只是通過這個參數來選擇配置信息和觸摸調整。

此時我定義為 ic 的型號

&i2c4 {
    status = "okay";
    i2c-scl-rising-time-ns = <150>;
    i2c-scl-falling-time-ns = <30>;
    clock-frequency = <400000>;

    gt9xx: gt9xx@14 {
        compatible = "goodix,gt9xx";
        // tp ic設備地址
        reg = <0x14>;
        // tp 中斷腳和復位腳
        touch-gpio = <&gpio1 6 IRQ_TYPE_LEVEL_LOW>;
        reset-gpio = <&gpio1 4 GPIO_ACTIVE_HIGH>;
        // tp 分辨率
        max-x = <1024>;
        max-y = <768>;
        // tp 尺寸
        tp-size = <927>;
        // tp 電壓
        tp-supply = <&vcc3v0_tp>;
    };
};

 

3、添加觸摸屏的配置信息參數

新代碼的 gt9xx.cfg.h 中按照 tp 的尺寸定義了一些數組,數組中將配置文件包含進來即可,不用再將參數拷貝出來,放到指定數組中

如果有尺寸和分辨率合適的就可以直接用,或者只修改數組中包含的配置文件即可

目前調試的 tp 沒有合適的數組,現在就開始按照規則創建配置信息數組

FAE 提供的配置文件 GT9271_Config_20190827.cfg 也需要拷貝到當前目錄,文件名自己隨意定義

diff --git a/kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h b/kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
index c667948..2d81563 100644
--- a/kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
+++ b/kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
@@ -53,4 +53,9 @@ u8 gtp_dat_7[] = {
        #include "WGJ10187_GT910_Config_20140623_104014_0X41.cfg"
 };
 
+u8 gtp_dat_8[] = {
+       /* <1024, 768> 8.0 */
+       #include "GT9271_Config_20190827.cfg"
+};
+
 #endif /* _GOODIX_GT9XX_CFG_H_ */

 

 4、在源碼中根據 tp-size 設置 tp 方向是否需要鏡像、切換,還有需要使用的配置參數

如果 bgt927 設置為 TRUE,其他的 bgtxxx 都要設置 FALSE

開始調試時,下面三個參數都設置為 FALSE,然后根據 bgt927 選擇配置參數,編譯燒錄后根據實際現象再調整下面三個參數

gtp_change-x2y:x、y交換方向

gtp_x_reverse:x 方向坐標鏡像

gtp_y_reverse:y 方向左邊鏡像

diff --git a/kernel/drivers/input/touchscreen/gt9xx/gt9xx.c b/kernel/drivers/input/touchscreen/gt9xx/gt9xx.c
index 6db7e39..f23c4af 100644
--- a/kernel/drivers/input/touchscreen/gt9xx/gt9xx.c
+++ b/kernel/drivers/input/touchscreen/gt9xx/gt9xx.c
@@ -60,6 +60,7 @@ static u8 m89or101 = TRUE;
 static u8 bgt911 = FALSE;
 static u8 bgt970 = FALSE;
 static u8 bgt910 = FALSE;
+static u8 bgt927 = FALSE;
 static u8 gtp_change_x2y = TRUE;
 static u8 gtp_x_reverse = FALSE;
 static u8 gtp_y_reverse = TRUE;
@@ -1453,6 +1454,11 @@ static s32 gtp_init_panel(struct goodix_ts_data *ts)
                cfg_info_len[0] = CFG_GROUP_LEN(gtp_dat_7);
        }
 
+       if (bgt927) {
+               send_cfg_buf[0] = gtp_dat_8;
+               cfg_info_len[0] = CFG_GROUP_LEN(gtp_dat_8);
+       }
+
     GTP_DEBUG_FUNC();
     GTP_DEBUG("Config Groups\' Lengths: %d, %d, %d, %d, %d, %d", 
         cfg_info_len[0], cfg_info_len[1], cfg_info_len[2], cfg_info_len[3],
@@ -2657,6 +2663,12 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
                gtp_change_x2y = TRUE;
                gtp_x_reverse = FALSE;
                gtp_y_reverse = TRUE;
+       } else if (val == 927) {
+               m89or101 = FALSE;
+               bgt927 = TRUE;
+               gtp_change_x2y = TRUE;
+               gtp_x_reverse = TRUE;
+               gtp_y_reverse = FALSE;
        }
 
        ts->tp_regulator = devm_regulator_get(&client->dev, "tp");

 

這是匯頂官方提供的標准代碼,有需要的可以自己下載移植

鏈接:https://pan.baidu.com/s/1aBFIO0L0Edwlplv1T0nm6A
提取碼:0uj3


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM