android 双触摸屏(touchscreen)实现--kernel driver

背景

本文主要实现一个Android系统,调试两个相同的TP设备,使用同一个TP的驱动。

最终实现结果,两个TP都可以控制Android,正常报点。

 

实现过程:

硬件连接介绍:

 

软件实现:

在dtsi文件添加两个TP设备(名字不一样):

LA.UM.5.6\kernel\msm-3.18\arch\arm\boot\dts\qcom\msm8937-pmi8937-qrd-sku2.dtsi

 

&soc {      
i2c@78b6000 {
                   status= "ok";
                   goodix@5d{
                            compatible = "goodix,gt9xx_2";
                            reg= <0x5d>;
                            interrupt-parent= <&tlmm>;
                         interrupts = <62 0x00>;
                            reset-gpios = <&tlmm128 0x00>;
                            interrupt-gpios= <&tlmm 62 0x2002>;
                            /*avdd-supply= <&tp_power>;*/
                            vdd-supply= <&pm8937_l17>;
                            vcc_i2c-supply= <&pm8937_l6>;
                            /*pins used by touchscreen */
                            pinctrl-names= "pmx_ts_active",
                                                        "pmx_ts_suspend",
                                                        "pmx_ts_release";
                            pinctrl-0= <&ts_int_active &ts_reset_active>;
                            pinctrl-1= <&ts_int_suspend &ts_reset_suspend>;
                            pinctrl-2= <&ts_release>;
                            goodix,i2c-pull-up;
                            goodix,no-force-update;
                            goodix,panel-coords= <0 0 1080 1920>;
                            goodix,display-coords= <0 0 1080 1920>;
                            goodix,button-map=<139 172 158>;
            goodix,product-id0 ="9147";
                            goodix,product-id1= "915L";
                            goodix,fw_name= "gtp_fw.bin";
                            //goodix,enable-power-off;
                            goodix,cfg-data1= [
                                     00D0 02 38 04 0A 05 00 01 08
                                     2805 50 32 03 05 00 00 00 00
                                     0000 00 00 00 00 00 8C 2C 0E
                                     1715 31 0D 00 00 01 9B 03 1D
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 02 04 06 08 0A 0C 0E 10
                                     1214 16 18 1A 1C 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 02 04 06 08 0A 0C 0F
                                     1012 13 14 28 26 24 22 21 20
                                     1F1E 1D 1C 18 16 FF FF 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 6C 01];
                            goodix,have-touch-key;
                            goodix,driver-send-cfg;
                   };
         };
         i2c@78b7000{
                   status= "ok";
                   goodix@5d{
                            compatible = "goodix,gt9xx";
                            reg= <0x5d>;
                            interrupt-parent= <&tlmm>;
                         interrupts = <65 0x00>;
                            reset-gpios= <&tlmm 64 0x00>;
                            interrupt-gpios= <&tlmm 65 0x2002>;
                            /*avdd-supply= <&tp_power>;*/
                            vdd-supply= <&pm8937_l17>;
                            vcc_i2c-supply= <&pm8937_l6>;
                            /*pins used by touchscreen */
                             pinctrl-names = "pmx_ts_active",
                                                        "pmx_ts_suspend",
                                                        "pmx_ts_release";
                            pinctrl-0= <&ts_int_active &ts_reset_active>;
                            pinctrl-1= <&ts_int_suspend &ts_reset_suspend>;
                            pinctrl-2= <&ts_release>;
                            goodix,i2c-pull-up;
                            goodix,no-force-update;
                            goodix,panel-coords= <0 0 1080 1920>;
                            goodix,display-coords= <0 0 1080 1920>;
                            goodix,button-map=<139 172 158>;
            goodix,product-id0 ="9147";
                            goodix,product-id1= "915L";
                            goodix,fw_name= "gtp_fw.bin";
                            //goodix,enable-power-off;
                            goodix,cfg-data1= [
                                     00D0 02 38 04 0A 05 00 01 08
                                     2805 50 32 03 05 00 00 00 00
                                     0000 00 00 00 00 00 8C 2C 0E
                                     1715 31 0D 00 00 01 9B 03 1D
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 02 04 06 08 0A 0C 0E 10
                                     1214 16 18 1A 1C 00 00 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 02 04 06 08 0A 0C 0F
                                     1012 13 14 28 26 24 22 21 20
                                     1F1E 1D 1C 18 16 FF FF 00 00
                                     0000 00 00 00 00 00 00 00 00
                                     0000 00 00 6C 01];
                            goodix,have-touch-key;
                            goodix,driver-send-cfg;
                   };
         };
};
 

 

 

 

 

 

 

修改pinctrl

