void tpd_down(int raw_x, int raw_y, int x, int y, int p) { printk("mtk-tpd: D[rx:%4d,ry:%4d, %4d %4d %4d]\n", raw_x, raw_y, x, y, p); if(tpd && tpd->dev && tpd_register_flag==1) { input_report_abs(tpd->dev, ABS_PRESSURE, p/PRESSURE_FACTOR); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, p/PRESSURE_FACTOR); input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, p/PRESSURE_FACTOR); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); input_mt_sync(tpd->dev); TPD_DEBUG("D[%4d %4d %4d]\n", x, y, p); printk("mtk-tpd: [%4d %4d %4d]\n", x, y, p); TPD_EM_PRINT(raw_x, raw_y, x, y, p, 1); } }
static void synaptics_ts_work_func(struct work_struct *work) { int ret; uint8_t start_reg = 0x10; uint8_t buf1[6]; int x=0; int y=0; int finger=0; int width=0; static int finger_old=0; struct synaptics_ts_data *ts = container_of(work, struct synaptics_ts_data, work); ret = tsp_i2c_read( start_reg, buf1, sizeof(buf1)); if (ret <= 0) { printk("[TSP] i2c failed : ret=%d, ln=%d\n",ret, __LINE__); goto work_func_out; } if( !tsp_ready ){ tsp_ready++; goto work_func_out; } x = buf1[2] | (uint16_t)(buf1[1] & 0x03) << 8; y = buf1[4] | (uint16_t)(buf1[3] & 0x0f) << 8; width = buf1[5]/4; finger = buf1[0] & 0x01; input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, finger); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, width); input_mt_sync(ts->input_dev); input_sync(ts->input_dev); if(finger != finger_old) printk("[TSP] x:%3d, y:%3d, width:%3d, finger=%d\n", x, y, width, finger ); finger_old = finger; work_func_out: enable_irq(ts->client->irq); }
static void cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data *md, int max_slots) { int t; if (md->num_prv_tch == 0) return; for (t = 0; t < max_slots; t++) { input_mt_slot(md->input, t); input_mt_report_slot_state(md->input, MT_TOOL_FINGER, false); } input_mt_sync(md->input); input_sync(md->input); }
static void gt811_touch_down(struct ts_device* ts,s32 id,s32 x,s32 y,s32 w) { //将x和y值互换,说明坐标需要调整, //一般只能在调试的时候出现 swap(x, y); y = 479 -y; input_report_abs(ts->ts_input, ABS_MT_POSITION_X, x); input_report_abs(ts->ts_input, ABS_MT_POSITION_Y, y); // 上报压力值 input_report_abs(ts->ts_input, ABS_MT_TOUCH_MAJOR, w); input_report_abs(ts->ts_input, ABS_MT_WIDTH_MAJOR, w); input_report_abs(ts->ts_input, ABS_MT_TRACKING_ID, id); input_mt_sync(ts->ts_input); //GTP_DEBUG("ID=%d, X=%d, Y=%d, W=%d ", id, x, y, w); printk("input_x=%d,input_y=%d,input_w=%d id=%d\n ", x, y, w, id); }
void report_single_touch(void) { #ifdef MULTITOUCH input_report_abs(crtouch->input_dev, ABS_MT_POSITION_X, crtouch->x1); input_report_abs(crtouch->input_dev, ABS_MT_POSITION_Y, crtouch->y1); input_report_abs(crtouch->input_dev, ABS_MT_TOUCH_MAJOR, 1); input_mt_sync(crtouch->input_dev); #endif /* MULTITOUCH */ input_event(crtouch->input_dev, EV_ABS, ABS_X, crtouch->x1); input_event(crtouch->input_dev, EV_ABS, ABS_Y, crtouch->y1); input_event(crtouch->input_dev, EV_KEY, BTN_TOUCH, 1); #ifdef PRESSURE_EVENT input_report_abs(crtouch->input_dev, ABS_PRESSURE, 1); #endif /* PRESSURE_EVENT */ input_sync(crtouch->input_dev); status_pressed = CRICS_TOUCHED; }
static int tpd_up(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { CTP_DBG("x=%03d, y=%03d, ID=%03d", x, y, trackID); //input_report_abs(tpd->dev, ABS_PRESSURE, 0); input_report_key(tpd->dev, BTN_TOUCH, 0); //input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 0); //input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); //input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); //input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); input_mt_sync(tpd->dev); //TPD_UP_DEBUG_TRACK(x,y); if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 0); } return 0; }
static void report_value(int x,int y,struct ct360_ts_data *ts) { myct360printk("%s(%d,%d)\n", __FUNCTION__,x, y); //if((x>ts->x_max)||(y>ts->y_max)) // return; myct360printk("x=%d,y=%d,swap=%d\n",x,y,ts->swap_xy); if (ts->swap_xy){ swap(x, y); } if((x==0)||(y==0)) return; input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1); //Finger Size input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 1); //Touch Size input_mt_sync(ts->input_dev); }
/******************************************************* Function: Touch down report function. Input: ts:private data. id:tracking id. x:input x. y:input y. w:input weight. Output: None. *******************************************************/ static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w) { /**************************************** if(x > 18 && x < 28) x =x + 8; if(x > 4 && x < 13) x = x+13; if(x > 775 && x < 790) x = x - 5; if(x > 790 && x < 799) x = x - 13; if(y > 15 && y < 25) y =y + 8; if(y > 4 && y < 10) y = y+13; if(y > 455 && y < 470) y = y - 5; if(y > 470 && y < 480) y = y - 10; *********************************************/ #if GTP_ICS_SLOT_REPORT input_mt_slot(ts->input_dev, id); input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(ts->input_dev, ABS_MT_PRESSURE, w); #else input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); input_mt_sync(ts->input_dev); #endif GTP_DEBUG("ID:%d, X:%d, Y:%d, W:%d", id, x, y, w); }
static void tpd_down(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { CTP_DBG("x=%03d, y=%03d, pressure=%03d, ID=%03d", x, y, pressure, trackID); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 20); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); input_mt_sync(tpd->dev); if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 1); } //TPD_DOWN_DEBUG_TRACK(x,y); }
static void report_finger_data(struct input_dev *input, const struct bcm5974_config *cfg, const struct tp_finger *f) { input_report_abs(input, ABS_MT_TOUCH_MAJOR, raw2int(f->force_major) << 1); input_report_abs(input, ABS_MT_TOUCH_MINOR, raw2int(f->force_minor) << 1); input_report_abs(input, ABS_MT_WIDTH_MAJOR, raw2int(f->size_major) << 1); input_report_abs(input, ABS_MT_WIDTH_MINOR, raw2int(f->size_minor) << 1); input_report_abs(input, ABS_MT_ORIENTATION, MAX_FINGER_ORIENTATION - raw2int(f->orientation)); input_report_abs(input, ABS_MT_POSITION_X, raw2int(f->abs_x)); input_report_abs(input, ABS_MT_POSITION_Y, cfg->y.devmin + cfg->y.devmax - raw2int(f->abs_y)); input_mt_sync(input); }
//[*]--------------------------------------------------------------------------------------------------[*] //[*]--------------------------------------------------------------------------------------------------[*] static void solomon_report(struct solomon *ts) { int idx; for(idx = 0; idx < MAX_FINGERS; idx++) { if(ts->finger[idx].bits.event) { input_report_abs(ts->input, ABS_MT_TRACKING_ID, ts->finger[idx].bits.number); switch(ts->finger[idx].bits.event) { case EVENT_PRESS: case EVENT_MOVE: input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 1); input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, ts->finger[idx].bits.pressure ? ts->finger[idx].bits.pressure : 1); break; case EVENT_RELEASE: default : input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 0); ts->finger[idx].bits.event = EVENT_UNKNOWN; break; } input_report_abs(ts->input, ABS_MT_POSITION_X, (unsigned short)(((ts->finger[idx].bits.msb_x << 8) & 0xF00) | ts->finger[idx].bits.lsb_x)); input_report_abs(ts->input, ABS_MT_POSITION_Y, (unsigned short)(((ts->finger[idx].bits.msb_y << 8) & 0xF00) | ts->finger[idx].bits.lsb_y)); input_mt_sync(ts->input); #if defined(DEBUG_DISPLAY_EVENT_MESSAGE) printk("event:%d, finger:%d, pressure:%d, x:%d, y:%d\n" , ts->finger[idx].bits.event , ts->finger[idx].bits.number , ts->finger[idx].bits.pressure , (unsigned short)(((ts->finger[idx].bits.msb_x << 8) & 0xF00) | ts->finger[idx].bits.lsb_x) , (unsigned short)(((ts->finger[idx].bits.msb_y << 8) & 0xF00) | ts->finger[idx].bits.lsb_y)); #endif } } input_sync(ts->input); }
/* * this function is called when a whole finger has been parsed, * so that it can decide what to send to the input layer. */ static void egalax_filter_event(struct egalax_data *td, struct input_dev *input) { td->first = !td->first; /* touchscreen emulation */ if (td->valid) { /* emit multitouch events */ input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id); input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x >> 3); input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y >> 3); input_event(input, EV_ABS, ABS_MT_PRESSURE, td->z); input_mt_sync(input); /* * touchscreen emulation: store (x, y) as * the last valid values in this frame */ td->lastx = td->x; td->lasty = td->y; td->lastz = td->z; }
static void tpd_down(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { CTP_DBG("x=%03d, y=%03d, pressure=%03d, ID=%03d", x, y, pressure, trackID); input_report_abs(tpd->dev, ABS_PRESSURE, pressure); input_report_abs(tpd->dev, ABS_MT_PRESSURE, pressure); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); #ifdef FTS_SUPPORT_TRACK_ID input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); #endif input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, pressure*pressure/112); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, pressure*pressure/112); input_mt_sync(tpd->dev); __set_bit(trackID, &ts->fingers_flag); ts->touch_point_pre[trackID].x=x; ts->touch_point_pre[trackID].y=y; if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 1); } TPD_DOWN_DEBUG_TRACK(x,y); }
static irqreturn_t pj_irq(int irq, void *dev_id) { struct pj_data *touch = dev_id; struct i2c_client *client = touch->client; union pj_buff event; int ret, i; ret = i2c_smbus_read_i2c_block_data(client, X1_H, sizeof(event.buff), event.buff); if (WARN_ON(ret < 0)) { dev_err(&client->dev, "error %d reading event data\n", ret); return IRQ_NONE; } ret = i2c_smbus_write_byte_data(client, C_FLAG, 0); if (WARN_ON(ret < 0)) { dev_err(&client->dev, "error %d clearing interrupt\n", ret); return IRQ_NONE; } input_report_key(touch->input_dev, BTN_TOUCH, (event.data.fingers == 1 || event.data.fingers == 2)); input_report_key(touch->input_dev, BTN_2, (event.data.fingers == 2)); if (!event.data.fingers || (event.data.fingers > 2)) goto out; for (i = 0; i < event.data.fingers; i++) { input_report_abs(touch->input_dev, ABS_MT_POSITION_X, __be16_to_cpu(event.data.coord[i][0])); input_report_abs(touch->input_dev, ABS_MT_POSITION_Y, __be16_to_cpu(event.data.coord[i][1])); input_report_abs(touch->input_dev, ABS_MT_TRACKING_ID, i + 1); input_mt_sync(touch->input_dev); } out: input_sync(touch->input_dev); return IRQ_HANDLED; }
static void vtouch_report(struct kp *kp, long x, long y, int id) { #if VERTICAL long tmp; #endif if (x != 0 || y != 0) { #if VERTICAL x = LCD_SCREEN_X - x; x = x * LCD_YXFACTOR; y = y * LCD_XYFACTOR; tmp = x; x = y; y = tmp; #endif input_report_key(kp->input_keytouch, BTN_TOUCH, 1); input_report_abs(kp->input_keytouch, ABS_MT_TRACKING_ID, id); input_report_abs(kp->input_keytouch, ABS_MT_POSITION_X, x); input_report_abs(kp->input_keytouch, ABS_MT_POSITION_Y, y); input_mt_sync(kp->input_keytouch); } release = 1; }
/******************************************************* Function: Touch down report function. Input: ts:private data. id:tracking id. x:input x. y:input y. w:input weight. Output: None. *******************************************************/ static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w) { #if GTP_CHANGE_X2Y GTP_SWAP(x, y); #endif #if GTP_ICS_SLOT_REPORT input_mt_slot(ts->input_dev, id); input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(ts->input_dev, ABS_MT_PRESSURE, w); #else input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); input_mt_sync(ts->input_dev); #endif GTP_DEBUG("ID:%d, X:%d, Y:%d, W:%d", id, x, y, w); }
static void release_finger(finger_info *finger) { #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 0, 0)) input_mt_slot(ts_data->input_dev, finger->bit_field.id - 1); input_mt_report_slot_state(ts_data->input_dev, MT_TOOL_FINGER, false); #else input_report_abs(ts_data->input_dev, ABS_MT_POSITION_X, finger->bit_field.x); input_report_abs(ts_data->input_dev, ABS_MT_POSITION_Y, finger->bit_field.y); input_report_abs(ts_data->input_dev, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(ts_data->input_dev, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(ts_data->input_dev); #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(3, 0, 0)) tsp_info("%s %d(%d, %d)\n", __func__, finger->bit_field.id, finger->bit_field.x, finger->bit_field.y); finger->bit_field.udmg &= ~(PRESS_MSG_MASK); //print_tsp_event(finger); finger->bit_field.id = 0; input_sync(ts_data->input_dev); }
static void tpd_down(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { int iPressure = pressure*pressure/110; if ( iPressure < 1 ){ iPressure = 1; } CTP_DBG("x=%03d, y=%03d, pressure=%03d, ID=%03d", x, y, pressure, trackID); input_report_abs(tpd->dev, ABS_PRESSURE, iPressure); input_report_abs(tpd->dev, ABS_MT_PRESSURE, iPressure); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 20); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); printk("[SWEEP2WAKE]: tpd down\n"); #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE if (sweep2wake) { //printk("[SWEEP2WAKE]: detecting sweep\n"); detect_sweep2wake(x, y, jiffies, trackID); } #endif #ifdef FTS_SUPPORT_TRACK_ID input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); #endif input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, iPressure); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, iPressure); input_mt_sync(tpd->dev); __set_bit(trackID, &ts->fingers_flag); ts->touch_point_pre[trackID].x=x; ts->touch_point_pre[trackID].y=y; if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 1); } TPD_DOWN_DEBUG_TRACK(x,y); }
/* * this function is called when a whole finger has been parsed, * so that it can decide what to send to the input layer. */ static void quanta_filter_event(struct quanta_data *td, struct input_dev *input) { td->first = !td->first; /* touchscreen emulation */ if (!td->valid) { /* * touchscreen emulation: if no finger in this frame is valid * and there previously was finger activity, this is a release */ if (!td->first && !td->activity_now && td->activity) { input_event(input, EV_KEY, BTN_TOUCH, 0); td->activity = false; } return; } input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id); input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x); input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y); input_mt_sync(input); td->valid = false; /* touchscreen emulation: if first active finger in this frame... */ if (!td->activity_now) { /* if there was no previous activity, emit touch event */ if (!td->activity) { input_event(input, EV_KEY, BTN_TOUCH, 1); td->activity = true; } td->activity_now = true; /* and in any case this is our preferred finger */ input_event(input, EV_ABS, ABS_X, td->x); input_event(input, EV_ABS, ABS_Y, td->y); } }
static void mms_clear_input_data(struct mms_ts_info *info) { int i; dev_dbg(&info->client->dev, "%s\n", __func__); for (i = 0; i < MAX_FINGER_NUM; i++) { #if defined(MT_PROTOCOL_TYPE_A) input_report_abs(info->input_dev, ABS_MT_PRESSURE, 0); input_mt_sync(info->input_dev); #else input_mt_slot(info->input_dev, i); input_mt_report_slot_state(info->input_dev, MT_TOOL_FINGER, false); #endif } input_sync(info->input_dev); #if defined(MT_PROTOCOL_TYPE_A) memset(&info->mt_data, 0, sizeof(info->mt_data)); #else #endif return; }
static void pixcir_ts_poscheck(struct work_struct *work) { struct pixcir_i2c_ts_data *tsdata = container_of(work, struct pixcir_i2c_ts_data, work.work); unsigned char touching, oldtouching; int posx1, posy1,posx2, posy2; u_int8_t Rdbuf[10],Wrbuf[1]; int ret; int z=50; int w=15; memset(Wrbuf, 0, sizeof(Wrbuf)); memset(Rdbuf, 0, sizeof(Rdbuf)); Wrbuf[0] = 0; ret = i2c_master_send(tsdata->client, Wrbuf, 1); #ifdef DEBUG printk("master send ret:%d\n",ret); #endif if(ret!=1){ dev_err(&tsdata->client->dev, "Unable to write to i2c touchscreen!\n"); goto out; } ret = i2c_master_recv(tsdata->client,Rdbuf,sizeof(Rdbuf)); #ifdef DEBUG printk("master recv ret:%d\n",ret); #endif if(ret!=sizeof(Rdbuf)){ dev_err(&tsdata->client->dev, "Unable to read i2c page!\n"); goto out; } touching=Rdbuf[0]; oldtouching=Rdbuf[1]; posx1 = ((Rdbuf[3] << 8) | Rdbuf[2]); posy1 = ((Rdbuf[5] << 8) | Rdbuf[4]); posx2 = ((Rdbuf[7] << 8) | Rdbuf[6]); posy2 = ((Rdbuf[9] << 8) | Rdbuf[8]); posx1 = TOUCHSCREEN_MAXX - posx1; posx2 = TOUCHSCREEN_MAXX - posx2; #ifdef DEBUG printk("touching:%-3d,oldtouching:%-3d,x1:%-6d,y1:%-6d," "x2:%-6d,y2:%-6d\n", touching,oldtouching,posx1,posy1, posx2,posy2); #endif input_report_key(tsdata->input, BTN_TOUCH, (touching!=0?1:0)); input_report_key(tsdata->input, BTN_2, (touching==2?1:0)); if(touching){ input_report_abs(tsdata->input, ABS_X, posx1); input_report_abs(tsdata->input, ABS_Y, posy1); } if (touching==2) { input_report_abs(tsdata->input, ABS_HAT0X, posx2); input_report_abs(tsdata->input, ABS_HAT0Y, posy2); } if(!(touching)){ z=0; w=0; } input_report_abs(tsdata->input, ABS_MT_TOUCH_MAJOR, z); input_report_abs(tsdata->input, ABS_MT_WIDTH_MAJOR, w); input_report_abs(tsdata->input, ABS_MT_POSITION_X, posx1); input_report_abs(tsdata->input, ABS_MT_POSITION_Y, posy1); input_mt_sync(tsdata->input); if (touching==2) { input_report_abs(tsdata->input, ABS_MT_TOUCH_MAJOR, z); input_report_abs(tsdata->input, ABS_MT_WIDTH_MAJOR, w); input_report_abs(tsdata->input, ABS_MT_POSITION_X, posx2); input_report_abs(tsdata->input, ABS_MT_POSITION_Y, posy2); input_mt_sync(tsdata->input); } input_sync(tsdata->input); out: enable_irq(tsdata->irq); }
static void ct36x_ts_workfunc(struct work_struct *work) { int iter; int sync; int x, y; struct ct36x_ts_info *ts; if ( /*CT36X_TS_DEBUG*/ 0 ) ct36x_debug_2(">>>>> %s() called <<<<< \n", __FUNCTION__); ts = container_of(work, struct ct36x_ts_info, event_work); // esd timer check #if (CT36X_TS_ESD_TIMER_INTERVAL) if ( ts->timer_on ) { ts->chip_id = ct36x_ts_get_chip(ts->client); if ( ts->chip_id != CT360_CHIP_VER && ts->chip_id != CT36X_CHIP_VER ) { if ( /*CT36X_TS_DEBUG*/ 0 ) ct36x_debug("Read Chip ID Error (%x), Chip Reset! \n", ts->chip_id); // reset chip ct36x_ts_hw_reset(ts); } // reset esd timer mod_timer(&ts->timer, jiffies + HZ * CT36X_TS_ESD_TIMER_INTERVAL); return; } #endif // read touch points ct36x_ts_reg_read(ts->client, ts->i2c_address, (char *) ts->data.pts, sizeof(struct ct36x_finger_info) * CT36X_TS_POINT_NUM, CT36X_TS_I2C_SPEED); // report points sync = 0; ts->press = 0; for ( iter = 0; iter < CT36X_TS_POINT_NUM; iter++ ) { if ( ts->data.pts[iter].xhi != 0xFF && ts->data.pts[iter].yhi != 0xFF && (ts->data.pts[iter].status == 1 || ts->data.pts[iter].status == 2) ) { #if CT36X_TS_XY_SWAP x = (ts->data.pts[iter].yhi<<4)|(ts->data.pts[iter].ylo&0xF); y = (ts->data.pts[iter].xhi<<4)|(ts->data.pts[iter].xlo&0xF); #else x = (ts->data.pts[iter].xhi<<4)|(ts->data.pts[iter].xlo&0xF); y = (ts->data.pts[iter].yhi<<4)|(ts->data.pts[iter].ylo&0xF); #endif #if CT36X_TS_X_REVERSE x = CT36X_TS_ABS_X_MAX - x; #endif #if CT36X_TS_Y_REVERSE y = CT36X_TS_ABS_Y_MAX - y; #endif if (CT36X_TS_DEBUG) { ct36x_debug_pt("ID: %d\n", ts->data.pts[iter].id); ct36x_debug_pt("status: %d\n", ts->data.pts[iter].status); ct36x_debug_pt("X Lo: %d\n", ts->data.pts[iter].xlo); ct36x_debug_pt("Y Lo: %d\n", ts->data.pts[iter].ylo); ct36x_debug_pt("X Hi: %d\n", ts->data.pts[iter].xhi); ct36x_debug_pt("Y Hi: %d\n", ts->data.pts[iter].yhi); ct36x_debug_pt("X: %d\n", (ts->data.pts[iter].xhi<<4)|(ts->data.pts[iter].xlo&0xF)); ct36x_debug_pt("Y: %d\n", (ts->data.pts[iter].yhi<<4)|(ts->data.pts[iter].ylo&0xF)); #if (CT36X_TS_CHIP_SEL == CT36X_CHIP_VER) ct36x_debug_pt("Area: %d\n", ts->data.pts[iter].area); ct36x_debug_pt("Pressure: %d\n", ts->data.pts[iter].pressure); #endif } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) // for android 4.0.x input_mt_slot(ts->input, ts->data.pts[iter].id - 1); input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 1); input_report_abs(ts->input, ABS_MT_POSITION_X, x); input_report_abs(ts->input, ABS_MT_POSITION_Y, y); input_report_abs(ts->input, ABS_MT_PRESSURE, #if (CT36X_TS_CHIP_SEL == CT360_CHIP_VER) 255 #elif (CT36X_TS_CHIP_SEL == CT36X_CHIP_VER) ts->data.pts[iter].pressure #endif ); #else input_report_abs(ts->input, ABS_MT_TRACKING_ID, ts->data.pts[iter].id - 1); input_report_abs(ts->input, ABS_MT_POSITION_X, x); input_report_abs(ts->input, ABS_MT_POSITION_Y, y); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, #if (CT36X_TS_CHIP_SEL == CT360_CHIP_VER) 255 #elif (CT36X_TS_CHIP_SEL == CT36X_CHIP_VER) ts->data.pts[iter].pressure #endif ); input_mt_sync(ts->input); #endif #if 0 if(lcd_state==0) { lcd_state = 1; rk29_backlight_set(1); printk("TP huanxing beiguang================\n"); } #endif sync = 1; ts->press |= 0x01 << (ts->data.pts[iter].id - 1); } } ts->release &= ts->release ^ ts->press; for ( iter = 0; iter < CT36X_TS_POINT_NUM; iter++ ) { if ( ts->release & (0x01<<iter) ) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) // for android 4.0.x input_mt_slot(ts->input, iter); input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); #else input_report_abs(ts->input, ABS_MT_TRACKING_ID, ts->data.pts[iter].id - 1); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(ts->input, ABS_MT_POSITION_X, x); input_report_abs(ts->input, ABS_MT_POSITION_Y, y); input_mt_sync(ts->input); #endif sync = 1; } } ts->release = ts->press; if ( sync ) input_sync(ts->input); // Enable esd timer #if (CT36X_TS_ESD_TIMER_INTERVAL) if ( !ts->timer_on ) { ts->timer.expires = jiffies + HZ * CT36X_TS_ESD_TIMER_INTERVAL; add_timer(&ts->timer); ts->timer_on = 1; } #endif // Enable ts interrupt enable_irq(ts->irq); }
static void cypress_cpt_ts_work_func(struct work_struct *work) { int i; int ret; int bad_data = 0; struct i2c_msg msg[2]; uint8_t start_reg; bool finger2_pressed = FALSE; #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY static int key_pressed = 0; uint8_t key_tmp; #endif uint8_t buf[i2c_read_len]; uint16_t position[2][2]; uint8_t finger; struct cypress_cpt_ts_data *ts = container_of(work, struct cypress_cpt_ts_data, work); if( muti_touch ) { finger2_pressed = FALSE; } msg[0].addr = ts->client->addr; msg[0].flags = 0; msg[0].len = 1; msg[0].buf = &start_reg; start_reg = 0x00; msg[1].addr = ts->client->addr; msg[1].flags = I2C_M_RD; msg[1].len = i2c_read_len; msg[1].buf = buf; //for (i = 0; i < ((ts->use_irq && !bad_data)? 1 : 5 ); i++) { ret = i2c_transfer(ts->client->adapter, msg, 2); if (ret < 0) { printk("%d times i2c_transfer failed\n",i); } if (i == 5 && 0) { printk("try to software reset if i2c_transfer error\n"); ret = i2c_smbus_write_byte_data(ts->client, 0x0, 0x1); if (ret < 0) { printk(KERN_ERR "cypress_ts reset failed \n"); goto return_irq_enable; } } bad_data = 0; finger = buf[2] & 0xf; position[0][0] = buf[4] | ((uint16_t)(buf[3])<<8); position[0][1] = buf[6] | ((uint16_t)(buf[5])<<8); CYPRESS_DEBUG("finger=%d\n x1=%d, y1=%d, z1=%d\n", finger, position[0][0] ,position[0][1], buf[7]); if(muti_touch) { position[1][0] = buf[10] |((uint16_t)(buf[9]) << 8); position[1][1] = buf[12] | ((uint16_t)(buf[11])<< 8); finger2_pressed = (finger > 1) && (finger != 7); CYPRESS_DEBUG(" x2=%d, y2=%d, z2=%d \n", position[1][0] ,position[1][1], buf[13]); #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY if(is_in_extra_region(position[0][0], position[0][1])) { key_tmp = touch_get_extra_keycode(position[0][0], position[0][1]); if (0 == finger) { if(1 == key_pressed) { input_report_key(ts->input_extra_dev, key_tmp, 0); key_pressed = 0; } } else { if(0 == key_pressed) { input_report_key(ts->input_extra_dev, key_tmp, 1); key_pressed = 1; } } input_sync(ts->input_extra_dev); } else { #endif //CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY if (!finger) { buf[7] = 0; } input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, buf[7]); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, buf[7]); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, position[0][0]); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, position[0][1]); input_mt_sync(ts->input_dev); if (finger2_pressed) { input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, buf[13]); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, buf[13]); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, position[1][0]); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, position[1][1]); input_mt_sync(ts->input_dev); } else if (finger > 1) { input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(ts->input_dev); } input_sync(ts->input_dev); #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY } #endif } else { #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY if(is_in_extra_region(position[0][0], position[0][1])) { key_tmp = touch_get_extra_keycode(position[0][0], position[0][1]); if (0 == finger) { if(1 == key_pressed) { input_report_key(ts->input_extra_dev, key_tmp, 0); key_pressed = 0; } } else { if(0 == key_pressed) { input_report_key(ts->input_extra_dev, key_tmp, 1); key_pressed = 1; } } input_sync(ts->input_extra_dev); } else { #endif if(!finger) { buf[7] = 0; } #if 1 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, buf[7]); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, buf[7]); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, position[0][0]); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, position[0][1]); input_mt_sync(ts->input_dev); input_sync(ts->input_dev); #else input_report_abs(ts->input_dev, ABS_X, position[0][0]); input_report_abs(ts->input_dev, ABS_Y, position[0][1]); input_report_abs(ts->input_dev, ABS_TOOL_WIDTH, buf[7]); if(finger) { finger = 1; } else { finger = 0; } input_report_abs(ts->input_dev, ABS_PRESSURE, buf[7]); input_report_key(ts->input_dev, BTN_TOUCH, finger); input_sync(ts->input_dev); CYPRESS_DEBUG("--------------finger=%d\n x1=%d, y1=%d, z1=%d\n", finger, position[0][0] ,position[0][1], buf[7]); #endif #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY } #endif } #ifdef CONFIG_CYPRESS_TOUCHSCREEN_GESTRUE GESTURE_TYPE gesture; gesture = i2c_smbus_read_byte_data(ts->client, 0x09); if (gesture < 0) { printk("i2c_smbus_read_byte_data failed\n"); } else if ((gesture > 0) && (gesture < 16)) { CYPRESS_DEBUG("gesture = %d\n", gesture); input_report_gesture(ts->input_dev, gesture,0); input_sync(ts->input_dev); } #endif //} return_irq_enable: if(ts->use_irq) { enable_irq(ts->client->irq); } return; }
static void ct36x_ts_workfunc(struct work_struct *work) { int iter; int sync; int x, y; struct ct36x_ts_info *ts; if ( CT36X_TS_CORE_DEBUG ) printk(">>>>> %s() called <<<<< \n", __FUNCTION__); ts = container_of(work, struct ct36x_ts_info, event_work); /* read touch points */ ct36x_ts_reg_read(ts->client, ts->i2c_address, (char *) ts->data.pts, sizeof(struct ct36x_finger_info) * CT36X_TS_POINT_NUM); /* report points */ sync = 0; ts->press = 0; for ( iter = 0; iter < CT36X_TS_POINT_NUM; iter++ ) { if ( ts->data.pts[iter].xhi != 0xFF && ts->data.pts[iter].yhi != 0xFF && (ts->data.pts[iter].status == 1 || ts->data.pts[iter].status == 2) ) { #ifdef CONFIG_TOUCHSCREEN_CT36X_MISC_XY_SWAP x = (ts->data.pts[iter].yhi<<4)|(ts->data.pts[iter].ylo&0xF); y = (ts->data.pts[iter].xhi<<4)|(ts->data.pts[iter].xlo&0xF); #else x = (ts->data.pts[iter].xhi<<4)|(ts->data.pts[iter].xlo&0xF); y = (ts->data.pts[iter].yhi<<4)|(ts->data.pts[iter].ylo&0xF); #endif #ifdef CONFIG_TOUCHSCREEN_CT36X_MISC_X_REVERSE x = CT36X_TS_ABS_X_MAX - x; #endif #ifdef CONFIG_TOUCHSCREEN_CT36X_MISC_Y_REVERSE y = CT36X_TS_ABS_Y_MAX - y; #endif if ( CT36X_TS_EVENT_DEBUG ) { printk("ID: %d\n", ts->data.pts[iter].id); printk("status: %d\n", ts->data.pts[iter].status); printk("X Lo: %d\n", ts->data.pts[iter].xlo); printk("Y Lo: %d\n", ts->data.pts[iter].ylo); printk("X Hi: %d\n", ts->data.pts[iter].xhi); printk("Y Hi: %d\n", ts->data.pts[iter].yhi); printk("X: %d\n", x); printk("Y: %d\n", y); } input_report_abs(ts->input, ABS_MT_POSITION_X, x); input_report_abs(ts->input, ABS_MT_POSITION_Y, y); input_mt_sync(ts->input); sync = 1; ts->press |= 0x01 << (ts->data.pts[iter].id - 1); } } ts->release &= ts->release ^ ts->press; for ( iter = 0; iter < CT36X_TS_POINT_NUM; iter++ ) { if ( ts->release & (0x01<<iter) ) { input_mt_sync(ts->input); sync = 1; } } ts->release = ts->press; if ( sync ) input_sync(ts->input); // Enable ts interrupt enable_irq(ts->irq); }
static void cyttsp5_input_sync(struct input_dev *input) { input_mt_sync(input); }
static void kp_work(struct kp *kp) { int i, code; kp_search_key(kp); //add for adc keys(channel 4) //start, select i = 4; code = kp->key_code[i]; if ((!code) && (!kp->cur_keycode[i])) { ; } else if (code != kp->tmp_code[i]) { kp->tmp_code[i] = code; kp->count[i] = 0; } else if(++kp->count[i] == 2) { if (kp->cur_keycode[i] != code) { if (!code) { kp->cur_keycode_status[i] = 0; //printk("key %d up\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode[i] = code; } else if (kp->cur_keycode_status[i] == 1) { //printk("--------------------------- error cur = %d new code = %d -------------------------\n", kp->cur_keycode[i], code); //printk("key %d up(force)\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode_status[i] = 0; kp->count[i] = 0; } else { kp->cur_keycode_status[i] = 1; //printk("key %d down\n", code); input_report_key(kp->input, code, 1); kp->cur_keycode[i] = code; } } } //end if (key_param[0]) { //circle 0 if ((kp->key_valid[2] == 1) || (kp->key_valid[3] == 1)) { kp->circle_flag[0] = 1; if(second0 < CENTER_TRY) { if(second0 == 0) key_report(kp, key_param[1], key_param[2], 0); if(second0 == 1) key_report(kp, key_param[1] + 1, key_param[2], 0); if(second0 == 2) key_report(kp, key_param[1], key_param[2] + 1, 0); if(second0 == 3) key_report(kp, key_param[1] - 1, key_param[2], 0); if(second0 == 4) key_report(kp, key_param[1], key_param[2] - 1, 0); second0++; } else { key_report(kp, key_param[1] + (kp->key_value[2] - 512) * key_param[3] / 512, key_param[2] + (kp->key_value[3] - 512) * key_param[3] / 512, 0); } } else if (kp->circle_flag[0] == 1) { kp->circle_flag[0] = 0; second0 = 0; } scan_keys(kp); input_sync(kp->input); if (release && (kp->circle_flag[0] == 0) \ && kp->flaga && kp->flagb && kp->flagx && kp->flagy && kp->flagl && kp->flagr) { release = 0; input_report_key(kp->input, BTN_TOUCH, 0); input_report_abs(kp->input, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(kp->input, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(kp->input); input_sync(kp->input); //printk("-------------- release all point -----------------\n"); } } else { //left,right,up,down for (i=2; i<kp->chan_num; i++) { code = kp->key_code[i]; if (!code && !kp->cur_keycode[i]) { continue; } else if (code != kp->tmp_code[i]) { kp->tmp_code[i] = code; kp->count[i] = 0; } else if(++kp->count[i] == 2) { if (kp->cur_keycode[i] != code) { if (!code) { kp->cur_keycode_status[i] = 0; //printk("key %d up\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode[i] = code; } else if (kp->cur_keycode_status[i] == 1) { //printk("--------------------------- error cur = %d new code = %d -------------------------\n", kp->cur_keycode[i], code); //printk("key %d up(force)\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode_status[i] = 0; kp->count[i] = 0; } else { kp->cur_keycode_status[i] = 1; //printk("key %d down\n", code); input_report_key(kp->input, code, 1); kp->cur_keycode[i] = code; } } } } scan_keys(kp); input_sync(kp->input); } }
static void scan_keys(struct kp *kp) { struct input_dev *input = kp->input; keyl = get_gpio_val(GPIOA_bank_bit0_27(3), GPIOA_bit_bit0_27(3)); keyr = get_gpio_val(GPIOA_bank_bit0_27(5), GPIOA_bit_bit0_27(5)); keya = get_gpio_val(GPIOA_bank_bit0_27(7), GPIOA_bit_bit0_27(7)); keyb = get_gpio_val(GPIOA_bank_bit0_27(8), GPIOA_bit_bit0_27(8)); keyx = get_gpio_val(GPIOA_bank_bit0_27(9), GPIOA_bit_bit0_27(9)); keyy = get_gpio_val(GPIOA_bank_bit0_27(10), GPIOA_bit_bit0_27(10)); if(keyl == keyl_old){ if (key_param[0]) { if(keyl) { key_report(kp, key_param[12], key_param[13], 6); input_report_key(input, BUTTON_L, 1); kp->flagl = 0; } else { input_report_key(input, BUTTON_L, 0); kp->flagl = 1; } } else if (keyl == kp->flagl) { if(keyl) { input_report_key(input, BUTTON_L, 1); input_mt_sync(input); kp->flagl = 0; printk("KEY L\n"); } else { input_report_key(input, BUTTON_L, 0); input_mt_sync(input); kp->flagl = 1; printk("KEY L release\n"); } } } if(keyr == keyr_old){ if (key_param[0]) { if(keyr) { key_report(kp, key_param[14], key_param[15], 7); kp->flagr = 0; } else { kp->flagr = 1; } } else if (keyr == kp->flagr) { if(keyr) { input_report_key(input, BUTTON_R, 1); input_mt_sync(input); kp->flagr = 0; printk("KEY R\n"); } else { input_report_key(input, BUTTON_R, 0); input_mt_sync(input); kp->flagr = 1; printk("KEY R release\n"); } } } if(keya == keya_old){ if (key_param[0]) { if(keya) { key_report(kp, key_param[4], key_param[5], 2); kp->flaga = 0; } else { kp->flaga = 1; } } else if (keya == kp->flaga) { if(keya) { input_report_key(input, BUTTON_A, 1); input_mt_sync(input); kp->flaga = 0; printk("KEY A\n"); } else { input_report_key(input, BUTTON_A, 0); input_mt_sync(input); kp->flaga = 1; printk("KEY A release\n"); } } } if(keyb == keyb_old){ if (key_param[0]) { if(keyb) { key_report(kp, key_param[6], key_param[7], 3); kp->flagb = 0; } else { kp->flagb = 1; } } else if (keyb == kp->flagb) { if(keyb) { input_report_key(input, BUTTON_B, 1); input_mt_sync(input); kp->flagb = 0; printk("KEY B\n"); } else { input_report_key(input, BUTTON_B, 0); input_mt_sync(input); printk("KEY B release\n"); kp->flagb = 1; } } } if(keyx == keyx_old){ if (key_param[0]) { if(keyx) { key_report(kp, key_param[8], key_param[9], 4); kp->flagx = 0; } else { kp->flagx = 1; } } else if (keyx == kp->flagx) { if(keyx) { input_report_key(input, BUTTON_X, 1); input_mt_sync(input); kp->flagx = 0; printk("KEY X\n"); } else { input_report_key(input, BUTTON_X, 0); input_mt_sync(input); kp->flagx = 1; printk("KEY X release\n"); } } } if(keyy == keyy_old){ if (key_param[0]) { if(keyy) { key_report(kp, key_param[10], key_param[11], 5); kp->flagy = 0; } else { kp->flagy = 1; } } else if (keyy == kp->flagy) { if(keyy) { input_report_key(input, BUTTON_Y, 1); input_mt_sync(input); kp->flagy = 0; printk("KEY Y\n"); } else { input_report_key(input, BUTTON_Y, 0); input_mt_sync(input); kp->flagy = 1; printk("KEY Y release\n"); } } } keyl_old = keyl; keyr_old = keyr; keya_old = keya; keyb_old = keyb; keyx_old = keyx; keyy_old = keyy; }
static void tpd_suspend(struct early_suspend *h) { int ret = 0; int iRetry = 5; const char data = 0x3; //release all touch points input_report_key(tpd->dev, BTN_TOUCH, 0); input_mt_sync(tpd->dev); input_sync(tpd->dev); //NEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei #ifdef TPD_PROXIMITY if (tpd_proximity_flag == 1) { tpd_proximity_flag_one = 1; return; } #endif //END <touch panel> <DATE20130831> <tp proximity> zhangxiaofei if ( g_pts ){ CTP_DBG("TPD enter sleep\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); //mutex_lock(&g_pts->mutex);//Unlock on resume mutex_trylock(&g_pts->mutex);//Unlock on resume #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE fts_6x06_key_cancel(); #endif #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(2); #ifdef MT6577 hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #else hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #endif #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP //make sure the WakeUp is high before it enter sleep mode, //otherwise the touch can't be resumed. //mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE); //msleep(1); while (iRetry) { ret = i2c_smbus_write_i2c_block_data(g_pts->client, 0xA5, 1, &data); //TP enter sleep mode if ( ret < 0 ){ TPD_DMESG("Enter sleep mode is %d\n", ret); #ifdef MT6577 hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #else //hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); //mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ZERO); #endif msleep(2); fts_6x06_hw_init(); }else{ break; } iRetry--; msleep(100); } #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP #if 0//Android 4.0 don't need to report these up events. ft6x06_complete_unfinished_event(); #endif atomic_set( &g_pts->ts_sleepState, 1 ); } }
static long uibc_kbd_dev_ioctl(struct file * file, unsigned int cmd, unsigned long arg) { void __user *uarg = (void __user *)arg; static short XValue; static short YValue; short keycode; short touchPosition[16]; int err, i; pr_debug("uibc_kbd_dev_ioctl,cmd=%d\n", cmd); switch (cmd) { case UIBC_KEYBOARD: { uibc_input_dev->keycodemax = ARRAY_SIZE(uibc_keycode); for (i = 0; i < ARRAY_SIZE(uibckbd->keymap); i++) __set_bit(uibckbd->keymap[i], uibc_input_dev->keybit); err = input_register_device(uibc_input_dev); if (err) { pr_err("register input device failed (%d)\n", err); input_free_device(uibc_input_dev); return err; } uibc_registered = 1; break; } case UIBC_KEYBOARD_MIRACAST: { uibc_input_dev->keycodemax = ARRAY_SIZE(uibc_keycode_chars); for (i = 0; i < ARRAY_SIZE(uibc_keycode_chars); i++) __set_bit(uibc_keycode_chars[i], uibc_input_dev->keybit); err = input_register_device(uibc_input_dev); if (err) { pr_err("register input device failed (%d)\n", err); input_free_device(uibc_input_dev); return err; } uibc_registered = 1; break; } case UIBC_KEY_PRESS: { if (copy_from_user(&keycode, uarg, sizeof(keycode))) return -EFAULT; pr_debug("uibc keycode %d\n", keycode); input_report_key(uibc_input_dev, keycode, 1); input_sync(uibc_input_dev); break; } case UIBC_KEY_RELEASE: { if (copy_from_user(&keycode, uarg, sizeof(keycode))) return -EFAULT; input_report_key(uibc_input_dev, keycode, 0); input_sync(uibc_input_dev); break; } case UIBC_POINTER_X: { if (copy_from_user(&XValue, uarg, sizeof(XValue))) return -EFAULT; pr_debug("uibc pointer X %d\n", XValue); break; } case UIBC_POINTER_Y: { if (copy_from_user(&YValue, uarg, sizeof(YValue))) return -EFAULT; pr_debug("uibc pointer Y %d\n", YValue); input_report_rel(uibc_input_dev, REL_X, XValue); input_report_rel(uibc_input_dev, REL_Y, YValue); input_sync(uibc_input_dev); XValue = 0; YValue = 0; break; } case UIBC_TOUCH_DOWN: { if (copy_from_user(&touchPosition, uarg, sizeof(touchPosition))) return -EFAULT; pr_debug("uibc UIBC_TOUCH_DOWN id=%d,(%d,%d)\n", touchPosition[idVal(0)], touchPosition[xVal(0)], touchPosition[yVal(0)]); input_report_key(uibc_input_dev, BTN_TOUCH, 1); input_report_abs(uibc_input_dev, ABS_MT_TRACKING_ID, touchPosition[idVal(0)]); input_report_abs(uibc_input_dev, ABS_MT_POSITION_X, touchPosition[xVal(0)]); input_report_abs(uibc_input_dev, ABS_MT_POSITION_Y, touchPosition[yVal(0)]); input_mt_sync(uibc_input_dev); input_sync(uibc_input_dev); break; } case UIBC_TOUCH_UP: { if (copy_from_user(&touchPosition, uarg, sizeof(touchPosition))) return -EFAULT; pr_debug("uibc UIBC_TOUCH_UP"); input_report_key(uibc_input_dev, BTN_TOUCH, 0); input_sync(uibc_input_dev); break; } case UIBC_TOUCH_MOVE: { if (copy_from_user(&touchPosition, uarg, sizeof(touchPosition))) return -EFAULT; for (i = 0; i < MAX_POINTERS; i++) { if (touchPosition[xVal(i)] == 0 && touchPosition[yVal(i)] == 0) continue; input_report_abs(uibc_input_dev, ABS_MT_TRACKING_ID, touchPosition[idVal(i)]); input_report_abs(uibc_input_dev, ABS_MT_POSITION_X, touchPosition[xVal(i)]); input_report_abs(uibc_input_dev, ABS_MT_POSITION_Y, touchPosition[yVal(i)]); input_mt_sync(uibc_input_dev); } input_sync(uibc_input_dev); break; } default: return -EINVAL; } return 0; }
static void report_joystick_key(struct kp *kp) { int i; read_keys_value(kp); for (i = 0; i < keynum; i++) { if(gamekeys[i].value == gamekeys[i].old_value) { if (gamekeys[i].value == gamekeys[i].flag) { if(gamekeys[i].value) { //printk("%s press\n", gamekeys[i].name); #if L2_R2 input_report_key(kp->input_joystick, gamekeys[i].code, 1); input_mt_sync(kp->input_joystick); #else if((i == 6) || (i == 7)) { ; } else { input_report_key(kp->input_joystick, gamekeys[i].code, 1); input_mt_sync(kp->input_joystick); } #endif gamekeys[i].flag = 0; if(i == 6) brake = 0xff; if(i == 7) gas = 0xff; #if DPAD_AXIS if(i == 8) hatx = -0xff; else if(i == 9) hatx = 0xff; if(i == 10) haty = -0xff; else if(i == 11) haty = 0xff; #endif } else { //printk("%s release\n", gamekeys[i].name); #if L2_R2 input_report_key(kp->input_joystick, gamekeys[i].code, 0); input_mt_sync(kp->input_joystick); #else if((i == 6) || (i == 7)) { ; } else { input_report_key(kp->input_joystick, gamekeys[i].code, 0); input_mt_sync(kp->input_joystick); } #endif gamekeys[i].flag = 1; if(i == 6) brake = 0; if(i == 7) gas = 0; #if DPAD_AXIS if((i == 8) || (i == 9)) hatx = 0; if((i == 10) || (i == 11)) haty = 0; #endif } } } gamekeys[i].old_value = gamekeys[i].value; } }