[media] mceusb: fix keybouce issue after parser simplification

Something I failed to notice while testing the mceusb RLE buffer
decoding simplification patches was that we were getting an extra event
from the previously pressed key.

As was pointed out to me on irc by Maxim, this is actually due to using
ir_raw_event_store_with_filter without having set up a timeout value.
The hardware has a timeout value we're now reading and storing, which
properly enables the transition to idle in the raw event storage
process, and makes IR decode behave correctly w/o keybounce.

Also remove no-longer-used ir_raw_event struct from mceusb_dev struct
and add as-yet-unused enable flags for carrier reports and learning
mode, which I'll hopefully start wiring up sooner than later. While
looking into that, found evidence that 0x9f 0x15 responses are only
non-zero when the short-range learning sensor is used, so correct the
debug spew message, and then suppress it when using the standard
long-range sensor.

Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by Jarod Wilson and committed by Mauro Carvalho Chehab 2ee95db2 2d6e588c

+46 -10
+46 -10
drivers/media/IR/mceusb.c
··· 49 #define USB_BUFLEN 32 /* USB reception buffer length */ 50 #define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ 51 #define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ 52 53 /* MCE constants */ 54 #define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ ··· 93 #define MCE_CMD_G_TXMASK 0x13 /* Set TX port bitmask */ 94 #define MCE_CMD_S_RXSENSOR 0x14 /* Set RX sensor (std/learning) */ 95 #define MCE_CMD_G_RXSENSOR 0x15 /* Get RX sensor (std/learning) */ 96 #define MCE_CMD_TX_PORTS 0x16 /* Get number of TX ports */ 97 #define MCE_CMD_G_WAKESRC 0x17 /* Get wake source */ 98 #define MCE_CMD_UNKNOWN7 0x18 /* Unknown */ ··· 316 struct mceusb_dev { 317 /* ir-core bits */ 318 struct ir_dev_props *props; 319 - struct ir_raw_event rawir; 320 321 /* core device bits */ 322 struct device *dev; ··· 334 /* buffers and dma */ 335 unsigned char *buf_in; 336 unsigned int len_in; 337 338 enum { 339 CMD_HEADER = 0, ··· 343 CMD_DATA, 344 PARSE_IRDATA, 345 } parser_state; 346 - u8 cmd, rem; /* Remaining IR data bytes in packet */ 347 348 - dma_addr_t dma_in; 349 - dma_addr_t dma_out; 350 351 struct { 352 u32 connected:1; ··· 425 case MCE_CMD_UNKNOWN: 426 case MCE_CMD_S_CARRIER: 427 case MCE_CMD_S_TIMEOUT: 428 - case MCE_CMD_G_RXSENSOR: 429 datasize = 2; 430 break; 431 case MCE_CMD_SIG_END: ··· 546 inout, data1 == 0x02 ? "short" : "long"); 547 break; 548 case MCE_CMD_G_RXSENSOR: 549 - if (len == 2) 550 dev_info(dev, "Get receive sensor\n"); 551 - else 552 - dev_info(dev, "Remaining pulse count is %d\n", 553 ((data1 << 8) | data2)); 554 break; 555 case MCE_RSP_CMD_INVALID: ··· 804 return carrier; 805 } 806 807 static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) 808 { 809 DEFINE_IR_RAW_EVENT(rawir); ··· 851 ir->rem = mceusb_cmdsize(ir->cmd, ir->buf_in[i]); 852 mceusb_dev_printdata(ir, ir->buf_in, i - 1, 853 ir->rem + 2, false); 854 ir->parser_state = CMD_DATA; 855 break; 856 case PARSE_IRDATA: 857 ir->rem--; 858 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); 859 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) 860 - * MCE_TIME_UNIT * 1000; 861 862 dev_dbg(ir->dev, "Storing %s with duration %d\n", 863 rawir.pulse ? "pulse" : "space", ··· 880 continue; 881 } 882 ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); 883 - mceusb_dev_printdata(ir, ir->buf_in, i, ir->rem + 1, false); 884 if (ir->rem) 885 ir->parser_state = PARSE_IRDATA; 886 break;
··· 49 #define USB_BUFLEN 32 /* USB reception buffer length */ 50 #define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ 51 #define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ 52 + #define MS_TO_NS(msec) ((msec) * 1000) 53 54 /* MCE constants */ 55 #define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ ··· 92 #define MCE_CMD_G_TXMASK 0x13 /* Set TX port bitmask */ 93 #define MCE_CMD_S_RXSENSOR 0x14 /* Set RX sensor (std/learning) */ 94 #define MCE_CMD_G_RXSENSOR 0x15 /* Get RX sensor (std/learning) */ 95 + #define MCE_RSP_PULSE_COUNT 0x15 /* RX pulse count (only if learning) */ 96 #define MCE_CMD_TX_PORTS 0x16 /* Get number of TX ports */ 97 #define MCE_CMD_G_WAKESRC 0x17 /* Get wake source */ 98 #define MCE_CMD_UNKNOWN7 0x18 /* Unknown */ ··· 314 struct mceusb_dev { 315 /* ir-core bits */ 316 struct ir_dev_props *props; 317 + 318 + /* optional features we can enable */ 319 + bool carrier_report_enabled; 320 + bool learning_enabled; 321 322 /* core device bits */ 323 struct device *dev; ··· 329 /* buffers and dma */ 330 unsigned char *buf_in; 331 unsigned int len_in; 332 + dma_addr_t dma_in; 333 + dma_addr_t dma_out; 334 335 enum { 336 CMD_HEADER = 0, ··· 336 CMD_DATA, 337 PARSE_IRDATA, 338 } parser_state; 339 340 + u8 cmd, rem; /* Remaining IR data bytes in packet */ 341 342 struct { 343 u32 connected:1; ··· 420 case MCE_CMD_UNKNOWN: 421 case MCE_CMD_S_CARRIER: 422 case MCE_CMD_S_TIMEOUT: 423 + case MCE_RSP_PULSE_COUNT: 424 datasize = 2; 425 break; 426 case MCE_CMD_SIG_END: ··· 541 inout, data1 == 0x02 ? "short" : "long"); 542 break; 543 case MCE_CMD_G_RXSENSOR: 544 + /* aka MCE_RSP_PULSE_COUNT */ 545 + if (out) 546 dev_info(dev, "Get receive sensor\n"); 547 + else if (ir->learning_enabled) 548 + dev_info(dev, "RX pulse count: %d\n", 549 ((data1 << 8) | data2)); 550 break; 551 case MCE_RSP_CMD_INVALID: ··· 798 return carrier; 799 } 800 801 + /* 802 + * We don't do anything but print debug spew for many of the command bits 803 + * we receive from the hardware, but some of them are useful information 804 + * we want to store so that we can use them. 805 + */ 806 + static void mceusb_handle_command(struct mceusb_dev *ir, int index) 807 + { 808 + u8 hi = ir->buf_in[index + 1] & 0xff; 809 + u8 lo = ir->buf_in[index + 2] & 0xff; 810 + 811 + switch (ir->buf_in[index]) { 812 + /* 2-byte return value commands */ 813 + case MCE_CMD_S_TIMEOUT: 814 + ir->props->timeout = MS_TO_NS((hi << 8 | lo) / 2); 815 + break; 816 + 817 + /* 1-byte return value commands */ 818 + case MCE_CMD_S_TXMASK: 819 + ir->tx_mask = hi; 820 + break; 821 + case MCE_CMD_S_RXSENSOR: 822 + ir->learning_enabled = (hi == 0x02); 823 + break; 824 + default: 825 + break; 826 + } 827 + } 828 + 829 static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) 830 { 831 DEFINE_IR_RAW_EVENT(rawir); ··· 817 ir->rem = mceusb_cmdsize(ir->cmd, ir->buf_in[i]); 818 mceusb_dev_printdata(ir, ir->buf_in, i - 1, 819 ir->rem + 2, false); 820 + mceusb_handle_command(ir, i); 821 ir->parser_state = CMD_DATA; 822 break; 823 case PARSE_IRDATA: 824 ir->rem--; 825 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); 826 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) 827 + * MS_TO_NS(MCE_TIME_UNIT); 828 829 dev_dbg(ir->dev, "Storing %s with duration %d\n", 830 rawir.pulse ? "pulse" : "space", ··· 845 continue; 846 } 847 ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); 848 + mceusb_dev_printdata(ir, ir->buf_in, 849 + i, ir->rem + 1, false); 850 if (ir->rem) 851 ir->parser_state = PARSE_IRDATA; 852 break;