8. Remote Controller devices¶
8.1. Remote Controller core¶
-
enum
rc_driver_type
¶ type of the RC output
Constants
RC_DRIVER_SCANCODE
- Driver or hardware generates a scancode
RC_DRIVER_IR_RAW
- Driver or hardware generates pulse/space sequences. It needs a Infra-Red pulse/space decoder
-
struct
rc_scancode_filter
¶ Filter scan codes.
Definition
struct rc_scancode_filter {
u32 data;
u32 mask;
};
Members
u32 data
- Scancode data to match.
u32 mask
- Mask of bits of scancode to compare.
-
enum
rc_filter_type
¶ Filter type constants.
Constants
RC_FILTER_NORMAL
- Filter for normal operation.
RC_FILTER_WAKEUP
- Filter for waking from suspend.
RC_FILTER_MAX
- Number of filter types.
-
struct
rc_dev
¶ represents a remote control device
Definition
struct rc_dev {
struct device dev;
atomic_t initialized;
const struct attribute_group * sysfs_groups[5];
const char * input_name;
const char * input_phys;
struct input_id input_id;
char * driver_name;
const char * map_name;
struct rc_map rc_map;
struct mutex lock;
unsigned int minor;
struct ir_raw_event_ctrl * raw;
struct input_dev * input_dev;
enum rc_driver_type driver_type;
bool idle;
u64 allowed_protocols;
u64 enabled_protocols;
u64 allowed_wakeup_protocols;
u64 enabled_wakeup_protocols;
struct rc_scancode_filter scancode_filter;
struct rc_scancode_filter scancode_wakeup_filter;
u32 scancode_mask;
u32 users;
void * priv;
spinlock_t keylock;
bool keypressed;
unsigned long keyup_jiffies;
struct timer_list timer_keyup;
u32 last_keycode;
enum rc_type last_protocol;
u32 last_scancode;
u8 last_toggle;
u32 timeout;
u32 min_timeout;
u32 max_timeout;
u32 rx_resolution;
u32 tx_resolution;
int (* change_protocol) (struct rc_dev *dev, u64 *rc_type);
int (* change_wakeup_protocol) (struct rc_dev *dev, u64 *rc_type);
int (* open) (struct rc_dev *dev);
void (* close) (struct rc_dev *dev);
int (* s_tx_mask) (struct rc_dev *dev, u32 mask);
int (* s_tx_carrier) (struct rc_dev *dev, u32 carrier);
int (* s_tx_duty_cycle) (struct rc_dev *dev, u32 duty_cycle);
int (* s_rx_carrier_range) (struct rc_dev *dev, u32 min, u32 max);
int (* tx_ir) (struct rc_dev *dev, unsigned *txbuf, unsigned n);
void (* s_idle) (struct rc_dev *dev, bool enable);
int (* s_learning_mode) (struct rc_dev *dev, int enable);
int (* s_carrier_report) (struct rc_dev *dev, int enable);
int (* s_filter) (struct rc_dev *dev,struct rc_scancode_filter *filter);
int (* s_wakeup_filter) (struct rc_dev *dev,struct rc_scancode_filter *filter);
int (* s_timeout) (struct rc_dev *dev,unsigned int timeout);
};
Members
struct device dev
- driver model’s view of this device
atomic_t initialized
- 1 if the device init has completed, 0 otherwise
const struct attribute_group * sysfs_groups[5]
- sysfs attribute groups
const char * input_name
- name of the input child device
const char * input_phys
- physical path to the input child device
struct input_id input_id
- id of the input child device (struct input_id)
char * driver_name
- name of the hardware driver which registered this device
const char * map_name
- name of the default keymap
struct rc_map rc_map
- current scan/key table
struct mutex lock
- used to ensure we’ve filled in all protocol details before anyone can call show_protocols or store_protocols
unsigned int minor
- unique minor remote control device number
struct ir_raw_event_ctrl * raw
- additional data for raw pulse/space devices
struct input_dev * input_dev
- the input child device used to communicate events to userspace
enum rc_driver_type driver_type
- specifies if protocol decoding is done in hardware or software
bool idle
- used to keep track of RX state
u64 allowed_protocols
- bitmask with the supported RC_BIT_* protocols
u64 enabled_protocols
- bitmask with the enabled RC_BIT_* protocols
u64 allowed_wakeup_protocols
- bitmask with the supported RC_BIT_* wakeup protocols
u64 enabled_wakeup_protocols
- bitmask with the enabled RC_BIT_* wakeup protocols
struct rc_scancode_filter scancode_filter
- scancode filter
struct rc_scancode_filter scancode_wakeup_filter
- scancode wakeup filters
u32 scancode_mask
- some hardware decoders are not capable of providing the full scancode to the application. As this is a hardware limit, we can’t do anything with it. Yet, as the same keycode table can be used with other devices, a mask is provided to allow its usage. Drivers should generally leave this field in blank
u32 users
- number of current users of the device
void * priv
- driver-specific data
spinlock_t keylock
- protects the remaining members of the struct
bool keypressed
- whether a key is currently pressed
unsigned long keyup_jiffies
- time (in jiffies) when the current keypress should be released
struct timer_list timer_keyup
- timer for releasing a keypress
u32 last_keycode
- keycode of last keypress
enum rc_type last_protocol
- protocol of last keypress
u32 last_scancode
- scancode of last keypress
u8 last_toggle
- toggle value of last command
u32 timeout
- optional time after which device stops sending data
u32 min_timeout
- minimum timeout supported by device
u32 max_timeout
- maximum timeout supported by device
u32 rx_resolution
- resolution (in ns) of input sampler
u32 tx_resolution
- resolution (in ns) of output sampler
int (*)(struct rc_dev *dev, u64 *rc_type) change_protocol
- allow changing the protocol used on hardware decoders
int (*)(struct rc_dev *dev, u64 *rc_type) change_wakeup_protocol
- allow changing the protocol used for wakeup filtering
int (*)(struct rc_dev *dev) open
- callback to allow drivers to enable polling/irq when IR input device is opened.
void (*)(struct rc_dev *dev) close
- callback to allow drivers to disable polling/irq when IR input device is opened.
int (*)(struct rc_dev *dev, u32 mask) s_tx_mask
- set transmitter mask (for devices with multiple tx outputs)
int (*)(struct rc_dev *dev, u32 carrier) s_tx_carrier
- set transmit carrier frequency
int (*)(struct rc_dev *dev, u32 duty_cycle) s_tx_duty_cycle
- set transmit duty cycle (0% - 100%)
int (*)(struct rc_dev *dev, u32 min, u32 max) s_rx_carrier_range
- inform driver about carrier it is expected to handle
int (*)(struct rc_dev *dev, unsigned *txbuf, unsigned n) tx_ir
- transmit IR
void (*)(struct rc_dev *dev, bool enable) s_idle
- enable/disable hardware idle mode, upon which, device doesn’t interrupt host until it sees IR pulses
int (*)(struct rc_dev *dev, int enable) s_learning_mode
- enable wide band receiver used for learning
int (*) (struct rc_dev *dev, int enable) s_carrier_report
- enable carrier reports
int (*)(struct rc_dev *dev,struct rc_scancode_filter *filter) s_filter
- set the scancode filter
int (*)(struct rc_dev *dev,struct rc_scancode_filter *filter) s_wakeup_filter
- set the wakeup scancode filter
int (*)(struct rc_dev *dev,unsigned int timeout) s_timeout
- set hardware timeout in ns
Parameters
void
- no arguments
Description
returns a pointer to struct rc_dev.
Parameters
struct rc_dev * dev
- pointer to struct rc_dev.
Parameters
struct rc_dev * dev
- pointer to struct rc_dev.
Parameters
struct rc_dev * dev
- pointer to struct rc_dev.
Parameters
struct rc_dev * rdev
- pointer to struct rc_dev.
Parameters
struct rc_dev * rdev
- pointer to struct rc_dev.
-
int
rc_map_register
(struct rc_map_list * map)¶ Registers a Remote Controler scancode map
Parameters
struct rc_map_list * map
- pointer to struct rc_map_list
-
void
rc_map_unregister
(struct rc_map_list * map)¶ Unregisters a Remote Controler scancode map
Parameters
struct rc_map_list * map
- pointer to struct rc_map_list
-
struct rc_map *
rc_map_get
(const char * name)¶ gets an RC map from its name
Parameters
const char * name
- name of the RC scancode map
8.2. LIRC¶
-
struct
lirc_driver
¶ Defines the parameters on a LIRC driver
Definition
struct lirc_driver {
char name[40];
int minor;
__u32 code_length;
unsigned int buffer_size;
int sample_rate;
__u32 features;
unsigned int chunk_size;
void * data;
int min_timeout;
int max_timeout;
int (* add_to_buf) (void *data, struct lirc_buffer *buf);
struct lirc_buffer * rbuf;
int (* set_use_inc) (void *data);
void (* set_use_dec) (void *data);
struct rc_dev * rdev;
const struct file_operations * fops;
struct device * dev;
struct module * owner;
};
Members
char name[40]
- this string will be used for logs
int minor
- indicates minor device (/dev/lirc) number for registered driver if caller fills it with negative value, then the first free minor number will be used (if available).
__u32 code_length
- length of the remote control key code expressed in bits.
unsigned int buffer_size
- Number of FIFO buffers with chunk_size size. If zero, creates a buffer with BUFLEN size (16 bytes).
int sample_rate
- if zero, the device will wait for an event with a new code to be parsed. Otherwise, specifies the sample rate for polling. Value should be between 0 and HZ. If equal to HZ, it would mean one polling per second.
__u32 features
- lirc compatible hardware features, like LIRC_MODE_RAW, LIRC_CAN_*, as defined at include/media/lirc.h.
unsigned int chunk_size
- Size of each FIFO buffer.
void * data
- it may point to any driver data and this pointer will be passed to all callback functions.
int min_timeout
- Minimum timeout for record. Valid only if LIRC_CAN_SET_REC_TIMEOUT is defined.
int max_timeout
- Maximum timeout for record. Valid only if LIRC_CAN_SET_REC_TIMEOUT is defined.
int (*)(void *data, struct lirc_buffer *buf) add_to_buf
- add_to_buf will be called after specified period of the time or triggered by the external event, this behavior depends on value of the sample_rate this function will be called in user context. This routine should return 0 if data was added to the buffer and -ENODATA if none was available. This should add some number of bits evenly divisible by code_length to the buffer.
struct lirc_buffer * rbuf
- if not NULL, it will be used as a read buffer, you will have to write to the buffer by other means, like irq’s (see also lirc_serial.c).
int (*)(void *data) set_use_inc
- set_use_inc will be called after device is opened
void (*)(void *data) set_use_dec
- set_use_dec will be called after device is closed
struct rc_dev * rdev
- Pointed to struct rc_dev associated with the LIRC device.
const struct file_operations * fops
- file_operations for drivers which don’t fit the current driver model. Some ioctl’s can be directly handled by lirc_dev if the driver’s ioctl function is NULL or if it returns -ENOIOCTLCMD (see also lirc_serial.c).
struct device * dev
- pointer to the struct device associated with the LIRC device.
struct module * owner
- the module owning this struct