/*********************************************************************** [function]: callback: gather the finger information and calculate the X,Y coordinate then report them to the input system; [parameters]: null; [return]: null; ************************************************************************/ int fts_read_data(void) { struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client); u8 buf[6*CFG_MAX_POINT_NUM+3] = {0}; u8 * pt_tmp; static int key_id=0x80; int i,id,temp,temp1,i_count,ret = -1,k; int touch_event, x, y; i_count = 0; DBG_FUNC(KERN_INFO"Enter %s ,and ts orientation\n", __func__); ret=fts_i2c_rxdata(buf, 6*CFG_MAX_POINT_NUM+3); DBG_FUNC("ret = %d\n", ret); if (ret > 0) { for (k = 0; k < CFG_MAX_POINT_NUM; ++k) { pt_tmp = buf+3+k*6; touch_event = pt_tmp[0]>>6; id = pt_tmp[2] >> 4; if (id >= 0 && id< CFG_MAX_POINT_NUM) { temp = ((pt_tmp[0] & 0x0F) << 8) | pt_tmp[1]; temp1 = ((pt_tmp[2] & 0x0F) << 8) | pt_tmp[3]; } if (touch_event == 0) {//press down x = temp; y = temp1; for(i=0; i<key_num; i++) { if((x >= keys_data[i].x-key_span) && (x <= keys_data[i].x+key_span) && (y >= keys_data[i].y-key_span) && (y <= keys_data[i].y+key_span)) { input_report_key(data->input_dev, keys_data[i].value, 1); keys_data[i].press = 1; key_id = i; break; } } //tsp_keystatus[key_id] = KEY_PRESS; } if(touch_event == 1) { input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, id); input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 0); //input_report_abs(data->input_dev, ABS_MT_POSITION_X, _st_finger_infos[i].i2_x); //input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y); //input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure); input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 0); input_report_abs(data->input_dev, BTN_TOUCH, 0); //input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id); input_mt_sync(data->input_dev); DBG_FUNC("up\n"); } else if(touch_event == 2) { switch(orient_num){ case 1: x = temp; y = temp1; break; case 2: x = temp; y = SCREEN_MAX_Y - temp1; break; case 3: x = SCREEN_MAX_X - temp; y = temp1; break; case 4: x = SCREEN_MAX_X - temp; y = SCREEN_MAX_Y - temp1; break; case 5: x = temp1; y = temp; break; case 6: x = temp1; y = SCREEN_MAX_Y - temp; break; case 7: x = SCREEN_MAX_X - temp1; y = temp; break; case 8: x = SCREEN_MAX_X - temp1; y = SCREEN_MAX_Y - temp; break; } input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, id); input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 1); input_report_abs(data->input_dev, ABS_MT_POSITION_X, x); input_report_abs(data->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 50); input_report_key(data->input_dev, BTN_TOUCH, 1); input_mt_sync(data->input_dev); DBG_FUNC("x,y = %d, %d\n", x, y); } else { } } input_sync(data->input_dev); } return 0; }
/*********************************************************************** [function]: callback: gather the finger information and calculate the X,Y coordinate then report them to the input system; [parameters]: null; [return]: null; ************************************************************************/ static int fts_read_data(void) { struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client); u8 buf[6*CFG_MAX_POINT_NUM+2] = {0}; int id, i_count, cur_touch_release, i, ret = -1; int touch_point_num = 0, touch_event, x, y, swap_x, swap_y; int report_id_index[CFG_MAX_POINT_NUM] = {false}; buf[0] = 2;//ADDR ret = fts_i2c_rxdata(buf, 1); if (ret > 0) touch_point_num = buf[0]&0xf; else printk(KERN_ERR "get fingers failed!\n"); //printk("touch_point_num=%d\n", touch_point_num); if(touch_point_num > CFG_MAX_POINT_NUM) { //printk("Touch number [%d] readed is larger than max point number\n", touch_point_num); touch_point_num = 0; } i_count = 0; cur_touch_release = 0; if(touch_point_num != 0) { buf[0] = 3;//ADDR ret=fts_i2c_rxdata(buf, 6*touch_point_num); if(ret >= 0) { do { id = buf[2+i_count*6]>>4; if(id <0 || id>CFG_MAX_POINT_NUM) { printk("[ERROR] Touch ID readed is illegal!!\n"); } _st_finger_infos[i_count].id = id; touch_event = buf[i_count*6]>>6; swap_x =((buf[i_count*6]& 0x0f)<<8) |buf[i_count*6+1]; swap_y =( (buf[i_count*6+2]& 0x0f)<<8) | buf[i_count*6+3]; WPRINTK("touch id[%d], raw point(%d, %d), touch_event=%d\n", id, swap_x, swap_y, touch_event); #if defined(TS_SWAP_PX_PY) x = swap_x; y = swap_y; #elif defined(TS_SWAP_PY_PX) x = swap_y; y = swap_x; #elif defined(TS_SWAP_PX_NY) x = swap_x; y = WISKY_TOUCH_HEIGHT-swap_y; #elif defined(TS_SWAP_NX_PY) x = WISKY_TOUCH_WIDTH-swap_x; y = swap_y; #elif defined(TS_SWAP_NX_NY) x = WISKY_TOUCH_WIDTH-swap_x; y = WISKY_TOUCH_HEIGHT-swap_y; #else x = swap_x; y = swap_y; #endif //printk("touch id[%d], swap point(%d, %d)\n", id, x, y); if (touch_event == 0) //down { _st_finger_infos[i_count].u2_pressure= 1;//pressure; _st_finger_infos[i_count].i2_x= (int16_t)x; _st_finger_infos[i_count].i2_y= (int16_t)y; } else if (touch_event == 1) //up event { //report up key input_mt_slot(data->input_dev, id); input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false); _st_finger_infos[i_count].u2_pressure= 0; _st_finger_infos[i_count].id = -1; cur_touch_release++; } else if (touch_event == 2) //move { _st_finger_infos[i_count].u2_pressure= 1;//pressure; _st_finger_infos[i_count].i2_x= (int16_t)x; _st_finger_infos[i_count].i2_y= (int16_t)y; } else /*bad event, ignore*/ { printk("Bad event, ignore!!!\n"); i_count++; continue; } i_count++; } while(i_count < touch_point_num); if(0 == cur_touch_release) { for(i = touch_point_num; i < CFG_MAX_POINT_NUM; i++) { _st_finger_infos[i].id = -1; _st_finger_infos[i].u2_pressure = 0; _st_finger_infos[i].i2_x = 0; _st_finger_infos[i].i2_y = 0; } } for(i = 0; i < CFG_MAX_POINT_NUM; i++) { //report all down key if(_st_finger_infos[i].id >= 0 && _st_finger_infos[i].u2_pressure > 0) { WPRINTK("--->DOWN: id(%d)\n", _st_finger_infos[i].id); report_id_index[_st_finger_infos[i].id] = true; input_mt_slot(data->input_dev, _st_finger_infos[i].id); input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, true); input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 1); #if defined(WISKY_BOARD_U7PLUS_TV10) input_report_abs(data->input_dev, ABS_MT_POSITION_X, 1280- (_st_finger_infos[i].i2_x)); input_report_abs(data->input_dev, ABS_MT_POSITION_Y, 800 - (_st_finger_infos[i].i2_y)); #else input_report_abs(data->input_dev, ABS_MT_POSITION_X, _st_finger_infos[i].i2_x); input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y); #endif } } for(i = 0; i < CFG_MAX_POINT_NUM; i++) { if(false == report_id_index[i]) { WPRINTK("--->UP: id(%d)\n", i); //report all up key input_mt_slot(data->input_dev, i); input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false); } } input_sync(data->input_dev); cur_touch_release = 0; /*for(i = 0; i < CFG_MAX_POINT_NUM; i++){ WPRINTK("ID:%d (%d, %d), Presure[%d]", _st_finger_infos[i].id, _st_finger_infos[i].i2_x, _st_finger_infos[i].i2_y, _st_finger_infos[i].u2_pressure); }*/ } else {
/*********************************************************************** [function]: callback: gather the finger information and calculate the X,Y coordinate then report them to the input system; [parameters]: null; [return]: null; ************************************************************************/ int fts_read_data(void) { struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client); struct FTS_TS_EVENT_T *event = &data->event; u8 buf[32] = {0}; int i,key_id,id,temp,i_count,ret = -1; int touch_point_num = 0, touch_event, x, y, pressure, size; REPORT_FINGER_INFO_T touch_info[CFG_MAX_POINT_NUM]; i_count = 0; do { buf[0] = 3; id = 0xe; //assign an initial value ret=fts_i2c_rxdata(buf, 6);//read packet information, begin from 3 if (ret > 0) { id = buf[2]>>4; touch_event = buf[0]>>6; // 0 -- down, 1 -- up, 2--repeat, 3--reserved if (id >= 0 && id< CFG_MAX_POINT_NUM) //touch point information { //parse the finger information temp = buf[0]& 0x0f; temp = temp<<8; temp = temp | buf[1]; x = temp; temp = (buf[2])& 0x0f; temp = temp<<8; temp = temp | buf[3]; y=temp; pressure = buf[4] & 0x3f; //max is 255 size = buf[5]&0xf0; size = (id<<8)|size; touch_event = buf[0]>>6; // 0 -- down, 1 -- up, 2--repeat, 3--reserved if (touch_event == 0) //press down { _st_finger_infos[id].u2_pressure= pressure; _st_finger_infos[id].i2_x= (int16_t)x; _st_finger_infos[id].i2_y= (int16_t)y; _st_finger_infos[id].ui2_id = size; _si_touch_num ++; printk("\n--report x position is %d----\n",_st_finger_infos[id].i2_x); printk("\n--report y position is %d----\n",_st_finger_infos[id].i2_y); } else if (touch_event == 1) //up event { _st_finger_infos[id].u2_pressure= 0; } else if (touch_event == 2) //move { _st_finger_infos[id].u2_pressure= pressure; _st_finger_infos[id].i2_x= (int16_t)x; _st_finger_infos[id].i2_y= (int16_t)y; _st_finger_infos[id].ui2_id = size; _si_touch_num ++; } else { continue; //bad event, ignore } if ( (touch_event==1) ) { printk("[TSP]id=%d up\n", id); } for( i= 0; i<CFG_MAX_POINT_NUM; ++i ) { input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure); input_report_abs(data->input_dev, ABS_MT_POSITION_X, _st_finger_infos[i].i2_x); input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y); input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, _st_finger_infos[i].ui2_id); input_mt_sync(data->input_dev); if(_st_finger_infos[i].u2_pressure == 0 ) { _st_finger_infos[i].u2_pressure= -1; } } input_sync(data->input_dev); if (_si_touch_num == 0 ) { fts_ts_release(); } _si_touch_num = 0; } else if (id == 10) //touch key { if ( (buf[1]& 0x1)!= 0) { key_id = 0; } else if ( (buf[1]& 0x2)!= 0) { key_id = 1; } else if ( (buf[1]& 0x4)!= 0) { key_id = 2; } else if ( (buf[1]& 0x8)!= 0) { key_id = 3; } else { key_id = 0xf; } for(i = 0; i <CFG_NUMOFKEYS; i++ ) { if(tsp_keystatus[i]) { input_report_key(data->input_dev, tsp_keycodes[i], 0); tsp_keystatus[i] = KEY_RELEASE; } else if( key_id == i ) { if( touch_event == 0) // detect { input_report_key(data->input_dev, tsp_keycodes[i], 1); tsp_keystatus[i] = KEY_PRESS; } } } } else { if (id != 0xf) //invalid id report { printk("[TSP] ERROR: in %s, line %d, invlid id = %d\n", __FUNCTION__, __LINE__, id); } } }