All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: "David Härdeman" <david@hardeman.nu>
Cc: <linux-media@vger.kernel.org>, <m.chehab@samsung.com>
Subject: Re: [PATCH 04/11] rc-core: do not change 32bit NEC scancode format for now
Date: Mon, 31 Mar 2014 10:09:38 +0100	[thread overview]
Message-ID: <533930D2.8060106@imgtec.com> (raw)
In-Reply-To: <20140329161105.13234.40393.stgit@zeus.muc.hardeman.nu>

[-- Attachment #1: Type: text/plain, Size: 3142 bytes --]

On 29/03/14 16:11, David Härdeman wrote:
> This reverts 18bc17448147e93f31cc9b1a83be49f1224657b2
> 
> The patch ignores the fact that NEC32 scancodes are generated not only in the
> NEC raw decoder but also directly in some drivers. Whichever approach is chosen
> it should be consistent across drivers and this patch needs more discussion.
> 
> Furthermore, I'm convinced that we have to stop playing games trying to
> decipher the "meaning" of NEC scancodes (what's the customer/vendor/address,
> which byte is the MSB, etc).
> 
> This patch is in preparation for the next few patches in this series.
> 
> Signed-off-by: David Härdeman <david@hardeman.nu>
> ---
>  drivers/media/rc/img-ir/img-ir-nec.c |   27 ++++++-----
>  drivers/media/rc/ir-nec-decoder.c    |    5 --
>  drivers/media/rc/keymaps/rc-tivo.c   |   86 +++++++++++++++++-----------------
>  3 files changed, 59 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c
> index c0111d6..40ee844 100644
> --- a/drivers/media/rc/img-ir/img-ir-nec.c
> +++ b/drivers/media/rc/img-ir/img-ir-nec.c
> @@ -5,6 +5,7 @@
>   */
>  
>  #include "img-ir-hw.h"
> +#include <linux/bitrev.h>
>  
>  /* Convert NEC data to a scancode */
>  static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
> @@ -23,11 +24,11 @@ static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
>  	data_inv = (raw >> 24) & 0xff;
>  	if ((data_inv ^ data) != 0xff) {
>  		/* 32-bit NEC (used by Apple and TiVo remotes) */
> -		/* scan encoding: aaAAddDD */
> -		*scancode = addr_inv << 24 |
> -			    addr     << 16 |
> -			    data_inv <<  8 |
> -			    data;
> +		/* scan encoding: AAaaDDdd (LSBit first) */
> +		*scancode = bitrev8(addr)     << 24 |
> +			    bitrev8(addr_inv) << 16 |
> +			    bitrev8(data)     <<  8 |
> +			    bitrev8(data_inv);
>  	} else if ((addr_inv ^ addr) != 0xff) {
>  		/* Extended NEC */
>  		/* scan encoding: AAaaDD */
> @@ -56,13 +57,15 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
>  
>  	if ((in->data | in->mask) & 0xff000000) {
>  		/* 32-bit NEC (used by Apple and TiVo remotes) */
> -		/* scan encoding: aaAAddDD */
> -		addr_inv   = (in->data >> 24) & 0xff;
> -		addr_inv_m = (in->mask >> 24) & 0xff;
> -		addr       = (in->data >> 16) & 0xff;
> -		addr_m     = (in->mask >> 16) & 0xff;
> -		data_inv   = (in->data >>  8) & 0xff;
> -		data_inv_m = (in->mask >>  8) & 0xff;
> +		/* scan encoding: AAaaDDdd (LSBit first) */
> +		addr       = bitrev8((in->data >> 24) & 0xff);
> +		addr_m     = (in->mask >> 24) & 0xff;
> +		addr_inv   = bitrev8((in->data >> 16) & 0xff);
> +		addr_inv_m = (in->mask >> 16) & 0xff;
> +		data       = bitrev8((in->data >>  8) & 0xff);
> +		data_m     = (in->mask >>  8) & 0xff;
> +		data_inv   = bitrev8((in->data >>  0) & 0xff);
> +		data_inv_m = (in->mask >>  0) & 0xff;

I think the masks need bit reversing too, otherwise the mask bits won't
line up with the data as intended.

Otherwise this patch looks okay to me.

Cheers
James


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-03-31  9:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-29 16:10 [PATCH 00/11] rc-core: My current patch queue David Härdeman
2014-03-29 16:10 ` [PATCH 01/11] bt8xx: fixup RC5 decoding David Härdeman
2014-03-29 16:10 ` [PATCH 02/11] rc-core: improve ir-kbd-i2c get_key functions David Härdeman
2014-03-29 16:11 ` [PATCH 03/11] rc-core: document the protocol type David Härdeman
2014-03-31  9:54   ` James Hogan
2014-03-31 19:39     ` David Härdeman
2014-03-29 16:11 ` [PATCH 04/11] rc-core: do not change 32bit NEC scancode format for now David Härdeman
2014-03-31  9:09   ` James Hogan [this message]
2014-03-29 16:11 ` [PATCH 05/11] rc-core: split dev->s_filter David Härdeman
2014-04-03 23:27   ` James Hogan
2014-03-29 16:11 ` [PATCH 06/11] rc-core: remove generic scancode filter David Härdeman
2014-03-31  9:29   ` James Hogan
2014-03-31 19:38     ` David Härdeman
2014-03-31 22:01       ` James Hogan
2014-03-29 16:11 ` [PATCH 07/11] dib0700: NEC scancode cleanup David Härdeman
2014-03-29 16:11 ` [PATCH 08/11] lmedm04: " David Härdeman
2014-03-29 16:11 ` [PATCH 09/11] saa7134: NEC scancode fix David Härdeman
2014-03-29 16:11 ` [PATCH 10/11] [RFC] rc-core: use the full 32 bits for NEC scancodes David Härdeman
2014-03-31  9:44   ` James Hogan
2014-03-31 10:19     ` David Härdeman
2014-03-31 10:56       ` James Hogan
2014-03-31 13:22         ` David Härdeman
2014-03-31 14:06           ` James Hogan
2014-03-31 15:26           ` Mauro Carvalho Chehab
2014-03-31 16:47             ` David Härdeman
2014-03-31 12:14       ` Mauro Carvalho Chehab
2014-03-31 12:58         ` David Härdeman
2014-03-31 13:15           ` Mauro Carvalho Chehab
2014-03-31 13:54             ` David Härdeman
2014-03-29 16:11 ` [PATCH 11/11] [RFC] rc-core: don't throw away protocol information David Härdeman

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=533930D2.8060106@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=david@hardeman.nu \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.