diff options
author | Jarod Wilson <jarod@redhat.com> | 2010-10-22 15:49:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-22 18:05:38 -0400 |
commit | 36e9d2605d430d94c60e4b449c737da1798de3b5 (patch) | |
tree | 6c2f9c249edfe57fa95eccb138b1e27c9715bc4d /drivers/media | |
parent | 4a8839187a613cbc34cf21f4f58ae5d5176ec26d (diff) |
[media] mceusb: hook debug print spew directly into parser routine
Provides more complete debug spew, parses individual commands and raw IR
data one chunk at a time.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/IR/mceusb.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c index 0a2981ac7429..9dce684fd231 100644 --- a/drivers/media/IR/mceusb.c +++ b/drivers/media/IR/mceusb.c | |||
@@ -421,26 +421,28 @@ static int mceusb_cmdsize(u8 cmd, u8 subcmd) | |||
421 | } | 421 | } |
422 | 422 | ||
423 | static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, | 423 | static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, |
424 | int len, bool out) | 424 | int offset, int len, bool out) |
425 | { | 425 | { |
426 | char codes[USB_BUFLEN * 3 + 1]; | 426 | char codes[USB_BUFLEN * 3 + 1]; |
427 | char inout[9]; | 427 | char inout[9]; |
428 | int i; | ||
429 | u8 cmd, subcmd, data1, data2; | 428 | u8 cmd, subcmd, data1, data2; |
430 | struct device *dev = ir->dev; | 429 | struct device *dev = ir->dev; |
431 | int idx = 0; | 430 | int i, start, skip = 0; |
431 | |||
432 | if (!debug) | ||
433 | return; | ||
432 | 434 | ||
433 | /* skip meaningless 0xb1 0x60 header bytes on orig receiver */ | 435 | /* skip meaningless 0xb1 0x60 header bytes on orig receiver */ |
434 | if (ir->flags.microsoft_gen1 && !out) | 436 | if (ir->flags.microsoft_gen1 && !out) |
435 | idx = 2; | 437 | skip = 2; |
436 | 438 | ||
437 | if (len <= idx) | 439 | if (len <= skip) |
438 | return; | 440 | return; |
439 | 441 | ||
440 | for (i = 0; i < len && i < USB_BUFLEN; i++) | 442 | for (i = 0; i < len && i < USB_BUFLEN; i++) |
441 | snprintf(codes + i * 3, 4, "%02x ", buf[i] & 0xff); | 443 | snprintf(codes + i * 3, 4, "%02x ", buf[i + offset] & 0xff); |
442 | 444 | ||
443 | dev_info(dev, "%sx data: %s (length=%d)\n", | 445 | dev_info(dev, "%sx data: %s(length=%d)\n", |
444 | (out ? "t" : "r"), codes, len); | 446 | (out ? "t" : "r"), codes, len); |
445 | 447 | ||
446 | if (out) | 448 | if (out) |
@@ -448,10 +450,11 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, | |||
448 | else | 450 | else |
449 | strcpy(inout, "Got\0"); | 451 | strcpy(inout, "Got\0"); |
450 | 452 | ||
451 | cmd = buf[idx] & 0xff; | 453 | start = offset + skip; |
452 | subcmd = buf[idx + 1] & 0xff; | 454 | cmd = buf[start] & 0xff; |
453 | data1 = buf[idx + 2] & 0xff; | 455 | subcmd = buf[start + 1] & 0xff; |
454 | data2 = buf[idx + 3] & 0xff; | 456 | data1 = buf[start + 2] & 0xff; |
457 | data2 = buf[start + 3] & 0xff; | ||
455 | 458 | ||
456 | switch (cmd) { | 459 | switch (cmd) { |
457 | case MCE_COMMAND_NULL: | 460 | case MCE_COMMAND_NULL: |
@@ -470,7 +473,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, | |||
470 | else | 473 | else |
471 | dev_info(dev, "hw/sw rev 0x%02x 0x%02x " | 474 | dev_info(dev, "hw/sw rev 0x%02x 0x%02x " |
472 | "0x%02x 0x%02x\n", data1, data2, | 475 | "0x%02x 0x%02x\n", data1, data2, |
473 | buf[idx + 4], buf[idx + 5]); | 476 | buf[start + 4], buf[start + 5]); |
474 | break; | 477 | break; |
475 | case MCE_CMD_DEVICE_RESET: | 478 | case MCE_CMD_DEVICE_RESET: |
476 | dev_info(dev, "Device reset requested\n"); | 479 | dev_info(dev, "Device reset requested\n"); |
@@ -543,6 +546,12 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, | |||
543 | default: | 546 | default: |
544 | break; | 547 | break; |
545 | } | 548 | } |
549 | |||
550 | if (cmd == MCE_IRDATA_TRAILER) | ||
551 | dev_info(dev, "End of raw IR data\n"); | ||
552 | else if ((cmd != MCE_COMMAND_HEADER) && | ||
553 | ((cmd & MCE_COMMAND_MASK) == MCE_COMMAND_IRDATA)) | ||
554 | dev_info(dev, "Raw IR data, %d pulse/space samples\n", ir->rem); | ||
546 | } | 555 | } |
547 | 556 | ||
548 | static void mce_async_callback(struct urb *urb, struct pt_regs *regs) | 557 | static void mce_async_callback(struct urb *urb, struct pt_regs *regs) |
@@ -560,9 +569,7 @@ static void mce_async_callback(struct urb *urb, struct pt_regs *regs) | |||
560 | dev_dbg(ir->dev, "callback called (status=%d len=%d)\n", | 569 | dev_dbg(ir->dev, "callback called (status=%d len=%d)\n", |
561 | urb->status, len); | 570 | urb->status, len); |
562 | 571 | ||
563 | if (debug) | 572 | mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true); |
564 | mceusb_dev_printdata(ir, urb->transfer_buffer, | ||
565 | len, true); | ||
566 | } | 573 | } |
567 | 574 | ||
568 | } | 575 | } |
@@ -788,6 +795,8 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) | |||
788 | switch (ir->parser_state) { | 795 | switch (ir->parser_state) { |
789 | case SUBCMD: | 796 | case SUBCMD: |
790 | ir->rem = mceusb_cmdsize(ir->cmd, ir->buf_in[i]); | 797 | ir->rem = mceusb_cmdsize(ir->cmd, ir->buf_in[i]); |
798 | mceusb_dev_printdata(ir, ir->buf_in, i - 1, | ||
799 | ir->rem + 2, false); | ||
791 | ir->parser_state = CMD_DATA; | 800 | ir->parser_state = CMD_DATA; |
792 | break; | 801 | break; |
793 | case PARSE_IRDATA: | 802 | case PARSE_IRDATA: |
@@ -830,8 +839,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) | |||
830 | continue; | 839 | continue; |
831 | } | 840 | } |
832 | ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); | 841 | ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); |
833 | dev_dbg(ir->dev, "Processing RX data: len = %d\n", | 842 | mceusb_dev_printdata(ir, ir->buf_in, i, ir->rem + 1, false); |
834 | ir->rem); | ||
835 | if (ir->rem) { | 843 | if (ir->rem) { |
836 | ir->parser_state = PARSE_IRDATA; | 844 | ir->parser_state = PARSE_IRDATA; |
837 | break; | 845 | break; |
@@ -868,9 +876,6 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) | |||
868 | 876 | ||
869 | buf_len = urb->actual_length; | 877 | buf_len = urb->actual_length; |
870 | 878 | ||
871 | if (debug) | ||
872 | mceusb_dev_printdata(ir, urb->transfer_buffer, buf_len, false); | ||
873 | |||
874 | if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { | 879 | if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { |
875 | ir->send_flags = SEND_FLAG_COMPLETE; | 880 | ir->send_flags = SEND_FLAG_COMPLETE; |
876 | dev_dbg(ir->dev, "setup answer received %d bytes\n", | 881 | dev_dbg(ir->dev, "setup answer received %d bytes\n", |