Re: [PATCH 4/4] ir-keytable: allow protocol for scancode-keycode mappings
On Thu, May 14, 2015 at 06:24:46PM -0300, Mauro Carvalho Chehab wrote: Em Mon, 06 Apr 2015 13:26:18 +0200 David Härdeman da...@hardeman.nu escreveu: Introduce a list of kernel ir protocols (e.g. sony12 instead of sony) and extend the set-key command to ir-keytable to allow for a mapping of the form protocol:scancode=keycode in addition to the old scancode=keycode format. The code automatically falls back to the old behaviour if the kernel doesn't support the new approach with protocols. The read command is also updated to show the protocol information if the kernel supports it. I applied patches 1 to 3 of this series, as they are not based on any new feature. This patch, however, needs to wait for the Kernel patch to be acked, and may be modified, depending on the review process. I'll mark it at patchwork as RFC. Please re-submit after we merge the Kernel changes. Agreed :) Thanks, Mauro Signed-off-by: David Härdeman da...@hardeman.nu --- utils/keytable/keytable.c | 288 - 1 file changed, 202 insertions(+), 86 deletions(-) diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c index 63eea2e..fd50095 100644 --- a/utils/keytable/keytable.c +++ b/utils/keytable/keytable.c @@ -55,13 +55,22 @@ struct input_keymap_entry_v2 { #define EVIOCSKEYCODE_V2_IOW('E', 0x04, struct input_keymap_entry_v2) #endif -struct keytable_entry { -u_int32_t scancode; -u_int32_t keycode; -struct keytable_entry *next; +struct rc_scancode { +u_int16_t protocol; +u_int16_t reserved[3]; +u_int64_t scancode; }; -struct keytable_entry *keytable = NULL; +struct rc_keymap_entry { +u_int8_t flags; +u_int8_t len; +u_int16_t index; +u_int32_t keycode; +union { +struct rc_scancode rc; +u_int8_t raw[32]; +}; +}; struct uevents { char*key; @@ -109,41 +118,76 @@ enum sysfs_protocols { SYSFS_INVALID = 0, }; +enum kernel_protocol { +KERN_UNKNOWN= 0,/* Protocol not known */ +KERN_OTHER = 1,/* Protocol known but proprietary */ +KERN_LIRC = 2,/* Pass raw IR to lirc userspace */ +KERN_RC5= 3,/* Philips RC5 protocol */ +KERN_RC5X = 4,/* Philips RC5x protocol */ +KERN_RC5_SZ = 5,/* StreamZap variant of RC5 */ +KERN_JVC= 6,/* JVC protocol */ +KERN_SONY12 = 7,/* Sony 12 bit protocol */ +KERN_SONY15 = 8,/* Sony 15 bit protocol */ +KERN_SONY20 = 9,/* Sony 20 bit protocol */ +KERN_NEC= 10, /* NEC protocol */ +KERN_SANYO = 11, /* Sanyo protocol */ +KERN_MCE_KBD= 12, /* RC6-ish MCE keyboard/mouse */ +KERN_RC6_0 = 13, /* Philips RC6-0-16 protocol */ +KERN_RC6_6A_20 = 14, /* Philips RC6-6A-20 protocol */ +KERN_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */ +KERN_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */ +KERN_RC6_MCE= 17, /* MCE (Philips RC6-6A-32 subtype) protocol */ +KERN_SHARP = 18, /* Sharp protocol */ +KERN_XMP= 19, /* XMP protocol */ +KERN_INVALID= 31, /* internal, no real protocol number */ +}; + struct protocol_map_entry { const char *name; const char *sysfs1_name; enum sysfs_protocols sysfs_protocol; +enum kernel_protocol kernel_protocol; }; const struct protocol_map_entry protocol_map[] = { -{ unknown,NULL, SYSFS_UNKNOWN }, -{ other, NULL, SYSFS_OTHER }, -{ lirc, NULL, SYSFS_LIRC }, -{ rc-5, /rc5_decoder, SYSFS_RC5 }, -{ rc5,NULL, SYSFS_RC5 }, -{ rc-5x, NULL, SYSFS_INVALID }, -{ rc5x, NULL, SYSFS_INVALID }, -{ jvc,/jvc_decoder, SYSFS_JVC }, -{ sony, /sony_decoder,SYSFS_SONY }, -{ sony12, NULL, SYSFS_INVALID }, -{ sony15, NULL, SYSFS_INVALID }, -{ sony20, NULL, SYSFS_INVALID }, -{ nec,/nec_decoder, SYSFS_NEC }, -{ sanyo, NULL, SYSFS_SANYO }, -{ mce-kbd,NULL, SYSFS_MCE_KBD }, -{ mce_kbd,NULL, SYSFS_MCE_KBD }, -{ rc-6, /rc6_decoder, SYSFS_RC6 }, -{ rc6,NULL, SYSFS_RC6 }, -{ rc-6-0, NULL, SYSFS_INVALID }, -{ rc-6-6a-20, NULL, SYSFS_INVALID }, -{ rc-6-6a-24, NULL, SYSFS_INVALID }, -{ rc-6-6a-32, NULL, SYSFS_INVALID }, -{ rc-6-mce, NULL, SYSFS_INVALID }, -{ sharp,
Re: [PATCH 4/4] ir-keytable: allow protocol for scancode-keycode mappings
Em Mon, 06 Apr 2015 13:26:18 +0200 David Härdeman da...@hardeman.nu escreveu: Introduce a list of kernel ir protocols (e.g. sony12 instead of sony) and extend the set-key command to ir-keytable to allow for a mapping of the form protocol:scancode=keycode in addition to the old scancode=keycode format. The code automatically falls back to the old behaviour if the kernel doesn't support the new approach with protocols. The read command is also updated to show the protocol information if the kernel supports it. I applied patches 1 to 3 of this series, as they are not based on any new feature. This patch, however, needs to wait for the Kernel patch to be acked, and may be modified, depending on the review process. I'll mark it at patchwork as RFC. Please re-submit after we merge the Kernel changes. Thanks, Mauro Signed-off-by: David Härdeman da...@hardeman.nu --- utils/keytable/keytable.c | 288 - 1 file changed, 202 insertions(+), 86 deletions(-) diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c index 63eea2e..fd50095 100644 --- a/utils/keytable/keytable.c +++ b/utils/keytable/keytable.c @@ -55,13 +55,22 @@ struct input_keymap_entry_v2 { #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry_v2) #endif -struct keytable_entry { - u_int32_t scancode; - u_int32_t keycode; - struct keytable_entry *next; +struct rc_scancode { + u_int16_t protocol; + u_int16_t reserved[3]; + u_int64_t scancode; }; -struct keytable_entry *keytable = NULL; +struct rc_keymap_entry { + u_int8_t flags; + u_int8_t len; + u_int16_t index; + u_int32_t keycode; + union { + struct rc_scancode rc; + u_int8_t raw[32]; + }; +}; struct uevents { char*key; @@ -109,41 +118,76 @@ enum sysfs_protocols { SYSFS_INVALID = 0, }; +enum kernel_protocol { + KERN_UNKNOWN= 0,/* Protocol not known */ + KERN_OTHER = 1,/* Protocol known but proprietary */ + KERN_LIRC = 2,/* Pass raw IR to lirc userspace */ + KERN_RC5= 3,/* Philips RC5 protocol */ + KERN_RC5X = 4,/* Philips RC5x protocol */ + KERN_RC5_SZ = 5,/* StreamZap variant of RC5 */ + KERN_JVC= 6,/* JVC protocol */ + KERN_SONY12 = 7,/* Sony 12 bit protocol */ + KERN_SONY15 = 8,/* Sony 15 bit protocol */ + KERN_SONY20 = 9,/* Sony 20 bit protocol */ + KERN_NEC= 10, /* NEC protocol */ + KERN_SANYO = 11, /* Sanyo protocol */ + KERN_MCE_KBD= 12, /* RC6-ish MCE keyboard/mouse */ + KERN_RC6_0 = 13, /* Philips RC6-0-16 protocol */ + KERN_RC6_6A_20 = 14, /* Philips RC6-6A-20 protocol */ + KERN_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */ + KERN_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */ + KERN_RC6_MCE= 17, /* MCE (Philips RC6-6A-32 subtype) protocol */ + KERN_SHARP = 18, /* Sharp protocol */ + KERN_XMP= 19, /* XMP protocol */ + KERN_INVALID= 31, /* internal, no real protocol number */ +}; + struct protocol_map_entry { const char *name; const char *sysfs1_name; enum sysfs_protocols sysfs_protocol; + enum kernel_protocol kernel_protocol; }; const struct protocol_map_entry protocol_map[] = { - { unknown,NULL, SYSFS_UNKNOWN }, - { other, NULL, SYSFS_OTHER }, - { lirc, NULL, SYSFS_LIRC }, - { rc-5, /rc5_decoder, SYSFS_RC5 }, - { rc5,NULL, SYSFS_RC5 }, - { rc-5x, NULL, SYSFS_INVALID }, - { rc5x, NULL, SYSFS_INVALID }, - { jvc,/jvc_decoder, SYSFS_JVC }, - { sony, /sony_decoder,SYSFS_SONY }, - { sony12, NULL, SYSFS_INVALID }, - { sony15, NULL, SYSFS_INVALID }, - { sony20, NULL, SYSFS_INVALID }, - { nec,/nec_decoder, SYSFS_NEC }, - { sanyo, NULL, SYSFS_SANYO }, - { mce-kbd,NULL, SYSFS_MCE_KBD }, - { mce_kbd,NULL, SYSFS_MCE_KBD }, - { rc-6, /rc6_decoder, SYSFS_RC6 }, - { rc6,NULL, SYSFS_RC6 }, - { rc-6-0, NULL, SYSFS_INVALID }, - { rc-6-6a-20, NULL, SYSFS_INVALID }, - { rc-6-6a-24, NULL, SYSFS_INVALID }, - { rc-6-6a-32, NULL, SYSFS_INVALID }, - { rc-6-mce, NULL, SYSFS_INVALID }, - { sharp, NULL,
[PATCH 4/4] ir-keytable: allow protocol for scancode-keycode mappings
Introduce a list of kernel ir protocols (e.g. sony12 instead of sony) and extend the set-key command to ir-keytable to allow for a mapping of the form protocol:scancode=keycode in addition to the old scancode=keycode format. The code automatically falls back to the old behaviour if the kernel doesn't support the new approach with protocols. The read command is also updated to show the protocol information if the kernel supports it. Signed-off-by: David Härdeman da...@hardeman.nu --- utils/keytable/keytable.c | 288 - 1 file changed, 202 insertions(+), 86 deletions(-) diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c index 63eea2e..fd50095 100644 --- a/utils/keytable/keytable.c +++ b/utils/keytable/keytable.c @@ -55,13 +55,22 @@ struct input_keymap_entry_v2 { #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry_v2) #endif -struct keytable_entry { - u_int32_t scancode; - u_int32_t keycode; - struct keytable_entry *next; +struct rc_scancode { + u_int16_t protocol; + u_int16_t reserved[3]; + u_int64_t scancode; }; -struct keytable_entry *keytable = NULL; +struct rc_keymap_entry { + u_int8_t flags; + u_int8_t len; + u_int16_t index; + u_int32_t keycode; + union { + struct rc_scancode rc; + u_int8_t raw[32]; + }; +}; struct uevents { char*key; @@ -109,41 +118,76 @@ enum sysfs_protocols { SYSFS_INVALID = 0, }; +enum kernel_protocol { + KERN_UNKNOWN= 0,/* Protocol not known */ + KERN_OTHER = 1,/* Protocol known but proprietary */ + KERN_LIRC = 2,/* Pass raw IR to lirc userspace */ + KERN_RC5= 3,/* Philips RC5 protocol */ + KERN_RC5X = 4,/* Philips RC5x protocol */ + KERN_RC5_SZ = 5,/* StreamZap variant of RC5 */ + KERN_JVC= 6,/* JVC protocol */ + KERN_SONY12 = 7,/* Sony 12 bit protocol */ + KERN_SONY15 = 8,/* Sony 15 bit protocol */ + KERN_SONY20 = 9,/* Sony 20 bit protocol */ + KERN_NEC= 10, /* NEC protocol */ + KERN_SANYO = 11, /* Sanyo protocol */ + KERN_MCE_KBD= 12, /* RC6-ish MCE keyboard/mouse */ + KERN_RC6_0 = 13, /* Philips RC6-0-16 protocol */ + KERN_RC6_6A_20 = 14, /* Philips RC6-6A-20 protocol */ + KERN_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */ + KERN_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */ + KERN_RC6_MCE= 17, /* MCE (Philips RC6-6A-32 subtype) protocol */ + KERN_SHARP = 18, /* Sharp protocol */ + KERN_XMP= 19, /* XMP protocol */ + KERN_INVALID= 31, /* internal, no real protocol number */ +}; + struct protocol_map_entry { const char *name; const char *sysfs1_name; enum sysfs_protocols sysfs_protocol; + enum kernel_protocol kernel_protocol; }; const struct protocol_map_entry protocol_map[] = { - { unknown,NULL, SYSFS_UNKNOWN }, - { other, NULL, SYSFS_OTHER }, - { lirc, NULL, SYSFS_LIRC }, - { rc-5, /rc5_decoder, SYSFS_RC5 }, - { rc5,NULL, SYSFS_RC5 }, - { rc-5x, NULL, SYSFS_INVALID }, - { rc5x, NULL, SYSFS_INVALID }, - { jvc,/jvc_decoder, SYSFS_JVC }, - { sony, /sony_decoder,SYSFS_SONY }, - { sony12, NULL, SYSFS_INVALID }, - { sony15, NULL, SYSFS_INVALID }, - { sony20, NULL, SYSFS_INVALID }, - { nec,/nec_decoder, SYSFS_NEC }, - { sanyo, NULL, SYSFS_SANYO }, - { mce-kbd,NULL, SYSFS_MCE_KBD }, - { mce_kbd,NULL, SYSFS_MCE_KBD }, - { rc-6, /rc6_decoder, SYSFS_RC6 }, - { rc6,NULL, SYSFS_RC6 }, - { rc-6-0, NULL, SYSFS_INVALID }, - { rc-6-6a-20, NULL, SYSFS_INVALID }, - { rc-6-6a-24, NULL, SYSFS_INVALID }, - { rc-6-6a-32, NULL, SYSFS_INVALID }, - { rc-6-mce, NULL, SYSFS_INVALID }, - { sharp, NULL, SYSFS_SHARP }, - { xmp,/xmp_decoder, SYSFS_XMP }, - { NULL, NULL, SYSFS_INVALID }, + { unknown,NULL, SYSFS_UNKNOWN, KERN_UNKNOWN}, + { other, NULL, SYSFS_OTHER,KERN_OTHER }, + { lirc, NULL, SYSFS_LIRC, KERN_LIRC }, + { rc-5,