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 */
525 /* MCE Device Command Strings, generally a port and command pair */
602 struct device *dev = ir->dev; in mceusb_dev_printdata()
610 min(len, buf_len - offset), buf + offset, len, buf_len); in mceusb_dev_printdata()
619 if (ir->flags.microsoft_gen1 && !out && !offset) { in mceusb_dev_printdata()
740 dev_dbg(dev, "%s %s-range receive sensor in use", in mceusb_dev_printdata()
783 set_bit(kevent, &ir->kevent_flags); in mceusb_defer_kevent()
785 if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) { in mceusb_defer_kevent()
786 dev_dbg(ir->dev, "kevent %d dropped pending USB Reset Device", in mceusb_defer_kevent()
791 if (!schedule_work(&ir->kevent)) in mceusb_defer_kevent()
792 dev_dbg(ir->dev, "kevent %d already scheduled", kevent); in mceusb_defer_kevent()
794 dev_dbg(ir->dev, "kevent %d scheduled", kevent); in mceusb_defer_kevent()
802 complete(urb->context); in mce_write_callback()
815 struct device *dev = ir->dev; in mce_write()
826 return -ENOMEM; in mce_write()
832 return -ENOMEM; in mce_write()
838 if (usb_endpoint_xfer_int(ir->usb_ep_out)) in mce_write()
839 usb_fill_int_urb(urb, ir->usbdev, ir->pipe_out, in mce_write()
841 ir->usb_ep_out->bInterval); in mce_write()
843 usb_fill_bulk_urb(urb, ir->usbdev, ir->pipe_out, in mce_write()
861 ret = (urb->status == -ENOENT ? -ETIMEDOUT : urb->status); in mce_write()
863 ret = urb->status; in mce_write()
866 ret = urb->actual_length; /* bytes written */ in mce_write()
868 switch (urb->status) { in mce_write()
873 case -ECONNRESET: in mce_write()
874 case -ENOENT: in mce_write()
875 case -EILSEQ: in mce_write()
876 case -ESHUTDOWN: in mce_write()
879 case -EPIPE: in mce_write()
880 dev_err(ir->dev, "Error: mce write urb status = %d (TX HALT)", in mce_write()
881 urb->status); in mce_write()
886 dev_err(ir->dev, "Error: mce write urb status = %d", in mce_write()
887 urb->status); in mce_write()
891 …dev_dbg(dev, "tx done status = %d (wait = %lu, expire = %lu (%dms), urb->actual_length = %d, urb->… in mce_write()
893 urb->actual_length, urb->status); in mce_write()
905 if (ir->need_reset) { in mce_command_out()
906 ir->need_reset = false; in mce_command_out()
927 * An IR sample is 1-bit pulse/space flag with 7-bit time
934 struct mceusb_dev *ir = dev->priv; in mceusb_tx_ir()
942 cmdbuf[2] = ir->tx_mask; in mceusb_tx_ir()
954 if (ircount >= MCE_IRBUF_SIZE - 1) { in mceusb_tx_ir()
970 irsample -= MCE_MAX_PULSE_LENGTH; in mceusb_tx_ir()
984 irbuf[ircount - length] -= in mceusb_tx_ir()
985 MCE_PACKET_SIZE - length; in mceusb_tx_ir()
998 irbuf[ircount - length] -= MCE_PACKET_SIZE - length; in mceusb_tx_ir()
1011 /* Sets active IR outputs -- mce devices typically have two */
1014 struct mceusb_dev *ir = dev->priv; in mceusb_set_tx_mask()
1017 int emitters = ir->num_txports ? ir->num_txports : 2; in mceusb_set_tx_mask()
1022 if (ir->flags.tx_mask_normal) in mceusb_set_tx_mask()
1023 ir->tx_mask = mask; in mceusb_set_tx_mask()
1025 ir->tx_mask = (mask != MCE_DEFAULT_TX_MASK ? in mceusb_set_tx_mask()
1034 struct mceusb_dev *ir = dev->priv; in mceusb_set_tx_carrier()
1041 if (ir->carrier != carrier) { in mceusb_set_tx_carrier()
1044 ir->carrier = carrier; in mceusb_set_tx_carrier()
1047 dev_dbg(ir->dev, "disabling carrier modulation"); in mceusb_set_tx_carrier()
1055 ir->carrier = carrier; in mceusb_set_tx_carrier()
1058 dev_dbg(ir->dev, "requesting %u HZ carrier", in mceusb_set_tx_carrier()
1067 return -EINVAL; in mceusb_set_tx_carrier()
1077 struct mceusb_dev *ir = dev->priv; in mceusb_set_timeout()
1095 * Second receiver is learning mode, wide-band, short-range receiver.
1100 struct mceusb_dev *ir = dev->priv; in mceusb_set_rx_wideband()
1104 dev_dbg(ir->dev, "select %s-range receive sensor", in mceusb_set_rx_wideband()
1107 ir->wideband_rx_enabled = true; in mceusb_set_rx_wideband()
1110 ir->wideband_rx_enabled = false; in mceusb_set_rx_wideband()
1114 /* response from device sets ir->learning_active */ in mceusb_set_rx_wideband()
1121 * Only the short-range receiver has carrier frequency measuring capability.
1126 struct mceusb_dev *ir = dev->priv; in mceusb_set_rx_carrier_report()
1130 dev_dbg(ir->dev, "%s short-range receiver carrier reporting", in mceusb_set_rx_carrier_report()
1133 ir->carrier_report_enabled = true; in mceusb_set_rx_carrier_report()
1134 if (!ir->learning_active) { in mceusb_set_rx_carrier_report()
1139 ir->carrier_report_enabled = false; in mceusb_set_rx_carrier_report()
1141 * Revert to normal (long-range) receiver only if the in mceusb_set_rx_carrier_report()
1142 * wideband (short-range) receiver wasn't explicitly in mceusb_set_rx_carrier_report()
1145 if (ir->learning_active && !ir->wideband_rx_enabled) { in mceusb_set_rx_carrier_report()
1177 /* the one and only 5-byte return value command */ in mceusb_handle_command()
1180 ir->txports_cabled |= 1 << *hi; in mceusb_handle_command()
1183 /* 1-byte return value commands */ in mceusb_handle_command()
1185 ir->emver = *hi; in mceusb_handle_command()
1190 ir->need_reset = true; in mceusb_handle_command()
1204 /* 2-byte return value commands */ in mceusb_handle_command()
1206 ir->rc->timeout = (*hi << 8 | *lo) * MCE_TIME_UNIT; in mceusb_handle_command()
1209 ir->num_txports = *hi; in mceusb_handle_command()
1210 ir->num_rxports = *lo; in mceusb_handle_command()
1218 * The long-range (non learning) receiver always reports in mceusb_handle_command()
1221 if (ir->carrier_report_enabled && ir->learning_active && in mceusb_handle_command()
1222 ir->pulse_tunit > 0) { in mceusb_handle_command()
1228 cycles_fix = ir->flags.rx2 == 2 ? ir->pulse_count : 0; in mceusb_handle_command()
1232 ir->pulse_tunit; in mceusb_handle_command()
1233 …dev_dbg(ir->dev, "RX carrier frequency %u Hz (pulse count = %u, cycles = %u, duration = %u, rx2 = … in mceusb_handle_command()
1234 rawir.carrier, ir->pulse_count, carrier_cycles, in mceusb_handle_command()
1235 ir->pulse_tunit, ir->flags.rx2); in mceusb_handle_command()
1236 ir_raw_event_store(ir->rc, &rawir); in mceusb_handle_command()
1240 /* 1-byte return value commands */ in mceusb_handle_command()
1242 ir->tx_mask = *hi; in mceusb_handle_command()
1245 ir->learning_active = ((*hi & 0x02) == 0x02); in mceusb_handle_command()
1246 if (ir->rxports_active != *hi) { in mceusb_handle_command()
1247 dev_info(ir->dev, "%s-range (0x%x) receiver active", in mceusb_handle_command()
1248 ir->learning_active ? "short" : "long", *hi); in mceusb_handle_command()
1249 ir->rxports_active = *hi; in mceusb_handle_command()
1256 ir->need_reset = true; in mceusb_handle_command()
1271 if (ir->flags.microsoft_gen1) in mceusb_process_ir_data()
1279 switch (ir->parser_state) { in mceusb_process_ir_data()
1281 ir->rem = mceusb_cmd_datasize(ir->cmd, ir->buf_in[i]); in mceusb_process_ir_data()
1282 mceusb_dev_printdata(ir, ir->buf_in, buf_len, i - 1, in mceusb_process_ir_data()
1283 ir->rem + 2, false); in mceusb_process_ir_data()
1284 if (i + ir->rem < buf_len) in mceusb_process_ir_data()
1285 mceusb_handle_command(ir, &ir->buf_in[i - 1]); in mceusb_process_ir_data()
1286 ir->parser_state = CMD_DATA; in mceusb_process_ir_data()
1289 ir->rem--; in mceusb_process_ir_data()
1290 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); in mceusb_process_ir_data()
1291 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK); in mceusb_process_ir_data()
1293 dev_dbg(ir->dev, "nonsensical irdata %02x with duration 0", in mceusb_process_ir_data()
1294 ir->buf_in[i]); in mceusb_process_ir_data()
1298 ir->pulse_tunit += rawir.duration; in mceusb_process_ir_data()
1299 ir->pulse_count++; in mceusb_process_ir_data()
1303 dev_dbg(ir->dev, "Storing %s %u us (%02x)", in mceusb_process_ir_data()
1305 rawir.duration, ir->buf_in[i]); in mceusb_process_ir_data()
1307 if (ir_raw_event_store_with_filter(ir->rc, &rawir)) in mceusb_process_ir_data()
1311 ir->rem--; in mceusb_process_ir_data()
1314 ir->cmd = ir->buf_in[i]; in mceusb_process_ir_data()
1315 if ((ir->cmd == MCE_CMD_PORT_IR) || in mceusb_process_ir_data()
1316 ((ir->cmd & MCE_PORT_MASK) != in mceusb_process_ir_data()
1322 ir->parser_state = SUBCMD; in mceusb_process_ir_data()
1330 ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK); in mceusb_process_ir_data()
1331 mceusb_dev_printdata(ir, ir->buf_in, buf_len, in mceusb_process_ir_data()
1332 i, ir->rem + 1, false); in mceusb_process_ir_data()
1333 if (ir->rem) { in mceusb_process_ir_data()
1334 ir->parser_state = PARSE_IRDATA; in mceusb_process_ir_data()
1338 .duration = ir->rc->timeout in mceusb_process_ir_data()
1341 if (ir_raw_event_store_with_filter(ir->rc, in mceusb_process_ir_data()
1344 ir->pulse_tunit = 0; in mceusb_process_ir_data()
1345 ir->pulse_count = 0; in mceusb_process_ir_data()
1350 if (ir->parser_state != CMD_HEADER && !ir->rem) in mceusb_process_ir_data()
1351 ir->parser_state = CMD_HEADER; in mceusb_process_ir_data()
1358 if (ir->parser_state != PARSE_IRDATA || !ir->rem) in mceusb_process_ir_data()
1359 ir->parser_state = CMD_HEADER; in mceusb_process_ir_data()
1362 dev_dbg(ir->dev, "processed IR data"); in mceusb_process_ir_data()
1363 ir_raw_event_handle(ir->rc); in mceusb_process_ir_data()
1374 ir = urb->context; in mceusb_dev_recv()
1380 switch (urb->status) { in mceusb_dev_recv()
1383 mceusb_process_ir_data(ir, urb->actual_length); in mceusb_dev_recv()
1386 case -ECONNRESET: in mceusb_dev_recv()
1387 case -ENOENT: in mceusb_dev_recv()
1388 case -EILSEQ: in mceusb_dev_recv()
1389 case -EPROTO: in mceusb_dev_recv()
1390 case -ESHUTDOWN: in mceusb_dev_recv()
1394 case -EPIPE: in mceusb_dev_recv()
1395 dev_err(ir->dev, "Error: urb status = %d (RX HALT)", in mceusb_dev_recv()
1396 urb->status); in mceusb_dev_recv()
1401 dev_err(ir->dev, "Error: urb status = %d", urb->status); in mceusb_dev_recv()
1411 ir->emver = 1; in mceusb_get_emulator_version()
1418 struct device *dev = ir->dev; in mceusb_gen1_init()
1423 * on the receive control pipe and expect a certain value pair back in mceusb_gen1_init()
1425 ret = usb_control_msg_recv(ir->usbdev, 0, USB_REQ_SET_ADDRESS, in mceusb_gen1_init()
1429 dev_dbg(dev, "set address - ret = %d", ret); in mceusb_gen1_init()
1430 dev_dbg(dev, "set address - data[0] = %d, data[1] = %d", in mceusb_gen1_init()
1434 ret = usb_control_msg_send(ir->usbdev, 0, in mceusb_gen1_init()
1438 dev_dbg(dev, "set feature - ret = %d", ret); in mceusb_gen1_init()
1441 ret = usb_control_msg_send(ir->usbdev, 0, in mceusb_gen1_init()
1444 dev_dbg(dev, "set char length - retB = %d", ret); in mceusb_gen1_init()
1447 ret = usb_control_msg_send(ir->usbdev, 0, in mceusb_gen1_init()
1450 dev_dbg(dev, "set handshake - retC = %d", ret); in mceusb_gen1_init()
1478 ir->num_txports = 2; in mceusb_get_parameters()
1479 ir->num_rxports = 2; in mceusb_get_parameters()
1487 if (ir->num_txports && !ir->flags.no_tx) in mceusb_get_parameters()
1497 for (i = 0; i < ir->num_txports; i++) { in mceusb_get_parameters()
1505 if (ir->emver < 2) in mceusb_flash_led()
1514 * specified in ir->kevent bit field.
1515 * Function runs (via schedule_work()) in non-interrupt context, for
1516 * calls here (such as usb_clear_halt()) requiring non-interrupt context.
1524 dev_err(ir->dev, "kevent handler called (flags 0x%lx)", in mceusb_deferred_kevent()
1525 ir->kevent_flags); in mceusb_deferred_kevent()
1527 if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) { in mceusb_deferred_kevent()
1528 dev_err(ir->dev, "kevent handler canceled pending USB Reset Device"); in mceusb_deferred_kevent()
1532 if (test_bit(EVENT_RX_HALT, &ir->kevent_flags)) { in mceusb_deferred_kevent()
1533 usb_unlink_urb(ir->urb_in); in mceusb_deferred_kevent()
1534 status = usb_clear_halt(ir->usbdev, ir->pipe_in); in mceusb_deferred_kevent()
1535 dev_err(ir->dev, "rx clear halt status = %d", status); in mceusb_deferred_kevent()
1541 dev_err(ir->dev, in mceusb_deferred_kevent()
1543 usb_queue_reset_device(ir->usbintf); in mceusb_deferred_kevent()
1544 set_bit(EVENT_RST_PEND, &ir->kevent_flags); in mceusb_deferred_kevent()
1545 clear_bit(EVENT_RX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1548 clear_bit(EVENT_TX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1551 clear_bit(EVENT_RX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1552 status = usb_submit_urb(ir->urb_in, GFP_KERNEL); in mceusb_deferred_kevent()
1554 dev_err(ir->dev, "rx unhalt submit urb error = %d", in mceusb_deferred_kevent()
1559 if (test_bit(EVENT_TX_HALT, &ir->kevent_flags)) { in mceusb_deferred_kevent()
1560 status = usb_clear_halt(ir->usbdev, ir->pipe_out); in mceusb_deferred_kevent()
1561 dev_err(ir->dev, "tx clear halt status = %d", status); in mceusb_deferred_kevent()
1567 dev_err(ir->dev, in mceusb_deferred_kevent()
1569 usb_queue_reset_device(ir->usbintf); in mceusb_deferred_kevent()
1570 set_bit(EVENT_RST_PEND, &ir->kevent_flags); in mceusb_deferred_kevent()
1571 clear_bit(EVENT_TX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1574 clear_bit(EVENT_RX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1577 clear_bit(EVENT_TX_HALT, &ir->kevent_flags); in mceusb_deferred_kevent()
1583 struct usb_device *udev = ir->usbdev; in mceusb_init_rc_dev()
1584 struct device *dev = ir->dev; in mceusb_init_rc_dev()
1594 snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)", in mceusb_init_rc_dev()
1595 mceusb_model[ir->model].name ? in mceusb_init_rc_dev()
1596 mceusb_model[ir->model].name : in mceusb_init_rc_dev()
1598 le16_to_cpu(ir->usbdev->descriptor.idVendor), in mceusb_init_rc_dev()
1599 le16_to_cpu(ir->usbdev->descriptor.idProduct)); in mceusb_init_rc_dev()
1601 usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys)); in mceusb_init_rc_dev()
1603 rc->device_name = ir->name; in mceusb_init_rc_dev()
1604 rc->input_phys = ir->phys; in mceusb_init_rc_dev()
1605 usb_to_input_id(ir->usbdev, &rc->input_id); in mceusb_init_rc_dev()
1606 rc->dev.parent = dev; in mceusb_init_rc_dev()
1607 rc->priv = ir; in mceusb_init_rc_dev()
1608 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in mceusb_init_rc_dev()
1609 rc->rx_resolution = MCE_TIME_UNIT; in mceusb_init_rc_dev()
1610 rc->min_timeout = MCE_TIME_UNIT; in mceusb_init_rc_dev()
1611 rc->timeout = MS_TO_US(100); in mceusb_init_rc_dev()
1612 if (!mceusb_model[ir->model].broken_irtimeout) { in mceusb_init_rc_dev()
1613 rc->s_timeout = mceusb_set_timeout; in mceusb_init_rc_dev()
1614 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; in mceusb_init_rc_dev()
1620 rc->max_timeout = rc->timeout; in mceusb_init_rc_dev()
1622 if (!ir->flags.no_tx) { in mceusb_init_rc_dev()
1623 rc->s_tx_mask = mceusb_set_tx_mask; in mceusb_init_rc_dev()
1624 rc->s_tx_carrier = mceusb_set_tx_carrier; in mceusb_init_rc_dev()
1625 rc->tx_ir = mceusb_tx_ir; in mceusb_init_rc_dev()
1627 if (ir->flags.rx2 > 0) { in mceusb_init_rc_dev()
1628 rc->s_wideband_receiver = mceusb_set_rx_wideband; in mceusb_init_rc_dev()
1629 rc->s_carrier_report = mceusb_set_rx_carrier_report; in mceusb_init_rc_dev()
1631 rc->driver_name = DRIVER_NAME; in mceusb_init_rc_dev()
1633 switch (le16_to_cpu(udev->descriptor.idVendor)) { in mceusb_init_rc_dev()
1635 rc->map_name = RC_MAP_HAUPPAUGE; in mceusb_init_rc_dev()
1638 rc->map_name = RC_MAP_PINNACLE_PCTV_HD; in mceusb_init_rc_dev()
1641 rc->map_name = RC_MAP_RC6_MCE; in mceusb_init_rc_dev()
1643 if (mceusb_model[ir->model].rc_map) in mceusb_init_rc_dev()
1644 rc->map_name = mceusb_model[ir->model].rc_map; in mceusb_init_rc_dev()
1670 enum mceusb_model_type model = id->driver_info; in mceusb_dev_probe()
1676 dev_dbg(&intf->dev, "%s called", __func__); in mceusb_dev_probe()
1678 idesc = intf->cur_altsetting; in mceusb_dev_probe()
1685 /* There are multi-function devices with non-IR interfaces */ in mceusb_dev_probe()
1686 if (idesc->desc.bInterfaceNumber != ir_intfnum) in mceusb_dev_probe()
1687 return -ENODEV; in mceusb_dev_probe()
1690 for (i = 0; i < idesc->desc.bNumEndpoints; ++i) { in mceusb_dev_probe()
1691 ep = &idesc->endpoint[i].desc; in mceusb_dev_probe()
1696 dev_dbg(&intf->dev, "acceptable bulk inbound endpoint found\n"); in mceusb_dev_probe()
1699 ep_in->bInterval = 1; in mceusb_dev_probe()
1700 dev_dbg(&intf->dev, "acceptable interrupt inbound endpoint found\n"); in mceusb_dev_probe()
1707 dev_dbg(&intf->dev, "acceptable bulk outbound endpoint found\n"); in mceusb_dev_probe()
1710 ep_out->bInterval = 1; in mceusb_dev_probe()
1711 dev_dbg(&intf->dev, "acceptable interrupt outbound endpoint found\n"); in mceusb_dev_probe()
1716 dev_dbg(&intf->dev, "required endpoints not found\n"); in mceusb_dev_probe()
1717 return -ENODEV; in mceusb_dev_probe()
1721 pipe = usb_rcvintpipe(dev, ep_in->bEndpointAddress); in mceusb_dev_probe()
1723 pipe = usb_rcvbulkpipe(dev, ep_in->bEndpointAddress); in mceusb_dev_probe()
1730 ir->pipe_in = pipe; in mceusb_dev_probe()
1731 ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_KERNEL, &ir->dma_in); in mceusb_dev_probe()
1732 if (!ir->buf_in) in mceusb_dev_probe()
1735 ir->urb_in = usb_alloc_urb(0, GFP_KERNEL); in mceusb_dev_probe()
1736 if (!ir->urb_in) in mceusb_dev_probe()
1739 ir->usbintf = intf; in mceusb_dev_probe()
1740 ir->usbdev = usb_get_dev(dev); in mceusb_dev_probe()
1741 ir->dev = &intf->dev; in mceusb_dev_probe()
1742 ir->len_in = maxp; in mceusb_dev_probe()
1743 ir->flags.microsoft_gen1 = is_microsoft_gen1; in mceusb_dev_probe()
1744 ir->flags.tx_mask_normal = tx_mask_normal; in mceusb_dev_probe()
1745 ir->flags.no_tx = mceusb_model[model].no_tx; in mceusb_dev_probe()
1746 ir->flags.rx2 = mceusb_model[model].rx2; in mceusb_dev_probe()
1747 ir->model = model; in mceusb_dev_probe()
1750 ir->usb_ep_out = ep_out; in mceusb_dev_probe()
1752 ir->pipe_out = usb_sndintpipe(ir->usbdev, in mceusb_dev_probe()
1753 ep_out->bEndpointAddress); in mceusb_dev_probe()
1755 ir->pipe_out = usb_sndbulkpipe(ir->usbdev, in mceusb_dev_probe()
1756 ep_out->bEndpointAddress); in mceusb_dev_probe()
1758 if (dev->descriptor.iManufacturer in mceusb_dev_probe()
1759 && usb_string(dev, dev->descriptor.iManufacturer, in mceusb_dev_probe()
1762 if (dev->descriptor.iProduct in mceusb_dev_probe()
1763 && usb_string(dev, dev->descriptor.iProduct, in mceusb_dev_probe()
1765 snprintf(name + strlen(name), sizeof(name) - strlen(name), in mceusb_dev_probe()
1772 INIT_WORK(&ir->kevent, mceusb_deferred_kevent); in mceusb_dev_probe()
1774 ir->rc = mceusb_init_rc_dev(ir); in mceusb_dev_probe()
1775 if (!ir->rc) in mceusb_dev_probe()
1780 usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp, in mceusb_dev_probe()
1781 mceusb_dev_recv, ir, ep_in->bInterval); in mceusb_dev_probe()
1783 usb_fill_bulk_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp, in mceusb_dev_probe()
1786 ir->urb_in->transfer_dma = ir->dma_in; in mceusb_dev_probe()
1787 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in mceusb_dev_probe()
1790 dev_dbg(&intf->dev, "Flushing receive buffers"); in mceusb_dev_probe()
1791 res = usb_submit_urb(ir->urb_in, GFP_KERNEL); in mceusb_dev_probe()
1793 dev_err(&intf->dev, "failed to flush buffers: %d", res); in mceusb_dev_probe()
1799 if (ir->flags.microsoft_gen1) in mceusb_dev_probe()
1808 if (!ir->flags.no_tx) in mceusb_dev_probe()
1809 mceusb_set_tx_mask(ir->rc, MCE_DEFAULT_TX_MASK); in mceusb_dev_probe()
1814 device_set_wakeup_capable(ir->dev, true); in mceusb_dev_probe()
1815 device_set_wakeup_enable(ir->dev, true); in mceusb_dev_probe()
1817 dev_info(&intf->dev, "Registered %s with mce emulator interface version %x", in mceusb_dev_probe()
1818 name, ir->emver); in mceusb_dev_probe()
1819 dev_info(&intf->dev, "%x tx ports (0x%x cabled) and %x rx sensors (0x%x active)", in mceusb_dev_probe()
1820 ir->num_txports, ir->txports_cabled, in mceusb_dev_probe()
1821 ir->num_rxports, ir->rxports_active); in mceusb_dev_probe()
1825 /* Error-handling path */ in mceusb_dev_probe()
1827 cancel_work_sync(&ir->kevent); in mceusb_dev_probe()
1828 usb_put_dev(ir->usbdev); in mceusb_dev_probe()
1829 usb_kill_urb(ir->urb_in); in mceusb_dev_probe()
1830 usb_free_urb(ir->urb_in); in mceusb_dev_probe()
1832 usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in); in mceusb_dev_probe()
1836 dev_err(&intf->dev, "%s: device setup failed!", __func__); in mceusb_dev_probe()
1838 return -ENOMEM; in mceusb_dev_probe()
1847 dev_dbg(&intf->dev, "%s called", __func__); in mceusb_dev_disconnect()
1854 ir->usbdev = NULL; in mceusb_dev_disconnect()
1855 cancel_work_sync(&ir->kevent); in mceusb_dev_disconnect()
1856 rc_unregister_device(ir->rc); in mceusb_dev_disconnect()
1857 usb_kill_urb(ir->urb_in); in mceusb_dev_disconnect()
1858 usb_free_urb(ir->urb_in); in mceusb_dev_disconnect()
1859 usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in); in mceusb_dev_disconnect()
1868 dev_info(ir->dev, "suspend"); in mceusb_dev_suspend()
1869 usb_kill_urb(ir->urb_in); in mceusb_dev_suspend()
1876 dev_info(ir->dev, "resume"); in mceusb_dev_resume()
1877 if (usb_submit_urb(ir->urb_in, GFP_ATOMIC)) in mceusb_dev_resume()
1878 return -EIO; in mceusb_dev_resume()