2010-06-02 04:32:08 +08:00
|
|
|
/*
|
|
|
|
* Driver for USB Windows Media Center Ed. eHome Infrared Transceivers
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 by Jarod Wilson <jarod@redhat.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
2010-12-17 00:23:07 +08:00
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/usb/input.h>
|
2010-11-18 00:28:38 +08:00
|
|
|
#include <media/rc-core.h>
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
#define DRIVER_VERSION "1.91"
|
|
|
|
#define DRIVER_AUTHOR "Jarod Wilson <jarod@wilsonet.com>"
|
|
|
|
#define DRIVER_DESC "Windows Media Center Ed. eHome Infrared Transceiver " \
|
|
|
|
"device driver"
|
|
|
|
#define DRIVER_NAME "mceusb"
|
|
|
|
|
2010-10-23 01:42:54 +08:00
|
|
|
#define USB_BUFLEN 32 /* USB reception buffer length */
|
|
|
|
#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-02 04:32:08 +08:00
|
|
|
|
|
|
|
/* MCE constants */
|
2010-10-23 01:42:54 +08: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_TX_HEADER_LENGTH 3 /* # of bytes in the initializing tx header */
|
|
|
|
#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 */
|
|
|
|
|
|
|
|
#define MCE_HW_CMD_HEADER 0xff /* MCE hardware command header */
|
|
|
|
#define MCE_COMMAND_HEADER 0x9f /* MCE command header */
|
|
|
|
#define MCE_COMMAND_MASK 0xe0 /* Mask out command bits */
|
|
|
|
#define MCE_COMMAND_NULL 0x00 /* These show up various places... */
|
|
|
|
/* if buf[i] & MCE_COMMAND_MASK == 0x80 and buf[i] != MCE_COMMAND_HEADER,
|
|
|
|
* then we're looking at a raw IR data sample */
|
|
|
|
#define MCE_COMMAND_IRDATA 0x80
|
|
|
|
#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */
|
|
|
|
|
|
|
|
/* Sub-commands, which follow MCE_COMMAND_HEADER or MCE_HW_CMD_HEADER */
|
2010-11-10 05:41:03 +08:00
|
|
|
#define MCE_CMD_SIG_END 0x01 /* End of signal */
|
2010-10-23 01:42:54 +08:00
|
|
|
#define MCE_CMD_PING 0x03 /* Ping device */
|
|
|
|
#define MCE_CMD_UNKNOWN 0x04 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN2 0x05 /* Unknown */
|
|
|
|
#define MCE_CMD_S_CARRIER 0x06 /* Set TX carrier frequency */
|
|
|
|
#define MCE_CMD_G_CARRIER 0x07 /* Get TX carrier frequency */
|
|
|
|
#define MCE_CMD_S_TXMASK 0x08 /* Set TX port bitmask */
|
|
|
|
#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_S_TIMEOUT 0x0c /* Set RX timeout value */
|
|
|
|
#define MCE_CMD_G_TIMEOUT 0x0d /* Get RX timeout value */
|
|
|
|
#define MCE_CMD_UNKNOWN5 0x0e /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN6 0x0f /* Unknown */
|
|
|
|
#define MCE_CMD_G_RXPORTSTS 0x11 /* Get RX port status */
|
|
|
|
#define MCE_CMD_G_TXMASK 0x13 /* Set TX port bitmask */
|
|
|
|
#define MCE_CMD_S_RXSENSOR 0x14 /* Set RX sensor (std/learning) */
|
|
|
|
#define MCE_CMD_G_RXSENSOR 0x15 /* Get RX sensor (std/learning) */
|
2010-11-13 06:49:04 +08:00
|
|
|
#define MCE_RSP_PULSE_COUNT 0x15 /* RX pulse count (only if learning) */
|
2010-10-23 01:42:54 +08:00
|
|
|
#define MCE_CMD_TX_PORTS 0x16 /* Get number of TX ports */
|
|
|
|
#define MCE_CMD_G_WAKESRC 0x17 /* Get wake source */
|
|
|
|
#define MCE_CMD_UNKNOWN7 0x18 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN8 0x19 /* Unknown */
|
|
|
|
#define MCE_CMD_UNKNOWN9 0x1b /* Unknown */
|
|
|
|
#define MCE_CMD_DEVICE_RESET 0xaa /* Reset the hardware */
|
|
|
|
#define MCE_RSP_CMD_INVALID 0xfe /* Invalid command issued */
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* module parameters */
|
|
|
|
#ifdef CONFIG_USB_DEBUG
|
|
|
|
static int debug = 1;
|
|
|
|
#else
|
|
|
|
static int debug;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* general constants */
|
|
|
|
#define SEND_FLAG_IN_PROGRESS 1
|
|
|
|
#define SEND_FLAG_COMPLETE 2
|
|
|
|
#define RECV_FLAG_IN_PROGRESS 3
|
|
|
|
#define RECV_FLAG_COMPLETE 4
|
|
|
|
|
|
|
|
#define MCEUSB_RX 1
|
|
|
|
#define MCEUSB_TX 2
|
|
|
|
|
|
|
|
#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-19 03:32:50 +08:00
|
|
|
#define VENDOR_CONEXANT 0x0572
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-22 22:50:37 +08:00
|
|
|
enum mceusb_model_type {
|
|
|
|
MCE_GEN2 = 0, /* Most boards */
|
|
|
|
MCE_GEN1,
|
|
|
|
MCE_GEN3,
|
|
|
|
MCE_GEN2_TX_INV,
|
|
|
|
POLARIS_EVK,
|
2010-10-29 11:07:39 +08:00
|
|
|
CX_HYBRID_TV,
|
2011-03-01 23:38:28 +08:00
|
|
|
MULTIFUNCTION,
|
2010-10-22 22:50:37 +08: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-16 06:20:55 +08:00
|
|
|
u32 tx_mask_normal:1;
|
2010-10-29 11:07:39 +08:00
|
|
|
u32 no_tx:1;
|
2010-10-22 22:50:37 +08:00
|
|
|
|
2011-03-01 23:38:28 +08:00
|
|
|
int ir_intfnum;
|
|
|
|
|
2010-10-22 22:51:50 +08:00
|
|
|
const char *rc_map; /* Allow specify a per-board map */
|
2010-10-22 22:52:53 +08:00
|
|
|
const char *name; /* per-board name */
|
2010-10-22 22:50:37 +08: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-16 06:20:55 +08:00
|
|
|
.tx_mask_normal = 1,
|
2010-10-22 22:50:37 +08:00
|
|
|
},
|
|
|
|
[MCE_GEN2] = {
|
|
|
|
.mce_gen2 = 1,
|
|
|
|
},
|
|
|
|
[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-16 06:20:55 +08:00
|
|
|
.tx_mask_normal = 1,
|
2010-10-22 22:50:37 +08: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-16 06:20:55 +08:00
|
|
|
.tx_mask_normal = 1,
|
2010-10-22 22:50:37 +08:00
|
|
|
},
|
|
|
|
[POLARIS_EVK] = {
|
2010-10-22 22:51:50 +08:00
|
|
|
/*
|
|
|
|
* In fact, the EVK is shipped without
|
|
|
|
* remotes, but we should have something handy,
|
|
|
|
* to allow testing it
|
|
|
|
*/
|
2011-01-24 23:18:47 +08:00
|
|
|
.rc_map = RC_MAP_HAUPPAUGE,
|
2010-10-29 11:07:39 +08:00
|
|
|
.name = "Conexant Hybrid TV (cx231xx) MCE IR",
|
|
|
|
},
|
|
|
|
[CX_HYBRID_TV] = {
|
|
|
|
.no_tx = 1, /* tx isn't wired up at all */
|
|
|
|
.name = "Conexant Hybrid TV (cx231xx) MCE IR",
|
2010-10-22 22:50:37 +08:00
|
|
|
},
|
2011-03-01 23:38:28 +08:00
|
|
|
[MULTIFUNCTION] = {
|
|
|
|
.mce_gen2 = 1,
|
|
|
|
.ir_intfnum = 2,
|
|
|
|
},
|
2010-10-22 22:50:37 +08:00
|
|
|
};
|
|
|
|
|
2010-06-02 04:32:08 +08:00
|
|
|
static struct usb_device_id mceusb_dev_table[] = {
|
|
|
|
/* Original Microsoft MCE IR Transceiver (often HP-branded) */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_MICROSOFT, 0x006d),
|
|
|
|
.driver_info = MCE_GEN1 },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Philips Infrared Transceiver - Sahara branded */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x0608) },
|
|
|
|
/* Philips Infrared Transceiver - HP branded */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x060c),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08: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-28 05:21:14 +08: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-26 01:48:18 +08:00
|
|
|
/* Philips IR transceiver (Dell branded) */
|
|
|
|
{ USB_DEVICE(VENDOR_PHILIPS, 0x2093) },
|
2011-03-01 23:38:28 +08:00
|
|
|
/* Realtek MCE IR Receiver and card reader */
|
|
|
|
{ USB_DEVICE(VENDOR_REALTEK, 0x0161),
|
|
|
|
.driver_info = MULTIFUNCTION },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* SMK/Toshiba G83C0004D410 */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x031d),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* SMK eHome Infrared Transceiver (Sony VAIO) */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0322),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* bundled with Hauppauge PVR-150 */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0334),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* SMK eHome Infrared Transceiver */
|
|
|
|
{ USB_DEVICE(VENDOR_SMK, 0x0338) },
|
|
|
|
/* 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 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0001),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Topseed HP eHome Infrared Transceiver */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0006),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0007),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0008),
|
|
|
|
.driver_info = MCE_GEN3 },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x000a),
|
|
|
|
.driver_info = MCE_GEN2_TX_INV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Topseed eHome Infrared Transceiver */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_TOPSEED, 0x0011),
|
2011-03-05 07:20:47 +08:00
|
|
|
.driver_info = MCE_GEN3 },
|
2010-06-02 04:32:08 +08: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 */
|
|
|
|
{ USB_DEVICE(VENDOR_FORMOSA, 0xe017) },
|
|
|
|
/* 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) },
|
2010-12-17 00:27:11 +08:00
|
|
|
/* Fintek eHome Infrared Transceiver (HP branded) */
|
|
|
|
{ USB_DEVICE(VENDOR_FINTEK, 0x5168) },
|
2010-06-02 04:32:08 +08: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 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_PINNACLE, 0x0225),
|
|
|
|
.driver_info = MCE_GEN3 },
|
2010-06-02 04:32:08 +08: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 */
|
|
|
|
{ USB_DEVICE(VENDOR_TIVO, 0x2000) },
|
2010-10-29 11:07:39 +08:00
|
|
|
/* Conexant Hybrid TV "Shelby" Polaris SDK */
|
2010-10-22 22:50:37 +08:00
|
|
|
{ USB_DEVICE(VENDOR_CONEXANT, 0x58a1),
|
|
|
|
.driver_info = POLARIS_EVK },
|
2010-10-29 11:07:39 +08:00
|
|
|
/* Conexant Hybrid TV RDU253S Polaris */
|
|
|
|
{ USB_DEVICE(VENDOR_CONEXANT, 0x58a5),
|
|
|
|
.driver_info = CX_HYBRID_TV },
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Terminating entry */
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* data structure for each usb transceiver */
|
|
|
|
struct mceusb_dev {
|
|
|
|
/* ir-core bits */
|
2010-10-30 03:08:23 +08:00
|
|
|
struct rc_dev *rc;
|
2010-11-13 06:49:04 +08:00
|
|
|
|
|
|
|
/* optional features we can enable */
|
|
|
|
bool carrier_report_enabled;
|
|
|
|
bool learning_enabled;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
/* core device bits */
|
|
|
|
struct device *dev;
|
|
|
|
|
|
|
|
/* usb */
|
|
|
|
struct usb_device *usbdev;
|
|
|
|
struct urb *urb_in;
|
|
|
|
struct usb_endpoint_descriptor *usb_ep_in;
|
|
|
|
struct usb_endpoint_descriptor *usb_ep_out;
|
|
|
|
|
|
|
|
/* buffers and dma */
|
|
|
|
unsigned char *buf_in;
|
|
|
|
unsigned int len_in;
|
2010-11-13 06:49:04 +08:00
|
|
|
dma_addr_t dma_in;
|
|
|
|
dma_addr_t dma_out;
|
2010-10-22 12:35:44 +08:00
|
|
|
|
|
|
|
enum {
|
|
|
|
CMD_HEADER = 0,
|
|
|
|
SUBCMD,
|
|
|
|
CMD_DATA,
|
|
|
|
PARSE_IRDATA,
|
|
|
|
} parser_state;
|
|
|
|
|
2010-11-13 06:49:04 +08:00
|
|
|
u8 cmd, rem; /* Remaining IR data bytes in packet */
|
2010-06-02 04:32:08 +08: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-16 06:20:55 +08:00
|
|
|
u32 tx_mask_normal:1;
|
2010-06-02 04:32:08 +08:00
|
|
|
u32 microsoft_gen1:1;
|
2010-10-29 11:07:39 +08:00
|
|
|
u32 no_tx:1;
|
2010-06-02 04:32:08 +08:00
|
|
|
} flags;
|
|
|
|
|
2010-06-17 04:55:52 +08:00
|
|
|
/* transmit support */
|
2010-06-02 04:32:08 +08:00
|
|
|
int send_flags;
|
2010-06-17 04:55:52 +08:00
|
|
|
u32 carrier;
|
|
|
|
unsigned char tx_mask;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
char name[128];
|
|
|
|
char phys[64];
|
2010-10-22 22:50:37 +08:00
|
|
|
enum mceusb_model_type model;
|
2010-06-02 04:32:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MCE Device Command Strings
|
|
|
|
* Device command responses vary from device to device...
|
|
|
|
* - DEVICE_RESET resets the hardware to its default state
|
|
|
|
* - GET_REVISION fetches the hardware/software revision, common
|
|
|
|
* replies are ff 0b 45 ff 1b 08 and ff 0b 50 ff 1b 42
|
|
|
|
* - GET_CARRIER_FREQ gets the carrier mode and frequency of the
|
|
|
|
* device, with replies in the form of 9f 06 MM FF, where MM is 0-3,
|
|
|
|
* meaning clk of 10000000, 2500000, 625000 or 156250, and FF is
|
|
|
|
* ((clk / frequency) - 1)
|
|
|
|
* - GET_RX_TIMEOUT fetches the receiver timeout in units of 50us,
|
|
|
|
* response in the form of 9f 0c msb lsb
|
|
|
|
* - GET_TX_BITMASK fetches the transmitter bitmask, replies in
|
|
|
|
* the form of 9f 08 bm, where bm is the bitmask
|
|
|
|
* - GET_RX_SENSOR fetches the RX sensor setting -- long-range
|
|
|
|
* general use one or short-range learning one, in the form of
|
|
|
|
* 9f 14 ss, where ss is either 01 for long-range or 02 for short
|
|
|
|
* - SET_CARRIER_FREQ sets a new carrier mode and frequency
|
|
|
|
* - SET_TX_BITMASK sets the transmitter bitmask
|
|
|
|
* - SET_RX_TIMEOUT sets the receiver timeout
|
|
|
|
* - SET_RX_SENSOR sets which receiver sensor to use
|
|
|
|
*/
|
2010-10-23 01:42:54 +08:00
|
|
|
static char DEVICE_RESET[] = {MCE_COMMAND_NULL, MCE_HW_CMD_HEADER,
|
|
|
|
MCE_CMD_DEVICE_RESET};
|
|
|
|
static char GET_REVISION[] = {MCE_HW_CMD_HEADER, MCE_CMD_G_REVISION};
|
|
|
|
static char GET_UNKNOWN[] = {MCE_HW_CMD_HEADER, MCE_CMD_UNKNOWN7};
|
|
|
|
static char GET_UNKNOWN2[] = {MCE_COMMAND_HEADER, MCE_CMD_UNKNOWN2};
|
|
|
|
static char GET_CARRIER_FREQ[] = {MCE_COMMAND_HEADER, MCE_CMD_G_CARRIER};
|
|
|
|
static char GET_RX_TIMEOUT[] = {MCE_COMMAND_HEADER, MCE_CMD_G_TIMEOUT};
|
|
|
|
static char GET_TX_BITMASK[] = {MCE_COMMAND_HEADER, MCE_CMD_G_TXMASK};
|
|
|
|
static char GET_RX_SENSOR[] = {MCE_COMMAND_HEADER, MCE_CMD_G_RXSENSOR};
|
2010-06-02 04:32:08 +08:00
|
|
|
/* sub in desired values in lower byte or bytes for full command */
|
|
|
|
/* FIXME: make use of these for transmit.
|
2010-10-23 01:42:54 +08:00
|
|
|
static char SET_CARRIER_FREQ[] = {MCE_COMMAND_HEADER,
|
|
|
|
MCE_CMD_S_CARRIER, 0x00, 0x00};
|
|
|
|
static char SET_TX_BITMASK[] = {MCE_COMMAND_HEADER, MCE_CMD_S_TXMASK, 0x00};
|
|
|
|
static char SET_RX_TIMEOUT[] = {MCE_COMMAND_HEADER,
|
|
|
|
MCE_CMD_S_TIMEOUT, 0x00, 0x00};
|
|
|
|
static char SET_RX_SENSOR[] = {MCE_COMMAND_HEADER,
|
|
|
|
MCE_CMD_S_RXSENSOR, 0x00};
|
2010-06-02 04:32:08 +08:00
|
|
|
*/
|
|
|
|
|
2010-10-22 12:35:44 +08:00
|
|
|
static int mceusb_cmdsize(u8 cmd, u8 subcmd)
|
|
|
|
{
|
|
|
|
int datasize = 0;
|
|
|
|
|
|
|
|
switch (cmd) {
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_COMMAND_NULL:
|
|
|
|
if (subcmd == MCE_HW_CMD_HEADER)
|
2010-10-22 12:35:44 +08:00
|
|
|
datasize = 1;
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_HW_CMD_HEADER:
|
2010-10-22 12:35:44 +08:00
|
|
|
switch (subcmd) {
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_G_REVISION:
|
2010-10-22 12:35:44 +08:00
|
|
|
datasize = 2;
|
|
|
|
break;
|
|
|
|
}
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_COMMAND_HEADER:
|
2010-10-22 12:35:44 +08:00
|
|
|
switch (subcmd) {
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_UNKNOWN:
|
|
|
|
case MCE_CMD_S_CARRIER:
|
|
|
|
case MCE_CMD_S_TIMEOUT:
|
2010-11-13 06:49:04 +08:00
|
|
|
case MCE_RSP_PULSE_COUNT:
|
2010-10-22 12:35:44 +08:00
|
|
|
datasize = 2;
|
|
|
|
break;
|
2010-11-10 05:41:03 +08:00
|
|
|
case MCE_CMD_SIG_END:
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_S_TXMASK:
|
|
|
|
case MCE_CMD_S_RXSENSOR:
|
2010-10-22 12:35:44 +08:00
|
|
|
datasize = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return datasize;
|
|
|
|
}
|
|
|
|
|
2010-06-02 04:32:08 +08:00
|
|
|
static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
|
2010-10-23 03:49:35 +08:00
|
|
|
int offset, int len, bool out)
|
2010-06-02 04:32:08 +08:00
|
|
|
{
|
|
|
|
char codes[USB_BUFLEN * 3 + 1];
|
|
|
|
char inout[9];
|
|
|
|
u8 cmd, subcmd, data1, data2;
|
|
|
|
struct device *dev = ir->dev;
|
2010-10-23 03:49:35 +08:00
|
|
|
int i, start, skip = 0;
|
|
|
|
|
|
|
|
if (!debug)
|
|
|
|
return;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-06-17 04:10:05 +08:00
|
|
|
/* skip meaningless 0xb1 0x60 header bytes on orig receiver */
|
2010-11-10 05:41:46 +08:00
|
|
|
if (ir->flags.microsoft_gen1 && !out && !offset)
|
2010-10-23 03:49:35 +08:00
|
|
|
skip = 2;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-23 03:49:35 +08:00
|
|
|
if (len <= skip)
|
2010-06-02 04:32:08 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < len && i < USB_BUFLEN; i++)
|
2010-10-23 03:49:35 +08:00
|
|
|
snprintf(codes + i * 3, 4, "%02x ", buf[i + offset] & 0xff);
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-23 03:49:35 +08:00
|
|
|
dev_info(dev, "%sx data: %s(length=%d)\n",
|
2010-06-02 04:32:08 +08:00
|
|
|
(out ? "t" : "r"), codes, len);
|
|
|
|
|
|
|
|
if (out)
|
|
|
|
strcpy(inout, "Request\0");
|
|
|
|
else
|
|
|
|
strcpy(inout, "Got\0");
|
|
|
|
|
2010-10-23 03:49:35 +08:00
|
|
|
start = offset + skip;
|
|
|
|
cmd = buf[start] & 0xff;
|
|
|
|
subcmd = buf[start + 1] & 0xff;
|
|
|
|
data1 = buf[start + 2] & 0xff;
|
|
|
|
data2 = buf[start + 3] & 0xff;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
switch (cmd) {
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_COMMAND_NULL:
|
|
|
|
if ((subcmd == MCE_HW_CMD_HEADER) &&
|
|
|
|
(data1 == MCE_CMD_DEVICE_RESET))
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Device reset requested\n");
|
|
|
|
else
|
|
|
|
dev_info(dev, "Unknown command 0x%02x 0x%02x\n",
|
|
|
|
cmd, subcmd);
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_HW_CMD_HEADER:
|
2010-06-02 04:32:08 +08:00
|
|
|
switch (subcmd) {
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_G_REVISION:
|
2010-06-02 04:32:08 +08:00
|
|
|
if (len == 2)
|
|
|
|
dev_info(dev, "Get hw/sw rev?\n");
|
|
|
|
else
|
|
|
|
dev_info(dev, "hw/sw rev 0x%02x 0x%02x "
|
|
|
|
"0x%02x 0x%02x\n", data1, data2,
|
2010-10-23 03:49:35 +08:00
|
|
|
buf[start + 4], buf[start + 5]);
|
2010-06-02 04:32:08 +08:00
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_DEVICE_RESET:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Device reset requested\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_RSP_CMD_INVALID:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Previous command not supported\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_UNKNOWN7:
|
|
|
|
case MCE_CMD_UNKNOWN9:
|
2010-06-02 04:32:08 +08:00
|
|
|
default:
|
|
|
|
dev_info(dev, "Unknown command 0x%02x 0x%02x\n",
|
|
|
|
cmd, subcmd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_COMMAND_HEADER:
|
2010-06-02 04:32:08 +08:00
|
|
|
switch (subcmd) {
|
2010-11-10 05:41:03 +08:00
|
|
|
case MCE_CMD_SIG_END:
|
|
|
|
dev_info(dev, "End of signal\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_PING:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Ping\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_UNKNOWN:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Resp to 9f 05 of 0x%02x 0x%02x\n",
|
|
|
|
data1, data2);
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_S_CARRIER:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "%s carrier mode and freq of "
|
|
|
|
"0x%02x 0x%02x\n", inout, data1, data2);
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_G_CARRIER:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Get carrier mode and freq\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_S_TXMASK:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "%s transmit blaster mask of 0x%02x\n",
|
|
|
|
inout, data1);
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_S_TIMEOUT:
|
2010-06-02 04:32:08 +08:00
|
|
|
/* value is in units of 50us, so x*50/100 or x/2 ms */
|
|
|
|
dev_info(dev, "%s receive timeout of %d ms\n",
|
|
|
|
inout, ((data1 << 8) | data2) / 2);
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_G_TIMEOUT:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Get receive timeout\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_G_TXMASK:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Get transmit blaster mask\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_S_RXSENSOR:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "%s %s-range receive sensor in use\n",
|
|
|
|
inout, data1 == 0x02 ? "short" : "long");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_G_RXSENSOR:
|
2010-11-13 06:49:04 +08:00
|
|
|
/* aka MCE_RSP_PULSE_COUNT */
|
|
|
|
if (out)
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Get receive sensor\n");
|
2010-11-13 06:49:04 +08:00
|
|
|
else if (ir->learning_enabled)
|
|
|
|
dev_info(dev, "RX pulse count: %d\n",
|
2010-06-02 04:32:08 +08:00
|
|
|
((data1 << 8) | data2));
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_RSP_CMD_INVALID:
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_info(dev, "Error! Hardware is likely wedged...\n");
|
|
|
|
break;
|
2010-10-23 01:42:54 +08:00
|
|
|
case MCE_CMD_UNKNOWN2:
|
|
|
|
case MCE_CMD_UNKNOWN3:
|
|
|
|
case MCE_CMD_UNKNOWN5:
|
2010-06-02 04:32:08 +08:00
|
|
|
default:
|
|
|
|
dev_info(dev, "Unknown command 0x%02x 0x%02x\n",
|
|
|
|
cmd, subcmd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-10-23 03:49:35 +08:00
|
|
|
|
|
|
|
if (cmd == MCE_IRDATA_TRAILER)
|
|
|
|
dev_info(dev, "End of raw IR data\n");
|
|
|
|
else if ((cmd != MCE_COMMAND_HEADER) &&
|
|
|
|
((cmd & MCE_COMMAND_MASK) == MCE_COMMAND_IRDATA))
|
|
|
|
dev_info(dev, "Raw IR data, %d pulse/space samples\n", ir->rem);
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
2010-08-03 05:21:06 +08:00
|
|
|
static void mce_async_callback(struct urb *urb, struct pt_regs *regs)
|
2010-06-02 04:32:08 +08:00
|
|
|
{
|
|
|
|
struct mceusb_dev *ir;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!urb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ir = urb->context;
|
|
|
|
if (ir) {
|
|
|
|
len = urb->actual_length;
|
|
|
|
|
|
|
|
dev_dbg(ir->dev, "callback called (status=%d len=%d)\n",
|
|
|
|
urb->status, len);
|
|
|
|
|
2010-10-23 03:49:35 +08:00
|
|
|
mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true);
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* request incoming or send outgoing usb packet - used to initialize remote */
|
|
|
|
static void mce_request_packet(struct mceusb_dev *ir,
|
|
|
|
struct usb_endpoint_descriptor *ep,
|
|
|
|
unsigned char *data, int size, int urb_type)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
struct urb *async_urb;
|
|
|
|
struct device *dev = ir->dev;
|
|
|
|
unsigned char *async_buf;
|
|
|
|
|
|
|
|
if (urb_type == MCEUSB_TX) {
|
|
|
|
async_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (unlikely(!async_urb)) {
|
|
|
|
dev_err(dev, "Error, couldn't allocate urb!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
async_buf = kzalloc(size, GFP_KERNEL);
|
|
|
|
if (!async_buf) {
|
|
|
|
dev_err(dev, "Error, couldn't allocate buf!\n");
|
|
|
|
usb_free_urb(async_urb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* outbound data */
|
|
|
|
usb_fill_int_urb(async_urb, ir->usbdev,
|
|
|
|
usb_sndintpipe(ir->usbdev, ep->bEndpointAddress),
|
2010-08-03 05:21:06 +08:00
|
|
|
async_buf, size, (usb_complete_t)mce_async_callback,
|
2010-06-02 04:32:08 +08:00
|
|
|
ir, ep->bInterval);
|
|
|
|
memcpy(async_buf, data, size);
|
|
|
|
|
|
|
|
} else if (urb_type == MCEUSB_RX) {
|
|
|
|
/* standard request */
|
|
|
|
async_urb = ir->urb_in;
|
|
|
|
ir->send_flags = RECV_FLAG_IN_PROGRESS;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dev_err(dev, "Error! Unknown urb type %d\n", urb_type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_dbg(dev, "receive request called (size=%#x)\n", size);
|
|
|
|
|
|
|
|
async_urb->transfer_buffer_length = size;
|
|
|
|
async_urb->dev = ir->usbdev;
|
|
|
|
|
|
|
|
res = usb_submit_urb(async_urb, GFP_ATOMIC);
|
|
|
|
if (res) {
|
|
|
|
dev_dbg(dev, "receive request FAILED! (res=%d)\n", res);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dev_dbg(dev, "receive request complete (res=%d)\n", res);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
|
|
|
|
{
|
|
|
|
mce_request_packet(ir, ir->usb_ep_out, data, size, MCEUSB_TX);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size)
|
|
|
|
{
|
|
|
|
mce_request_packet(ir, ir->usb_ep_in, data, size, MCEUSB_RX);
|
|
|
|
}
|
|
|
|
|
2010-06-17 04:55:52 +08:00
|
|
|
/* Send data out the IR blaster port(s) */
|
2010-10-30 03:08:23 +08:00
|
|
|
static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n)
|
2010-06-17 04:55:52 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
struct mceusb_dev *ir = dev->priv;
|
2010-06-17 04:55:52 +08:00
|
|
|
int i, ret = 0;
|
|
|
|
int count, cmdcount = 0;
|
|
|
|
unsigned char *cmdbuf; /* MCE command buffer */
|
|
|
|
long signal_duration = 0; /* Singnal length in us */
|
|
|
|
struct timeval start_time, end_time;
|
|
|
|
|
|
|
|
do_gettimeofday(&start_time);
|
|
|
|
|
|
|
|
count = n / sizeof(int);
|
|
|
|
|
|
|
|
cmdbuf = kzalloc(sizeof(int) * MCE_CMDBUF_SIZE, GFP_KERNEL);
|
|
|
|
if (!cmdbuf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* MCE tx init header */
|
2010-10-23 01:42:54 +08:00
|
|
|
cmdbuf[cmdcount++] = MCE_COMMAND_HEADER;
|
|
|
|
cmdbuf[cmdcount++] = MCE_CMD_S_TXMASK;
|
2010-06-17 04:55:52 +08:00
|
|
|
cmdbuf[cmdcount++] = ir->tx_mask;
|
|
|
|
|
|
|
|
/* Generate mce packet data */
|
|
|
|
for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) {
|
|
|
|
signal_duration += txbuf[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) &&
|
|
|
|
(cmdcount - MCE_TX_HEADER_LENGTH) %
|
|
|
|
MCE_CODE_LENGTH == 0)
|
2010-10-23 01:42:54 +08:00
|
|
|
cmdbuf[cmdcount++] = MCE_IRDATA_HEADER;
|
2010-06-17 04:55:52 +08: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));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fix packet length in last header */
|
|
|
|
cmdbuf[cmdcount - (cmdcount - MCE_TX_HEADER_LENGTH) % MCE_CODE_LENGTH] =
|
2010-10-23 01:42:54 +08:00
|
|
|
MCE_COMMAND_IRDATA + (cmdcount - MCE_TX_HEADER_LENGTH) %
|
|
|
|
MCE_CODE_LENGTH - 1;
|
2010-06-17 04:55:52 +08:00
|
|
|
|
|
|
|
/* Check if we have room for the empty packet at the end */
|
|
|
|
if (cmdcount >= MCE_CMDBUF_SIZE) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All mce commands end with an empty packet (0x80) */
|
2010-10-23 01:42:54 +08:00
|
|
|
cmdbuf[cmdcount++] = MCE_IRDATA_TRAILER;
|
2010-06-17 04:55:52 +08:00
|
|
|
|
|
|
|
/* Transmit the command to the mce device */
|
|
|
|
mce_async_out(ir, cmdbuf, cmdcount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The lircd gap calculation expects the write function to
|
|
|
|
* wait the time it takes for the ircommand to be sent before
|
|
|
|
* it returns.
|
|
|
|
*/
|
|
|
|
do_gettimeofday(&end_time);
|
|
|
|
signal_duration -= (end_time.tv_usec - start_time.tv_usec) +
|
|
|
|
(end_time.tv_sec - start_time.tv_sec) * 1000000;
|
|
|
|
|
|
|
|
/* delay with the closest number of ticks */
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
schedule_timeout(usecs_to_jiffies(signal_duration));
|
|
|
|
|
|
|
|
out:
|
|
|
|
kfree(cmdbuf);
|
|
|
|
return ret ? ret : n;
|
|
|
|
}
|
|
|
|
|
2010-10-29 11:07:39 +08:00
|
|
|
/* Sets active IR outputs -- mce devices typically have two */
|
2010-10-30 03:08:23 +08:00
|
|
|
static int mceusb_set_tx_mask(struct rc_dev *dev, u32 mask)
|
2010-06-17 04:10:05 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
struct mceusb_dev *ir = dev->priv;
|
2010-06-17 04:10:05 +08:00
|
|
|
|
[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-16 06:20:55 +08:00
|
|
|
if (ir->flags.tx_mask_normal)
|
|
|
|
ir->tx_mask = mask;
|
|
|
|
else
|
2010-10-23 01:42:54 +08:00
|
|
|
ir->tx_mask = (mask != MCE_DEFAULT_TX_MASK ?
|
|
|
|
mask ^ MCE_DEFAULT_TX_MASK : mask) << 1;
|
2010-06-17 04:10:05 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-17 04:55:52 +08:00
|
|
|
/* Sets the send carrier frequency and mode */
|
2010-10-30 03:08:23 +08:00
|
|
|
static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
|
2010-06-17 04:55:52 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
struct mceusb_dev *ir = dev->priv;
|
2010-06-17 04:55:52 +08:00
|
|
|
int clk = 10000000;
|
|
|
|
int prescaler = 0, divisor = 0;
|
2010-10-23 01:42:54 +08:00
|
|
|
unsigned char cmdbuf[4] = { MCE_COMMAND_HEADER,
|
|
|
|
MCE_CMD_S_CARRIER, 0x00, 0x00 };
|
2010-06-17 04:55:52 +08:00
|
|
|
|
|
|
|
/* Carrier has changed */
|
|
|
|
if (ir->carrier != carrier) {
|
|
|
|
|
|
|
|
if (carrier == 0) {
|
|
|
|
ir->carrier = carrier;
|
2010-11-10 05:41:03 +08:00
|
|
|
cmdbuf[2] = MCE_CMD_SIG_END;
|
2010-10-23 01:42:54 +08:00
|
|
|
cmdbuf[3] = MCE_IRDATA_TRAILER;
|
2010-06-17 04:55:52 +08:00
|
|
|
dev_dbg(ir->dev, "%s: disabling carrier "
|
|
|
|
"modulation\n", __func__);
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
return carrier;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (prescaler = 0; prescaler < 4; ++prescaler) {
|
|
|
|
divisor = (clk >> (2 * prescaler)) / carrier;
|
2010-10-23 01:42:54 +08:00
|
|
|
if (divisor <= 0xff) {
|
2010-06-17 04:55:52 +08:00
|
|
|
ir->carrier = carrier;
|
|
|
|
cmdbuf[2] = prescaler;
|
|
|
|
cmdbuf[3] = divisor;
|
|
|
|
dev_dbg(ir->dev, "%s: requesting %u HZ "
|
|
|
|
"carrier\n", __func__, carrier);
|
|
|
|
|
|
|
|
/* Transmit new carrier to mce device */
|
|
|
|
mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
|
|
|
|
return carrier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return carrier;
|
|
|
|
}
|
|
|
|
|
2010-11-13 06:49:04 +08: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)
|
|
|
|
{
|
|
|
|
u8 hi = ir->buf_in[index + 1] & 0xff;
|
|
|
|
u8 lo = ir->buf_in[index + 2] & 0xff;
|
|
|
|
|
|
|
|
switch (ir->buf_in[index]) {
|
|
|
|
/* 2-byte return value commands */
|
|
|
|
case MCE_CMD_S_TIMEOUT:
|
2011-01-19 04:31:24 +08:00
|
|
|
ir->rc->timeout = US_TO_NS((hi << 8 | lo) / 2);
|
2010-11-13 06:49:04 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* 1-byte return value commands */
|
|
|
|
case MCE_CMD_S_TXMASK:
|
|
|
|
ir->tx_mask = hi;
|
|
|
|
break;
|
|
|
|
case MCE_CMD_S_RXSENSOR:
|
|
|
|
ir->learning_enabled = (hi == 0x02);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-02 04:32:08 +08:00
|
|
|
static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
|
|
|
|
{
|
2010-10-17 06:56:28 +08:00
|
|
|
DEFINE_IR_RAW_EVENT(rawir);
|
2010-10-22 12:35:44 +08:00
|
|
|
int i = 0;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
/* skip meaningless 0xb1 0x60 header bytes on orig receiver */
|
|
|
|
if (ir->flags.microsoft_gen1)
|
2010-10-22 12:35:44 +08:00
|
|
|
i = 2;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-11-10 05:41:46 +08:00
|
|
|
/* if there's no data, just return now */
|
|
|
|
if (buf_len <= i)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 12:35:44 +08:00
|
|
|
for (; i < buf_len; i++) {
|
|
|
|
switch (ir->parser_state) {
|
|
|
|
case SUBCMD:
|
|
|
|
ir->rem = mceusb_cmdsize(ir->cmd, ir->buf_in[i]);
|
2010-10-23 03:49:35 +08:00
|
|
|
mceusb_dev_printdata(ir, ir->buf_in, i - 1,
|
|
|
|
ir->rem + 2, false);
|
2010-11-13 06:49:04 +08:00
|
|
|
mceusb_handle_command(ir, i);
|
2010-10-22 12:35:44 +08:00
|
|
|
ir->parser_state = CMD_DATA;
|
|
|
|
break;
|
|
|
|
case PARSE_IRDATA:
|
2010-06-02 04:32:08 +08:00
|
|
|
ir->rem--;
|
2011-01-26 23:20:09 +08:00
|
|
|
init_ir_raw_event(&rawir);
|
2010-06-02 04:32:08 +08:00
|
|
|
rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0);
|
|
|
|
rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK)
|
2011-01-19 04:31:24 +08:00
|
|
|
* US_TO_NS(MCE_TIME_UNIT);
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
dev_dbg(ir->dev, "Storing %s with duration %d\n",
|
|
|
|
rawir.pulse ? "pulse" : "space",
|
|
|
|
rawir.duration);
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
ir_raw_event_store_with_filter(ir->rc, &rawir);
|
2010-10-22 12:35:44 +08: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];
|
2010-10-23 01:42:54 +08:00
|
|
|
if ((ir->cmd == MCE_COMMAND_HEADER) ||
|
|
|
|
((ir->cmd & MCE_COMMAND_MASK) !=
|
|
|
|
MCE_COMMAND_IRDATA)) {
|
2010-10-22 12:35:44 +08:00
|
|
|
ir->parser_state = SUBCMD;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK);
|
2010-11-13 06:49:04 +08:00
|
|
|
mceusb_dev_printdata(ir, ir->buf_in,
|
|
|
|
i, ir->rem + 1, false);
|
2010-11-10 05:41:03 +08:00
|
|
|
if (ir->rem)
|
2010-10-22 12:35:44 +08:00
|
|
|
ir->parser_state = PARSE_IRDATA;
|
2011-01-26 23:20:09 +08:00
|
|
|
else
|
|
|
|
ir_raw_event_reset(ir->rc);
|
2010-10-22 12:35:44 +08:00
|
|
|
break;
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
2010-10-22 12:35:44 +08:00
|
|
|
if (ir->parser_state != CMD_HEADER && !ir->rem)
|
|
|
|
ir->parser_state = CMD_HEADER;
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
2010-10-22 12:35:44 +08:00
|
|
|
dev_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n");
|
2010-10-30 03:08:23 +08:00
|
|
|
ir_raw_event_handle(ir->rc);
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir;
|
|
|
|
int buf_len;
|
|
|
|
|
|
|
|
if (!urb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ir = urb->context;
|
|
|
|
if (!ir) {
|
|
|
|
usb_unlink_urb(urb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf_len = urb->actual_length;
|
|
|
|
|
|
|
|
if (ir->send_flags == RECV_FLAG_IN_PROGRESS) {
|
|
|
|
ir->send_flags = SEND_FLAG_COMPLETE;
|
2010-07-30 05:34:52 +08:00
|
|
|
dev_dbg(ir->dev, "setup answer received %d bytes\n",
|
2010-06-02 04:32:08 +08:00
|
|
|
buf_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
/* success */
|
|
|
|
case 0:
|
|
|
|
mceusb_process_ir_data(ir, buf_len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
usb_unlink_urb(urb);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case -EPIPE:
|
|
|
|
default:
|
2010-10-22 12:35:44 +08:00
|
|
|
dev_dbg(ir->dev, "Error: urb status = %d\n", urb->status);
|
2010-06-02 04:32:08 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mceusb_gen1_init(struct mceusb_dev *ir)
|
|
|
|
{
|
2010-07-10 22:19:42 +08:00
|
|
|
int ret;
|
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 23:38:57 +08:00
|
|
|
int maxp = ir->len_in;
|
2010-06-02 04:32:08 +08:00
|
|
|
struct device *dev = ir->dev;
|
2010-07-04 09:42:14 +08:00
|
|
|
char *data;
|
2010-06-17 04:10:05 +08:00
|
|
|
|
|
|
|
data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
|
|
|
|
if (!data) {
|
|
|
|
dev_err(dev, "%s: memory allocation failed!\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
/*
|
2010-07-04 09:42:14 +08:00
|
|
|
* This is a strange one. Windows issues a set address to the device
|
2010-06-02 04:32:08 +08: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-17 04:10:05 +08:00
|
|
|
data, USB_CTRL_MSG_SZ, HZ * 3);
|
2010-06-02 04:32:08 +08:00
|
|
|
dev_dbg(dev, "%s - ret = %d\n", __func__, ret);
|
|
|
|
dev_dbg(dev, "%s - data[0] = %d, data[1] = %d\n",
|
|
|
|
__func__, data[0], data[1]);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
dev_dbg(dev, "%s - ret = %d\n", __func__, ret);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
dev_dbg(dev, "%s - retB = %d\n", __func__, ret);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
dev_dbg(dev, "%s - retC = %d\n", __func__, ret);
|
2010-06-17 04:10:05 +08: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 23:38:57 +08:00
|
|
|
/* device reset */
|
|
|
|
mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
|
|
|
/* get hw/sw revision? */
|
|
|
|
mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
2010-06-17 04:10:05 +08:00
|
|
|
kfree(data);
|
2010-06-02 04:32:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void mceusb_gen2_init(struct mceusb_dev *ir)
|
|
|
|
{
|
|
|
|
int maxp = ir->len_in;
|
|
|
|
|
|
|
|
/* device reset */
|
|
|
|
mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
|
|
|
/* get hw/sw revision? */
|
|
|
|
mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
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 23:38:57 +08:00
|
|
|
/* unknown what the next two actually return... */
|
2010-06-02 04:32:08 +08:00
|
|
|
mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
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 23:38:57 +08:00
|
|
|
mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
2010-06-02 04:32:08 +08: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 23:38:57 +08:00
|
|
|
static void mceusb_get_parameters(struct mceusb_dev *ir)
|
2010-06-02 04:32:08 +08:00
|
|
|
{
|
|
|
|
int maxp = ir->len_in;
|
|
|
|
|
|
|
|
/* get the carrier and frequency */
|
|
|
|
mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
2010-10-29 11:07:39 +08:00
|
|
|
if (!ir->flags.no_tx) {
|
|
|
|
/* get the transmitter bitmask */
|
|
|
|
mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
}
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
/* get receiver timeout value */
|
|
|
|
mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
|
|
|
/* get receiver sensor setting */
|
|
|
|
mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR));
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
}
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
|
2010-06-02 04:32:08 +08:00
|
|
|
{
|
|
|
|
struct device *dev = ir->dev;
|
2010-10-30 03:08:23 +08:00
|
|
|
struct rc_dev *rc;
|
|
|
|
int ret;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
rc = rc_allocate_device();
|
|
|
|
if (!rc) {
|
|
|
|
dev_err(dev, "remote dev allocation failed\n");
|
|
|
|
goto out;
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
2010-10-22 22:52:53 +08:00
|
|
|
snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)",
|
2010-10-30 03:08:23 +08:00
|
|
|
mceusb_model[ir->model].name ?
|
2010-11-18 03:56:17 +08:00
|
|
|
mceusb_model[ir->model].name :
|
2010-10-30 03:08:23 +08:00
|
|
|
"Media Center Ed. eHome Infrared Remote Transceiver",
|
2010-06-02 04:32:08 +08: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));
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->input_name = ir->name;
|
|
|
|
rc->input_phys = ir->phys;
|
|
|
|
usb_to_input_id(ir->usbdev, &rc->input_id);
|
|
|
|
rc->dev.parent = dev;
|
|
|
|
rc->priv = ir;
|
|
|
|
rc->driver_type = RC_DRIVER_IR_RAW;
|
2010-11-18 01:20:52 +08:00
|
|
|
rc->allowed_protos = RC_TYPE_ALL;
|
2011-01-19 04:31:24 +08:00
|
|
|
rc->timeout = US_TO_NS(1000);
|
2010-10-29 11:07:39 +08:00
|
|
|
if (!ir->flags.no_tx) {
|
2010-10-30 03:08:23 +08: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 11:07:39 +08:00
|
|
|
}
|
2010-10-30 03:08:23 +08:00
|
|
|
rc->driver_name = DRIVER_NAME;
|
|
|
|
rc->map_name = mceusb_model[ir->model].rc_map ?
|
|
|
|
mceusb_model[ir->model].rc_map : RC_MAP_RC6_MCE;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
ret = rc_register_device(rc);
|
2010-06-02 04:32:08 +08:00
|
|
|
if (ret < 0) {
|
2010-10-30 03:08:23 +08:00
|
|
|
dev_err(dev, "remote dev registration failed\n");
|
|
|
|
goto out;
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
return rc;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
out:
|
|
|
|
rc_free_device(rc);
|
2010-06-02 04:32:08 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit mceusb_dev_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
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;
|
2010-06-17 04:10:46 +08:00
|
|
|
int pipe, maxp, i;
|
2010-06-02 04:32:08 +08:00
|
|
|
char buf[63], name[128] = "";
|
2010-10-22 22:50:37 +08:00
|
|
|
enum mceusb_model_type model = id->driver_info;
|
2010-06-02 04:32:08 +08: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-16 06:20:55 +08:00
|
|
|
bool tx_mask_normal;
|
2011-03-01 23:38:28 +08:00
|
|
|
int ir_intfnum;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-11-10 05:41:03 +08:00
|
|
|
dev_dbg(&intf->dev, "%s called\n", __func__);
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
idesc = intf->cur_altsetting;
|
|
|
|
|
2010-10-22 22:50:37 +08: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-16 06:20:55 +08:00
|
|
|
tx_mask_normal = mceusb_model[model].tx_mask_normal;
|
2011-03-01 23:38:28 +08:00
|
|
|
ir_intfnum = mceusb_model[model].ir_intfnum;
|
2010-10-19 03:32:50 +08:00
|
|
|
|
2011-03-01 23:38:28 +08:00
|
|
|
/* There are multi-function devices with non-IR interfaces */
|
|
|
|
if (idesc->desc.bInterfaceNumber != ir_intfnum)
|
|
|
|
return -ENODEV;
|
2010-06-02 04:32:08 +08: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;
|
|
|
|
|
|
|
|
if ((ep_in == NULL)
|
|
|
|
&& ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
|
|
|
|
== USB_DIR_IN)
|
|
|
|
&& (((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
|
|
|
|
== USB_ENDPOINT_XFER_BULK)
|
|
|
|
|| ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
|
|
|
|
== USB_ENDPOINT_XFER_INT))) {
|
|
|
|
|
|
|
|
ep_in = ep;
|
|
|
|
ep_in->bmAttributes = USB_ENDPOINT_XFER_INT;
|
2010-06-17 04:10:46 +08:00
|
|
|
ep_in->bInterval = 1;
|
2010-11-10 05:41:03 +08:00
|
|
|
dev_dbg(&intf->dev, "acceptable inbound endpoint "
|
2010-06-17 04:10:46 +08:00
|
|
|
"found\n");
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((ep_out == NULL)
|
|
|
|
&& ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
|
|
|
|
== USB_DIR_OUT)
|
|
|
|
&& (((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
|
|
|
|
== USB_ENDPOINT_XFER_BULK)
|
|
|
|
|| ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
|
|
|
|
== USB_ENDPOINT_XFER_INT))) {
|
|
|
|
|
|
|
|
ep_out = ep;
|
|
|
|
ep_out->bmAttributes = USB_ENDPOINT_XFER_INT;
|
2010-06-17 04:10:46 +08:00
|
|
|
ep_out->bInterval = 1;
|
2010-11-10 05:41:03 +08:00
|
|
|
dev_dbg(&intf->dev, "acceptable outbound endpoint "
|
2010-06-17 04:10:46 +08:00
|
|
|
"found\n");
|
2010-06-02 04:32:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ep_in == NULL) {
|
2010-11-10 05:41:03 +08:00
|
|
|
dev_dbg(&intf->dev, "inbound and/or endpoint not found\n");
|
2010-06-02 04:32:08 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
pipe = usb_rcvintpipe(dev, ep_in->bEndpointAddress);
|
|
|
|
maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
|
|
|
|
|
|
|
|
ir = kzalloc(sizeof(struct mceusb_dev), GFP_KERNEL);
|
|
|
|
if (!ir)
|
|
|
|
goto mem_alloc_fail;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
ir->usbdev = dev;
|
|
|
|
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-16 06:20:55 +08:00
|
|
|
ir->flags.tx_mask_normal = tx_mask_normal;
|
2010-10-29 11:07:39 +08:00
|
|
|
ir->flags.no_tx = mceusb_model[model].no_tx;
|
2010-10-22 22:50:37 +08:00
|
|
|
ir->model = model;
|
|
|
|
|
2010-06-02 04:32:08 +08:00
|
|
|
/* Saving usb interface data for use by the transmitter routine */
|
|
|
|
ir->usb_ep_in = ep_in;
|
|
|
|
ir->usb_ep_out = ep_out;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
ir->rc = mceusb_init_rc_dev(ir);
|
|
|
|
if (!ir->rc)
|
|
|
|
goto rc_dev_fail;
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-07-04 09:42:14 +08:00
|
|
|
/* flush buffers on the device */
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
mce_sync_in(ir, NULL, maxp);
|
|
|
|
|
|
|
|
/* wire up inbound data handler */
|
2010-06-02 04:32:08 +08:00
|
|
|
usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in,
|
|
|
|
maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval);
|
|
|
|
ir->urb_in->transfer_dma = ir->dma_in;
|
|
|
|
ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
|
|
|
|
|
|
|
/* 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 23:38:57 +08:00
|
|
|
if (ir->flags.microsoft_gen1)
|
2010-06-02 04:32:08 +08: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 23:38:57 +08:00
|
|
|
else if (!is_gen3)
|
2010-06-02 04:32:08 +08: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 23:38:57 +08:00
|
|
|
mceusb_get_parameters(ir);
|
2010-06-02 04:32:08 +08:00
|
|
|
|
2010-10-29 11:07:39 +08:00
|
|
|
if (!ir->flags.no_tx)
|
2010-10-30 03:08:23 +08:00
|
|
|
mceusb_set_tx_mask(ir->rc, MCE_DEFAULT_TX_MASK);
|
2010-06-02 04:32:08 +08:00
|
|
|
|
|
|
|
usb_set_intfdata(intf, ir);
|
|
|
|
|
|
|
|
dev_info(&intf->dev, "Registered %s on usb%d:%d\n", name,
|
|
|
|
dev->bus->busnum, dev->devnum);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Error-handling path */
|
2010-10-30 03:08:23 +08:00
|
|
|
rc_dev_fail:
|
2010-06-02 04:32:08 +08: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:
|
|
|
|
dev_err(&intf->dev, "%s: device setup failed!\n", __func__);
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void __devexit mceusb_dev_disconnect(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
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;
|
2010-10-30 03:08:23 +08:00
|
|
|
rc_unregister_device(ir->rc);
|
2010-06-02 04:32:08 +08: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);
|
|
|
|
|
|
|
|
kfree(ir);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mceusb_dev_suspend(struct usb_interface *intf, pm_message_t message)
|
|
|
|
{
|
|
|
|
struct mceusb_dev *ir = usb_get_intfdata(intf);
|
|
|
|
dev_info(ir->dev, "suspend\n");
|
|
|
|
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);
|
|
|
|
dev_info(ir->dev, "resume\n");
|
|
|
|
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,
|
|
|
|
.disconnect = mceusb_dev_disconnect,
|
|
|
|
.suspend = mceusb_dev_suspend,
|
|
|
|
.resume = mceusb_dev_resume,
|
|
|
|
.reset_resume = mceusb_dev_resume,
|
|
|
|
.id_table = mceusb_dev_table
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init mceusb_dev_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = usb_register(&mceusb_dev_driver);
|
|
|
|
if (ret < 0)
|
|
|
|
printk(KERN_ERR DRIVER_NAME
|
|
|
|
": usb register failed, result = %d\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit mceusb_dev_exit(void)
|
|
|
|
{
|
|
|
|
usb_deregister(&mceusb_dev_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(mceusb_dev_init);
|
|
|
|
module_exit(mceusb_dev_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(usb, mceusb_dev_table);
|
|
|
|
|
|
|
|
module_param(debug, bool, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(debug, "Debug enabled or not");
|