linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Dyer <nick.dyer@itdev.co.uk>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Yufeng Shen <miletus@google.com>,
	Benson Leung <bleung@chromium.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alan Bowens <Alan.Bowens@atmel.com>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Chris Healy <cphealy@gmail.com>,
	Nick Dyer <nick.dyer@itdev.co.uk>
Subject: [PATCH RFC 6/8] Input: atmel_mxt_ts - Add support for reference data
Date: Wed,  2 Dec 2015 20:42:29 +0000	[thread overview]
Message-ID: <1449088951-7069-7-git-send-email-nick.dyer@itdev.co.uk> (raw)
In-Reply-To: <1449088951-7069-1-git-send-email-nick.dyer@itdev.co.uk>

There are different datatypes available from a maXTouch chip. Add
support to retrieve reference data as well.

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
 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);
 
-- 
2.5.0


  parent reply	other threads:[~2015-12-02 20:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 20:42 [PATCH RFC 0/8] Input: atmel_mxt_ts - raw data via debugfs Nick Dyer
2015-12-02 20:42 ` [PATCH RFC 1/8] Input: atmel_mxt_ts - improve touchscreen size/orientation handling Nick Dyer
2015-12-02 20:42 ` [PATCH RFC 2/8] Input: atmel_mxt_ts - add diagnostic data retrieval via debugfs Nick Dyer
2015-12-02 20:42 ` [PATCH RFC 3/8] Input: atmel_mxt_ts - read touchscreen position in matrix Nick Dyer
2015-12-02 20:42 ` [PATCH RFC 4/8] Input: atmel_mxt_ts - handle diagnostic data orientation Nick Dyer
2015-12-02 20:42 ` [PATCH RFC 5/8] Input: atmel_mxt_ts - add diagnostic data support for mXT1386 Nick Dyer
2015-12-02 20:42 ` Nick Dyer [this message]
2015-12-02 20:42 ` [PATCH RFC 7/8] Input: atmel_mxt_ts - add metadata to debugfs Nick Dyer
2015-12-02 20:42 ` [PATCH RFC 8/8] Input: atmel_mxt_ts - create debugfs info file Nick Dyer
2015-12-17 17:22 ` [PATCH RFC 0/8] Input: atmel_mxt_ts - raw data via debugfs Nick Dyer
2016-01-11 23:24   ` Dmitry Torokhov
2016-01-12  8:10     ` Benjamin Tissoires
2016-01-13 17:20       ` Nick Dyer
2016-01-13 18:40         ` Dmitry Torokhov
     [not found]           ` <CAFXsbZrJg75Z1jRYmzac9grr5Oqqtq4gW9Cs8aDh15wvBjrKNg@mail.gmail.com>
2016-01-13 20:42             ` Henrik Rydberg
2016-02-08 21:38               ` Nick Dyer
2016-03-10 14:08           ` Nick Dyer
2016-01-13 18:35       ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449088951-7069-7-git-send-email-nick.dyer@itdev.co.uk \
    --to=nick.dyer@itdev.co.uk \
    --cc=Alan.Bowens@atmel.com \
    --cc=bleung@chromium.org \
    --cc=cphealy@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=javier@osg.samsung.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miletus@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).