Beispiel #1
0
static void  xpt2046_send_values(struct XPT2046_TS_EVENT *ts_dev)
{
    struct XPT2046_TS_EVENT *ts = ts_dev;
    struct input_dev *xpt2046_ts_dev;
    u16 x,y,z1,z2;
    int pixelpoint_x = 0;
    int pixelpoint_y = 0;
    int padding = 0;
    x = ts->x;
    y = ts->y;
    z1 = ts->z1;
    z2 = ts->z2;

    if((x == 0)&&(y == 4095))	/*ignored pressure*/
    {   /**/
        if(!ts->pendown)
        {
            ts_dev->pendown = 1;
            is_first_availability_point = true;
        }
        //ts_dev->pendown = 1;	//change by cong, 2010-06-14, old core
        hrtimer_start(&ts_dev->timer,ktime_set(0,TS_POLL_PERIOD),HRTIMER_MODE_REL);
        return ;
    } else		/*valid event*/
    {
        if(is_first_availability_point) {
            ts->pendown = 0;
            is_first_availability_point = false;
        }
        xpt2046_ts_dev = ts->input;
        if(!ts->pendown)
        {
            rk28printk("The touchscreen down!!\n");
            //printk("---x = %d, y = %d ---------------------------------------The touchscreen down!!\n", x, y);
            input_report_key(xpt2046_ts_dev,BTN_TOUCH,1);
            ts->pendown = 1;
        }
#if 0
        gADPoint.x = x;
        gADPoint.y = y;
#else
        gADPoint.x = y;
        gADPoint.y = x;
#endif
        TouchPanelCalibrateAPoint(gADPoint.x, gADPoint.y, &pixelpoint_x, &pixelpoint_y);
        ts->touch_x = pixelpoint_x/4;
        ts->touch_y = pixelpoint_y/4;
        TouchReportFilter(&(ts->touch_x),&(ts->touch_y));
        //ts->touch_x = TouchReportFilterX(ts->touch_x);
        //ts->touch_y = TouchReportFilterY(ts->touch_y);
        rk28printk("send ad    value	x=%d	y=%d\n",gADPoint.x,gADPoint.y);
        rk28printk("send value px	 point	   x=%d    y=%d\n\n",ts->touch_x,ts->touch_y);
        if((ts->touch_x > LCD_MAX_LENGTH )||(ts->touch_y > LCD_MAX_WIDTH ))
        {
            /*should be calibrate mode*/
            rk28printk("should be calibrate mode\n");
            input_report_abs(xpt2046_ts_dev,ABS_X,100);
            input_report_abs(xpt2046_ts_dev,ABS_Y,100);
            input_sync(xpt2046_ts_dev);
        }
        input_report_abs(xpt2046_ts_dev,ABS_X,ts->touch_x);
        //padding=(ts->touch_y-300)/30;
        input_report_abs(xpt2046_ts_dev,ABS_Y,ts->touch_y+padding);
        //input_report_key(xpt2046_ts_dev,BTN_TOUCH,1);
        input_sync(xpt2046_ts_dev);
    }
    hrtimer_start(&ts_dev->timer,ktime_set(0,TS_POLL_PERIOD),HRTIMER_MODE_REL);
}
Beispiel #2
0
void ak4183_delay_work(struct work_struct *work)
{
	struct AK4183_TS_EVENT *ts_dev = g_ts_dev;
	int ak4183_irq_pin_level = 0;
	int ak4183_input_report_flag = 0;
	int raw_x[SAMPLE_TIMES] = {0}; /* x raw adc data */
	int raw_y[SAMPLE_TIMES] = {0}; /* y raw adc data */
    int filtered_x = 0;
	int filtered_y = 0;
    int xpos;
	int ypos;
	int ret = 0;	
	int i;
	
	D("enter!\n");

	ak4183_irq_pin_level = GPIOGetPinLevel(GPIOPortE_Pin3);

	/* touch */
	if(ak4183_irq_pin_level == 0){
		/* get raw data of x and y */
		for(i = 0; i < SAMPLE_TIMES; i++){
			ret |= ak4183_read_x(&raw_x[i]);
			ret |= ak4183_read_y(&raw_y[i]);
			if(ret != 0){
				E("an4183_read xpos or ypos err!\n");
				goto fake_touch;
			}
		}

		/* check raw data whether valid */
	    for (i = 0; i < SAMPLE_TIMES; i++)
	    {
	        if (raw_x[i] == 4095 || raw_x[i] == 0 ||
			    raw_y[i] == 4095 || raw_y[i] == 0){
			    I("raw data invalid\n");
	            goto fake_touch;
	        }
	    }

		/* filter raw data */
	    ret = tp_average_filter(raw_x, &filtered_x);
		if(ret < 0){
			I("x fake touch\n");
			goto fake_touch;
		}

		ret = tp_average_filter(raw_y, &filtered_y);
	    if (ret < 0){
			I("y fake touch\n");
	        goto fake_touch;
	    }

	    TouchPanelCalibrateAPoint(filtered_x, filtered_y, &xpos, &ypos);
		xpos = xpos / 4;
	    ypos = ypos / 4;

		if(tp_state == TP_STATE_IDLE){
			input_report_key(ts_dev->input, BTN_TOUCH, 1);
			ak4183_input_report_flag = 1;
			tp_state = TP_STATE_DOWN;
		}
		
		if(tp_state == TP_STATE_DOWN){
			I("xpos=%d, ypos=%d\n", xpos, ypos);
			I("gADPoint.x=%d, gADPoint.y=%d\n", gADPoint.x, gADPoint.y);
			gADPoint.x = filtered_x;
			gADPoint.y = filtered_y;
			
			input_report_abs(ts_dev->input, ABS_X, xpos);
			input_report_abs(ts_dev->input, ABS_Y, ypos);
			ak4183_input_report_flag = 1;
		}
	}

fake_touch:
	if(ak4183_irq_pin_level == 1 && tp_state == TP_STATE_DOWN){
		input_report_key(ts_dev->input, BTN_TOUCH, 0);
		ak4183_input_report_flag = 1;
		tp_state = TP_STATE_IDLE;
	}

	if(ak4183_input_report_flag != 0){
		input_sync(ts_dev->input);
	}

	/* still on touch */
	if(ak4183_irq_pin_level == 0){
		schedule_delayed_work(&ts_dev->work, TP_POLL_PERIOD);
	}
	/* untouch, open ts irq */
	else{
		gpio_irq_enable(GPIOPortE_Pin3);
	}
}