Lines Matching +full:twisted +full:- +full:pair

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2010-2011, Jarod Wilson <jarod@redhat.com>
11 * support for the 1st-gen device added primarily by Patrick Calhoun,
13 * support for what appears to be 3rd-gen hardware added by Jarod.
14 * Initial port from lirc driver to ir-core drivery by Jarod, based
22 * Windows-Media-Center-RC-IR-Collection-Green-Button-Specification-03-08-2011-V2.pdf
32 #include <media/rc-core.h>
48 #define MCE_IRDATA_HEADER (0x80 + MCE_PACKET_SIZE - 1)
58 * The interface between the host and the IR hardware is command-response
76 #define MCE_CMD_PORT_IR 0x9f /* IR-related cmd/rsp */
77 #define MCE_CMD_PORT_SYS 0xff /* System (non-IR) device cmd/rsp */
79 /* Commands that set device state (2-4 bytes in length) */
104 /* Responses to commands (non-error cases) */
195 * 2nd IR receiver (short-range, wideband) for learning mode:
204 const char *rc_map; /* Allow specify a per-board map */
205 const char *name; /* per-board name */
283 /* Original Microsoft MCE IR Transceiver (often HP-branded) */
286 /* Philips Infrared Transceiver - Sahara branded */
288 /* Philips Infrared Transceiver - HP branded */
293 /* Philips Infrared Transceiver - Omaura */
295 /* Philips Infrared Transceiver - Spinel plus */
315 /* bundled with Hauppauge PVR-150 */
320 /* SMK/I-O Data GV-MC7/RCKIT Receiver */
356 /* Itron ione Libra Q-11 */
410 /* Twisted Melon Inc. - Manta Mini Receiver */
412 /* Twisted Melon Inc. - Manta Pico Receiver */
414 /* Twisted Melon Inc. - Manta Transceiver */
416 /* Hauppauge WINTV-HVR-HVR 930C-HD - based on cx231xx */
425 /* Hauppauge WinTV-HVR-935C - based on cx231xx */
428 /* Hauppauge WinTV-HVR-955Q - based on cx231xx */
431 /* Hauppauge WinTV-HVR-975 - based on cx231xx */
453 /* ir-core bits */
458 bool wideband_rx_enabled; /* aka learning mode, short-range rx */
524 /* MCE Device Command Strings, generally a port and command pair */
601 struct device *dev = ir->dev; in mceusb_dev_printdata()
609 min(len, buf_len - offset), buf + offset, len, buf_len); in mceusb_dev_printdata()
618 if (ir->flags.microsoft_gen1 && !out && !offset) { in mceusb_dev_printdata()
739 dev_dbg(dev, "%s %s-range receive sensor in use", in mceusb_dev_printdata()
782 set_bit(kevent, &ir->kevent_flags); in mceusb_defer_kevent()
784 if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) { in mceusb_defer_kevent()
785 dev_dbg(ir->dev, "kevent %d dropped pending USB Reset Device", in mceusb_defer_kevent()
790 if (!schedule_work(&ir->kevent)) in mceusb_defer_kevent()
791 dev_dbg(ir->dev, "kevent %d already scheduled", kevent); in mceusb_defer_kevent()
793 dev_dbg(ir->dev, "kevent %d scheduled", kevent); in mceusb_defer_kevent()
801 complete(urb->context); in mce_write_callback()
814 struct device *dev = ir->dev; in mce_write()
825 return -ENOMEM; in mce_write()
831 return -ENOMEM; in mce_write()
837 if (usb_endpoint_xfer_int(ir->usb_ep_out)) in mce_write()
838 usb_fill_int_urb(urb, ir->usbdev, ir->pipe_out, in mce_write()
840 ir->usb_ep_out->bInterval); in mce_write()
842 usb_fill_bulk_urb(urb, ir->usbdev, ir->pipe_out, in mce_write()
860 ret = (urb->status == -ENOENT ? -ETIMEDOUT : urb->status); in mce_write()
862 ret = urb->status; in mce_write()
865 ret = urb->actual_length; /* bytes written */ in mce_write()
867 switch (urb->status) { in mce_write()
872 case -ECONNRESET: in mce_write()
873 case -ENOENT: in mce_write()
874 case -EILSEQ: in mce_write()
875 case -ESHUTDOWN: in mce_write()
878 case -EPIPE: in mce_write()
879 dev_err(ir->dev, "Error: mce write urb status = %d (TX HALT)", in mce_write()
880 urb->status); in mce_write()
885 dev_err(ir->dev, "Error: mce write urb status = %d", in mce_write()
886 urb->status); in mce_write()
890 …dev_dbg(dev, "tx done status = %d (wait = %lu, expire = %lu (%dms), urb->actual_length = %d, urb->… in mce_write()
892 urb->actual_length, urb->status); in mce_write()
904 if (ir->need_reset) { in mce_command_out()
905 ir->need_reset = false; in mce_command_out()
926 * An IR sample is 1-bit pulse/space flag with 7-bit time
933 struct mceusb_dev *ir = dev->priv; in mceusb_tx_ir()
941 cmdbuf[2] = ir->tx_mask; in mceusb_tx_ir()
953 if (ircount >= MCE_IRBUF_SIZE - 1) { in mceusb_tx_ir()
969 irsample -= MCE_MAX_PULSE_LENGTH; in mceusb_tx_ir()
983 irbuf[ircount - length] -= in mceusb_tx_ir()
984 MCE_PACKET_SIZE - length; in mceusb_tx_ir()
997 irbuf[ircount - length] -= MCE_PACKET_SIZE - length; in mceusb_tx_ir()
1010 /* Sets active IR outputs -- mce devices typically have two */
1013 struct mceusb_dev *ir = dev->priv; in mceusb_set_tx_mask()
1016 int emitters = ir->num_txports ? ir->num_txports : 2; in mceusb_set_tx_mask()
1021 if (ir->flags.tx_mask_normal) in mceusb_set_tx_mask()
1022 ir->tx_mask = mask; in mceusb_set_tx_mask()
1024 ir->tx_mask = (mask != MCE_DEFAULT_TX_MASK ? in mceusb_set_tx_mask()
1033 struct mceusb_dev *ir = dev->priv; in mceusb_set_tx_carrier()
1040 if (ir->carrier != carrier) { in mceusb_set_tx_carrier()
1043 ir->carrier = carrier; in mceusb_set_tx_carrier()
1046 dev_dbg(ir->dev, "disabling carrier modulation"); in mceusb_set_tx_carrier()
1054 ir->carrier = carrier; in mceusb_set_tx_carrier()
1057 dev_dbg(ir->dev, "requesting %u HZ carrier", in mceusb_set_tx_carrier()
1066 return -EINVAL; in mceusb_set_tx_carrier()
1076 struct mceusb_dev *ir = dev->priv; in mceusb_set_timeout()
1094 * Second receiver is learning mode, wide-band, short-range receiver.
1099 struct mceusb_dev *ir = dev->priv; in mceusb_set_rx_wideband()
1103 dev_dbg(ir->dev, "select %s-range receive sensor", in mceusb_set_rx_wideband()
1106 ir->wideband_rx_enabled = true; in mceusb_set_rx_wideband()
1109 ir->wideband_rx_enabled = false; in mceusb_set_rx_wideband()
1113 /* response from device sets ir->learning_active */ in mceusb_set_rx_wideband()
1120 * Only the short-range receiver has carrier frequency measuring capability.
1125 struct mceusb_dev *ir = dev->priv; in mceusb_set_rx_carrier_report()
1129 dev_dbg(ir->dev, "%s short-range receiver carrier reporting", in mceusb_set_rx_carrier_report()
1132 ir->carrier_report_enabled = true; in mceusb_set_rx_carrier_report()
1133 if (!ir->learning_active) { in mceusb_set_rx_carrier_report()
1138 ir->carrier_report_enabled = false; in mceusb_set_rx_carrier_report()
1140 * Revert to normal (long-range) receiver only if the in mceusb_set_rx_carrier_report()
1141 * wideband (short-range) receiver wasn't explicitly in mceusb_set_rx_carrier_report()
1144 if (ir->learning_active && !ir->wideband_rx_enabled) { in mceusb_set_rx_carrier_report()
1176 /* the one and only 5-byte return value command */ in mceusb_handle_command()
1179 ir->txports_cabled |= 1 << *hi; in mceusb_handle_command()
1182 /* 1-byte return value commands */ in mceusb_handle_command()
1184 ir->emver = *hi; in mceusb_handle_command()
1189 ir->need_reset = true; in mceusb_handle_command()
1203 /* 2-byte return value commands */ in mceusb_handle_command()
1205 ir->rc->timeout = (*hi << 8 | *lo) * MCE_TIME_UNIT; in mceusb_handle_command()
1208 ir->num_txports = *hi; in mceusb_handle_command()
1209 ir->num_rxports = *lo; in mceusb_handle_command()
1217 * The long-range (non learning) receiver always reports in mceusb_handle_command()
1220 if (ir->carrier_report_enabled && ir->learning_active && in mceusb_handle_command()
1221 ir->pulse_tunit > 0) { in mceusb_handle_command()
1227 cycles_fix = ir->flags.rx2 == 2 ? ir->pulse_count : 0; in mceusb_handle_command()
1231 ir->pulse_tunit; in mceusb_handle_command()
1232 …dev_dbg(ir->dev, "RX carrier frequency %u Hz (pulse count = %u, cycles = %u, duration = %u, rx2 = … in mceusb_handle_command()
1233 rawir.carrier, ir->pulse_count, carrier_cycles, in mceusb_handle_command()
1234 ir->pulse_tunit, ir->flags.rx2); in mceusb_handle_command()
1235 ir_raw_event_store(ir->rc, &rawir); in mceusb_handle_command()
1239 /* 1-byte return value commands */ in mceusb_handle_command()
1241 ir->tx_mask = *hi; in mceusb_handle_command()
1244 ir->learning_active = ((*hi & 0x02) == 0x02); in mceusb_handle_command()
1245 if (ir->rxports_active != *hi) { in mceusb_handle_command()
1246 dev_info(ir->dev, "%s-range (0x%x) receiver active", in mceusb_handle_command()
1247 ir->learning_active ? "short" : "long", *hi); in mceusb_handle_command()
1248 ir->rxports_active = *hi; in mceusb_handle_command()
1255 ir->need_reset = true; in mceusb_handle_command()
1270 if (ir->flags.microsoft_gen1) in mceusb_process_ir_data()
1278 switch (ir->parser_state) { in mceusb_process_ir_data()
1280 ir->rem = mceusb_cmd_datasize(ir->cmd, ir->buf_in[i]); in mceusb_process_ir_data()
1281 mceusb_dev_printdata(ir, ir->buf_in, buf_len, i - 1, in mceusb_process_ir_data()
1282 ir->rem + 2, false); in mceusb_process_ir_data()
1283 if (i + ir->rem < buf_len) in mceusb_process_ir_data()
1284 mceusb_handle_command(ir, &ir->buf_in[i - 1]); in mceusb_process_ir_data()
1285 ir->parser_state = CMD_DATA; in mceusb_process_ir_data()
1288 ir->rem--; in mceusb_process_ir_data()
1289 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); in mceusb_process_ir_data()
1290 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK); in mceusb_process_ir_data()
1292 dev_dbg(ir->dev, "nonsensical irdata %02x with duration 0", in mceusb_process_ir_data()
1293 ir->buf_in[i]); in mceusb_process_ir_data()
1297 ir->pulse_tunit += rawir.duration; in mceusb_process_ir_data()
1298 ir->pulse_count++; in mceusb_process_ir_data()
1302 dev_dbg(ir->dev, "Storing %s %u us (%02x)", in mceusb_process_ir_data()
1304 rawir.duration, ir->buf_in[i]); in mceusb_process_ir_data()
1306 if (ir_raw_event_store_with_filter(ir->rc, &rawir)) in mceusb_process_ir_data()
1310 ir->rem--; in mceusb_process_ir_data()
1313 ir->cmd = ir->buf_in[i]; in mceusb_process_ir_data()
1314 if ((ir->cmd == MCE_CMD_PORT_IR) || in mceusb_process_ir_data()
1315 ((ir->cmd & MCE_PORT_MASK) != in mceusb_process_ir_data()
1321 ir->parser_state = SUBCMD; in mceusb_process_ir_data()
1329 ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); in mceusb_process_ir_data()
1330 mceusb_dev_printdata(ir, ir->buf_in, buf_len, in mceusb_process_ir_data()
1331 i, ir->rem + 1, false); in mceusb_process_ir_data()
1332 if (ir->rem) { in mceusb_process_ir_data()
1333 ir->parser_state = PARSE_IRDATA; in mceusb_process_ir_data()
1337 .duration = ir->rc->timeout in mceusb_process_ir_data()
1340 if (ir_raw_event_store_with_filter(ir->rc, in mceusb_process_ir_data()
1343 ir->pulse_tunit = 0; in mceusb_process_ir_data()
1344 ir->pulse_count = 0; in mceusb_process_ir_data()
1349 if (ir->parser_state != CMD_HEADER && !ir->rem) in mceusb_process_ir_data()
1350 ir->parser_state = CMD_HEADER; in mceusb_process_ir_data()
1357 if (ir->parser_state != PARSE_IRDATA || !ir->rem) in mceusb_process_ir_data()
1358 ir->parser_state = CMD_HEADER; in mceusb_process_ir_data()
1361 dev_dbg(ir->dev, "processed IR data"); in mceusb_process_ir_data()
1362 ir_raw_event_handle(ir->rc); in mceusb_process_ir_data()
1373 ir = urb->context; in mceusb_dev_recv()
1379 switch (urb->status) { in mceusb_dev_recv()
1382 mceusb_process_ir_data(ir, urb->actual_length); in mceusb_dev_recv()
1385 case -ECONNRESET: in mceusb_dev_recv()
1386 case -ENOENT: in mceusb_dev_recv()
1387 case -EILSEQ: in mceusb_dev_recv()
1388 case -EPROTO: in mceusb_dev_recv()
1389 case -ESHUTDOWN: in mceusb_dev_recv()
1393 case -EPIPE: in mceusb_dev_recv()
1394 dev_err(ir->dev, "Error: urb status = %d (RX HALT)", in mceusb_dev_recv()
1395 urb->status); in mceusb_dev_recv()
1400 dev_err(ir->dev, "Error: urb status = %d", urb->status); in mceusb_dev_recv()
1410 ir->emver = 1; in mceusb_get_emulator_version()
1417 struct device *dev = ir->dev; in mceusb_gen1_init()
1422 * on the receive control pipe and expect a certain value pair back in mceusb_gen1_init()
1424 ret = usb_control_msg_recv(ir->usbdev, 0, USB_REQ_SET_ADDRESS, in mceusb_gen1_init()
1428 dev_dbg(dev, "set address - ret = %d", ret); in mceusb_gen1_init()
1429 dev_dbg(dev, "set address - data[0] = %d, data[1] = %d", in mceusb_gen1_init()
1433 ret = usb_control_msg_send(ir->usbdev, 0, in mceusb_gen1_init()
1437 dev_dbg(dev, "set feature - ret = %d", ret); in mceusb_gen1_init()
1440 ret = usb_control_msg_send(ir->usbdev, 0, in mceusb_gen1_init()
1443 dev_dbg(dev, "set char length - retB = %d", ret); in mceusb_gen1_init()
1446 ret = usb_control_msg_send(ir->usbdev, 0, in mceusb_gen1_init()
1449 dev_dbg(dev, "set handshake - retC = %d", ret); in mceusb_gen1_init()
1477 ir->num_txports = 2; in mceusb_get_parameters()
1478 ir->num_rxports = 2; in mceusb_get_parameters()
1486 if (ir->num_txports && !ir->flags.no_tx) in mceusb_get_parameters()
1496 for (i = 0; i < ir->num_txports; i++) { in mceusb_get_parameters()
1504 if (ir->emver < 2) in mceusb_flash_led()
1513 * specified in ir->kevent bit field.
1514 * Function runs (via schedule_work()) in non-interrupt context, for
1515 * calls here (such as usb_clear_halt()) requiring non-interrupt context.
1523 dev_err(ir->dev, "kevent handler called (flags 0x%lx)", in mceusb_deferred_kevent()
1524 ir->kevent_flags); in mceusb_deferred_kevent()
1526 if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) { in mceusb_deferred_kevent()
1527 dev_err(ir->dev, "kevent handler canceled pending USB Reset Device"); in mceusb_deferred_kevent()
1531 if (test_bit(EVENT_RX_HALT, &ir->kevent_flags)) { in mceusb_deferred_kevent()
1532 usb_unlink_urb(ir->urb_in); in mceusb_deferred_kevent()
1533 status = usb_clear_halt(ir->usbdev, ir->pipe_in); in mceusb_deferred_kevent()
1534 dev_err(ir->dev, "rx clear halt status = %d", status); in mceusb_deferred_kevent()
1540 dev_err(ir->dev, in mceusb_deferred_kevent()
1542 usb_queue_reset_device(ir->usbintf); in mceusb_deferred_kevent()
1543 set_bit(EVENT_RST_PEND, &ir->kevent_flags); in mceusb_deferred_kevent()
1544 clear_bit(EVENT_RX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1547 clear_bit(EVENT_TX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1550 clear_bit(EVENT_RX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1551 status = usb_submit_urb(ir->urb_in, GFP_KERNEL); in mceusb_deferred_kevent()
1553 dev_err(ir->dev, "rx unhalt submit urb error = %d", in mceusb_deferred_kevent()
1558 if (test_bit(EVENT_TX_HALT, &ir->kevent_flags)) { in mceusb_deferred_kevent()
1559 status = usb_clear_halt(ir->usbdev, ir->pipe_out); in mceusb_deferred_kevent()
1560 dev_err(ir->dev, "tx clear halt status = %d", status); in mceusb_deferred_kevent()
1566 dev_err(ir->dev, in mceusb_deferred_kevent()
1568 usb_queue_reset_device(ir->usbintf); in mceusb_deferred_kevent()
1569 set_bit(EVENT_RST_PEND, &ir->kevent_flags); in mceusb_deferred_kevent()
1570 clear_bit(EVENT_TX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1573 clear_bit(EVENT_RX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1576 clear_bit(EVENT_TX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1582 struct usb_device *udev = ir->usbdev; in mceusb_init_rc_dev()
1583 struct device *dev = ir->dev; in mceusb_init_rc_dev()
1593 usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys)); in mceusb_init_rc_dev()
1595 rc->device_name = mceusb_model[ir->model].name ? : in mceusb_init_rc_dev()
1597 rc->input_phys = ir->phys; in mceusb_init_rc_dev()
1598 usb_to_input_id(ir->usbdev, &rc->input_id); in mceusb_init_rc_dev()
1599 rc->dev.parent = dev; in mceusb_init_rc_dev()
1600 rc->priv = ir; in mceusb_init_rc_dev()
1601 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in mceusb_init_rc_dev()
1602 rc->rx_resolution = MCE_TIME_UNIT; in mceusb_init_rc_dev()
1603 rc->min_timeout = MCE_TIME_UNIT; in mceusb_init_rc_dev()
1604 rc->timeout = MS_TO_US(100); in mceusb_init_rc_dev()
1605 if (!mceusb_model[ir->model].broken_irtimeout) { in mceusb_init_rc_dev()
1606 rc->s_timeout = mceusb_set_timeout; in mceusb_init_rc_dev()
1607 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; in mceusb_init_rc_dev()
1613 rc->max_timeout = rc->timeout; in mceusb_init_rc_dev()
1615 if (!ir->flags.no_tx) { in mceusb_init_rc_dev()
1616 rc->s_tx_mask = mceusb_set_tx_mask; in mceusb_init_rc_dev()
1617 rc->s_tx_carrier = mceusb_set_tx_carrier; in mceusb_init_rc_dev()
1618 rc->tx_ir = mceusb_tx_ir; in mceusb_init_rc_dev()
1620 if (ir->flags.rx2 > 0) { in mceusb_init_rc_dev()
1621 rc->s_wideband_receiver = mceusb_set_rx_wideband; in mceusb_init_rc_dev()
1622 rc->s_carrier_report = mceusb_set_rx_carrier_report; in mceusb_init_rc_dev()
1624 rc->driver_name = DRIVER_NAME; in mceusb_init_rc_dev()
1626 switch (le16_to_cpu(udev->descriptor.idVendor)) { in mceusb_init_rc_dev()
1628 rc->map_name = RC_MAP_HAUPPAUGE; in mceusb_init_rc_dev()
1631 rc->map_name = RC_MAP_PINNACLE_PCTV_HD; in mceusb_init_rc_dev()
1634 rc->map_name = RC_MAP_RC6_MCE; in mceusb_init_rc_dev()
1636 if (mceusb_model[ir->model].rc_map) in mceusb_init_rc_dev()
1637 rc->map_name = mceusb_model[ir->model].rc_map; in mceusb_init_rc_dev()
1663 enum mceusb_model_type model = id->driver_info; in mceusb_dev_probe()
1669 dev_dbg(&intf->dev, "%s called", __func__); in mceusb_dev_probe()
1671 idesc = intf->cur_altsetting; in mceusb_dev_probe()
1678 /* There are multi-function devices with non-IR interfaces */ in mceusb_dev_probe()
1679 if (idesc->desc.bInterfaceNumber != ir_intfnum) in mceusb_dev_probe()
1680 return -ENODEV; in mceusb_dev_probe()
1683 for (i = 0; i < idesc->desc.bNumEndpoints; ++i) { in mceusb_dev_probe()
1684 ep = &idesc->endpoint[i].desc; in mceusb_dev_probe()
1689 dev_dbg(&intf->dev, "acceptable bulk inbound endpoint found\n"); in mceusb_dev_probe()
1692 ep_in->bInterval = 1; in mceusb_dev_probe()
1693 dev_dbg(&intf->dev, "acceptable interrupt inbound endpoint found\n"); in mceusb_dev_probe()
1700 dev_dbg(&intf->dev, "acceptable bulk outbound endpoint found\n"); in mceusb_dev_probe()
1703 ep_out->bInterval = 1; in mceusb_dev_probe()
1704 dev_dbg(&intf->dev, "acceptable interrupt outbound endpoint found\n"); in mceusb_dev_probe()
1709 dev_dbg(&intf->dev, "required endpoints not found\n"); in mceusb_dev_probe()
1710 return -ENODEV; in mceusb_dev_probe()
1714 pipe = usb_rcvintpipe(dev, ep_in->bEndpointAddress); in mceusb_dev_probe()
1716 pipe = usb_rcvbulkpipe(dev, ep_in->bEndpointAddress); in mceusb_dev_probe()
1723 ir->pipe_in = pipe; in mceusb_dev_probe()
1724 ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_KERNEL, &ir->dma_in); in mceusb_dev_probe()
1725 if (!ir->buf_in) in mceusb_dev_probe()
1728 ir->urb_in = usb_alloc_urb(0, GFP_KERNEL); in mceusb_dev_probe()
1729 if (!ir->urb_in) in mceusb_dev_probe()
1732 ir->usbintf = intf; in mceusb_dev_probe()
1733 ir->usbdev = usb_get_dev(dev); in mceusb_dev_probe()
1734 ir->dev = &intf->dev; in mceusb_dev_probe()
1735 ir->len_in = maxp; in mceusb_dev_probe()
1736 ir->flags.microsoft_gen1 = is_microsoft_gen1; in mceusb_dev_probe()
1737 ir->flags.tx_mask_normal = tx_mask_normal; in mceusb_dev_probe()
1738 ir->flags.no_tx = mceusb_model[model].no_tx; in mceusb_dev_probe()
1739 ir->flags.rx2 = mceusb_model[model].rx2; in mceusb_dev_probe()
1740 ir->model = model; in mceusb_dev_probe()
1743 ir->usb_ep_out = ep_out; in mceusb_dev_probe()
1745 ir->pipe_out = usb_sndintpipe(ir->usbdev, in mceusb_dev_probe()
1746 ep_out->bEndpointAddress); in mceusb_dev_probe()
1748 ir->pipe_out = usb_sndbulkpipe(ir->usbdev, in mceusb_dev_probe()
1749 ep_out->bEndpointAddress); in mceusb_dev_probe()
1751 if (dev->descriptor.iManufacturer in mceusb_dev_probe()
1752 && usb_string(dev, dev->descriptor.iManufacturer, in mceusb_dev_probe()
1755 if (dev->descriptor.iProduct in mceusb_dev_probe()
1756 && usb_string(dev, dev->descriptor.iProduct, in mceusb_dev_probe()
1758 snprintf(name + strlen(name), sizeof(name) - strlen(name), in mceusb_dev_probe()
1765 INIT_WORK(&ir->kevent, mceusb_deferred_kevent); in mceusb_dev_probe()
1767 ir->rc = mceusb_init_rc_dev(ir); in mceusb_dev_probe()
1768 if (!ir->rc) in mceusb_dev_probe()
1773 usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp, in mceusb_dev_probe()
1774 mceusb_dev_recv, ir, ep_in->bInterval); in mceusb_dev_probe()
1776 usb_fill_bulk_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp, in mceusb_dev_probe()
1779 ir->urb_in->transfer_dma = ir->dma_in; in mceusb_dev_probe()
1780 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in mceusb_dev_probe()
1783 dev_dbg(&intf->dev, "Flushing receive buffers"); in mceusb_dev_probe()
1784 res = usb_submit_urb(ir->urb_in, GFP_KERNEL); in mceusb_dev_probe()
1786 dev_err(&intf->dev, "failed to flush buffers: %d", res); in mceusb_dev_probe()
1792 if (ir->flags.microsoft_gen1) in mceusb_dev_probe()
1801 if (!ir->flags.no_tx) in mceusb_dev_probe()
1802 mceusb_set_tx_mask(ir->rc, MCE_DEFAULT_TX_MASK); in mceusb_dev_probe()
1807 device_set_wakeup_capable(ir->dev, true); in mceusb_dev_probe()
1808 device_set_wakeup_enable(ir->dev, true); in mceusb_dev_probe()
1810 dev_info(&intf->dev, "Registered %s with mce emulator interface version %x", in mceusb_dev_probe()
1811 name, ir->emver); in mceusb_dev_probe()
1812 dev_info(&intf->dev, "%x tx ports (0x%x cabled) and %x rx sensors (0x%x active)", in mceusb_dev_probe()
1813 ir->num_txports, ir->txports_cabled, in mceusb_dev_probe()
1814 ir->num_rxports, ir->rxports_active); in mceusb_dev_probe()
1818 /* Error-handling path */ in mceusb_dev_probe()
1820 cancel_work_sync(&ir->kevent); in mceusb_dev_probe()
1821 usb_put_dev(ir->usbdev); in mceusb_dev_probe()
1822 usb_kill_urb(ir->urb_in); in mceusb_dev_probe()
1823 usb_free_urb(ir->urb_in); in mceusb_dev_probe()
1825 usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in); in mceusb_dev_probe()
1829 dev_err(&intf->dev, "%s: device setup failed!", __func__); in mceusb_dev_probe()
1831 return -ENOMEM; in mceusb_dev_probe()
1840 dev_dbg(&intf->dev, "%s called", __func__); in mceusb_dev_disconnect()
1847 ir->usbdev = NULL; in mceusb_dev_disconnect()
1848 cancel_work_sync(&ir->kevent); in mceusb_dev_disconnect()
1849 rc_unregister_device(ir->rc); in mceusb_dev_disconnect()
1850 usb_kill_urb(ir->urb_in); in mceusb_dev_disconnect()
1851 usb_free_urb(ir->urb_in); in mceusb_dev_disconnect()
1852 usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in); in mceusb_dev_disconnect()
1861 dev_info(ir->dev, "suspend"); in mceusb_dev_suspend()
1862 usb_kill_urb(ir->urb_in); in mceusb_dev_suspend()
1869 dev_info(ir->dev, "resume"); in mceusb_dev_resume()
1870 if (usb_submit_urb(ir->urb_in, GFP_ATOMIC)) in mceusb_dev_resume()
1871 return -EIO; in mceusb_dev_resume()