Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: mceusb: fix (eliminate) TX IR signal length limit

Fix and eliminate mceusb's IR length limit for IR signals transmitted to
the MCE IR blaster ports.

An IR signal TX exceeding 306 pulse/space samples presently causes -EINVAL
return error. There's no such limitation nor error with the MCE device
hardware. And valid IR signals exist with more than 400 pulse/space for the
control of certain appliances (eg Panasonic ACXA75C00600 air conditioner).

The scope of this patch is limited to the mceusb driver. There are still
IR signal TX length and time constraints that related modules of rc core
(eg LIRC) impose, further up the driver stack.

Changes for mceusb_tx_ir():

Converts and sends LIRC IR pulse/space sequence to MCE device IR
pulse/space format.

Break long length LIRC sequence into multiple (unlimited number of) parts
for sending to the MCE device.
Reduce kernel stack IR buffer size: 128 (was 384)
Increase MCE IR data packet size: 31 (was 5)
Zero time LIRC pulse/space no longer copied to MCE IR data.
Eliminate overwriting the source/input LIRC IR data in txbuf[].
Eliminate -EINVAL return; return number of IR samples sent (>0) or
MCE write error code (<0).

New mce_write() and mce_write_callback():

Implements synchronous blocking I/O, with timeout, for writing/sending
data to the MCE device.

An unlimited multipart IR signal sent to the MCE device faster than real
time requires flow control absent with the original mce_request_packet()
and mce_async_callback() asynchronous I/O implementation. Also absent is
TX error feedback.

mce_write() combines and replaces mce_request_packet() and
mce_async_callback() with conversion to synchronous I/O.
mce_write() returns bytes sent (>0) or MCE device write error (<0).
Debug hex dump TX data before processing.

Rename mce_async_out() -> mce_command_out():

The original name is misleading with underlying synchronous I/O
implementation. Function renamed to mce_command_out().

Changes in mceusb_handle_command():

Add support for MCE device error case MCE_RSP_TX_TIMEOUT
"IR TX timeout (TX buffer underrun)"

Changes in mceusb_dev_printdata():

Changes support test and debug of multipart TX IR.

Add buffer boundary information (offset and buffer size) to TX hex dump.
Correct TX trace bug "Raw IR data, 0 pulse/space samples"
Add trace for MCE_RSP_TX_TIMEOUT "IR TX timeout (TX buffer underrun)"

Other changes:

The driver's write to USB device architecture change (async to sync I/O)
is significant so we bump DRIVER_VERSION to "1.95" (from "1.94").

Tests:

$ cat -n irdata1 | head -3
1 carrier 36000
2 pulse 6350
3 space 6350
$ cat -n irdata1 | tail -3
76 pulse 6350
77 space 6350
78 pulse 6350
$ ir-ctl -s irdata1

[1549021.073612] mceusb 1-1.3:1.0: requesting 36000 HZ carrier
[1549021.073635] mceusb 1-1.3:1.0: tx data[0]: 9f 06 01 45 (len=4 sz=4)
[1549021.073649] mceusb 1-1.3:1.0: Request carrier of 35714 Hz (period 28us)
[1549021.073848] mceusb 1-1.3:1.0: tx done status = 4 (wait = 100, expire = 100 (1000ms), urb->actual_length = 4, urb->status = 0)
[1549021.074689] mceusb 1-1.3:1.0: rx data[0]: 9f 06 01 45 (len=4 sz=4)
[1549021.074701] mceusb 1-1.3:1.0: Got carrier of 35714 Hz (period 28us)
[1549021.102023] mceusb 1-1.3:1.0: tx data[0]: 9f 08 03 (len=3 sz=3)
[1549021.102036] mceusb 1-1.3:1.0: Request transmit blaster mask of 0x03
[1549021.102219] mceusb 1-1.3:1.0: tx done status = 3 (wait = 100, expire = 100 (1000ms), urb->actual_length = 3, urb->status = 0)
[1549021.131979] mceusb 1-1.3:1.0: tx data[0]: 9e ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f 9e ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f 91 ff (len=81 sz=81)
[1549021.131992] mceusb 1-1.3:1.0: Raw IR data, 30 pulse/space samples
[1549021.133592] mceusb 1-1.3:1.0: tx done status = 81 (wait = 100, expire = 100 (1000ms), urb->actual_length = 81, urb->status = 0)

