From patchwork Wed Dec 2 20:42:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Dyer X-Patchwork-Id: 7751781 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4BAB7BEEE1 for ; Wed, 2 Dec 2015 20:54:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 625B320532 for ; Wed, 2 Dec 2015 20:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CEEC203F1 for ; Wed, 2 Dec 2015 20:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757076AbbLBUxl (ORCPT ); Wed, 2 Dec 2015 15:53:41 -0500 Received: from kdh-gw.itdev.co.uk ([89.21.227.133]:22435 "EHLO hermes.kdh.itdev.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754437AbbLBUvR (ORCPT ); Wed, 2 Dec 2015 15:51:17 -0500 Received: from localhost.localdomain (unknown [80.229.148.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by hermes.kdh.itdev.co.uk (Postfix) with ESMTPSA id DAFB98099E; Wed, 2 Dec 2015 20:42:37 +0000 (GMT) From: Nick Dyer To: Dmitry Torokhov Cc: Yufeng Shen , Benson Leung , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Bowens , Javier Martinez Canillas , Chris Healy , Nick Dyer Subject: [PATCH RFC 6/8] Input: atmel_mxt_ts - Add support for reference data Date: Wed, 2 Dec 2015 20:42:29 +0000 Message-Id: <1449088951-7069-7-git-send-email-nick.dyer@itdev.co.uk> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1449088951-7069-1-git-send-email-nick.dyer@itdev.co.uk> References: <1449088951-7069-1-git-send-email-nick.dyer@itdev.co.uk> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are different datatypes available from a maXTouch chip. Add support to retrieve reference data as well. Signed-off-by: Nick Dyer --- drivers/input/touchscreen/atmel_mxt_ts.c | 78 ++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 6c9fbc0..49fbe2a 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -132,6 +132,7 @@ struct t9_range { /* MXT_DEBUG_DIAGNOSTIC_T37 */ #define MXT_DIAGNOSTIC_PAGEUP 0x01 #define MXT_DIAGNOSTIC_DELTAS 0x10 +#define MXT_DIAGNOSTIC_REFS 0x11 #define MXT_DIAGNOSTIC_SIZE 128 #define MXT_FAMILY_1386 160 @@ -211,6 +212,8 @@ enum t100_type { #define MXT_PIXELS_PER_MM 20 +struct mxt_data; + struct mxt_info { u8 family_id; u8 variant_id; @@ -230,6 +233,29 @@ struct mxt_object { } __packed; #ifdef CONFIG_DEBUG_FS +struct mxt_debug_datatype { + u8 mode; + char *name; +}; + +struct mxt_debug_datatype_meta { + struct mxt_data *data; + const struct mxt_debug_datatype *datatype; + struct dentry *dent; + void *buf; +}; + +static const struct mxt_debug_datatype datatypes[] = { + { + .mode = MXT_DIAGNOSTIC_REFS, + .name = "refs", + }, + { + .mode = MXT_DIAGNOSTIC_DELTAS, + .name = "deltas", + } +}; + struct mxt_dbg { u16 t37_address; u16 diag_cmd_address; @@ -240,6 +266,8 @@ struct mxt_dbg { struct dentry *debugfs_dir; struct dentry *deltas_file; + struct dentry *refs_file; + struct mxt_debug_datatype_meta dt_meta[ARRAY_SIZE(datatypes)]; }; #endif @@ -2166,14 +2194,15 @@ static void mxt_convert_debug_pages(struct mxt_data *data) } } -static int mxt_open_deltas(struct inode *inode, struct file *file) +static int mxt_dbg_open(struct inode *inode, struct file *file) { - struct mxt_data *data = inode->i_private; + struct mxt_debug_datatype_meta *dtm = inode->i_private; + struct mxt_data *data = dtm->data; struct mxt_dbg *dbg = &data->dbg; int retries = 0; int page; int ret; - u8 mode = MXT_DIAGNOSTIC_DELTAS; + u8 mode = dtm->datatype->mode; u8 cmd = mode; struct t37_debug *p; @@ -2218,24 +2247,23 @@ wait_cmd: } mxt_convert_debug_pages(data); - file->private_data = data; + file->private_data = dtm; return 0; } -static ssize_t mxt_read_deltas(struct file *file, char __user *ubuf, - size_t count, loff_t *offp) +static ssize_t mxt_dbg_read(struct file *file, char __user *ubuf, + size_t count, loff_t *offp) { - struct mxt_data *data = file->private_data; + struct mxt_debug_datatype_meta *dtm = file->private_data; - return simple_read_from_buffer(ubuf, count, offp, - data->dbg.debug_buf, - data->dbg.t37_nodes * sizeof(u16)); + return simple_read_from_buffer(ubuf, count, offp, dtm->buf, + dtm->dent->d_inode->i_size); } -static const struct file_operations atmel_mxt_deltas_fops = { - .open = mxt_open_deltas, - .read = mxt_read_deltas, +static const struct file_operations atmel_mxt_dbg_fops = { + .open = mxt_dbg_open, + .read = mxt_dbg_read, }; static void mxt_debugfs_remove(struct mxt_data *data) @@ -2248,7 +2276,10 @@ static void mxt_debugfs_init(struct mxt_data *data) struct mxt_info *info = &data->info; struct mxt_dbg *dbg = &data->dbg; struct mxt_object *object; + struct dentry *dent; + struct mxt_debug_datatype_meta *dtm; char dirname[50]; + int i; object = mxt_get_object(data, MXT_GEN_COMMAND_T6); if (!object) @@ -2299,11 +2330,22 @@ static void mxt_debugfs_init(struct mxt_data *data) if (!dbg->t37_buf) goto error; - dbg->deltas_file = debugfs_create_file("deltas", S_IRUGO, - dbg->debugfs_dir, data, - &atmel_mxt_deltas_fops); - if (!dbg->deltas_file) - goto error; + for (i = 0; i < ARRAY_SIZE(datatypes); i++) { + dtm = &data->dbg.dt_meta[i]; + + dtm->data = data; + dtm->datatype = datatypes + i; + dtm->buf = dbg->debug_buf; + + dent = debugfs_create_file(datatypes[i].name, + S_IRUGO, dbg->debugfs_dir, + dtm, &atmel_mxt_dbg_fops); + if (!dent) + goto error; + + dtm->dent = dent; + dent->d_inode->i_size = dbg->t37_nodes * sizeof(u16); + } dbg->deltas_file->d_inode->i_size = dbg->t37_nodes * sizeof(u16);