linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] USB: input: yealink.c: update key mappings
@ 2014-12-22 14:41 Daniele Forsi
  2014-12-22 14:41 ` [RFC PATCH 1/2] USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and pound Daniele Forsi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daniele Forsi @ 2014-12-22 14:41 UTC (permalink / raw)
  To: Henk Vergonet, Dmitry Torokhov; +Cc: usbb2k-api-dev, linux-input, linux-kernel

Hello,

I have an Yealink USB phone which is handled by the yealink.c driver but the
'#' key returns an unexpected value and keys labeled "RING" and "MUTE" do not
return any value to userspace.

In the first patch of this series I replace the combination KEY_LEFTSHIFT and
KEY_3 with KEY_NUMERIC_POUND and I also replace other keys for internal consistency
and with the cm109.c driver, which according to the comment in the code is derived
from this one, is this the right approach?

In the second patch I add two additional keys which could be handled by userspace:
 "RING" whose purpose according to the user manual is to cycle all available ringtones
 "MUTE" whose purpose is to mute the USB microphone
which KEY_* values should be used for them?

I have two more questions:
DRIVER_VERSION should be updated?
are both patches suitable for stable?

Daniele Forsi (2):
  USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and
    pound
  USB: input: yealink.c: add mapping for "RING" and "MUTE" keys

 drivers/input/misc/yealink.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

-- 
2.1.3

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

* [RFC PATCH 1/2] USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and pound
  2014-12-22 14:41 [RFC PATCH 0/2] USB: input: yealink.c: update key mappings Daniele Forsi
@ 2014-12-22 14:41 ` Daniele Forsi
       [not found]   ` <CAMFK4TMJTb5dJ1kXLBgsu8WE8Ygyh+jW_d_TqmDO5OqB5yr3nw@mail.gmail.com>
  2014-12-22 14:41 ` [RFC PATCH 2/2] USB: input: yealink.c: add mapping for "RING" and "MUTE" keys Daniele Forsi
       [not found] ` <CAMFK4TMNuQEao5n3XPjn4ZSkX0eTtfkWO+h=bPbyHthyJYebPw@mail.gmail.com>
  2 siblings, 1 reply; 6+ messages in thread
From: Daniele Forsi @ 2014-12-22 14:41 UTC (permalink / raw)
  To: Henk Vergonet, Dmitry Torokhov
  Cc: usbb2k-api-dev, linux-input, linux-kernel, Daniele Forsi

Fix the "pound" key that being mapped to Shift+3 was returning '£' instead
of '#' when using an Italian keyboard mapping and use the same values as
the cm109.c driver (which was based on this yealink.c driver) also for '0'
to '9' and for '*'.

Signed-off-by: Daniele Forsi <dforsi@gmail.com>
---
 drivers/input/misc/yealink.c | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
index 79c964c..e9403da 100644
--- a/drivers/input/misc/yealink.c
+++ b/drivers/input/misc/yealink.c
@@ -212,27 +212,24 @@ static int map_p1k_to_key(int scancode)
 	case 0x03: return KEY_ENTER;	/*   pickup	*/
 	case 0x14: return KEY_BACKSPACE; /*  C		*/
 	case 0x13: return KEY_ESC;	/*   hangup	*/
-	case 0x00: return KEY_1;	/*   1		*/
-	case 0x01: return KEY_2;	/*   2 		*/
-	case 0x02: return KEY_3;	/*   3		*/
-	case 0x10: return KEY_4;	/*   4		*/
-	case 0x11: return KEY_5;	/*   5		*/
-	case 0x12: return KEY_6;	/*   6		*/
-	case 0x20: return KEY_7;	/*   7		*/
-	case 0x21: return KEY_8;	/*   8		*/
-	case 0x22: return KEY_9;	/*   9		*/
-	case 0x30: return KEY_KPASTERISK; /* *		*/
-	case 0x31: return KEY_0;	/*   0		*/
-	case 0x32: return KEY_LEFTSHIFT |
-			  KEY_3 << 8;	/*   #		*/
+	case 0x00: return KEY_NUMERIC_1;	/*   1		*/
+	case 0x01: return KEY_NUMERIC_2;	/*   2		*/
+	case 0x02: return KEY_NUMERIC_3;	/*   3		*/
+	case 0x10: return KEY_NUMERIC_4;	/*   4		*/
+	case 0x11: return KEY_NUMERIC_5;	/*   5		*/
+	case 0x12: return KEY_NUMERIC_6;	/*   6		*/
+	case 0x20: return KEY_NUMERIC_7;	/*   7		*/
+	case 0x21: return KEY_NUMERIC_8;	/*   8		*/
+	case 0x22: return KEY_NUMERIC_9;	/*   9		*/
+	case 0x30: return KEY_NUMERIC_STAR;	/*   *		*/
+	case 0x31: return KEY_NUMERIC_0;	/*   0		*/
+	case 0x32: return KEY_NUMERIC_POUND;	/*   #		*/
 	}
 	return -EINVAL;
 }
 
 /* Completes a request by converting the data into events for the
  * input subsystem.
- *
- * The key parameter can be cascaded: key2 << 8 | key1
  */
 static void report_key(struct yealink_dev *yld, int key)
 {
@@ -240,17 +237,13 @@ static void report_key(struct yealink_dev *yld, int key)
 
 	if (yld->key_code >= 0) {
 		/* old key up */
-		input_report_key(idev, yld->key_code & 0xff, 0);
-		if (yld->key_code >> 8)
-			input_report_key(idev, yld->key_code >> 8, 0);
+		input_report_key(idev, yld->key_code, 0);
 	}
 
 	yld->key_code = key;
 	if (key >= 0) {
 		/* new valid key */
-		input_report_key(idev, key & 0xff, 1);
-		if (key >> 8)
-			input_report_key(idev, key >> 8, 1);
+		input_report_key(idev, key, 1);
 	}
 	input_sync(idev);
 }
@@ -966,9 +959,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	for (i = 0; i < 256; i++) {
 		int k = map_p1k_to_key(i);
 		if (k >= 0) {
-			set_bit(k & 0xff, input_dev->keybit);
-			if (k >> 8)
-				set_bit(k >> 8, input_dev->keybit);
+			set_bit(k, input_dev->keybit);
 		}
 	}
 
-- 
2.1.3

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

* [RFC PATCH 2/2] USB: input: yealink.c: add mapping for "RING" and "MUTE" keys
  2014-12-22 14:41 [RFC PATCH 0/2] USB: input: yealink.c: update key mappings Daniele Forsi
  2014-12-22 14:41 ` [RFC PATCH 1/2] USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and pound Daniele Forsi
