CPU:RK3399git
系統:Android 7.1數組
觸摸屏:1024x768 8inch服務器
觸摸IC:GT9271微服務
基於RK3399,從瑞芯微服務器更新到最新的 Android 7.1 代碼中,瑞芯微已經將匯頂觸摸屏的代碼作了一些改動,與匯頂官方提供的不一致。spa
初步來看,瑞芯微更改後的代碼,爲開發者提供了更多的便利。調試
好比:x/y座標反了,x、y座標鏡像了,這些問題開發者就能夠解決,不用再聯繫 FAE 修改配置文件。code
一、將 gt9xx 文件夾添加到編譯中,修改 rockchip_defconfig 文件,或者在 kernel 中執行 make menuconfig 指令均可以blog
新代碼中通常都默認支持了,不須要額外手動打開ip
CONFIG_INPUT_TOUCHSCREEN=y CONFIG_TOUCHSCREEN_GT9XX=y
二、在 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>; }; };
三、添加觸摸屏的配置信息參數
新代碼的 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_ */
四、在源碼中根據 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