All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Large scancode handling
@ 2010-09-08  7:41 Dmitry Torokhov
  2010-09-08  7:41 ` [PATCH 1/6] Input: add support for large scancodes Dmitry Torokhov
                   ` (8 more replies)
  0 siblings, 9 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Hi Mauro,

I guess I better get off my behind and commit the changes to support large
scancodes, or they will not make to 2.6.37 either... There isn't much
changes, except I followed David's suggestion and changed boolean index
field into u8 flags field. Still, please glance it over once again and
shout if you see something you do not like.

Jiri, how do you want to handle the changes to HID? I could either push
them through my tree together with the first patch or you can push through
yours once the first change hits mainline.

Mauro, the same question goes for media/IR patch.

David, I suppose you still have the winbond remote so you could test
changes to winbond-cir driver.

Ville, do you still have the hardware to try our ati_remote2 changes?

Thanks!

-- 
Dmitry

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

* [PATCH 1/6] Input: add support for large scancodes
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
@ 2010-09-08  7:41 ` Dmitry Torokhov
  2010-10-29 21:36   ` James Hogan
  2010-09-08  7:41 ` [PATCH 2/6] Input: sparse-keymap - switch to using new keycode interface Dmitry Torokhov
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

From: Mauro Carvalho Chehab <mchehab@redhat.com>

Several devices use a high number of bits for scancodes. One important
group is the Remote Controllers. Some new protocols like RC-6 define a
scancode space of 64 bits.

The current EVIO[CS]GKEYCODE ioctls allow replace the scancode/keycode
translation tables, but it is limited to up to 32 bits for scancode.

Also, if userspace wants to clean the existing table, replacing it by
a new one, it needs to run a loop calling the ioctls over the entire
sparse scancode space.

To solve those problems, this patch extends the ioctls to allow drivers
handle scancodes up to 32 bytes long (the length could be extended in
the future should such need arise) and allow userspace to query and set
scancode to keycode mappings not only by scancode but also by index.

Compatibility code were also added to handle the old format of
EVIO[CS]GKEYCODE ioctls.

Folded fixes by:
- Dan Carpenter: locking fixes for the original implementation
- Jarod Wilson: fix crash when setting keycode and wiring up get/set
                handlers in original implementation.
- Dmitry Torokhov: rework to consolidate old and new scancode handling,
                   provide options to act either by index or scancode.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/char/keyboard.c |   31 ++++++--
 drivers/input/evdev.c   |  100 ++++++++++++++++++++----
 drivers/input/input.c   |  192 +++++++++++++++++++++++++++++++++++------------
 include/linux/input.h   |   55 +++++++++++--
 4 files changed, 292 insertions(+), 86 deletions(-)

diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index a7ca752..e95d787 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -175,8 +175,7 @@ EXPORT_SYMBOL_GPL(unregister_keyboard_notifier);
  */
 
 struct getset_keycode_data {
-	unsigned int scancode;
-	unsigned int keycode;
+	struct input_keymap_entry ke;
 	int error;
 };
 
@@ -184,32 +183,50 @@ static int getkeycode_helper(struct input_handle *handle, void *data)
 {
 	struct getset_keycode_data *d = data;
 
-	d->error = input_get_keycode(handle->dev, d->scancode, &d->keycode);
+	d->error = input_get_keycode(handle->dev, &d->ke);
 
 	return d->error == 0; /* stop as soon as we successfully get one */
 }
 
 int getkeycode(unsigned int scancode)
 {
-	struct getset_keycode_data d = { scancode, 0, -ENODEV };
+	struct getset_keycode_data d = {
+		.ke	= {
+			.flags		= 0,
+			.len		= sizeof(scancode),
+			.keycode	= 0,
+		},
+		.error	= -ENODEV,
+	};
+
+	memcpy(d.ke.scancode, &scancode, sizeof(scancode));
 
 	input_handler_for_each_handle(&kbd_handler, &d, getkeycode_helper);
 
-	return d.error ?: d.keycode;
+	return d.error ?: d.ke.keycode;
 }
 
 static int setkeycode_helper(struct input_handle *handle, void *data)
 {
 	struct getset_keycode_data *d = data;
 
-	d->error = input_set_keycode(handle->dev, d->scancode, d->keycode);
+	d->error = input_set_keycode(handle->dev, &d->ke);
 
 	return d->error == 0; /* stop as soon as we successfully set one */
 }
 
 int setkeycode(unsigned int scancode, unsigned int keycode)
 {
-	struct getset_keycode_data d = { scancode, keycode, -ENODEV };
+	struct getset_keycode_data d = {
+		.ke	= {
+			.flags		= 0,
+			.len		= sizeof(scancode),
+			.keycode	= keycode,
+		},
+		.error	= -ENODEV,
+	};
+
+	memcpy(d.ke.scancode, &scancode, sizeof(scancode));
 
 	input_handler_for_each_handle(&kbd_handler, &d, setkeycode_helper);
 
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index c908c5f..1ce9bf6 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -534,6 +534,80 @@ static int handle_eviocgbit(struct input_dev *dev,
 }
 #undef OLD_KEY_MAX
 
+static int evdev_handle_get_keycode(struct input_dev *dev,
+				    void __user *p, size_t size)
+{
+	struct input_keymap_entry ke;
+	int error;
+
+	memset(&ke, 0, sizeof(ke));
+
+	if (size == sizeof(unsigned int[2])) {
+		/* legacy case */
+		int __user *ip = (int __user *)p;
+
+		if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
+			return -EFAULT;
+
+		ke.len = sizeof(unsigned int);
+		ke.flags = 0;
+
+		error = input_get_keycode(dev, &ke);
+		if (error)
+			return error;
+
+		if (put_user(ke.keycode, ip + 1))
+			return -EFAULT;
+
+	} else {
+		size = min(size, sizeof(ke));
+
+		if (copy_from_user(&ke, p, size))
+			return -EFAULT;
+
+		error = input_get_keycode(dev, &ke);
+		if (error)
+			return error;
+
+		if (copy_to_user(p, &ke, size))
+			return -EFAULT;
+	}
+	return 0;
+}
+
+static int evdev_handle_set_keycode(struct input_dev *dev,
+				    void __user *p, size_t size)
+{
+	struct input_keymap_entry ke;
+
+	memset(&ke, 0, sizeof(ke));
+
+	if (size == sizeof(unsigned int[2])) {
+		/* legacy case */
+		int __user *ip = (int __user *)p;
+
+		if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
+			return -EFAULT;
+
+		if (get_user(ke.keycode, ip + 1))
+			return -EFAULT;
+
+		ke.len = sizeof(unsigned int);
+		ke.flags = 0;
+
+	} else {
+		size = min(size, sizeof(ke));
+
+		if (copy_from_user(&ke, p, size))
+			return -EFAULT;
+
+		if (ke.len > sizeof(ke.scancode))
+			return -EINVAL;
+	}
+
+	return input_set_keycode(dev, &ke);
+}
+
 static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 			   void __user *p, int compat_mode)
 {
@@ -580,25 +654,6 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 
 		return 0;
 
-	case EVIOCGKEYCODE:
-		if (get_user(t, ip))
-			return -EFAULT;
-
-		error = input_get_keycode(dev, t, &v);
-		if (error)
-			return error;
-
-		if (put_user(v, ip + 1))
-			return -EFAULT;
-
-		return 0;
-
-	case EVIOCSKEYCODE:
-		if (get_user(t, ip) || get_user(v, ip + 1))
-			return -EFAULT;
-
-		return input_set_keycode(dev, t, v);
-
 	case EVIOCRMFF:
 		return input_ff_erase(dev, (int)(unsigned long) p, file);
 
@@ -620,7 +675,6 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 
 	/* Now check variable-length commands */
 #define EVIOC_MASK_SIZE(nr)	((nr) & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT))
-
 	switch (EVIOC_MASK_SIZE(cmd)) {
 
 	case EVIOCGKEY(0):
@@ -654,6 +708,12 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 			return -EFAULT;
 
 		return error;
+
+	case EVIOC_MASK_SIZE(EVIOCGKEYCODE):
+		return evdev_handle_get_keycode(dev, p, size);
+
+	case EVIOC_MASK_SIZE(EVIOCSKEYCODE):
+		return evdev_handle_set_keycode(dev, p, size);
 	}
 
 	/* Multi-number variable-length handlers */
diff --git a/drivers/input/input.c b/drivers/input/input.c
index acb3c80..832771e 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -634,78 +634,141 @@ static void input_disconnect_device(struct input_dev *dev)
 	spin_unlock_irq(&dev->event_lock);
 }
 
-static int input_fetch_keycode(struct input_dev *dev, int scancode)
+/**
+ * input_scancode_to_scalar() - converts scancode in &struct input_keymap_entry
+ * @ke: keymap entry containing scancode to be converted.
+ * @scancode: pointer to the location where converted scancode should
+ *	be stored.
+ *
+ * This function is used to convert scancode stored in &struct keymap_entry
+ * into scalar form understood by legacy keymap handling methods. These
+ * methods expect scancodes to be represented as 'unsigned int'.
+ */
+int input_scancode_to_scalar(const struct input_keymap_entry *ke,
+			     unsigned int *scancode)
+{
+	switch (ke->len) {
+	case 1:
+		*scancode = *((u8 *)ke->scancode);
+		break;
+
+	case 2:
+		*scancode = *((u16 *)ke->scancode);
+		break;
+
+	case 4:
+		*scancode = *((u32 *)ke->scancode);
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(input_scancode_to_scalar);
+
+/*
+ * Those routines handle the default case where no [gs]etkeycode() is
+ * defined. In this case, an array indexed by the scancode is used.
+ */
+
+static unsigned int input_fetch_keycode(struct input_dev *dev,
+					unsigned int index)
 {
 	switch (dev->keycodesize) {
-		case 1:
-			return ((u8 *)dev->keycode)[scancode];
+	case 1:
+		return ((u8 *)dev->keycode)[index];
 
-		case 2:
-			return ((u16 *)dev->keycode)[scancode];
+	case 2:
+		return ((u16 *)dev->keycode)[index];
 
-		default:
-			return ((u32 *)dev->keycode)[scancode];
+	default:
+		return ((u32 *)dev->keycode)[index];
 	}
 }
 
 static int input_default_getkeycode(struct input_dev *dev,
-				    unsigned int scancode,
-				    unsigned int *keycode)
+				    struct input_keymap_entry *ke)
 {
+	unsigned int index;
+	int error;
+
 	if (!dev->keycodesize)
 		return -EINVAL;
 
-	if (scancode >= dev->keycodemax)
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+		index = ke->index;
+	else {
+		error = input_scancode_to_scalar(ke, &index);
+		if (error)
+			return error;
+	}
+
+	if (index >= dev->keycodemax)
 		return -EINVAL;
 
-	*keycode = input_fetch_keycode(dev, scancode);
+	ke->keycode = input_fetch_keycode(dev, index);
+	ke->index = index;
+	ke->len = sizeof(index);
+	memcpy(ke->scancode, &index, sizeof(index));
 
 	return 0;
 }
 
 static int input_default_setkeycode(struct input_dev *dev,
-				    unsigned int scancode,
-				    unsigned int keycode)
+				    const struct input_keymap_entry *ke,
+				    unsigned int *old_keycode)
 {
-	int old_keycode;
+	unsigned int index;
+	int error;
 	int i;
 
-	if (scancode >= dev->keycodemax)
+	if (!dev->keycodesize)
 		return -EINVAL;
 
-	if (!dev->keycodesize)
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+		index = ke->index;
+	} else {
+		error = input_scancode_to_scalar(ke, &index);
+		if (error)
+			return error;
+	}
+
+	if (index >= dev->keycodemax)
 		return -EINVAL;
 
-	if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
+	if (dev->keycodesize < sizeof(dev->keycode) &&
+			(ke->keycode >> (dev->keycodesize * 8)))
 		return -EINVAL;
 
 	switch (dev->keycodesize) {
 		case 1: {
 			u8 *k = (u8 *)dev->keycode;
-			old_keycode = k[scancode];
-			k[scancode] = keycode;
+			*old_keycode = k[index];
+			k[index] = ke->keycode;
 			break;
 		}
 		case 2: {
 			u16 *k = (u16 *)dev->keycode;
-			old_keycode = k[scancode];
-			k[scancode] = keycode;
+			*old_keycode = k[index];
+			k[index] = ke->keycode;
 			break;
 		}
 		default: {
 			u32 *k = (u32 *)dev->keycode;
-			old_keycode = k[scancode];
-			k[scancode] = keycode;
+			*old_keycode = k[index];
+			k[index] = ke->keycode;
 			break;
 		}
 	}
 
-	__clear_bit(old_keycode, dev->keybit);
-	__set_bit(keycode, dev->keybit);
+	__clear_bit(*old_keycode, dev->keybit);
+	__set_bit(ke->keycode, dev->keybit);
 
 	for (i = 0; i < dev->keycodemax; i++) {
-		if (input_fetch_keycode(dev, i) == old_keycode) {
-			__set_bit(old_keycode, dev->keybit);
+		if (input_fetch_keycode(dev, i) == *old_keycode) {
+			__set_bit(*old_keycode, dev->keybit);
 			break; /* Setting the bit twice is useless, so break */
 		}
 	}
@@ -716,53 +779,86 @@ static int input_default_setkeycode(struct input_dev *dev,
 /**
  * input_get_keycode - retrieve keycode currently mapped to a given scancode
  * @dev: input device which keymap is being queried
- * @scancode: scancode (or its equivalent for device in question) for which
- *	keycode is needed
- * @keycode: result
+ * @ke: keymap entry
  *
  * This function should be called by anyone interested in retrieving current
- * keymap. Presently keyboard and evdev handlers use it.
+ * keymap. Presently evdev handlers use it.
  */
-int input_get_keycode(struct input_dev *dev,
-		      unsigned int scancode, unsigned int *keycode)
+int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
 {
 	unsigned long flags;
 	int retval;
 
 	spin_lock_irqsave(&dev->event_lock, flags);
-	retval = dev->getkeycode(dev, scancode, keycode);
-	spin_unlock_irqrestore(&dev->event_lock, flags);
 
+	if (dev->getkeycode) {
+		/*
+		 * Support for legacy drivers, that don't implement the new
+		 * ioctls
+		 */
+		u32 scancode = ke->index;
+
+		memcpy(ke->scancode, &scancode, sizeof(scancode));
+		ke->len = sizeof(scancode);
+		retval = dev->getkeycode(dev, scancode, &ke->keycode);
+	} else {
+		retval = dev->getkeycode_new(dev, ke);
+	}
+
+	spin_unlock_irqrestore(&dev->event_lock, flags);
 	return retval;
 }
 EXPORT_SYMBOL(input_get_keycode);
 
 /**
- * input_get_keycode - assign new keycode to a given scancode
+ * input_set_keycode - attribute a keycode to a given scancode
  * @dev: input device which keymap is being updated
- * @scancode: scancode (or its equivalent for device in question)
- * @keycode: new keycode to be assigned to the scancode
+ * @ke: new keymap entry
  *
  * This function should be called by anyone needing to update current
  * keymap. Presently keyboard and evdev handlers use it.
  */
 int input_set_keycode(struct input_dev *dev,
-		      unsigned int scancode, unsigned int keycode)
+		      const struct input_keymap_entry *ke)
 {
 	unsigned long flags;
 	unsigned int old_keycode;
 	int retval;
 
-	if (keycode > KEY_MAX)
+	if (ke->keycode > KEY_MAX)
 		return -EINVAL;
 
 	spin_lock_irqsave(&dev->event_lock, flags);
 
-	retval = dev->getkeycode(dev, scancode, &old_keycode);
-	if (retval)
-		goto out;
+	if (dev->setkeycode) {
+		/*
+		 * Support for legacy drivers, that don't implement the new
+		 * ioctls
+		 */
+		unsigned int scancode;
+
+		retval = input_scancode_to_scalar(ke, &scancode);
+		if (retval)
+			goto out;
+
+		/*
+		 * We need to know the old scancode, in order to generate a
+		 * keyup effect, if the set operation happens successfully
+		 */
+		if (!dev->getkeycode) {
+			retval = -EINVAL;
+			goto out;
+		}
+
+		retval = dev->getkeycode(dev, scancode, &old_keycode);
+		if (retval)
+			goto out;
+
+		retval = dev->setkeycode(dev, scancode, ke->keycode);
+	} else {
+		retval = dev->setkeycode_new(dev, ke, &old_keycode);
+	}
 
-	retval = dev->setkeycode(dev, scancode, keycode);
 	if (retval)
 		goto out;
 
@@ -1759,11 +1855,11 @@ int input_register_device(struct input_dev *dev)
 		dev->rep[REP_PERIOD] = 33;
 	}
 
-	if (!dev->getkeycode)
-		dev->getkeycode = input_default_getkeycode;
+	if (!dev->getkeycode && !dev->getkeycode_new)
+		dev->getkeycode_new = input_default_getkeycode;
 
-	if (!dev->setkeycode)
-		dev->setkeycode = input_default_setkeycode;
+	if (!dev->setkeycode && !dev->setkeycode_new)
+		dev->setkeycode_new = input_default_setkeycode;
 
 	dev_set_name(&dev->dev, "input%ld",
 		     (unsigned long) atomic_inc_return(&input_no) - 1);
diff --git a/include/linux/input.h b/include/linux/input.h
index 7892651..0057698 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -34,7 +34,7 @@ struct input_event {
  * Protocol version.
  */
 
-#define EV_VERSION		0x010000
+#define EV_VERSION		0x010001
 
 /*
  * IOCTLs (0x00 - 0x7f)
@@ -56,12 +56,37 @@ struct input_absinfo {
 	__s32 resolution;
 };
 
+/**
+ * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
+ * @scancode: scancode represented in machine-endian form.
+ * @len: length of the scancode that resides in @scancode buffer.
+ * @index: index in the keymap, may be used instead of scancode
+ * @flags: allows to specify how kernel should handle the request. For
+ *	example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
+ *	should perform lookup in keymap by @index instead of @scancode
+ * @keycode: key code assigned to this scancode
+ *
+ * The structure is used to retrieve and modify keymap data. Users have
+ * option of performing lookup either by @scancode itself or by @index
+ * in keymap entry. EVIOCGKEYCODE will also return scancode or index
+ * (depending on which element was used to perform lookup).
+ */
+struct input_keymap_entry {
+#define INPUT_KEYMAP_BY_INDEX	(1 << 0)
+	__u8  flags;
+	__u8  len;
+	__u16 index;
+	__u32 keycode;
+	__u8  scancode[32];
+};
+
 #define EVIOCGVERSION		_IOR('E', 0x01, int)			/* get driver version */
 #define EVIOCGID		_IOR('E', 0x02, struct input_id)	/* get device ID */
 #define EVIOCGREP		_IOR('E', 0x03, unsigned int[2])	/* get repeat settings */
 #define EVIOCSREP		_IOW('E', 0x03, unsigned int[2])	/* set repeat settings */
-#define EVIOCGKEYCODE		_IOR('E', 0x04, unsigned int[2])	/* get keycode */
-#define EVIOCSKEYCODE		_IOW('E', 0x04, unsigned int[2])	/* set keycode */
+
+#define EVIOCGKEYCODE		_IOR('E', 0x04, struct input_keymap_entry)	/* get keycode */
+#define EVIOCSKEYCODE		_IOW('E', 0x04, struct input_keymap_entry)	/* set keycode */
 
 #define EVIOCGNAME(len)		_IOC(_IOC_READ, 'E', 0x06, len)		/* get device name */
 #define EVIOCGPHYS(len)		_IOC(_IOC_READ, 'E', 0x07, len)		/* get physical location */
@@ -73,8 +98,8 @@ struct input_absinfo {
 #define EVIOCGSW(len)		_IOC(_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
 
 #define EVIOCGBIT(ev,len)	_IOC(_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
-#define EVIOCGABS(abs)		_IOR('E', 0x40 + abs, struct input_absinfo)		/* get abs value/limits */
-#define EVIOCSABS(abs)		_IOW('E', 0xc0 + abs, struct input_absinfo)		/* set abs value/limits */
+#define EVIOCGABS(abs)		_IOR('E', 0x40 + abs, struct input_absinfo)	/* get abs value/limits */
+#define EVIOCSABS(abs)		_IOW('E', 0xc0 + abs, struct input_absinfo)	/* set abs value/limits */
 
 #define EVIOCSFF		_IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect))	/* send a force effect to a force feedback device */
 #define EVIOCRMFF		_IOW('E', 0x81, int)			/* Erase a force effect */
@@ -1088,13 +1113,13 @@ struct input_mt_slot {
  * @keycodemax: size of keycode table
  * @keycodesize: size of elements in keycode table
  * @keycode: map of scancodes to keycodes for this device
+ * @getkeycode: optional legacy method to retrieve current keymap.
  * @setkeycode: optional method to alter current keymap, used to implement
  *	sparse keymaps. If not supplied default mechanism will be used.
  *	The method is being called while holding event_lock and thus must
  *	not sleep
- * @getkeycode: optional method to retrieve current keymap. If not supplied
- *	default mechanism will be used. The method is being called while
- *	holding event_lock and thus must not sleep
+ * @getkeycode_new: transition method
+ * @setkeycode_new: transition method
  * @ff: force feedback structure associated with the device if device
  *	supports force feedback effects
  * @repeat_key: stores key code of the last key pressed; used to implement
@@ -1168,10 +1193,16 @@ struct input_dev {
 	unsigned int keycodemax;
 	unsigned int keycodesize;
 	void *keycode;
+
 	int (*setkeycode)(struct input_dev *dev,
 			  unsigned int scancode, unsigned int keycode);
 	int (*getkeycode)(struct input_dev *dev,
 			  unsigned int scancode, unsigned int *keycode);
+	int (*setkeycode_new)(struct input_dev *dev,
+			      const struct input_keymap_entry *ke,
+			      unsigned int *old_keycode);
+	int (*getkeycode_new)(struct input_dev *dev,
+			      struct input_keymap_entry *ke);
 
 	struct ff_device *ff;
 
@@ -1478,10 +1509,12 @@ INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz)
 INPUT_GENERATE_ABS_ACCESSORS(flat, flat)
 INPUT_GENERATE_ABS_ACCESSORS(res, resolution)
 
-int input_get_keycode(struct input_dev *dev,
-		      unsigned int scancode, unsigned int *keycode);
+int input_scancode_to_scalar(const struct input_keymap_entry *ke,
+			     unsigned int *scancode);
+
+int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
 int input_set_keycode(struct input_dev *dev,
-		      unsigned int scancode, unsigned int keycode);
+		      const struct input_keymap_entry *ke);
 
 extern struct class input_class;
 


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

* [PATCH 2/6] Input: sparse-keymap - switch to using new keycode interface
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
  2010-09-08  7:41 ` [PATCH 1/6] Input: add support for large scancodes Dmitry Torokhov
