2010-06-01 20:32:08 +00:00
|
|
|
/*
|
|
|
|
* Driver for USB Windows Media Center Ed. eHome Infrared Transceivers
|
|
|
|
*
|
2011-07-18 19:54:29 +00:00
|
|
|
* Copyright (c) 2010-2011, Jarod Wilson <jarod@redhat.com>
|
2010-06-01 20:32:08 +00:00
|
|
|
*
|
|
|
|
* Based on the original lirc_mceusb and lirc_mceusb2 drivers, by Dan
|
|
|
|
* Conti, Martin Blatter and Daniel Melander, the latter of which was
|
|
|
|
* in turn also based on the lirc_atiusb driver by Paul Miller. The
|
|
|
|
* two mce drivers were merged into one by Jarod Wilson, with transmit
|
|
|
|
* support for the 1st-gen device added primarily by Patrick Calhoun,
|
|
|
|
* with a bit of tweaks by Jarod. Debugging improvements and proper
|
|
|
|
* support for what appears to be 3rd-gen hardware added by Jarod.
|
|
|
|
* Initial port from lirc driver to ir-core drivery by Jarod, based
|
|
|
|
* partially on a port to an earlier proposed IR infrastructure by
|
|
|
|
* Jon Smirl, which included enhancements and simplifications to the
|
|
|
|
* incoming IR buffer parsing routines.
|
|
|
|
*
|
2011-07-18 19:54:29 +00:00
|
|
|
* Updated in July of 2011 with the aid of Microsoft's official
|
|
|
|
* remote/transceiver requirements and specification document, found at
|
|
|
|
* download.microsoft.com, title
|
|
|
|
* Windows-Media-Center-RC-IR-Collection-Green-Button-Specification-03-08-2011-V2.pdf
|
|
|
|
*
|
2010-06-01 20:32:08 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
2017-03-26 18:28:08 +00:00
|
|
|
#include <linux/workqueue.h>
|
2010-12-16 16:23:07 +00:00
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/usb/input.h>
|
2011-07-18 19:54:23 +00:00
|
|
|
#include <linux/pm_wakeup.h>
|
2010-11-17 16:28:38 +00:00
|
|
|
#include <media/rc-core.h>
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2018-03-16 19:52:09 +00:00
|
|
|
#define DRIVER_VERSION "1.94"
|
2011-07-18 19:54:29 +00:00
|
|
|
#define DRIVER_AUTHOR "Jarod Wilson <jarod@redhat.com>"
|
2010-06-01 20:32:08 +00:00
|
|
|
#define DRIVER_DESC "Windows Media Center Ed. eHome Infrared Transceiver " \
|
|
|
|
"device driver"
|
|
|
|
#define DRIVER_NAME "mceusb"
|
|
|
|
|
2010-10-22 17:42:54 +00:00
|
|
|
#define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */
|
|
|
|
#define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* MCE constants */
|
2010-10-22 17:42:54 +00:00
|
|
|
#define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */
|
|
|
|
#define MCE_TIME_UNIT 50 /* Approx 50us resolution */
|
|
|
|
#define MCE_CODE_LENGTH 5 /* Normal length of packet (with header) */
|
|
|
|
#define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */
|
|
|
|
#define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */
|
|
|
|
#define MCE_IRDATA_TRAILER 0x80 /* End of IR data */
|
|
|
|
#define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */
|
|
|
|
#define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */
|
|
|
|
#define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */
|
|
|
|
#define MCE_PULSE_MASK 0x7f /* Pulse mask */
|
|
|
|
#define MCE_MAX_PULSE_LENGTH 0x7f /* Longest transmittable pulse symbol */
|
|
|
|
|
2011-07-18 19:54:21 +00:00
|
|
|
/*
|
|
|
|
* The interface between the host and the IR hardware is command-response
|
|
|
|
* based. All commands and responses have a consistent format, where a lead
|
|
|
|
* byte always identifies the type of data following it. The lead byte has
|
|
|
|
* a port value in the 3 highest bits and a length value in the 5 lowest
|
|
|
|
* bits.
|
|
|
|
*
|
|
|
|
* The length field is overloaded, with a value of 11111 indicating that the
|
|
|
|
* following byte is a command or response code, and the length of the entire
|
|
|
|
* message is determined by the code. If the length field is not 11111, then
|
|
|
|
* it specifies the number of bytes of port data that follow.
|
|
|
|
*/
|
|
|
|
#define MCE_CMD 0x1f
|
|
|
|
#define MCE_PORT_IR 0x4 /* (0x4 << 5) | MCE_CMD = 0x9f */
|
|
|
|
#define MCE_PORT_SYS 0x7 /* (0x7 << 5) | MCE_CMD = 0xff */
|
|
|
|
#define MCE_PORT_SER 0x6 /* 0xc0 thru 0xdf flush & 0x1f bytes */
|
2014-01-20 22:10:44 +00:00
|
|
|
#define MCE_PORT_MASK 0xe0 /* Mask out command bits */
|
2011-07-18 19:54:21 +00:00
|
|
|
|
|
|
|
/* Command port headers */
|
|
|
|
#define MCE_CMD_PORT_IR 0x9f /* IR-related cmd/rsp */
|
|
|
|
#define MCE_CMD_PORT_SYS 0xff /* System (non-IR) device cmd/rsp */
|
|
|
|
|
|
|
|
/* Commands that set device state (2-4 bytes in length) */
|
|
|
|
#define MCE_CMD_RESET 0xfe /* Reset device, 2 bytes */
|
|
|
|
#define MCE_CMD_RESUME 0xaa /* Resume device after error, 2 bytes */
|
|
|
|
#define MCE_CMD_SETIRCFS 0x06 /* Set tx carrier, 4 bytes */
|
|
|
|
#define MCE_CMD_SETIRTIMEOUT 0x0c /* Set timeout, 4 bytes */
|
|
|
|
#define MCE_CMD_SETIRTXPORTS 0x08 /* Set tx ports, 3 bytes */
|
|
|
|
#define MCE_CMD_SETIRRXPORTEN 0x14 /* Set rx ports, 3 bytes */
|
|
|
|
#define MCE_CMD_FLASHLED 0x23 /* Flash receiver LED, 2 bytes */
|
|
|
|
|
|
|
|
/* Commands that query device state (all 2 bytes, unless noted) */
|
|
|
|
#define MCE_CMD_GETIRCFS 0x07 /* Get carrier */
|
|
|
|
#define MCE_CMD_GETIRTIMEOUT 0x0d /* Get timeout */
|
|
|
|
#define MCE_CMD_GETIRTXPORTS 0x13 /* Get tx ports */
|
|
|
|
#define MCE_CMD_GETIRRXPORTEN 0x15 /* Get rx ports */
|
|
|
|
#define MCE_CMD_GETPORTSTATUS 0x11 /* Get tx port status, 3 bytes */
|
|
|
|
#define MCE_CMD_GETIRNUMPORTS 0x16 /* Get number of ports */
|
|
|
|
#define MCE_CMD_GETWAKESOURCE 0x17 /* Get wake source */
|
|
|
|
#define MCE_CMD_GETEMVER 0x22 /* Get emulator interface version */
|
|
|
|
#define MCE_CMD_GETDEVDETAILS 0x21 /* Get device details (em ver2 only) */
|
|
|
|
#define MCE_CMD_GETWAKESUPPORT 0x20 /* Get wake details (em ver2 only) */
|
|
|
|
#define MCE_CMD_GETWAKEVERSION 0x18 /* Get wake pattern (em ver2 only) */
|
|
|
|
|
|
|
|
/* Misc commands */
|
|
|
|
#define MCE_CMD_NOP 0xff /* No operation */
|
|
|
|
|
|
|
|
/* Responses to commands (non-error cases) */
|
|
|
|
#define MCE_RSP_EQIRCFS 0x06 /* tx carrier, 4 bytes */
|
|
|
|
#define MCE_RSP_EQIRTIMEOUT 0x0c /* rx timeout, 4 bytes */
|
|
|
|
#define MCE_RSP_GETWAKESOURCE 0x17 /* wake source, 3 bytes */
|
|
|
|
#define MCE_RSP_EQIRTXPORTS 0x08 /* tx port mask, 3 bytes */
|
|
|
|
#define MCE_RSP_EQIRRXPORTEN 0x14 /* rx port mask, 3 bytes */
|
|
|
|
#define MCE_RSP_GETPORTSTATUS 0x11 /* tx port status, 7 bytes */
|
|
|
|
#define MCE_RSP_EQIRRXCFCNT 0x15 /* rx carrier count, 4 bytes */
|
|
|
|
#define MCE_RSP_EQIRNUMPORTS 0x16 /* number of ports, 4 bytes */
|
|
|
|
#define MCE_RSP_EQWAKESUPPORT 0x20 /* wake capabilities, 3 bytes */
|
|
|
|
#define MCE_RSP_EQWAKEVERSION 0x18 /* wake pattern details, 6 bytes */
|
|
|
|
#define MCE_RSP_EQDEVDETAILS 0x21 /* device capabilities, 3 bytes */
|
|
|
|
#define MCE_RSP_EQEMVER 0x22 /* emulator interface ver, 3 bytes */
|
|
|
|
#define MCE_RSP_FLASHLED 0x23 /* success flashing LED, 2 bytes */
|
|
|
|
|
|
|
|
/* Responses to error cases, must send MCE_CMD_RESUME to clear them */
|
|
|
|
#define MCE_RSP_CMD_ILLEGAL 0xfe /* illegal command for port, 2 bytes */
|
|
|
|
#define MCE_RSP_TX_TIMEOUT 0x81 /* tx timed out, 2 bytes */
|
|
|
|
|
|
|
|
/* Misc commands/responses not defined in the MCE remote/transceiver spec */
|
2010-11-09 21:41:03 +00:00
|
|
|
#define MCE_CMD_SIG_END 0x01 /* End of signal */
|
2010-10-22 17:42:54 +00:00
|
|
|
#define MCE_CMD_PING 0x03 /* Ping device */
|
|
|
|
#define MCE_CMD_UNKNOWN 0x04 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN2 0x05 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN3 0x09 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN4 0x0a /* Unknown */
|
|
|
|
#define MCE_CMD_G_REVISION 0x0b /* Get hw/sw revision */
|
|
|
|
#define MCE_CMD_UNKNOWN5 0x0e /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN6 0x0f /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN8 0x19 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN9 0x1b /* Unknown */
|
2011-07-18 19:54:21 +00:00
|
|
|
#define MCE_CMD_NULL 0x00 /* These show up various places... */
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2011-07-18 19:54:21 +00:00
|
|
|
/* if buf[i] & MCE_PORT_MASK == 0x80 and buf[i] != MCE_CMD_PORT_IR,
|
|
|
|
* then we're looking at a raw IR data sample */
|
|
|
|
#define MCE_COMMAND_IRDATA 0x80
|
|
|
|
#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
#define VENDOR_PHILIPS 0x0471
|
|
|
|
#define VENDOR_SMK 0x0609
|
|
|
|
#define VENDOR_TATUNG 0x1460
|
|
|
|
#define VENDOR_GATEWAY 0x107b
|
|
|
|
#define VENDOR_SHUTTLE 0x1308
|
|
|
|
#define VENDOR_SHUTTLE2 0x051c
|
|
|
|
#define VENDOR_MITSUMI 0x03ee
|
|
|
|
#define VENDOR_TOPSEED 0x1784
|
|
|
|
#define VENDOR_RICAVISION 0x179d
|
|
|
|
#define VENDOR_ITRON 0x195d
|
|
|
|
#define VENDOR_FIC 0x1509
|
|
|
|
#define VENDOR_LG 0x043e
|
|
|
|
#define VENDOR_MICROSOFT 0x045e
|
|
|
|
#define VENDOR_FORMOSA 0x147a
|
|
|
|
#define VENDOR_FINTEK 0x1934
|
|
|
|
#define VENDOR_PINNACLE 0x2304
|
|
|
|
#define VENDOR_ECS 0x1019
|
|
|
|
#define VENDOR_WISTRON 0x0fb8
|
|
|
|
#define VENDOR_COMPRO 0x185b
|
|
|
|
#define VENDOR_NORTHSTAR 0x04eb
|
|
|
|
#define VENDOR_REALTEK 0x0bda
|
|
|
|
#define VENDOR_TIVO 0x105a
|
2010-10-18 19:32:50 +00:00
|
|
|
#define VENDOR_CONEXANT 0x0572
|
2012-07-11 21:53:28 +00:00
|
|
|
#define VENDOR_TWISTEDMELON 0x2596
|
2013-11-21 20:26:42 +00:00
|
|
|
#define VENDOR_HAUPPAUGE 0x2040
|
2014-07-27 20:06:02 +00:00
|
|
|
#define VENDOR_PCTV 0x2013
|
2016-03-17 13:11:09 +00:00
|
|
|
#define VENDOR_ADAPTEC 0x03f3
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-10-22 14:50:37 +00:00
|
|
|
enum mceusb_model_type {
|
|
|
|
MCE_GEN2 = 0, /* Most boards */
|
|
|
|
MCE_GEN1,
|
|
|
|
MCE_GEN3,
|
2018-05-09 10:11:28 +00:00
|
|
|
MCE_GEN3_BROKEN_IRTIMEOUT,
|
2010-10-22 14:50:37 +00:00
|
|
|
MCE_GEN2_TX_INV,
|
2018-03-18 10:46:02 +00:00
|
|
|
MCE_GEN2_TX_INV_RX_GOOD,
|
2010-10-22 14:50:37 +00:00
|
|
|
POLARIS_EVK,
|
2010-10-29 03:07:39 +00:00
|
|
|
CX_HYBRID_TV,
|
2011-03-01 15:38:28 +00:00
|
|
|
MULTIFUNCTION,
|
2011-03-24 15:59:10 +00:00
|
|
|
TIVO_KIT,
|
2011-04-19 19:47:34 +00:00
|
|
|
MCE_GEN2_NO_TX,
|
2013-11-21 20:26:42 +00:00
|
|
|
HAUPPAUGE_CX_HYBRID_TV,
|
2017-10-28 13:38:16 +00:00
|
|
|
EVROMEDIA_FULL_HYBRID_FULLHD,
|
2017-10-28 13:38:18 +00:00
|
|
|
ASTROMETA_T2HYBRID,
|
2010-10-22 14:50:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mceusb_model {
|
|
|
|
u32 mce_gen1:1;
|
|
|
|
u32 mce_gen2:1;
|
|
|
|
u32 mce_gen3:1;
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
u32 tx_mask_normal:1;
|
2010-10-29 03:07:39 +00:00
|
|
|
u32 no_tx:1;
|
2018-05-09 10:11:28 +00:00
|
|
|
u32 broken_irtimeout:1;
|
2018-03-16 19:52:09 +00:00
|
|
|
/*
|
|
|
|
* 2nd IR receiver (short-range, wideband) for learning mode:
|
|
|
|
* 0, absent 2nd receiver (rx2)
|
|
|
|
* 1, rx2 present
|
|
|
|
* 2, rx2 which under counts IR carrier cycles
|
|
|
|
*/
|
|
|
|
u32 rx2;
|
2010-10-22 14:50:37 +00:00
|
|
|
|
2011-03-01 15:38:28 +00:00
|
|
|
int ir_intfnum;
|
|
|
|
|
2010-10-22 14:51:50 +00:00
|
|
|
const char *rc_map; /* Allow specify a per-board map */
|
2010-10-22 14:52:53 +00:00
|
|
|
const char *name; /* per-board name */
|
2010-10-22 14:50:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct mceusb_model mceusb_model[] = {
|
|
|
|
[MCE_GEN1] = {
|
|
|
|
.mce_gen1 = 1,
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
.tx_mask_normal = 1,
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 2,
|
2010-10-22 14:50:37 +00:00
|
|
|
},
|
|
|
|
[MCE_GEN2] = {
|
|
|
|
.mce_gen2 = 1,
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 2,
|
2010-10-22 14:50:37 +00:00
|
|
|
},
|
2011-04-19 19:47:34 +00:00
|
|
|
[MCE_GEN2_NO_TX] = {
|
|
|
|
.mce_gen2 = 1,
|
|
|
|
.no_tx = 1,
|
|
|
|
},
|
2010-10-22 14:50:37 +00:00
|
|
|
[MCE_GEN2_TX_INV] = {
|
|
|
|
.mce_gen2 = 1,
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
.tx_mask_normal = 1,
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 1,
|
2010-10-22 14:50:37 +00:00
|
|
|
},
|
2018-03-18 10:46:02 +00:00
|
|
|
[MCE_GEN2_TX_INV_RX_GOOD] = {
|
|
|
|
.mce_gen2 = 1,
|
|
|
|
.tx_mask_normal = 1,
|
|
|
|
.rx2 = 2,
|
|
|
|
},
|
2010-10-22 14:50:37 +00:00
|
|
|
[MCE_GEN3] = {
|
|
|
|
.mce_gen3 = 1,
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
.tx_mask_normal = 1,
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 2,
|
2010-10-22 14:50:37 +00:00
|
|
|
},
|
2018-05-09 10:11:28 +00:00
|
|
|
[MCE_GEN3_BROKEN_IRTIMEOUT] = {
|
|
|
|
.mce_gen3 = 1,
|
|
|
|
.tx_mask_normal = 1,
|
|
|
|
.rx2 = 2,
|
|
|
|
.broken_irtimeout = 1
|
|
|
|
},
|
2010-10-22 14:50:37 +00:00
|
|
|
[POLARIS_EVK] = {
|
2010-10-22 14:51:50 +00:00
|
|
|
/*
|
|
|
|
* In fact, the EVK is shipped without
|
|
|
|
* remotes, but we should have something handy,
|
|
|
|
* to allow testing it
|
|
|
|
*/
|
2010-10-29 03:07:39 +00:00
|
|
|
.name = "Conexant Hybrid TV (cx231xx) MCE IR",
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 2,
|
2010-10-29 03:07:39 +00:00
|
|
|
},
|
|
|
|
[CX_HYBRID_TV] = {
|
|
|
|
.no_tx = 1, /* tx isn't wired up at all */
|
|
|
|
.name = "Conexant Hybrid TV (cx231xx) MCE IR",
|
2010-10-22 14:50:37 +00:00
|
|
|
},
|
2013-11-21 20:26:42 +00:00
|
|
|
[HAUPPAUGE_CX_HYBRID_TV] = {
|
|
|
|
.no_tx = 1, /* eeprom says it has no tx */
|
|
|
|
.name = "Conexant Hybrid TV (cx231xx) MCE IR no TX",
|
|
|
|
},
|
2011-03-01 15:38:28 +00:00
|
|
|
[MULTIFUNCTION] = {
|
|
|
|
.mce_gen2 = 1,
|
|
|
|
.ir_intfnum = 2,
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 2,
|
2011-03-01 15:38:28 +00:00
|
|
|
},
|
2011-03-24 15:59:10 +00:00
|
|
|
[TIVO_KIT] = {
|
|
|
|
.mce_gen2 = 1,
|
|
|
|
.rc_map = RC_MAP_TIVO,
|
2018-03-16 19:52:09 +00:00
|
|
|
.rx2 = 2,
|
2011-03-24 15:59:10 +00:00
|
|
|
},
|
2017-10-28 13:38:16 +00:00
|
|
|
[EVROMEDIA_FULL_HYBRID_FULLHD] = {
|
|
|
|
.name = "Evromedia USB Full Hybrid Full HD",
|
|
|
|
.no_tx = 1,
|
|
|
|
.rc_map = RC_MAP_MSI_DIGIVOX_III,
|
|
|
|
},
|
2017-10-28 13:38:18 +00:00
|
|
|
[ASTROMETA_T2HYBRID] = {
|
|
|
|
.name = "Astrometa T2Hybrid",
|
|
|
|
.no_tx = 1,
|
|
|
|
.rc_map = RC_MAP_ASTROMETA_T2HYBRID,
|
|
|
|
}
|
2010-10-22 14:50:37 +00:00
|
|
|
};
|
|
|
|
|
2017-08-13 08:54:44 +00:00
|
|
|
static const struct usb_device_id mceusb_dev_table[] = {
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Original Microsoft MCE IR Transceiver (often HP-branded) */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_MICROSOFT, 0x006d),
|
|
|
|
.driver_info = MCE_GEN1 },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Philips Infrared Transceiver - Sahara branded */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x0608) },
|
|
|
|
/* Philips Infrared Transceiver - HP branded */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x060c),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Philips SRM5100 */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x060d) },
|
|
|
|
/* Philips Infrared Transceiver - Omaura */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x060f) },
|
|
|
|
/* Philips Infrared Transceiver - Spinel plus */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x0613) },
|
|
|
|
/* Philips eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x0815) },
|
2010-08-27 21:21:14 +00:00
|
|
|
/* Philips/Spinel plus IR transceiver for ASUS */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x206c) },
|
|
|
|
/* Philips/Spinel plus IR transceiver for ASUS */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x2088) },
|
2011-04-25 17:48:18 +00:00
|
|
|
/* Philips IR transceiver (Dell branded) */
|
2013-01-29 11:19:29 +00:00
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x2093),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2011-03-01 15:38:28 +00:00
|
|
|
/* Realtek MCE IR Receiver and card reader */
|
|
|
|
{ USB_DEVICE(VENDOR_REALTEK, 0x0161),
|
|
|
|
.driver_info = MULTIFUNCTION },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* SMK/Toshiba G83C0004D410 */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x031d),
|
2018-03-18 10:46:02 +00:00
|
|
|
.driver_info = MCE_GEN2_TX_INV_RX_GOOD },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* SMK eHome Infrared Transceiver (Sony VAIO) */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0322),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* bundled with Hauppauge PVR-150 */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0334),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* SMK eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0338) },
|
2011-05-26 19:03:17 +00:00
|
|
|
/* SMK/I-O Data GV-MC7/RCKIT Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0353),
|
|
|
|
.driver_info = MCE_GEN2_NO_TX },
|
2016-03-17 13:11:10 +00:00
|
|
|
/* SMK RXX6000 Infrared Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0357),
|
|
|
|
.driver_info = MCE_GEN2_NO_TX },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Tatung eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_TATUNG, 0x9150) },
|
|
|
|
/* Shuttle eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_SHUTTLE, 0xc001) },
|
|
|
|
/* Shuttle eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_SHUTTLE2, 0xc001) },
|
|
|
|
/* Gateway eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_GATEWAY, 0x3009) },
|
|
|
|
/* Mitsumi */
|
|
|
|
{ USB_DEVICE(VENDOR_MITSUMI, 0x2501) },
|
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0001),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Topseed HP eHome Infrared Transceiver */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0006),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0007),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0008),
|
|
|
|
.driver_info = MCE_GEN3 },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x000a),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0011),
|
2018-05-09 10:11:28 +00:00
|
|
|
.driver_info = MCE_GEN3_BROKEN_IRTIMEOUT },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Ricavision internal Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_RICAVISION, 0x0010) },
|
|
|
|
/* Itron ione Libra Q-11 */
|
|
|
|
{ USB_DEVICE(VENDOR_ITRON, 0x7002) },
|
|
|
|
/* FIC eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_FIC, 0x9242) },
|
|
|
|
/* LG eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_LG, 0x9803) },
|
|
|
|
/* Microsoft MCE Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_MICROSOFT, 0x00a0) },
|
|
|
|
/* Formosa eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe015) },
|
|
|
|
/* Formosa21 / eHome Infrared Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe016) },
|
|
|
|
/* Formosa aim / Trust MCE Infrared Receiver */
|
2011-04-19 19:47:34 +00:00
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe017),
|
|
|
|
.driver_info = MCE_GEN2_NO_TX },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Formosa Industrial Computing / Beanbag Emulation Device */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe018) },
|
|
|
|
/* Formosa21 / eHome Infrared Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03a) },
|
|
|
|
/* Formosa Industrial Computing AIM IR605/A */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03c) },
|
|
|
|
/* Formosa Industrial Computing */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03e) },
|
2012-03-12 16:27:03 +00:00
|
|
|
/* Formosa Industrial Computing */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe042) },
|
2010-12-16 16:27:11 +00:00
|
|
|
/* Fintek eHome Infrared Transceiver (HP branded) */
|
2013-01-29 11:19:30 +00:00
|
|
|
{ USB_DEVICE(VENDOR_FINTEK, 0x5168),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Fintek eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_FINTEK, 0x0602) },
|
|
|
|
/* Fintek eHome Infrared Transceiver (in the AOpen MP45) */
|
|
|
|
{ USB_DEVICE(VENDOR_FINTEK, 0x0702) },
|
|
|
|
/* Pinnacle Remote Kit */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_PINNACLE, 0x0225),
|
|
|
|
.driver_info = MCE_GEN3 },
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Elitegroup Computer Systems IR */
|
|
|
|
{ USB_DEVICE(VENDOR_ECS, 0x0f38) },
|
|
|
|
/* Wistron Corp. eHome Infrared Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_WISTRON, 0x0002) },
|
|
|
|
/* Compro K100 */
|
|
|
|
{ USB_DEVICE(VENDOR_COMPRO, 0x3020) },
|
|
|
|
/* Compro K100 v2 */
|
|
|
|
{ USB_DEVICE(VENDOR_COMPRO, 0x3082) },
|
|
|
|
/* Northstar Systems, Inc. eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_NORTHSTAR, 0xe004) },
|
|
|
|
/* TiVo PC IR Receiver */
|
2011-03-24 15:59:10 +00:00
|
|
|
{ USB_DEVICE(VENDOR_TIVO, 0x2000),
|
|
|
|
.driver_info = TIVO_KIT },
|
2010-10-29 03:07:39 +00:00
|
|
|
/* Conexant Hybrid TV "Shelby" Polaris SDK */
|
2010-10-22 14:50:37 +00:00
|
|
|
{ USB_DEVICE(VENDOR_CONEXANT, 0x58a1),
|
|
|
|
.driver_info = POLARIS_EVK },
|
2010-10-29 03:07:39 +00:00
|
|
|
/* Conexant Hybrid TV RDU253S Polaris */
|
|
|
|
{ USB_DEVICE(VENDOR_CONEXANT, 0x58a5),
|
|
|
|
.driver_info = CX_HYBRID_TV },
|
2012-07-11 21:53:28 +00:00
|
|
|
/* Twisted Melon Inc. - Manta Mini Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_TWISTEDMELON, 0x8008) },
|
|
|
|
/* Twisted Melon Inc. - Manta Pico Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_TWISTEDMELON, 0x8016) },
|
|
|
|
/* Twisted Melon Inc. - Manta Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_TWISTEDMELON, 0x8042) },
|
2013-11-21 20:26:42 +00:00
|
|
|
/* Hauppauge WINTV-HVR-HVR 930C-HD - based on cx231xx */
|
|
|
|
{ USB_DEVICE(VENDOR_HAUPPAUGE, 0xb130),
|
|
|
|
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
|
2014-07-27 20:06:02 +00:00
|
|
|
{ USB_DEVICE(VENDOR_HAUPPAUGE, 0xb131),
|
|
|
|
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
|
2014-08-31 11:35:10 +00:00
|
|
|
{ USB_DEVICE(VENDOR_HAUPPAUGE, 0xb138),
|
|
|
|
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
|
|
|
|
{ USB_DEVICE(VENDOR_HAUPPAUGE, 0xb139),
|
|
|
|
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
|
2014-07-27 20:06:02 +00:00
|
|
|
{ USB_DEVICE(VENDOR_PCTV, 0x0259),
|
|
|
|
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
|
|
|
|
{ USB_DEVICE(VENDOR_PCTV, 0x025e),
|
|
|
|
.driver_info = HAUPPAUGE_CX_HYBRID_TV },
|
2016-03-17 13:11:09 +00:00
|
|
|
/* Adaptec / HP eHome Receiver */
|
|
|
|
{ USB_DEVICE(VENDOR_ADAPTEC, 0x0094) },
|
2017-10-28 13:38:16 +00:00
|
|
|
/* Evromedia USB Full Hybrid Full HD */
|
|
|
|
{ USB_DEVICE(0x1b80, 0xd3b2),
|
|
|
|
.driver_info = EVROMEDIA_FULL_HYBRID_FULLHD },
|
2017-10-28 13:38:18 +00:00
|
|
|
/* Astrometa T2hybrid */
|
|
|
|
{ USB_DEVICE(0x15f4, 0x0135),
|
|
|
|
.driver_info = ASTROMETA_T2HYBRID },
|
2014-07-27 20:06:02 +00:00
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Terminating entry */
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* data structure for each usb transceiver */
|
|
|
|
struct mceusb_dev {
|
|
|
|
/* ir-core bits */
|
2010-10-29 19:08:23 +00:00
|
|
|
struct rc_dev *rc;
|
2010-11-12 22:49:04 +00:00
|
|
|
|
|
|
|
/* optional features we can enable */
|
2018-03-16 19:52:09 +00:00
|
|
|
bool carrier_report_enabled;
|
|
|
|
bool wideband_rx_enabled; /* aka learning mode, short-range rx */
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* core device bits */
|
|
|
|
struct device *dev;
|
|
|
|
|
|
|
|
/* usb */
|
|
|
|
struct usb_device *usbdev;
|
|
|
|
struct urb *urb_in;
|
2017-03-26 18:28:08 +00:00
|
|
|
unsigned int pipe_in;
|
2010-06-01 20:32:08 +00:00
|
|
|
struct usb_endpoint_descriptor *usb_ep_out;
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
unsigned int pipe_out;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* buffers and dma */
|
|
|
|
unsigned char *buf_in;
|
|
|
|
unsigned int len_in;
|
2010-11-12 22:49:04 +00:00
|
|
|
dma_addr_t dma_in;
|
2010-10-22 04:35:44 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
CMD_HEADER = 0,
|
|
|
|
SUBCMD,
|
|
|
|
CMD_DATA,
|
|
|
|
PARSE_IRDATA,
|
|
|
|
} parser_state;
|
|
|
|
|
2010-11-12 22:49:04 +00:00
|
|
|
u8 cmd, rem; /* Remaining IR data bytes in packet */
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 connected:1;
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
u32 tx_mask_normal:1;
|
2010-06-01 20:32:08 +00:00
|
|
|
u32 microsoft_gen1:1;
|
2010-10-29 03:07:39 +00:00
|
|
|
u32 no_tx:1;
|
2018-03-16 19:52:09 +00:00
|
|
|
u32 rx2;
|
2010-06-01 20:32:08 +00:00
|
|
|
} flags;
|
|
|
|
|
2010-06-16 20:55:52 +00:00
|
|
|
/* transmit support */
|
|
|
|
u32 carrier;
|
|
|
|
unsigned char tx_mask;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
char name[128];
|
|
|
|
char phys[64];
|
2010-10-22 14:50:37 +00:00
|
|
|
enum mceusb_model_type model;
|
2011-07-18 19:54:24 +00:00
|
|
|
|
|
|
|
bool need_reset; /* flag to issue a device resume cmd */
|
[media] mceusb: query device for firmware emulator version
Supposedly, there are essentially three different classes of devices
that are compatible with Microsoft's specs. First are the "legacy"
devices, which are built using Microsoft-provided hardware specs and
firmware. Second are "emulator" devices, which are built using custom
hardware and firmware, written to emulate Microsoft's firmware. Third
are "port" devices, which have their own device driver and firmware,
which provides compatible data to higher levels of the stack.
>From what I can tell, things like nuvoton-cir and fintek-cir are
essentially "port" devices -- their raw IR buffer format is very similar
to that of the mceusb devices. Now, within the mceusb driver, we have
three different "generations", which at first, seemed like maybe they
mapped to emulator versions. Unfortuantely, every single device I have
responds "illegal command" to the query to get firmware emulator version
from the hardware, which means they're either all emulator version 1, or
they're legacy devices, and our different "generations" aren't at all
related here. Though in theory, its possible the gen1 devices are
"legacy" devices and the rest are emulator v1. There are some useful
features of the v2 interface I was hoping to play with, but alas...
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-18 19:54:25 +00:00
|
|
|
u8 emver; /* emulator interface version */
|
2011-07-18 19:54:26 +00:00
|
|
|
u8 num_txports; /* number of transmit ports */
|
|
|
|
u8 num_rxports; /* number of receive sensors */
|
|
|
|
u8 txports_cabled; /* bitmask of transmitters with cable */
|
|
|
|
u8 rxports_active; /* bitmask of active receive sensors */
|
2018-03-16 19:52:09 +00:00
|
|
|
bool learning_active; /* wideband rx is active */
|
|
|
|
|
|
|
|
/* receiver carrier frequency detection support */
|
|
|
|
u32 pulse_tunit; /* IR pulse "on" cumulative time units */
|
|
|
|
u32 pulse_count; /* pulse "on" count in measurement interval */
|
2017-03-26 18:28:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* support for async error handler mceusb_deferred_kevent()
|
|
|
|
* where usb_clear_halt(), usb_reset_configuration(),
|
|
|
|
* usb_reset_device(), etc. must be done in process context
|
|
|
|
*/
|
|
|
|
struct work_struct kevent;
|
|
|
|
unsigned long kevent_flags;
|
|
|
|
# define EVENT_TX_HALT 0
|
|
|
|
# define EVENT_RX_HALT 1
|
2010-06-01 20:32:08 +00:00
|
|
|
};
|
|
|
|
|
2011-07-18 19:54:21 +00:00
|
|
|
/* MCE Device Command Strings, generally a port and command pair */
|
|
|
|
static char DEVICE_RESUME[] = {MCE_CMD_NULL, MCE_CMD_PORT_SYS,
|
|
|
|
MCE_CMD_RESUME};
|
|
|
|
static char GET_REVISION[] = {MCE_CMD_PORT_SYS, MCE_CMD_G_REVISION};
|
[media] mceusb: query device for firmware emulator version
Supposedly, there are essentially three different classes of devices
that are compatible with Microsoft's specs. First are the "legacy"
devices, which are built using Microsoft-provided hardware specs and
firmware. Second are "emulator" devices, which are built using custom
hardware and firmware, written to emulate Microsoft's firmware. Third
are "port" devices, which have their own device driver and firmware,
which provides compatible data to higher levels of the stack.
>From what I can tell, things like nuvoton-cir and fintek-cir are
essentially "port" devices -- their raw IR buffer format is very similar
to that of the mceusb devices. Now, within the mceusb driver, we have
three different "generations", which at first, seemed like maybe they
mapped to emulator versions. Unfortuantely, every single device I have
responds "illegal command" to the query to get firmware emulator version
from the hardware, which means they're either all emulator version 1, or
they're legacy devices, and our different "generations" aren't at all
related here. Though in theory, its possible the gen1 devices are
"legacy" devices and the rest are emulator v1. There are some useful
features of the v2 interface I was hoping to play with, but alas...
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-18 19:54:25 +00:00
|
|
|
static char GET_EMVER[] = {MCE_CMD_PORT_SYS, MCE_CMD_GETEMVER};
|
2011-07-18 19:54:21 +00:00
|
|
|
static char GET_WAKEVERSION[] = {MCE_CMD_PORT_SYS, MCE_CMD_GETWAKEVERSION};
|
2011-07-18 19:54:27 +00:00
|
|
|
static char FLASH_LED[] = {MCE_CMD_PORT_SYS, MCE_CMD_FLASHLED};
|
2011-07-18 19:54:21 +00:00
|
|
|
static char GET_UNKNOWN2[] = {MCE_CMD_PORT_IR, MCE_CMD_UNKNOWN2};
|
|
|
|
static char GET_CARRIER_FREQ[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRCFS};
|
|
|
|
static char GET_RX_TIMEOUT[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRTIMEOUT};
|
2011-07-18 19:54:26 +00:00
|
|
|
static char GET_NUM_PORTS[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRNUMPORTS};
|
2011-07-18 19:54:21 +00:00
|
|
|
static char GET_TX_BITMASK[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRTXPORTS};
|
|
|
|
static char GET_RX_SENSOR[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRRXPORTEN};
|
2010-06-01 20:32:08 +00:00
|
|
|
/* sub in desired values in lower byte or bytes for full command */
|
|
|
|
/* FIXME: make use of these for transmit.
|
2011-07-18 19:54:21 +00:00
|
|
|
static char SET_CARRIER_FREQ[] = {MCE_CMD_PORT_IR,
|
|
|
|
MCE_CMD_SETIRCFS, 0x00, 0x00};
|
|
|
|
static char SET_TX_BITMASK[] = {MCE_CMD_PORT_IR, MCE_CMD_SETIRTXPORTS, 0x00};
|
|
|
|
static char SET_RX_TIMEOUT[] = {MCE_CMD_PORT_IR,
|
|
|
|
MCE_CMD_SETIRTIMEOUT, 0x00, 0x00};
|
|
|
|
static char SET_RX_SENSOR[] = {MCE_CMD_PORT_IR,
|
|
|
|
MCE_RSP_EQIRRXPORTEN, 0x00};
|
2010-06-01 20:32:08 +00:00
|
|
|
*/
|
|
|
|
|
2013-04-15 20:17:11 +00:00
|
|
|
static int mceusb_cmd_datasize(u8 cmd, u8 subcmd)
|
2010-10-22 04:35:44 +00:00
|
|
|
{
|
|
|
|
int datasize = 0;
|
|
|
|
|
|
|
|
switch (cmd) {
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_NULL:
|
|
|
|
if (subcmd == MCE_CMD_PORT_SYS)
|
2010-10-22 04:35:44 +00:00
|
|
|
datasize = 1;
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_PORT_SYS:
|
2010-10-22 04:35:44 +00:00
|
|
|
switch (subcmd) {
|
2013-04-15 20:17:11 +00:00
|
|
|
case MCE_RSP_GETPORTSTATUS:
|
|
|
|
datasize = 5;
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQWAKEVERSION:
|
|
|
|
datasize = 4;
|
|
|
|
break;
|
2010-10-22 17:42:54 +00:00
|
|
|
case MCE_CMD_G_REVISION:
|
2010-10-22 04:35:44 +00:00
|
|
|
datasize = 2;
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQWAKESUPPORT:
|
2013-04-15 20:17:11 +00:00
|
|
|
case MCE_RSP_GETWAKESOURCE:
|
|
|
|
case MCE_RSP_EQDEVDETAILS:
|
|
|
|
case MCE_RSP_EQEMVER:
|
2011-07-18 19:54:21 +00:00
|
|
|
datasize = 1;
|
|
|
|
break;
|
2010-10-22 04:35:44 +00:00
|
|
|
}
|
2018-05-10 11:49:49 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_PORT_IR:
|
2010-10-22 04:35:44 +00:00
|
|
|
switch (subcmd) {
|
2010-10-22 17:42:54 +00:00
|
|
|
case MCE_CMD_UNKNOWN:
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRCFS:
|
|
|
|
case MCE_RSP_EQIRTIMEOUT:
|
|
|
|
case MCE_RSP_EQIRRXCFCNT:
|
2013-04-15 20:17:11 +00:00
|
|
|
case MCE_RSP_EQIRNUMPORTS:
|
2010-10-22 04:35:44 +00:00
|
|
|
datasize = 2;
|
|
|
|
break;
|
2010-11-09 21:41:03 +00:00
|
|
|
case MCE_CMD_SIG_END:
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRTXPORTS:
|
|
|
|
case MCE_RSP_EQIRRXPORTEN:
|
2010-10-22 04:35:44 +00:00
|
|
|
datasize = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return datasize;
|
|
|
|
}
|
|
|
|
|
2017-08-04 09:30:20 +00:00
|
|
|
static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len,
|
|
|
|
int offset, int len, bool out)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
2014-01-20 22:10:44 +00:00
|
|
|
#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
|
|
|
|
char *inout;
|
2017-08-04 09:30:20 +00:00
|
|
|
u8 cmd, subcmd, *data;
|
2010-06-01 20:32:08 +00:00
|
|
|
struct device *dev = ir->dev;
|
2014-01-20 22:10:44 +00:00
|
|
|
int start, skip = 0;
|
2011-07-18 19:54:28 +00:00
|
|
|
u32 carrier, period;
|
2010-10-22 19:49:35 +00:00
|
|
|
|
2010-06-16 20:10:05 +00:00
|
|
|
/* skip meaningless 0xb1 0x60 header bytes on orig receiver */
|
2010-11-09 21:41:46 +00:00
|
|
|
if (ir->flags.microsoft_gen1 && !out && !offset)
|
2010-10-22 19:49:35 +00:00
|
|
|
skip = 2;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-10-22 19:49:35 +00:00
|
|
|
if (len <= skip)
|
2010-06-01 20:32:08 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "%cx data: %*ph (length=%d)",
|
2017-03-26 19:04:51 +00:00
|
|
|
(out ? 't' : 'r'),
|
|
|
|
min(len, buf_len - offset), buf + offset, len);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2014-01-20 22:10:44 +00:00
|
|
|
inout = out ? "Request" : "Got";
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-10-22 19:49:35 +00:00
|
|
|
start = offset + skip;
|
|
|
|
cmd = buf[start] & 0xff;
|
|
|
|
subcmd = buf[start + 1] & 0xff;
|
2017-08-04 09:30:20 +00:00
|
|
|
data = buf + start + 2;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_NULL:
|
2011-07-18 19:54:26 +00:00
|
|
|
if (subcmd == MCE_CMD_NULL)
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
if ((subcmd == MCE_CMD_PORT_SYS) &&
|
2017-08-04 09:30:20 +00:00
|
|
|
(data[0] == MCE_CMD_RESUME))
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Device resume requested");
|
2010-06-01 20:32:08 +00:00
|
|
|
else
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
|
2010-06-01 20:32:08 +00:00
|
|
|
cmd, subcmd);
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_PORT_SYS:
|
2010-06-01 20:32:08 +00:00
|
|
|
switch (subcmd) {
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQEMVER:
|
|
|
|
if (!out)
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Emulator interface version %x",
|
2017-08-04 09:30:20 +00:00
|
|
|
data[0]);
|
2011-07-18 19:54:21 +00:00
|
|
|
break;
|
2010-10-22 17:42:54 +00:00
|
|
|
case MCE_CMD_G_REVISION:
|
2010-06-01 20:32:08 +00:00
|
|
|
if (len == 2)
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Get hw/sw rev?");
|
2010-06-01 20:32:08 +00:00
|
|
|
else
|
2016-03-06 13:00:09 +00:00
|
|
|
dev_dbg(dev, "hw/sw rev %*ph",
|
|
|
|
4, &buf[start + 2]);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_RESUME:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Device resume requested");
|
2011-07-18 19:54:21 +00:00
|
|
|
break;
|
|
|
|
case MCE_RSP_CMD_ILLEGAL:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Illegal PORT_SYS command");
|
2011-07-18 19:54:21 +00:00
|
|
|
break;
|
|
|
|
case MCE_RSP_EQWAKEVERSION:
|
|
|
|
if (!out)
|
[media] rc: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-18 19:44:25 +00:00
|
|
|
dev_dbg(dev, "Wake version, proto: 0x%02x, payload: 0x%02x, address: 0x%02x, version: 0x%02x",
|
2017-08-04 09:30:20 +00:00
|
|
|
data[0], data[1], data[2], data[3]);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_GETPORTSTATUS:
|
|
|
|
if (!out)
|
|
|
|
/* We use data1 + 1 here, to match hw labels */
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "TX port %d: blaster is%s connected",
|
2017-08-04 09:30:20 +00:00
|
|
|
data[0] + 1, data[3] ? " not" : "");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:27 +00:00
|
|
|
case MCE_CMD_FLASHLED:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Attempting to flash LED");
|
2011-07-18 19:54:27 +00:00
|
|
|
break;
|
2010-06-01 20:32:08 +00:00
|
|
|
default:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
|
2010-06-01 20:32:08 +00:00
|
|
|
cmd, subcmd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_PORT_IR:
|
2010-06-01 20:32:08 +00:00
|
|
|
switch (subcmd) {
|
2010-11-09 21:41:03 +00:00
|
|
|
case MCE_CMD_SIG_END:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "End of signal");
|
2010-11-09 21:41:03 +00:00
|
|
|
break;
|
2010-10-22 17:42:54 +00:00
|
|
|
case MCE_CMD_PING:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Ping");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2010-10-22 17:42:54 +00:00
|
|
|
case MCE_CMD_UNKNOWN:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Resp to 9f 05 of 0x%02x 0x%02x",
|
2017-08-04 09:30:20 +00:00
|
|
|
data[0], data[1]);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:28 +00:00
|
|
|
case MCE_RSP_EQIRCFS:
|
2017-08-04 09:30:20 +00:00
|
|
|
period = DIV_ROUND_CLOSEST((1U << data[0] * 2) *
|
|
|
|
(data[1] + 1), 10);
|
2011-07-18 19:54:28 +00:00
|
|
|
if (!period)
|
|
|
|
break;
|
|
|
|
carrier = (1000 * 1000) / period;
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "%s carrier of %u Hz (period %uus)",
|
2011-07-18 19:54:28 +00:00
|
|
|
inout, carrier, period);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_GETIRCFS:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Get carrier mode and freq");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRTXPORTS:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "%s transmit blaster mask of 0x%02x",
|
2017-08-04 09:30:20 +00:00
|
|
|
inout, data[0]);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRTIMEOUT:
|
2011-07-03 20:13:52 +00:00
|
|
|
/* value is in units of 50us, so x*50/1000 ms */
|
2017-08-04 09:30:20 +00:00
|
|
|
period = ((data[0] << 8) | data[1]) *
|
|
|
|
MCE_TIME_UNIT / 1000;
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "%s receive timeout of %d ms",
|
2011-07-18 19:54:28 +00:00
|
|
|
inout, period);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_GETIRTIMEOUT:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Get receive timeout");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_GETIRTXPORTS:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Get transmit blaster mask");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRRXPORTEN:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "%s %s-range receive sensor in use",
|
2017-08-04 09:30:20 +00:00
|
|
|
inout, data[0] == 0x02 ? "short" : "long");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_CMD_GETIRRXPORTEN:
|
|
|
|
/* aka MCE_RSP_EQIRRXCFCNT */
|
2010-11-12 22:49:04 +00:00
|
|
|
if (out)
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Get receive sensor");
|
2018-03-16 19:52:09 +00:00
|
|
|
else
|
|
|
|
dev_dbg(dev, "RX carrier cycle count: %d",
|
2017-08-04 09:30:20 +00:00
|
|
|
((data[0] << 8) | data[1]));
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRNUMPORTS:
|
|
|
|
if (out)
|
|
|
|
break;
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Num TX ports: %x, num RX ports: %x",
|
2017-08-04 09:30:20 +00:00
|
|
|
data[0], data[1]);
|
2011-07-18 19:54:21 +00:00
|
|
|
break;
|
|
|
|
case MCE_RSP_CMD_ILLEGAL:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Illegal PORT_IR command");
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
|
2010-06-01 20:32:08 +00:00
|
|
|
cmd, subcmd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-10-22 19:49:35 +00:00
|
|
|
|
|
|
|
if (cmd == MCE_IRDATA_TRAILER)
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "End of raw IR data");
|
2011-07-18 19:54:21 +00:00
|
|
|
else if ((cmd != MCE_CMD_PORT_IR) &&
|
|
|
|
((cmd & MCE_PORT_MASK) == MCE_COMMAND_IRDATA))
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "Raw IR data, %d pulse/space samples", ir->rem);
|
|
|
|
#endif
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-26 18:28:08 +00:00
|
|
|
/*
|
|
|
|
* Schedule work that can't be done in interrupt handlers
|
|
|
|
* (mceusb_dev_recv() and mce_async_callback()) nor tasklets.
|
|
|
|
* Invokes mceusb_deferred_kevent() for recovering from
|
|
|
|
* error events specified by the kevent bit field.
|
|
|
|
*/
|
|
|
|
static void mceusb_defer_kevent(struct mceusb_dev *ir, int kevent)
|
|
|
|
{
|
|
|
|
set_bit(kevent, &ir->kevent_flags);
|
|
|
|
if (!schedule_work(&ir->kevent))
|
|
|
|
dev_err(ir->dev, "kevent %d may have been dropped", kevent);
|
|
|
|
else
|
|
|
|
dev_dbg(ir->dev, "kevent %d scheduled", kevent);
|
|
|
|
}
|
|
|
|
|
2012-07-15 16:31:31 +00:00
|
|
|
static void mce_async_callback(struct urb *urb)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
|
|
|
struct mceusb_dev *ir;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!urb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ir = urb->context;
|
2014-01-20 22:10:44 +00:00
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
/* success */
|
|
|
|
case 0:
|
2010-06-01 20:32:08 +00:00
|
|
|
len = urb->actual_length;
|
|
|
|
|
2017-03-26 19:04:51 +00:00
|
|
|
mceusb_dev_printdata(ir, urb->transfer_buffer, len,
|
|
|
|
0, len, true);
|
2014-01-20 22:10:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ENOENT:
|
|
|
|
case -EILSEQ:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -EPIPE:
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
dev_err(ir->dev, "Error: request urb status = %d (TX HALT)",
|
|
|
|
urb->status);
|
|
|
|
mceusb_defer_kevent(ir, EVENT_TX_HALT);
|
|
|
|
break;
|
|
|
|
|
2014-01-20 22:10:44 +00:00
|
|
|
default:
|
|
|
|
dev_err(ir->dev, "Error: request urb status = %d", urb->status);
|
|
|
|
break;
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2011-05-24 19:44:54 +00:00
|
|
|
/* the transfer buffer and urb were allocated in mce_request_packet */
|
|
|
|
kfree(urb->transfer_buffer);
|
|
|
|
usb_free_urb(urb);
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-26 19:04:51 +00:00
|
|
|
/* request outgoing (send) usb packet - used to initialize remote */
|
2011-05-10 17:09:59 +00:00
|
|
|
static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data,
|
2016-04-14 20:42:50 +00:00
|
|
|
int size)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
int res;
|
2010-06-01 20:32:08 +00:00
|
|
|
struct urb *async_urb;
|
|
|
|
struct device *dev = ir->dev;
|
|
|
|
unsigned char *async_buf;
|
|
|
|
|
2016-04-14 20:42:50 +00:00
|
|
|
async_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (unlikely(!async_urb)) {
|
2017-03-26 19:04:51 +00:00
|
|
|
dev_err(dev, "Error, couldn't allocate urb!");
|
2016-04-14 20:42:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2016-04-14 20:42:50 +00:00
|
|
|
async_buf = kmalloc(size, GFP_KERNEL);
|
|
|
|
if (!async_buf) {
|
|
|
|
usb_free_urb(async_urb);
|
|
|
|
return;
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2016-04-14 20:42:50 +00:00
|
|
|
/* outbound data */
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
if (usb_endpoint_xfer_int(ir->usb_ep_out))
|
|
|
|
usb_fill_int_urb(async_urb, ir->usbdev, ir->pipe_out,
|
|
|
|
async_buf, size, mce_async_callback, ir,
|
2016-04-14 20:42:50 +00:00
|
|
|
ir->usb_ep_out->bInterval);
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
else
|
|
|
|
usb_fill_bulk_urb(async_urb, ir->usbdev, ir->pipe_out,
|
|
|
|
async_buf, size, mce_async_callback, ir);
|
|
|
|
|
2016-04-14 20:42:50 +00:00
|
|
|
memcpy(async_buf, data, size);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2017-03-26 19:04:51 +00:00
|
|
|
dev_dbg(dev, "send request called (size=%#x)", size);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
res = usb_submit_urb(async_urb, GFP_ATOMIC);
|
|
|
|
if (res) {
|
2017-03-26 19:04:51 +00:00
|
|
|
dev_err(dev, "send request FAILED! (res=%d)", res);
|
2017-06-01 07:45:59 +00:00
|
|
|
kfree(async_buf);
|
|
|
|
usb_free_urb(async_urb);
|
2010-06-01 20:32:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-03-26 19:04:51 +00:00
|
|
|
dev_dbg(dev, "send request complete (res=%d)", res);
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
|
|
|
|
{
|
2011-07-18 19:54:24 +00:00
|
|
|
int rsize = sizeof(DEVICE_RESUME);
|
|
|
|
|
|
|
|
if (ir->need_reset) {
|
|
|
|
ir->need_reset = false;
|
2016-04-14 20:42:50 +00:00
|
|
|
mce_request_packet(ir, DEVICE_RESUME, rsize);
|
2011-07-18 19:54:24 +00:00
|
|
|
msleep(10);
|
|
|
|
}
|
|
|
|
|
2016-04-14 20:42:50 +00:00
|
|
|
mce_request_packet(ir, data, size);
|
2011-07-18 19:54:22 +00:00
|
|
|
msleep(10);
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2010-06-16 20:55:52 +00:00
|
|
|
/* Send data out the IR blaster port(s) */
|
2011-04-28 15:13:58 +00:00
|
|
|
static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
|
2010-06-16 20:55:52 +00:00
|
|
|
{
|
2010-10-29 19:08:23 +00:00
|
|
|
struct mceusb_dev *ir = dev->priv;
|
2013-01-29 11:19:30 +00:00
|
|
|
int i, length, ret = 0;
|
2011-04-28 15:13:58 +00:00
|
|
|
int cmdcount = 0;
|
2013-01-29 11:19:30 +00:00
|
|
|
unsigned char cmdbuf[MCE_CMDBUF_SIZE];
|
2010-06-16 20:55:52 +00:00
|
|
|
|
|
|
|
/* MCE tx init header */
|
2011-07-18 19:54:21 +00:00
|
|
|
cmdbuf[cmdcount++] = MCE_CMD_PORT_IR;
|
|
|
|
cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS;
|
2010-06-16 20:55:52 +00:00
|
|
|
cmdbuf[cmdcount++] = ir->tx_mask;
|
|
|
|
|
2013-01-29 11:19:30 +00:00
|
|
|
/* Send the set TX ports command */
|
|
|
|
mce_async_out(ir, cmdbuf, cmdcount);
|
|
|
|
cmdcount = 0;
|
|
|
|
|
2010-06-16 20:55:52 +00:00
|
|
|
/* Generate mce packet data */
|
|
|
|
for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) {
|
|
|
|
txbuf[i] = txbuf[i] / MCE_TIME_UNIT;
|
|
|
|
|
|
|
|
do { /* loop to support long pulses/spaces > 127*50us=6.35ms */
|
|
|
|
|
|
|
|
/* Insert mce packet header every 4th entry */
|
|
|
|
if ((cmdcount < MCE_CMDBUF_SIZE) &&
|
2013-01-29 11:19:30 +00:00
|
|
|
(cmdcount % MCE_CODE_LENGTH) == 0)
|
2010-10-22 17:42:54 +00:00
|
|
|
cmdbuf[cmdcount++] = MCE_IRDATA_HEADER;
|
2010-06-16 20:55:52 +00:00
|
|
|
|
|
|
|
/* Insert mce packet data */
|
|
|
|
if (cmdcount < MCE_CMDBUF_SIZE)
|
|
|
|
cmdbuf[cmdcount++] =
|
|
|
|
(txbuf[i] < MCE_PULSE_BIT ?
|
|
|
|
txbuf[i] : MCE_MAX_PULSE_LENGTH) |
|
|
|
|
(i & 1 ? 0x00 : MCE_PULSE_BIT);
|
|
|
|
else {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
} while ((txbuf[i] > MCE_MAX_PULSE_LENGTH) &&
|
|
|
|
(txbuf[i] -= MCE_MAX_PULSE_LENGTH));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we have room for the empty packet at the end */
|
|
|
|
if (cmdcount >= MCE_CMDBUF_SIZE) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-02-12 11:22:08 +00:00
|
|
|
/* Fix packet length in last header */
|
|
|
|
length = cmdcount % MCE_CODE_LENGTH;
|
|
|
|
cmdbuf[cmdcount - length] -= MCE_CODE_LENGTH - length;
|
|
|
|
|
2010-06-16 20:55:52 +00:00
|
|
|
/* All mce commands end with an empty packet (0x80) */
|
2010-10-22 17:42:54 +00:00
|
|
|
cmdbuf[cmdcount++] = MCE_IRDATA_TRAILER;
|
2010-06-16 20:55:52 +00:00
|
|
|
|
|
|
|
/* Transmit the command to the mce device */
|
|
|
|
mce_async_out(ir, cmdbuf, cmdcount);
|
|
|
|
|
|
|
|
out:
|
2011-04-28 15:13:58 +00:00
|
|
|
return ret ? ret : count;
|
2010-06-16 20:55:52 +00:00
|
|
|
}
|
|
|
|
|
2010-10-29 03:07:39 +00:00
|
|
|
/* Sets active IR outputs -- mce devices typically have two */
|
2010-10-29 19:08:23 +00:00
|
|
|
static int mceusb_set_tx_mask(struct rc_dev *dev, u32 mask)
|
2010-06-16 20:10:05 +00:00
|
|
|
{
|
2010-10-29 19:08:23 +00:00
|
|
|
struct mceusb_dev *ir = dev->priv;
|
2010-06-16 20:10:05 +00:00
|
|
|
|
2016-07-10 16:34:32 +00:00
|
|
|
/* return number of transmitters */
|
|
|
|
int emitters = ir->num_txports ? ir->num_txports : 2;
|
|
|
|
|
|
|
|
if (mask >= (1 << emitters))
|
|
|
|
return emitters;
|
|
|
|
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
if (ir->flags.tx_mask_normal)
|
|
|
|
ir->tx_mask = mask;
|
|
|
|
else
|
2010-10-22 17:42:54 +00:00
|
|
|
ir->tx_mask = (mask != MCE_DEFAULT_TX_MASK ?
|
|
|
|
mask ^ MCE_DEFAULT_TX_MASK : mask) << 1;
|
2010-06-16 20:10:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-16 20:55:52 +00:00
|
|
|
/* Sets the send carrier frequency and mode */
|
2010-10-29 19:08:23 +00:00
|
|
|
static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
|
2010-06-16 20:55:52 +00:00
|
|
|
{
|
2010-10-29 19:08:23 +00:00
|
|
|
struct mceusb_dev *ir = dev->priv;
|
2010-06-16 20:55:52 +00:00
|
|
|
int clk = 10000000;
|
|
|
|
int prescaler = 0, divisor = 0;
|
2011-07-18 19:54:21 +00:00
|
|
|
unsigned char cmdbuf[4] = { MCE_CMD_PORT_IR,
|
|
|
|
MCE_CMD_SETIRCFS, 0x00, 0x00 };
|
2010-06-16 20:55:52 +00:00
|
|
|
|
|
|
|
/* Carrier has changed */
|
|
|
|
if (ir->carrier != carrier) {
|
|
|
|
|
|
|
|
if (carrier == 0) {
|
|
|
|
ir->carrier = carrier;
|
2010-11-09 21:41:03 +00:00
|
|
|
cmdbuf[2] = MCE_CMD_SIG_END;
|
2010-10-22 17:42:54 +00:00
|
|
|
cmdbuf[3] = MCE_IRDATA_TRAILER;
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(ir->dev, "disabling carrier modulation");
|
2010-06-16 20:55:52 +00:00
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
2016-12-02 17:16:07 +00:00
|
|
|
return 0;
|
2010-06-16 20:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (prescaler = 0; prescaler < 4; ++prescaler) {
|
|
|
|
divisor = (clk >> (2 * prescaler)) / carrier;
|
2010-10-22 17:42:54 +00:00
|
|
|
if (divisor <= 0xff) {
|
2010-06-16 20:55:52 +00:00
|
|
|
ir->carrier = carrier;
|
|
|
|
cmdbuf[2] = prescaler;
|
|
|
|
cmdbuf[3] = divisor;
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(ir->dev, "requesting %u HZ carrier",
|
|
|
|
carrier);
|
2010-06-16 20:55:52 +00:00
|
|
|
|
|
|
|
/* Transmit new carrier to mce device */
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
2016-12-02 17:16:07 +00:00
|
|
|
return 0;
|
2010-06-16 20:55:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-10 16:34:33 +00:00
|
|
|
return 0;
|
2010-06-16 20:55:52 +00:00
|
|
|
}
|
|
|
|
|
2018-04-08 15:06:49 +00:00
|
|
|
static int mceusb_set_timeout(struct rc_dev *dev, unsigned int timeout)
|
|
|
|
{
|
|
|
|
u8 cmdbuf[4] = { MCE_CMD_PORT_IR, MCE_CMD_SETIRTIMEOUT, 0, 0 };
|
|
|
|
struct mceusb_dev *ir = dev->priv;
|
|
|
|
unsigned int units;
|
|
|
|
|
|
|
|
units = DIV_ROUND_CLOSEST(timeout, US_TO_NS(MCE_TIME_UNIT));
|
|
|
|
|
|
|
|
cmdbuf[2] = units >> 8;
|
|
|
|
cmdbuf[3] = units;
|
|
|
|
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
|
|
|
|
/* get receiver timeout value */
|
|
|
|
mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-16 19:52:09 +00:00
|
|
|
/*
|
|
|
|
* Select or deselect the 2nd receiver port.
|
|
|
|
* Second receiver is learning mode, wide-band, short-range receiver.
|
|
|
|
* Only one receiver (long or short range) may be active at a time.
|
|
|
|
*/
|
|
|
|
static int mceusb_set_rx_wideband(struct rc_dev *dev, int enable)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir = dev->priv;
|
|
|
|
unsigned char cmdbuf[3] = { MCE_CMD_PORT_IR,
|
|
|
|
MCE_CMD_SETIRRXPORTEN, 0x00 };
|
|
|
|
|
|
|
|
dev_dbg(ir->dev, "select %s-range receive sensor",
|
|
|
|
enable ? "short" : "long");
|
|
|
|
if (enable) {
|
|
|
|
ir->wideband_rx_enabled = true;
|
|
|
|
cmdbuf[2] = 2; /* port 2 is short range receiver */
|
|
|
|
} else {
|
|
|
|
ir->wideband_rx_enabled = false;
|
|
|
|
cmdbuf[2] = 1; /* port 1 is long range receiver */
|
|
|
|
}
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
/* response from device sets ir->learning_active */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable/disable receiver carrier frequency pass through reporting.
|
|
|
|
* Only the short-range receiver has carrier frequency measuring capability.
|
|
|
|
* Implicitly select this receiver when enabling carrier frequency reporting.
|
|
|
|
*/
|
|
|
|
static int mceusb_set_rx_carrier_report(struct rc_dev *dev, int enable)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir = dev->priv;
|
|
|
|
unsigned char cmdbuf[3] = { MCE_CMD_PORT_IR,
|
|
|
|
MCE_CMD_SETIRRXPORTEN, 0x00 };
|
|
|
|
|
|
|
|
dev_dbg(ir->dev, "%s short-range receiver carrier reporting",
|
|
|
|
enable ? "enable" : "disable");
|
|
|
|
if (enable) {
|
|
|
|
ir->carrier_report_enabled = true;
|
|
|
|
if (!ir->learning_active) {
|
|
|
|
cmdbuf[2] = 2; /* port 2 is short range receiver */
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ir->carrier_report_enabled = false;
|
|
|
|
/*
|
|
|
|
* Revert to normal (long-range) receiver only if the
|
|
|
|
* wideband (short-range) receiver wasn't explicitly
|
|
|
|
* enabled.
|
|
|
|
*/
|
|
|
|
if (ir->learning_active && !ir->wideband_rx_enabled) {
|
|
|
|
cmdbuf[2] = 1; /* port 1 is long range receiver */
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-12 22:49:04 +00:00
|
|
|
/*
|
|
|
|
* We don't do anything but print debug spew for many of the command bits
|
|
|
|
* we receive from the hardware, but some of them are useful information
|
|
|
|
* we want to store so that we can use them.
|
|
|
|
*/
|
|
|
|
static void mceusb_handle_command(struct mceusb_dev *ir, int index)
|
|
|
|
{
|
2018-03-16 19:52:09 +00:00
|
|
|
DEFINE_IR_RAW_EVENT(rawir);
|
2010-11-12 22:49:04 +00:00
|
|
|
u8 hi = ir->buf_in[index + 1] & 0xff;
|
|
|
|
u8 lo = ir->buf_in[index + 2] & 0xff;
|
2018-03-16 19:52:09 +00:00
|
|
|
u32 carrier_cycles;
|
|
|
|
u32 cycles_fix;
|
2010-11-12 22:49:04 +00:00
|
|
|
|
|
|
|
switch (ir->buf_in[index]) {
|
2011-07-18 19:54:26 +00:00
|
|
|
/* the one and only 5-byte return value command */
|
|
|
|
case MCE_RSP_GETPORTSTATUS:
|
|
|
|
if ((ir->buf_in[index + 4] & 0xff) == 0x00)
|
|
|
|
ir->txports_cabled |= 1 << hi;
|
|
|
|
break;
|
|
|
|
|
2010-11-12 22:49:04 +00:00
|
|
|
/* 2-byte return value commands */
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRTIMEOUT:
|
2011-07-03 20:13:52 +00:00
|
|
|
ir->rc->timeout = US_TO_NS((hi << 8 | lo) * MCE_TIME_UNIT);
|
2010-11-12 22:49:04 +00:00
|
|
|
break;
|
2011-07-18 19:54:26 +00:00
|
|
|
case MCE_RSP_EQIRNUMPORTS:
|
|
|
|
ir->num_txports = hi;
|
|
|
|
ir->num_rxports = lo;
|
|
|
|
break;
|
2018-03-16 19:52:09 +00:00
|
|
|
case MCE_RSP_EQIRRXCFCNT:
|
|
|
|
/*
|
|
|
|
* The carrier cycle counter can overflow and wrap around
|
|
|
|
* without notice from the device. So frequency measurement
|
|
|
|
* will be inaccurate with long duration IR.
|
|
|
|
*
|
|
|
|
* The long-range (non learning) receiver always reports
|
|
|
|
* zero count so we always ignore its report.
|
|
|
|
*/
|
|
|
|
if (ir->carrier_report_enabled && ir->learning_active &&
|
|
|
|
ir->pulse_tunit > 0) {
|
|
|
|
carrier_cycles = (hi << 8 | lo);
|
|
|
|
/*
|
|
|
|
* Adjust carrier cycle count by adding
|
|
|
|
* 1 missed count per pulse "on"
|
|
|
|
*/
|
|
|
|
cycles_fix = ir->flags.rx2 == 2 ? ir->pulse_count : 0;
|
|
|
|
rawir.carrier_report = 1;
|
|
|
|
rawir.carrier = (1000000u / MCE_TIME_UNIT) *
|
|
|
|
(carrier_cycles + cycles_fix) /
|
|
|
|
ir->pulse_tunit;
|
|
|
|
dev_dbg(ir->dev, "RX carrier frequency %u Hz (pulse count = %u, cycles = %u, duration = %u, rx2 = %u)",
|
|
|
|
rawir.carrier, ir->pulse_count, carrier_cycles,
|
|
|
|
ir->pulse_tunit, ir->flags.rx2);
|
|
|
|
ir_raw_event_store(ir->rc, &rawir);
|
|
|
|
}
|
|
|
|
break;
|
2010-11-12 22:49:04 +00:00
|
|
|
|
|
|
|
/* 1-byte return value commands */
|
[media] mceusb: query device for firmware emulator version
Supposedly, there are essentially three different classes of devices
that are compatible with Microsoft's specs. First are the "legacy"
devices, which are built using Microsoft-provided hardware specs and
firmware. Second are "emulator" devices, which are built using custom
hardware and firmware, written to emulate Microsoft's firmware. Third
are "port" devices, which have their own device driver and firmware,
which provides compatible data to higher levels of the stack.
>From what I can tell, things like nuvoton-cir and fintek-cir are
essentially "port" devices -- their raw IR buffer format is very similar
to that of the mceusb devices. Now, within the mceusb driver, we have
three different "generations", which at first, seemed like maybe they
mapped to emulator versions. Unfortuantely, every single device I have
responds "illegal command" to the query to get firmware emulator version
from the hardware, which means they're either all emulator version 1, or
they're legacy devices, and our different "generations" aren't at all
related here. Though in theory, its possible the gen1 devices are
"legacy" devices and the rest are emulator v1. There are some useful
features of the v2 interface I was hoping to play with, but alas...
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-18 19:54:25 +00:00
|
|
|
case MCE_RSP_EQEMVER:
|
|
|
|
ir->emver = hi;
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRTXPORTS:
|
2010-11-12 22:49:04 +00:00
|
|
|
ir->tx_mask = hi;
|
|
|
|
break;
|
2011-07-18 19:54:21 +00:00
|
|
|
case MCE_RSP_EQIRRXPORTEN:
|
2018-03-16 19:52:09 +00:00
|
|
|
ir->learning_active = ((hi & 0x02) == 0x02);
|
|
|
|
if (ir->rxports_active != hi) {
|
|
|
|
dev_info(ir->dev, "%s-range (0x%x) receiver active",
|
|
|
|
ir->learning_active ? "short" : "long", hi);
|
|
|
|
ir->rxports_active = hi;
|
|
|
|
}
|
2010-11-12 22:49:04 +00:00
|
|
|
break;
|
2011-07-18 19:54:24 +00:00
|
|
|
case MCE_RSP_CMD_ILLEGAL:
|
|
|
|
ir->need_reset = true;
|
|
|
|
break;
|
2010-11-12 22:49:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
|
|
|
|
{
|
2010-10-16 22:56:28 +00:00
|
|
|
DEFINE_IR_RAW_EVENT(rawir);
|
2012-08-13 11:59:47 +00:00
|
|
|
bool event = false;
|
2010-10-22 04:35:44 +00:00
|
|
|
int i = 0;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* skip meaningless 0xb1 0x60 header bytes on orig receiver */
|
|
|
|
if (ir->flags.microsoft_gen1)
|
2010-10-22 04:35:44 +00:00
|
|
|
i = 2;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-11-09 21:41:46 +00:00
|
|
|
/* if there's no data, just return now */
|
|
|
|
if (buf_len <= i)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 04:35:44 +00:00
|
|
|
for (; i < buf_len; i++) {
|
|
|
|
switch (ir->parser_state) {
|
|
|
|
case SUBCMD:
|
2013-04-15 20:17:11 +00:00
|
|
|
ir->rem = mceusb_cmd_datasize(ir->cmd, ir->buf_in[i]);
|
2017-03-26 19:04:51 +00:00
|
|
|
mceusb_dev_printdata(ir, ir->buf_in, buf_len, i - 1,
|
2010-10-22 19:49:35 +00:00
|
|
|
ir->rem + 2, false);
|
2010-11-12 22:49:04 +00:00
|
|
|
mceusb_handle_command(ir, i);
|
2010-10-22 04:35:44 +00:00
|
|
|
ir->parser_state = CMD_DATA;
|
|
|
|
break;
|
|
|
|
case PARSE_IRDATA:
|
2010-06-01 20:32:08 +00:00
|
|
|
ir->rem--;
|
2011-01-26 15:20:09 +00:00
|
|
|
init_ir_raw_event(&rawir);
|
2010-06-01 20:32:08 +00:00
|
|
|
rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0);
|
2018-03-16 19:52:09 +00:00
|
|
|
rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK);
|
2018-05-10 11:37:51 +00:00
|
|
|
if (unlikely(!rawir.duration)) {
|
|
|
|
dev_warn(ir->dev, "nonsensical irdata %02x with duration 0",
|
|
|
|
ir->buf_in[i]);
|
|
|
|
break;
|
|
|
|
}
|
2018-03-16 19:52:09 +00:00
|
|
|
if (rawir.pulse) {
|
|
|
|
ir->pulse_tunit += rawir.duration;
|
|
|
|
ir->pulse_count++;
|
|
|
|
}
|
|
|
|
rawir.duration *= US_TO_NS(MCE_TIME_UNIT);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2018-03-16 19:52:09 +00:00
|
|
|
dev_dbg(ir->dev, "Storing %s %u ns (%02x)",
|
2010-06-01 20:32:08 +00:00
|
|
|
rawir.pulse ? "pulse" : "space",
|
2018-03-16 19:52:09 +00:00
|
|
|
rawir.duration, ir->buf_in[i]);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2012-08-13 11:59:47 +00:00
|
|
|
if (ir_raw_event_store_with_filter(ir->rc, &rawir))
|
|
|
|
event = true;
|
2010-10-22 04:35:44 +00:00
|
|
|
break;
|
|
|
|
case CMD_DATA:
|
|
|
|
ir->rem--;
|
|
|
|
break;
|
|
|
|
case CMD_HEADER:
|
|
|
|
/* decode mce packets of the form (84),AA,BB,CC,DD */
|
|
|
|
/* IR data packets can span USB messages - rem */
|
|
|
|
ir->cmd = ir->buf_in[i];
|
2011-07-18 19:54:21 +00:00
|
|
|
if ((ir->cmd == MCE_CMD_PORT_IR) ||
|
|
|
|
((ir->cmd & MCE_PORT_MASK) !=
|
2010-10-22 17:42:54 +00:00
|
|
|
MCE_COMMAND_IRDATA)) {
|
2010-10-22 04:35:44 +00:00
|
|
|
ir->parser_state = SUBCMD;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK);
|
2017-03-26 19:04:51 +00:00
|
|
|
mceusb_dev_printdata(ir, ir->buf_in, buf_len,
|
2010-11-12 22:49:04 +00:00
|
|
|
i, ir->rem + 1, false);
|
2018-03-16 19:52:09 +00:00
|
|
|
if (ir->rem) {
|
2010-10-22 04:35:44 +00:00
|
|
|
ir->parser_state = PARSE_IRDATA;
|
2018-03-16 19:52:09 +00:00
|
|
|
} else {
|
2018-04-18 09:36:25 +00:00
|
|
|
init_ir_raw_event(&rawir);
|
|
|
|
rawir.timeout = 1;
|
|
|
|
rawir.duration = ir->rc->timeout;
|
|
|
|
if (ir_raw_event_store_with_filter(ir->rc,
|
|
|
|
&rawir))
|
|
|
|
event = true;
|
2018-03-16 19:52:09 +00:00
|
|
|
ir->pulse_tunit = 0;
|
|
|
|
ir->pulse_count = 0;
|
|
|
|
}
|
2010-10-22 04:35:44 +00:00
|
|
|
break;
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 04:35:44 +00:00
|
|
|
if (ir->parser_state != CMD_HEADER && !ir->rem)
|
|
|
|
ir->parser_state = CMD_HEADER;
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
2012-08-13 11:59:47 +00:00
|
|
|
if (event) {
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(ir->dev, "processed IR data");
|
2012-08-13 11:59:47 +00:00
|
|
|
ir_raw_event_handle(ir->rc);
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2012-07-15 16:31:31 +00:00
|
|
|
static void mceusb_dev_recv(struct urb *urb)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
|
|
|
struct mceusb_dev *ir;
|
|
|
|
|
|
|
|
if (!urb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ir = urb->context;
|
|
|
|
if (!ir) {
|
|
|
|
usb_unlink_urb(urb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
/* success */
|
|
|
|
case 0:
|
2016-04-14 20:42:49 +00:00
|
|
|
mceusb_process_ir_data(ir, urb->actual_length);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ENOENT:
|
2014-01-20 22:10:44 +00:00
|
|
|
case -EILSEQ:
|
2010-06-01 20:32:08 +00:00
|
|
|
case -ESHUTDOWN:
|
|
|
|
usb_unlink_urb(urb);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case -EPIPE:
|
2017-03-26 18:28:08 +00:00
|
|
|
dev_err(ir->dev, "Error: urb status = %d (RX HALT)",
|
|
|
|
urb->status);
|
|
|
|
mceusb_defer_kevent(ir, EVENT_RX_HALT);
|
|
|
|
return;
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
default:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_err(ir->dev, "Error: urb status = %d", urb->status);
|
2010-06-01 20:32:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
}
|
|
|
|
|
[media] mceusb: query device for firmware emulator version
Supposedly, there are essentially three different classes of devices
that are compatible with Microsoft's specs. First are the "legacy"
devices, which are built using Microsoft-provided hardware specs and
firmware. Second are "emulator" devices, which are built using custom
hardware and firmware, written to emulate Microsoft's firmware. Third
are "port" devices, which have their own device driver and firmware,
which provides compatible data to higher levels of the stack.
>From what I can tell, things like nuvoton-cir and fintek-cir are
essentially "port" devices -- their raw IR buffer format is very similar
to that of the mceusb devices. Now, within the mceusb driver, we have
three different "generations", which at first, seemed like maybe they
mapped to emulator versions. Unfortuantely, every single device I have
responds "illegal command" to the query to get firmware emulator version
from the hardware, which means they're either all emulator version 1, or
they're legacy devices, and our different "generations" aren't at all
related here. Though in theory, its possible the gen1 devices are
"legacy" devices and the rest are emulator v1. There are some useful
features of the v2 interface I was hoping to play with, but alas...
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-18 19:54:25 +00:00
|
|
|
static void mceusb_get_emulator_version(struct mceusb_dev *ir)
|
|
|
|
{
|
|
|
|
/* If we get no reply or an illegal command reply, its ver 1, says MS */
|
|
|
|
ir->emver = 1;
|
|
|
|
mce_async_out(ir, GET_EMVER, sizeof(GET_EMVER));
|
|
|
|
}
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
static void mceusb_gen1_init(struct mceusb_dev *ir)
|
|
|
|
{
|
2010-07-10 14:19:42 +00:00
|
|
|
int ret;
|
2010-06-01 20:32:08 +00:00
|
|
|
struct device *dev = ir->dev;
|
2010-07-04 01:42:14 +00:00
|
|
|
char *data;
|
2010-06-16 20:10:05 +00:00
|
|
|
|
|
|
|
data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
|
|
|
|
if (!data) {
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_err(dev, "%s: memory allocation failed!", __func__);
|
2010-06-16 20:10:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/*
|
2010-07-04 01:42:14 +00:00
|
|
|
* This is a strange one. Windows issues a set address to the device
|
2010-06-01 20:32:08 +00:00
|
|
|
* on the receive control pipe and expect a certain value pair back
|
|
|
|
*/
|
|
|
|
ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
|
|
|
|
USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
|
2010-06-16 20:10:05 +00:00
|
|
|
data, USB_CTRL_MSG_SZ, HZ * 3);
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "set address - ret = %d", ret);
|
|
|
|
dev_dbg(dev, "set address - data[0] = %d, data[1] = %d",
|
|
|
|
data[0], data[1]);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* set feature: bit rate 38400 bps */
|
|
|
|
ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
|
|
|
|
USB_REQ_SET_FEATURE, USB_TYPE_VENDOR,
|
|
|
|
0xc04e, 0x0000, NULL, 0, HZ * 3);
|
|
|
|
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "set feature - ret = %d", ret);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* bRequest 4: set char length to 8 bits */
|
|
|
|
ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
|
|
|
|
4, USB_TYPE_VENDOR,
|
|
|
|
0x0808, 0x0000, NULL, 0, HZ * 3);
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "set char length - retB = %d", ret);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* bRequest 2: set handshaking to use DTR/DSR */
|
|
|
|
ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
|
|
|
|
2, USB_TYPE_VENDOR,
|
|
|
|
0x0000, 0x0100, NULL, 0, HZ * 3);
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(dev, "set handshake - retC = %d", ret);
|
2010-06-16 20:10:05 +00:00
|
|
|
|
2011-07-18 19:54:21 +00:00
|
|
|
/* device resume */
|
|
|
|
mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME));
|
V4L/DVB: IR/mceusb: more streamlining of device init
Spent a while last night getting device initialization packet captures
under Windows for all generations of devices. There are a few places
where we were doing things differently, and few things we were doing
that we don't need to do, particularly on gen3 hardware, and I *think*
one of those things is what was locking up my pinnacle hw from time to
time -- at least, its been perfectly well behaved every time its been
plugged in since making this change.
First up, we're adding a bit more to the gen1 init routine here. Its
not absolutely necessary, the hardware works the same both with and
without it, but I'd like to be consistent w/Windows here.
Second, DEVICE_RESET is never called when initializing either of my
gen3 devices, its only called for gen1 and gen2. The bits in the gen3
init after removing that, are safe (and interesting) to run on all
hardware, so there's no more gen3-specific init done, there's instead
a generic mceusb_get_parameters() that is run for all hardware.
Third, the gen3 flag isn't needed. We only care if hardware is gen3
during probe, so I've dropped that from the device flags struct.
Successfully tested on all three generations of mceusb hardware.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-08 15:38:57 +00:00
|
|
|
|
|
|
|
/* get hw/sw revision? */
|
|
|
|
mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
|
|
|
|
|
2010-06-16 20:10:05 +00:00
|
|
|
kfree(data);
|
2013-01-29 11:19:29 +00:00
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
static void mceusb_gen2_init(struct mceusb_dev *ir)
|
|
|
|
{
|
2011-07-18 19:54:21 +00:00
|
|
|
/* device resume */
|
|
|
|
mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME));
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2011-07-18 19:54:21 +00:00
|
|
|
/* get wake version (protocol, key, address) */
|
|
|
|
mce_async_out(ir, GET_WAKEVERSION, sizeof(GET_WAKEVERSION));
|
|
|
|
|
|
|
|
/* unknown what this one actually returns... */
|
V4L/DVB: IR/mceusb: more streamlining of device init
Spent a while last night getting device initialization packet captures
under Windows for all generations of devices. There are a few places
where we were doing things differently, and few things we were doing
that we don't need to do, particularly on gen3 hardware, and I *think*
one of those things is what was locking up my pinnacle hw from time to
time -- at least, its been perfectly well behaved every time its been
plugged in since making this change.
First up, we're adding a bit more to the gen1 init routine here. Its
not absolutely necessary, the hardware works the same both with and
without it, but I'd like to be consistent w/Windows here.
Second, DEVICE_RESET is never called when initializing either of my
gen3 devices, its only called for gen1 and gen2. The bits in the gen3
init after removing that, are safe (and interesting) to run on all
hardware, so there's no more gen3-specific init done, there's instead
a generic mceusb_get_parameters() that is run for all hardware.
Third, the gen3 flag isn't needed. We only care if hardware is gen3
during probe, so I've dropped that from the device flags struct.
Successfully tested on all three generations of mceusb hardware.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-08 15:38:57 +00:00
|
|
|
mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2));
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
V4L/DVB: IR/mceusb: more streamlining of device init
Spent a while last night getting device initialization packet captures
under Windows for all generations of devices. There are a few places
where we were doing things differently, and few things we were doing
that we don't need to do, particularly on gen3 hardware, and I *think*
one of those things is what was locking up my pinnacle hw from time to
time -- at least, its been perfectly well behaved every time its been
plugged in since making this change.
First up, we're adding a bit more to the gen1 init routine here. Its
not absolutely necessary, the hardware works the same both with and
without it, but I'd like to be consistent w/Windows here.
Second, DEVICE_RESET is never called when initializing either of my
gen3 devices, its only called for gen1 and gen2. The bits in the gen3
init after removing that, are safe (and interesting) to run on all
hardware, so there's no more gen3-specific init done, there's instead
a generic mceusb_get_parameters() that is run for all hardware.
Third, the gen3 flag isn't needed. We only care if hardware is gen3
during probe, so I've dropped that from the device flags struct.
Successfully tested on all three generations of mceusb hardware.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-08 15:38:57 +00:00
|
|
|
static void mceusb_get_parameters(struct mceusb_dev *ir)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
2011-07-18 19:54:26 +00:00
|
|
|
int i;
|
|
|
|
unsigned char cmdbuf[3] = { MCE_CMD_PORT_SYS,
|
|
|
|
MCE_CMD_GETPORTSTATUS, 0x00 };
|
|
|
|
|
|
|
|
/* defaults, if the hardware doesn't support querying */
|
|
|
|
ir->num_txports = 2;
|
|
|
|
ir->num_rxports = 2;
|
|
|
|
|
|
|
|
/* get number of tx and rx ports */
|
|
|
|
mce_async_out(ir, GET_NUM_PORTS, sizeof(GET_NUM_PORTS));
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
/* get the carrier and frequency */
|
|
|
|
mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ));
|
|
|
|
|
2011-07-18 19:54:26 +00:00
|
|
|
if (ir->num_txports && !ir->flags.no_tx)
|
2010-10-29 03:07:39 +00:00
|
|
|
/* get the transmitter bitmask */
|
|
|
|
mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK));
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* get receiver timeout value */
|
|
|
|
mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
|
|
|
|
|
|
|
|
/* get receiver sensor setting */
|
|
|
|
mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR));
|
2011-07-18 19:54:26 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ir->num_txports; i++) {
|
|
|
|
cmdbuf[2] = i;
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2011-07-18 19:54:27 +00:00
|
|
|
static void mceusb_flash_led(struct mceusb_dev *ir)
|
|
|
|
{
|
|
|
|
if (ir->emver < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mce_async_out(ir, FLASH_LED, sizeof(FLASH_LED));
|
|
|
|
}
|
|
|
|
|
2017-03-26 18:28:08 +00:00
|
|
|
/*
|
|
|
|
* Workqueue function
|
|
|
|
* for resetting or recovering device after occurrence of error events
|
|
|
|
* specified in ir->kevent bit field.
|
|
|
|
* Function runs (via schedule_work()) in non-interrupt context, for
|
|
|
|
* calls here (such as usb_clear_halt()) requiring non-interrupt context.
|
|
|
|
*/
|
|
|
|
static void mceusb_deferred_kevent(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir =
|
|
|
|
container_of(work, struct mceusb_dev, kevent);
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (test_bit(EVENT_RX_HALT, &ir->kevent_flags)) {
|
|
|
|
usb_unlink_urb(ir->urb_in);
|
|
|
|
status = usb_clear_halt(ir->usbdev, ir->pipe_in);
|
|
|
|
if (status < 0) {
|
|
|
|
dev_err(ir->dev, "rx clear halt error %d",
|
|
|
|
status);
|
|
|
|
}
|
|
|
|
clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
if (status == 0) {
|
|
|
|
status = usb_submit_urb(ir->urb_in, GFP_KERNEL);
|
|
|
|
if (status < 0) {
|
|
|
|
dev_err(ir->dev,
|
|
|
|
"rx unhalt submit urb error %d",
|
|
|
|
status);
|
|
|
|
}
|
2017-03-26 18:28:08 +00:00
|
|
|
}
|
|
|
|
}
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
|
|
|
|
if (test_bit(EVENT_TX_HALT, &ir->kevent_flags)) {
|
|
|
|
status = usb_clear_halt(ir->usbdev, ir->pipe_out);
|
|
|
|
if (status < 0)
|
|
|
|
dev_err(ir->dev, "tx clear halt error %d", status);
|
|
|
|
clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
|
|
|
|
}
|
2017-03-26 18:28:08 +00:00
|
|
|
}
|
|
|
|
|
2014-09-08 22:10:43 +00:00
|
|
|
static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
2014-09-08 22:10:43 +00:00
|
|
|
struct usb_device *udev = ir->usbdev;
|
2010-06-01 20:32:08 +00:00
|
|
|
struct device *dev = ir->dev;
|
2010-10-29 19:08:23 +00:00
|
|
|
struct rc_dev *rc;
|
|
|
|
int ret;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2016-12-16 08:50:58 +00:00
|
|
|
rc = rc_allocate_device(RC_DRIVER_IR_RAW);
|
2010-10-29 19:08:23 +00:00
|
|
|
if (!rc) {
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_err(dev, "remote dev allocation failed");
|
2010-10-29 19:08:23 +00:00
|
|
|
goto out;
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 14:52:53 +00:00
|
|
|
snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)",
|
2010-10-29 19:08:23 +00:00
|
|
|
mceusb_model[ir->model].name ?
|
2010-11-17 19:56:17 +00:00
|
|
|
mceusb_model[ir->model].name :
|
2010-10-29 19:08:23 +00:00
|
|
|
"Media Center Ed. eHome Infrared Remote Transceiver",
|
2010-06-01 20:32:08 +00:00
|
|
|
le16_to_cpu(ir->usbdev->descriptor.idVendor),
|
|
|
|
le16_to_cpu(ir->usbdev->descriptor.idProduct));
|
|
|
|
|
|
|
|
usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys));
|
|
|
|
|
2017-07-01 16:13:19 +00:00
|
|
|
rc->device_name = ir->name;
|
2010-10-29 19:08:23 +00:00
|
|
|
rc->input_phys = ir->phys;
|
|
|
|
usb_to_input_id(ir->usbdev, &rc->input_id);
|
|
|
|
rc->dev.parent = dev;
|
|
|
|
rc->priv = ir;
|
2017-08-07 20:20:58 +00:00
|
|
|
rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
|
2018-04-08 15:06:49 +00:00
|
|
|
rc->min_timeout = US_TO_NS(MCE_TIME_UNIT);
|
2011-07-03 20:13:53 +00:00
|
|
|
rc->timeout = MS_TO_NS(100);
|
2018-05-09 10:11:28 +00:00
|
|
|
if (!mceusb_model[ir->model].broken_irtimeout) {
|
|
|
|
rc->s_timeout = mceusb_set_timeout;
|
|
|
|
rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If we can't set the timeout using CMD_SETIRTIMEOUT, we can
|
|
|
|
* rely on software timeouts for timeouts < 100ms.
|
|
|
|
*/
|
|
|
|
rc->max_timeout = rc->timeout;
|
|
|
|
}
|
2010-10-29 03:07:39 +00:00
|
|
|
if (!ir->flags.no_tx) {
|
2010-10-29 19:08:23 +00:00
|
|
|
rc->s_tx_mask = mceusb_set_tx_mask;
|
|
|
|
rc->s_tx_carrier = mceusb_set_tx_carrier;
|
|
|
|
rc->tx_ir = mceusb_tx_ir;
|
2010-10-29 03:07:39 +00:00
|
|
|
}
|
2018-03-16 19:52:09 +00:00
|
|
|
if (ir->flags.rx2 > 0) {
|
|
|
|
rc->s_learning_mode = mceusb_set_rx_wideband;
|
|
|
|
rc->s_carrier_report = mceusb_set_rx_carrier_report;
|
|
|
|
}
|
2010-10-29 19:08:23 +00:00
|
|
|
rc->driver_name = DRIVER_NAME;
|
2014-07-27 20:28:48 +00:00
|
|
|
|
|
|
|
switch (le16_to_cpu(udev->descriptor.idVendor)) {
|
|
|
|
case VENDOR_HAUPPAUGE:
|
|
|
|
rc->map_name = RC_MAP_HAUPPAUGE;
|
|
|
|
break;
|
|
|
|
case VENDOR_PCTV:
|
|
|
|
rc->map_name = RC_MAP_PINNACLE_PCTV_HD;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc->map_name = RC_MAP_RC6_MCE;
|
|
|
|
}
|
|
|
|
if (mceusb_model[ir->model].rc_map)
|
|
|
|
rc->map_name = mceusb_model[ir->model].rc_map;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-10-29 19:08:23 +00:00
|
|
|
ret = rc_register_device(rc);
|
2010-06-01 20:32:08 +00:00
|
|
|
if (ret < 0) {
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_err(dev, "remote dev registration failed");
|
2010-10-29 19:08:23 +00:00
|
|
|
goto out;
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2010-10-29 19:08:23 +00:00
|
|
|
return rc;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-10-29 19:08:23 +00:00
|
|
|
out:
|
|
|
|
rc_free_device(rc);
|
2010-06-01 20:32:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-21 21:17:53 +00:00
|
|
|
static int mceusb_dev_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
|
|
|
struct usb_device *dev = interface_to_usbdev(intf);
|
|
|
|
struct usb_host_interface *idesc;
|
|
|
|
struct usb_endpoint_descriptor *ep = NULL;
|
|
|
|
struct usb_endpoint_descriptor *ep_in = NULL;
|
|
|
|
struct usb_endpoint_descriptor *ep_out = NULL;
|
|
|
|
struct mceusb_dev *ir = NULL;
|
2016-04-14 20:42:50 +00:00
|
|
|
int pipe, maxp, i, res;
|
2010-06-01 20:32:08 +00:00
|
|
|
char buf[63], name[128] = "";
|
2010-10-22 14:50:37 +00:00
|
|
|
enum mceusb_model_type model = id->driver_info;
|
2010-06-01 20:32:08 +00:00
|
|
|
bool is_gen3;
|
|
|
|
bool is_microsoft_gen1;
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
bool tx_mask_normal;
|
2011-03-01 15:38:28 +00:00
|
|
|
int ir_intfnum;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_dbg(&intf->dev, "%s called", __func__);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
idesc = intf->cur_altsetting;
|
|
|
|
|
2010-10-22 14:50:37 +00:00
|
|
|
is_gen3 = mceusb_model[model].mce_gen3;
|
|
|
|
is_microsoft_gen1 = mceusb_model[model].mce_gen1;
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
tx_mask_normal = mceusb_model[model].tx_mask_normal;
|
2011-03-01 15:38:28 +00:00
|
|
|
ir_intfnum = mceusb_model[model].ir_intfnum;
|
2010-10-18 19:32:50 +00:00
|
|
|
|
2011-03-01 15:38:28 +00:00
|
|
|
/* There are multi-function devices with non-IR interfaces */
|
|
|
|
if (idesc->desc.bInterfaceNumber != ir_intfnum)
|
|
|
|
return -ENODEV;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
/* step through the endpoints to find first bulk in and out endpoint */
|
|
|
|
for (i = 0; i < idesc->desc.bNumEndpoints; ++i) {
|
|
|
|
ep = &idesc->endpoint[i].desc;
|
|
|
|
|
2014-04-24 14:16:31 +00:00
|
|
|
if (ep_in == NULL) {
|
|
|
|
if (usb_endpoint_is_bulk_in(ep)) {
|
|
|
|
ep_in = ep;
|
|
|
|
dev_dbg(&intf->dev, "acceptable bulk inbound endpoint found\n");
|
|
|
|
} else if (usb_endpoint_is_int_in(ep)) {
|
|
|
|
ep_in = ep;
|
|
|
|
ep_in->bInterval = 1;
|
|
|
|
dev_dbg(&intf->dev, "acceptable interrupt inbound endpoint found\n");
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2014-04-24 14:16:31 +00:00
|
|
|
if (ep_out == NULL) {
|
|
|
|
if (usb_endpoint_is_bulk_out(ep)) {
|
|
|
|
ep_out = ep;
|
|
|
|
dev_dbg(&intf->dev, "acceptable bulk outbound endpoint found\n");
|
|
|
|
} else if (usb_endpoint_is_int_out(ep)) {
|
|
|
|
ep_out = ep;
|
|
|
|
ep_out->bInterval = 1;
|
|
|
|
dev_dbg(&intf->dev, "acceptable interrupt outbound endpoint found\n");
|
|
|
|
}
|
2010-06-01 20:32:08 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-07 18:14:13 +00:00
|
|
|
if (!ep_in || !ep_out) {
|
|
|
|
dev_dbg(&intf->dev, "required endpoints not found\n");
|
2010-06-01 20:32:08 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2014-04-24 14:16:31 +00:00
|
|
|
if (usb_endpoint_xfer_int(ep_in))
|
|
|
|
pipe = usb_rcvintpipe(dev, ep_in->bEndpointAddress);
|
|
|
|
else
|
|
|
|
pipe = usb_rcvbulkpipe(dev, ep_in->bEndpointAddress);
|
2010-06-01 20:32:08 +00:00
|
|
|
maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
|
|
|
|
|
|
|
|
ir = kzalloc(sizeof(struct mceusb_dev), GFP_KERNEL);
|
|
|
|
if (!ir)
|
|
|
|
goto mem_alloc_fail;
|
|
|
|
|
2017-03-26 18:28:08 +00:00
|
|
|
ir->pipe_in = pipe;
|
2010-06-01 20:32:08 +00:00
|
|
|
ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_ATOMIC, &ir->dma_in);
|
|
|
|
if (!ir->buf_in)
|
|
|
|
goto buf_in_alloc_fail;
|
|
|
|
|
|
|
|
ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!ir->urb_in)
|
|
|
|
goto urb_in_alloc_fail;
|
|
|
|
|
2014-09-08 22:10:43 +00:00
|
|
|
ir->usbdev = usb_get_dev(dev);
|
2010-06-01 20:32:08 +00:00
|
|
|
ir->dev = &intf->dev;
|
|
|
|
ir->len_in = maxp;
|
|
|
|
ir->flags.microsoft_gen1 = is_microsoft_gen1;
|
[media] mceusb: fix inverted mask inversion logic
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.
Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.
Tested successfully by myself and Dennis Gilmore.
Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-15 22:20:55 +00:00
|
|
|
ir->flags.tx_mask_normal = tx_mask_normal;
|
2010-10-29 03:07:39 +00:00
|
|
|
ir->flags.no_tx = mceusb_model[model].no_tx;
|
2018-03-16 19:52:09 +00:00
|
|
|
ir->flags.rx2 = mceusb_model[model].rx2;
|
2010-10-22 14:50:37 +00:00
|
|
|
ir->model = model;
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
/* Saving usb interface data for use by the transmitter routine */
|
|
|
|
ir->usb_ep_out = ep_out;
|
[media] mceusb: TX -EPIPE (urb status = -32) lockup fix
Once IR blasting or mceusb device commands fail with mce_async_callback()
TX -EPIPE error, all subsequent TX to device then fail with the same error.
...
[ 249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[ 249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[ 249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[ 249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 249.999929] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.000013] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[ 250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...
Fault simulation/injection is by executing the following USB operation
in a mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);
After setting halt state for the TX endpoint, perform an lirc "irsend"
to generate TX traffic to device. After the TX HALT, the patch restores
subsequent TX to working state.
...
[ 508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.009847] mce_async_callback()
[ 508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[ 508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[ 508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[ 508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.021963] mce_async_callback()
[ 508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[ 508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[ 508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[ 508.066669] mceusb 1-1.2:1.0: send request complete (res=0)
[ 508.066841] mce_async_callback()
[ 508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...
Signed-off-by: A Sun <as1033x@comcast.net>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-13 08:06:47 +00:00
|
|
|
if (usb_endpoint_xfer_int(ep_out))
|
|
|
|
ir->pipe_out = usb_sndintpipe(ir->usbdev,
|
|
|
|
ep_out->bEndpointAddress);
|
|
|
|
else
|
|
|
|
ir->pipe_out = usb_sndbulkpipe(ir->usbdev,
|
|
|
|
ep_out->bEndpointAddress);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
if (dev->descriptor.iManufacturer
|
|
|
|
&& usb_string(dev, dev->descriptor.iManufacturer,
|
|
|
|
buf, sizeof(buf)) > 0)
|
|
|
|
strlcpy(name, buf, sizeof(name));
|
|
|
|
if (dev->descriptor.iProduct
|
|
|
|
&& usb_string(dev, dev->descriptor.iProduct,
|
|
|
|
buf, sizeof(buf)) > 0)
|
|
|
|
snprintf(name + strlen(name), sizeof(name) - strlen(name),
|
|
|
|
" %s", buf);
|
|
|
|
|
2017-03-26 18:28:08 +00:00
|
|
|
/*
|
|
|
|
* Initialize async USB error handler before registering
|
|
|
|
* or activating any mceusb RX and TX functions
|
|
|
|
*/
|
|
|
|
INIT_WORK(&ir->kevent, mceusb_deferred_kevent);
|
|
|
|
|
2014-09-08 22:10:43 +00:00
|
|
|
ir->rc = mceusb_init_rc_dev(ir);
|
2010-10-29 19:08:23 +00:00
|
|
|
if (!ir->rc)
|
|
|
|
goto rc_dev_fail;
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2010-07-04 01:42:14 +00:00
|
|
|
/* wire up inbound data handler */
|
2017-03-26 18:33:07 +00:00
|
|
|
if (usb_endpoint_xfer_int(ep_in))
|
|
|
|
usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp,
|
|
|
|
mceusb_dev_recv, ir, ep_in->bInterval);
|
|
|
|
else
|
|
|
|
usb_fill_bulk_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp,
|
|
|
|
mceusb_dev_recv, ir);
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
ir->urb_in->transfer_dma = ir->dma_in;
|
|
|
|
ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
|
|
|
|
[media] mceusb: mce_sync_in is brain-dead
Aside from the initial "hey, lets make sure we've flushed any
pre-existing data on the device" call to mce_sync_in, every other one of
the calls was entirely superfluous. Ergo, remove them all, and rename
the one and only (questionably) useful one to reflect what it really
does. Verified on both gen2 and gen3 hardware to make zero difference.
Well, except that you no longer get a bunch of urb submit failures from
the unneeded mce_sync_in calls. Oh. And move that flush to a point
*after* we've wired up the inbound urb, or it won't do squat. I have
half a mind to just remove it entirely, but someone thought it was
necessary at some point, and it doesn't seem to hurt, so lets leave it
for the time being.
This excercise took place due to insightful questions asked by Hans
Petter Selasky, about the possible reuse of the inbound urb before it
was actually availble by mce_sync_in, so thanks to him for motivating
this cleanup.
Reported-by: Hans Petter Selasky <hselasky@c2i.net>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-05-26 17:23:18 +00:00
|
|
|
/* flush buffers on the device */
|
2017-03-26 19:04:51 +00:00
|
|
|
dev_dbg(&intf->dev, "Flushing receive buffers");
|
2016-04-14 20:42:50 +00:00
|
|
|
res = usb_submit_urb(ir->urb_in, GFP_KERNEL);
|
|
|
|
if (res)
|
2017-03-26 19:04:51 +00:00
|
|
|
dev_err(&intf->dev, "failed to flush buffers: %d", res);
|
[media] mceusb: mce_sync_in is brain-dead
Aside from the initial "hey, lets make sure we've flushed any
pre-existing data on the device" call to mce_sync_in, every other one of
the calls was entirely superfluous. Ergo, remove them all, and rename
the one and only (questionably) useful one to reflect what it really
does. Verified on both gen2 and gen3 hardware to make zero difference.
Well, except that you no longer get a bunch of urb submit failures from
the unneeded mce_sync_in calls. Oh. And move that flush to a point
*after* we've wired up the inbound urb, or it won't do squat. I have
half a mind to just remove it entirely, but someone thought it was
necessary at some point, and it doesn't seem to hurt, so lets leave it
for the time being.
This excercise took place due to insightful questions asked by Hans
Petter Selasky, about the possible reuse of the inbound urb before it
was actually availble by mce_sync_in, so thanks to him for motivating
this cleanup.
Reported-by: Hans Petter Selasky <hselasky@c2i.net>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-05-26 17:23:18 +00:00
|
|
|
|
[media] mceusb: query device for firmware emulator version
Supposedly, there are essentially three different classes of devices
that are compatible with Microsoft's specs. First are the "legacy"
devices, which are built using Microsoft-provided hardware specs and
firmware. Second are "emulator" devices, which are built using custom
hardware and firmware, written to emulate Microsoft's firmware. Third
are "port" devices, which have their own device driver and firmware,
which provides compatible data to higher levels of the stack.
>From what I can tell, things like nuvoton-cir and fintek-cir are
essentially "port" devices -- their raw IR buffer format is very similar
to that of the mceusb devices. Now, within the mceusb driver, we have
three different "generations", which at first, seemed like maybe they
mapped to emulator versions. Unfortuantely, every single device I have
responds "illegal command" to the query to get firmware emulator version
from the hardware, which means they're either all emulator version 1, or
they're legacy devices, and our different "generations" aren't at all
related here. Though in theory, its possible the gen1 devices are
"legacy" devices and the rest are emulator v1. There are some useful
features of the v2 interface I was hoping to play with, but alas...
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-18 19:54:25 +00:00
|
|
|
/* figure out which firmware/emulator version this hardware has */
|
|
|
|
mceusb_get_emulator_version(ir);
|
|
|
|
|
2010-06-01 20:32:08 +00:00
|
|
|
/* initialize device */
|
V4L/DVB: IR/mceusb: more streamlining of device init
Spent a while last night getting device initialization packet captures
under Windows for all generations of devices. There are a few places
where we were doing things differently, and few things we were doing
that we don't need to do, particularly on gen3 hardware, and I *think*
one of those things is what was locking up my pinnacle hw from time to
time -- at least, its been perfectly well behaved every time its been
plugged in since making this change.
First up, we're adding a bit more to the gen1 init routine here. Its
not absolutely necessary, the hardware works the same both with and
without it, but I'd like to be consistent w/Windows here.
Second, DEVICE_RESET is never called when initializing either of my
gen3 devices, its only called for gen1 and gen2. The bits in the gen3
init after removing that, are safe (and interesting) to run on all
hardware, so there's no more gen3-specific init done, there's instead
a generic mceusb_get_parameters() that is run for all hardware.
Third, the gen3 flag isn't needed. We only care if hardware is gen3
during probe, so I've dropped that from the device flags struct.
Successfully tested on all three generations of mceusb hardware.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-08 15:38:57 +00:00
|
|
|
if (ir->flags.microsoft_gen1)
|
2010-06-01 20:32:08 +00:00
|
|
|
mceusb_gen1_init(ir);
|
V4L/DVB: IR/mceusb: more streamlining of device init
Spent a while last night getting device initialization packet captures
under Windows for all generations of devices. There are a few places
where we were doing things differently, and few things we were doing
that we don't need to do, particularly on gen3 hardware, and I *think*
one of those things is what was locking up my pinnacle hw from time to
time -- at least, its been perfectly well behaved every time its been
plugged in since making this change.
First up, we're adding a bit more to the gen1 init routine here. Its
not absolutely necessary, the hardware works the same both with and
without it, but I'd like to be consistent w/Windows here.
Second, DEVICE_RESET is never called when initializing either of my
gen3 devices, its only called for gen1 and gen2. The bits in the gen3
init after removing that, are safe (and interesting) to run on all
hardware, so there's no more gen3-specific init done, there's instead
a generic mceusb_get_parameters() that is run for all hardware.
Third, the gen3 flag isn't needed. We only care if hardware is gen3
during probe, so I've dropped that from the device flags struct.
Successfully tested on all three generations of mceusb hardware.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-08 15:38:57 +00:00
|
|
|
else if (!is_gen3)
|
2010-06-01 20:32:08 +00:00
|
|
|
mceusb_gen2_init(ir);
|
|
|
|
|
V4L/DVB: IR/mceusb: more streamlining of device init
Spent a while last night getting device initialization packet captures
under Windows for all generations of devices. There are a few places
where we were doing things differently, and few things we were doing
that we don't need to do, particularly on gen3 hardware, and I *think*
one of those things is what was locking up my pinnacle hw from time to
time -- at least, its been perfectly well behaved every time its been
plugged in since making this change.
First up, we're adding a bit more to the gen1 init routine here. Its
not absolutely necessary, the hardware works the same both with and
without it, but I'd like to be consistent w/Windows here.
Second, DEVICE_RESET is never called when initializing either of my
gen3 devices, its only called for gen1 and gen2. The bits in the gen3
init after removing that, are safe (and interesting) to run on all
hardware, so there's no more gen3-specific init done, there's instead
a generic mceusb_get_parameters() that is run for all hardware.
Third, the gen3 flag isn't needed. We only care if hardware is gen3
during probe, so I've dropped that from the device flags struct.
Successfully tested on all three generations of mceusb hardware.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-08 15:38:57 +00:00
|
|
|
mceusb_get_parameters(ir);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
2011-07-18 19:54:27 +00:00
|
|
|
mceusb_flash_led(ir);
|
|
|
|
|
2010-10-29 03:07:39 +00:00
|
|
|
if (!ir->flags.no_tx)
|
2010-10-29 19:08:23 +00:00
|
|
|
mceusb_set_tx_mask(ir->rc, MCE_DEFAULT_TX_MASK);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
usb_set_intfdata(intf, ir);
|
|
|
|
|
2011-07-18 19:54:23 +00:00
|
|
|
/* enable wake via this device */
|
|
|
|
device_set_wakeup_capable(ir->dev, true);
|
|
|
|
device_set_wakeup_enable(ir->dev, true);
|
|
|
|
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_info(&intf->dev, "Registered %s with mce emulator interface version %x",
|
|
|
|
name, ir->emver);
|
|
|
|
dev_info(&intf->dev, "%x tx ports (0x%x cabled) and %x rx sensors (0x%x active)",
|
2011-07-18 19:54:26 +00:00
|
|
|
ir->num_txports, ir->txports_cabled,
|
|
|
|
ir->num_rxports, ir->rxports_active);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Error-handling path */
|
2010-10-29 19:08:23 +00:00
|
|
|
rc_dev_fail:
|
2017-03-26 18:28:08 +00:00
|
|
|
cancel_work_sync(&ir->kevent);
|
2014-09-08 22:10:43 +00:00
|
|
|
usb_put_dev(ir->usbdev);
|
2016-04-14 20:42:50 +00:00
|
|
|
usb_kill_urb(ir->urb_in);
|
2010-06-01 20:32:08 +00:00
|
|
|
usb_free_urb(ir->urb_in);
|
|
|
|
urb_in_alloc_fail:
|
|
|
|
usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in);
|
|
|
|
buf_in_alloc_fail:
|
|
|
|
kfree(ir);
|
|
|
|
mem_alloc_fail:
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_err(&intf->dev, "%s: device setup failed!", __func__);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-21 21:17:53 +00:00
|
|
|
static void mceusb_dev_disconnect(struct usb_interface *intf)
|
2010-06-01 20:32:08 +00:00
|
|
|
{
|
|
|
|
struct usb_device *dev = interface_to_usbdev(intf);
|
|
|
|
struct mceusb_dev *ir = usb_get_intfdata(intf);
|
|
|
|
|
|
|
|
usb_set_intfdata(intf, NULL);
|
|
|
|
|
|
|
|
if (!ir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ir->usbdev = NULL;
|
2017-03-26 18:28:08 +00:00
|
|
|
cancel_work_sync(&ir->kevent);
|
2010-10-29 19:08:23 +00:00
|
|
|
rc_unregister_device(ir->rc);
|
2010-06-01 20:32:08 +00:00
|
|
|
usb_kill_urb(ir->urb_in);
|
|
|
|
usb_free_urb(ir->urb_in);
|
|
|
|
usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in);
|
2014-09-08 22:10:43 +00:00
|
|
|
usb_put_dev(dev);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
kfree(ir);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mceusb_dev_suspend(struct usb_interface *intf, pm_message_t message)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir = usb_get_intfdata(intf);
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_info(ir->dev, "suspend");
|
2010-06-01 20:32:08 +00:00
|
|
|
usb_kill_urb(ir->urb_in);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mceusb_dev_resume(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir = usb_get_intfdata(intf);
|
2014-01-20 22:10:44 +00:00
|
|
|
dev_info(ir->dev, "resume");
|
2010-06-01 20:32:08 +00:00
|
|
|
if (usb_submit_urb(ir->urb_in, GFP_ATOMIC))
|
|
|
|
return -EIO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_driver mceusb_dev_driver = {
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.probe = mceusb_dev_probe,
|
2012-12-21 21:17:53 +00:00
|
|
|
.disconnect = mceusb_dev_disconnect,
|
2010-06-01 20:32:08 +00:00
|
|
|
.suspend = mceusb_dev_suspend,
|
|
|
|
.resume = mceusb_dev_resume,
|
|
|
|
.reset_resume = mceusb_dev_resume,
|
|
|
|
.id_table = mceusb_dev_table
|
|
|
|
};
|
|
|
|
|
2011-11-18 17:46:12 +00:00
|
|
|
module_usb_driver(mceusb_dev_driver);
|
2010-06-01 20:32:08 +00:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(usb, mceusb_dev_table);
|