From patchwork Mon May 23 13:55:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Just X-Patchwork-Id: 9132351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8965D6075F for ; Mon, 23 May 2016 20:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DCFE28248 for ; Mon, 23 May 2016 20:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7242528250; Mon, 23 May 2016 20:13:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 176E228248 for ; Mon, 23 May 2016 20:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754576AbcEWUNW (ORCPT ); Mon, 23 May 2016 16:13:22 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34664 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754428AbcEWUNU (ORCPT ); Mon, 23 May 2016 16:13:20 -0400 X-Greylist: delayed 1005 seconds by postgrey-1.27 at vger.kernel.org; Mon, 23 May 2016 16:13:20 EDT Received: by mail-it0-f67.google.com with SMTP id k76so6212944ita.1 for ; Mon, 23 May 2016 13:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8PWlgr4532ZwgJM8vlgzaAQ16zfrmdgRPy+NN4rXGnA=; b=Z0n4un2hh7spDaz3hk+8Hho/1M0rqwfuu+Ub0btzk6/5gPS3tXUTU/ozyKTpCVuo6q m9Rm19Af/x1iYjmgcMZVn6gCOw/XXrWRXDV8EoTWg4r3OTcBE1faWDSA2d9Y3aGoi25T kw9/qP35aPbF8EAJUHsbzAg/Lo00SX0rpZJQ1oJ2v+IgcBTKT4BPnplUFaKzjAC5ovZO e4Ee9GLzHd4n4NHLBXR33dCEAAvIMtXzFqScxJVdnmGsLkiOSlZ4Uurry9RVbgWTPCl0 skt2lGtTklTRjuaQ4Hi7zubMgW6sjTNDxY/g0MEqLy2sV1fZOXblUNsjGUlvLYBoIww+ 30KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8PWlgr4532ZwgJM8vlgzaAQ16zfrmdgRPy+NN4rXGnA=; b=Tishq0MgXjwMcYIysz/hyfogRPpJAhBaargFDIe9sJ/9t7karvNrLJrRP7Cb2CiTYC NnMG9F3zDf/NgYnTWjX3R7YEQk1HBQ2iR1yVdguAmU+Eu6UeKrOCZD9wugroXdy/0+VS /a//4hhshOz63rKm6cPHa3wbhALCRxVNoHX3nswmscq3KEQgSPWM0J4JMnjdWEiyqN+F npbf1c1+uVgLqVFy7mmSOT9p13AD0jQte2X0MG6IyU91P9F054/BrEX9Z/nPf06RBcTd EnDCfmeoXwrbdCB24fqYpZZ6RcqH+jzKfSrpPZqF0TGoVGwHD7vU76g43Ls2HF29IJ9V Mi7w== X-Gm-Message-State: ALyK8tIHi5n0yMcF4Dd/MVjnqt9H5kZ3+OJpaiEQZkH88mhybOB1RqZQ/6MhDZS3AHQtYg== X-Received: by 10.36.217.79 with SMTP id p76mr6031644itg.38.1464033394707; Mon, 23 May 2016 12:56:34 -0700 (PDT) Received: from arch_usb.localdomain (S0106c0c1c0256baf.ed.shawcable.net. [70.74.127.58]) by smtp.gmail.com with ESMTPSA id k8sm4273124igf.7.2016.05.23.12.56.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 May 2016 12:56:34 -0700 (PDT) From: Stephen Just To: linux-input@vger.kernel.org, Dmitry Torokhov , Benjamin Tissoires Cc: Stephen Just , Bastien Nocera Subject: [PATCH 1/2] Input - surface3_spi: Prepare to add support for Surface Pen Date: Mon, 23 May 2016 07:55:33 -0600 Message-Id: <1464011734-18657-2-git-send-email-stephenjust@gmail.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1464011734-18657-1-git-send-email-stephenjust@gmail.com> References: <1464011734-18657-1-git-send-email-stephenjust@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Surface Pens can be supported by handling a second report type. Prepare for this change. Signed-off-by: Stephen Just --- drivers/input/touchscreen/surface3_spi.c | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen/surface3_spi.c b/drivers/input/touchscreen/surface3_spi.c index 58631d1..204a162 100644 --- a/drivers/input/touchscreen/surface3_spi.c +++ b/drivers/input/touchscreen/surface3_spi.c @@ -27,6 +27,8 @@ #define SURFACE3_PACKET_SIZE 264 +#define SURFACE3_REPORT_TOUCH 0xd2 + struct surface3_ts_data { struct spi_device *spi; struct gpio_desc *gpiod_rst[2]; @@ -84,19 +86,10 @@ static void surface3_spi_report_touch(struct surface3_ts_data *ts_data, } } -static void surface3_spi_process(struct surface3_ts_data *ts_data) +static void surface3_spi_process_touch(struct surface3_ts_data *ts_data, u8 *data) { - const char header[] = {0xff, 0xff, 0xff, 0xff, 0xa5, 0x5a, 0xe7, 0x7e, - 0x01, 0xd2, 0x00, 0x80, 0x01, 0x03, 0x03}; - u8 *data = ts_data->rd_buf; u16 timestamp; unsigned int i; - - if (memcmp(header, data, sizeof(header))) - dev_err(&ts_data->spi->dev, - "%s header error: %*ph, ignoring...\n", - __func__, (int)sizeof(header), data); - timestamp = get_unaligned_le16(&data[15]); for (i = 0; i < 13; i++) { @@ -121,6 +114,25 @@ static void surface3_spi_process(struct surface3_ts_data *ts_data) input_sync(ts_data->input_dev); } +static void surface3_spi_process(struct surface3_ts_data *ts_data) +{ + const char header[] = {0xff, 0xff, 0xff, 0xff, 0xa5, 0x5a, 0xe7, 0x7e, 0x01}; + + u8 *data = ts_data->rd_buf; + + if (memcmp(header, data, sizeof(header))) + dev_err(&ts_data->spi->dev, + "%s header error: %*ph, ignoring...\n", + __func__, (int)sizeof(header), data); + + if (data[9] == SURFACE3_REPORT_TOUCH) + surface3_spi_process_touch(ts_data, data); + else + dev_err(&ts_data->spi->dev, + "%s unknown packet type: %x, ignoring...\n", + __func__, data[9]); +} + static irqreturn_t surface3_spi_irq_handler(int irq, void *dev_id) { struct surface3_ts_data *data = dev_id; @@ -176,7 +188,7 @@ static int surface3_spi_get_gpio_config(struct surface3_ts_data *data) return 0; } -static int surface3_spi_create_input(struct surface3_ts_data *data) +static int surface3_spi_create_touch_input(struct surface3_ts_data *data) { struct input_dev *input; int error; @@ -199,7 +211,7 @@ static int surface3_spi_create_input(struct surface3_ts_data *data) input->phys = "input/ts"; input->id.bustype = BUS_SPI; input->id.vendor = 0x045e; /* Microsoft */ - input->id.product = 0x0000; + input->id.product = 0x0001; input->id.version = 0x0000; error = input_register_device(input); @@ -239,7 +251,7 @@ static int surface3_spi_probe(struct spi_device *spi) surface3_spi_power(data, false); surface3_spi_power(data, true); - error = surface3_spi_create_input(data); + error = surface3_spi_create_touch_input(data); if (error) return error;