@ 2010-09-08  7:41 ` Dmitry Torokhov
  2010-09-08  7:41 ` [PATCH 3/6] Input: hid-input " Dmitry Torokhov
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Switch sparse keymap library to use new style of getkeycode and
setkeycode methods to allow retrieving and setting keycodes not
only by their scancodes but also by index.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/sparse-keymap.c |   81 +++++++++++++++++++++++++++++++++--------
 1 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 0142483..a29a7812 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -22,6 +22,37 @@ MODULE_DESCRIPTION("Generic support for sparse keymaps");
 MODULE_LICENSE("GPL v2");
 MODULE_VERSION("0.1");
 
+static unsigned int sparse_keymap_get_key_index(struct input_dev *dev,
+						const struct key_entry *k)
+{
+	struct key_entry *key;
+	unsigned int idx = 0;
+
+	for (key = dev->keycode; key->type != KE_END; key++) {
+		if (key->type == KE_KEY) {
+			if (key == k)
+				break;
+			idx++;
+		}
+	}
+
+	return idx;
+}
+
+static struct key_entry *sparse_keymap_entry_by_index(struct input_dev *dev,
+						      unsigned int index)
+{
+	struct key_entry *key;
+	unsigned int key_cnt = 0;
+
+	for (key = dev->keycode; key->type != KE_END; key++)
+		if (key->type == KE_KEY)
+			if (key_cnt++ == index)
+				return key;
+
+	return NULL;
+}
+
 /**
  * sparse_keymap_entry_from_scancode - perform sparse keymap lookup
  * @dev: Input device using sparse keymap
@@ -64,16 +95,36 @@ struct key_entry *sparse_keymap_entry_from_keycode(struct input_dev *dev,
 }
 EXPORT_SYMBOL(sparse_keymap_entry_from_keycode);
 
+static struct key_entry *sparse_keymap_locate(struct input_dev *dev,
+					const struct input_keymap_entry *ke)
+{
+	struct key_entry *key;
+	unsigned int scancode;
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+		key = sparse_keymap_entry_by_index(dev, ke->index);
+	else if (input_scancode_to_scalar(ke, &scancode) == 0)
+		key = sparse_keymap_entry_from_scancode(dev, scancode);
+	else
+		key = NULL;
+
+	return key;
+}
+
 static int sparse_keymap_getkeycode(struct input_dev *dev,
-				    unsigned int scancode,
-				    unsigned int *keycode)
+				    struct input_keymap_entry *ke)
 {
 	const struct key_entry *key;
 
 	if (dev->keycode) {
-		key = sparse_keymap_entry_from_scancode(dev, scancode);
+		key = sparse_keymap_locate(dev, ke);
 		if (key && key->type == KE_KEY) {
-			*keycode = key->keycode;
+			ke->keycode = key->keycode;
+			if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))
+				ke->index =
+					sparse_keymap_get_key_index(dev, key);
+			ke->len = sizeof(key->code);
+			memcpy(ke->scancode, &key->code, sizeof(key->code));
 			return 0;
 		}
 	}
@@ -82,20 +133,19 @@ static int sparse_keymap_getkeycode(struct input_dev *dev,
 }
 
 static int sparse_keymap_setkeycode(struct input_dev *dev,
-				    unsigned int scancode,
-				    unsigned int keycode)
+				    const struct input_keymap_entry *ke,
+				    unsigned int *old_keycode)
 {
 	struct key_entry *key;
-	int old_keycode;
 
 	if (dev->keycode) {
-		key = sparse_keymap_entry_from_scancode(dev, scancode);
+		key = sparse_keymap_locate(dev, ke);
 		if (key && key->type == KE_KEY) {
-			old_keycode = key->keycode;
-			key->keycode = keycode;
-			set_bit(keycode, dev->keybit);
-			if (!sparse_keymap_entry_from_keycode(dev, old_keycode))
-				clear_bit(old_keycode, dev->keybit);
+			*old_keycode = key->keycode;
+			key->keycode = ke->keycode;
+			set_bit(ke->keycode, dev->keybit);
+			if (!sparse_keymap_entry_from_keycode(dev, *old_keycode))
+				clear_bit(*old_keycode, dev->keybit);
 			return 0;
 		}
 	}
@@ -159,15 +209,14 @@ int sparse_keymap_setup(struct input_dev *dev,
 
 	dev->keycode = map;
 	dev->keycodemax = map_size;
-	dev->getkeycode = sparse_keymap_getkeycode;
-	dev->setkeycode = sparse_keymap_setkeycode;
+	dev->getkeycode_new = sparse_keymap_getkeycode;
+	dev->setkeycode_new = sparse_keymap_setkeycode;
 
 	return 0;
 
  err_out:
 	kfree(map);
 	return error;
-
 }
 EXPORT_SYMBOL(sparse_keymap_setup);
 


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

* [PATCH 3/6] Input: hid-input - switch to using new keycode interface
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
  2010-09-08  7:41 ` [PATCH 1/6] Input: add support for large scancodes Dmitry Torokhov
  2010-09-08  7:41 ` [PATCH 2/6] Input: sparse-keymap - switch to using new keycode interface Dmitry Torokhov
@ 2010-09-08  7:41 ` Dmitry Torokhov
  2010-09-08  7:42 ` [PATCH 4/6] Input: winbond-cir " Dmitry Torokhov
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Switch HID code to use new style of getkeycode and setkeycode
methods to allow retrieving and setting keycodes not only by
their scancodes but also by index.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/hid/hid-input.c |  103 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 70 insertions(+), 33 deletions(-)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 6c03dcc..b12c07e 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -68,39 +68,49 @@ static const struct {
 #define map_key_clear(c)	hid_map_usage_clear(hidinput, usage, &bit, \
 		&max, EV_KEY, (c))
 
-static inline int match_scancode(unsigned int code, unsigned int scancode)
+static bool match_scancode(struct hid_usage *usage,
+			   unsigned int cur_idx, unsigned int scancode)
 {
-	if (scancode == 0)
-		return 1;
-
-	return (code & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
+	return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
 }
 
-static inline int match_keycode(unsigned int code, unsigned int keycode)
+static bool match_keycode(struct hid_usage *usage,
+			  unsigned int cur_idx, unsigned int keycode)
 {
-	if (keycode == 0)
-		return 1;
+	return usage->code == keycode;
+}
 
-	return code == keycode;
+static bool match_index(struct hid_usage *usage,
+			unsigned int cur_idx, unsigned int idx)
+{
+	return cur_idx == idx;
 }
 
+typedef bool (*hid_usage_cmp_t)(struct hid_usage *usage,
+				unsigned int cur_idx, unsigned int val);
+
 static struct hid_usage *hidinput_find_key(struct hid_device *hid,
-					   unsigned int scancode,
-					   unsigned int keycode)
+					   hid_usage_cmp_t match,
+					   unsigned int value,
+					   unsigned int *usage_idx)
 {
-	int i, j, k;
+	unsigned int i, j, k, cur_idx = 0;
 	struct hid_report *report;
 	struct hid_usage *usage;
 
 	for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
 		list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
 			for (i = 0; i < report->maxfield; i++) {
-				for ( j = 0; j < report->field[i]->maxusage; j++) {
+				for (j = 0; j < report->field[i]->maxusage; j++) {
 					usage = report->field[i]->usage + j;
-					if (usage->type == EV_KEY &&
-						match_scancode(usage->hid, scancode) &&
-						match_keycode(usage->code, keycode))
-						return usage;
+					if (usage->type == EV_KEY) {
+						if (match(usage, cur_idx, value)) {
+							if (usage_idx)
+								*usage_idx = cur_idx;
+							return usage;
+						}
+						cur_idx++;
+					}
 				}
 			}
 		}
@@ -108,39 +118,66 @@ static struct hid_usage *hidinput_find_key(struct hid_device *hid,
 	return NULL;
 }
 
+static struct hid_usage *hidinput_locate_usage(struct hid_device *hid,
+					const struct input_keymap_entry *ke,
+					unsigned int *index)
+{
+	struct hid_usage *usage;
+	unsigned int scancode;
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+		usage = hidinput_find_key(hid, match_index, ke->index, index);
+	else if (input_scancode_to_scalar(ke, &scancode) == 0)
+		usage = hidinput_find_key(hid, match_scancode, scancode, index);
+	else
+		usage = NULL;
+
+	return usage;
+}
+
 static int hidinput_getkeycode(struct input_dev *dev,
-			       unsigned int scancode, unsigned int *keycode)
+			       struct input_keymap_entry *ke)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct hid_usage *usage;
+	unsigned int scancode, index;
 
-	usage = hidinput_find_key(hid, scancode, 0);
+	usage = hidinput_locate_usage(hid, ke, &index);
 	if (usage) {
-		*keycode = usage->code;
+		ke->keycode = usage->code;
+		ke->index = index;
+		scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE);
+		ke->len = sizeof(scancode);
+		memcpy(ke->scancode, &scancode, sizeof(scancode));
 		return 0;
 	}
+
 	return -EINVAL;
 }
 
 static int hidinput_setkeycode(struct input_dev *dev,
-			       unsigned int scancode, unsigned int keycode)
+			       const struct input_keymap_entry *ke,
+			       unsigned int *old_keycode)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct hid_usage *usage;
-	int old_keycode;
 
-	usage = hidinput_find_key(hid, scancode, 0);
+	usage = hidinput_locate_usage(hid, ke, NULL);
 	if (usage) {
-		old_keycode = usage->code;
-		usage->code = keycode;
+		*old_keycode = usage->code;
+		usage->code = ke->keycode;
 
-		clear_bit(old_keycode, dev->keybit);
+		clear_bit(*old_keycode, dev->keybit);
 		set_bit(usage->code, dev->keybit);
-		dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode);
-		/* Set the keybit for the old keycode if the old keycode is used
-		 * by another key */
-		if (hidinput_find_key (hid, 0, old_keycode))
-			set_bit(old_keycode, dev->keybit);
+		dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n",
+			usage->code, usage->hid);
+
+		/*
+		 * Set the keybit for the old keycode if the old keycode is used
+		 * by another key
+		 */
+		if (hidinput_find_key(hid, match_keycode, *old_keycode, NULL))
+			set_bit(*old_keycode, dev->keybit);
 
 		return 0;
 	}
