summaryrefslogtreecommitdiff
path: root/include/media
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2017-07-30 16:23:11 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-08-20 16:49:18 +0300
commite8ffda78623677f7935b30901a173405b4861bda (patch)
treebb728024aa0607541546d1ed35bcd8a27af3c46c /include/media
parenta2df9d064336ba62b810639114c06b2b0bfe3e0b (diff)
downloadlinux-e8ffda78623677f7935b30901a173405b4861bda.tar.xz
media: rc: ir-nec-decoder: move scancode composing code into a shared function
The NEC scancode composing and protocol type detection in ir_nec_decode() is generic enough to be a shared function. Let's create an inline function in rc-core.h, so that other remote control drivers can reuse this function to save some code. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/rc-core.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 16bd89caa22d..b6c18840d125 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -340,4 +340,35 @@ static inline u32 ir_extract_bits(u32 data, u32 mask)
return value;
}
+/* Get NEC scancode and protocol type from address and command bytes */
+static inline u32 ir_nec_bytes_to_scancode(u8 address, u8 not_address,
+ u8 command, u8 not_command,
+ enum rc_type *protocol)
+{
+ u32 scancode;
+
+ if ((command ^ not_command) != 0xff) {
+ /* NEC transport, but modified protocol, used by at
+ * least Apple and TiVo remotes
+ */
+ scancode = not_address << 24 |
+ address << 16 |
+ not_command << 8 |
+ command;
+ *protocol = RC_TYPE_NEC32;
+ } else if ((address ^ not_address) != 0xff) {
+ /* Extended NEC */
+ scancode = address << 16 |
+ not_address << 8 |
+ command;
+ *protocol = RC_TYPE_NECX;
+ } else {
+ /* Normal NEC */
+ scancode = address << 8 | command;
+ *protocol = RC_TYPE_NEC;
+ }
+
+ return scancode;
+}
+
#endif /* _RC_CORE */