Hex dumps limited to 64 bytes.
0xff is MCE maximum time pulse, 0x7f is MCE maximum time space.

$ cat -n irdata2 | head -3
1 carrier 36000
2 pulse 50
3 space 50
$ cat -n irdata2 | tail -3
254 pulse 50
255 space 50
256 pulse 50
$ ir-ctl -s irdata2

[1549306.586998] mceusb 1-1.3:1.0: tx data[0]: 9f 08 03 (len=3 sz=3)
[1549306.587015] mceusb 1-1.3:1.0: Request transmit blaster mask of 0x03
[1549306.587252] mceusb 1-1.3:1.0: tx done status = 3 (wait = 100, expire = 100 (1000ms), urb->actual_length = 3, urb->status = 0)
[1549306.613275] mceusb 1-1.3:1.0: tx data[0]: 9e 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 9e 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 9e 81 (len=128 sz=128)
[1549306.613291] mceusb 1-1.3:1.0: Raw IR data, 30 pulse/space samples
[1549306.614837] mceusb 1-1.3:1.0: tx done status = 128 (wait = 100, expire = 100 (1000ms), urb->actual_length = 128, urb->status = 0)
[1549306.614861] mceusb 1-1.3:1.0: tx data[0]: 9e 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 9e 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 01 81 9e 01 (len=128 sz=128)
[1549306.614869] mceusb 1-1.3:1.0: Raw IR data, 30 pulse/space samples
[1549306.620199] mceusb 1-1.3:1.0: tx done status = 128 (wait = 100, expire = 100 (1000ms), urb->actual_length = 128, urb->status = 0)
[1549306.620212] mceusb 1-1.3:1.0: tx data[0]: 89 81 01 81 01 81 01 81 01 81 80 (len=11 sz=11)
[1549306.620221] mceusb 1-1.3:1.0: Raw IR data, 9 pulse/space samples
[1549306.633294] mceusb 1-1.3:1.0: tx done status = 11 (wait = 98, expire = 100 (1000ms), urb->actual_length = 11, urb->status = 0)

Hex dumps limited to 64 bytes.
0x81 is MCE minimum time pulse, 0x01 is MCE minimum time space.
TX IR part 3 sz=11 shows 20msec I/O blocking delay
(100expire - 98wait = 2jiffies)

Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

A Sun and committed by
Mauro Carvalho Chehab
9fc3ce31 8f5f33f7