@@ -748,8 +785,8 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
 					hid->ll_driver->hidinput_input_event;
 				input_dev->open = hidinput_open;
 				input_dev->close = hidinput_close;
-				input_dev->setkeycode = hidinput_setkeycode;
-				input_dev->getkeycode = hidinput_getkeycode;
+				input_dev->setkeycode_new = hidinput_setkeycode;
+				input_dev->getkeycode_new = hidinput_getkeycode;
 
 				input_dev->name = hid->name;
 				input_dev->phys = hid->phys;


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

* [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2010-09-08  7:41 ` [PATCH 3/6] Input: hid-input " Dmitry Torokhov
@ 2010-09-08  7:42 ` Dmitry Torokhov
  2010-09-08 21:16   ` David Härdeman
  2010-09-08  7:42 ` [PATCH 5/6] Input: ati-remote2 " Dmitry Torokhov
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:42 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Switch the code to use new style of getkeycode and setkeycode
methods to allow retrieving and setting keycodes not only by
their scancodes but also by index.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
 1 files changed, 163 insertions(+), 85 deletions(-)

diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index 64f1de7..6a69067 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -172,7 +172,6 @@ enum wbcir_protocol {
 #define WBCIR_MAX_IDLE_BYTES       10
 
 static DEFINE_SPINLOCK(wbcir_lock);
-static DEFINE_RWLOCK(keytable_lock);
 
 struct wbcir_key {
 	u32 scancode;
@@ -184,7 +183,7 @@ struct wbcir_keyentry {
 	struct list_head list;
 };
 
-static struct wbcir_key rc6_def_keymap[] = {
+static const struct wbcir_key rc6_def_keymap[] = {
 	{ 0x800F0400, KEY_NUMERIC_0		},
 	{ 0x800F0401, KEY_NUMERIC_1		},
 	{ 0x800F0402, KEY_NUMERIC_2		},
@@ -365,88 +364,152 @@ wbcir_to_rc6cells(u8 val)
  *
  *****************************************************************************/
 
-static unsigned int
-wbcir_do_getkeycode(struct wbcir_data *data, u32 scancode)
+static struct wbcir_keyentry *
+wbcir_keyentry_by_scancode(struct wbcir_data *data, u32 scancode)
 {
 	struct wbcir_keyentry *keyentry;
-	unsigned int keycode = KEY_RESERVED;
-	unsigned long flags;
 
-	read_lock_irqsave(&keytable_lock, flags);
+	list_for_each_entry(keyentry, &data->keytable, list)
+		if (keyentry->key.scancode == scancode)
+			return keyentry;
+
+	return NULL;
+}
+
+static struct wbcir_keyentry *
+wbcir_keyentry_by_index(struct wbcir_data *data, unsigned int index)
+{
+	struct wbcir_keyentry *keyentry;
+	unsigned int cur_idx = 0;
+
+	list_for_each_entry(keyentry, &data->keytable, list)
+		if (cur_idx++ == index)
+			return keyentry;
+
+	return NULL;
+}
+
+static struct wbcir_keyentry *
+wbcir_lookup_keyentry(struct wbcir_data *data,
+		      const struct input_keymap_entry *ke)
+{
+	struct wbcir_keyentry *keyentry;
+	unsigned int scancode;
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+		keyentry = wbcir_keyentry_by_index(data, ke->index);
+	else if (input_scancode_to_scalar(ke, &scancode) == 0)
+		keyentry = wbcir_keyentry_by_scancode(data, scancode);
+	else
+		keyentry = NULL;
+
+	return keyentry;
+
+}
+
+static unsigned int
+wbcir_keyentry_get_index(struct wbcir_data *data,
+			 const struct wbcir_keyentry *keyentry)
+{
+	struct wbcir_keyentry *k;
+	int idx = 0;
 
-	list_for_each_entry(keyentry, &data->keytable, list) {
-		if (keyentry->key.scancode == scancode) {
-			keycode = keyentry->key.keycode;
+	list_for_each_entry(k, &data->keytable, list) {
+		if (k == keyentry)
 			break;
-		}
+		idx++;
 	}
 
-	read_unlock_irqrestore(&keytable_lock, flags);
-	return keycode;
+	return idx;
 }
 
 static int
-wbcir_getkeycode(struct input_dev *dev,
-		 unsigned int scancode, unsigned int *keycode)
+wbcir_getkeycode(struct input_dev *dev, struct input_keymap_entry *ke)
 {
 	struct wbcir_data *data = input_get_drvdata(dev);
+	const struct wbcir_keyentry *keyentry;
+
+	keyentry = wbcir_lookup_keyentry(data, ke);
+	if (keyentry) {
+		ke->keycode = keyentry->key.keycode;
+		if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))
+			ke->index = wbcir_keyentry_get_index(data, keyentry);
+		ke->len = sizeof(keyentry->key.scancode);
+		memcpy(ke->scancode, &keyentry->key.scancode,
+			sizeof(keyentry->key.scancode));
+
+		return 0;
+	}
 
-	*keycode = wbcir_do_getkeycode(data, scancode);
-	return 0;
+	return -EINVAL;
 }
 
 static int
 wbcir_setkeycode(struct input_dev *dev,
-		 unsigned int scancode, unsigned int keycode)
+		 const struct input_keymap_entry *ke,
+		 unsigned int *old_keycode)
 {
 	struct wbcir_data *data = input_get_drvdata(dev);
 	struct wbcir_keyentry *keyentry;
-	struct wbcir_keyentry *new_keyentry;
-	unsigned long flags;
-	unsigned int old_keycode = KEY_RESERVED;
-
-	new_keyentry = kmalloc(sizeof(*new_keyentry), GFP_KERNEL);
-	if (!new_keyentry)
-		return -ENOMEM;
+	unsigned int scancode;
 
-	write_lock_irqsave(&keytable_lock, flags);
+	*old_keycode = KEY_RESERVED;
 
-	list_for_each_entry(keyentry, &data->keytable, list) {
-		if (keyentry->key.scancode != scancode)
-			continue;
+	if (input_scancode_to_scalar(ke, &scancode))
+		return -EINVAL;
 
-		old_keycode = keyentry->key.keycode;
-		keyentry->key.keycode = keycode;
+	keyentry = wbcir_lookup_keyentry(data, ke);
+	if (keyentry) {
+		*old_keycode = keyentry->key.keycode;
+		clear_bit(*old_keycode, dev->keybit);
+	} else {
+		if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+			return -EINVAL;
 
-		if (keyentry->key.keycode == KEY_RESERVED) {
-			list_del(&keyentry->list);
-			kfree(keyentry);
-		}
+		keyentry = kmalloc(sizeof(*keyentry), GFP_ATOMIC);
+		if (!keyentry)
+			return -ENOMEM;
 
-		break;
+		list_add_tail(&keyentry->list, &data->keytable);
 	}
 
-	set_bit(keycode, dev->keybit);
+	keyentry->key.keycode = ke->keycode;
+	keyentry->key.scancode = scancode;
 
-	if (old_keycode == KEY_RESERVED) {
-		new_keyentry->key.scancode = scancode;
-		new_keyentry->key.keycode = keycode;
-		list_add(&new_keyentry->list, &data->keytable);
+	if (keyentry->key.keycode == KEY_RESERVED) {
+		list_del(&keyentry->list);
+		kfree(keyentry);
 	} else {
-		kfree(new_keyentry);
-		clear_bit(old_keycode, dev->keybit);
+		set_bit(ke->keycode, dev->keybit);
 		list_for_each_entry(keyentry, &data->keytable, list) {
-			if (keyentry->key.keycode == old_keycode) {
-				set_bit(old_keycode, dev->keybit);
+			if (keyentry->key.keycode == *old_keycode) {
+				set_bit(*old_keycode, dev->keybit);
 				break;
 			}
 		}
 	}
 
-	write_unlock_irqrestore(&keytable_lock, flags);
 	return 0;
 }
 
+static unsigned int
+wbcir_fetch_keycode(struct wbcir_data *data, u32 scancode)
+{
+	struct input_dev *input = data->input_dev;
+	const struct wbcir_keyentry *keyentry;
+	unsigned int keycode;
+	unsigned long flags;
+
+	/* Take event lock to prevent race with setkeycode */
+	spin_lock_irqsave(&input->event_lock, flags);
+
+	keyentry = wbcir_keyentry_by_scancode(data, scancode);
+	keycode = keyentry ? keyentry->key.keycode : KEY_RESERVED;
+
+	spin_unlock_irqrestore(&input->event_lock, flags);
+	return keycode;
+}
+
 /*
  * Timer function to report keyup event some time after keydown is
  * reported by the ISR.
@@ -503,7 +566,7 @@ wbcir_keydown(struct wbcir_data *data, u32 scancode, u8 toggle)
 	input_event(data->input_dev, EV_MSC, MSC_SCAN, (int)scancode);
 
 	/* Do we know this scancode? */
-	keycode = wbcir_do_getkeycode(data, scancode);
+	keycode = wbcir_fetch_keycode(data, scancode);
 	if (keycode == KEY_RESERVED)
 		goto set_timer;
 
@@ -1247,7 +1310,7 @@ wbcir_init_hw(struct wbcir_data *data)
 
 	/*
 	 * Clear IR LED, set SP3 clock to 24Mhz
-	 * set SP3_IRRX_SW to binary 01, helpfully not documented
+	;* set SP3_IRRX_SW to binary 01, helpfully not documented
 	 */
 	outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS);
 
@@ -1339,6 +1402,41 @@ wbcir_resume(struct pnp_dev *device)
 	return 0;
 }
 
+static void
+wbcir_free_keymap(struct wbcir_data *data)
+{
+	struct wbcir_keyentry *key, *next;
+
+	list_for_each_entry_safe(key, next, &data->keytable, list) {
+		list_del(&key->list);
+		kfree(key);
+	}
+}
+
+static int
+wbcir_load_keymap(struct wbcir_data *data,
+		  const struct wbcir_key *keymap, unsigned int keymap_size)
+{
+	struct wbcir_keyentry *keyentry;
+	int i;
+
+	for (i = 0; i < keymap_size; i++) {
+		if (keymap[i].keycode != KEY_RESERVED) {
+			keyentry = kmalloc(sizeof(*keyentry), GFP_KERNEL);
+			if (!keyentry) {
+				wbcir_free_keymap(data);
+				return -ENOMEM;
+			}
+
+			keyentry->key.keycode = keymap[i].keycode;
+			keyentry->key.scancode = keymap[i].scancode;
+			list_add_tail(&keyentry->list, &data->keytable);
+		}
+	}
+
+	return 0;
+}
+
 static int __devinit
 wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
 {
@@ -1359,6 +1457,10 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
 		goto exit;
 	}
 
+	data->last_scancode = INVALID_SCANCODE;
+	INIT_LIST_HEAD(&data->keytable);
+	setup_timer(&data->timer_keyup, wbcir_keyup, (unsigned long)data);
+
 	pnp_set_drvdata(device, data);
 
 	data->ebase = pnp_port_start(device, 0);
@@ -1439,50 +1541,31 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
 	data->input_dev->id.vendor  = PCI_VENDOR_ID_WINBOND;
 	data->input_dev->id.product = WBCIR_ID_FAMILY;
 	data->input_dev->id.version = WBCIR_ID_CHIP;
-	data->input_dev->getkeycode = wbcir_getkeycode;
-	data->input_dev->setkeycode = wbcir_setkeycode;
+	data->input_dev->getkeycode_new = wbcir_getkeycode;
+	data->input_dev->setkeycode_new = wbcir_setkeycode;
 	input_set_capability(data->input_dev, EV_MSC, MSC_SCAN);
 	input_set_drvdata(data->input_dev, data);
 
-	err = input_register_device(data->input_dev);
-	if (err)
-		goto exit_free_input;
-
-	data->last_scancode = INVALID_SCANCODE;
-	INIT_LIST_HEAD(&data->keytable);
-	setup_timer(&data->timer_keyup, wbcir_keyup, (unsigned long)data);
-
 	/* Load default keymaps */
 	if (protocol == IR_PROTOCOL_RC6) {
-		int i;
-		for (i = 0; i < ARRAY_SIZE(rc6_def_keymap); i++) {
-			err = wbcir_setkeycode(data->input_dev,
-					       (int)rc6_def_keymap[i].scancode,
-					       (int)rc6_def_keymap[i].keycode);
-			if (err)
-				goto exit_unregister_keys;
-		}
+		err = wbcir_load_keymap(data, rc6_def_keymap,
+					ARRAY_SIZE(rc6_def_keymap));
+		if (err)
+			goto exit_free_input;
 	}
 
+	err = input_register_device(data->input_dev);
+	if (err)
+		goto exit_free_keymap;
+
 	device_init_wakeup(&device->dev, 1);
 
 	wbcir_init_hw(data);
 
 	return 0;
 
-exit_unregister_keys:
-	if (!list_empty(&data->keytable)) {
-		struct wbcir_keyentry *key;
-		struct wbcir_keyentry *keytmp;
-
-		list_for_each_entry_safe(key, keytmp, &data->keytable, list) {
-			list_del(&key->list);
-			kfree(key);
-		}
-	}
-	input_unregister_device(data->input_dev);
-	/* Can't call input_free_device on an unregistered device */
-	data->input_dev = NULL;
+exit_free_keymap:
+	wbcir_free_keymap(data);
 exit_free_input:
 	input_free_device(data->input_dev);
 exit_unregister_led:
@@ -1510,8 +1593,6 @@ static void __devexit
 wbcir_remove(struct pnp_dev *device)
 {
 	struct wbcir_data *data = pnp_get_drvdata(device);
-	struct wbcir_keyentry *key;
-	struct wbcir_keyentry *keytmp;
 
 	/* Disable interrupts */
 	wbcir_select_bank(data, WBCIR_BANK_0);
@@ -1544,10 +1625,7 @@ wbcir_remove(struct pnp_dev *device)
 	release_region(data->ebase, EHFUNC_IOMEM_LEN);
 	release_region(data->sbase, SP_IOMEM_LEN);
 
-	list_for_each_entry_safe(key, keytmp, &data->keytable, list) {
-		list_del(&key->list);
-		kfree(key);
-	}
+	wbcir_free_keymap(data);
 
 	kfree(data);
 


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

* [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2010-09-08  7:42 ` [PATCH 4/6] Input: winbond-cir " Dmitry Torokhov
@ 2010-09-08  7:42 ` Dmitry Torokhov
  2010-09-09 12:40   ` Ville Syrjälä
  2010-09-08  7:42 ` [PATCH 6/6] Input: media/IR " Dmitry Torokhov
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:42 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Switch the code to use new style of getkeycode and setkeycode
methods to allow retrieving and setting keycodes not only by
their scancodes but also by index.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
 1 files changed, 65 insertions(+), 28 deletions(-)

diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 2325765..b2e0d82 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
 }
 
 static int ati_remote2_getkeycode(struct input_dev *idev,
-				  unsigned int scancode, unsigned int *keycode)
+				  struct input_keymap_entry *ke)
 {
 	struct ati_remote2 *ar2 = input_get_drvdata(idev);
 	unsigned int mode;
-	int index;
+	int offset;
+	unsigned int index;
+	unsigned int scancode;
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+		index = ke->index;
+		if (index >= (ATI_REMOTE2_MODES - 1) *
+				ARRAY_SIZE(ati_remote2_key_table))
+			return -EINVAL;
+
+		mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
+		offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
+		scancode = (mode << 8) + ati_remote2_key_table[offset].hw_code;
+	} else {
+		if (input_scancode_to_scalar(ke, &scancode))
+			return -EINVAL;
+
+		mode = scancode >> 8;
+		if (mode > ATI_REMOTE2_PC)
+			return -EINVAL;
+
+		offset = ati_remote2_lookup(scancode & 0xff);
+		if (offset < 0)
+			return -EINVAL;
+
+		index = mode * ARRAY_SIZE(ati_remote2_key_table) + offset;
+	}
 
-	mode = scancode >> 8;
-	if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
-		return -EINVAL;
+	ke->keycode = ar2->keycode[mode][offset];
+	ke->len = sizeof(scancode);
+	memcpy(&ke->scancode, &scancode, sizeof(scancode));
+	ke->index = index;
 
-	index = ati_remote2_lookup(scancode & 0xFF);
-	if (index < 0)
-		return -EINVAL;
-
-	*keycode = ar2->keycode[mode][index];
 	return 0;
 }
 
 static int ati_remote2_setkeycode(struct input_dev *idev,
-				  unsigned int scancode, unsigned int keycode)
+				  const struct input_keymap_entry *ke,
+				  unsigned int *old_keycode)
 {
 	struct ati_remote2 *ar2 = input_get_drvdata(idev);
-	unsigned int mode, old_keycode;
-	int index;
-
-	mode = scancode >> 8;
-	if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
-		return -EINVAL;
-
-	index = ati_remote2_lookup(scancode & 0xFF);
-	if (index < 0)
-		return -EINVAL;
+	unsigned int mode;
+	int offset;
+	unsigned int index;
+	unsigned int scancode;
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+		if (ke->index >= (ATI_REMOTE2_MODES - 1) *
+				ARRAY_SIZE(ati_remote2_key_table))
+			return -EINVAL;
+
+		mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
+		offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
+	} else {
+		if (input_scancode_to_scalar(ke, &scancode))
+			return -EINVAL;
+
+		mode = scancode >> 8;
+		if (mode > ATI_REMOTE2_PC)
+			return -EINVAL;
+
+		offset = ati_remote2_lookup(scancode & 0xff);
+		if (offset < 0)
+			return -EINVAL;
+	}
 
-	old_keycode = ar2->keycode[mode][index];
-	ar2->keycode[mode][index] = keycode;
-	__set_bit(keycode, idev->keybit);
+	*old_keycode = ar2->keycode[mode][offset];
+	ar2->keycode[mode][offset] = ke->keycode;
+	__set_bit(ke->keycode, idev->keybit);
 
 	for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
 		for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
-			if (ar2->keycode[mode][index] == old_keycode)
+			if (ar2->keycode[mode][index] == *old_keycode)
 				return 0;
 		}
 	}
 
