高通8x12 添加 TP和按键

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

  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.     "\n");  
  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\n", __func__);  
  45.   
  46.       
  47. }  
static ssize_t
ft5x06_virtual_keys_register(struct kobject *kobj,
			     struct kobj_attribute *attr,
			     char *buf)
{
	return snprintf(buf, 200,
	__stringify(EV_KEY) ":" __stringify(KEY_HOME)  ":120:840:80:60"
	":" __stringify(EV_KEY) ":" __stringify(KEY_BACK)   ":360:840:80:60"
	"\n");
}

static struct kobj_attribute ft5x06_virtual_keys_attr = {
	.attr = {
		.name = "virtualkeys.ft5x06_ts",
		.mode = S_IRUGO,
	},
	.show = &ft5x06_virtual_keys_register,
};

static struct attribute *ft5x06_virtual_key_properties_attrs[] = {
	&ft5x06_virtual_keys_attr.attr,
	NULL,
};

static struct attribute_group ft5x06_virtual_key_properties_attr_group = {
	.attrs = ft5x06_virtual_key_properties_attrs,
};

struct kobject *ft5x06_virtual_key_properties_kobj;


static void __init ft5x06_touchpad_setup(void)
{
	int rc;
	ft5x06_virtual_key_properties_kobj =
			kobject_create_and_add("board_properties", NULL);
	

	if (ft5x06_virtual_key_properties_kobj)
		rc = sysfs_create_group(ft5x06_virtual_key_properties_kobj,
				&ft5x06_virtual_key_properties_attr_group);

	if (!ft5x06_virtual_key_properties_kobj || rc)
		pr_err("%s: failed to create board_properties\n", __func__);

	
}
另外需要在-mtp.dtsi文件中配置TP的参数和gen_vkeys

  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;  
 i2c@f9923000{
		focaltech@38{
			compatible = "focaltech,5x06";
			reg = <0x38>;
			interrupt-parent = <&msmgpio>;
			interrupts = <1 0x2>;
			vdd-supply = <&pm8110_l19>;
			vcc_i2c-supply = <&pm8110_l14>;
			focaltech,family-id = <0x06>;
			focaltech,reset-gpio = <&msmgpio 0 0x00>;
			focaltech,irq-gpio = <&msmgpio 1 0x00>;
			focaltech,display-coords = <0 0 480 854>;
			focaltech,panel-coords = <0 0 480 946>;
			focaltech,button-map= <139 102 158>;
			focaltech,no-force-update;
			focaltech,i2c-pull-up;

  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.     };  
gen-vkeys {
		compatible = "qcom,gen-vkeys";
		label = "ft5x06_ts";
		qcom,disp-maxx = <480>;
		qcom,disp-maxy = <800>;
		qcom,panel-maxx = <481>;
		qcom,panel-maxy = <940>;
		qcom,key-codes = <102 158 >;  //按键码,TP需要几个就写几个
		qcom,y-offset = <0>;
	};
下面是成功添加后的截图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值