static irqreturn_t wacom_interrupt_pdct(int irq, void *dev_id) { struct wacom_i2c *wac_i2c = dev_id; if (wac_i2c->query_status == false) return IRQ_HANDLED; wac_i2c->pen_pdct = gpio_get_value(wac_i2c->wac_pdata->gpio_pen_pdct); dev_info(&wac_i2c->client->dev, "%s: pdct %d(%d) [%s]\n", __func__, wac_i2c->pen_pdct, wac_i2c->pen_prox, wac_i2c->pen_pdct ? "Released" : "Pressed"); #ifdef CONFIG_TOUCH_WAKE if (touchwake_is_active() && !wac_i2c->pen_pdct) { #ifdef TOUCHWAKE_DEBUG_PRINT pr_info("[TOUCHWAKE] Wacom Pen pressed\n"); #endif touch_press(); // Yank555.lu - Screen touched by pen } #endif #if 0 if (wac_i2c->pen_pdct == PDCT_NOSIGNAL) { /* If rdy is 1, pen is still working*/ if (wac_i2c->pen_prox == 0) forced_release(wac_i2c); } else if (wac_i2c->pen_prox == 0) forced_hover(wac_i2c); #endif return IRQ_HANDLED; }
static irqreturn_t wacom_interrupt_pdct(int irq, void *dev_id) { struct wacom_i2c *wac_i2c = dev_id; if (wac_i2c->query_status == false) return IRQ_HANDLED; wac_i2c->pen_pdct = gpio_get_value(wac_i2c->wac_pdata->gpio_pendct); printk(KERN_DEBUG "[E-PEN] pdct %d(%d)\n", wac_i2c->pen_pdct, wac_i2c->pen_prox); if (wac_i2c->pen_pdct == PDCT_NOSIGNAL) { #ifdef WACOM_DISCARD_EVENT_ON_EDGE /* on edge, pen_prox can be zero even if hover event is released. */ if (wac_i2c->rdy_pdct == true && wac_i2c->pen_prox == 0) forced_release(wac_i2c); #else /* If rdy is 1, pen is still working*/ if (wac_i2c->pen_prox == 0) forced_release(wac_i2c); #endif } else if (wac_i2c->pen_prox == 0) forced_hover(wac_i2c); return IRQ_HANDLED; }
static irqreturn_t wacom_interrupt_pdct(int irq, void *dev_id) { struct wacom_i2c *wac_i2c = dev_id; wac_i2c->pen_pdct = gpio_get_value(wac_i2c->wac_pdata->gpio_pendct); printk(KERN_DEBUG "[E-PEN] pdct %d(%d)\n", wac_i2c->pen_pdct, wac_i2c->pen_prox); if (wac_i2c->pen_pdct == PDCT_NOSIGNAL) { /* If rdy is 1, pen is still working*/ if (wac_i2c->pen_prox == 0) forced_release(wac_i2c); } else if (wac_i2c->pen_prox == 0) forced_hover(wac_i2c); return IRQ_HANDLED; }
static irqreturn_t wacom_interrupt_pdct(int irq, void *dev_id) { struct wacom_i2c *wac_i2c = dev_id; if (wac_i2c->query_status == false) return IRQ_HANDLED; wac_i2c->pen_pdct = gpio_get_value(wac_i2c->wac_pdata->gpio_pen_pdct); dev_info(&wac_i2c->client->dev, "%s: pdct %d(%d) [%s]\n", __func__, wac_i2c->pen_pdct, wac_i2c->pen_prox, wac_i2c->pen_pdct ? "Released" : "Pressed"); #if 0 if (wac_i2c->pen_pdct == PDCT_NOSIGNAL) { /* If rdy is 1, pen is still working*/ if (wac_i2c->pen_prox == 0) forced_release(wac_i2c); } else if (wac_i2c->pen_prox == 0) forced_hover(wac_i2c); #endif return IRQ_HANDLED; }
int wacom_i2c_coord(struct wacom_i2c *wac_i2c) { bool prox = false; int ret = 0; u8 *data; int rubber, stylus; static u16 x, y, pressure; static u16 tmp; int rdy = 0; #ifdef WACOM_IRQ_WORK_AROUND cancel_delayed_work(&wac_i2c->pendct_dwork); #endif data = wac_i2c->wac_feature->data; ret = i2c_master_recv(wac_i2c->client, data, COM_COORD_NUM); if (ret < 0) { printk(KERN_ERR "[E-PEN] %s failed to read i2c.L%d\n", __func__, __LINE__); return -1; } #if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER) pr_debug("[E-PEN] %x, %x, %x, %x, %x, %x, %x\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6]); #endif if (data[0] & 0x80) { /* enable emr device */ if (!wac_i2c->pen_prox) { wac_i2c->pen_prox = 1; if (data[0] & 0x40) wac_i2c->tool = BTN_TOOL_RUBBER; else wac_i2c->tool = BTN_TOOL_PEN; #if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER) pr_debug("[E-PEN] is in(%d)\n", wac_i2c->tool); #endif } prox = !!(data[0] & 0x10); stylus = !!(data[0] & 0x20); rubber = !!(data[0] & 0x40); rdy = !!(data[0] & 0x80); x = ((u16) data[1] << 8) + (u16) data[2]; y = ((u16) data[3] << 8) + (u16) data[4]; pressure = ((u16) data[5] << 8) + (u16) data[6]; #ifdef WACOM_IMPORT_FW_ALGO /* Change Position to Active Area */ if (x <= origin_offset[0]) x = 0; else x = x - origin_offset[0]; if (y <= origin_offset[1]) y = 0; else y = y - origin_offset[1]; #ifdef COOR_WORK_AROUND wacom_i2c_coord_offset(&x, &y); wacom_i2c_coord_average(&x, &y, rdy); #endif #endif if (wac_i2c->wac_pdata->x_invert) x = wac_i2c->wac_feature->x_max - x; if (wac_i2c->wac_pdata->y_invert) y = wac_i2c->wac_feature->y_max - y; if (wac_i2c->wac_pdata->xy_switch) { tmp = x; x = y; y = tmp; } #ifdef COOR_WORK_AROUND /* Add offset */ x = x + tilt_offsetX[user_hand][screen_rotate]; y = y + tilt_offsetY[user_hand][screen_rotate]; #endif if (wacom_i2c_coord_range(&x, &y)) { input_report_abs(wac_i2c->input_dev, ABS_X, x); input_report_abs(wac_i2c->input_dev, ABS_Y, y); input_report_abs(wac_i2c->input_dev, ABS_PRESSURE, pressure); input_report_key(wac_i2c->input_dev, BTN_STYLUS, stylus); input_report_key(wac_i2c->input_dev, BTN_TOUCH, prox); input_report_key(wac_i2c->input_dev, wac_i2c->tool, 1); input_sync(wac_i2c->input_dev); if (prox && !wac_i2c->pen_pressed) { #ifdef CONFIG_SEC_TOUCHSCREEN_DVFS_LOCK set_dvfs_lock(wac_i2c, true); #endif #if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER) printk(KERN_DEBUG "[E-PEN] is pressed(%d,%d,%d)(%d)\n", x, y, pressure, wac_i2c->tool); #else printk(KERN_DEBUG "[E-PEN] pressed\n"); #endif } else if (!prox && wac_i2c->pen_pressed) { #ifdef CONFIG_SEC_TOUCHSCREEN_DVFS_LOCK set_dvfs_lock(wac_i2c, false); #endif #if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER) printk(KERN_DEBUG "[E-PEN] is released(%d,%d,%d)(%d)\n", x, y, pressure, wac_i2c->tool); #else printk(KERN_DEBUG "[E-PEN] released\n"); #endif } wac_i2c->pen_pressed = prox; if (stylus && !wac_i2c->side_pressed) printk(KERN_DEBUG "[E-PEN] side on\n"); else if (!stylus && wac_i2c->side_pressed) printk(KERN_DEBUG "[E-PEN] side off\n"); wac_i2c->side_pressed = stylus; } #if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER) else printk(KERN_DEBUG "[E-PEN] raw data x=0x%x, y=0x%x\n", x, y); #endif } else { #ifdef WACOM_IRQ_WORK_AROUND if (!gpio_get_value(wac_i2c->wac_pdata->gpio_pendct)) { x = ((u16) data[1] << 8) + (u16) data[2]; y = ((u16) data[3] << 8) + (u16) data[4]; if (data[0] & 0x40) wac_i2c->tool = BTN_TOOL_RUBBER; else wac_i2c->tool = BTN_TOOL_PEN; input_report_abs(wac_i2c->input_dev, ABS_X, x); input_report_abs(wac_i2c->input_dev, ABS_Y, y); input_report_abs(wac_i2c->input_dev, ABS_PRESSURE, 0); input_report_key(wac_i2c->input_dev, BTN_STYLUS, 0); input_report_key(wac_i2c->input_dev, BTN_TOUCH, 0); input_report_key(wac_i2c->input_dev, wac_i2c->tool, 1); input_sync(wac_i2c->input_dev); } schedule_delayed_work(&wac_i2c->pendct_dwork, HZ / 10); return 0; #else /* WACOM_IRQ_WORK_AROUND */ #ifdef COOR_WORK_AROUND /* enable emr device */ wacom_i2c_coord_average(0, 0, 0); #endif #ifdef WACOM_PDCT_WORK_AROUND if (wac_i2c->pen_pdct == PDCT_DETECT_PEN) forced_hover(wac_i2c); else #endif if (wac_i2c->pen_prox) { /* input_report_abs(wac->input_dev, ABS_X, x); */ /* input_report_abs(wac->input_dev, ABS_Y, y); */ input_report_abs(wac_i2c->input_dev, ABS_PRESSURE, 0); input_report_key(wac_i2c->input_dev, BTN_STYLUS, 0); input_report_key(wac_i2c->input_dev, BTN_TOUCH, 0); #if defined(WACOM_PDCT_WORK_AROUND) input_report_key(wac_i2c->input_dev, BTN_TOOL_RUBBER, 0); input_report_key(wac_i2c->input_dev, BTN_TOOL_PEN, 0); #else input_report_key(wac_i2c->input_dev, wac_i2c->tool, 0); #endif input_sync(wac_i2c->input_dev); printk(KERN_DEBUG "[E-PEN] is out"); } wac_i2c->pen_prox = 0; wac_i2c->pen_pressed = 0; wac_i2c->side_pressed = 0; #ifdef CONFIG_SEC_TOUCHSCREEN_DVFS_LOCK set_dvfs_lock(wac_i2c, false); #endif #endif } return 0; }