@ 2014-12-22 14:41 ` Daniele Forsi
       [not found]   ` <CAMFK4TM4zVNWBt14vS3T=eQMtwM2OMLW4Wf5dfHS1vKVoPrQiw@mail.gmail.com>
       [not found] ` <CAMFK4TMNuQEao5n3XPjn4ZSkX0eTtfkWO+h=bPbyHthyJYebPw@mail.gmail.com>
  2 siblings, 1 reply; 6+ messages in thread
From: Daniele Forsi @ 2014-12-22 14:41 UTC (permalink / raw)
  To: Henk Vergonet, Dmitry Torokhov
  Cc: usbb2k-api-dev, linux-input, linux-kernel, Daniele Forsi

According to the user manual of the "VOIP-3 SKY" USB phone, the RING
key is used to select different ring tones and the MUTE key is used
to mute the microphone.

Signed-off-by: Daniele Forsi <dforsi@gmail.com>
---
 drivers/input/misc/yealink.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
index e9403da..0b86c49 100644
--- a/drivers/input/misc/yealink.c
+++ b/drivers/input/misc/yealink.c
@@ -189,7 +189,9 @@ static int setChar(struct yealink_dev *yld, int el, int chr)
  * USB-P1K button layout:
  *
  *             up
+ *            ring
  *       IN           OUT
+ *            mute
  *            down
  *
  *     pickup   C    hangup
@@ -207,7 +209,9 @@ static int map_p1k_to_key(int scancode)
 	switch(scancode) {		/* phone key:	*/
 	case 0x23: return KEY_LEFT;	/*   IN		*/
 	case 0x33: return KEY_UP;	/*   up		*/
+	case 0x44: return KEY_SOUND;	/*   ring	*/
 	case 0x04: return KEY_RIGHT;	/*   OUT	*/
+	case 0x41: return KEY_MICMUTE;	/*   mute	*/
 	case 0x24: return KEY_DOWN;	/*   down	*/
 	case 0x03: return KEY_ENTER;	/*   pickup	*/
 	case 0x14: return KEY_BACKSPACE; /*  C		*/
-- 
2.1.3

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

* Fwd: [RFC PATCH 0/2] USB: input: yealink.c: update key mappings
       [not found] ` <CAMFK4TMNuQEao5n3XPjn4ZSkX0eTtfkWO+h=bPbyHthyJYebPw@mail.gmail.com>
