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