linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
@ 2016-04-21  9:31 Nick Dyer
  2016-04-21  9:31 ` [PATCH 1/8] Input: atmel_mxt_ts - add support for T37 diagnostic data Nick Dyer
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler

This is a series of patches to add diagnostic data support to the Atmel
maXTouch driver. It's a rewrite of the previous implementation which output via
debugfs: it now uses a V4L2 device in a similar way to the sur40 driver.

There are significant performance advantages to putting 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).

We have a utility which can read the data and display it in a useful format:
	https://github.com/ndyer/heatmap/commits/heatmap-v4l

These patches are also available from
	https://github.com/ndyer/linux/commits/diagnostic-v4l

Any feedback appreciated.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/8] Input: atmel_mxt_ts - add support for T37 diagnostic data
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21  9:31 ` [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device Nick Dyer
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

Add function to retrieve raw references data from the diagnostic data
object

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 152 +++++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 2160512..0784a18 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -124,6 +124,17 @@ struct t9_range {
 #define MXT_COMMS_CTRL		0
 #define MXT_COMMS_CMD		1
 
+/* MXT_DEBUG_DIAGNOSTIC_T37 */
+#define MXT_DIAGNOSTIC_PAGEUP 0x01
+#define MXT_DIAGNOSTIC_DELTAS 0x10
+#define MXT_DIAGNOSTIC_SIZE    128
+
+struct t37_debug {
+	u8 mode;
+	u8 page;
+	u8 data[MXT_DIAGNOSTIC_SIZE];
+};
+
 /* Define for MXT_GEN_COMMAND_T6 */
 #define MXT_BOOT_VALUE		0xa5
 #define MXT_RESET_VALUE		0x01
@@ -205,6 +216,14 @@ struct mxt_object {
 	u8 num_report_ids;
 } __packed;
 
+struct mxt_dbg {
+	u16 t37_address;
+	u16 diag_cmd_address;
+	struct t37_debug *t37_buf;
+	unsigned int t37_pages;
+	unsigned int t37_nodes;
+};
+
 /* Each client has this additional data */
 struct mxt_data {
 	struct i2c_client *client;
@@ -233,6 +252,7 @@ struct mxt_data {
 	u8 num_touchids;
 	u8 multitouch;
 	struct t7_config t7_cfg;
+	struct mxt_dbg dbg;
 
 	/* Cached parameters from object table */
 	u16 T5_address;
@@ -2043,6 +2063,136 @@ recheck:
 	return 0;
 }
 
+static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x,
+			       unsigned int y)
+{
+	struct mxt_dbg *dbg = &data->dbg;
+	unsigned int ofs, page;
+
+	ofs = (y + (x * data->info.matrix_ysize)) * sizeof(u16);
+	page = ofs / MXT_DIAGNOSTIC_SIZE;
+	ofs %= MXT_DIAGNOSTIC_SIZE;
+
+	return get_unaligned_le16(&dbg->t37_buf[page].data[ofs]);
+}
+
+static int mxt_convert_debug_pages(struct mxt_data *data, u16 *outbuf)
+{
+	struct mxt_dbg *dbg = &data->dbg;
+	unsigned int x = 0;
+	unsigned int y = 0;
+	unsigned int i;
+
+	for (i = 0; i < dbg->t37_nodes; i++) {
+		outbuf[i] = mxt_get_debug_value(data, x, y);
+
+		/* Next value */
+		if (++x >= data->info.matrix_xsize) {
+			x = 0;
+			y++;
+		}
+	}
+
+	return 0;
+}
+
+static int mxt_read_diagnostic_debug(struct mxt_data *data, u8 mode,
+				     u16 *outbuf)
+{
+	struct mxt_dbg *dbg = &data->dbg;
+	int retries = 0;
+	int page;
+	int ret;
+	u8 cmd = mode;
+	struct t37_debug *p;
+	u8 cmd_poll;
+
+	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;
+
+		retries = 0;
+		msleep(20);
+wait_cmd:
+		/* Read back command byte */
+		ret = __mxt_read_reg(data->client, dbg->diag_cmd_address,
+				     sizeof(cmd_poll), &cmd_poll);
+		if (ret)
+			return ret;
+
+		/* Field is cleared once the command has been processed */
+		if (cmd_poll) {
+			if (retries++ > 100)
+				return -EINVAL;
+
+			msleep(20);
+			goto wait_cmd;
+		}
+
+		/* Read T37 page */
+		ret = __mxt_read_reg(data->client, dbg->t37_address,
+				sizeof(struct t37_debug), p);
+		if (ret)
+			return ret;
+
+		if ((p->mode != mode) || (p->page != page)) {
+			dev_err(&data->client->dev, "T37 page mismatch\n");
+			return -EINVAL;
+		}
+
+		dev_dbg(&data->client->dev, "%s page:%d retries:%d\n",
+			__func__, page, retries);
+
+		/* For remaining pages, write PAGEUP rather than mode */
+		cmd = MXT_DIAGNOSTIC_PAGEUP;
+	}
+
+	return mxt_convert_debug_pages(data, outbuf);
+}
+
+static void mxt_debug_init(struct mxt_data *data)
+{
+	struct mxt_dbg *dbg = &data->dbg;
+	struct mxt_object *object;
+
+	object = mxt_get_object(data, MXT_GEN_COMMAND_T6);
+	if (!object)
+		return;
+
+	dbg->diag_cmd_address = object->start_address + MXT_COMMAND_DIAGNOSTIC;
+
+	object = mxt_get_object(data, MXT_DEBUG_DIAGNOSTIC_T37);
+	if (!object)
+		return;
+
+	if (mxt_obj_size(object) != sizeof(struct t37_debug)) {
+		dev_warn(&data->client->dev, "Bad T37 size");
+		return;
+	}
+
+	dbg->t37_address = object->start_address;
+
+	/* 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_buf = devm_kzalloc(&data->client->dev,
+				     sizeof(struct t37_debug) * dbg->t37_pages,
+				     GFP_KERNEL);
+	if (!dbg->t37_buf)
+		goto error;
+
+	return;
+
+error:
+	dev_err(&data->client->dev, "Error initialising T37 diagnostic data\n");
+}
+
 static int mxt_configure_objects(struct mxt_data *data,
 				 const struct firmware *cfg)
 {
@@ -2070,6 +2220,8 @@ static int mxt_configure_objects(struct mxt_data *data,
 		dev_warn(dev, "No touch object detected\n");
 	}
 
+	mxt_debug_init(data);
+
 	dev_info(dev,
 		 "Family: %u Variant: %u Firmware V%u.%u.%02X Objects: %u\n",
 		 info->family_id, info->variant_id, info->version >> 4,
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
  2016-04-21  9:31 ` [PATCH 1/8] Input: atmel_mxt_ts - add support for T37 diagnostic data Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21 11:04   ` kbuild test robot
                     ` (2 more replies)
  2016-04-21  9:31 ` [PATCH 3/8] Input: atmel_mxt_ts - read touchscreen size Nick Dyer
                   ` (6 subsequent siblings)
  8 siblings, 3 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 270 +++++++++++++++++++++++++++++++
 1 file changed, 270 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 0784a18..81eecf1 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -28,6 +28,10 @@
 #include <linux/of.h>
 #include <linux/slab.h>
 #include <asm/unaligned.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-ioctl.h>
+#include <media/videobuf2-v4l2.h>
+#include <media/videobuf2-vmalloc.h>
 
 /* Firmware files */
 #define MXT_FW_NAME		"maxtouch.fw"
@@ -222,6 +226,23 @@ struct mxt_dbg {
 	struct t37_debug *t37_buf;
 	unsigned int t37_pages;
 	unsigned int t37_nodes;
+
+	struct v4l2_device v4l2;
+	struct v4l2_pix_format format;
+	struct video_device vdev;
+	struct vb2_queue queue;
+	struct mutex lock;
+	int input;
+};
+
+static const struct v4l2_file_operations mxt_video_fops = {
+	.owner = THIS_MODULE,
+	.open = v4l2_fh_open,
+	.release = vb2_fop_release,
+	.unlocked_ioctl = video_ioctl2,
+	.read = vb2_fop_read,
+	.mmap = vb2_fop_mmap,
+	.poll = vb2_fop_poll,
 };
 
 /* Each client has this additional data */
@@ -277,6 +298,11 @@ struct mxt_data {
 	struct completion crc_completion;
 };
 
+struct mxt_vb2_buffer {
+	struct vb2_buffer	vb;
+	struct list_head	list;
+};
+
 static size_t mxt_obj_size(const struct mxt_object *obj)
 {
 	return obj->size_minus_one + 1;
@@ -1523,6 +1549,9 @@ static void mxt_free_input_device(struct mxt_data *data)
 
 static void mxt_free_object_table(struct mxt_data *data)
 {
+	video_unregister_device(&data->dbg.vdev);
+	v4l2_device_unregister(&data->dbg.v4l2);
+
 	kfree(data->object_table);
 	data->object_table = NULL;
 	kfree(data->msg_buf);
@@ -2154,10 +2183,215 @@ wait_cmd:
 	return mxt_convert_debug_pages(data, outbuf);
 }
 
+static int mxt_queue_setup(struct vb2_queue *q,
+		       unsigned int *nbuffers, unsigned int *nplanes,
+		       unsigned int sizes[], void *alloc_ctxs[])
+{
+	struct mxt_data *data = q->drv_priv;
+
+	*nbuffers = 1;
+	*nplanes = 1;
+	sizes[0] = data->dbg.t37_nodes * sizeof(u16);
+
+	return 0;
+}
+
+static int mxt_buffer_prepare(struct vb2_buffer *vb)
+{
+	return 0;
+}
+
+static void mxt_buffer_queue(struct vb2_buffer *vb)
+{
+	struct mxt_data *data = vb2_get_drv_priv(vb->vb2_queue);
+	u16 *ptr;
+	int ret;
+
+	ptr = vb2_plane_vaddr(vb, 0);
+	if (!ptr) {
+		dev_err(&data->client->dev, "Error acquiring frame ptr\n");
+		goto fault;
+	}
+
+	ret = mxt_read_diagnostic_debug(data, MXT_DIAGNOSTIC_DELTAS, ptr);
+	if (ret)
+		goto fault;
+
+	vb2_set_plane_payload(vb, 0, data->dbg.t37_nodes * sizeof(u16));
+	vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
+	return;
+
+fault:
+	vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
+}
+
+/* V4L2 structures */
+static const struct vb2_ops mxt_queue_ops = {
+	.queue_setup		= mxt_queue_setup,
+	.buf_prepare		= mxt_buffer_prepare,
+	.buf_queue		= mxt_buffer_queue,
+	.wait_prepare		= vb2_ops_wait_prepare,
+	.wait_finish		= vb2_ops_wait_finish,
+};
+
+static const struct vb2_queue mxt_queue = {
+	.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+	.io_modes = VB2_MMAP,
+	.buf_struct_size = sizeof(struct mxt_vb2_buffer),
+	.ops = &mxt_queue_ops,
+	.mem_ops = &vb2_vmalloc_memops,
+	.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC,
+	.min_buffers_needed = 1,
+};
+
+static int mxt_vidioc_querycap(struct file *file, void *priv,
+				 struct v4l2_capability *cap)
+{
+	struct mxt_data *data = video_drvdata(file);
+
+	strlcpy(cap->driver, "atmel_mxt_ts", sizeof(cap->driver));
+	strlcpy(cap->card, "atmel_mxt_ts touch", sizeof(cap->card));
+	strlcpy(cap->bus_info, data->phys, sizeof(cap->bus_info));
+	cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
+		V4L2_CAP_READWRITE |
+		V4L2_CAP_STREAMING;
+	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
+
+	return 0;
+}
+
+static int mxt_vidioc_enum_input(struct file *file, void *priv,
+				   struct v4l2_input *i)
+{
+	if (i->index > 0)
+		return -EINVAL;
+
+	i->type = V4L2_INPUT_TYPE_CAMERA;
+	i->std = V4L2_STD_UNKNOWN;
+	i->capabilities = 0;
+	strlcpy(i->name, "Mutual References", sizeof(i->name));
+	return 0;
+}
+
+static int mxt_set_input(struct mxt_data *data, unsigned int i)
+{
+	struct v4l2_pix_format *f = &data->dbg.format;
+
+	if (i > 0)
+		return -EINVAL;
+
+	f->width = data->info.matrix_xsize;
+	f->height = data->info.matrix_ysize;
+	f->pixelformat = V4L2_PIX_FMT_Y16;
+	f->field = V4L2_FIELD_NONE;
+	f->colorspace = V4L2_COLORSPACE_SRGB;
+	f->bytesperline = f->width * sizeof(u16);
+	f->sizeimage = f->width * f->height * sizeof(u16);
+
+	data->dbg.input = i;
+
+	return 0;
+}
+
+static int mxt_vidioc_s_input(struct file *file, void *priv, unsigned int i)
+{
+	return mxt_set_input(video_drvdata(file), i);
+}
+
+static int mxt_vidioc_g_input(struct file *file, void *priv, unsigned int *i)
+{
+	struct mxt_data *data = video_drvdata(file);
+
+	*i = data->dbg.input;
+
+	return 0;
+}
+
+static int mxt_vidioc_fmt(struct file *file, void *priv, struct v4l2_format *f)
+{
+	struct mxt_data *data = video_drvdata(file);
+
+	f->fmt.pix = data->dbg.format;
+
+	return 0;
+}
+
+static int mxt_vidioc_enum_fmt(struct file *file, void *priv,
+				 struct v4l2_fmtdesc *fmt)
+{
+	if (fmt->index > 0 || fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;
+
+	fmt->pixelformat = V4L2_PIX_FMT_Y16;
+	strlcpy(fmt->description, "16-bit raw debug data",
+		sizeof(fmt->description));
+	fmt->flags = 0;
+	return 0;
+}
+
+static int mxt_vidioc_enum_framesizes(struct file *file, void *priv,
+					struct v4l2_frmsizeenum *f)
+{
+	struct mxt_data *data = video_drvdata(file);
+
+	if (f->index > 0)
+		return -EINVAL;
+
+	f->discrete.width = data->info.matrix_xsize;
+	f->discrete.height = data->info.matrix_ysize;
+	f->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+	return 0;
+}
+
+static int mxt_vidioc_enum_frameintervals(struct file *file, void *priv,
+					  struct v4l2_frmivalenum *f)
+{
+	if ((f->index > 0) || (f->pixel_format != V4L2_PIX_FMT_Y16))
+		return -EINVAL;
+
+	f->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+	f->discrete.denominator  = 10;
+	f->discrete.numerator = 1;
+	return 0;
+}
+
+static const struct v4l2_ioctl_ops mxt_video_ioctl_ops = {
+	.vidioc_querycap        = mxt_vidioc_querycap,
+
+	.vidioc_enum_fmt_vid_cap = mxt_vidioc_enum_fmt,
+	.vidioc_s_fmt_vid_cap   = mxt_vidioc_fmt,
+	.vidioc_g_fmt_vid_cap   = mxt_vidioc_fmt,
+
+	.vidioc_enum_framesizes = mxt_vidioc_enum_framesizes,
+	.vidioc_enum_frameintervals = mxt_vidioc_enum_frameintervals,
+
+	.vidioc_enum_input      = mxt_vidioc_enum_input,
+	.vidioc_g_input         = mxt_vidioc_g_input,
+	.vidioc_s_input         = mxt_vidioc_s_input,
+
+	.vidioc_reqbufs         = vb2_ioctl_reqbufs,
+	.vidioc_create_bufs     = vb2_ioctl_create_bufs,
+	.vidioc_querybuf        = vb2_ioctl_querybuf,
+	.vidioc_qbuf            = vb2_ioctl_qbuf,
+	.vidioc_dqbuf           = vb2_ioctl_dqbuf,
+	.vidioc_expbuf          = vb2_ioctl_expbuf,
+
+	.vidioc_streamon        = vb2_ioctl_streamon,
+	.vidioc_streamoff       = vb2_ioctl_streamoff,
+};
+
+static const struct video_device mxt_video_device = {
+	.name = "Atmel maxTouch",
+	.fops = &mxt_video_fops,
+	.ioctl_ops = &mxt_video_ioctl_ops,
+	.release = video_device_release_empty,
+};
+
 static void mxt_debug_init(struct mxt_data *data)
 {
 	struct mxt_dbg *dbg = &data->dbg;
 	struct mxt_object *object;
+	int error;
 
 	object = mxt_get_object(data, MXT_GEN_COMMAND_T6);
 	if (!object)
@@ -2187,8 +2421,44 @@ static void mxt_debug_init(struct mxt_data *data)
 	if (!dbg->t37_buf)
 		goto error;
 
+	/* init channel to zero */
+	mxt_set_input(data, 0);
+
+	/* register video device */
+	snprintf(dbg->v4l2.name, sizeof(dbg->v4l2.name), "%s", "atmel_mxt_ts");
+	error = v4l2_device_register(&data->client->dev, &dbg->v4l2);
+	if (error) {
+		dev_err(&data->client->dev, "Unable to register video master device.");
+		goto error;
+	}
+
+	/* initialize the queue */
+	mutex_init(&dbg->lock);
+	dbg->queue = mxt_queue;
+	dbg->queue.drv_priv = data;
+	dbg->queue.lock = &dbg->lock;
+
+	error = vb2_queue_init(&dbg->queue);
+	if (error)
+		goto error_unreg_v4l2;
+
+	dbg->vdev = mxt_video_device;
+	dbg->vdev.v4l2_dev = &dbg->v4l2;
+	dbg->vdev.lock = &dbg->lock;
+	dbg->vdev.queue = &dbg->queue;
+	video_set_drvdata(&dbg->vdev, data);
+
+	error = video_register_device(&dbg->vdev, VFL_TYPE_GRABBER, -1);
+	if (error) {
+		dev_err(&data->client->dev,
+				"Unable to register video subdevice.");
+		goto error_unreg_v4l2;
+	}
+
 	return;
 
+error_unreg_v4l2:
+	v4l2_device_unregister(&dbg->v4l2);
 error:
 	dev_err(&data->client->dev, "Error initialising T37 diagnostic data\n");
 }
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/8] Input: atmel_mxt_ts - read touchscreen size
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
  2016-04-21  9:31 ` [PATCH 1/8] Input: atmel_mxt_ts - add support for T37 diagnostic data Nick Dyer
  2016-04-21  9:31 ` [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21  9:31 ` [PATCH 4/8] Input: atmel_mxt_ts - handle diagnostic data orientation Nick Dyer
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

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.

Note: this does not read the XORIGIN/YORIGIN fields so it assumes that
the touchscreen starts at (0,0)

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 47 ++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 81eecf1..bcace51 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -103,6 +103,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
 
@@ -148,7 +150,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)
@@ -257,6 +261,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;
@@ -1710,6 +1716,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)
@@ -1759,6 +1777,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,
@@ -2116,7 +2146,7 @@ static int mxt_convert_debug_pages(struct mxt_data *data, u16 *outbuf)
 		outbuf[i] = mxt_get_debug_value(data, x, y);
 
 		/* Next value */
-		if (++x >= data->info.matrix_xsize) {
+		if (++x >= data->xsize) {
 			x = 0;
 			y++;
 		}
@@ -2280,8 +2310,8 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i)
 	if (i > 0)
 		return -EINVAL;
 
-	f->width = data->info.matrix_xsize;
-	f->height = data->info.matrix_ysize;
+	f->width = data->xsize;
+	f->height = data->ysize;
 	f->pixelformat = V4L2_PIX_FMT_Y16;
 	f->field = V4L2_FIELD_NONE;
 	f->colorspace = V4L2_COLORSPACE_SRGB;
@@ -2337,8 +2367,8 @@ static int mxt_vidioc_enum_framesizes(struct file *file, void *priv,
 	if (f->index > 0)
 		return -EINVAL;
 
-	f->discrete.width = data->info.matrix_xsize;
-	f->discrete.height = data->info.matrix_ysize;
+	f->discrete.width = data->xsize;
+	f->discrete.height = data->ysize;
 	f->type = V4L2_FRMSIZE_TYPE_DISCRETE;
 	return 0;
 }
@@ -2411,9 +2441,10 @@ static void mxt_debug_init(struct mxt_data *data)
 	dbg->t37_address = object->start_address;
 
 	/* 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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/8] Input: atmel_mxt_ts - handle diagnostic data orientation
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
                   ` (2 preceding siblings ...)
  2016-04-21  9:31 ` [PATCH 3/8] Input: atmel_mxt_ts - read touchscreen size Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21  9:31 ` [PATCH 5/8] Input: atmel_mxt_ts - add diagnostic data support for mXT1386 Nick Dyer
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

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 bcace51..3dd312f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -125,6 +125,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
@@ -156,6 +158,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)
@@ -260,6 +264,8 @@ struct mxt_data {
 	unsigned int irq;
 	unsigned int max_x;
 	unsigned int max_y;
+	bool invertx;
+	bool inverty;
 	bool xy_switch;
 	u8 xsize;
 	u8 ysize;
@@ -1743,6 +1749,8 @@ static int mxt_read_t9_resolution(struct mxt_data *data)
 		return error;
 
 	data->xy_switch = orient & MXT_T9_ORIENT_SWITCH;
+	data->invertx = orient & MXT_T9_ORIENT_INVERTX;
+	data->inverty = orient & MXT_T9_ORIENT_INVERTY;
 
 	return 0;
 }
@@ -1797,6 +1805,8 @@ static int mxt_read_t100_config(struct mxt_data *data)
 		return error;
 
 	data->xy_switch = 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,
@@ -2140,13 +2150,19 @@ static int mxt_convert_debug_pages(struct mxt_data *data, u16 *outbuf)
 	struct mxt_dbg *dbg = &data->dbg;
 	unsigned int x = 0;
 	unsigned int y = 0;
-	unsigned int i;
+	unsigned int i, rx, ry;
 
 	for (i = 0; i < dbg->t37_nodes; i++) {
-		outbuf[i] = mxt_get_debug_value(data, x, y);
+		/* Handle orientation */
+		rx = data->xy_switch ? y : x;
+		ry = data->xy_switch ? x : y;
+		rx = data->invertx ? (data->xsize - 1 - rx) : rx;
+		ry = data->inverty ? (data->ysize - 1 - ry) : ry;
+
+		outbuf[i] = mxt_get_debug_value(data, rx, ry);
 
 		/* Next value */
-		if (++x >= data->xsize) {
+		if (++x >= (data->xy_switch ? data->ysize : data->xsize)) {
 			x = 0;
 			y++;
 		}
@@ -2310,8 +2326,8 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i)
 	if (i > 0)
 		return -EINVAL;
 
-	f->width = data->xsize;
-	f->height = data->ysize;
+	f->width = data->xy_switch ? data->ysize : data->xsize;
+	f->height = data->xy_switch ? data->xsize : data->ysize;
 	f->pixelformat = V4L2_PIX_FMT_Y16;
 	f->field = V4L2_FIELD_NONE;
 	f->colorspace = V4L2_COLORSPACE_SRGB;
@@ -2367,8 +2383,8 @@ static int mxt_vidioc_enum_framesizes(struct file *file, void *priv,
 	if (f->index > 0)
 		return -EINVAL;
 
-	f->discrete.width = data->xsize;
-	f->discrete.height = data->ysize;
+	f->discrete.width = data->xy_switch ? data->ysize : data->xsize;
+	f->discrete.height = data->xy_switch ? data->xsize : data->ysize;
 	f->type = V4L2_FRMSIZE_TYPE_DISCRETE;
 	return 0;
 }
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 5/8] Input: atmel_mxt_ts - add diagnostic data support for mXT1386
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
                   ` (3 preceding siblings ...)
  2016-04-21  9:31 ` [PATCH 4/8] Input: atmel_mxt_ts - handle diagnostic data orientation Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21  9:31 ` [PATCH 6/8] Input: atmel_mxt_ts - add support for reference data Nick Dyer
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

The mXT1386 family of chips have a different architecture which splits
the diagnostic data into 3 columns.

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 3dd312f..bac0aa0 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -137,6 +137,10 @@ struct t9_range {
 #define MXT_DIAGNOSTIC_DELTAS 0x10
 #define MXT_DIAGNOSTIC_SIZE    128
 
+#define MXT_FAMILY_1386			160
+#define MXT1386_COLUMNS			3
+#define MXT1386_PAGES_PER_COLUMN	8
+
 struct t37_debug {
 	u8 mode;
 	u8 page;
@@ -2135,13 +2139,27 @@ recheck:
 static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x,
 			       unsigned int y)
 {
+	struct mxt_info *info = &data->info;
 	struct mxt_dbg *dbg = &data->dbg;
 	unsigned int ofs, page;
+	unsigned int col = 0;
+	unsigned int col_width;
+
+	if (info->family_id == MXT_FAMILY_1386) {
+		col_width = info->matrix_ysize / MXT1386_COLUMNS;
+		col = y / col_width;
+		y = y % col_width;
+	} else {
+		col_width = info->matrix_ysize;
+	}
 
-	ofs = (y + (x * data->info.matrix_ysize)) * sizeof(u16);
+	ofs = (y + (x * col_width)) * sizeof(u16);
 	page = ofs / MXT_DIAGNOSTIC_SIZE;
 	ofs %= MXT_DIAGNOSTIC_SIZE;
 
+	if (info->family_id == MXT_FAMILY_1386)
+		page += col * MXT1386_PAGES_PER_COLUMN;
+
 	return get_unaligned_le16(&dbg->t37_buf[page].data[ofs]);
 }
 
@@ -2435,6 +2453,7 @@ static const struct video_device mxt_video_device = {
 
 static void mxt_debug_init(struct mxt_data *data)
 {
+	struct mxt_info *info = &data->info;
 	struct mxt_dbg *dbg = &data->dbg;
 	struct mxt_object *object;
 	int error;
@@ -2458,9 +2477,13 @@ static void mxt_debug_init(struct mxt_data *data)
 
 	/* Calculate size of data and allocate buffer */
 	dbg->t37_nodes = data->xsize * data->ysize;
-	dbg->t37_pages = ((data->xsize * data->info.matrix_ysize)
-			  * sizeof(u16) / sizeof(dbg->t37_buf->data)) + 1;
 
+	if (info->family_id == MXT_FAMILY_1386)
+		dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN;
+	else
+		dbg->t37_pages = ((data->xsize * 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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 6/8] Input: atmel_mxt_ts - add support for reference data
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
                   ` (4 preceding siblings ...)
  2016-04-21  9:31 ` [PATCH 5/8] Input: atmel_mxt_ts - add diagnostic data support for mXT1386 Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21  9:31 ` [PATCH 7/8] Input: atmel_mxt_ts - single node diagnostic data support Nick Dyer
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

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 | 36 ++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index bac0aa0..6a35d94 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -135,6 +135,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
@@ -247,6 +248,12 @@ struct mxt_dbg {
 	int input;
 };
 
+enum v4l_dbg_inputs {
+	MXT_V4L_INPUT_DELTAS,
+	MXT_V4L_INPUT_REFS,
+	MXT_V4L_INPUT_MAX,
+};
+
 static const struct v4l2_file_operations mxt_video_fops = {
 	.owner = THIS_MODULE,
 	.open = v4l2_fh_open,
@@ -2270,6 +2277,7 @@ static void mxt_buffer_queue(struct vb2_buffer *vb)
 	struct mxt_data *data = vb2_get_drv_priv(vb->vb2_queue);
 	u16 *ptr;
 	int ret;
+	u8 mode;
 
 	ptr = vb2_plane_vaddr(vb, 0);
 	if (!ptr) {
@@ -2277,7 +2285,18 @@ static void mxt_buffer_queue(struct vb2_buffer *vb)
 		goto fault;
 	}
 
-	ret = mxt_read_diagnostic_debug(data, MXT_DIAGNOSTIC_DELTAS, ptr);
+	switch (data->dbg.input) {
+	case MXT_V4L_INPUT_DELTAS:
+	default:
+		mode = MXT_DIAGNOSTIC_DELTAS;
+		break;
+
+	case MXT_V4L_INPUT_REFS:
+		mode = MXT_DIAGNOSTIC_REFS;
+		break;
+	}
+
+	ret = mxt_read_diagnostic_debug(data, mode, ptr);
 	if (ret)
 		goto fault;
 
@@ -2327,13 +2346,22 @@ static int mxt_vidioc_querycap(struct file *file, void *priv,
 static int mxt_vidioc_enum_input(struct file *file, void *priv,
 				   struct v4l2_input *i)
 {
-	if (i->index > 0)
+	if (i->index >= MXT_V4L_INPUT_MAX)
 		return -EINVAL;
 
 	i->type = V4L2_INPUT_TYPE_CAMERA;
 	i->std = V4L2_STD_UNKNOWN;
 	i->capabilities = 0;
-	strlcpy(i->name, "Mutual References", sizeof(i->name));
+
+	switch (i->index) {
+	case MXT_V4L_INPUT_REFS:
+		strlcpy(i->name, "Mutual References", sizeof(i->name));
+		break;
+	case MXT_V4L_INPUT_DELTAS:
+		strlcpy(i->name, "Mutual Deltas", sizeof(i->name));
+		break;
+	}
+
 	return 0;
 }
 
@@ -2341,7 +2369,7 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i)
 {
 	struct v4l2_pix_format *f = &data->dbg.format;
 
-	if (i > 0)
+	if (i >= MXT_V4L_INPUT_MAX)
 		return -EINVAL;
 
 	f->width = data->xy_switch ? data->ysize : data->xsize;
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 7/8] Input: atmel_mxt_ts - single node diagnostic data support
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
                   ` (5 preceding siblings ...)
  2016-04-21  9:31 ` [PATCH 6/8] Input: atmel_mxt_ts - add support for reference data Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-21  9:31 ` [PATCH 8/8] Input: atmel_mxt_ts - add v4l pixelformat definition for touch refs output Nick Dyer
  2016-04-22  8:26 ` [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Hans Verkuil
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

Add support for retrieving a single node of data at high rate.
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 79 ++++++++++++++++++++++++++++----
 1 file changed, 70 insertions(+), 9 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 6a35d94..3bb1179 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -239,6 +239,7 @@ struct mxt_dbg {
 	struct t37_debug *t37_buf;
 	unsigned int t37_pages;
 	unsigned int t37_nodes;
+	unsigned int single_node_ofs;
 
 	struct v4l2_device v4l2;
 	struct v4l2_pix_format format;
@@ -251,6 +252,8 @@ struct mxt_dbg {
 enum v4l_dbg_inputs {
 	MXT_V4L_INPUT_DELTAS,
 	MXT_V4L_INPUT_REFS,
+	MXT_V4L_INPUT_DELTAS_SINGLE,
+	MXT_V4L_INPUT_REFS_SINGLE,
 	MXT_V4L_INPUT_MAX,
 };
 
@@ -2197,17 +2200,19 @@ static int mxt_convert_debug_pages(struct mxt_data *data, u16 *outbuf)
 }
 
 static int mxt_read_diagnostic_debug(struct mxt_data *data, u8 mode,
-				     u16 *outbuf)
+				     u16 *outbuf, bool single_node)
 {
 	struct mxt_dbg *dbg = &data->dbg;
 	int retries = 0;
 	int page;
+	int pages = single_node ? 1 : dbg->t37_pages;
 	int ret;
 	u8 cmd = mode;
 	struct t37_debug *p;
 	u8 cmd_poll;
 
-	for (page = 0; page < dbg->t37_pages; page++) {
+
+	for (page = 0; page < pages; page++) {
 		p = dbg->t37_buf + page;
 
 		ret = mxt_write_reg(data->client, dbg->diag_cmd_address,
@@ -2251,7 +2256,15 @@ wait_cmd:
 		cmd = MXT_DIAGNOSTIC_PAGEUP;
 	}
 
-	return mxt_convert_debug_pages(data, outbuf);
+	if (single_node) {
+		*outbuf = get_unaligned_le16(&dbg->t37_buf[0]
+					     .data[dbg->single_node_ofs]);
+		ret = 0;
+	} else {
+		ret = mxt_convert_debug_pages(data, outbuf);
+	}
+
+	return ret;
 }
 
 static int mxt_queue_setup(struct vb2_queue *q,
@@ -2278,6 +2291,7 @@ static void mxt_buffer_queue(struct vb2_buffer *vb)
 	u16 *ptr;
 	int ret;
 	u8 mode;
+	bool single_node = false;
 
 	ptr = vb2_plane_vaddr(vb, 0);
 	if (!ptr) {
@@ -2286,17 +2300,21 @@ static void mxt_buffer_queue(struct vb2_buffer *vb)
 	}
 
 	switch (data->dbg.input) {
+	case MXT_V4L_INPUT_DELTAS_SINGLE:
+		single_node = true; /* fall through */
 	case MXT_V4L_INPUT_DELTAS:
 	default:
 		mode = MXT_DIAGNOSTIC_DELTAS;
 		break;
 
+	case MXT_V4L_INPUT_REFS_SINGLE:
+		single_node = true; /* fall through */
 	case MXT_V4L_INPUT_REFS:
 		mode = MXT_DIAGNOSTIC_REFS;
 		break;
 	}
 
-	ret = mxt_read_diagnostic_debug(data, mode, ptr);
+	ret = mxt_read_diagnostic_debug(data, mode, ptr, single_node);
 	if (ret)
 		goto fault;
 
@@ -2360,6 +2378,12 @@ static int mxt_vidioc_enum_input(struct file *file, void *priv,
 	case MXT_V4L_INPUT_DELTAS:
 		strlcpy(i->name, "Mutual Deltas", sizeof(i->name));
 		break;
+	case MXT_V4L_INPUT_REFS_SINGLE:
+		strlcpy(i->name, "Single node refs", sizeof(i->name));
+		break;
+	case MXT_V4L_INPUT_DELTAS_SINGLE:
+		strlcpy(i->name, "Single node deltas", sizeof(i->name));
+		break;
 	}
 
 	return 0;
@@ -2372,8 +2396,20 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i)
 	if (i >= MXT_V4L_INPUT_MAX)
 		return -EINVAL;
 
-	f->width = data->xy_switch ? data->ysize : data->xsize;
-	f->height = data->xy_switch ? data->xsize : data->ysize;
+	switch (i) {
+	case MXT_V4L_INPUT_REFS:
+	case MXT_V4L_INPUT_DELTAS:
+		f->width = data->xy_switch ? data->ysize : data->xsize;
+		f->height = data->xy_switch ? data->xsize : data->ysize;
+		break;
+
+	case MXT_V4L_INPUT_REFS_SINGLE:
+	case MXT_V4L_INPUT_DELTAS_SINGLE:
+		f->width = 1;
+		f->height = 1;
+		break;
+	}
+
 	f->pixelformat = V4L2_PIX_FMT_Y16;
 	f->field = V4L2_FIELD_NONE;
 	f->colorspace = V4L2_COLORSPACE_SRGB;
@@ -2426,11 +2462,21 @@ static int mxt_vidioc_enum_framesizes(struct file *file, void *priv,
 {
 	struct mxt_data *data = video_drvdata(file);
 
-	if (f->index > 0)
+	switch (f->index) {
+	case 0:
+		f->discrete.width = data->xy_switch ? data->ysize:data->xsize;
+		f->discrete.height = data->xy_switch ? data->xsize:data->ysize;
+		break;
+
+	case 1:
+		f->discrete.width = 1;
+		f->discrete.height = 1;
+		break;
+
+	default:
 		return -EINVAL;
+	}
 
-	f->discrete.width = data->xy_switch ? data->ysize : data->xsize;
-	f->discrete.height = data->xy_switch ? data->xsize : data->ysize;
 	f->type = V4L2_FRMSIZE_TYPE_DISCRETE;
 	return 0;
 }
@@ -2479,6 +2525,19 @@ static const struct video_device mxt_video_device = {
 	.release = video_device_release_empty,
 };
 
+static void mxt_debugfs_calc_single_node_ofs(struct mxt_data *data)
+{
+	struct mxt_info *info = &data->info;
+	int ofs = data->ysize / 2;
+
+	while ((ofs + info->matrix_ysize) <= (MXT_DIAGNOSTIC_SIZE/sizeof(u16)))
+		ofs += info->matrix_ysize;
+
+	dev_dbg(&data->client->dev, "Single node ofs: %d\n", ofs);
+
+	data->dbg.single_node_ofs = ofs;
+}
+
 static void mxt_debug_init(struct mxt_data *data)
 {
 	struct mxt_info *info = &data->info;
@@ -2519,6 +2578,8 @@ static void mxt_debug_init(struct mxt_data *data)
 	if (!dbg->t37_buf)
 		goto error;
 
+	mxt_debugfs_calc_single_node_ofs(data);
+
 	/* init channel to zero */
 	mxt_set_input(data, 0);
 
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 8/8] Input: atmel_mxt_ts - add v4l pixelformat definition for touch refs output
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
                   ` (6 preceding siblings ...)
  2016-04-21  9:31 ` [PATCH 7/8] Input: atmel_mxt_ts - single node diagnostic data support Nick Dyer
@ 2016-04-21  9:31 ` Nick Dyer
  2016-04-22  8:26 ` [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Hans Verkuil
  8 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-21  9:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler,
	Nick Dyer

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 33 ++++++++++++++++++++++++--------
 include/uapi/linux/videodev2.h           |  1 +
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 3bb1179..94ed8bd 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2396,21 +2396,24 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i)
 	if (i >= MXT_V4L_INPUT_MAX)
 		return -EINVAL;
 
+	f->pixelformat = V4L2_PIX_FMT_Y16;
+
 	switch (i) {
-	case MXT_V4L_INPUT_REFS:
 	case MXT_V4L_INPUT_DELTAS:
+		f->pixelformat = V4L2_PIX_FMT_YS16; /* fall-through */
+	case MXT_V4L_INPUT_REFS:
 		f->width = data->xy_switch ? data->ysize : data->xsize;
 		f->height = data->xy_switch ? data->xsize : data->ysize;
 		break;
 
-	case MXT_V4L_INPUT_REFS_SINGLE:
 	case MXT_V4L_INPUT_DELTAS_SINGLE:
+		f->pixelformat = V4L2_PIX_FMT_YS16; /* fall-through */
+	case MXT_V4L_INPUT_REFS_SINGLE:
 		f->width = 1;
 		f->height = 1;
 		break;
 	}
 
-	f->pixelformat = V4L2_PIX_FMT_Y16;
 	f->field = V4L2_FIELD_NONE;
 	f->colorspace = V4L2_COLORSPACE_SRGB;
 	f->bytesperline = f->width * sizeof(u16);
@@ -2447,12 +2450,26 @@ static int mxt_vidioc_fmt(struct file *file, void *priv, struct v4l2_format *f)
 static int mxt_vidioc_enum_fmt(struct file *file, void *priv,
 				 struct v4l2_fmtdesc *fmt)
 {
-	if (fmt->index > 0 || fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 		return -EINVAL;
 
-	fmt->pixelformat = V4L2_PIX_FMT_Y16;
-	strlcpy(fmt->description, "16-bit raw debug data",
-		sizeof(fmt->description));
+	switch (fmt->index) {
+	case 0:
+		fmt->pixelformat = V4L2_PIX_FMT_Y16;
+		strlcpy(fmt->description, "16-bit unsigned raw debug data",
+			sizeof(fmt->description));
+		break;
+
+	case 1:
+		fmt->pixelformat = V4L2_PIX_FMT_YS16;
+		strlcpy(fmt->description, "16-bit signed raw debug data",
+			sizeof(fmt->description));
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
 	fmt->flags = 0;
 	return 0;
 }
@@ -2484,7 +2501,7 @@ static int mxt_vidioc_enum_framesizes(struct file *file, void *priv,
 static int mxt_vidioc_enum_frameintervals(struct file *file, void *priv,
 					  struct v4l2_frmivalenum *f)
 {
-	if ((f->index > 0) || (f->pixel_format != V4L2_PIX_FMT_Y16))
+	if (f->index > 0)
 		return -EINVAL;
 
 	f->type = V4L2_FRMIVAL_TYPE_DISCRETE;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 14cd5eb..ab577dd 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -496,6 +496,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12  Greyscale     */
 #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale     */
 #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16  Greyscale BE  */
+#define V4L2_PIX_FMT_YS16    v4l2_fourcc('Y', 'S', '1', '6') /* signed 16-bit Greyscale */
 
 /* Grey bit-packed formats */
 #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device
  2016-04-21  9:31 ` [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device Nick Dyer
@ 2016-04-21 11:04   ` kbuild test robot
  2016-04-21 11:23   ` kbuild test robot
  2016-04-21 11:43   ` kbuild test robot
  2 siblings, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-04-21 11:04 UTC (permalink / raw)
  To: Nick Dyer
  Cc: kbuild-all, Dmitry Torokhov, linux-input, linux-kernel,
	linux-media, Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler, Nick Dyer

[-- Attachment #1: Type: text/plain, Size: 2453 bytes --]

Hi,

[auto build test ERROR on input/next]
[also build test ERROR on v4.6-rc4 next-20160420]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Nick-Dyer/Input-atmel_mxt_ts-output-raw-touch-diagnostic-data-via-V4L/20160421-174351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-b0-04211643 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "vb2_fop_release" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "v4l2_fh_open" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_fop_mmap" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "video_ioctl2" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_fop_poll" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_fop_read" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ops_wait_finish" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ops_wait_prepare" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_streamoff" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_streamon" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_create_bufs" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_dqbuf" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_expbuf" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_qbuf" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_querybuf" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_ioctl_reqbufs" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "__video_register_device" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "video_device_release_empty" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_queue_init" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!
>> ERROR: "vb2_vmalloc_memops" [drivers/input/touchscreen/atmel_mxt_ts.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 21801 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device
  2016-04-21  9:31 ` [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device Nick Dyer
  2016-04-21 11:04   ` kbuild test robot
@ 2016-04-21 11:23   ` kbuild test robot
  2016-04-21 11:43   ` kbuild test robot
  2 siblings, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-04-21 11:23 UTC (permalink / raw)
  To: Nick Dyer
  Cc: kbuild-all, Dmitry Torokhov, linux-input, linux-kernel,
	linux-media, Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler, Nick Dyer

[-- Attachment #1: Type: text/plain, Size: 3497 bytes --]

Hi,

[auto build test ERROR on input/next]
[also build test ERROR on v4.6-rc4 next-20160420]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Nick-Dyer/Input-atmel_mxt_ts-output-raw-touch-diagnostic-data-via-V4L/20160421-174351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: arm-exynos_defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `video_drvdata':
>> include/media/v4l2-dev.h:224: undefined reference to `video_devdata'
>> include/media/v4l2-dev.h:224: undefined reference to `video_devdata'
>> include/media/v4l2-dev.h:224: undefined reference to `video_devdata'
>> include/media/v4l2-dev.h:224: undefined reference to `video_devdata'
>> include/media/v4l2-dev.h:224: undefined reference to `video_devdata'
   drivers/built-in.o: In function `mxt_free_object_table':
>> drivers/input/touchscreen/atmel_mxt_ts.c:1552: undefined reference to `video_unregister_device'
>> drivers/input/touchscreen/atmel_mxt_ts.c:1553: undefined reference to `v4l2_device_unregister'
   drivers/built-in.o: In function `mxt_buffer_queue':
>> drivers/input/touchscreen/atmel_mxt_ts.c:2210: undefined reference to `vb2_plane_vaddr'
>> drivers/input/touchscreen/atmel_mxt_ts.c:2225: undefined reference to `vb2_buffer_done'
   drivers/input/touchscreen/atmel_mxt_ts.c:2221: undefined reference to `vb2_buffer_done'
   drivers/built-in.o: In function `mxt_debug_init':
>> drivers/input/touchscreen/atmel_mxt_ts.c:2429: undefined reference to `v4l2_device_register'
>> drivers/input/touchscreen/atmel_mxt_ts.c:2437: undefined reference to `vb2_vmalloc_memops'
>> drivers/input/touchscreen/atmel_mxt_ts.c:2437: undefined reference to `vb2_vmalloc_memops'
>> drivers/input/touchscreen/atmel_mxt_ts.c:2441: undefined reference to `vb2_queue_init'
>> drivers/input/touchscreen/atmel_mxt_ts.c:2445: undefined reference to `video_device_release_empty'
>> drivers/input/touchscreen/atmel_mxt_ts.c:2445: undefined reference to `video_device_release_empty'
   drivers/built-in.o: In function `video_register_device':
>> include/media/v4l2-dev.h:160: undefined reference to `__video_register_device'
   drivers/built-in.o: In function `mxt_debug_init':
   drivers/input/touchscreen/atmel_mxt_ts.c:2461: undefined reference to `v4l2_device_unregister'
   drivers/built-in.o: In function `.LANCHOR1':
>> :(.rodata+0x3a090): undefined reference to `vb2_ops_wait_prepare'
>> :(.rodata+0x3a094): undefined reference to `vb2_ops_wait_finish'
>> :(.rodata+0x3a0b8): undefined reference to `vb2_fop_read'
>> :(.rodata+0x3a0c0): undefined reference to `vb2_fop_poll'

vim +1552 drivers/input/touchscreen/atmel_mxt_ts.c

  1546			data->input_dev = NULL;
  1547		}
  1548	}
  1549	
  1550	static void mxt_free_object_table(struct mxt_data *data)
  1551	{
> 1552		video_unregister_device(&data->dbg.vdev);
> 1553		v4l2_device_unregister(&data->dbg.v4l2);
  1554	
  1555		kfree(data->object_table);
  1556		data->object_table = NULL;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 23857 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device
  2016-04-21  9:31 ` [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device Nick Dyer
  2016-04-21 11:04   ` kbuild test robot
  2016-04-21 11:23   ` kbuild test robot
@ 2016-04-21 11:43   ` kbuild test robot
  2 siblings, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-04-21 11:43 UTC (permalink / raw)
  To: Nick Dyer
  Cc: kbuild-all, Dmitry Torokhov, linux-input, linux-kernel,
	linux-media, Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler, Nick Dyer

[-- Attachment #1: Type: text/plain, Size: 3651 bytes --]

Hi,

[auto build test ERROR on input/next]
[also build test ERROR on v4.6-rc4 next-20160420]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Nick-Dyer/Input-atmel_mxt_ts-output-raw-touch-diagnostic-data-via-V4L/20160421-174351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: arm-multi_v7_defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `mxt_vidioc_s_input':
>> :(.text+0x376b70): undefined reference to `video_devdata'
   drivers/built-in.o: In function `mxt_vidioc_g_input':
   :(.text+0x376bdc): undefined reference to `video_devdata'
   drivers/built-in.o: In function `mxt_vidioc_fmt':
   :(.text+0x376bfc): undefined reference to `video_devdata'
   drivers/built-in.o: In function `mxt_vidioc_enum_framesizes':
   :(.text+0x376c34): undefined reference to `video_devdata'
   drivers/built-in.o: In function `mxt_vidioc_querycap':
   :(.text+0x376d10): undefined reference to `video_devdata'
   drivers/built-in.o: In function `mxt_free_object_table':
>> :(.text+0x377744): undefined reference to `video_unregister_device'
>> :(.text+0x37774c): undefined reference to `v4l2_device_unregister'
   drivers/built-in.o: In function `mxt_buffer_queue':
>> :(.text+0x377a38): undefined reference to `vb2_plane_vaddr'
>> :(.text+0x377ad0): undefined reference to `vb2_buffer_done'
   :(.text+0x377bb0): undefined reference to `vb2_buffer_done'
   drivers/built-in.o: In function `mxt_config_cb':
>> :(.text+0x378e84): undefined reference to `v4l2_device_register'
>> :(.text+0x379104): undefined reference to `vb2_vmalloc_memops'
   :(.text+0x379108): undefined reference to `vb2_vmalloc_memops'
>> :(.text+0x37913c): undefined reference to `vb2_queue_init'
>> :(.text+0x37919c): undefined reference to `video_device_release_empty'
   :(.text+0x3791a4): undefined reference to `video_device_release_empty'
>> :(.text+0x3791d0): undefined reference to `__video_register_device'
   :(.text+0x3791f4): undefined reference to `v4l2_device_unregister'
   drivers/built-in.o: In function `.LANCHOR1':
   :(.rodata+0x12c9ac): undefined reference to `vb2_ops_wait_prepare'
   :(.rodata+0x12c9b0): undefined reference to `vb2_ops_wait_finish'
   :(.rodata+0x12c9d4): undefined reference to `vb2_fop_read'
   :(.rodata+0x12c9dc): undefined reference to `vb2_fop_poll'
   :(.rodata+0x12c9e0): undefined reference to `video_ioctl2'
   :(.rodata+0x12c9e8): undefined reference to `vb2_fop_mmap'
   :(.rodata+0x12c9ec): undefined reference to `v4l2_fh_open'
   :(.rodata+0x12c9f0): undefined reference to `vb2_fop_release'
   :(.rodata+0x12cac4): undefined reference to `vb2_ioctl_reqbufs'
   :(.rodata+0x12cac8): undefined reference to `vb2_ioctl_querybuf'
   :(.rodata+0x12cacc): undefined reference to `vb2_ioctl_qbuf'
   :(.rodata+0x12cad0): undefined reference to `vb2_ioctl_expbuf'
   :(.rodata+0x12cad4): undefined reference to `vb2_ioctl_dqbuf'
   :(.rodata+0x12cad8): undefined reference to `vb2_ioctl_create_bufs'
   :(.rodata+0x12caec): undefined reference to `vb2_ioctl_streamon'
   :(.rodata+0x12caf0): undefined reference to `vb2_ioctl_streamoff'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 36583 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
  2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
                   ` (7 preceding siblings ...)
  2016-04-21  9:31 ` [PATCH 8/8] Input: atmel_mxt_ts - add v4l pixelformat definition for touch refs output Nick Dyer
@ 2016-04-22  8:26 ` Hans Verkuil
  2016-04-22 14:45   ` Mauro Carvalho Chehab
  8 siblings, 1 reply; 18+ messages in thread
From: Hans Verkuil @ 2016-04-22  8:26 UTC (permalink / raw)
  To: Nick Dyer, Dmitry Torokhov
  Cc: linux-input, linux-kernel, linux-media, Benjamin Tissoires,
	Benson Leung, Alan Bowens, Javier Martinez Canillas, Chris Healy,
	Henrik Rydberg, Andrew Duggan, James Chen, Dudley Du,
	Andrew de los Reyes, sheckylin, Peter Hutterer, Florian Echtler

Hi Nick,

On 04/21/2016 11:31 AM, Nick Dyer wrote:
> This is a series of patches to add diagnostic data support to the Atmel
> maXTouch driver. It's a rewrite of the previous implementation which output via
> debugfs: it now uses a V4L2 device in a similar way to the sur40 driver.
> 
> There are significant performance advantages to putting 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).
> 
> We have a utility which can read the data and display it in a useful format:
> 	https://github.com/ndyer/heatmap/commits/heatmap-v4l
> 
> These patches are also available from
> 	https://github.com/ndyer/linux/commits/diagnostic-v4l
> 
> Any feedback appreciated.

FYI: we're working on a new buffer type for meta data:

https://patchwork.linuxtv.org/patch/33938/
https://patchwork.linuxtv.org/patch/33939/

This would be an excellent fit for you. I expect that this new feature would be
merged soon (for 4.7 or 4.8 at the latest) since it looks all pretty good to me.

So let's wait for this to be merged and then you can migrate to the new buffer
type.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
  2016-04-22  8:26 ` [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Hans Verkuil
@ 2016-04-22 14:45   ` Mauro Carvalho Chehab
  2016-04-22 15:07     ` Nick Dyer
  0 siblings, 1 reply; 18+ messages in thread
From: Mauro Carvalho Chehab @ 2016-04-22 14:45 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Nick Dyer, Dmitry Torokhov, linux-input, linux-kernel,
	linux-media, Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler

Em Fri, 22 Apr 2016 10:26:37 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> Hi Nick,
> 
> On 04/21/2016 11:31 AM, Nick Dyer wrote:
> > This is a series of patches to add diagnostic data support to the Atmel
> > maXTouch driver. It's a rewrite of the previous implementation which output via
> > debugfs: it now uses a V4L2 device in a similar way to the sur40 driver.
> > 
> > There are significant performance advantages to putting 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).
> > 
> > We have a utility which can read the data and display it in a useful format:
> > 	https://github.com/ndyer/heatmap/commits/heatmap-v4l
> > 
> > These patches are also available from
> > 	https://github.com/ndyer/linux/commits/diagnostic-v4l
> > 
> > Any feedback appreciated.  
> 
> FYI: we're working on a new buffer type for meta data:
> 
> https://patchwork.linuxtv.org/patch/33938/
> https://patchwork.linuxtv.org/patch/33939/

Nick,

One of the things I missed on your patchset is the content of the
new format you added (V4L2_PIX_FMT_YS16). You should be patching
the V4L2 docbook too, in order to add it there.

That's said, if the output is really an image, I don't think it
should be mapped via the new V4L2_BUF_TYPE_META_CAPTURE. This type of
buffer is meant to be used on non-image metadata, like image statistics
to feed auto whitebalance and other similar AAA algorithms.

It could still make sense to use the new device type (VFL_TYPE_META) for
such drivers, as we don't want applications to identify those devices as
if they are a webcam.

> 
> This would be an excellent fit for you. I expect that this new feature would be
> merged soon (for 4.7 or 4.8 at the latest) since it looks all pretty good to me.
> 
> So let's wait for this to be merged and then you can migrate to the new buffer
> type.
> 
> Regards,
> 
> 	Hans
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Thanks,
Mauro

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
  2016-04-22 14:45   ` Mauro Carvalho Chehab
@ 2016-04-22 15:07     ` Nick Dyer
  2016-04-22 15:18       ` Hans Verkuil
  0 siblings, 1 reply; 18+ messages in thread
From: Nick Dyer @ 2016-04-22 15:07 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Hans Verkuil
  Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-media,
	Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler

On 22/04/2016 15:45, Mauro Carvalho Chehab wrote:
> Em Fri, 22 Apr 2016 10:26:37 +0200
> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
>> On 04/21/2016 11:31 AM, Nick Dyer wrote:
>>> This is a series of patches to add diagnostic data support to the Atmel
>>> maXTouch driver. It's a rewrite of the previous implementation which output via
>>> debugfs: it now uses a V4L2 device in a similar way to the sur40 driver.
>>>
>>> There are significant performance advantages to putting 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).
>>>
>>> We have a utility which can read the data and display it in a useful format:
>>> 	https://github.com/ndyer/heatmap/commits/heatmap-v4l
>>>
>>> These patches are also available from
>>> 	https://github.com/ndyer/linux/commits/diagnostic-v4l
>>>
>>> Any feedback appreciated.  
>>
>> FYI: we're working on a new buffer type for meta data:
>>
>> https://patchwork.linuxtv.org/patch/33938/
>> https://patchwork.linuxtv.org/patch/33939/
> 
> One of the things I missed on your patchset is the content of the
> new format you added (V4L2_PIX_FMT_YS16). You should be patching
> the V4L2 docbook too, in order to add it there.

OK, will do. I also see that I forgot Kconfig changes for CONFIG_VIDEO_V4L2
etc.

> That's said, if the output is really an image, I don't think it
> should be mapped via the new V4L2_BUF_TYPE_META_CAPTURE. This type of
> buffer is meant to be used on non-image metadata, like image statistics
> to feed auto whitebalance and other similar AAA algorithms.

The output is raw touch data - i.e. a rectangular grid of nodes each having
an integer value. I think it is an image in some senses, although perhaps
it's a matter of opinion!

You can see an example of a Atmel MXT capacitive touch device here (using
this patchset):
https://www.youtube.com/watch?v=Uj4T6fUCySw

There are touch devices which can deliver much higher resolution/framerate.
For example here's the data coming from a SUR40 which is an optical touch
sensor but uses V4L in a similar way:
https://www.youtube.com/watch?v=e-JNqTY_3b0

> It could still make sense to use the new device type (VFL_TYPE_META) for
> such drivers, as we don't want applications to identify those devices as
> if they are a webcam.

I agree it may be a little confusing if things like Skype start picking up
these devices. Could we #define V4L2_INPUT_TYPE_TOUCH_SENSOR to solve that
problem?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
  2016-04-22 15:07     ` Nick Dyer
@ 2016-04-22 15:18       ` Hans Verkuil
  2016-04-22 15:44         ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 18+ messages in thread
From: Hans Verkuil @ 2016-04-22 15:18 UTC (permalink / raw)
  To: Nick Dyer, Mauro Carvalho Chehab
  Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-media,
	Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler

On 04/22/2016 05:07 PM, Nick Dyer wrote:
> On 22/04/2016 15:45, Mauro Carvalho Chehab wrote:
>> Em Fri, 22 Apr 2016 10:26:37 +0200
>> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
>>> On 04/21/2016 11:31 AM, Nick Dyer wrote:
>>>> This is a series of patches to add diagnostic data support to the Atmel
>>>> maXTouch driver. It's a rewrite of the previous implementation which output via
>>>> debugfs: it now uses a V4L2 device in a similar way to the sur40 driver.
>>>>
>>>> There are significant performance advantages to putting 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).
>>>>
>>>> We have a utility which can read the data and display it in a useful format:
>>>> 	https://github.com/ndyer/heatmap/commits/heatmap-v4l
>>>>
>>>> These patches are also available from
>>>> 	https://github.com/ndyer/linux/commits/diagnostic-v4l
>>>>
>>>> Any feedback appreciated.  
>>>
>>> FYI: we're working on a new buffer type for meta data:
>>>
>>> https://patchwork.linuxtv.org/patch/33938/
>>> https://patchwork.linuxtv.org/patch/33939/
>>
>> One of the things I missed on your patchset is the content of the
>> new format you added (V4L2_PIX_FMT_YS16). You should be patching
>> the V4L2 docbook too, in order to add it there.
> 
> OK, will do. I also see that I forgot Kconfig changes for CONFIG_VIDEO_V4L2
> etc.
> 
>> That's said, if the output is really an image, I don't think it
>> should be mapped via the new V4L2_BUF_TYPE_META_CAPTURE. This type of
>> buffer is meant to be used on non-image metadata, like image statistics
>> to feed auto whitebalance and other similar AAA algorithms.
> 
> The output is raw touch data - i.e. a rectangular grid of nodes each having
> an integer value. I think it is an image in some senses, although perhaps
> it's a matter of opinion!
> 
> You can see an example of a Atmel MXT capacitive touch device here (using
> this patchset):
> https://www.youtube.com/watch?v=Uj4T6fUCySw
> 
> There are touch devices which can deliver much higher resolution/framerate.
> For example here's the data coming from a SUR40 which is an optical touch
> sensor but uses V4L in a similar way:
> https://www.youtube.com/watch?v=e-JNqTY_3b0
> 
>> It could still make sense to use the new device type (VFL_TYPE_META) for
>> such drivers, as we don't want applications to identify those devices as
>> if they are a webcam.
> 
> I agree it may be a little confusing if things like Skype start picking up
> these devices. Could we #define V4L2_INPUT_TYPE_TOUCH_SENSOR to solve that
> problem?
> 

That might be an idea. I have to admit that I didn't look at the patches in
detail. It mentioned diagnostics, so I didn't realize that it is a image
with a width and height, even though it is not a regular video input.

Adding a new input type won't prevent anyone from picking it up, since
nobody tests that field :-)

On the other hand, it would be a good place to tell the user that it
is from a touch sensor.

Using the upcoming metadata feature wouldn't work since there is no width
and height in the metadata format.

I wonder what others think about adding a new type value.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
  2016-04-22 15:18       ` Hans Verkuil
@ 2016-04-22 15:44         ` Mauro Carvalho Chehab
  2016-04-29 12:14           ` Nick Dyer
  0 siblings, 1 reply; 18+ messages in thread
From: Mauro Carvalho Chehab @ 2016-04-22 15:44 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Nick Dyer, Dmitry Torokhov, linux-input, linux-kernel,
	linux-media, Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler

Em Fri, 22 Apr 2016 17:18:24 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 04/22/2016 05:07 PM, Nick Dyer wrote:
> > On 22/04/2016 15:45, Mauro Carvalho Chehab wrote:  
> >> Em Fri, 22 Apr 2016 10:26:37 +0200
> >> Hans Verkuil <hverkuil@xs4all.nl> escreveu:  
> >>> On 04/21/2016 11:31 AM, Nick Dyer wrote:  
> >>>> This is a series of patches to add diagnostic data support to the Atmel
> >>>> maXTouch driver. It's a rewrite of the previous implementation which output via
> >>>> debugfs: it now uses a V4L2 device in a similar way to the sur40 driver.
> >>>>
> >>>> There are significant performance advantages to putting 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).
> >>>>
> >>>> We have a utility which can read the data and display it in a useful format:
> >>>> 	https://github.com/ndyer/heatmap/commits/heatmap-v4l
> >>>>
> >>>> These patches are also available from
> >>>> 	https://github.com/ndyer/linux/commits/diagnostic-v4l
> >>>>
> >>>> Any feedback appreciated.    
> >>>
> >>> FYI: we're working on a new buffer type for meta data:
> >>>
> >>> https://patchwork.linuxtv.org/patch/33938/
> >>> https://patchwork.linuxtv.org/patch/33939/  
> >>
> >> One of the things I missed on your patchset is the content of the
> >> new format you added (V4L2_PIX_FMT_YS16). You should be patching
> >> the V4L2 docbook too, in order to add it there.  
> > 
> > OK, will do. I also see that I forgot Kconfig changes for CONFIG_VIDEO_V4L2
> > etc.
> >   
> >> That's said, if the output is really an image, I don't think it
> >> should be mapped via the new V4L2_BUF_TYPE_META_CAPTURE. This type of
> >> buffer is meant to be used on non-image metadata, like image statistics
> >> to feed auto whitebalance and other similar AAA algorithms.  
> > 
> > The output is raw touch data - i.e. a rectangular grid of nodes each having
> > an integer value. I think it is an image in some senses, although perhaps
> > it's a matter of opinion!
> > 
> > You can see an example of a Atmel MXT capacitive touch device here (using
> > this patchset):
> > https://www.youtube.com/watch?v=Uj4T6fUCySw
> > 
> > There are touch devices which can deliver much higher resolution/framerate.
> > For example here's the data coming from a SUR40 which is an optical touch
> > sensor but uses V4L in a similar way:
> > https://www.youtube.com/watch?v=e-JNqTY_3b0
> >   
> >> It could still make sense to use the new device type (VFL_TYPE_META) for
> >> such drivers, as we don't want applications to identify those devices as
> >> if they are a webcam.  
> > 
> > I agree it may be a little confusing if things like Skype start picking up
> > these devices. Could we #define V4L2_INPUT_TYPE_TOUCH_SENSOR to solve that
> > problem?
> >   
> 
> That might be an idea. I have to admit that I didn't look at the patches in
> detail. It mentioned diagnostics, so I didn't realize that it is a image
> with a width and height, even though it is not a regular video input.
> 
> Adding a new input type won't prevent anyone from picking it up, since
> nobody tests that field :-)

Yeah, I agree.

> On the other hand, it would be a good place to tell the user that it
> is from a touch sensor.
> 
> Using the upcoming metadata feature wouldn't work since there is no width
> and height in the metadata format.
> 
> I wonder what others think about adding a new type value.

IMO, two things should be done here:

1) Add some caps flag to help userspace to identify what's there
   on those devices;

2) Make sure that udev/systemd won't be naming the devnodes as
   "/dev/video";


The latter one could be solved with either the new dev meta or
with another VFL_TYPE for input systems (like VFL_TYPE_TOUCH_SENSOR)
and use this code snippet:

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d8e5994cccf1..4d3e574eba49 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -887,6 +887,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
                /* Use device name 'swradio' because 'sdr' was already taken. */
                name_base = "swradio";
                break;
+       case VFL_TYPE_TOUCH_SENSOR:
+               name_base = "v4l-touch";
+               break;
        default:
                printk(KERN_ERR "%s called with unknown type: %d\n",
                       __func__, type);


Such change would cause __video_register_device() to pass a different
name_base to:
	dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);

This way, udev/systemd will use a different name (by default, 
/dev/v4l-touch0), and existing apps won't identify this as a
webcam.

Regards,
Mauro

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L
  2016-04-22 15:44         ` Mauro Carvalho Chehab
@ 2016-04-29 12:14           ` Nick Dyer
  0 siblings, 0 replies; 18+ messages in thread
From: Nick Dyer @ 2016-04-29 12:14 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Hans Verkuil
  Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-media,
	Benjamin Tissoires, Benson Leung, Alan Bowens,
	Javier Martinez Canillas, Chris Healy, Henrik Rydberg,
	Andrew Duggan, James Chen, Dudley Du, Andrew de los Reyes,
	sheckylin, Peter Hutterer, Florian Echtler

On 22/04/2016 16:44, Mauro Carvalho Chehab wrote:
>> On the other hand, it would be a good place to tell the user that it
>> is from a touch sensor.
>>
>> Using the upcoming metadata feature wouldn't work since there is no width
>> and height in the metadata format.
>>
>> I wonder what others think about adding a new type value.
> 
> IMO, two things should be done here:
> 
> 1) Add some caps flag to help userspace to identify what's there
>    on those devices;

In the patches I have written so far, I have used inputs to select between
different types of data, so I believe there's no real need for this yet.
Did you have anything else in mind?

> 2) Make sure that udev/systemd won't be naming the devnodes as
>    "/dev/video";
> 
> 
> The latter one could be solved with either the new dev meta or
> with another VFL_TYPE for input systems (like VFL_TYPE_TOUCH_SENSOR)
> and use this code snippet:
> 
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index d8e5994cccf1..4d3e574eba49 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -887,6 +887,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
>                 /* Use device name 'swradio' because 'sdr' was already taken. */
>                 name_base = "swradio";
>                 break;
> +       case VFL_TYPE_TOUCH_SENSOR:
> +               name_base = "v4l-touch";
> +               break;
>         default:
>                 printk(KERN_ERR "%s called with unknown type: %d\n",
>                        __func__, type);
> 
> 
> Such change would cause __video_register_device() to pass a different
> name_base to:
> 	dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
> 
> This way, udev/systemd will use a different name (by default, 
> /dev/v4l-touch0), and existing apps won't identify this as a
> webcam.

Thanks - this sounds like a good approach to me. I will update.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-04-29 12:14 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-21  9:31 [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Nick Dyer
2016-04-21  9:31 ` [PATCH 1/8] Input: atmel_mxt_ts - add support for T37 diagnostic data Nick Dyer
2016-04-21  9:31 ` [PATCH 2/8] Input: atmel_mxt_ts - output diagnostic debug via v4l2 device Nick Dyer
2016-04-21 11:04   ` kbuild test robot
2016-04-21 11:23   ` kbuild test robot
2016-04-21 11:43   ` kbuild test robot
2016-04-21  9:31 ` [PATCH 3/8] Input: atmel_mxt_ts - read touchscreen size Nick Dyer
2016-04-21  9:31 ` [PATCH 4/8] Input: atmel_mxt_ts - handle diagnostic data orientation Nick Dyer
2016-04-21  9:31 ` [PATCH 5/8] Input: atmel_mxt_ts - add diagnostic data support for mXT1386 Nick Dyer
2016-04-21  9:31 ` [PATCH 6/8] Input: atmel_mxt_ts - add support for reference data Nick Dyer
2016-04-21  9:31 ` [PATCH 7/8] Input: atmel_mxt_ts - single node diagnostic data support Nick Dyer
2016-04-21  9:31 ` [PATCH 8/8] Input: atmel_mxt_ts - add v4l pixelformat definition for touch refs output Nick Dyer
2016-04-22  8:26 ` [PATCH 0/8] Input: atmel_mxt_ts - output raw touch diagnostic data via V4L Hans Verkuil
2016-04-22 14:45   ` Mauro Carvalho Chehab
2016-04-22 15:07     ` Nick Dyer
2016-04-22 15:18       ` Hans Verkuil
2016-04-22 15:44         ` Mauro Carvalho Chehab
2016-04-29 12:14           ` Nick Dyer

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).