static ssize_t touch_cali_status(struct device *dev, struct device_attribute *attr, char *_buf)
{
    int ret;
    
    ret = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x, uncali_y);
    if (ret == 1){
    	memcpy(uncali_x_default, uncali_x, sizeof(uncali_x));
    	memcpy(uncali_y_default, uncali_y, sizeof(uncali_y));
    	printk("touch_cali_status-0--%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
	                uncali_x_default[0], uncali_y_default[0],
	                uncali_x_default[1], uncali_y_default[1],
	                uncali_x_default[2], uncali_y_default[2],
	                uncali_x_default[3], uncali_y_default[3],
	                uncali_x_default[4], uncali_y_default[4]);
    	ret = sprintf(_buf, "successful\n");
    }
    else{
     	printk("touchpal calibration failed, use default value.\n");
#if 0
    	ret = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x_default, uncali_y_default);
    	printk("touch_cali_status-1---%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
	                uncali_x_default[0], uncali_y_default[0],
	                uncali_x_default[1], uncali_y_default[1],
	                uncali_x_default[2], uncali_y_default[2],
	                uncali_x_default[3], uncali_y_default[3],
	                uncali_x_default[4], uncali_y_default[4]);
    	if (ret == 1){
    		ret = sprintf(_buf, "recovery\n");
    	}
    	else{
    		ret = sprintf(_buf, "fail\n");
   		}
#endif
    }
    
    //printk("Calibration status: _buf=<%s", _buf);
    
	return ret;
}
Esempio n. 2
0
static ssize_t touch_cali_status(struct device_driver *_drv, char *_buf)
{
    int ret;

	D("enter!\n");
    ret = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x, uncali_y);
    if (ret == 1)
        ret = sprintf(_buf, "successful\n");
    else
        ret = sprintf(_buf, "fail\n");
    
    printk("Calibration status: _buf=<%s", _buf);
    
	return ret;
}
static int __init tp_calib_iface_init(void)
{
    int ret = 0;
    int err = 0;
    
    tp_class = class_create(THIS_MODULE, "touchpanel");
    if (IS_ERR(tp_class)) 
    {
        printk("Create class touchpanel failed.\n");
        return -ENOMEM;
    }
/*
    memcpy(screen_x,x,5*sizeof(int));
	memcpy(screen_y,y,5*sizeof(int));
	memcpy(uncali_x_default,uncali_x,5*sizeof(int));
	memcpy(uncali_y_default,uncali_y,5*sizeof(int));
*/
    err = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x_default, uncali_y_default);
    	printk("tp_calib_iface_init---%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
	                uncali_x_default[0], uncali_y_default[0],
	                uncali_x_default[1], uncali_y_default[1],
	                uncali_x_default[2], uncali_y_default[2],
	                uncali_x_default[3], uncali_y_default[3],
	                uncali_x_default[4], uncali_y_default[4]);
  	if (err == 1){
		printk("Auto set calibration successfully.\n");
	} else {
		printk("Auto set calibraion failed, reset data again please !");
	}
    
    /*
	 * Create ifaces for TP calibration.
	 */
	tp_dev = device_create(tp_class, NULL, MKDEV(0, 1), NULL, "tp");
    ret =  device_create_file(tp_dev, &dev_attr_touchcheck);
    ret += device_create_file(tp_dev, &dev_attr_touchadc);
    ret += device_create_file(tp_dev, &dev_attr_calistatus);
#ifdef TS_PRESSURE
   ret += device_create_file(tp_dev, &dev_attr_pressure);
#endif
    if (ret)
    {
        printk("Fail to class ifaces for TP calibration.\n");
    }

    return ret;
}