From: Sean Young Date: Fri, 5 Jan 2018 13:38:43 +0000 (-0500) Subject: media: rc: do not remove first bit if leader pulse is present X-Git-Tag: v4.16-rc1~57^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80008ddbed83b40d5b745a9bae721b736dd7314c;p=thirdparty%2Flinux.git media: rc: do not remove first bit if leader pulse is present The rc5 protocol does not have a leading pulse or space, but we encode the first bit using a single leading pulse. For other protocols, the leading pulse or space does not represent any bit. So, don't remove the first bit if a leading pulse is present. Cc: Antti Seppälä Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index 2a279b3b9c0af..2c3df02e05ffd 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -452,11 +452,11 @@ static int ir_mce_kbd_encode(enum rc_proto protocol, u32 scancode, if (protocol == RC_PROTO_MCIR2_KBD) { raw = scancode | ((u64)MCIR2_KEYBOARD_HEADER << MCIR2_KEYBOARD_NBITS); - len = MCIR2_KEYBOARD_NBITS + MCIR2_HEADER_NBITS + 1; + len = MCIR2_KEYBOARD_NBITS + MCIR2_HEADER_NBITS; } else { raw = scancode | ((u64)MCIR2_MOUSE_HEADER << MCIR2_MOUSE_NBITS); - len = MCIR2_MOUSE_NBITS + MCIR2_HEADER_NBITS + 1; + len = MCIR2_MOUSE_NBITS + MCIR2_HEADER_NBITS; } ret = ir_raw_gen_manchester(&e, max, &ir_mce_kbd_timings, len, raw); diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c index a1d6c955ffc8e..11a28f8772da7 100644 --- a/drivers/media/rc/ir-rc5-decoder.c +++ b/drivers/media/rc/ir-rc5-decoder.c @@ -225,9 +225,9 @@ static int ir_rc5_encode(enum rc_proto protocol, u32 scancode, /* encode data */ data = !commandx << 12 | system << 6 | command; - /* Modulate the data */ + /* First bit is encoded by leader_pulse */ ret = ir_raw_gen_manchester(&e, max, &ir_rc5_timings, - RC5_NBITS, data); + RC5_NBITS - 1, data); if (ret < 0) return ret; } else if (protocol == RC_PROTO_RC5X_20) { @@ -240,10 +240,11 @@ static int ir_rc5_encode(enum rc_proto protocol, u32 scancode, /* encode data */ data = commandx << 18 | system << 12 | command << 6 | xdata; - /* Modulate the data */ + /* First bit is encoded by leader_pulse */ pre_space_data = data >> (RC5X_NBITS - CHECK_RC5X_NBITS); ret = ir_raw_gen_manchester(&e, max, &ir_rc5x_timings[0], - CHECK_RC5X_NBITS, pre_space_data); + CHECK_RC5X_NBITS - 1, + pre_space_data); if (ret < 0) return ret; ret = ir_raw_gen_manchester(&e, max - (e - events), @@ -254,8 +255,10 @@ static int ir_rc5_encode(enum rc_proto protocol, u32 scancode, return ret; } else if (protocol == RC_PROTO_RC5_SZ) { /* RC5-SZ scancode is raw enough for Manchester as it is */ + /* First bit is encoded by leader_pulse */ ret = ir_raw_gen_manchester(&e, max, &ir_rc5_sz_timings, - RC5_SZ_NBITS, scancode & 0x2fff); + RC5_SZ_NBITS - 1, + scancode & 0x2fff); if (ret < 0) return ret; } else { diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c index 422dec08738cb..55bb19bbd4e9a 100644 --- a/drivers/media/rc/ir-rc6-decoder.c +++ b/drivers/media/rc/ir-rc6-decoder.c @@ -327,7 +327,7 @@ static int ir_rc6_encode(enum rc_proto protocol, u32 scancode, /* Modulate the header (Start Bit & Mode-0) */ ret = ir_raw_gen_manchester(&e, max - (e - events), &ir_rc6_timings[0], - RC6_HEADER_NBITS + 1, (1 << 3)); + RC6_HEADER_NBITS, (1 << 3)); if (ret < 0) return ret; @@ -365,7 +365,7 @@ static int ir_rc6_encode(enum rc_proto protocol, u32 scancode, /* Modulate the header (Start Bit & Header-version 6 */ ret = ir_raw_gen_manchester(&e, max - (e - events), &ir_rc6_timings[0], - RC6_HEADER_NBITS + 1, (1 << 3 | 6)); + RC6_HEADER_NBITS, (1 << 3 | 6)); if (ret < 0) return ret; diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 8500b57923c09..18504870b9f05 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -256,7 +256,6 @@ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max, init_ir_raw_event_duration(++(*ev), 0, timings->leader_space); } - i >>= 1; } else { /* continue existing signal */ --(*ev);