+194 -136
+194 -136
drivers/media/rc/mceusb.c
··· 31 31 #include <linux/pm_wakeup.h> 32 32 #include <media/rc-core.h> 33 33 34 - #define DRIVER_VERSION "1.94" 34 + #define DRIVER_VERSION "1.95" 35 35 #define DRIVER_AUTHOR "Jarod Wilson <jarod@redhat.com>" 36 36 #define DRIVER_DESC "Windows Media Center Ed. eHome Infrared Transceiver " \ 37 37 "device driver" 38 38 #define DRIVER_NAME "mceusb" 39 39 40 + #define USB_TX_TIMEOUT 1000 /* in milliseconds */ 40 41 #define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ 41 42 #define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ 42 43 43 44 /* MCE constants */ 44 - #define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ 45 + #define MCE_IRBUF_SIZE 128 /* TX IR buffer length */ 45 46 #define MCE_TIME_UNIT 50 /* Approx 50us resolution */ 46 - #define MCE_CODE_LENGTH 5 /* Normal length of packet (with header) */ 47 - #define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */ 48 - #define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */ 47 + #define MCE_PACKET_SIZE 31 /* Max length of packet (with header) */ 48 + #define MCE_IRDATA_HEADER (0x80 + MCE_PACKET_SIZE - 1) 49 + /* Actual format is 0x80 + num_bytes */ 49 50 #define MCE_IRDATA_TRAILER 0x80 /* End of IR data */ 50 51 #define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */ 51 52 #define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */ ··· 610 609 if (len <= skip) 611 610 return; 612 611 613 - dev_dbg(dev, "%cx data: %*ph (length=%d)", 614 - (out ? 't' : 'r'), 615 - min(len, buf_len - offset), buf + offset, len); 612 + dev_dbg(dev, "%cx data[%d]: %*ph (len=%d sz=%d)", 613 + (out ? 't' : 'r'), offset, 614 + min(len, buf_len - offset), buf + offset, len, buf_len); 616 615 617 616 inout = out ? "Request" : "Got"; 618 617 ··· 734 733 case MCE_RSP_CMD_ILLEGAL: 735 734 dev_dbg(dev, "Illegal PORT_IR command"); 736 735 break; 736 + case MCE_RSP_TX_TIMEOUT: 737 + dev_dbg(dev, "IR TX timeout (TX buffer underrun)"); 738 + break; 737 739 default: 738 740 dev_dbg(dev, "Unknown command 0x%02x 0x%02x", 739 741 cmd, subcmd); ··· 751 747 dev_dbg(dev, "End of raw IR data"); 752 748 else if ((cmd != MCE_CMD_PORT_IR) && 753 749 ((cmd & MCE_PORT_MASK) == MCE_COMMAND_IRDATA)) 754 - dev_dbg(dev, "Raw IR data, %d pulse/space samples", ir->rem); 750 + dev_dbg(dev, "Raw IR data, %d pulse/space samples", 751 + cmd & MCE_PACKET_LENGTH_MASK); 755 752 #endif 756 753 } 757 754 758 755 /* 759 756 * Schedule work that can't be done in interrupt handlers 760 - * (mceusb_dev_recv() and mce_async_callback()) nor tasklets. 757 + * (mceusb_dev_recv() and mce_write_callback()) nor tasklets. 761 758 * Invokes mceusb_deferred_kevent() for recovering from 762 759 * error events specified by the kevent bit field. 763 760 */ ··· 778 773 dev_dbg(ir->dev, "kevent %d scheduled", kevent); 779 774 } 780 775 781 - static void mce_async_callback(struct urb *urb) 776 + static void mce_write_callback(struct urb *urb) 782 777 { 783 - struct mceusb_dev *ir; 784 - int len; 785 - 786 778 if (!urb) 787 779 return; 788 780 789 - ir = urb->context; 781 + complete(urb->context); 782 + } 783 + 784 + /* 785 + * Write (TX/send) data to MCE device USB endpoint out. 786 + * Used for IR blaster TX and MCE device commands. 787 + * 788 + * Return: The number of bytes written (> 0) or errno (< 0). 789 + */ 790 + static int mce_write(struct mceusb_dev *ir, u8 *data, int size) 791 + { 792 + int ret; 793 + struct urb *urb; 794 + struct device *dev = ir->dev; 795 + unsigned char *buf_out; 796 + struct completion tx_done; 797 + unsigned long expire; 798 + unsigned long ret_wait; 799 + 800 + mceusb_dev_printdata(ir, data, size, 0, size, true); 801 + 802 + urb = usb_alloc_urb(0, GFP_KERNEL); 803 + if (unlikely(!urb)) { 804 + dev_err(dev, "Error: mce write couldn't allocate urb"); 805 + return -ENOMEM; 806 + } 807 + 808 + buf_out = kmalloc(size, GFP_KERNEL); 809 + if (!buf_out) { 810 + usb_free_urb(urb); 811 + return -ENOMEM; 812 + } 813 + 814 + init_completion(&tx_done); 815 + 816 + /* outbound data */ 817 + if (usb_endpoint_xfer_int(ir->usb_ep_out)) 818 + usb_fill_int_urb(urb, ir->usbdev, ir->pipe_out, 819 + buf_out, size, mce_write_callback, &tx_done, 820 + ir->usb_ep_out->bInterval); 821 + else 822 + usb_fill_bulk_urb(urb, ir->usbdev, ir->pipe_out, 823 + buf_out, size, mce_write_callback, &tx_done); 824 + memcpy(buf_out, data, size); 825 + 826 + ret = usb_submit_urb(urb, GFP_KERNEL); 827 + if (ret) { 828 + dev_err(dev, "Error: mce write submit urb error = %d", ret); 829 + kfree(buf_out); 830 + usb_free_urb(urb); 831 + return ret; 832 + } 833 + 834 + expire = msecs_to_jiffies(USB_TX_TIMEOUT); 835 + ret_wait = wait_for_completion_timeout(&tx_done, expire); 836 + if (!ret_wait) { 837 + dev_err(dev, "Error: mce write timed out (expire = %lu (%dms))", 838 + expire, USB_TX_TIMEOUT); 839 + usb_kill_urb(urb); 840 + ret = (urb->status == -ENOENT ? -ETIMEDOUT : urb->status); 841 + } else { 842 + ret = urb->status; 843 + } 844 + if (ret >= 0) 845 + ret = urb->actual_length; /* bytes written */ 790 846 791 847 switch (urb->status) { 792 848 /* success */ 793 849 case 0: 794 - len = urb->actual_length; 795 - 796 - mceusb_dev_printdata(ir, urb->transfer_buffer, len, 797 - 0, len, true); 798 850 break; 799 851 800 852 case -ECONNRESET: ··· 861 799 break; 862 800 863 801 case -EPIPE: 864 - dev_err(ir->dev, "Error: request urb status = %d (TX HALT)", 802 + dev_err(ir->dev, "Error: mce write urb status = %d (TX HALT)", 865 803 urb->status); 866 804 mceusb_defer_kevent(ir, EVENT_TX_HALT); 867 805 break; 868 806 869 807 default: 870 - dev_err(ir->dev, "Error: request urb status = %d", urb->status); 808 + dev_err(ir->dev, "Error: mce write urb status = %d", 809 + urb->status); 871 810 break; 872 811 } 873 812 874 - /* the transfer buffer and urb were allocated in mce_request_packet */ 875 - kfree(urb->transfer_buffer); 813 + dev_dbg(dev, "tx done status = %d (wait = %lu, expire = %lu (%dms), urb->actual_length = %d, urb->status = %d)", 814 + ret, ret_wait, expire, USB_TX_TIMEOUT, 815 + urb->actual_length, urb->status); 816 + 817 + kfree(buf_out); 876 818 usb_free_urb(urb); 819 + 820 + return ret; 877 821 } 878 822 879 - /* request outgoing (send) usb packet - used to initialize remote */ 880 - static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data, 881 - int size) 882 - { 883 - int res; 884 - struct urb *async_urb; 885 - struct device *dev = ir->dev; 886 - unsigned char *async_buf; 887 - 888 - async_urb = usb_alloc_urb(0, GFP_KERNEL); 889 - if (unlikely(!async_urb)) { 890 - dev_err(dev, "Error, couldn't allocate urb!"); 891 - return; 892 - } 893 - 894 - async_buf = kmalloc(size, GFP_KERNEL); 895 - if (!async_buf) { 896 - usb_free_urb(async_urb); 897 - return; 898 - } 899 - 900 - /* outbound data */ 901 - if (usb_endpoint_xfer_int(ir->usb_ep_out)) 902 - usb_fill_int_urb(async_urb, ir->usbdev, ir->pipe_out, 903 - async_buf, size, mce_async_callback, ir, 904 - ir->usb_ep_out->bInterval); 905 - else 906 - usb_fill_bulk_urb(async_urb, ir->usbdev, ir->pipe_out, 907 - async_buf, size, mce_async_callback, ir); 908 - 909 - memcpy(async_buf, data, size); 910 - 911 - dev_dbg(dev, "send request called (size=%#x)", size); 912 - 913 - res = usb_submit_urb(async_urb, GFP_ATOMIC); 914 - if (res) { 915 - dev_err(dev, "send request FAILED! (res=%d)", res); 916 - kfree(async_buf); 917 - usb_free_urb(async_urb); 918 - return; 919 - } 920 - dev_dbg(dev, "send request complete (res=%d)", res); 921 - } 922 - 923 - static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) 823 + static void mce_command_out(struct mceusb_dev *ir, u8 *data, int size) 924 824 { 925 825 int rsize = sizeof(DEVICE_RESUME); 926 826 927 827 if (ir->need_reset) { 928 828 ir->need_reset = false; 929 - mce_request_packet(ir, DEVICE_RESUME, rsize); 829 + mce_write(ir, DEVICE_RESUME, rsize); 930 830 msleep(10); 931 831 } 932 832 933 - mce_request_packet(ir, data, size); 833 + mce_write(ir, data, size); 934 834 msleep(10); 935 835 } 936 836 937 - /* Send data out the IR blaster port(s) */ 837 + /* 838 + * Transmit IR out the MCE device IR blaster port(s). 839 + * 840 + * Convert IR pulse/space sequence from LIRC to MCE format. 841 + * Break up a long IR sequence into multiple parts (MCE IR data packets). 842 + * 843 + * u32 txbuf[] consists of IR pulse, space, ..., and pulse times in usec. 844 + * Pulses and spaces are implicit by their position. 845 + * The first IR sample, txbuf[0], is always a pulse. 846 + * 847 + * u8 irbuf[] consists of multiple IR data packets for the MCE device. 848 + * A packet is 1 u8 MCE_IRDATA_HEADER and up to 30 u8 IR samples. 849 + * An IR sample is 1-bit pulse/space flag with 7-bit time 850 + * in MCE time units (50usec). 851 + * 852 + * Return: The number of IR samples sent (> 0) or errno (< 0). 853 + */ 938 854 static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) 939 855 { 940 856 struct mceusb_dev *ir = dev->priv; 941 - int i, length, ret = 0; 942 - int cmdcount = 0; 943 - unsigned char cmdbuf[MCE_CMDBUF_SIZE]; 944 - 945 - /* MCE tx init header */ 946 - cmdbuf[cmdcount++] = MCE_CMD_PORT_IR; 947 - cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS; 948 - cmdbuf[cmdcount++] = ir->tx_mask; 857 + u8 cmdbuf[3] = { MCE_CMD_PORT_IR, MCE_CMD_SETIRTXPORTS, 0x00 }; 858 + u8 irbuf[MCE_IRBUF_SIZE]; 859 + int ircount = 0; 860 + unsigned int irsample; 861 + int i, length, ret; 949 862 950 863 /* Send the set TX ports command */ 951 - mce_async_out(ir, cmdbuf, cmdcount); 952 - cmdcount = 0; 864 + cmdbuf[2] = ir->tx_mask; 865 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 953 866 954 - /* Generate mce packet data */ 955 - for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) { 956 - txbuf[i] = txbuf[i] / MCE_TIME_UNIT; 867 + /* Generate mce IR data packet */ 868 + for (i = 0; i < count; i++) { 869 + irsample = txbuf[i] / MCE_TIME_UNIT; 957 870 958 - do { /* loop to support long pulses/spaces > 127*50us=6.35ms */ 959 - 960 - /* Insert mce packet header every 4th entry */ 961 - if ((cmdcount < MCE_CMDBUF_SIZE) && 962 - (cmdcount % MCE_CODE_LENGTH) == 0) 963 - cmdbuf[cmdcount++] = MCE_IRDATA_HEADER; 964 - 965 - /* Insert mce packet data */ 966 - if (cmdcount < MCE_CMDBUF_SIZE) 967 - cmdbuf[cmdcount++] = 968 - (txbuf[i] < MCE_PULSE_BIT ? 969 - txbuf[i] : MCE_MAX_PULSE_LENGTH) | 970 - (i & 1 ? 0x00 : MCE_PULSE_BIT); 971 - else { 972 - ret = -EINVAL; 973 - goto out; 871 + /* loop to support long pulses/spaces > 6350us (127*50us) */ 872 + while (irsample > 0) { 873 + /* Insert IR header every 30th entry */ 874 + if (ircount % MCE_PACKET_SIZE == 0) { 875 + /* Room for IR header and one IR sample? */ 876 + if (ircount >= MCE_IRBUF_SIZE - 1) { 877 + /* Send near full buffer */ 878 + ret = mce_write(ir, irbuf, ircount); 879 + if (ret < 0) 880 + return ret; 881 + ircount = 0; 882 + } 883 + irbuf[ircount++] = MCE_IRDATA_HEADER; 974 884 } 975 885 976 - } while ((txbuf[i] > MCE_MAX_PULSE_LENGTH) && 977 - (txbuf[i] -= MCE_MAX_PULSE_LENGTH)); 978 - } 886 + /* Insert IR sample */ 887 + if (irsample <= MCE_MAX_PULSE_LENGTH) { 888 + irbuf[ircount] = irsample; 889 + irsample = 0; 890 + } else { 891 + irbuf[ircount] = MCE_MAX_PULSE_LENGTH; 892 + irsample -= MCE_MAX_PULSE_LENGTH; 893 + } 894 + /* 895 + * Even i = IR pulse 896 + * Odd i = IR space 897 + */ 898 + irbuf[ircount] |= (i & 1 ? 0 : MCE_PULSE_BIT); 899 + ircount++; 979 900 980 - /* Check if we have room for the empty packet at the end */ 981 - if (cmdcount >= MCE_CMDBUF_SIZE) { 982 - ret = -EINVAL; 983 - goto out; 984 - } 901 + /* IR buffer full? */ 902 + if (ircount >= MCE_IRBUF_SIZE) { 903 + /* Fix packet length in last header */ 904 + length = ircount % MCE_PACKET_SIZE; 905 + if (length > 0) 906 + irbuf[ircount - length] -= 907 + MCE_PACKET_SIZE - length; 908 + /* Send full buffer */ 909 + ret = mce_write(ir, irbuf, ircount); 910 + if (ret < 0) 911 + return ret; 912 + ircount = 0; 913 + } 914 + } 915 + } /* after for loop, 0 <= ircount < MCE_IRBUF_SIZE */ 985 916 986 917 /* Fix packet length in last header */ 987 - length = cmdcount % MCE_CODE_LENGTH; 988 - cmdbuf[cmdcount - length] -= MCE_CODE_LENGTH - length; 918 + length = ircount % MCE_PACKET_SIZE; 919 + if (length > 0) 920 + irbuf[ircount - length] -= MCE_PACKET_SIZE - length; 989 921 990 - /* All mce commands end with an empty packet (0x80) */ 991 - cmdbuf[cmdcount++] = MCE_IRDATA_TRAILER; 922 + /* Append IR trailer (0x80) to final partial (or empty) IR buffer */ 923 + irbuf[ircount++] = MCE_IRDATA_TRAILER; 992 924 993 - /* Transmit the command to the mce device */ 994 - mce_async_out(ir, cmdbuf, cmdcount); 925 + /* Send final buffer */ 926 + ret = mce_write(ir, irbuf, ircount); 927 + if (ret < 0) 928 + return ret; 995 929 996 - out: 997 - return ret ? ret : count; 930 + return count; 998 931 } 999 932 1000 933 /* Sets active IR outputs -- mce devices typically have two */ ··· 1029 972 cmdbuf[2] = MCE_CMD_SIG_END; 1030 973 cmdbuf[3] = MCE_IRDATA_TRAILER; 1031 974 dev_dbg(ir->dev, "disabling carrier modulation"); 1032 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 975 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1033 976 return 0; 1034 977 } 1035 978 ··· 1043 986 carrier); 1044 987 1045 988 /* Transmit new carrier to mce device */ 1046 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 989 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1047 990 return 0; 1048 991 } 1049 992 } ··· 1066 1009 cmdbuf[2] = units >> 8; 1067 1010 cmdbuf[3] = units; 1068 1011 1069 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 1012 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1070 1013 1071 1014 /* get receiver timeout value */ 1072 - mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); 1015 + mce_command_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); 1073 1016 1074 1017 return 0; 1075 1018 } ··· 1094 1037 ir->wideband_rx_enabled = false; 1095 1038 cmdbuf[2] = 1; /* port 1 is long range receiver */ 1096 1039 } 1097 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 1040 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1098 1041 /* response from device sets ir->learning_active */ 1099 1042 1100 1043 return 0; ··· 1117 1060 ir->carrier_report_enabled = true; 1118 1061 if (!ir->learning_active) { 1119 1062 cmdbuf[2] = 2; /* port 2 is short range receiver */ 1120 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 1063 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1121 1064 } 1122 1065 } else { 1123 1066 ir->carrier_report_enabled = false; ··· 1128 1071 */ 1129 1072 if (ir->learning_active && !ir->wideband_rx_enabled) { 1130 1073 cmdbuf[2] = 1; /* port 1 is long range receiver */ 1131 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 1074 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1132 1075 } 1133 1076 } 1134 1077 ··· 1207 1150 } 1208 1151 break; 1209 1152 case MCE_RSP_CMD_ILLEGAL: 1153 + case MCE_RSP_TX_TIMEOUT: 1210 1154 ir->need_reset = true; 1211 1155 break; 1212 1156 default: ··· 1346 1288 { 1347 1289 /* If we get no reply or an illegal command reply, its ver 1, says MS */ 1348 1290 ir->emver = 1; 1349 - mce_async_out(ir, GET_EMVER, sizeof(GET_EMVER)); 1291 + mce_command_out(ir, GET_EMVER, sizeof(GET_EMVER)); 1350 1292 } 1351 1293 1352 1294 static void mceusb_gen1_init(struct mceusb_dev *ir) ··· 1392 1334 dev_dbg(dev, "set handshake - retC = %d", ret); 1393 1335 1394 1336 /* device resume */ 1395 - mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME)); 1337 + mce_command_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME)); 1396 1338 1397 1339 /* get hw/sw revision? */ 1398 - mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); 1340 + mce_command_out(ir, GET_REVISION, sizeof(GET_REVISION)); 1399 1341 1400 1342 kfree(data); 1401 1343 } ··· 1403 1345 static void mceusb_gen2_init(struct mceusb_dev *ir) 1404 1346 { 1405 1347 /* device resume */ 1406 - mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME)); 1348 + mce_command_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME)); 1407 1349 1408 1350 /* get wake version (protocol, key, address) */ 1409 - mce_async_out(ir, GET_WAKEVERSION, sizeof(GET_WAKEVERSION)); 1351 + mce_command_out(ir, GET_WAKEVERSION, sizeof(GET_WAKEVERSION)); 1410 1352 1411 1353 /* unknown what this one actually returns... */ 1412 - mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2)); 1354 + mce_command_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2)); 1413 1355 } 1414 1356 1415 1357 static void mceusb_get_parameters(struct mceusb_dev *ir) ··· 1423 1365 ir->num_rxports = 2; 1424 1366 1425 1367 /* get number of tx and rx ports */ 1426 - mce_async_out(ir, GET_NUM_PORTS, sizeof(GET_NUM_PORTS)); 1368 + mce_command_out(ir, GET_NUM_PORTS, sizeof(GET_NUM_PORTS)); 1427 1369 1428 1370 /* get the carrier and frequency */ 1429 - mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); 1371 + mce_command_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); 1430 1372 1431 1373 if (ir->num_txports && !ir->flags.no_tx) 1432 1374 /* get the transmitter bitmask */ 1433 - mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); 1375 + mce_command_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); 1434 1376 1435 1377 /* get receiver timeout value */ 1436 - mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); 1378 + mce_command_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); 1437 1379 1438 1380 /* get receiver sensor setting */ 1439 - mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); 1381 + mce_command_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); 1440 1382 1441 1383 for (i = 0; i < ir->num_txports; i++) { 1442 1384 cmdbuf[2] = i; 1443 - mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 1385 + mce_command_out(ir, cmdbuf, sizeof(cmdbuf)); 1444 1386 } 1445 1387 } 1446 1388 ··· 1449 1391 if (ir->emver < 2) 1450 1392 return; 1451 1393 1452 - mce_async_out(ir, FLASH_LED, sizeof(FLASH_LED)); 1394 + mce_command_out(ir, FLASH_LED, sizeof(FLASH_LED)); 1453 1395 } 1454 1396 1455 1397 /*