From patchwork Fri Dec 17 17:37:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 416671 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBHHaT1Q019773 for ; Fri, 17 Dec 2010 17:36:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754818Ab0LQRg3 (ORCPT ); Fri, 17 Dec 2010 12:36:29 -0500 Received: from mail-gw0-f42.google.com ([74.125.83.42]:38606 "EHLO mail-gw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754753Ab0LQRg2 (ORCPT ); Fri, 17 Dec 2010 12:36:28 -0500 Received: by gwb20 with SMTP id 20so601647gwb.1 for ; Fri, 17 Dec 2010 09:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=Ti+EMQDBmJGOeBhRAmx3U0bEKd7irR+A0BfLj9zUfSI=; b=VfAXm4CCp5iOq0tRZsgdJXRc9EJXghGTvlwNGcALFJjb0ACYeqZvqPxEJi1Ru/caHu a3GnljPEqq/9zRakBMLWPkul76ZTF6H0/IHt4owVETFUGAPPCJZLf+/+iL9okuNOlO7/ 0gQrWMHsUzm5AJsI/PFdhENPyu1da8gLLn86w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=P2WCzRU65tTicQMoDlwT5M42Ki4JNJeX1y43BoUztwO7vIWN9xm9bQMuMuZwW8bqUS Z2NDq9PFszgy60W9Mhgi2ZT5vDyzTS0Fw7qzjo7Z4wBZIzXHCEmECRpGWy3VwfFpDi7Z auitiF4V/MIdcNPLabLjl76u//1wDmvM1knZQ= Received: by 10.151.154.8 with SMTP id g8mr3131726ybo.322.1292607387824; Fri, 17 Dec 2010 09:36:27 -0800 (PST) Received: from localhost.localdomain ([204.119.25.150]) by mx.google.com with ESMTPS id v4sm5662085ybe.5.2010.12.17.09.36.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 17 Dec 2010 09:36:26 -0800 (PST) From: Ping Cheng To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, Ping Cheng , Ping Cheng Subject: [PATCH 2/3 v2] input - wacom_w8001: Support pen or touch only devices Date: Fri, 17 Dec 2010 09:37:00 -0800 Message-Id: <1292607420-22638-1-git-send-email-pinglinux@gmail.com> X-Mailer: git-send-email 1.7.3.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 17 Dec 2010 17:36:29 +0000 (UTC) diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 49bce13..59664a8 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -37,6 +37,7 @@ MODULE_LICENSE("GPL"); #define W8001_QUERY_PACKET 0x20 +#define W8001_CMD_STOP '0' #define W8001_CMD_START '1' #define W8001_CMD_QUERY '*' #define W8001_CMD_TOUCHQUERY '%' @@ -279,24 +280,45 @@ static int w8001_setup(struct w8001 *w8001) struct w8001_coord coord; int error; - error = w8001_command(w8001, W8001_CMD_QUERY, true); + error = w8001_command(w8001, W8001_CMD_STOP, false); if (error) return error; - parse_data(w8001->response, &coord); + mdelay(250); /* wait 250ms before querying the device */ - input_set_abs_params(dev, ABS_X, 0, coord.x, 0, 0); - input_set_abs_params(dev, ABS_Y, 0, coord.y, 0, 0); - input_set_abs_params(dev, ABS_PRESSURE, 0, coord.pen_pressure, 0, 0); - input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0); - input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0); + /* penabled? */ + error = w8001_command(w8001, W8001_CMD_QUERY, true); + if (!error) { + __set_bit(BTN_TOOL_PEN, dev->keybit); + __set_bit(BTN_TOOL_RUBBER, dev->keybit); + __set_bit(BTN_STYLUS, dev->keybit); + __set_bit(BTN_STYLUS2, dev->keybit); + parse_data(w8001->response, &coord); + + input_set_abs_params(dev, ABS_X, 0, coord.x, 0, 0); + input_set_abs_params(dev, ABS_Y, 0, coord.y, 0, 0); + input_set_abs_params(dev, ABS_PRESSURE, 0, coord.pen_pressure, 0, 0); + if (coord.tilt_x && coord.tilt_y) { + input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0); + input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0); + } + } + /* touch enabled? */ error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); - if (!error) { + + /* Some non-touch devices may reply to the touch query. But their + * second byte is empty, which indicates touch is not supported. + */ + if (!error && w8001->response[1]) { struct w8001_touch_query touch; parse_touchquery(w8001->response, &touch); + input_set_abs_params(dev, ABS_X, 0, touch.x, 0, 0); + input_set_abs_params(dev, ABS_Y, 0, touch.y, 0, 0); + __set_bit(BTN_TOOL_FINGER, dev->keybit); + switch (touch.sensor_id) { case 0: case 2: @@ -375,10 +397,6 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv) input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); __set_bit(BTN_TOUCH, input_dev->keybit); - __set_bit(BTN_TOOL_PEN, input_dev->keybit); - __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); - __set_bit(BTN_STYLUS, input_dev->keybit); - __set_bit(BTN_STYLUS2, input_dev->keybit); serio_set_drvdata(serio, w8001); err = serio_open(serio, drv);