From patchwork Thu Dec 9 01:17:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 392632 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 oB91GiQU012924 for ; Thu, 9 Dec 2010 01:16:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752156Ab0LIBQn (ORCPT ); Wed, 8 Dec 2010 20:16:43 -0500 Received: from mail-gx0-f180.google.com ([209.85.161.180]:62091 "EHLO mail-gx0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751823Ab0LIBQn (ORCPT ); Wed, 8 Dec 2010 20:16:43 -0500 Received: by gxk19 with SMTP id 19so1028329gxk.11 for ; Wed, 08 Dec 2010 17:16:42 -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=0gDA0BNxPu0PWn38Y0qm7fyUBw8shCmp3p6ZuoT+7Zs=; b=gMpu4D+9r+kCy76zGPqW9gocbc1tfEOScqVx747Zyg/s4ttI0jtw+zzldwBzrdtrGY P2CSkBHPzYhUY0buZBkaRFFuCiC8Wm4YyQcswa4YeqBEZOZRd0nq1gJ2frEmJUJ+cQl3 Sxc1EQWTELkTd6FTdtbYA2Ocna+KwQKrzWTFY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=rAn4+4amIt39b7v6J90x8Qlex2GLV07JYntO+HnbQHB9Tkp0h3ftQZpYvZq2ObuMnH 5M3zvVVyC1SG6bGRmOI9IDz6W3LeP74ZGDUM+E5Jw3KiPES72YPxsVHCMcNmZQOKYqf1 2qbjHJGm9Rg5m9Bn0OehJPnAz13JjSlCJlPOo= Received: by 10.151.157.10 with SMTP id j10mr5201318ybo.147.1291857402136; Wed, 08 Dec 2010 17:16:42 -0800 (PST) Received: from localhost.localdomain ([204.119.25.150]) by mx.google.com with ESMTPS id v4sm1342ybe.5.2010.12.08.17.16.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 08 Dec 2010 17:16:41 -0800 (PST) From: Ping Cheng To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, Ping Cheng , Ping Cheng Subject: [PATCH 1/2]input - wacom_w8001: Support pen or touch only devices Date: Wed, 8 Dec 2010 17:17:13 -0800 Message-Id: <1291857433-13731-1-git-send-email-pinglinux@gmail.com> X-Mailer: git-send-email 1.7.2.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]); Thu, 09 Dec 2010 01:16:44 +0000 (UTC) diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 361d00a..90b92e8 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,46 @@ 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) { + dev->keybit[BIT_WORD(BTN_TOOL_PEN)] |= BIT_MASK(BTN_TOOL_PEN); + dev->keybit[BIT_WORD(BTN_TOOL_RUBBER)] |= BIT_MASK(BTN_TOOL_RUBBER); + dev->keybit[BIT_WORD(BTN_STYLUS)] |= BIT_MASK(BTN_STYLUS); + dev->keybit[BIT_WORD(BTN_STYLUS2)] |= BIT_MASK(BTN_STYLUS2); + 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); + dev->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER); + switch (touch.sensor_id) { case 0: case 2: