summaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2017-10-09 16:32:41 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-14 10:35:17 -0500
commit6b514c4a50cbbb9bd2080a95ed83d834b11f1e40 (patch)
tree89edbe599b7b3b922c115a2079e19aab3351c223 /drivers/media/rc
parent49a4b36ada336270b564cabbbcb727cadebd024d (diff)
downloadlinux-6b514c4a50cbbb9bd2080a95ed83d834b11f1e40.tar.bz2
media: rc: document and fix rc_validate_scancode()
For some IR protocols, some scancode values not valid, i.e. they're part of a different protocol variant. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/rc-main.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index ce8837b1facd..e944d28b96d2 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -776,21 +776,35 @@ void rc_keydown_notimeout(struct rc_dev *dev, enum rc_proto protocol,
EXPORT_SYMBOL_GPL(rc_keydown_notimeout);
/**
- * rc_validate_scancode() - checks that a scancode is valid for a protocol
+ * rc_validate_scancode() - checks that a scancode is valid for a protocol.
+ * For nec, it should do the opposite of ir_nec_bytes_to_scancode()
* @proto: protocol
* @scancode: scancode
*/
bool rc_validate_scancode(enum rc_proto proto, u32 scancode)
{
switch (proto) {
+ /*
+ * NECX has a 16-bit address; if the lower 8 bits match the upper
+ * 8 bits inverted, then the address would match regular nec.
+ */
case RC_PROTO_NECX:
if ((((scancode >> 16) ^ ~(scancode >> 8)) & 0xff) == 0)
return false;
break;
+ /*
+ * NEC32 has a 16 bit address and 16 bit command. If the lower 8 bits
+ * of the command match the upper 8 bits inverted, then it would
+ * be either NEC or NECX.
+ */
case RC_PROTO_NEC32:
- if ((((scancode >> 24) ^ ~(scancode >> 16)) & 0xff) == 0)
+ if ((((scancode >> 8) ^ ~scancode) & 0xff) == 0)
return false;
break;
+ /*
+ * If the customer code (top 32-bit) is 0x800f, it is MCE else it
+ * is regular mode-6a 32 bit
+ */
case RC_PROTO_RC6_MCE:
if ((scancode & 0xffff0000) != 0x800f0000)
return false;