@ 2015-01-09 12:40   ` Henk
  0 siblings, 0 replies; 6+ messages in thread
From: Henk @ 2015-01-09 12:40 UTC (permalink / raw)
  To: linux-input, linux-kernel

Hi Danielle,

Thanks for the '#' fix!

> DRIVER_VERSION should be updated?
Yes seems logical, considering that the API has changed slightly by
using NUMERIC scan commands. I would suggest:

#define DRIVER_VERSION "yld-20141222"

So users something is new and can track changes to your patches more easily.

> are both patches suitable for stable?

I would have no objection to that :)

Regards,
Henk Vergonet

On Mon, Dec 22, 2014 at 3:41 PM, Daniele Forsi <dforsi@gmail.com> wrote:
>
> Hello,
>
> I have an Yealink USB phone which is handled by the yealink.c driver but the
> '#' key returns an unexpected value and keys labeled "RING" and "MUTE" do not
> return any value to userspace.
>
> In the first patch of this series I replace the combination KEY_LEFTSHIFT and
> KEY_3 with KEY_NUMERIC_POUND and I also replace other keys for internal consistency
> and with the cm109.c driver, which according to the comment in the code is derived
> from this one, is this the right approach?
>
> In the second patch I add two additional keys which could be handled by userspace:
>  "RING" whose purpose according to the user manual is to cycle all available ringtones
>  "MUTE" whose purpose is to mute the USB microphone
> which KEY_* values should be used for them?
>
> I have two more questions:
> DRIVER_VERSION should be updated?
> are both patches suitable for stable?
>
> Daniele Forsi (2):
>   USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and
>     pound
>   USB: input: yealink.c: add mapping for "RING" and "MUTE" keys
>
>  drivers/input/misc/yealink.c | 43 +++++++++++++++++++------------------------
>  1 file changed, 19 insertions(+), 24 deletions(-)
>
> --
> 2.1.3
>

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

* Fwd: [RFC PATCH 1/2] USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and pound
       [not found]   ` <CAMFK4TMJTb5dJ1kXLBgsu8WE8Ygyh+jW_d_TqmDO5OqB5yr3nw@mail.gmail.com>
@ 2015-01-09 12:41     ` Henk
  0 siblings, 0 replies; 6+ messages in thread
From: Henk @ 2015-01-09 12:41 UTC (permalink / raw)
  To: linux-input, linux-kernel

Signed-off-by: Henk Vergonet <henk.vergonet@gmail.com>

Thanks!

On Mon, Dec 22, 2014 at 3:41 PM, Daniele Forsi <dforsi@gmail.com> wrote:
>
> Fix the "pound" key that being mapped to Shift+3 was returning '£' instead
> of '#' when using an Italian keyboard mapping and use the same values as
> the cm109.c driver (which was based on this yealink.c driver) also for '0'
> to '9' and for '*'.
>
> Signed-off-by: Daniele Forsi <dforsi@gmail.com>
> ---
>  drivers/input/misc/yealink.c | 39 +++++++++++++++------------------------
>  1 file changed, 15 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
> index 79c964c..e9403da 100644
> --- a/drivers/input/misc/yealink.c
> +++ b/drivers/input/misc/yealink.c
> @@ -212,27 +212,24 @@ static int map_p1k_to_key(int scancode)
>         case 0x03: return KEY_ENTER;    /*   pickup     */
>         case 0x14: return KEY_BACKSPACE; /*  C          */
>         case 0x13: return KEY_ESC;      /*   hangup     */
> -       case 0x00: return KEY_1;        /*   1          */
> -       case 0x01: return KEY_2;        /*   2          */
> -       case 0x02: return KEY_3;        /*   3          */
> -       case 0x10: return KEY_4;        /*   4          */
> -       case 0x11: return KEY_5;        /*   5          */
> -       case 0x12: return KEY_6;        /*   6          */
> -       case 0x20: return KEY_7;        /*   7          */
> -       case 0x21: return KEY_8;        /*   8          */
> -       case 0x22: return KEY_9;        /*   9          */
> -       case 0x30: return KEY_KPASTERISK; /* *          */
> -       case 0x31: return KEY_0;        /*   0          */
> -       case 0x32: return KEY_LEFTSHIFT |
> -                         KEY_3 << 8;   /*   #          */
> +       case 0x00: return KEY_NUMERIC_1;        /*   1          */
> +       case 0x01: return KEY_NUMERIC_2;        /*   2          */
> +       case 0x02: return KEY_NUMERIC_3;        /*   3          */
> +       case 0x10: return KEY_NUMERIC_4;        /*   4          */
> +       case 0x11: return KEY_NUMERIC_5;        /*   5          */
> +       case 0x12: return KEY_NUMERIC_6;        /*   6          */
> +       case 0x20: return KEY_NUMERIC_7;        /*   7          */
> +       case 0x21: return KEY_NUMERIC_8;        /*   8          */
> +       case 0x22: return KEY_NUMERIC_9;        /*   9          */
> +       case 0x30: return KEY_NUMERIC_STAR;     /*   *          */
> +       case 0x31: return KEY_NUMERIC_0;        /*   0          */
> +       case 0x32: return KEY_NUMERIC_POUND;    /*   #          */
>         }
>         return -EINVAL;
>  }
>
>  /* Completes a request by converting the data into events for the
>   * input subsystem.
> - *
> - * The key parameter can be cascaded: key2 << 8 | key1
>   */
>  static void report_key(struct yealink_dev *yld, int key)
>  {
> @@ -240,17 +237,13 @@ static void report_key(struct yealink_dev *yld, int key)
>
>         if (yld->key_code >= 0) {
>                 /* old key up */
> -               input_report_key(idev, yld->key_code & 0xff, 0);
> -               if (yld->key_code >> 8)
> -                       input_report_key(idev, yld->key_code >> 8, 0);
> +               input_report_key(idev, yld->key_code, 0);
>         }
>
>         yld->key_code = key;
>         if (key >= 0) {
>                 /* new valid key */
> -               input_report_key(idev, key & 0xff, 1);
> -               if (key >> 8)
> -                       input_report_key(idev, key >> 8, 1);
> +               input_report_key(idev, key, 1);
>         }
>         input_sync(idev);
>  }
> @@ -966,9 +959,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
>         for (i = 0; i < 256; i++) {
>                 int k = map_p1k_to_key(i);
>                 if (k >= 0) {
> -                       set_bit(k & 0xff, input_dev->keybit);
> -                       if (k >> 8)
> -                               set_bit(k >> 8, input_dev->keybit);
> +                       set_bit(k, input_dev->keybit);
>                 }
>         }
>
> --
> 2.1.3
>
--
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] 6+ messages in thread

* Fwd: [RFC PATCH 2/2] USB: input: yealink.c: add mapping for "RING" and "MUTE" keys
       [not found]   ` <CAMFK4TM4zVNWBt14vS3T=eQMtwM2OMLW4Wf5dfHS1vKVoPrQiw@mail.gmail.com>
