linux/drivers/media/rc/redrat3.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * USB RedRat3 IR Transceiver rc-core driver
 *
 * Copyright (c) 2011 by Jarod Wilson <[email protected]>
 *  based heavily on the work of Stephen Cox, with additional
 *  help from RedRat Ltd.
 *
 * This driver began life based on an old version of the first-generation
 * lirc_mceusb driver from the lirc 0.7.2 distribution. It was then
 * significantly rewritten by Stephen Cox with the aid of RedRat Ltd's
 * Chris Dodge.
 *
 * The driver was then ported to rc-core and significantly rewritten again,
 * by Jarod, using the in-kernel mceusb driver as a guide, after an initial
 * port effort was started by Stephen.
 *
 * TODO LIST:
 * - fix lirc not showing repeats properly
 * --
 *
 * The RedRat3 is a USB transceiver with both send & receive,
 * with 2 separate sensors available for receive to enable
 * both good long range reception for general use, and good
 * short range reception when required for learning a signal.
 *
 * http://www.redrat.co.uk/
 *
 * It uses its own little protocol to communicate, the required
 * parts of which are embedded within this driver.
 * --
 */

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

/* Driver Information */
#define DRIVER_AUTHOR
#define DRIVER_AUTHOR2
#define DRIVER_DESC
#define DRIVER_NAME

/* bulk data transfer types */
#define RR3_ERROR
#define RR3_MOD_SIGNAL_IN
#define RR3_MOD_SIGNAL_OUT

/* Get the RR firmware version */
#define RR3_FW_VERSION
#define RR3_FW_VERSION_LEN
/* Send encoded signal bulk-sent earlier*/
#define RR3_TX_SEND_SIGNAL
#define RR3_SET_IR_PARAM
#define RR3_GET_IR_PARAM
/* Blink the red LED on the device */
#define RR3_BLINK_LED
/* Read serial number of device */
#define RR3_READ_SER_NO
#define RR3_SER_NO_LEN
/* Start capture with the RC receiver */
#define RR3_RC_DET_ENABLE
/* Stop capture with the RC receiver */
#define RR3_RC_DET_DISABLE
/* Start capture with the wideband receiver */
#define RR3_MODSIG_CAPTURE
/* Return the status of RC detector capture */
#define RR3_RC_DET_STATUS
/* Reset redrat */
#define RR3_RESET

/* Max number of lengths in the signal. */
#define RR3_IR_IO_MAX_LENGTHS
/* Periods to measure mod. freq. */
#define RR3_IR_IO_PERIODS_MF
/* Size of memory for main signal data */
#define RR3_IR_IO_SIG_MEM_SIZE
/* Delta value when measuring lengths */
#define RR3_IR_IO_LENGTH_FUZZ
/* Timeout for end of signal detection */
#define RR3_IR_IO_SIG_TIMEOUT
/* Minimum value for pause recognition. */
#define RR3_IR_IO_MIN_PAUSE

/* Clock freq. of EZ-USB chip */
#define RR3_CLK
/* Clock periods per timer count */
#define RR3_CLK_PER_COUNT
/* (RR3_CLK / RR3_CLK_PER_COUNT) */
#define RR3_CLK_CONV_FACTOR
/* USB bulk-in wideband IR data endpoint address */
#define RR3_WIDE_IN_EP_ADDR
/* USB bulk-in narrowband IR data endpoint address */
#define RR3_NARROW_IN_EP_ADDR

/* Size of the fixed-length portion of the signal */
#define RR3_DRIVER_MAXLENS
#define RR3_MAX_SIG_SIZE
#define RR3_TIME_UNIT
#define RR3_END_OF_SIGNAL
#define RR3_TX_TRAILER_LEN
#define RR3_RX_MIN_TIMEOUT
#define RR3_RX_MAX_TIMEOUT

/* The 8051's CPUCS Register address */
#define RR3_CPUCS_REG_ADDR

#define USB_RR3USB_VENDOR_ID
#define USB_RR3USB_PRODUCT_ID
#define USB_RR3IIUSB_PRODUCT_ID


/*
 * The redrat3 encodes an IR signal as set of different lengths and a set
 * of indices into those lengths. This sets how much two lengths must
 * differ before they are considered distinct, the value is specified
 * in microseconds.
 * Default 5, value 0 to 127.
 */
static int length_fuzz =;
module_param(length_fuzz, uint, 0644);
MODULE_PARM_DESC();

/*
 * When receiving a continuous ir stream (for example when a user is
 * holding a button down on a remote), this specifies the minimum size
 * of a space when the redrat3 sends a irdata packet to the host. Specified
 * in milliseconds. Default value 18ms.
 * The value can be between 2 and 30 inclusive.
 */
static int minimum_pause =;
module_param(minimum_pause, uint, 0644);
MODULE_PARM_DESC();

/*
 * The carrier frequency is measured during the first pulse of the IR
 * signal. The larger the number of periods used To measure, the more
 * accurate the result is likely to be, however some signals have short
 * initial pulses, so in some case it may be necessary to reduce this value.
 * Default 8, value 1 to 255.
 */
static int periods_measure_carrier =;
module_param(periods_measure_carrier, uint, 0644);
MODULE_PARM_DESC();


struct redrat3_header {} __packed;

/* sending and receiving irdata */
struct redrat3_irdata {} __packed;

/* firmware errors */
struct redrat3_error {} __packed;

/* table of devices that work with this driver */
static const struct usb_device_id redrat3_dev_table[] =;

/* Structure to hold all of our device specific stuff */
struct redrat3_dev {};

static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code)
{}

static u32 redrat3_val_to_mod_freq(struct redrat3_irdata *irdata)
{}

/* this function scales down the figures for the same result... */
static u32 redrat3_len_to_us(u32 length)
{}

/*
 * convert us back into redrat3 lengths
 *
 * length * 1000   length * 1000000
 * ------------- = ---------------- = micro
 * rr3clk / 1000       rr3clk

 * 6 * 2       4 * 3        micro * rr3clk          micro * rr3clk / 1000
 * ----- = 4   ----- = 6    -------------- = len    ---------------------
 *   3           2             1000000                    1000
 */
static u32 redrat3_us_to_len(u32 microsec)
{}

static void redrat3_process_ir_data(struct redrat3_dev *rr3)
{}

/* Util fn to send rr3 cmds */
static int redrat3_send_cmd(int cmd, struct redrat3_dev *rr3)
{}

/* Enables the long range detector and starts async receive */
static int redrat3_enable_detector(struct redrat3_dev *rr3)
{}

static inline void redrat3_delete(struct redrat3_dev *rr3,
				  struct usb_device *udev)
{}

static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
{}

static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutus)
{}

static void redrat3_reset(struct redrat3_dev *rr3)
{}

static void redrat3_get_firmware_rev(struct redrat3_dev *rr3)
{}

static void redrat3_read_packet_start(struct redrat3_dev *rr3, unsigned len)
{}

static void redrat3_read_packet_continue(struct redrat3_dev *rr3, unsigned len)
{}

/* gather IR data from incoming urb, process it when we have enough */
static int redrat3_get_ir_data(struct redrat3_dev *rr3, unsigned len)
{}

/* callback function from USB when async USB request has completed */
static void redrat3_handle_async(struct urb *urb)
{}

static u16 mod_freq_to_val(unsigned int mod_freq)
{}

static int redrat3_set_tx_carrier(struct rc_dev *rcdev, u32 carrier)
{}

static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
				unsigned count)
{}

static void redrat3_brightness_set(struct led_classdev *led_dev, enum
						led_brightness brightness)
{}

static int redrat3_wideband_receiver(struct rc_dev *rcdev, int enable)
{}

static void redrat3_learn_complete(struct urb *urb)
{}

static void redrat3_led_complete(struct urb *urb)
{}

static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
{}

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

static void redrat3_dev_disconnect(struct usb_interface *intf)
{}

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

static int redrat3_dev_resume(struct usb_interface *intf)
{}

static struct usb_driver redrat3_dev_driver =;

module_usb_driver();

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