LA.UM.5.6\kernel\msm-3.18\arch\arm\boot\dts\qcom\msm8937-pinctrl.dtsi

 

/* add pingrp for touchscreen */
                   pmx_ts_int_active{
                            ts_int_active:ts_int_active {
                                     mux{
                                               pins= "gpio65","gpio62";
                                               function= "gpio";
                                     };
 
                                     config{
                                               pins= "gpio65","gpio62";
                                               drive-strength= <8>;
                                               bias-pull-up;
                                     };
                            };
                   };
 
                   pmx_ts_int_suspend{
                            ts_int_suspend:ts_int_suspend {
                                     mux{
                                               pins= "gpio65","gpio62";
                                               function= "gpio";
                                     };
 
                                     config{
                                               pins= "gpio65","gpio62";
                                               drive-strength= <2>;
                                               bias-pull-down;
                                     };
                            };
                   };
 
                   pmx_ts_reset_active{
                            ts_reset_active:ts_reset_active {
                                     mux{
                                               pins= "gpio64","gpio128";
                                               function= "gpio";
                                     };
 
                                     config{
                                               pins= "gpio64","gpio128";
                                               drive-strength= <8>;
                                               bias-pull-up;
                                     };
                            };
                   };
 
                   pmx_ts_reset_suspend{
                            ts_reset_suspend:ts_reset_suspend {
                                     mux{
                                               pins= "gpio64","gpio128";
                                               function= "gpio";
                                     };
 
                                     config{
                                               pins= "gpio64","gpio128";
                                               drive-strength= <2>;
                                               bias-pull-down;
                                     };
                            };
                   };
 
                   pmx_ts_release{
                            ts_release:ts_release {
                                     mux{
                                               pins= "gpio65","gpio64","gpio62","gpio128";
                                               function= "gpio";
                                     };
 
                                     config{
                                               pins = "gpio65","gpio64","gpio62","gpio128";
                                               drive-strength= <2>;
                                               bias-pull-down;
                                     };
                            };
                   };
 

 

 

 

在驱动中添加一个支持的设备名称:

LA.UM.5.6\kernel\msm-3.18\drivers\input\touchscreen\gt9xx\gt9xx.c

 

static struct of_device_idgoodix_match_table[] = {

         {.compatible = "goodix,gt9xx", },

         { .compatible = "goodix,gt9xx_2",},

         {},

};

 

到这里主要的配置都实现了,编译bootimage,下载进去运行,发现TP1不能使用,TP2可以使用,查看串口log

adb shell dmesg > j:\looo.txt

 

 

[    5.873218] goodix_ts_probename = gt9xx_2
[    5.876305] goodix_parse_dt  pdata->irq_gpio=62,pdata->irq_gpio_flags=8194
[    5.883271] 2-005d supply avdd not found,using dummy regulator
[    6.008605] i2c-msm-v2 78b6000.i2c:msm_bus_scale_register_client(mstr-id:86):0xf (ok)
[    6.016036] Goodix-TS 2-005d: Goodix ProductID = 915L
[    6.020998] Goodix-TS 2-005d: Sensor IDselected: 1
[    6.026139] sps: BAM device0x0000000007884000 is not registered yet.
[    6.033125] sps:BAM 0x0000000007884000 isregistered.
[    6.037345] sps:BAM 0x0000000007884000(va:0xffffff8001b60000) enabled: ver:0x19, number of pipes:12
[    6.078795] input: Goodix-CTP as/devices/virtual/input/input1
[    6.084776] Goodix-TS 2-005d: GTP works ininterrupt mode.
[    6.091032] goodix_ts_probename = gt9xx
[    6.093944] goodix_parse_dt  pdata->irq_gpio=65,pdata->irq_gpio_flags=8194
[    6.100931] 3-005d supply avdd not found,using dummy regulator
[    6.108821] msm8937-pinctrl 1000000.pinctrl:pin GPIO_65 already requested by 2-005d; cannot claim for 3-005d
[    6.117710] msm8937-pinctrl 1000000.pinctrl:pin-65 (3-005d) status -22
[    6.124332] msm8937-pinctrl 1000000.pinctrl:could not request pin 65 (GPIO_65) from group gpio65  on device 1000000.pinctrl
[    6.135517] Goodix-TS 3-005d: Error applyingsetting, reverse things back
[    6.142286] Goodix-TS 3-005d: failed toselect pin to active state
[    6.149159] Goodix-TS: probe of 3-005d failedwith error -22

 

 

 

 

 

通过串口log,TP2已经先probe通过,pinctrl也申请设置成功,但是TP1具有相同的pinctrl,造成无法申请GPIO,失败返回,TP1的probe失败了。

