From: "David Härdeman" <david@hardeman.nu>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: James Hogan <james.hogan@imgtec.com>, linux-media@vger.kernel.org
Subject: Re: [PATCH 10/11] [RFC] rc-core: use the full 32 bits for NEC scancodes
Date: Mon, 31 Mar 2014 18:47:56 +0200 [thread overview]
Message-ID: <20140331164756.GA9610@hardeman.nu> (raw)
In-Reply-To: <20140331122656.13266f88@samsung.com>
On Mon, Mar 31, 2014 at 12:26:56PM -0300, Mauro Carvalho Chehab wrote:
>Inside the RC core, for all other protocols, the order always
>ADDRESS + COMMAND.
>
>Up to NEC-24 bits, this is preserved, as the command is always 0xDD
>and the address is either 0xaaAA or 0xAA.
>
>The 32-bits NEC is a little ackward, if we consider the command as
>also being 8 bits, and the address having 24 bits.
>
>The Tivo keytable is weird:
>
> { 0x3085f009, KEY_MEDIA }, /* TiVo Button */
> { 0x3085e010, KEY_POWER2 }, /* TV Power */
> { 0x3085e011, KEY_TV }, /* Live TV/Swap */
> { 0x3085c034, KEY_VIDEO_NEXT }, /* TV Input */
> { 0x3085e013, KEY_INFO },
> { 0x3085a05f, KEY_CYCLEWINDOWS }, /* Window */
> { 0x0085305f, KEY_CYCLEWINDOWS },
> { 0x3085c036, KEY_EPG }, /* Guide */
> ...
>
>There, the only part of the scancode that doesn't change is 0x85.
>It seems that they're using 8 bits for address (0xaa) and 24
>bits for command (0xAADDdd).
>
>So, it seems that they're actually sending address/command as:
>
> [command >> 24><Address][(command >>8) & 0xff][command & 0xff]
>
>With seems too awkward.
>
>IMHO, it would make more sense to store those data as:
> <address><command>
>
>So, KEY_MEDIA, for example, would be:
>+ { 0x8530f009, KEY_MEDIA }, /* TiVo Button */
>
>However, I'm not sure how other 32 bits NEC scancodes might be.
And it's completely irrelevant. There's little to no value in trying to
determine what's a "command" and what's an "address". We have to
standardize on one in-memory representation of the 32 bits, and then we
should just treat it as that...as a u32 lookup key for the
scancode<->keycode table which lacks any further "meaning".
>So, I think we should keep the internal representation as-is,
>for now, while we're not sure about how other vendors handle
>it, as, for now, there's just one IR table with 32 bits nec.
It doesn't matter how other vendors handle (i.e. interpret) the
different bits, that's what we want to get away from, it's the whole
point of this discussion.
>That's said, I don't mind much how this is internally stored at
>the Kernel level, as we can always change it, but we should provide
>backward compatibility for userspace, when userspace sends
>to Kernel a 16 bit or a 24 bit keytable.
Yes, which is part of what I've proposed.
It's not a coicidence that I've proposed a new ioctl and the NEC32
standardization at the same time. A new ioctl is the perfect time and
place to get this right once and for all.
So with the new ioctl, the "protocol" is made explicit, and the
definition of a scancode follows from the "protocol" (protocol as in
RC_TYPE_*).
For RC_TYPE_NEC, that scancode would be a 32 bit int (exact byte and bit
order to be determined, but not terribly important for this discussion).
That removes *all* ambiguity and makes RC_TYPE_NEC behave *exactly* like
all other protocols. At the same time it removes pointless policy from
the kernel and causes a reduction in code (mostly thinking of the
pointless NEC16/24/32 parsing code that gets duplicated across drivers).
>So, I think we should first focus on how to properly get/set the
>bitsize at the API in a way that this is backward compatible.
No, adding bitsizes adds complexity and additional layers of abstraction
for no good reason. And it is not needed for *any other protocol*. Why?
Because the protocol already defines the bitsize. And so would NEC if we
would just use all 32 bits throughout.
With that change, the bitsize is implicit in *each protocol* and the new
ioctl I proposed makes the protocol explicit (while providing at least a
best-effort guess for NEC scancodes when the legacy ioctl is used).
(and no, please, don't suggest we add RC_TYPE_NEC, RC_TYPE_NEC24,
RC_TYPE_NEC32...)
>Ok, the API actually sends the bit size of each keycode, as the
>size length is variable, but I'm not sure if this is reliable enough,
>as I think that the current userspace just sets it to 32 bits, even
>when passing a 16 bits key.
That won't work as you've noted yourself.
>In any case, it doesn't make any sense to require userspace to
>convert a 16 bits normal NEC table (or a 24 bits "extended" NEC
>table) into a 32 bits data+checksum bitpack on userspace.
I disagree. Strongly.
It makes perfect sense. Policy doesn't belong in the kernel and all
that. Asking userspace to provide a full description of the 32 bits that
are transmitted removes all ambiguity and makes any "bitsize"
irrelevant. For all the other protocols we support, the "bitsize" is
known on a per-protocol basis. The same can be true for RC_TYPE_NEC.
And userspace can still write nice user-friendly 16 bit keymaps if it
likes and convert to kernel scancode notation on the fly. That's
something userspace anyways has to do today.
Consider the 32 bit scancode as simply being the communication protocol
between userspace <-> kernel if you like. There's no reason to
complicate that with bitsizes and/or multiple protocols when a single 32
bit scancode describes exactly everything that the kernel and userspace
needs to know.
--
David Härdeman
next prev parent reply other threads:[~2014-03-31 16:48 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
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 [this message]
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=20140331164756.GA9610@hardeman.nu \
--to=david@hardeman.nu \
--cc=james.hogan@imgtec.com \
--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 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).