@ 2015-01-09 12:42     ` Henk
  0 siblings, 0 replies; 6+ messages in thread
From: Henk @ 2015-01-09 12:42 UTC (permalink / raw)
  To: linux-input, linux-kernel

Signed-off-by: Henk Vergonet <henk.vergonet@gmail.com>


On Mon, Dec 22, 2014 at 3:41 PM, Daniele Forsi <dforsi@gmail.com> wrote:
>
> According to the user manual of the "VOIP-3 SKY" USB phone, the RING
> key is used to select different ring tones and the MUTE key is used
> to mute the microphone.
>
> Signed-off-by: Daniele Forsi <dforsi@gmail.com>
> ---
>  drivers/input/misc/yealink.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
> index e9403da..0b86c49 100644
> --- a/drivers/input/misc/yealink.c
> +++ b/drivers/input/misc/yealink.c
> @@ -189,7 +189,9 @@ static int setChar(struct yealink_dev *yld, int el, int chr)
>   * USB-P1K button layout:
>   *
>   *             up
> + *            ring
>   *       IN           OUT
> + *            mute
>   *            down
>   *
>   *     pickup   C    hangup
> @@ -207,7 +209,9 @@ static int map_p1k_to_key(int scancode)
>         switch(scancode) {              /* phone key:   */
>         case 0x23: return KEY_LEFT;     /*   IN         */
>         case 0x33: return KEY_UP;       /*   up         */
> +       case 0x44: return KEY_SOUND;    /*   ring       */
>         case 0x04: return KEY_RIGHT;    /*   OUT        */
> +       case 0x41: return KEY_MICMUTE;  /*   mute       */
>         case 0x24: return KEY_DOWN;     /*   down       */
>         case 0x03: return KEY_ENTER;    /*   pickup     */
>         case 0x14: return KEY_BACKSPACE; /*  C          */
> --
> 2.1.3
>

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

end of thread, other threads:[~2015-01-09 12:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-22 14:41 [RFC PATCH 0/2] USB: input: yealink.c: update key mappings Daniele Forsi
2014-12-22 14:41 ` [RFC PATCH 1/2] USB: input: yealink.c: use KEY_NUMERIC_* for numeric keys, star and pound Daniele Forsi
     [not found]   ` <CAMFK4TMJTb5dJ1kXLBgsu8WE8Ygyh+jW_d_TqmDO5OqB5yr3nw@mail.gmail.com>
2015-01-09 12:41     ` Fwd: " Henk
2014-12-22 14:41 ` [RFC PATCH 2/2] USB: input: yealink.c: add mapping for "RING" and "MUTE" keys Daniele Forsi
     [not found]   ` <CAMFK4TM4zVNWBt14vS3T=eQMtwM2OMLW4Wf5dfHS1vKVoPrQiw@mail.gmail.com>
2015-01-09 12:42     ` Fwd: " Henk
     [not found] ` <CAMFK4TMNuQEao5n3XPjn4ZSkX0eTtfkWO+h=bPbyHthyJYebPw@mail.gmail.com>
2015-01-09 12:40   ` Fwd: [RFC PATCH 0/2] USB: input: yealink.c: update key mappings Henk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).