高通 8x12 添加 TP和按键

1 .在tp的驱动文件中添加以下代码实现按键功能

[plain] view plain copy
  1. static ssize_t  
  2. ft5x06_virtual_keys_register(struct kobject *kobj,  
  3.                  struct kobj_attribute *attr,  
  4.                  char *buf)  
  5. {  
  6.     return snprintf(buf, 200,  
  7.     __stringify(EV_KEY) ":" __stringify(KEY_HOME)  ":120:840:80:60"  
  8.     ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK)   ":360:840:80:60"  
  9.     " ");  
  10. }  
  11.   
  12. static struct kobj_attribute ft5x06_virtual_keys_attr = {  
  13.     .attr = {  
  14.         .name = "virtualkeys.ft5x06_ts",  
  15.         .mode = S_IRUGO,  
  16.     },  
  17.     .show = &ft5x06_virtual_keys_register,  
  18. };  
  19.   
  20. static struct attribute *ft5x06_virtual_key_properties_attrs[] = {  
  21.     &ft5x06_virtual_keys_attr.attr,  
  22.     NULL,  
  23. };  
  24.   
  25. static struct attribute_group ft5x06_virtual_key_properties_attr_group = {  
  26.     .attrs = ft5x06_virtual_key_properties_attrs,  
  27. };  
  28.   
  29. struct kobject *ft5x06_virtual_key_properties_kobj;  
  30.   
  31.   
  32. static void __init ft5x06_touchpad_setup(void)  
  33. {  
  34.     int rc;  
  35.     ft5x06_virtual_key_properties_kobj =  
  36.             kobject_create_and_add("board_properties", NULL);  
  37.       
  38.   
  39.     if (ft5x06_virtual_key_properties_kobj)  
  40.         rc = sysfs_create_group(ft5x06_virtual_key_properties_kobj,  
  41.                 &ft5x06_virtual_key_properties_attr_group);  
  42.   
  43.     if (!ft5x06_virtual_key_properties_kobj || rc)  
  44.         pr_err("%s: failed to create board_properties ", __func__);  
  45.   
  46.       
  47. }  
另外需要在-mtp.dtsi文件中配置TP的参数和gen_vkeys

[plain] view plain copy
  1. i2c@f9923000{  
  2.     focaltech@38{  
  3.         compatible = "focaltech,5x06";  
  4.         reg = <0x38>;  
  5.         interrupt-parent = <&msmgpio>;  
  6.         interrupts = <1 0x2>;  
  7.         vdd-supply = <&pm8110_l19>;  
  8.         vcc_i2c-supply = <&pm8110_l14>;  
  9.         focaltech,family-id = <0x06>;  
  10.         focaltech,reset-gpio = <&msmgpio 0 0x00>;  
  11.         focaltech,irq-gpio = <&msmgpio 1 0x00>;  
  12.         focaltech,display-coords = <0 0 480 854>;  
  13.         focaltech,panel-coords = <0 0 480 946>;  
  14.         focaltech,button-map= <139 102 158>;  
  15.         focaltech,no-force-update;  
  16.         focaltech,i2c-pull-up;  


这里主要配置touch panel的按键:

[plain] view plain copy
  1. gen-vkeys {  
  2.         compatible = "qcom,gen-vkeys";  
  3.         label = "ft5x06_ts";  
  4.         qcom,disp-maxx = <480>;  
  5.         qcom,disp-maxy = <800>;  
  6.         qcom,panel-maxx = <481>;  
  7.         qcom,panel-maxy = <940>;  
  8.         qcom,key-codes = <102 158 >;  //按键码,TP需要几个就写几个  
  9.         qcom,y-offset = <0>;  
  10.     };  


key_codes究竟是多少,在头文件kernel/include/linux/input.h 中定义,解析这些参数的函数是在driver/input/touchscreen/gen_vkeys.c,其中用的的函数还是这个

vkey_obj = kobject_create_and_add("board_properties", NULL);
if (!vkey_obj) {
dev_err(&pdev->dev, "unable to create kobject ");
return -ENOMEM;
}


ret = sysfs_create_group(vkey_obj, &vkey_grp);
if (ret) {
dev_err(&pdev->dev, "failed to create attributes ");
goto destroy_kobj;
}

这个实现的方法跟8x25的基本一样,只不过这里注册成了驱动。记住如果使能这个功能的话,在配置文件中CONFIG_TOUCHSCREEN_GEN_VKEYS=y


下面是成功添加后的截图

0
0
原文地址:https://www.cnblogs.com/liang123/p/6325233.html