-	__clear_bit(old_keycode, idev->keybit);
+	__clear_bit(*old_keycode, idev->keybit);
 
 	return 0;
 }
@@ -575,8 +612,8 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
 	idev->open = ati_remote2_open;
 	idev->close = ati_remote2_close;
 
-	idev->getkeycode = ati_remote2_getkeycode;
-	idev->setkeycode = ati_remote2_setkeycode;
+	idev->getkeycode_new = ati_remote2_getkeycode;
+	idev->setkeycode_new = ati_remote2_setkeycode;
 
 	idev->name = ar2->name;
 	idev->phys = ar2->phys;


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

* [PATCH 6/6] Input: media/IR - switch to using new keycode interface
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2010-09-08  7:42 ` [PATCH 5/6] Input: ati-remote2 " Dmitry Torokhov
@ 2010-09-08  7:42 ` Dmitry Torokhov
  2010-09-08  9:48 ` [PATCH 0/6] Large scancode handling Jiri Kosina
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08  7:42 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Switch the code to use new style of getkeycode and setkeycode
methods to allow retrieving and setting keycodes not only by
their scancodes but also by index.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/media/IR/ir-keytable.c |  393 +++++++++++++++++++++++++++-------------
 include/media/rc-map.h         |    2 
 2 files changed, 263 insertions(+), 132 deletions(-)

diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index 7e82a9d..5ca36a4 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -25,14 +25,56 @@
 #define IR_KEYPRESS_TIMEOUT 250
 
 /**
+ * ir_create_table() - initializes a scancode table
+ * @rc_tab:	the ir_scancode_table to initialize
+ * @name:	name to assign to the table
+ * @ir_type:	ir type to assign to the new table
+ * @size:	initial size of the table
+ * @return:	zero on success or a negative error code
+ *
+ * This routine will initialize the ir_scancode_table and will allocate
+ * memory to hold at least the specified number elements.
+ */
+static int ir_create_table(struct ir_scancode_table *rc_tab,
+			   const char *name, u64 ir_type, size_t size)
+{
+	rc_tab->name = name;
+	rc_tab->ir_type = ir_type;
+	rc_tab->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode));
+	rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode);
+	rc_tab->scan = kmalloc(rc_tab->alloc, GFP_KERNEL);
+	if (!rc_tab->scan)
+		return -ENOMEM;
+
+	IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
+		   rc_tab->size, rc_tab->alloc);
+	return 0;
+}
+
+/**
+ * ir_free_table() - frees memory allocated by a scancode table
+ * @rc_tab:	the table whose mappings need to be freed
+ *
+ * This routine will free memory alloctaed for key mappings used by given
+ * scancode table.
+ */
+static void ir_free_table(struct ir_scancode_table *rc_tab)
+{
+	rc_tab->size = 0;
+	kfree(rc_tab->scan);
+	rc_tab->scan = NULL;
+}
+
+/**
  * ir_resize_table() - resizes a scancode table if necessary
  * @rc_tab:	the ir_scancode_table to resize
+ * @gfp_flags:	gfp flags to use when allocating memory
  * @return:	zero on success or a negative error code
  *
  * This routine will shrink the ir_scancode_table if it has lots of
  * unused entries and grow it if it is full.
  */
-static int ir_resize_table(struct ir_scancode_table *rc_tab)
+static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags)
 {
 	unsigned int oldalloc = rc_tab->alloc;
 	unsigned int newalloc = oldalloc;
@@ -57,7 +99,7 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab)
 	if (newalloc == oldalloc)
 		return 0;
 
-	newscan = kmalloc(newalloc, GFP_ATOMIC);
+	newscan = kmalloc(newalloc, gfp_flags);
 	if (!newscan) {
 		IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc);
 		return -ENOMEM;
@@ -72,26 +114,78 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab)
 }
 
 /**
- * ir_do_setkeycode() - internal function to set a keycode in the
- *			scancode->keycode table
+ * ir_update_mapping() - set a keycode in the scancode->keycode table
  * @dev:	the struct input_dev device descriptor
- * @rc_tab:	the struct ir_scancode_table to set the keycode in
- * @scancode:	the scancode for the ir command
- * @keycode:	the keycode for the ir command
- * @resize:	whether the keytable may be shrunk
- * @return:	-EINVAL if the keycode could not be inserted, otherwise zero.
+ * @rc_tab:	scancode table to be adjusted
+ * @index:	index of the mapping that needs to be updated
+ * @keycode:	the desired keycode
+ * @return:	previous keycode assigned to the mapping
+ *
+ * This routine is used to update scancode->keycopde mapping at given
+ * position.
+ */
+static unsigned int ir_update_mapping(struct input_dev *dev,
+				      struct ir_scancode_table *rc_tab,
+				      unsigned int index,
+				      unsigned int new_keycode)
+{
+	int old_keycode = rc_tab->scan[index].keycode;
+	int i;
+
+	/* Did the user wish to remove the mapping? */
+	if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) {
+		IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",
+			   index, rc_tab->scan[index].scancode);
+		rc_tab->len--;
+		memmove(&rc_tab->scan[index], &rc_tab->scan[index+ 1],
+			(rc_tab->len - index) * sizeof(struct ir_scancode));
+	} else {
+		IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n",
+			   index,
+			   old_keycode == KEY_RESERVED ? "New" : "Replacing",
+			   rc_tab->scan[index].scancode, new_keycode);
+		rc_tab->scan[index].keycode = new_keycode;
+		__set_bit(new_keycode, dev->keybit);
+	}
+
+	if (old_keycode != KEY_RESERVED) {
+		/* A previous mapping was updated... */
+		__clear_bit(old_keycode, dev->keybit);
+		/* ... but another scancode might use the same keycode */
+		for (i = 0; i < rc_tab->len; i++) {
+			if (rc_tab->scan[i].keycode == old_keycode) {
+				__set_bit(old_keycode, dev->keybit);
+				break;
+			}
+		}
+
+		/* Possibly shrink the keytable, failure is not a problem */
+		ir_resize_table(rc_tab, GFP_ATOMIC);
+	}
+
+	return old_keycode;
+}
+
+/**
+ * ir_locate_scancode() - set a keycode in the scancode->keycode table
+ * @ir_dev:	the struct ir_input_dev device descriptor
+ * @rc_tab:	scancode table to be searched
+ * @scancode:	the desired scancode
+ * @resize:	controls whether we allowed to resize the table to
+ *		accomodate not yet present scancodes
+ * @return:	index of the mapping containing scancode in question
+ *		or -1U in case of failure.
  *
- * This routine is used internally to manipulate the scancode->keycode table.
- * The caller has to hold @rc_tab->lock.
+ * This routine is used to locate given scancode in ir_scancode_table.
+ * If scancode is not yet present the routine will allocate a new slot
+ * for it.
  */
-static int ir_do_setkeycode(struct input_dev *dev,
-			    struct ir_scancode_table *rc_tab,
-			    unsigned scancode, unsigned keycode,
-			    bool resize)
+static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev,
+					  struct ir_scancode_table *rc_tab,
+					  unsigned int scancode,
+					  bool resize)
 {
 	unsigned int i;
-	int old_keycode = KEY_RESERVED;
-	struct ir_input_dev *ir_dev = input_get_drvdata(dev);
 
 	/*
 	 * Unfortunately, some hardware-based IR decoders don't provide
@@ -100,65 +194,34 @@ static int ir_do_setkeycode(struct input_dev *dev,
 	 * the provided IR with another one, it is needed to allow loading
 	 * IR tables from other remotes. So,
 	 */
-	if (ir_dev->props && ir_dev->props->scanmask) {
+	if (ir_dev->props && ir_dev->props->scanmask)
 		scancode &= ir_dev->props->scanmask;
-	}
 
 	/* First check if we already have a mapping for this ir command */
 	for (i = 0; i < rc_tab->len; i++) {
+		if (rc_tab->scan[i].scancode == scancode)
+			return i;
+
 		/* Keytable is sorted from lowest to highest scancode */
-		if (rc_tab->scan[i].scancode > scancode)
+		if (rc_tab->scan[i].scancode >= scancode)
 			break;
-		else if (rc_tab->scan[i].scancode < scancode)
-			continue;
-
-		old_keycode = rc_tab->scan[i].keycode;
-		rc_tab->scan[i].keycode = keycode;
-
-		/* Did the user wish to remove the mapping? */
-		if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN) {
-			IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",
-				   i, scancode);
-			rc_tab->len--;
-			memmove(&rc_tab->scan[i], &rc_tab->scan[i + 1],
-				(rc_tab->len - i) * sizeof(struct ir_scancode));
-		}
-
-		/* Possibly shrink the keytable, failure is not a problem */
-		ir_resize_table(rc_tab);
-		break;
 	}
 
-	if (old_keycode == KEY_RESERVED && keycode != KEY_RESERVED) {
-		/* No previous mapping found, we might need to grow the table */
-		if (resize && ir_resize_table(rc_tab))
-			return -ENOMEM;
-
-		IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",
-			   i, scancode, keycode);
+	/* No previous mapping found, we might need to grow the table */
+	if (rc_tab->size == rc_tab->len) {
+		if (!resize || ir_resize_table(rc_tab, GFP_ATOMIC))
+			return -1U;
+	}
 
-		/* i is the proper index to insert our new keycode */
+	/* i is the proper index to insert our new keycode */
+	if (i < rc_tab->len)
 		memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i],
 			(rc_tab->len - i) * sizeof(struct ir_scancode));
-		rc_tab->scan[i].scancode = scancode;
-		rc_tab->scan[i].keycode = keycode;
-		rc_tab->len++;
-		set_bit(keycode, dev->keybit);
-	} else {
-		IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",
-			   i, scancode, keycode);
-		/* A previous mapping was updated... */
-		clear_bit(old_keycode, dev->keybit);
-		/* ...but another scancode might use the same keycode */
-		for (i = 0; i < rc_tab->len; i++) {
-			if (rc_tab->scan[i].keycode == old_keycode) {
-				set_bit(old_keycode, dev->keybit);
-				break;
-			}
-		}
-	}
+	rc_tab->scan[i].scancode = scancode;
+	rc_tab->scan[i].keycode = KEY_RESERVED;
+	rc_tab->len++;
 
-	return 0;
+	return i;
 }
 
 /**
@@ -171,17 +234,41 @@ static int ir_do_setkeycode(struct input_dev *dev,
  * This routine is used to handle evdev EVIOCSKEY ioctl.
  */
 static int ir_setkeycode(struct input_dev *dev,
-			 unsigned int scancode, unsigned int keycode)
+			 const struct input_keymap_entry *ke,
+			 unsigned int *old_keycode)
 {
-	int rc;
-	unsigned long flags;
 	struct ir_input_dev *ir_dev = input_get_drvdata(dev);
 	struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
+	unsigned int index;
+	unsigned int scancode;
+	int retval;
+	unsigned long flags;
 
 	spin_lock_irqsave(&rc_tab->lock, flags);
-	rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode, true);
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+		index = ke->index;
+		if (index >= rc_tab->len) {
+			retval = -EINVAL;
+			goto out;
+		}
+	} else {
+		retval = input_scancode_to_scalar(ke, &scancode);
+		if (retval)
+			goto out;
+
+		index = ir_establish_scancode(ir_dev, rc_tab, scancode, true);
+		if (index >= rc_tab->len) {
+			retval = -ENOMEM;
+			goto out;
+		}
+	}
+
+	*old_keycode = ir_update_mapping(dev, rc_tab, index, ke->keycode);
+
+out:
 	spin_unlock_irqrestore(&rc_tab->lock, flags);
-	return rc;
+	return retval;
 }
 
 /**
@@ -189,32 +276,73 @@ static int ir_setkeycode(struct input_dev *dev,
  * @dev:	the struct input_dev device descriptor
  * @to:		the struct ir_scancode_table to copy entries to
  * @from:	the struct ir_scancode_table to copy entries from
- * @return:	-EINVAL if all keycodes could not be inserted, otherwise zero.
+ * @return:	-ENOMEM if all keycodes could not be inserted, otherwise zero.
  *
  * This routine is used to handle table initialization.
  */
-static int ir_setkeytable(struct input_dev *dev,
-			  struct ir_scancode_table *to,
+static int ir_setkeytable(struct ir_input_dev *ir_dev,
 			  const struct ir_scancode_table *from)
 {
-	struct ir_input_dev *ir_dev = input_get_drvdata(dev);
 	struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
-	unsigned long flags;
-	unsigned int i;
-	int rc = 0;
+	unsigned int i, index;
+	int rc;
+
+	rc = ir_create_table(&ir_dev->rc_tab,
+			     from->name, from->ir_type, from->size);
+	if (rc)
+		return rc;
+
+	IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
+		   rc_tab->size, rc_tab->alloc);
 
-	spin_lock_irqsave(&rc_tab->lock, flags);
 	for (i = 0; i < from->size; i++) {
-		rc = ir_do_setkeycode(dev, to, from->scan[i].scancode,
-				      from->scan[i].keycode, false);
-		if (rc)
+		index = ir_establish_scancode(ir_dev, rc_tab,
+					      from->scan[i].scancode, false);
+		if (index >= rc_tab->len) {
+			rc = -ENOMEM;
 			break;
+		}
+
+		ir_update_mapping(ir_dev->input_dev, rc_tab, index,
+				  from->scan[i].keycode);
 	}
-	spin_unlock_irqrestore(&rc_tab->lock, flags);
+
+	if (rc)
+		ir_free_table(rc_tab);
+
 	return rc;
 }
 
 /**
+ * ir_lookup_by_scancode() - locate mapping by scancode
+ * @rc_tab:	the &struct ir_scancode_table to search
+ * @scancode:	scancode to look for in the table
+ * @return:	index in the table, -1U if not found
+ *
+ * This routine performs binary search in RC keykeymap table for
+ * given scancode.
+ */
+static unsigned int ir_lookup_by_scancode(const struct ir_scancode_table *rc_tab,
+					  unsigned int scancode)
+{
+	unsigned int start = 0;
+	unsigned int end = rc_tab->len - 1;
+	unsigned int mid;
+
+	while (start <= end) {
+		mid = (start + end) / 2;
+		if (rc_tab->scan[mid].scancode < scancode)
+			start = mid + 1;
+		else if (rc_tab->scan[mid].scancode > scancode)
+			end = mid - 1;
+		else
+			return mid;
+	}
+
+	return -1U;
+}
+
+/**
  * ir_getkeycode() - get a keycode from the scancode->keycode table
  * @dev:	the struct input_dev device descriptor
  * @scancode:	the desired scancode
@@ -224,36 +352,46 @@ static int ir_setkeytable(struct input_dev *dev,
  * This routine is used to handle evdev EVIOCGKEY ioctl.
  */
 static int ir_getkeycode(struct input_dev *dev,
-			 unsigned int scancode, unsigned int *keycode)
+			 struct input_keymap_entry *ke)
 {
-	int start, end, mid;
-	unsigned long flags;
-	int key = KEY_RESERVED;
 	struct ir_input_dev *ir_dev = input_get_drvdata(dev);
 	struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
+	struct ir_scancode *entry;
+	unsigned long flags;
+	unsigned int index;
+	unsigned int scancode;
+	int retval;
 
 	spin_lock_irqsave(&rc_tab->lock, flags);
-	start = 0;
-	end = rc_tab->len - 1;
-	while (start <= end) {
-		mid = (start + end) / 2;
-		if (rc_tab->scan[mid].scancode < scancode)
-			start = mid + 1;
-		else if (rc_tab->scan[mid].scancode > scancode)
-			end = mid - 1;
-		else {
-			key = rc_tab->scan[mid].keycode;
-			break;
-		}
+
+	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+		index = ke->index;
+	} else {
+		retval = input_scancode_to_scalar(ke, &scancode);
+		if (retval)
+			goto out;
+
+		index = ir_lookup_by_scancode(rc_tab, scancode);
+	}
+
+	if (index >= rc_tab->len) {
+		if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))
+			IR_dprintk(1, "unknown key for scancode 0x%04x\n",
+				   scancode);
+		retval = -EINVAL;
+		goto out;
 	}
-	spin_unlock_irqrestore(&rc_tab->lock, flags);
 
-	if (key == KEY_RESERVED)
-		IR_dprintk(1, "unknown key for scancode 0x%04x\n",
-			   scancode);
+	entry = &rc_tab->scan[index];
 
-	*keycode = key;
-	return 0;
+	ke->index = index;
+	ke->keycode = entry->keycode;
+	ke->len = sizeof(entry->scancode);
+	memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));
+
+out:
+	spin_unlock_irqrestore(&rc_tab->lock, flags);
+	return retval;
 }
 
 /**
@@ -268,12 +406,24 @@ static int ir_getkeycode(struct input_dev *dev,
  */
 u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
 {
-	int keycode;
+	struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+	struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
+	unsigned int keycode;
+	unsigned int index;
+	unsigned long flags;
+
+	spin_lock_irqsave(&rc_tab->lock, flags);
+
+	index = ir_lookup_by_scancode(rc_tab, scancode);
+	keycode = index < rc_tab->len ?
+			rc_tab->scan[index].keycode : KEY_RESERVED;
+
+	spin_unlock_irqrestore(&rc_tab->lock, flags);
 
-	ir_getkeycode(dev, scancode, &keycode);
 	if (keycode != KEY_RESERVED)
 		IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
 			   dev->name, scancode, keycode);
+
 	return keycode;
 }
 EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
@@ -453,8 +603,8 @@ int __ir_input_register(struct input_dev *input_dev,
 		goto out_dev;
 	}
 
-	input_dev->getkeycode = ir_getkeycode;
-	input_dev->setkeycode = ir_setkeycode;
+	input_dev->getkeycode_new = ir_getkeycode;
+	input_dev->setkeycode_new = ir_setkeycode;
 	input_set_drvdata(input_dev, ir_dev);
 	ir_dev->input_dev = input_dev;
 
@@ -462,12 +612,6 @@ int __ir_input_register(struct input_dev *input_dev,
 	spin_lock_init(&ir_dev->keylock);
 	setup_timer(&ir_dev->timer_keyup, ir_timer_keyup, (unsigned long)ir_dev);
 
-	ir_dev->rc_tab.name = rc_tab->name;
-	ir_dev->rc_tab.ir_type = rc_tab->ir_type;
-	ir_dev->rc_tab.alloc = roundup_pow_of_two(rc_tab->size *
-						  sizeof(struct ir_scancode));
-	ir_dev->rc_tab.scan = kmalloc(ir_dev->rc_tab.alloc, GFP_KERNEL);
-	ir_dev->rc_tab.size = ir_dev->rc_tab.alloc / sizeof(struct ir_scancode);
 	if (props) {
 		ir_dev->props = props;
 		if (props->open)
@@ -476,23 +620,14 @@ int __ir_input_register(struct input_dev *input_dev,
 			input_dev->close = ir_close;
 	}
 
-	if (!ir_dev->rc_tab.scan) {
-		rc = -ENOMEM;
-		goto out_name;
-	}
-
-	IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
-		   ir_dev->rc_tab.size, ir_dev->rc_tab.alloc);
-
 	set_bit(EV_KEY, input_dev->evbit);
 	set_bit(EV_REP, input_dev->evbit);
 	set_bit(EV_MSC, input_dev->evbit);
 	set_bit(MSC_SCAN, input_dev->mscbit);
 
-	if (ir_setkeytable(input_dev, &ir_dev->rc_tab, rc_tab)) {
-		rc = -ENOMEM;
-		goto out_table;
-	}
+	rc = ir_setkeytable(ir_dev, rc_tab);
+	if (rc)
+		goto out_name;
 
 	rc = ir_register_class(input_dev);
 	if (rc < 0)
@@ -515,7 +650,7 @@ int __ir_input_register(struct input_dev *input_dev,
 out_event:
 	ir_unregister_class(input_dev);
 out_table:
-	kfree(ir_dev->rc_tab.scan);
+	ir_free_table(&ir_dev->rc_tab);
 out_name:
 	kfree(ir_dev->driver_name);
 out_dev:
@@ -533,7 +668,6 @@ EXPORT_SYMBOL_GPL(__ir_input_register);
 void ir_input_unregister(struct input_dev *input_dev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	struct ir_scancode_table *rc_tab;
 
 	if (!ir_dev)
 		return;
@@ -545,10 +679,7 @@ void ir_input_unregister(struct input_dev *input_dev)
 		if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW)
 			ir_raw_event_unregister(input_dev);
 
-	rc_tab = &ir_dev->rc_tab;
-	rc_tab->size = 0;
-	kfree(rc_tab->scan);
-	rc_tab->scan = NULL;
+	ir_free_table(&ir_dev->rc_tab);
 
 	ir_unregister_class(input_dev);
 
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index a9c041d..9b201ec 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -35,7 +35,7 @@ struct ir_scancode_table {
 	unsigned int		len;	/* Used number of entries */
 	unsigned int		alloc;	/* Size of *scan in bytes */
 	u64			ir_type;
-	char			*name;
+	const char		*name;
 	spinlock_t		lock;
 };
 


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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
                   ` (5 preceding siblings ...)
  2010-09-08  7:42 ` [PATCH 6/6] Input: media/IR " Dmitry Torokhov
@ 2010-09-08  9:48 ` Jiri Kosina
  2010-09-08 14:24   ` Jarod Wilson
  2010-09-08 15:36   ` Dmitry Torokhov
  2010-09-08 14:31 ` Jarod Wilson
  2010-09-08 15:23 ` Mauro Carvalho Chehab
  8 siblings, 2 replies; 38+ messages in thread
