Re: [PATCH] [media/input] rc: report rc protocol type to userspace through input

2016-09-25 Thread Sean Young
Hi Dmitry,

On Fri, Sep 23, 2016 at 03:08:31PM -0700, Dmitry Torokhov wrote:
> On Thu, Sep 22, 2016 at 11:57:13AM -0300, Mauro Carvalho Chehab wrote:
> > Em Wed, 21 Sep 2016 10:54:21 +0100
> > Sean Young  escreveu:
> > 
> > > We might want to know what protocol a remote uses when we do not know. 
> > > With
> > > this patch and another patch for v4l-utils (follows), you can do that 
> > > with:
> > > 
> > > ./ir-keytable  -p rc-5,nec,rc-6,jvc,sony,sanyo,sharp,xmp -t
> > > Testing events. Please, press CTRL-C to abort.
> > > 1474415431.689685: event type EV_MSC(0x04): protocol = RC_TYPE_RC6_MCE
> > > 1474415431.689685: event type EV_MSC(0x04): scancode = 0x800f040e
> > > 1474415431.689685: event type EV_SYN(0x00).
> > > 
> > > This makes RC_TYPE_* part of the ABI. We also remove the enum rc_type,
> > > since in input-event-codes.h we cannot not use enums.
> > > 
> > > In addition, now that the input layer knows the rc protocol and scancode,
> > > at a later point we could add a feature where keymaps could be created
> > > based on both protocol and scancode, not just scancode.
> > 
> > We need Dmitry's ack in order to apply this one.
> 
> I'd rather not: I am trying to keep input API hardware-independent and
> the kind of device emitting keycodes (a remote control in the sense of
> drivers/media/rc or USB device or BT device) should not really matter to
> consumers. Similarly how we do not export whether device is USB1.1 or
> USB2 or USB3 (although we do have input->id.bustype, but it is more for
> identification purposes rather than for adjusting properties).

Keyboards produce device dependant scancodes; the only output RC devices 
have is protocol and scancode. The scancode is already being sent to
the input layer, and if we can't send the rc protocol to the input layer
we would need a new char device just for that, which is complete overkill.

Alternatively we can put the rc protocol type in MSC_RAW, MSC_SERIAL or
ABS_MISC or one of the other existing device dependant input codes. 

> For configuration (like loading keymaps) we can examine
> parent hardware device and decide.

Unfortunately there is nothing to examine there. The usb device of an 
infrared receiver will tell you nothing about the remote the user is
using.

It would be really helpful if this could be merged; I don't know what
other solution there is to this problem.


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


Re: [PATCH] [media/input] rc: report rc protocol type to userspace through input

2016-09-23 Thread Dmitry Torokhov
On Thu, Sep 22, 2016 at 11:57:13AM -0300, Mauro Carvalho Chehab wrote:
> Em Wed, 21 Sep 2016 10:54:21 +0100
> Sean Young  escreveu:
> 
> > We might want to know what protocol a remote uses when we do not know. With
> > this patch and another patch for v4l-utils (follows), you can do that with:
> > 
> > ./ir-keytable  -p rc-5,nec,rc-6,jvc,sony,sanyo,sharp,xmp -t
> > Testing events. Please, press CTRL-C to abort.
> > 1474415431.689685: event type EV_MSC(0x04): protocol = RC_TYPE_RC6_MCE
> > 1474415431.689685: event type EV_MSC(0x04): scancode = 0x800f040e
> > 1474415431.689685: event type EV_SYN(0x00).
> > 
> > This makes RC_TYPE_* part of the ABI. We also remove the enum rc_type,
> > since in input-event-codes.h we cannot not use enums.
> > 
> > In addition, now that the input layer knows the rc protocol and scancode,
> > at a later point we could add a feature where keymaps could be created
> > based on both protocol and scancode, not just scancode.
> 
> We need Dmitry's ack in order to apply this one.

I'd rather not: I am trying to keep input API hardware-independent and
the kind of device emitting keycodes (a remote control in the sense of
drivers/media/rc or USB device or BT device) should not really matter to
consumers. Similarly how we do not export whether device is USB1.1 or
USB2 or USB3 (although we do have input->id.bustype, but it is more for
identification purposes rather than for adjusting properties).

For configuration (like loading keymaps) we can examine
parent hardware device and decide.

Thanks.

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


Re: [PATCH] [media/input] rc: report rc protocol type to userspace through input

2016-09-22 Thread Mauro Carvalho Chehab
Em Wed, 21 Sep 2016 10:54:21 +0100
Sean Young  escreveu:

