linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	Peter Hutterer <peter.hutterer@who-t.net>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/2] input/uinput: support abs resolution
Date: Mon, 15 Jul 2013 15:37:08 +0200	[thread overview]
Message-ID: <1373895429-8846-1-git-send-email-benjamin.tissoires@redhat.com> (raw)

From: Peter Hutterer <peter.hutterer@who-t.net>

Input resolution has been added in kernel v2.6.31 with commit
ec20a022aa24fc63. However, uinput was never updated since, meaning that
devices cannot be emulated in full. User-space processes that rely on the
resolution to be accurate need this.

Resolution is added in struct uinput_user_dev in a way it won't break
current programs relying on the old implementation.

Bump the UINPUT_VERSION number to 4 to aid detection of this in user-space.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
---

Sorry for that, I mixed up the "From:" field.
This v2 contains the right From in the first patch , and this is the only
difference...

Cheers,
Benjamin

 drivers/input/misc/uinput.c | 17 ++++++++++++-----
 include/linux/uinput.h      |  2 ++
 include/uapi/linux/uinput.h |  3 +++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index a0a4bba..7d518b4 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -20,6 +20,8 @@
  * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
  *
  * Changes/Revisions:
+ *	0.4	12/07/2013 (Peter Hutterer <peter.hutterer@redhat.com>)
+ *		- update uinput_user_dev struct to allow abs resolution
  *	0.3	09/04/2006 (Anssi Hannula <anssi.hannula@gmail.com>)
  *		- updated ff support for the changes in kernel interface
  *		- added MODULE_VERSION
@@ -364,9 +366,9 @@ static int uinput_setup_device(struct uinput_device *udev,
 	struct input_dev	*dev;
 	int			i;
 	int			retval;
+	size_t			size;
 
-	if (count != sizeof(struct uinput_user_dev))
-		return -EINVAL;
+	size = min_t(size_t, count, sizeof(struct uinput_user_dev));
 
 	if (!udev->dev) {
 		retval = uinput_allocate_device(udev);
@@ -376,9 +378,13 @@ static int uinput_setup_device(struct uinput_device *udev,
 
 	dev = udev->dev;
 
-	user_dev = memdup_user(buffer, sizeof(struct uinput_user_dev));
-	if (IS_ERR(user_dev))
-		return PTR_ERR(user_dev);
+	user_dev = kzalloc(sizeof(struct uinput_user_dev), GFP_KERNEL);
+	if (!user_dev)
+		return -ENOMEM;
+	if (copy_from_user(user_dev, buffer, size)) {
+		retval = -EFAULT;
+		goto exit;
+	}
 
 	udev->ff_effects_max = user_dev->ff_effects_max;
 
@@ -406,6 +412,7 @@ static int uinput_setup_device(struct uinput_device *udev,
 		input_abs_set_min(dev, i, user_dev->absmin[i]);
 		input_abs_set_fuzz(dev, i, user_dev->absfuzz[i]);
 		input_abs_set_flat(dev, i, user_dev->absflat[i]);
+		input_abs_set_res(dev, i, user_dev->absres[i]);
 	}
 
 	/* check if absmin/absmax/absfuzz/absflat are filled as
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
index 0a4487d..6291a22 100644
--- a/include/linux/uinput.h
+++ b/include/linux/uinput.h
@@ -20,6 +20,8 @@
  * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
  *
  * Changes/Revisions:
+ *	0.4	12/07/2013 (Peter Hutterer <peter.hutterer@redhat.com>)
+ *		- update uinput_user_dev struct to allow abs resolution
  *	0.3	24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>)
  *		- update ff support for the changes in kernel interface
  *		- add UINPUT_VERSION
diff --git a/include/uapi/linux/uinput.h b/include/uapi/linux/uinput.h
index fe46431..f6a393b 100644
--- a/include/uapi/linux/uinput.h
+++ b/include/uapi/linux/uinput.h
@@ -20,6 +20,8 @@
  * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
  *
  * Changes/Revisions:
+ *	0.4	12/07/2013 (Peter Hutterer <peter.hutterer@redhat.com>)
+ *		- update uinput_user_dev struct to allow abs resolution
  *	0.3	24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>)
  *		- update ff support for the changes in kernel interface
  *		- add UINPUT_VERSION
@@ -133,5 +135,6 @@ struct uinput_user_dev {
 	__s32 absmin[ABS_CNT];
 	__s32 absfuzz[ABS_CNT];
 	__s32 absflat[ABS_CNT];
+	__s32 absres[ABS_CNT];
 };
 #endif /* _UAPI__UINPUT_H_ */
-- 
1.8.3.1


             reply	other threads:[~2013-07-15 13:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 13:37 Benjamin Tissoires [this message]
2013-07-15 13:37 ` [PATCH v2 2/2] input/uinput: add UI_GET_SYSPATH ioctl to retrieve the sysfs path Benjamin Tissoires
2013-07-23  1:15   ` Peter Hutterer
2013-07-27 13:07   ` David Herrmann
2013-07-29  9:16     ` Benjamin Tissoires

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1373895429-8846-1-git-send-email-benjamin.tissoires@redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=benjamin.tissoires@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.hutterer@who-t.net \
    /path/to/YOUR_REPLY

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

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