/*
* 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>
#include <linux/usb.h>
#include <linux/input.h>
#include <media/ir-core.h>
#include <media/ir-common.h>
#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"
#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 */
/* MCE constants */
#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_PACKET_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */
#define MCE_CONTROL_HEADER 0x9f /* MCE status header */
#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 /* Val opts: 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_COMMAND_MASK 0xe0 /* Mask out command bits */
#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */
#define MCE_COMMAND_IRDATA 0x80 /* buf & MCE_COMMAND_MASK == 0x80 -> IR data */
/* 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
#define VENDOR_CONEXANT 0x0572
enum mceusb_model_type {
MCE_GEN2 = 0, /* Most boards */
MCE_GEN1,
MCE_GEN3,
MCE_GEN2_TX_INV,
POLARIS_EVK,
};
struct mceusb_model {
u32 mce_gen1:1;
u32 mce_gen2:1;
u32 mce_gen3:1;
u32 tx_mask_inverted:1;
u32 is_polaris:1;
/*
* Allow specify a per-board extra data, like
* device names, and per-device rc_maps
*/
};
static const struct mceusb_model mceusb_model[] = {
[MCE_GEN1] = {
.mce_gen1 = 1,
.tx_mask_inverted = 1,
},
[MCE_GEN2] = {
.mce_gen2 = 1,
},
[MCE_GEN2_TX_INV] = {
.mce_gen2 = 1,
.tx_mask_inverted = 1,
},
[MCE_GEN3] = {
.mce_gen3 = 1,
.tx_mask_inverted = 1,
},
[POLARIS_EVK] = {
.is_polaris = 1,
},
};
static struct usb_device_id mceusb_dev_table[] = {
/* Original Microsoft MCE IR Transceiver (often HP-branded) */
{ USB_DEVICE(VENDOR_MICROSOFT, 0x006d),
.driver_info = MCE_GEN1 },
/* Philips Infrared Transceiver - Sahara branded */
{ USB_DEVICE(VENDOR_PHILIPS, 0x0608) },
/* Philips Infrared Transceiver - HP branded */