> We might want to know what protocol a remote uses when we do not know. With
> this patch and another patch for v4l-utils (follows), you can do that with:
> 
> ./ir-keytable  -p rc-5,nec,rc-6,jvc,sony,sanyo,sharp,xmp -t
> Testing events. Please, press CTRL-C to abort.
> 1474415431.689685: event type EV_MSC(0x04): protocol = RC_TYPE_RC6_MCE
> 1474415431.689685: event type EV_MSC(0x04): scancode = 0x800f040e
> 1474415431.689685: event type EV_SYN(0x00).
> 
> This makes RC_TYPE_* part of the ABI. We also remove the enum rc_type,
> since in input-event-codes.h we cannot not use enums.
> 
> In addition, now that the input layer knows the rc protocol and scancode,
> at a later point we could add a feature where keymaps could be created
> based on both protocol and scancode, not just scancode.

We need Dmitry's ack in order to apply this one.

> 
> Signed-off-by: Sean Young 
> ---
>  drivers/media/i2c/ir-kbd-i2c.c  | 17 +
>  drivers/media/pci/bt8xx/bttv-input.c|  4 +--
>  drivers/media/pci/cx88/cx88-input.c |  4 +--
>  drivers/media/pci/ivtv/ivtv-i2c.c   |  4 +--
>  drivers/media/pci/saa7134/saa7134-input.c   | 18 +-
>  drivers/media/rc/img-ir/img-ir-hw.h |  2 +-
>  drivers/media/rc/ir-nec-decoder.c   |  3 +-
>  drivers/media/rc/ir-rc5-decoder.c   |  3 +-
>  drivers/media/rc/ir-rc6-decoder.c   |  3 +-
>  drivers/media/rc/ir-sony-decoder.c  |  3 +-
>  drivers/media/rc/rc-main.c  | 11 +++---
>  drivers/media/usb/cx231xx/cx231xx-input.c   |  4 +--
>  drivers/media/usb/dvb-usb-v2/af9015.c   |  2 +-
>  drivers/media/usb/dvb-usb-v2/af9035.c   |  3 +-
>  drivers/media/usb/dvb-usb-v2/az6007.c   |  2 +-
>  drivers/media/usb/dvb-usb-v2/rtl28xxu.c |  2 +-
>  drivers/media/usb/dvb-usb/dib0700_core.c|  2 +-
>  drivers/media/usb/dvb-usb/dib0700_devices.c |  3 +-
>  drivers/media/usb/dvb-usb/dtt200u.c |  2 +-
>  drivers/media/usb/em28xx/em28xx-input.c | 15 
>  drivers/media/usb/tm6000/tm6000-input.c |  3 +-
>  include/media/i2c/ir-kbd-i2c.h  |  4 +--
>  include/media/rc-core.h |  7 ++--
>  include/media/rc-map.h  | 54 
> ++---
>  include/uapi/linux/input-event-codes.h  | 28 +++
>  25 files changed, 89 insertions(+), 114 deletions(-)
> 
> diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
> index bf82726..f8435fa 100644
> --- a/drivers/media/i2c/ir-kbd-i2c.c
> +++ b/drivers/media/i2c/ir-kbd-i2c.c
> @@ -62,7 +62,7 @@ module_param(debug, int, 0644);/* debug level (0,1,2) */
>  
>  /* --- */
>  
> -static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
> +static int get_key_haup_common(struct IR_i2c *ir, u32 *protocol,
>  u32 *scancode, u8 *ptoggle, int size, int offset)
>  {
>   unsigned char buf[6];
> @@ -104,13 +104,13 @@ static int get_key_haup_common(struct IR_i2c *ir, enum 
> rc_type *protocol,
>   return 1;
>  }
>  
> -static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol,
> +static int get_key_haup(struct IR_i2c *ir, u32 *protocol,
>   u32 *scancode, u8 *toggle)
>  {
>   return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0);
>  }
>  
> -static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol,
> +static int get_key_haup_xvr(struct IR_i2c *ir, u32 *protocol,
>   u32 *scancode, u8 *toggle)
>  {
>   int ret;
> @@ -129,7 +129,7 @@ static int get_key_haup_xvr(struct IR_i2c *ir, enum 
> rc_type *protocol,
>   return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3);
>  }
>  
> -static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol,
> +static int get_key_pixelview(struct IR_i2c *ir, u32 *protocol,
>u32 *scancode, u8 *toggle)
>  {
>   unsigned char b;
> @@ -146,7 +146,7 @@ static int get_key_pixelview(struct IR_i2c *ir, enum 
> rc_type *protocol,
>   return 1;
>  }
>  
> -static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol,
> +static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *protocol,
> u32 *scancode, u8 *toggle)
>  {
>   unsigned char buf[4];
> @@ -171,7 +171,7 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, enum 
> rc_type *protocol,
>   return 1;
>  }
>  
> -static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol,
> +static int get_key_knc1(struct IR_i2c *ir, u32 *protocol,
>   u32 *scancode, u8 *toggle)
>  {
>   unsigned char b;
> @@ -201,7 +201,7 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_type 
> *protocol,
>   return 1;
>  }
>  
> -static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type 
> *protocol,
> 