From: Jiri Kosina @ 2010-09-08  9:48 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, 8 Sep 2010, Dmitry Torokhov wrote:

> Hi Mauro,
> 
> I guess I better get off my behind and commit the changes to support large
> scancodes, or they will not make to 2.6.37 either... There isn't much
> changes, except I followed David's suggestion and changed boolean index
> field into u8 flags field. Still, please glance it over once again and
> shout if you see something you do not like.
> 
> Jiri, how do you want to handle the changes to HID? I could either push
> them through my tree together with the first patch or you can push through
> yours once the first change hits mainline.

I think that there will unlikely be any conflict in .37 merge window in 
this area (and if there were, I'll sort it out).

So please add

	Acked-by: Jiri Kosina <jkosina@suse.cz>

to the hid-input.c bits and feel free to take it through your tree, if it 
is convenient for you.

Thanks,

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08  9:48 ` [PATCH 0/6] Large scancode handling Jiri Kosina
@ 2010-09-08 14:24   ` Jarod Wilson
  2010-09-08 15:15     ` Mauro Carvalho Chehab
  2010-09-08 15:36   ` Dmitry Torokhov
  1 sibling, 1 reply; 38+ messages in thread
From: Jarod Wilson @ 2010-09-08 14:24 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Dmitry Torokhov, Mauro Carvalho Chehab, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 11:48:50AM +0200, Jiri Kosina wrote:
> On Wed, 8 Sep 2010, Dmitry Torokhov wrote:
> 
> > Hi Mauro,
> > 
> > I guess I better get off my behind and commit the changes to support large
> > scancodes, or they will not make to 2.6.37 either... There isn't much
> > changes, except I followed David's suggestion and changed boolean index
> > field into u8 flags field. Still, please glance it over once again and
> > shout if you see something you do not like.
> > 
> > Jiri, how do you want to handle the changes to HID? I could either push
> > them through my tree together with the first patch or you can push through
> > yours once the first change hits mainline.
> 
> I think that there will unlikely be any conflict in .37 merge window in 
> this area (and if there were, I'll sort it out).
> 
> So please add
> 
> 	Acked-by: Jiri Kosina <jkosina@suse.cz>
> 
> to the hid-input.c bits and feel free to take it through your tree, if it 
> is convenient for you.

It'll conflict a little bith with the tivo slide patch I posted yesterday,
but mostly just minor context changes. I can redo that patch on top of
these changes if that's preferred.

-- 
Jarod Wilson
jarod@redhat.com


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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
                   ` (6 preceding siblings ...)
  2010-09-08  9:48 ` [PATCH 0/6] Large scancode handling Jiri Kosina
@ 2010-09-08 14:31 ` Jarod Wilson
  2010-09-08 15:34   ` Dmitry Torokhov
  2010-09-08 15:23 ` Mauro Carvalho Chehab
  8 siblings, 1 reply; 38+ messages in thread
From: Jarod Wilson @ 2010-09-08 14:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 12:41:38AM -0700, Dmitry Torokhov wrote:
> Hi Mauro,
> 
> I guess I better get off my behind and commit the changes to support large
> scancodes, or they will not make to 2.6.37 either... There isn't much
> changes, except I followed David's suggestion and changed boolean index
> field into u8 flags field. Still, please glance it over once again and
> shout if you see something you do not like.
> 
> Jiri, how do you want to handle the changes to HID? I could either push
> them through my tree together with the first patch or you can push through
> yours once the first change hits mainline.
> 
> Mauro, the same question goes for media/IR patch.
> 
> David, I suppose you still have the winbond remote so you could test
> changes to winbond-cir driver.

This'll be fun. :) David recently posted a patchset that among other
things, ports winbond-cir over to {ir,rc}-core to the tune of ~700 less
lines in winbond-cir.c. It also touches a fair amount of core bits, as
does a patchset posted by Maxim... I suspect this series should probably
go in first though.

> Ville, do you still have the hardware to try our ati_remote2 changes?

If not, I've got the hardware. (Speaking of which, porting ati_remote*
over to {ir,rc}-core is also on the TODO list, albeit with very very
low priority at the moment).

-- 
Jarod Wilson
jarod@redhat.com


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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 14:24   ` Jarod Wilson
@ 2010-09-08 15:15     ` Mauro Carvalho Chehab
  2010-09-08 15:22       ` Jarod Wilson
  0 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2010-09-08 15:15 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Jiri Kosina, Dmitry Torokhov, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

Em 08-09-2010 11:24, Jarod Wilson escreveu:
> On Wed, Sep 08, 2010 at 11:48:50AM +0200, Jiri Kosina wrote:
>> On Wed, 8 Sep 2010, Dmitry Torokhov wrote:
>>
>>> Hi Mauro,
>>>
>>> I guess I better get off my behind and commit the changes to support large
>>> scancodes, or they will not make to 2.6.37 either... There isn't much
>>> changes, except I followed David's suggestion and changed boolean index
>>> field into u8 flags field. Still, please glance it over once again and
>>> shout if you see something you do not like.
>>>
>>> Jiri, how do you want to handle the changes to HID? I could either push
>>> them through my tree together with the first patch or you can push through
>>> yours once the first change hits mainline.
>>
>> I think that there will unlikely be any conflict in .37 merge window in 
>> this area (and if there were, I'll sort it out).
>>
>> So please add
>>
>> 	Acked-by: Jiri Kosina <jkosina@suse.cz>
>>
>> to the hid-input.c bits and feel free to take it through your tree, if it 
>> is convenient for you.
> 
> It'll conflict a little bith with the tivo slide patch I posted yesterday,
> but mostly just minor context changes. I can redo that patch on top of
> these changes if that's preferred.

I can handle those context changes when merging the patches at linux-next and
when merging upstream. We just need to sync in a way that Dmitry send his patch
series before mine when sending them to Linus, and I'll take care of fixing the
merge conflicts.

Cheers,
mauro.

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 15:15     ` Mauro Carvalho Chehab
@ 2010-09-08 15:22       ` Jarod Wilson
  2010-09-08 15:25         ` Jiri Kosina
  0 siblings, 1 reply; 38+ messages in thread
From: Jarod Wilson @ 2010-09-08 15:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jiri Kosina, Dmitry Torokhov, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 12:15:06PM -0300, Mauro Carvalho Chehab wrote:
> Em 08-09-2010 11:24, Jarod Wilson escreveu:
> > On Wed, Sep 08, 2010 at 11:48:50AM +0200, Jiri Kosina wrote:
> >> On Wed, 8 Sep 2010, Dmitry Torokhov wrote:
> >>
> >>> Hi Mauro,
> >>>
> >>> I guess I better get off my behind and commit the changes to support large
> >>> scancodes, or they will not make to 2.6.37 either... There isn't much
> >>> changes, except I followed David's suggestion and changed boolean index
> >>> field into u8 flags field. Still, please glance it over once again and
> >>> shout if you see something you do not like.
> >>>
> >>> Jiri, how do you want to handle the changes to HID? I could either push
> >>> them through my tree together with the first patch or you can push through
> >>> yours once the first change hits mainline.
> >>
> >> I think that there will unlikely be any conflict in .37 merge window in 
> >> this area (and if there were, I'll sort it out).
> >>
> >> So please add
> >>
> >> 	Acked-by: Jiri Kosina <jkosina@suse.cz>
> >>
> >> to the hid-input.c bits and feel free to take it through your tree, if it 
> >> is convenient for you.
> > 
> > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > but mostly just minor context changes. I can redo that patch on top of
> > these changes if that's preferred.
> 
> I can handle those context changes when merging the patches at linux-next and
> when merging upstream. We just need to sync in a way that Dmitry send his patch
> series before mine when sending them to Linus, and I'll take care of fixing the
> merge conflicts.

Ah, the specific conflicts I was referring here are confined to
drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
the hid tree. It *is* for a remote, but its a pure HID device in this
case.

-- 
Jarod Wilson
jarod@redhat.com


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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
                   ` (7 preceding siblings ...)
  2010-09-08 14:31 ` Jarod Wilson
@ 2010-09-08 15:23 ` Mauro Carvalho Chehab
  8 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2010-09-08 15:23 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linux Input, linux-media, Jarod Wilson, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

Em 08-09-2010 04:41, Dmitry Torokhov escreveu:
> Hi Mauro,
> 
> I guess I better get off my behind and commit the changes to support large
> scancodes, or they will not make to 2.6.37 either... There isn't much
> changes, except I followed David's suggestion and changed boolean index
> field into u8 flags field. Still, please glance it over once again and
> shout if you see something you do not like.
> 
> Jiri, how do you want to handle the changes to HID? I could either push
> them through my tree together with the first patch or you can push through
> yours once the first change hits mainline.
> 
> Mauro, the same question goes for media/IR patch.

It seems easier if you apply them on your tree. I'm sure we won't have any
major conflicts, if we don't apply the big ir->rc renaming patch. I'll postpone
such patch to be applied after the merge upstream.

The patches look sane to me.

Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Cheers,
Mauro

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 15:22       ` Jarod Wilson
@ 2010-09-08 15:25         ` Jiri Kosina
  2010-09-08 15:36           ` Dmitry Torokhov
  2010-09-08 16:09           ` Jarod Wilson
  0 siblings, 2 replies; 38+ messages in thread
From: Jiri Kosina @ 2010-09-08 15:25 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, 8 Sep 2010, Jarod Wilson wrote:

> > > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > > but mostly just minor context changes. I can redo that patch on top of
> > > these changes if that's preferred.
> > 
> > I can handle those context changes when merging the patches at linux-next and
> > when merging upstream. We just need to sync in a way that Dmitry send his patch
> > series before mine when sending them to Linus, and I'll take care of fixing the
> > merge conflicts.
> 
> Ah, the specific conflicts I was referring here are confined to
> drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
> the hid tree. It *is* for a remote, but its a pure HID device in this
> case.

Umm, what patch are you talking about please? I don't seem to have 
anything from you in my queue.

Thanks,

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 14:31 ` Jarod Wilson
@ 2010-09-08 15:34   ` Dmitry Torokhov
  2010-09-13 17:48     ` Jarod Wilson
  0 siblings, 1 reply; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08 15:34 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Maxim Levitsky,
	David Hardeman, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 10:31:21AM -0400, Jarod Wilson wrote:
> On Wed, Sep 08, 2010 at 12:41:38AM -0700, Dmitry Torokhov wrote:
> > Hi Mauro,
> > 
> > I guess I better get off my behind and commit the changes to support large
> > scancodes, or they will not make to 2.6.37 either... There isn't much
> > changes, except I followed David's suggestion and changed boolean index
> > field into u8 flags field. Still, please glance it over once again and
> > shout if you see something you do not like.
> > 
> > Jiri, how do you want to handle the changes to HID? I could either push
> > them through my tree together with the first patch or you can push through
> > yours once the first change hits mainline.
> > 
> > Mauro, the same question goes for media/IR patch.
> > 
> > David, I suppose you still have the winbond remote so you could test
> > changes to winbond-cir driver.
> 
> This'll be fun. :) David recently posted a patchset that among other
> things, ports winbond-cir over to {ir,rc}-core to the tune of ~700 less
> lines in winbond-cir.c. It also touches a fair amount of core bits, as
> does a patchset posted by Maxim... I suspect this series should probably
> go in first though.
> 

Hmm, the only reason for conversion is that I want to do the back
converstion get/setkeycode_new->get/setkeycode sometimes around
2.6.37-rc2. So it should be perfectly fine for David's changes to go in
and I will just drop my patch completely.

> > Ville, do you still have the hardware to try our ati_remote2 changes?
> 
> If not, I've got the hardware. (Speaking of which, porting ati_remote*
> over to {ir,rc}-core is also on the TODO list, albeit with very very
> low priority at the moment).

Ok, then we'' pencil you in for testing if we do not hear from Ville ;)

-- 
Dmitry

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 15:25         ` Jiri Kosina
@ 2010-09-08 15:36           ` Dmitry Torokhov
  2010-09-08 16:09           ` Jarod Wilson
  1 sibling, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08 15:36 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Jarod Wilson, Mauro Carvalho Chehab, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 05:25:13PM +0200, Jiri Kosina wrote:
> On Wed, 8 Sep 2010, Jarod Wilson wrote:
> 
> > > > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > > > but mostly just minor context changes. I can redo that patch on top of
> > > > these changes if that's preferred.
> > > 
> > > I can handle those context changes when merging the patches at linux-next and
> > > when merging upstream. We just need to sync in a way that Dmitry send his patch
> > > series before mine when sending them to Linus, and I'll take care of fixing the
> > > merge conflicts.
> > 
> > Ah, the specific conflicts I was referring here are confined to
> > drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
> > the hid tree. It *is* for a remote, but its a pure HID device in this
> > case.
> 
> Umm, what patch are you talking about please? I don't seem to have 
> anything from you in my queue.
> 

Depending on the extent of the patch in question I could take it through
my tree as well to avoid too much interdependencies between trees at
merge window time...

-- 
Dmitry

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08  9:48 ` [PATCH 0/6] Large scancode handling Jiri Kosina
  2010-09-08 14:24   ` Jarod Wilson
@ 2010-09-08 15:36   ` Dmitry Torokhov
  1 sibling, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08 15:36 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 11:48:50AM +0200, Jiri Kosina wrote:
> On Wed, 8 Sep 2010, Dmitry Torokhov wrote:
> 
> > Hi Mauro,
> > 
> > I guess I better get off my behind and commit the changes to support large
> > scancodes, or they will not make to 2.6.37 either... There isn't much
> > changes, except I followed David's suggestion and changed boolean index
> > field into u8 flags field. Still, please glance it over once again and
> > shout if you see something you do not like.
> > 
> > Jiri, how do you want to handle the changes to HID? I could either push
> > them through my tree together with the first patch or you can push through
> > yours once the first change hits mainline.
> 
> I think that there will unlikely be any conflict in .37 merge window in 
> this area (and if there were, I'll sort it out).
> 
> So please add
> 
> 	Acked-by: Jiri Kosina <jkosina@suse.cz>
> 
> to the hid-input.c bits and feel free to take it through your tree, if it 
> is convenient for you.
> 

Thanks Jiri.

-- 
Dmitry

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 15:25         ` Jiri Kosina
  2010-09-08 15:36           ` Dmitry Torokhov
@ 2010-09-08 16:09           ` Jarod Wilson
  2010-09-08 16:56             ` Dmitry Torokhov
  2010-09-13 15:00             ` Jiri Kosina
  1 sibling, 2 replies; 38+ messages in thread
From: Jarod Wilson @ 2010-09-08 16:09 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 05:25:13PM +0200, Jiri Kosina wrote:
> On Wed, 8 Sep 2010, Jarod Wilson wrote:
> 
> > > > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > > > but mostly just minor context changes. I can redo that patch on top of
> > > > these changes if that's preferred.
> > > 
> > > I can handle those context changes when merging the patches at linux-next and
> > > when merging upstream. We just need to sync in a way that Dmitry send his patch
> > > series before mine when sending them to Linus, and I'll take care of fixing the
> > > merge conflicts.
> > 
> > Ah, the specific conflicts I was referring here are confined to
> > drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
> > the hid tree. It *is* for a remote, but its a pure HID device in this
> > case.
> 
> Umm, what patch are you talking about please? I don't seem to have 
> anything from you in my queue.

Gah. I suck. Forgot to cc you on it.

http://www.spinics.net/lists/linux-input/msg11007.html

Can resend and/or bounce you a copy if need be.

-- 
Jarod Wilson
jarod@redhat.com


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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 16:09           ` Jarod Wilson
@ 2010-09-08 16:56             ` Dmitry Torokhov
  2010-09-08 17:29               ` Jarod Wilson
  2010-09-13 15:00             ` Jiri Kosina
  1 sibling, 1 reply; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08 16:56 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Jiri Kosina, Mauro Carvalho Chehab, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 12:09:08PM -0400, Jarod Wilson wrote:
> On Wed, Sep 08, 2010 at 05:25:13PM +0200, Jiri Kosina wrote:
> > On Wed, 8 Sep 2010, Jarod Wilson wrote:
> > 
> > > > > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > > > > but mostly just minor context changes. I can redo that patch on top of
> > > > > these changes if that's preferred.
> > > > 
> > > > I can handle those context changes when merging the patches at linux-next and
> > > > when merging upstream. We just need to sync in a way that Dmitry send his patch
> > > > series before mine when sending them to Linus, and I'll take care of fixing the
> > > > merge conflicts.
> > > 
> > > Ah, the specific conflicts I was referring here are confined to
> > > drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
> > > the hid tree. It *is* for a remote, but its a pure HID device in this
> > > case.
> > 
> > Umm, what patch are you talking about please? I don't seem to have 
> > anything from you in my queue.
> 
> Gah. I suck. Forgot to cc you on it.
> 
> http://www.spinics.net/lists/linux-input/msg11007.html
> 
> Can resend and/or bounce you a copy if need be.
> 

Hmm, I do not see anything in there that would conflict with my
changes...

-- 
Dmitry

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 16:56             ` Dmitry Torokhov
@ 2010-09-08 17:29               ` Jarod Wilson
  0 siblings, 0 replies; 38+ messages in thread
From: Jarod Wilson @ 2010-09-08 17:29 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jiri Kosina, Mauro Carvalho Chehab, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, Sep 08, 2010 at 09:56:07AM -0700, Dmitry Torokhov wrote:
> On Wed, Sep 08, 2010 at 12:09:08PM -0400, Jarod Wilson wrote:
> > On Wed, Sep 08, 2010 at 05:25:13PM +0200, Jiri Kosina wrote:
> > > On Wed, 8 Sep 2010, Jarod Wilson wrote:
> > > 
> > > > > > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > > > > > but mostly just minor context changes. I can redo that patch on top of
> > > > > > these changes if that's preferred.
> > > > > 
> > > > > I can handle those context changes when merging the patches at linux-next and
> > > > > when merging upstream. We just need to sync in a way that Dmitry send his patch
> > > > > series before mine when sending them to Linus, and I'll take care of fixing the
> > > > > merge conflicts.
> > > > 
> > > > Ah, the specific conflicts I was referring here are confined to
> > > > drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
> > > > the hid tree. It *is* for a remote, but its a pure HID device in this
> > > > case.
> > > 
> > > Umm, what patch are you talking about please? I don't seem to have 
> > > anything from you in my queue.
> > 
> > Gah. I suck. Forgot to cc you on it.
> > 
> > http://www.spinics.net/lists/linux-input/msg11007.html
> > 
> > Can resend and/or bounce you a copy if need be.
> > 
> 
> Hmm, I do not see anything in there that would conflict with my
> changes...

Sorry, yeah, it *should* be solely context conflicts due to line offsets
and other misc drift, no functional conflicts with your changes.


-- 
Jarod Wilson
jarod@redhat.com


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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
  2010-09-08  7:42 ` [PATCH 4/6] Input: winbond-cir " Dmitry Torokhov
@ 2010-09-08 21:16   ` David Härdeman
  2010-09-08 23:00       ` Dmitry Torokhov
  0 siblings, 1 reply; 38+ messages in thread
From: David Härdeman @ 2010-09-08 21:16 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
> Switch the code to use new style of getkeycode and setkeycode
> methods to allow retrieving and setting keycodes not only by
> their scancodes but also by index.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> ---
> 
>  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
>  1 files changed, 163 insertions(+), 85 deletions(-)

Thanks for doing the conversion for me, but I think you can skip this 
patch. The driver will (if I understood your patchset correctly) still 
work with the old get/setkeycode ioctls and I have a patch lined up that 
converts winbond-cir.c to use ir-core which means all of the input 
related code is removed.


-- 
David Härdeman

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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
  2010-09-08 21:16   ` David Härdeman
@ 2010-09-08 23:00       ` Dmitry Torokhov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08 23:00 UTC (permalink / raw)
  To: David Härdeman
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 11:16:17PM +0200, David Härdeman wrote:
> On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
> > Switch the code to use new style of getkeycode and setkeycode
> > methods to allow retrieving and setting keycodes not only by
> > their scancodes but also by index.
> > 
> > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > ---
> > 
> >  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
> >  1 files changed, 163 insertions(+), 85 deletions(-)
> 
> Thanks for doing the conversion for me, but I think you can skip this 
> patch. The driver will (if I understood your patchset correctly) still 
> work with the old get/setkeycode ioctls and I have a patch lined up that 
> converts winbond-cir.c to use ir-core which means all of the input 
> related code is removed.
> 

Yes, it should still work with old get/setkeycode. What are the plans
for your patch? .37 or later?

-- 
Dmitry

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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
@ 2010-09-08 23:00       ` Dmitry Torokhov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-08 23:00 UTC (permalink / raw)
  To: David Härdeman
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 11:16:17PM +0200, David Härdeman wrote:
> On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
> > Switch the code to use new style of getkeycode and setkeycode
> > methods to allow retrieving and setting keycodes not only by
> > their scancodes but also by index.
> > 
> > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > ---
> > 
> >  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
> >  1 files changed, 163 insertions(+), 85 deletions(-)
> 
> Thanks for doing the conversion for me, but I think you can skip this 
> patch. The driver will (if I understood your patchset correctly) still 
> work with the old get/setkeycode ioctls and I have a patch lined up that 
> converts winbond-cir.c to use ir-core which means all of the input 
> related code is removed.
> 

Yes, it should still work with old get/setkeycode. What are the plans
for your patch? .37 or later?

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
  2010-09-08 23:00       ` Dmitry Torokhov
@ 2010-09-08 23:09         ` David Härdeman
  -1 siblings, 0 replies; 38+ messages in thread
From: David Härdeman @ 2010-09-08 23:09 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 04:00:04PM -0700, Dmitry Torokhov wrote:
> On Wed, Sep 08, 2010 at 11:16:17PM +0200, David Härdeman wrote:
> > On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
> > > Switch the code to use new style of getkeycode and setkeycode
> > > methods to allow retrieving and setting keycodes not only by
> > > their scancodes but also by index.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > > ---
> > > 
> > >  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
> > >  1 files changed, 163 insertions(+), 85 deletions(-)
> > 
> > Thanks for doing the conversion for me, but I think you can skip this 
> > patch. The driver will (if I understood your patchset correctly) still 
> > work with the old get/setkeycode ioctls and I have a patch lined up that 
> > converts winbond-cir.c to use ir-core which means all of the input 
> > related code is removed.
> > 
> 
> Yes, it should still work with old get/setkeycode. What are the plans
> for your patch? .37 or later?

Up to Mauro but I believe it's .37 (sometime after your input patches 
land).

-- 
David Härdeman

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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
@ 2010-09-08 23:09         ` David Härdeman
  0 siblings, 0 replies; 38+ messages in thread
From: David Härdeman @ 2010-09-08 23:09 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

On Wed, Sep 08, 2010 at 04:00:04PM -0700, Dmitry Torokhov wrote:
> On Wed, Sep 08, 2010 at 11:16:17PM +0200, David Härdeman wrote:
> > On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
> > > Switch the code to use new style of getkeycode and setkeycode
> > > methods to allow retrieving and setting keycodes not only by
> > > their scancodes but also by index.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > > ---
> > > 
> > >  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
> > >  1 files changed, 163 insertions(+), 85 deletions(-)
> > 
> > Thanks for doing the conversion for me, but I think you can skip this 
> > patch. The driver will (if I understood your patchset correctly) still 
> > work with the old get/setkeycode ioctls and I have a patch lined up that 
> > converts winbond-cir.c to use ir-core which means all of the input 
> > related code is removed.
> > 
> 
> Yes, it should still work with old get/setkeycode. What are the plans
> for your patch? .37 or later?

Up to Mauro but I believe it's .37 (sometime after your input patches 
land).

-- 
David Härdeman
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
  2010-09-08 23:09         ` David Härdeman
@ 2010-09-08 23:14           ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2010-09-08 23:14 UTC (permalink / raw)
  To: David Härdeman
  Cc: Dmitry Torokhov, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

Em 08-09-2010 20:09, David Härdeman escreveu:
> On Wed, Sep 08, 2010 at 04:00:04PM -0700, Dmitry Torokhov wrote:
>> On Wed, Sep 08, 2010 at 11:16:17PM +0200, David Härdeman wrote:
>>> On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
>>>> Switch the code to use new style of getkeycode and setkeycode
>>>> methods to allow retrieving and setting keycodes not only by
>>>> their scancodes but also by index.
>>>>
>>>> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
>>>> ---
>>>>
>>>>  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
>>>>  1 files changed, 163 insertions(+), 85 deletions(-)
>>>
>>> Thanks for doing the conversion for me, but I think you can skip this 
>>> patch. The driver will (if I understood your patchset correctly) still 
>>> work with the old get/setkeycode ioctls and I have a patch lined up that 
>>> converts winbond-cir.c to use ir-core which means all of the input 
>>> related code is removed.
>>>
>>
>> Yes, it should still work with old get/setkeycode. What are the plans
>> for your patch? .37 or later?
> 
> Up to Mauro but I believe it's .37 (sometime after your input patches 
> land).

.37 seems feasible, if you submit your patch in time for review.

Maybe I should create a temporary staging tree for .37 with the input patches
applied there, to allow people to better review and test the rc patches with
everything applied.

Cheers,
Mauro.


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

* Re: [PATCH 4/6] Input: winbond-cir - switch to using new keycode interface
@ 2010-09-08 23:14           ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2010-09-08 23:14 UTC (permalink / raw)
  To: David Härdeman
  Cc: Dmitry Torokhov, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, Jiri Kosina, Ville Syrjala

Em 08-09-2010 20:09, David Härdeman escreveu:
> On Wed, Sep 08, 2010 at 04:00:04PM -0700, Dmitry Torokhov wrote:
>> On Wed, Sep 08, 2010 at 11:16:17PM +0200, David Härdeman wrote:
>>> On Wed, Sep 08, 2010 at 12:42:00AM -0700, Dmitry Torokhov wrote:
>>>> Switch the code to use new style of getkeycode and setkeycode
>>>> methods to allow retrieving and setting keycodes not only by
>>>> their scancodes but also by index.
>>>>
>>>> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
>>>> ---
>>>>
>>>>  drivers/input/misc/winbond-cir.c |  248 +++++++++++++++++++++++++-------------
>>>>  1 files changed, 163 insertions(+), 85 deletions(-)
>>>
>>> Thanks for doing the conversion for me, but I think you can skip this 
>>> patch. The driver will (if I understood your patchset correctly) still 
>>> work with the old get/setkeycode ioctls and I have a patch lined up that 
>>> converts winbond-cir.c to use ir-core which means all of the input 
>>> related code is removed.
>>>
>>
>> Yes, it should still work with old get/setkeycode. What are the plans
>> for your patch? .37 or later?
> 
> Up to Mauro but I believe it's .37 (sometime after your input patches 
> land).