解决办法,在pinctrl这一块通过名称做一个兼容:

 

    

     if(strcmp(client->name,"gt9xx_2")==0)
         {
                   //printk(KERN_ERR"2222goodix_ts_probe name = %s\n",client->name);
                   ret= goodix_ts_pinctrl_init(ts);
        
                   if(!ret && ts->ts_pinctrl) {
                            ret= pinctrl_select_state(ts->ts_pinctrl,
                                                        ts->pinctrl_state_active);
                            if(ret < 0) {
                                     dev_err(&client->dev,
                                               "failedto select pin to active state");
                                     gotoexit_power_off;
                            }
                   }else {
                            gotoexit_power_off;
                   }
         }else
         {
                   //printk(KERN_ERR"1111goodix_ts_probe name = %s\n",client->name);
                   ts->ts_pinctrl= NULL ;
         }

 

 

 

 

继续编译执行,发现程序跑飞了!!!

WTF!

这次只能使用硬件串口log看看了。

 

[    5.721504] goodix_ts_probename = gt9xx_2
[    5.724592] goodix_parse_dt pdata->irq_gpio=62,pdata->irq_gpio_flags=8194
[    5.731560] 2-005d supply avdd not found,using dummy regulator
[    5.738635] 2222goodix_ts_probe name = gt9xx_2
[    5.858589] i2c-msm-v2 78b6000.i2c:msm_bus_scale_register_client(mstr-id:86):0xf (ok)
[    5.866018] Goodix-TS 2-005d: Goodix ProductID = 915L
[    5.870979] Goodix-TS 2-005d: Sensor IDselected: 1
[    5.876098] sps: BAM device 0x0000000007884000is not registered yet.
[    5.883091] sps:BAM 0x0000000007884000 isregistered.
[    5.887333] sps:BAM 0x0000000007884000(va:0xffffff8001b60000) enabled: ver:0x19, number of pipes:12
[    5.928830] input: Goodix-CTP as/devices/virtual/input/input1
[    5.934802] Goodix-TS 2-005d: GTP works ininterrupt mode.
[    5.941017] goodix_ts_probe name = gt9xx
[    5.943929] goodix_parse_dt pdata->irq_gpio=65,pdata->irq_gpio_flags=8194
[    5.950897] 3-005d supply avdd not found,using dummy regulator
[    5.957868] 1111goodix_ts_probe name = gt9xx
[    6.078455] i2c-msm-v2 78b7000.i2c:msm_bus_scale_register_client(mstr-id:86):0x10 (ok)
[    6.085946] Goodix-TS 3-005d: Goodix ProductID = 915L
[    6.090929] Goodix-TS 3-005d: Sensor IDselected: 1
[    6.128988] input: Goodix-CTP as/devices/virtual/input/input2
[    6.135134] Goodix-TS 3-005d: GTP works ininterrupt mode.
[    6.139974] Goodix-TS 3-005d: Failed tocreate debugfs dir.
[    6.145133] Goodix-TS 3-005d: Failed tocreate debugfs entries, -22
[    6.151449]=============================================================================
[    6.159541] BUG kmalloc-512 (Tainted: G        W    ): Invalid object pointer 0xffffffc069c19198
[    6.168392] -----------------------------------------------------------------------------
[    6.168392]
[    6.178028] Disabling lock debugging due tokernel taint
[    6.183326] INFO: Slab 0xffffffba448b5080objects=36 used=12 fp=0xffffffc069c19880 flags=0x4081
[   6.192008] CPU: 0 PID: 1 Comm:swapper/0 Tainted: G    B   W     3.18.31 #31
[    6.199210] Hardware name: QualcommTechnologies, Inc. MSM8937-PMI8937 QRD SKU2 (DT)
[    6.206936] Call trace:
[    6.209375] [<ffffffc000089b14>]dump_backtrace+0x0/0x270
[    6.214750] [<ffffffc000089d98>]show_stack+0x14/0x1c

 

 

 

 

 

原来在创建debugfs的时候失败了,应该是debugfs_create_dir(GTP_DEBUGFS_DIR, NULL);重复创建造成失败。还是用老方法规避一下:

    

     if(strcmp(client->name,"gt9xx_2")==0)
         {
                   ret= gtp_debugfs_init(ts);
                   if(ret != 0) {
                            dev_err(&client->dev,"Failed to create debugfs entries, %d\n",
                                                                 ret);
                            gotoexit_remove_sysfs;
                   }
         }

 

 

 

继续编译下载调试,最终两个TP也可以同时工作了!

测试结果:

两个TP的input子系统都已经创建,而且可以分别上报数据到各个event上。

 

 

  • 5
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值