Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: rc: nec decoder should not send both repeat and keycode

When receiving an nec repeat, rc_repeat() is called and then rc_keydown()
with the last decoded scancode. That last call is redundant.

Fixes: 265a2988d202 ("media: rc-core: consistent use of rc_repeat()")

Cc: <stable@vger.kernel.org> # v4.14
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Sean Young and committed by
Mauro Carvalho Chehab
829bbf26 2265425f

+17 -12
+17 -12
drivers/media/rc/ir-nec-decoder.c
··· 87 87 data->state = STATE_BIT_PULSE; 88 88 return 0; 89 89 } else if (eq_margin(ev.duration, NEC_REPEAT_SPACE, NEC_UNIT / 2)) { 90 - rc_repeat(dev); 91 - IR_dprintk(1, "Repeat last key\n"); 92 90 data->state = STATE_TRAILER_PULSE; 93 91 return 0; 94 92 } ··· 149 151 if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2)) 150 152 break; 151 153 152 - address = bitrev8((data->bits >> 24) & 0xff); 153 - not_address = bitrev8((data->bits >> 16) & 0xff); 154 - command = bitrev8((data->bits >> 8) & 0xff); 155 - not_command = bitrev8((data->bits >> 0) & 0xff); 154 + if (data->count == NEC_NBITS) { 155 + address = bitrev8((data->bits >> 24) & 0xff); 156 + not_address = bitrev8((data->bits >> 16) & 0xff); 157 + command = bitrev8((data->bits >> 8) & 0xff); 158 + not_command = bitrev8((data->bits >> 0) & 0xff); 156 159 157 - scancode = ir_nec_bytes_to_scancode(address, not_address, 158 - command, not_command, 159 - &rc_proto); 160 + scancode = ir_nec_bytes_to_scancode(address, 161 + not_address, 162 + command, 163 + not_command, 164 + &rc_proto); 160 165 161 - if (data->is_nec_x) 162 - data->necx_repeat = true; 166 + if (data->is_nec_x) 167 + data->necx_repeat = true; 163 168 164 - rc_keydown(dev, rc_proto, scancode, 0); 169 + rc_keydown(dev, rc_proto, scancode, 0); 170 + } else { 171 + rc_repeat(dev); 172 + } 173 + 165 174 data->state = STATE_INACTIVE; 166 175 return 0; 167 176 }