.37 seems feasible, if you submit your patch in time for review.

Maybe I should create a temporary staging tree for .37 with the input patches
applied there, to allow people to better review and test the rc patches with
everything applied.

Cheers,
Mauro.

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
  2010-09-08  7:42 ` [PATCH 5/6] Input: ati-remote2 " Dmitry Torokhov
@ 2010-09-09 12:40   ` Ville Syrjälä
  2010-09-13 16:28       ` Dmitry Torokhov
  0 siblings, 1 reply; 38+ messages in thread
From: Ville Syrjälä @ 2010-09-09 12:40 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina

On Wed, Sep 08, 2010 at 12:42:05AM -0700, Dmitry Torokhov wrote:
> Switch the code to use new style of getkeycode and setkeycode
> methods to allow retrieving and setting keycodes not only by
> their scancodes but also by index.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> ---
> 
>  drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
>  1 files changed, 65 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> index 2325765..b2e0d82 100644
> --- a/drivers/input/misc/ati_remote2.c
> +++ b/drivers/input/misc/ati_remote2.c
> @@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
>  }
>  
>  static int ati_remote2_getkeycode(struct input_dev *idev,
> -				  unsigned int scancode, unsigned int *keycode)
> +				  struct input_keymap_entry *ke)
>  {
>  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
>  	unsigned int mode;
> -	int index;
> +	int offset;
> +	unsigned int index;
> +	unsigned int scancode;
> +
> +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> +		index = ke->index;
> +		if (index >= (ATI_REMOTE2_MODES - 1) *
                                               ^^^^
That -1 looks wrong. Same in setkeycode().

> +				ARRAY_SIZE(ati_remote2_key_table))
> +			return -EINVAL;
> +
> +		mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
> +		offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
> +		scancode = (mode << 8) + ati_remote2_key_table[offset].hw_code;
> +	} else {
> +		if (input_scancode_to_scalar(ke, &scancode))
> +			return -EINVAL;
> +
> +		mode = scancode >> 8;
> +		if (mode > ATI_REMOTE2_PC)
> +			return -EINVAL;
> +
> +		offset = ati_remote2_lookup(scancode & 0xff);
> +		if (offset < 0)
> +			return -EINVAL;
> +
> +		index = mode * ARRAY_SIZE(ati_remote2_key_table) + offset;
> +	}
>  
> -	mode = scancode >> 8;
> -	if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
> -		return -EINVAL;

You're removing the mode_mask check here, but I think that's fine. I
don't see why the keymap shouldn't be allowed to be queried/modified for
the unused modes.

> +	ke->keycode = ar2->keycode[mode][offset];
> +	ke->len = sizeof(scancode);
> +	memcpy(&ke->scancode, &scancode, sizeof(scancode));

The scancodes fit into two bytes each. Does it matter that you're
using 4 bytes here?

> +	ke->index = index;
>  
> -	index = ati_remote2_lookup(scancode & 0xFF);
> -	if (index < 0)
> -		return -EINVAL;
> -
> -	*keycode = ar2->keycode[mode][index];
>  	return 0;
>  }
>  
>  static int ati_remote2_setkeycode(struct input_dev *idev,
> -				  unsigned int scancode, unsigned int keycode)
> +				  const struct input_keymap_entry *ke,
> +				  unsigned int *old_keycode)
>  {
>  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
> -	unsigned int mode, old_keycode;
> -	int index;
> -
> -	mode = scancode >> 8;
> -	if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
> -		return -EINVAL;
> -
> -	index = ati_remote2_lookup(scancode & 0xFF);
> -	if (index < 0)
> -		return -EINVAL;
> +	unsigned int mode;
> +	int offset;
> +	unsigned int index;
> +	unsigned int scancode;
> +
> +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> +		if (ke->index >= (ATI_REMOTE2_MODES - 1) *
> +				ARRAY_SIZE(ati_remote2_key_table))
> +			return -EINVAL;
> +
> +		mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
> +		offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
> +	} else {
> +		if (input_scancode_to_scalar(ke, &scancode))
> +			return -EINVAL;
> +
> +		mode = scancode >> 8;
> +		if (mode > ATI_REMOTE2_PC)
> +			return -EINVAL;
> +
> +		offset = ati_remote2_lookup(scancode & 0xff);
> +		if (offset < 0)
> +			return -EINVAL;
> +	}
>  
> -	old_keycode = ar2->keycode[mode][index];
> -	ar2->keycode[mode][index] = keycode;
> -	__set_bit(keycode, idev->keybit);
> +	*old_keycode = ar2->keycode[mode][offset];
> +	ar2->keycode[mode][offset] = ke->keycode;
> +	__set_bit(ke->keycode, idev->keybit);
>  
>  	for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
>  		for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
> -			if (ar2->keycode[mode][index] == old_keycode)
> +			if (ar2->keycode[mode][index] == *old_keycode)
>  				return 0;
>  		}
>  	}
>  
> -	__clear_bit(old_keycode, idev->keybit);
> +	__clear_bit(*old_keycode, idev->keybit);
>  
>  	return 0;
>  }
> @@ -575,8 +612,8 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
>  	idev->open = ati_remote2_open;
>  	idev->close = ati_remote2_close;
>  
> -	idev->getkeycode = ati_remote2_getkeycode;
> -	idev->setkeycode = ati_remote2_setkeycode;
> +	idev->getkeycode_new = ati_remote2_getkeycode;
> +	idev->setkeycode_new = ati_remote2_setkeycode;
>  
>  	idev->name = ar2->name;
>  	idev->phys = ar2->phys;
> 

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 16:09           ` Jarod Wilson
  2010-09-08 16:56             ` Dmitry Torokhov
@ 2010-09-13 15:00             ` Jiri Kosina
  1 sibling, 0 replies; 38+ messages in thread
