Commit 1cd50f25 authored by Jarod Wilson's avatar Jarod Wilson Committed by Mauro Carvalho Chehab

[media] mceusb: fix up reporting of trailing space

We were storing a bunch of spaces at the end of each signal, rather than
a single long space. The in-kernel decoders were actually okay with
this, but lirc isn't. As suggested by David Härdeman, switch to storing
samples using ir_raw_event_store_with_filter, which auto-merges the
consecutive space samples for us. This also allows us to bypass having
to store rawir samples in our device struct, further simplifying the
buffer parsing state machine. Both in-kernel decoders and lirc are happy
again with this change.

Also included in this patch is proper parsing of 0x9f 0x01 commands, the
removal of some magic number usage and some printk spew fixups.
Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b7582815
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */ #define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */
/* Sub-commands, which follow MCE_COMMAND_HEADER or MCE_HW_CMD_HEADER */ /* Sub-commands, which follow MCE_COMMAND_HEADER or MCE_HW_CMD_HEADER */
#define MCE_CMD_SIG_END 0x01 /* End of signal */
#define MCE_CMD_PING 0x03 /* Ping device */ #define MCE_CMD_PING 0x03 /* Ping device */
#define MCE_CMD_UNKNOWN 0x04 /* Unknown */ #define MCE_CMD_UNKNOWN 0x04 /* Unknown */
#define MCE_CMD_UNKNOWN2 0x05 /* Unknown */ #define MCE_CMD_UNKNOWN2 0x05 /* Unknown */
...@@ -422,6 +423,7 @@ static int mceusb_cmdsize(u8 cmd, u8 subcmd) ...@@ -422,6 +423,7 @@ static int mceusb_cmdsize(u8 cmd, u8 subcmd)
case MCE_CMD_G_RXSENSOR: case MCE_CMD_G_RXSENSOR:
datasize = 2; datasize = 2;
break; break;
case MCE_CMD_SIG_END:
case MCE_CMD_S_TXMASK: case MCE_CMD_S_TXMASK:
case MCE_CMD_S_RXSENSOR: case MCE_CMD_S_RXSENSOR:
datasize = 1; datasize = 1;
...@@ -502,6 +504,9 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, ...@@ -502,6 +504,9 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
break; break;
case MCE_COMMAND_HEADER: case MCE_COMMAND_HEADER:
switch (subcmd) { switch (subcmd) {
case MCE_CMD_SIG_END:
dev_info(dev, "End of signal\n");
break;
case MCE_CMD_PING: case MCE_CMD_PING:
dev_info(dev, "Ping\n"); dev_info(dev, "Ping\n");
break; break;
...@@ -539,7 +544,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, ...@@ -539,7 +544,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
if (len == 2) if (len == 2)
dev_info(dev, "Get receive sensor\n"); dev_info(dev, "Get receive sensor\n");
else else
dev_info(dev, "Received pulse count is %d\n", dev_info(dev, "Remaining pulse count is %d\n",
((data1 << 8) | data2)); ((data1 << 8) | data2));
break; break;
case MCE_RSP_CMD_INVALID: case MCE_RSP_CMD_INVALID:
...@@ -763,7 +768,7 @@ static int mceusb_set_tx_carrier(void *priv, u32 carrier) ...@@ -763,7 +768,7 @@ static int mceusb_set_tx_carrier(void *priv, u32 carrier)
if (carrier == 0) { if (carrier == 0) {
ir->carrier = carrier; ir->carrier = carrier;
cmdbuf[2] = 0x01; cmdbuf[2] = MCE_CMD_SIG_END;
cmdbuf[3] = MCE_IRDATA_TRAILER; cmdbuf[3] = MCE_IRDATA_TRAILER;
dev_dbg(ir->dev, "%s: disabling carrier " dev_dbg(ir->dev, "%s: disabling carrier "
"modulation\n", __func__); "modulation\n", __func__);
...@@ -816,25 +821,11 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) ...@@ -816,25 +821,11 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK)
* MCE_TIME_UNIT * 1000; * MCE_TIME_UNIT * 1000;
if ((ir->buf_in[i] & MCE_PULSE_MASK) == 0x7f) {
if (ir->rawir.pulse == rawir.pulse) {
ir->rawir.duration += rawir.duration;
} else {
ir->rawir.duration = rawir.duration;
ir->rawir.pulse = rawir.pulse;
}
if (ir->rem)
break;
}
rawir.duration += ir->rawir.duration;
ir->rawir.duration = 0;
ir->rawir.pulse = rawir.pulse;
dev_dbg(ir->dev, "Storing %s with duration %d\n", dev_dbg(ir->dev, "Storing %s with duration %d\n",
rawir.pulse ? "pulse" : "space", rawir.pulse ? "pulse" : "space",
rawir.duration); rawir.duration);
ir_raw_event_store(ir->idev, &rawir); ir_raw_event_store_with_filter(ir->idev, &rawir);
break; break;
case CMD_DATA: case CMD_DATA:
ir->rem--; ir->rem--;
...@@ -851,18 +842,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) ...@@ -851,18 +842,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
} }
ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK);
mceusb_dev_printdata(ir, ir->buf_in, i, ir->rem + 1, false); mceusb_dev_printdata(ir, ir->buf_in, i, ir->rem + 1, false);
if (ir->rem) { if (ir->rem)
ir->parser_state = PARSE_IRDATA; ir->parser_state = PARSE_IRDATA;
break; break;
} }
/*
* a package with len=0 (e. g. 0x80) means end of
* data. We could use it to do the call to
* ir_raw_event_handle(). For now, we don't need to
* use it.
*/
break;
}
if (ir->parser_state != CMD_HEADER && !ir->rem) if (ir->parser_state != CMD_HEADER && !ir->rem)
ir->parser_state = CMD_HEADER; ir->parser_state = CMD_HEADER;
...@@ -1092,7 +1075,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ...@@ -1092,7 +1075,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
bool tx_mask_inverted; bool tx_mask_inverted;
bool is_polaris; bool is_polaris;
dev_dbg(&intf->dev, ": %s called\n", __func__); dev_dbg(&intf->dev, "%s called\n", __func__);
idesc = intf->cur_altsetting; idesc = intf->cur_altsetting;
...@@ -1122,7 +1105,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ...@@ -1122,7 +1105,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
ep_in = ep; ep_in = ep;
ep_in->bmAttributes = USB_ENDPOINT_XFER_INT; ep_in->bmAttributes = USB_ENDPOINT_XFER_INT;
ep_in->bInterval = 1; ep_in->bInterval = 1;
dev_dbg(&intf->dev, ": acceptable inbound endpoint " dev_dbg(&intf->dev, "acceptable inbound endpoint "
"found\n"); "found\n");
} }
...@@ -1137,12 +1120,12 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ...@@ -1137,12 +1120,12 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
ep_out = ep; ep_out = ep;
ep_out->bmAttributes = USB_ENDPOINT_XFER_INT; ep_out->bmAttributes = USB_ENDPOINT_XFER_INT;
ep_out->bInterval = 1; ep_out->bInterval = 1;
dev_dbg(&intf->dev, ": acceptable outbound endpoint " dev_dbg(&intf->dev, "acceptable outbound endpoint "
"found\n"); "found\n");
} }
} }
if (ep_in == NULL) { if (ep_in == NULL) {
dev_dbg(&intf->dev, ": inbound and/or endpoint not found\n"); dev_dbg(&intf->dev, "inbound and/or endpoint not found\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1169,8 +1152,6 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ...@@ -1169,8 +1152,6 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
ir->flags.no_tx = mceusb_model[model].no_tx; ir->flags.no_tx = mceusb_model[model].no_tx;
ir->model = model; ir->model = model;
init_ir_raw_event(&ir->rawir);
/* Saving usb interface data for use by the transmitter routine */ /* Saving usb interface data for use by the transmitter routine */
ir->usb_ep_in = ep_in; ir->usb_ep_in = ep_in;
ir->usb_ep_out = ep_out; ir->usb_ep_out = ep_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment