linux/drivers/media/rc/mceusb.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Driver for USB Windows Media Center Ed. eHome Infrared Transceivers
 *
 * Copyright (c) 2010-2011, Jarod Wilson <[email protected]>
 *
 * 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.
 *
 * 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
 */

#include <linux/device.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
#include <linux/pm_wakeup.h>
#include <media/rc-core.h>

#define DRIVER_VERSION
#define DRIVER_AUTHOR
#define DRIVER_DESC
#define DRIVER_NAME

#define USB_TX_TIMEOUT
#define USB_CTRL_MSG_SZ
#define MCE_G1_INIT_MSGS

/* MCE constants */
#define MCE_IRBUF_SIZE
#define MCE_TIME_UNIT
#define MCE_PACKET_SIZE
#define MCE_IRDATA_HEADER
				     /* Actual format is 0x80 + num_bytes */
#define MCE_IRDATA_TRAILER
#define MCE_MAX_CHANNELS
#define MCE_DEFAULT_TX_MASK
#define MCE_PULSE_BIT
#define MCE_PULSE_MASK
#define MCE_MAX_PULSE_LENGTH

/*
 * 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
#define MCE_PORT_IR
#define MCE_PORT_SYS
#define MCE_PORT_SER
#define MCE_PORT_MASK

/* Command port headers */
#define MCE_CMD_PORT_IR
#define MCE_CMD_PORT_SYS

/* Commands that set device state  (2-4 bytes in length) */
#define MCE_CMD_RESET
#define MCE_CMD_RESUME
#define MCE_CMD_SETIRCFS
#define MCE_CMD_SETIRTIMEOUT
#define MCE_CMD_SETIRTXPORTS
#define MCE_CMD_SETIRRXPORTEN
#define MCE_CMD_FLASHLED

/* Commands that query device state (all 2 bytes, unless noted) */
#define MCE_CMD_GETIRCFS
#define MCE_CMD_GETIRTIMEOUT
#define MCE_CMD_GETIRTXPORTS
#define MCE_CMD_GETIRRXPORTEN
#define MCE_CMD_GETPORTSTATUS
#define MCE_CMD_GETIRNUMPORTS
#define MCE_CMD_GETWAKESOURCE
#define MCE_CMD_GETEMVER
#define MCE_CMD_GETDEVDETAILS
#define MCE_CMD_GETWAKESUPPORT
#define MCE_CMD_GETWAKEVERSION

/* Misc commands */
#define MCE_CMD_NOP

/* Responses to commands (non-error cases) */
#define MCE_RSP_EQIRCFS
#define MCE_RSP_EQIRTIMEOUT
#define MCE_RSP_GETWAKESOURCE
#define MCE_RSP_EQIRTXPORTS
#define MCE_RSP_EQIRRXPORTEN
#define MCE_RSP_GETPORTSTATUS
#define MCE_RSP_EQIRRXCFCNT
#define MCE_RSP_EQIRNUMPORTS
#define MCE_RSP_EQWAKESUPPORT
#define MCE_RSP_EQWAKEVERSION
#define MCE_RSP_EQDEVDETAILS
#define MCE_RSP_EQEMVER
#define MCE_RSP_FLASHLED

/* Responses to error cases, must send MCE_CMD_RESUME to clear them */
#define MCE_RSP_CMD_ILLEGAL
#define MCE_RSP_TX_TIMEOUT

/* Misc commands/responses not defined in the MCE remote/transceiver spec */
#define MCE_CMD_SIG_END
#define MCE_CMD_PING
#define MCE_CMD_UNKNOWN
#define MCE_CMD_UNKNOWN2
#define MCE_CMD_UNKNOWN3
#define MCE_CMD_UNKNOWN4
#define MCE_CMD_G_REVISION
#define MCE_CMD_UNKNOWN5
#define MCE_CMD_UNKNOWN6
#define MCE_CMD_UNKNOWN8
#define MCE_CMD_UNKNOWN9
#define MCE_CMD_NULL

/* 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
#define MCE_PACKET_LENGTH_MASK

#define VENDOR_PHILIPS
#define VENDOR_SMK
#define VENDOR_TATUNG
#define VENDOR_GATEWAY
#define VENDOR_SHUTTLE
#define VENDOR_SHUTTLE2
#define VENDOR_MITSUMI
#define VENDOR_TOPSEED
#define VENDOR_RICAVISION
#define VENDOR_ITRON
#define VENDOR_FIC
#define VENDOR_LG
#define VENDOR_MICROSOFT
#define VENDOR_FORMOSA
#define VENDOR_FINTEK
#define VENDOR_PINNACLE
#define VENDOR_ECS
#define VENDOR_WISTRON
#define VENDOR_COMPRO
#define VENDOR_NORTHSTAR
#define VENDOR_REALTEK
#define VENDOR_TIVO
#define VENDOR_CONEXANT
#define VENDOR_TWISTEDMELON
#define VENDOR_HAUPPAUGE
#define VENDOR_PCTV
#define VENDOR_ADAPTEC

enum mceusb_model_type {};

struct mceusb_model {};

static const struct mceusb_model mceusb_model[] =;

static const struct usb_device_id mceusb_dev_table[] =;

/* data structure for each usb transceiver */
struct mceusb_dev {};

/* MCE Device Command Strings, generally a port and command pair */
static char DEVICE_RESUME[]	=;
static char GET_REVISION[]	=;
static char GET_EMVER[]		=;
static char GET_WAKEVERSION[]	=;
static char FLASH_LED[]		=;
static char GET_UNKNOWN2[]	=;
static char GET_CARRIER_FREQ[]	=;
static char GET_RX_TIMEOUT[]	=;
static char GET_NUM_PORTS[]	=;
static char GET_TX_BITMASK[]	=;
static char GET_RX_SENSOR[]	=;
/* sub in desired values in lower byte or bytes for full command */
/* FIXME: make use of these for transmit.
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};
*/

static int mceusb_cmd_datasize(u8 cmd, u8 subcmd)
{}

static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len,
				 int offset, int len, bool out)
{}

/*
 * Schedule work that can't be done in interrupt handlers
 * (mceusb_dev_recv() and mce_write_callback()) nor BH work.
 * 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)
{}

static void mce_write_callback(struct urb *urb)
{}

/*
 * Write (TX/send) data to MCE device USB endpoint out.
 * Used for IR blaster TX and MCE device commands.
 *
 * Return: The number of bytes written (> 0) or errno (< 0).
 */
static int mce_write(struct mceusb_dev *ir, u8 *data, int size)
{}

static void mce_command_out(struct mceusb_dev *ir, u8 *data, int size)
{}

/*
 * Transmit IR out the MCE device IR blaster port(s).
 *
 * Convert IR pulse/space sequence from LIRC to MCE format.
 * Break up a long IR sequence into multiple parts (MCE IR data packets).
 *
 * u32 txbuf[] consists of IR pulse, space, ..., and pulse times in usec.
 * Pulses and spaces are implicit by their position.
 * The first IR sample, txbuf[0], is always a pulse.
 *
 * u8 irbuf[] consists of multiple IR data packets for the MCE device.
 * A packet is 1 u8 MCE_IRDATA_HEADER and up to 30 u8 IR samples.
 * An IR sample is 1-bit pulse/space flag with 7-bit time
 * in MCE time units (50usec).
 *
 * Return: The number of IR samples sent (> 0) or errno (< 0).
 */
static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
{}

/* Sets active IR outputs -- mce devices typically have two */
static int mceusb_set_tx_mask(struct rc_dev *dev, u32 mask)
{}

/* Sets the send carrier frequency and mode */
static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
{}

static int mceusb_set_timeout(struct rc_dev *dev, unsigned int timeout)
{}

/*
 * 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)
{}

/*
 * 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)
{}

/*
 * Handle PORT_SYS/IR command response received from the MCE device.
 *
 * Assumes single response with all its data (not truncated)
 * in buf_in[]. The response itself determines its total length
 * (mceusb_cmd_datasize() + 2) and hence the minimum size of buf_in[].
 *
 * 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, u8 *buf_in)
{}

static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
{}

static void mceusb_dev_recv(struct urb *urb)
{}

static void mceusb_get_emulator_version(struct mceusb_dev *ir)
{}

static void mceusb_gen1_init(struct mceusb_dev *ir)
{}

static void mceusb_gen2_init(struct mceusb_dev *ir)
{}

static void mceusb_get_parameters(struct mceusb_dev *ir)
{}

static void mceusb_flash_led(struct mceusb_dev *ir)
{}

/*
 * 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)
{}

static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
{}

static int mceusb_dev_probe(struct usb_interface *intf,
			    const struct usb_device_id *id)
{}


static void mceusb_dev_disconnect(struct usb_interface *intf)
{}

static int mceusb_dev_suspend(struct usb_interface *intf, pm_message_t message)
{}

static int mceusb_dev_resume(struct usb_interface *intf)
{}

static struct usb_driver mceusb_dev_driver =;

module_usb_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_DEVICE_TABLE(usb, mceusb_dev_table);