From: Jiri Kosina @ 2010-09-13 15:00 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Ville Syrjala

On Wed, 8 Sep 2010, Jarod Wilson wrote:

> > > > > It'll conflict a little bith with the tivo slide patch I posted yesterday,
> > > > > but mostly just minor context changes. I can redo that patch on top of
> > > > > these changes if that's preferred.
> > > > 
> > > > I can handle those context changes when merging the patches at linux-next and
> > > > when merging upstream. We just need to sync in a way that Dmitry send his patch
> > > > series before mine when sending them to Linus, and I'll take care of fixing the
> > > > merge conflicts.
> > > 
> > > Ah, the specific conflicts I was referring here are confined to
> > > drivers/hid/hid-input.c, and I sent the patch thinking it would go in via
> > > the hid tree. It *is* for a remote, but its a pure HID device in this
> > > case.
> > 
> > Umm, what patch are you talking about please? I don't seem to have 
> > anything from you in my queue.
> 
> Gah. I suck. Forgot to cc you on it.
> 
> http://www.spinics.net/lists/linux-input/msg11007.html
> 
> Can resend and/or bounce you a copy if need be.

No need to resend, I'll dig it out from linux-input@ archives where I have 
overlooked it and will start a discussion in that thread if needed, so 
that we don't pollute this one.

Thanks,

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

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

* Re: [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
  2010-09-09 12:40   ` Ville Syrjälä
@ 2010-09-13 16:28       ` Dmitry Torokhov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-13 16:28 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina

On Thu, Sep 09, 2010 at 03:40:04PM +0300, Ville Syrjälä wrote:
> On Wed, Sep 08, 2010 at 12:42:05AM -0700, Dmitry Torokhov wrote:
> > Switch the code to use new style of getkeycode and setkeycode
> > methods to allow retrieving and setting keycodes not only by
> > their scancodes but also by index.
> > 
> > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > ---
> > 
> >  drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
> >  1 files changed, 65 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> > index 2325765..b2e0d82 100644
> > --- a/drivers/input/misc/ati_remote2.c
> > +++ b/drivers/input/misc/ati_remote2.c
> > @@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
> >  }
> >  
> >  static int ati_remote2_getkeycode(struct input_dev *idev,
> > -				  unsigned int scancode, unsigned int *keycode)
> > +				  struct input_keymap_entry *ke)
> >  {
> >  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
> >  	unsigned int mode;
> > -	int index;
> > +	int offset;
> > +	unsigned int index;
> > +	unsigned int scancode;
> > +
> > +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> > +		index = ke->index;
> > +		if (index >= (ATI_REMOTE2_MODES - 1) *
>                                                ^^^^
> That -1 looks wrong. Same in setkeycode().
> 

Yes, indeed. Thanks for noticing.

> > +				ARRAY_SIZE(ati_remote2_key_table))
> > +			return -EINVAL;
> > +
> > +		mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
> > +		offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
> > +		scancode = (mode << 8) + ati_remote2_key_table[offset].hw_code;
> > +	} else {
> > +		if (input_scancode_to_scalar(ke, &scancode))
> > +			return -EINVAL;
> > +
> > +		mode = scancode >> 8;
> > +		if (mode > ATI_REMOTE2_PC)
> > +			return -EINVAL;
> > +
> > +		offset = ati_remote2_lookup(scancode & 0xff);
> > +		if (offset < 0)
> > +			return -EINVAL;
> > +
> > +		index = mode * ARRAY_SIZE(ati_remote2_key_table) + offset;
> > +	}
> >  
> > -	mode = scancode >> 8;
> > -	if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
> > -		return -EINVAL;
> 
> You're removing the mode_mask check here, but I think that's fine. I
> don't see why the keymap shouldn't be allowed to be queried/modified for
> the unused modes.

Rigth, that was my justification for removal of the check.

> 
> > +	ke->keycode = ar2->keycode[mode][offset];
> > +	ke->len = sizeof(scancode);
> > +	memcpy(&ke->scancode, &scancode, sizeof(scancode));
> 
> The scancodes fit into two bytes each. Does it matter that you're
> using 4 bytes here?

The old interface used 4 bytes and I think it just easier this way. I
think userspace will default to 4-byte scancodes unless they know they
need to handle bigger ones.

-- 
Dmitry

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

* Re: [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
@ 2010-09-13 16:28       ` Dmitry Torokhov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-13 16:28 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina

On Thu, Sep 09, 2010 at 03:40:04PM +0300, Ville Syrjälä wrote:
> On Wed, Sep 08, 2010 at 12:42:05AM -0700, Dmitry Torokhov wrote:
> > Switch the code to use new style of getkeycode and setkeycode
> > methods to allow retrieving and setting keycodes not only by
> > their scancodes but also by index.
> > 
> > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > ---
> > 
> >  drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
> >  1 files changed, 65 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> > index 2325765..b2e0d82 100644
> > --- a/drivers/input/misc/ati_remote2.c
> > +++ b/drivers/input/misc/ati_remote2.c
> > @@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
> >  }
> >  
> >  static int ati_remote2_getkeycode(struct input_dev *idev,
> > -				  unsigned int scancode, unsigned int *keycode)
> > +				  struct input_keymap_entry *ke)
> >  {
> >  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
> >  	unsigned int mode;
> > -	int index;
> > +	int offset;
> > +	unsigned int index;
> > +	unsigned int scancode;
> > +
> > +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> > +		index = ke->index;
> > +		if (index >= (ATI_REMOTE2_MODES - 1) *
>                                                ^^^^
> That -1 looks wrong. Same in setkeycode().
> 

Yes, indeed. Thanks for noticing.

> > +				ARRAY_SIZE(ati_remote2_key_table))
> > +			return -EINVAL;
> > +
> > +		mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
> > +		offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
> > +		scancode = (mode << 8) + ati_remote2_key_table[offset].hw_code;
> > +	} else {
> > +		if (input_scancode_to_scalar(ke, &scancode))
> > +			return -EINVAL;
> > +
> > +		mode = scancode >> 8;
> > +		if (mode > ATI_REMOTE2_PC)
> > +			return -EINVAL;
> > +
> > +		offset = ati_remote2_lookup(scancode & 0xff);
> > +		if (offset < 0)
> > +			return -EINVAL;
> > +
> > +		index = mode * ARRAY_SIZE(ati_remote2_key_table) + offset;
> > +	}
> >  
> > -	mode = scancode >> 8;
> > -	if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
> > -		return -EINVAL;
> 
> You're removing the mode_mask check here, but I think that's fine. I
> don't see why the keymap shouldn't be allowed to be queried/modified for
> the unused modes.

Rigth, that was my justification for removal of the check.

> 
> > +	ke->keycode = ar2->keycode[mode][offset];
> > +	ke->len = sizeof(scancode);
> > +	memcpy(&ke->scancode, &scancode, sizeof(scancode));
> 
> The scancodes fit into two bytes each. Does it matter that you're
> using 4 bytes here?

The old interface used 4 bytes and I think it just easier this way. I
think userspace will default to 4-byte scancodes unless they know they
need to handle bigger ones.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-08 15:34   ` Dmitry Torokhov
@ 2010-09-13 17:48     ` Jarod Wilson
  2010-09-14  1:26       ` Dmitry Torokhov
  0 siblings, 1 reply; 38+ messages in thread
From: Jarod Wilson @ 2010-09-13 17:48 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jarod Wilson, Mauro Carvalho Chehab, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Jiri Kosina, Ville Syrjala

On Wed, Sep 8, 2010 at 11:34 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Wed, Sep 08, 2010 at 10:31:21AM -0400, Jarod Wilson wrote:
>> On Wed, Sep 08, 2010 at 12:41:38AM -0700, Dmitry Torokhov wrote:
...
>> > Ville, do you still have the hardware to try our ati_remote2 changes?
>>
>> If not, I've got the hardware. (Speaking of which, porting ati_remote*
>> over to {ir,rc}-core is also on the TODO list, albeit with very very
>> low priority at the moment).
>
> Ok, then we'' pencil you in for testing if we do not hear from Ville ;)

