From 6a554bb5653f9844c2ee179d91a757b28ec36a99 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 13 Jan 2022 21:53:51 +0100 Subject: [PATCH] media: mtk-cir: remove superfluous ir_raw_event_reset() This IR receiver has two limitations: 1) Any IR pulse or space longer than 12ms will be truncated to 12ms 2) Any pulses/spaces after the first 68 are lost ir_raw_event_reset() won't help here. If the IR cannot be decoded, any decoder should reset itself, and if it does not, this is a bug in the decoder. Cc: Sean Wang Cc: Matthias Brugger Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/mtk-cir.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/media/rc/mtk-cir.c b/drivers/media/rc/mtk-cir.c index 746d43fdc17a..1255e3afb032 100644 --- a/drivers/media/rc/mtk-cir.c +++ b/drivers/media/rc/mtk-cir.c @@ -209,19 +209,18 @@ static irqreturn_t mtk_ir_irq(int irqno, void *dev_id) struct ir_raw_event rawir = {}; /* - * Reset decoder state machine explicitly is required - * because 1) the longest duration for space MTK IR hardware - * could record is not safely long. e.g 12ms if rx resolution - * is 46us by default. There is still the risk to satisfying - * every decoder to reset themselves through long enough - * trailing spaces and 2) the IRQ handler guarantees that - * start of IR message is always contained in and starting - * from register mtk_chkdata_reg(ir, i). + * Each pulse and space is encoded as a single byte, each byte + * alternating between pulse and space. If a pulse or space is longer + * than can be encoded in a single byte, it is encoded as the maximum + * value 0xff. + * + * If a space is longer than ok_count (about 23ms), the value is + * encoded as zero, and all following bytes are zero. Any IR that + * follows will be presented in the next interrupt. + * + * If there are more than 68 (=MTK_CHKDATA_SZ * 4) pulses and spaces, + * then the only the first 68 will be presented; the rest is lost. */ - ir_raw_event_reset(ir->rc); - - /* First message must be pulse */ - rawir.pulse = false; /* Handle all pulse and space IR controller captures */ for (i = 0 ; i < MTK_CHKDATA_SZ ; i++) { -- 2.25.1