Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1297861 > unrolled thread
| Started by | Nick Dyer <nick.dyer@itdev.co.uk> |
|---|---|
| First post | 2015-12-24 15:00 +0100 |
| Last post | 2015-12-24 15:00 +0100 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH RFC v2 0/8] Input: atmel_mxt_ts - raw data via debugfs Nick Dyer <nick.dyer@itdev.co.uk> - 2015-12-24 15:00 +0100
[PATCH RFC v2 4/9] Input: atmel_mxt_ts - handle diagnostic data orientation Nick Dyer <nick.dyer@itdev.co.uk> - 2015-12-24 15:00 +0100
[PATCH RFC v2 6/9] Input: atmel_mxt_ts - add support for reference data Nick Dyer <nick.dyer@itdev.co.uk> - 2015-12-24 15:00 +0100
[PATCH RFC v2 3/9] Input: atmel_mxt_ts - read touchscreen position in matrix Nick Dyer <nick.dyer@itdev.co.uk> - 2015-12-24 15:00 +0100
| From | Nick Dyer <nick.dyer@itdev.co.uk> |
|---|---|
| Date | 2015-12-24 15:00 +0100 |
| Subject | [PATCH RFC v2 0/8] Input: atmel_mxt_ts - raw data via debugfs |
| Message-ID | <qJeAW-7mT-3@gated-at.bofh.it> |
Hello-
This is an updated series of patches to add diagnostic data support to the
Atmel maXTouch driver.
There's an existing implementation in the open-source mxt-app tool, however
there are performance advantages to moving this code into the driver. The
algorithm for retrieving the data has been fairly consistent across a range of
chips, with the exception of the mXT1386 series (see patch). It would be good
if we could agree a single debugfs interface which could be supported by all
touchscreen chips that have this kind of feature, so I've attempted to
keep that part of this vendor neutral.
Changes since v1:
* adding a way to retrieve a single node at high performance
* adding some locking
* switching to using seq_file.
* numerous minor refactorings
This patch sequence is also available from:
https://github.com/ndyer/linux/commits/diagnostic-debug
A utility to display this data has now been released, and you can find it at:
https://github.com/ndyer/heatmap
I've recorded a couple of videos of the utility in action on a Pixel 2:
https://youtu.be/M0VD2gZt8Zk and https://youtu.be/nwDLB4zikzU
Any feedback appreciated.
Best regards
Nick Dyer
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Nick Dyer <nick.dyer@itdev.co.uk> |
|---|---|
| Date | 2015-12-24 15:00 +0100 |
| Subject | [PATCH RFC v2 4/9] Input: atmel_mxt_ts - handle diagnostic data orientation |
| Message-ID | <qJeAW-7mT-17@gated-at.bofh.it> |
| In reply to | #1297861 |
Invert the diagnostic data to match the orientation of the input device.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index a177019..48bf9ec 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -122,6 +122,8 @@ struct t9_range {
/* MXT_TOUCH_MULTI_T9 orient */
#define MXT_T9_ORIENT_SWITCH (1 << 0)
+#define MXT_T9_ORIENT_INVERTX (1 << 1)
+#define MXT_T9_ORIENT_INVERTY (1 << 2)
/* MXT_SPT_COMMSCONFIG_T18 */
#define MXT_COMMS_CTRL 0
@@ -153,6 +155,8 @@ struct t37_debug {
#define MXT_T100_YRANGE 24
#define MXT_T100_CFG_SWITCHXY BIT(5)
+#define MXT_T100_CFG_INVERTY BIT(6)
+#define MXT_T100_CFG_INVERTX BIT(7)
#define MXT_T100_TCHAUX_VECT BIT(0)
#define MXT_T100_TCHAUX_AMPL BIT(1)
@@ -244,7 +248,9 @@ struct mxt_data {
unsigned int irq;
unsigned int max_x;
unsigned int max_y;
- bool xy_switch;
+ bool invertx;
+ bool inverty;
+ bool xyswitch;
u8 xsize;
u8 ysize;
bool in_bootloader;
@@ -1720,7 +1726,9 @@ static int mxt_read_t9_resolution(struct mxt_data *data)
if (error)
return error;
- data->xy_switch = orient & MXT_T9_ORIENT_SWITCH;
+ data->xyswitch = orient & MXT_T9_ORIENT_SWITCH;
+ data->invertx = orient & MXT_T9_ORIENT_INVERTX;
+ data->inverty = orient & MXT_T9_ORIENT_INVERTY;
return 0;
}
@@ -1774,7 +1782,9 @@ static int mxt_read_t100_config(struct mxt_data *data)
if (error)
return error;
- data->xy_switch = cfg & MXT_T100_CFG_SWITCHXY;
+ data->xyswitch = cfg & MXT_T100_CFG_SWITCHXY;
+ data->invertx = cfg & MXT_T100_CFG_INVERTX;
+ data->inverty = cfg & MXT_T100_CFG_INVERTY;
/* allocate aux bytes */
error = __mxt_read_reg(client,
@@ -1863,7 +1873,7 @@ static int mxt_initialize_input_device(struct mxt_data *data)
if (data->max_y == 0)
data->max_y = 1023;
- if (data->xy_switch)
+ if (data->xyswitch)
swap(data->max_x, data->max_y);
dev_info(dev, "Touchscreen size X%uY%u\n", data->max_x, data->max_y);
@@ -2119,15 +2129,21 @@ static void mxt_convert_debug_pages(struct seq_file *s, struct mxt_data *data)
struct mxt_dbg *dbg = &data->dbg;
unsigned int x = 0;
unsigned int y = 0;
- unsigned int i;
+ unsigned int i, rx, ry;
u16 val;
for (i = 0; i < dbg->t37_nodes; i++) {
- val = mxt_get_debug_value(data, x, y);
+ /* Handle orientation */
+ rx = data->xyswitch ? y : x;
+ ry = data->xyswitch ? x : y;
+ rx = data->invertx ? (data->xsize - 1 - rx) : rx;
+ ry = data->inverty ? (data->ysize - 1 - ry) : ry;
+
+ val = mxt_get_debug_value(data, rx, ry);
seq_write(s, &val, sizeof(u16));
/* Next value */
- if (++x >= data->xsize) {
+ if (++x >= (data->xyswitch ? data->ysize : data->xsize)) {
x = 0;
y++;
}
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nick Dyer <nick.dyer@itdev.co.uk> |
|---|---|
| Date | 2015-12-24 15:00 +0100 |
| Subject | [PATCH RFC v2 6/9] Input: atmel_mxt_ts - add support for reference data |
| Message-ID | <qJeAW-7mT-21@gated-at.bofh.it> |
| In reply to | #1297861 |
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 | 75 +++++++++++++++++++++++++-------
1 file changed, 59 insertions(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index a2f11836..bccd7bc 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,27 @@ struct mxt_object {
} __packed;
#ifdef CONFIG_DEBUG_FS
+struct mxt_debug_datatype {
+ u8 mode;
+ char *name;
+};
+
+struct mxt_debug_entry {
+ struct mxt_data *data;
+ const struct mxt_debug_datatype *datatype;
+};
+
+static const struct mxt_debug_datatype mxt_dbg_datatypes[] = {
+ {
+ .mode = MXT_DIAGNOSTIC_REFS,
+ .name = "refs",
+ },
+ {
+ .mode = MXT_DIAGNOSTIC_DELTAS,
+ .name = "deltas",
+ },
+};
+
struct mxt_dbg {
u16 t37_address;
u16 diag_cmd_address;
@@ -238,6 +262,8 @@ struct mxt_dbg {
unsigned int t37_nodes;
struct dentry *debugfs_dir;
+ struct mxt_debug_entry entries[ARRAY_SIZE(mxt_dbg_datatypes)];
+ struct mutex dbg_mutex;
};
#endif
@@ -2142,7 +2168,7 @@ static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x,
return get_unaligned_le16(&dbg->t37_buf[page].data[ofs]);
}
-static void mxt_convert_debug_pages(struct seq_file *s, struct mxt_data *data)
+static int mxt_convert_debug_pages(struct seq_file *s, struct mxt_data *data)
{
struct mxt_dbg *dbg = &data->dbg;
unsigned int x = 0;
@@ -2166,26 +2192,31 @@ static void mxt_convert_debug_pages(struct seq_file *s, struct mxt_data *data)
y++;
}
}
+
+ return 0;
}
static int mxt_read_diagnostic_debug(struct seq_file *s, void *d)
{
- struct mxt_data *data = dev_get_drvdata(s->private);
+ struct mxt_debug_entry *e = s->private;
+ struct mxt_data *data = e->data;
struct mxt_dbg *dbg = &data->dbg;
int retries = 0;
int page;
int ret;
- u8 mode = MXT_DIAGNOSTIC_DELTAS;
+ u8 mode = e->datatype->mode;
u8 cmd = mode;
struct t37_debug *p;
+ mutex_lock(&dbg->dbg_mutex);
+
for (page = 0; page < dbg->t37_pages; page++) {
p = dbg->t37_buf + page;
ret = mxt_write_reg(data->client, dbg->diag_cmd_address,
cmd);
if (ret)
- return ret;
+ goto release;
retries = 0;
@@ -2196,7 +2227,7 @@ wait_cmd:
ret = __mxt_read_reg(data->client, dbg->t37_address,
2, p);
if (ret)
- return ret;
+ goto release;
if ((p->mode != mode) || (p->page != page)) {
if (retries++ > 100)
@@ -2210,7 +2241,7 @@ wait_cmd:
ret = __mxt_read_reg(data->client, dbg->t37_address,
sizeof(struct t37_debug), p);
if (ret)
- return ret;
+ goto release;
dev_dbg(&data->client->dev, "%s page:%d retries:%d\n",
__func__, page, retries);
@@ -2219,17 +2250,19 @@ wait_cmd:
cmd = MXT_DIAGNOSTIC_PAGEUP;
}
- mxt_convert_debug_pages(s, data);
+ ret = mxt_convert_debug_pages(s, data);
- return 0;
+release:
+ mutex_unlock(&dbg->dbg_mutex);
+ return ret;
}
static int mxt_debugfs_data_open(struct inode *inode, struct file *f)
{
- struct mxt_data *data = inode->i_private;
- size_t size = data->dbg.t37_nodes * sizeof(u16);
+ struct mxt_debug_entry *e = inode->i_private;
+ size_t size = e->data->dbg.t37_nodes * sizeof(u16);
- return single_open_size(f, mxt_read_diagnostic_debug, data, size);
+ return single_open_size(f, mxt_read_diagnostic_debug, e, size);
}
static const struct file_operations mxt_debugfs_data_ops = {
@@ -2252,6 +2285,8 @@ static void mxt_debugfs_init(struct mxt_data *data)
struct mxt_object *object;
char dirname[50];
struct dentry *dent;
+ struct mxt_debug_entry *e;
+ int i;
object = mxt_get_object(data, MXT_GEN_COMMAND_T6);
if (!object)
@@ -2297,11 +2332,19 @@ static void mxt_debugfs_init(struct mxt_data *data)
if (!dbg->t37_buf)
goto error;
- dent = debugfs_create_file("deltas", S_IRUGO,
- dbg->debugfs_dir, data,
- &mxt_debugfs_data_ops);
- if (!dent)
- goto error;
+ for (i = 0; i < ARRAY_SIZE(mxt_dbg_datatypes); i++) {
+ e = &dbg->entries[i];
+ e->data = data;
+ e->datatype = mxt_dbg_datatypes + i;
+
+ dent = debugfs_create_file(mxt_dbg_datatypes[i].name, S_IRUGO,
+ dbg->debugfs_dir, e,
+ &mxt_debugfs_data_ops);
+ if (!dent)
+ goto error;
+ }
+
+ mutex_init(&dbg->dbg_mutex);
return;
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nick Dyer <nick.dyer@itdev.co.uk> |
|---|---|
| Date | 2015-12-24 15:00 +0100 |
| Subject | [PATCH RFC v2 3/9] Input: atmel_mxt_ts - read touchscreen position in matrix |
| Message-ID | <qJeAX-7mT-23@gated-at.bofh.it> |
| In reply to | #1297861 |
The touchscreen may have a margin where not all the matrix is used. Read
the parameters from T9 and T100 and take account of the difference.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 41 ++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 96000f4..a177019 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -100,6 +100,8 @@ struct t7_config {
/* MXT_TOUCH_MULTI_T9 field */
#define MXT_T9_CTRL 0
+#define MXT_T9_XSIZE 3
+#define MXT_T9_YSIZE 4
#define MXT_T9_ORIENT 9
#define MXT_T9_RANGE 18
@@ -145,7 +147,9 @@ struct t37_debug {
#define MXT_T100_CTRL 0
#define MXT_T100_CFG1 1
#define MXT_T100_TCHAUX 3
+#define MXT_T100_XSIZE 9
#define MXT_T100_XRANGE 13
+#define MXT_T100_YSIZE 20
#define MXT_T100_YRANGE 24
#define MXT_T100_CFG_SWITCHXY BIT(5)
@@ -241,6 +245,8 @@ struct mxt_data {
unsigned int max_x;
unsigned int max_y;
bool xy_switch;
+ u8 xsize;
+ u8 ysize;
bool in_bootloader;
u16 mem_size;
u8 t100_aux_ampl;
@@ -1688,6 +1694,18 @@ static int mxt_read_t9_resolution(struct mxt_data *data)
return -EINVAL;
error = __mxt_read_reg(client,
+ object->start_address + MXT_T9_XSIZE,
+ sizeof(data->xsize), &data->xsize);
+ if (error)
+ return error;
+
+ error = __mxt_read_reg(client,
+ object->start_address + MXT_T9_YSIZE,
+ sizeof(data->ysize), &data->ysize);
+ if (error)
+ return error;
+
+ error = __mxt_read_reg(client,
object->start_address + MXT_T9_RANGE,
sizeof(range), &range);
if (error)
@@ -1737,6 +1755,18 @@ static int mxt_read_t100_config(struct mxt_data *data)
data->max_y = get_unaligned_le16(&range_y);
+ error = __mxt_read_reg(client,
+ object->start_address + MXT_T100_XSIZE,
+ sizeof(data->xsize), &data->xsize);
+ if (error)
+ return error;
+
+ error = __mxt_read_reg(client,
+ object->start_address + MXT_T100_YSIZE,
+ sizeof(data->ysize), &data->ysize);
+ if (error)
+ return error;
+
/* read orientation config */
error = __mxt_read_reg(client,
object->start_address + MXT_T100_CFG1,
@@ -2077,7 +2107,7 @@ static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x,
struct mxt_dbg *dbg = &data->dbg;
unsigned int ofs, page;
- ofs = (y + (x * (data->info.matrix_ysize))) * sizeof(u16);
+ ofs = (y + (x * data->info.matrix_ysize)) * sizeof(u16);
page = ofs / MXT_DIAGNOSTIC_SIZE;
ofs %= MXT_DIAGNOSTIC_SIZE;
@@ -2097,7 +2127,7 @@ static void mxt_convert_debug_pages(struct seq_file *s, struct mxt_data *data)
seq_write(s, &val, sizeof(u16));
/* Next value */
- if (++x >= data->info.matrix_xsize) {
+ if (++x >= data->xsize) {
x = 0;
y++;
}
@@ -2216,9 +2246,10 @@ static void mxt_debugfs_init(struct mxt_data *data)
}
/* Calculate size of data and allocate buffer */
- dbg->t37_nodes = data->info.matrix_xsize * data->info.matrix_ysize;
- dbg->t37_pages = dbg->t37_nodes * sizeof(u16)
- / sizeof(dbg->t37_buf->data) + 1;
+ dbg->t37_nodes = data->xsize * data->ysize;
+ dbg->t37_pages = ((data->xsize * data->info.matrix_ysize)
+ * sizeof(u16) / sizeof(dbg->t37_buf->data)) + 1;
+
dbg->t37_buf = devm_kzalloc(&data->client->dev,
sizeof(struct t37_debug) * dbg->t37_pages,
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web