We've heard from Ville, but I went ahead and did some testing anyway.
My RWII with the default mode (didn't try any of the others) works
just fine after applying this patch atop 2.6.36-rc3-git1, as do my
imon and mceusb receivers. Ran into some problems with streamzap, but
I'm fairly sure they're not the fault of this patchset.

-- 
Jarod Wilson
jarod@wilsonet.com

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

* Re: [PATCH 0/6] Large scancode handling
  2010-09-13 17:48     ` Jarod Wilson
@ 2010-09-14  1:26       ` Dmitry Torokhov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-14  1:26 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Jarod Wilson, Mauro Carvalho Chehab, Linux Input, linux-media,
	Maxim Levitsky, David Hardeman, Jiri Kosina, Ville Syrjala

On Mon, Sep 13, 2010 at 01:48:14PM -0400, Jarod Wilson wrote:
> On Wed, Sep 8, 2010 at 11:34 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > On Wed, Sep 08, 2010 at 10:31:21AM -0400, Jarod Wilson wrote:
> >> On Wed, Sep 08, 2010 at 12:41:38AM -0700, Dmitry Torokhov wrote:
> ...
> >> > Ville, do you still have the hardware to try our ati_remote2 changes?
> >>
> >> If not, I've got the hardware. (Speaking of which, porting ati_remote*
> >> over to {ir,rc}-core is also on the TODO list, albeit with very very
> >> low priority at the moment).
> >
> > Ok, then we'' pencil you in for testing if we do not hear from Ville ;)
> 
> We've heard from Ville, but I went ahead and did some testing anyway.
> My RWII with the default mode (didn't try any of the others) works
> just fine after applying this patch atop 2.6.36-rc3-git1, as do my
> imon and mceusb receivers. Ran into some problems with streamzap, but
> I'm fairly sure they're not the fault of this patchset.
> 

Thank you Jarod, I'll add Tested-by: you then.

-- 
Dmitry

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

* Re: [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
  2010-09-13 16:28       ` Dmitry Torokhov
@ 2010-09-15 21:04         ` Ville Syrjälä
  -1 siblings, 0 replies; 38+ messages in thread
From: Ville Syrjälä @ 2010-09-15 21:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina

On Mon, Sep 13, 2010 at 09:28:07AM -0700, Dmitry Torokhov wrote:
> On Thu, Sep 09, 2010 at 03:40:04PM +0300, Ville Syrjälä wrote:
> > On Wed, Sep 08, 2010 at 12:42:05AM -0700, Dmitry Torokhov wrote:
> > > Switch the code to use new style of getkeycode and setkeycode
> > > methods to allow retrieving and setting keycodes not only by
> > > their scancodes but also by index.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > > ---
> > > 
> > >  drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
> > >  1 files changed, 65 insertions(+), 28 deletions(-)
> > > 
> > > diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> > > index 2325765..b2e0d82 100644
> > > --- a/drivers/input/misc/ati_remote2.c
> > > +++ b/drivers/input/misc/ati_remote2.c
> > > @@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
> > >  }
> > >  
> > >  static int ati_remote2_getkeycode(struct input_dev *idev,
> > > -				  unsigned int scancode, unsigned int *keycode)
> > > +				  struct input_keymap_entry *ke)
> > >  {
> > >  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
> > >  	unsigned int mode;
> > > -	int index;
> > > +	int offset;
> > > +	unsigned int index;
> > > +	unsigned int scancode;
> > > +
> > > +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> > > +		index = ke->index;
> > > +		if (index >= (ATI_REMOTE2_MODES - 1) *
> >                                                ^^^^
> > That -1 looks wrong. Same in setkeycode().
> > 
> 
> Yes, indeed. Thanks for noticing.

I fixed this bug locally and gave this a short whirl with my RWII.
I tried both the old and new style keycode ioctls. Everything
worked as expected.

So if you want more tags feel free to add my Acked-by and Tested-by
for this (assuming the off-by-one fix is included) and you can add my
Tested-by for patch 1/6 as well.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

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

* Re: [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
@ 2010-09-15 21:04         ` Ville Syrjälä
  0 siblings, 0 replies; 38+ messages in thread
From: Ville Syrjälä @ 2010-09-15 21:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina

On Mon, Sep 13, 2010 at 09:28:07AM -0700, Dmitry Torokhov wrote:
> On Thu, Sep 09, 2010 at 03:40:04PM +0300, Ville Syrjälä wrote:
> > On Wed, Sep 08, 2010 at 12:42:05AM -0700, Dmitry Torokhov wrote:
> > > Switch the code to use new style of getkeycode and setkeycode
> > > methods to allow retrieving and setting keycodes not only by
> > > their scancodes but also by index.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > > ---
> > > 
> > >  drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
> > >  1 files changed, 65 insertions(+), 28 deletions(-)
> > > 
> > > diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> > > index 2325765..b2e0d82 100644
> > > --- a/drivers/input/misc/ati_remote2.c
> > > +++ b/drivers/input/misc/ati_remote2.c
> > > @@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
> > >  }
> > >  
> > >  static int ati_remote2_getkeycode(struct input_dev *idev,
> > > -				  unsigned int scancode, unsigned int *keycode)
> > > +				  struct input_keymap_entry *ke)
> > >  {
> > >  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
> > >  	unsigned int mode;
> > > -	int index;
> > > +	int offset;
> > > +	unsigned int index;
> > > +	unsigned int scancode;
> > > +
> > > +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> > > +		index = ke->index;
> > > +		if (index >= (ATI_REMOTE2_MODES - 1) *
> >                                                ^^^^
> > That -1 looks wrong. Same in setkeycode().
> > 
> 
> Yes, indeed. Thanks for noticing.

I fixed this bug locally and gave this a short whirl with my RWII.
I tried both the old and new style keycode ioctls. Everything
worked as expected.

So if you want more tags feel free to add my Acked-by and Tested-by
for this (assuming the off-by-one fix is included) and you can add my
Tested-by for patch 1/6 as well.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 5/6] Input: ati-remote2 - switch to using new keycode interface
  2010-09-15 21:04         ` Ville Syrjälä
  (?)
@ 2010-09-15 21:13         ` Dmitry Torokhov
  -1 siblings, 0 replies; 38+ messages in thread
From: Dmitry Torokhov @ 2010-09-15 21:13 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina

On Thu, Sep 16, 2010 at 12:04:19AM +0300, Ville Syrjälä wrote:
> On Mon, Sep 13, 2010 at 09:28:07AM -0700, Dmitry Torokhov wrote:
> > On Thu, Sep 09, 2010 at 03:40:04PM +0300, Ville Syrjälä wrote:
> > > On Wed, Sep 08, 2010 at 12:42:05AM -0700, Dmitry Torokhov wrote:
> > > > Switch the code to use new style of getkeycode and setkeycode
> > > > methods to allow retrieving and setting keycodes not only by
> > > > their scancodes but also by index.
> > > > 
> > > > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > > > ---
> > > > 
> > > >  drivers/input/misc/ati_remote2.c |   93 +++++++++++++++++++++++++++-----------
> > > >  1 files changed, 65 insertions(+), 28 deletions(-)
> > > > 
> > > > diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> > > > index 2325765..b2e0d82 100644
> > > > --- a/drivers/input/misc/ati_remote2.c
> > > > +++ b/drivers/input/misc/ati_remote2.c
> > > > @@ -483,51 +483,88 @@ static void ati_remote2_complete_key(struct urb *urb)
> > > >  }
> > > >  
> > > >  static int ati_remote2_getkeycode(struct input_dev *idev,
> > > > -				  unsigned int scancode, unsigned int *keycode)
> > > > +				  struct input_keymap_entry *ke)
> > > >  {
> > > >  	struct ati_remote2 *ar2 = input_get_drvdata(idev);
> > > >  	unsigned int mode;
> > > > -	int index;
> > > > +	int offset;
> > > > +	unsigned int index;
> > > > +	unsigned int scancode;
> > > > +
> > > > +	if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
> > > > +		index = ke->index;
> > > > +		if (index >= (ATI_REMOTE2_MODES - 1) *
> > >                                                ^^^^
> > > That -1 looks wrong. Same in setkeycode().
> > > 
> > 
> > Yes, indeed. Thanks for noticing.
> 
> I fixed this bug locally and gave this a short whirl with my RWII.
> I tried both the old and new style keycode ioctls. Everything
> worked as expected.
> 
> So if you want more tags feel free to add my Acked-by and Tested-by
> for this (assuming the off-by-one fix is included)

Thank you very much for reviewing and testing it Ville, I will surely
add the tags.

 and you can add my
> Tested-by for patch 1/6 as well.
> 

This one is already in public branch; I prefer not to rewind unless
there are compile or other major issues....

-- 
Dmitry

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

* Re: [PATCH 1/6] Input: add support for large scancodes
  2010-09-08  7:41 ` [PATCH 1/6] Input: add support for large scancodes Dmitry Torokhov
@ 2010-10-29 21:36   ` James Hogan
  2010-10-29 22:34     ` James Hogan
  0 siblings, 1 reply; 38+ messages in thread
From: James Hogan @ 2010-10-29 21:36 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina, Ville Syrjala,
	linux-doc, Randy Dunlap

> diff --git a/include/linux/input.h b/include/linux/input.h
> index 7892651..0057698 100644
> --- a/include/linux/input.h
> +++ b/include/linux/input.h
<snip>
> +/**
> + * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
> + * @scancode: scancode represented in machine-endian form.
> + * @len: length of the scancode that resides in @scancode buffer.
> + * @index: index in the keymap, may be used instead of scancode
> + * @flags: allows to specify how kernel should handle the request. For
> + *	example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
> + *	should perform lookup in keymap by @index instead of @scancode
> + * @keycode: key code assigned to this scancode
> + *
> + * The structure is used to retrieve and modify keymap data. Users have
> + * option of performing lookup either by @scancode itself or by @index
> + * in keymap entry. EVIOCGKEYCODE will also return scancode or index
> + * (depending on which element was used to perform lookup).
> + */
> +struct input_keymap_entry {
> +#define INPUT_KEYMAP_BY_INDEX	(1 << 0)
> +	__u8  flags;
> +	__u8  len;
> +	__u16 index;
> +	__u32 keycode;
> +	__u8  scancode[32];
> +};

I thought I better point out that this breaks make htmldocs (see below) 
because of the '<' characters "in" a kernel doc'd struct. This is with 
12ba8d1e9262ce81a695795410bd9ee5c9407ba1 from Linus' tree (>2.6.36). Moving 
the #define below the struct works around the problem, but I guess the real 
issue is in the kerneldoc code.

Cheers
James

$ make htmldocs
  DOCPROC Documentation/DocBook/device-drivers.xml
  HTML    Documentation/DocBook/device-drivers.html
/home/james/src/kernel/linux-2.6/Documentation/DocBook/device-
drivers.xml:41883: parser error : StartTag: invalid element name
#define INPUT_KEYMAP_BY_INDEX   (1 << 0)
                                    ^
/home/james/src/kernel/linux-2.6/Documentation/DocBook/device-
drivers.xml:41883: parser error : StartTag: invalid element name
#define INPUT_KEYMAP_BY_INDEX   (1 << 0)
                                     ^
unable to parse /home/james/src/kernel/linux-2.6/Documentation/DocBook/device-
drivers.xml
/bin/cp: cannot stat `*.*htm*': No such file or directory
make[1]: *** [Documentation/DocBook/device-drivers.html] Error 1
make: *** [htmldocs] Error 2

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

* Re: [PATCH 1/6] Input: add support for large scancodes
  2010-10-29 21:36   ` James Hogan
@ 2010-10-29 22:34     ` James Hogan
  0 siblings, 0 replies; 38+ messages in thread
From: James Hogan @ 2010-10-29 22:34 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, Linux Input, linux-media, Jarod Wilson,
	Maxim Levitsky, David Hardeman, Jiri Kosina, Ville Syrjala,
	linux-doc, Randy Dunlap

On Friday 29 October 2010 22:36:06 James Hogan wrote:
> I thought I better point out that this breaks make htmldocs (see below)
> because of the '<' characters "in" a kernel doc'd struct. This is with
> 12ba8d1e9262ce81a695795410bd9ee5c9407ba1 from Linus' tree (>2.6.36). Moving
> the #define below the struct works around the problem, but I guess the real
> issue is in the kerneldoc code.

appologies for the noise.
I see Randy had already beaten me to a fix.

Cheers
James

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

end of thread, other threads:[~2010-10-29 22:34 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-08  7:41 [PATCH 0/6] Large scancode handling Dmitry Torokhov
2010-09-08  7:41 ` [PATCH 1/6] Input: add support for large scancodes Dmitry Torokhov
2010-10-29 21:36   ` James Hogan
2010-10-29 22:34     ` James Hogan
2010-09-08  7:41 ` [PATCH 2/6] Input: sparse-keymap - switch to using new keycode interface Dmitry Torokhov
2010-09-08  7:41 ` [PATCH 3/6] Input: hid-input " Dmitry Torokhov
2010-09-08  7:42 ` [PATCH 4/6] Input: winbond-cir " Dmitry Torokhov
2010-09-08 21:16   ` David Härdeman
2010-09-08 23:00     ` Dmitry Torokhov
2010-09-08 23:00       ` Dmitry Torokhov
2010-09-08 23:09       ` David Härdeman
2010-09-08 23:09         ` David Härdeman
2010-09-08 23:14         ` Mauro Carvalho Chehab
2010-09-08 23:14           ` Mauro Carvalho Chehab
2010-09-08  7:42 ` [PATCH 5/6] Input: ati-remote2 " Dmitry Torokhov
2010-09-09 12:40   ` Ville Syrjälä
2010-09-13 16:28     ` Dmitry Torokhov
2010-09-13 16:28       ` Dmitry Torokhov
2010-09-15 21:04       ` Ville Syrjälä
2010-09-15 21:04         ` Ville Syrjälä
2010-09-15 21:13         ` Dmitry Torokhov
2010-09-08  7:42 ` [PATCH 6/6] Input: media/IR " Dmitry Torokhov
2010-09-08  9:48 ` [PATCH 0/6] Large scancode handling Jiri Kosina
2010-09-08 14:24   ` Jarod Wilson
2010-09-08 15:15     ` Mauro Carvalho Chehab
2010-09-08 15:22       ` Jarod Wilson
2010-09-08 15:25         ` Jiri Kosina
2010-09-08 15:36           ` Dmitry Torokhov
2010-09-08 16:09           ` Jarod Wilson
2010-09-08 16:56             ` Dmitry Torokhov
2010-09-08 17:29               ` Jarod Wilson
2010-09-13 15:00             ` Jiri Kosina
2010-09-08 15:36   ` Dmitry Torokhov
2010-09-08 14:31 ` Jarod Wilson
2010-09-08 15:34   ` Dmitry Torokhov
2010-09-13 17:48     ` Jarod Wilson
2010-09-14  1:26       ` Dmitry Torokhov
2010-09-08 15:23 ` Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.