[PATCH] [media/input] rc: report rc protocol type to userspace through input

2016-09-21 Thread Sean Young
We might want to know what protocol a remote uses when we do not know. With
this patch and another patch for v4l-utils (follows), you can do that with:

./ir-keytable  -p rc-5,nec,rc-6,jvc,sony,sanyo,sharp,xmp -t
Testing events. Please, press CTRL-C to abort.
1474415431.689685: event type EV_MSC(0x04): protocol = RC_TYPE_RC6_MCE
1474415431.689685: event type EV_MSC(0x04): scancode = 0x800f040e
1474415431.689685: event type EV_SYN(0x00).

This makes RC_TYPE_* part of the ABI. We also remove the enum rc_type,
since in input-event-codes.h we cannot not use enums.

In addition, now that the input layer knows the rc protocol and scancode,
at a later point we could add a feature where keymaps could be created
based on both protocol and scancode, not just scancode.

Signed-off-by: Sean Young 
---
 drivers/media/i2c/ir-kbd-i2c.c  | 17 +
 drivers/media/pci/bt8xx/bttv-input.c|  4 +--
 drivers/media/pci/cx88/cx88-input.c |  4 +--
 drivers/media/pci/ivtv/ivtv-i2c.c   |  4 +--
 drivers/media/pci/saa7134/saa7134-input.c   | 18 +-
 drivers/media/rc/img-ir/img-ir-hw.h |  2 +-
 drivers/media/rc/ir-nec-decoder.c   |  3 +-
 drivers/media/rc/ir-rc5-decoder.c   |  3 +-
 drivers/media/rc/ir-rc6-decoder.c   |  3 +-
 drivers/media/rc/ir-sony-decoder.c  |  3 +-
 drivers/media/rc/rc-main.c  | 11 +++---
 drivers/media/usb/cx231xx/cx231xx-input.c   |  4 +--
 drivers/media/usb/dvb-usb-v2/af9015.c   |  2 +-
 drivers/media/usb/dvb-usb-v2/af9035.c   |  3 +-
 drivers/media/usb/dvb-usb-v2/az6007.c   |  2 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c |  2 +-
 drivers/media/usb/dvb-usb/dib0700_core.c|  2 +-
 drivers/media/usb/dvb-usb/dib0700_devices.c |  3 +-
 drivers/media/usb/dvb-usb/dtt200u.c |  2 +-
 drivers/media/usb/em28xx/em28xx-input.c | 15 
 drivers/media/usb/tm6000/tm6000-input.c |  3 +-
 include/media/i2c/ir-kbd-i2c.h  |  4 +--
 include/media/rc-core.h |  7 ++--
 include/media/rc-map.h  | 54 ++---
 include/uapi/linux/input-event-codes.h  | 28 +++
 25 files changed, 89 insertions(+), 114 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index bf82726..f8435fa 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -62,7 +62,7 @@ module_param(debug, int, 0644);/* debug level (0,1,2) */
 
 /* --- */
 
-static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_haup_common(struct IR_i2c *ir, u32 *protocol,
   u32 *scancode, u8 *ptoggle, int size, int offset)
 {
unsigned char buf[6];
@@ -104,13 +104,13 @@ static int get_key_haup_common(struct IR_i2c *ir, enum 
rc_type *protocol,
return 1;
 }
 
-static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_haup(struct IR_i2c *ir, u32 *protocol,
u32 *scancode, u8 *toggle)
 {
return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0);
 }
 
-static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_haup_xvr(struct IR_i2c *ir, u32 *protocol,
u32 *scancode, u8 *toggle)
 {
int ret;
@@ -129,7 +129,7 @@ static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type 
*protocol,
return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3);
 }
 
-static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_pixelview(struct IR_i2c *ir, u32 *protocol,
 u32 *scancode, u8 *toggle)
 {
unsigned char b;
@@ -146,7 +146,7 @@ static int get_key_pixelview(struct IR_i2c *ir, enum 
rc_type *protocol,
return 1;
 }
 
-static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *protocol,
  u32 *scancode, u8 *toggle)
 {
unsigned char buf[4];
@@ -171,7 +171,7 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, enum 
rc_type *protocol,
return 1;
 }
 
-static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_knc1(struct IR_i2c *ir, u32 *protocol,
u32 *scancode, u8 *toggle)
 {
unsigned char b;
@@ -201,7 +201,7 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_type 
*protocol,
return 1;
 }
 
-static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol,
+static int get_key_avermedia_cardbus(struct IR_i2c *ir, u32 *protocol,
 u32 *scancode, u8 *toggle)
 {
unsigned char subaddr, key, keygroup;
@@ -248,8 +248,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, 
enum rc_type *protocol,
 
 static int ir_ke