aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/rc-core.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/rc-core.h')
-rw-r--r--include/media/rc-core.h69
1 files changed, 53 insertions, 16 deletions
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 314a1edb6189..aed4272d47f5 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -17,6 +17,7 @@
17#define _RC_CORE 17#define _RC_CORE
18 18
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/cdev.h>
20#include <linux/kfifo.h> 21#include <linux/kfifo.h>
21#include <linux/time.h> 22#include <linux/time.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
@@ -30,9 +31,9 @@ do { \
30} while (0) 31} while (0)
31 32
32/** 33/**
33 * enum rc_driver_type - type of the RC output 34 * enum rc_driver_type - type of the RC driver.
34 * 35 *
35 * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode 36 * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode.
36 * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences. 37 * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences.
37 * It needs a Infra-Red pulse/space decoder 38 * It needs a Infra-Red pulse/space decoder
38 * @RC_DRIVER_IR_RAW_TX: Device transmitter only, 39 * @RC_DRIVER_IR_RAW_TX: Device transmitter only,
@@ -68,6 +69,33 @@ enum rc_filter_type {
68}; 69};
69 70
70/** 71/**
72 * struct lirc_fh - represents an open lirc file
73 * @list: list of open file handles
74 * @rc: rcdev for this lirc chardev
75 * @carrier_low: when setting the carrier range, first the low end must be
76 * set with an ioctl and then the high end with another ioctl
77 * @send_timeout_reports: report timeouts in lirc raw IR.
78 * @rawir: queue for incoming raw IR
79 * @scancodes: queue for incoming decoded scancodes
80 * @wait_poll: poll struct for lirc device
81 * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or
82 * LIRC_MODE_PULSE
83 * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or
84 * LIRC_MODE_MODE2
85 */
86struct lirc_fh {
87 struct list_head list;
88 struct rc_dev *rc;
89 int carrier_low;
90 bool send_timeout_reports;
91 DECLARE_KFIFO_PTR(rawir, unsigned int);
92 DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode);
93 wait_queue_head_t wait_poll;
94 u8 send_mode;
95 u8 rec_mode;
96};
97
98/**
71 * struct rc_dev - represents a remote control device 99 * struct rc_dev - represents a remote control device
72 * @dev: driver model's view of this device 100 * @dev: driver model's view of this device
73 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev 101 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev
@@ -106,6 +134,8 @@ enum rc_filter_type {
106 * @keypressed: whether a key is currently pressed 134 * @keypressed: whether a key is currently pressed
107 * @keyup_jiffies: time (in jiffies) when the current keypress should be released 135 * @keyup_jiffies: time (in jiffies) when the current keypress should be released
108 * @timer_keyup: timer for releasing a keypress 136 * @timer_keyup: timer for releasing a keypress
137 * @timer_repeat: timer for autorepeat events. This is needed for CEC, which
138 * has non-standard repeats.
109 * @last_keycode: keycode of last keypress 139 * @last_keycode: keycode of last keypress
110 * @last_protocol: protocol of last keypress 140 * @last_protocol: protocol of last keypress
111 * @last_scancode: scancode of last keypress 141 * @last_scancode: scancode of last keypress
@@ -115,6 +145,15 @@ enum rc_filter_type {
115 * @max_timeout: maximum timeout supported by device 145 * @max_timeout: maximum timeout supported by device
116 * @rx_resolution : resolution (in ns) of input sampler 146 * @rx_resolution : resolution (in ns) of input sampler
117 * @tx_resolution: resolution (in ns) of output sampler 147 * @tx_resolution: resolution (in ns) of output sampler
148 * @lirc_dev: lirc device
149 * @lirc_cdev: lirc char cdev
150 * @gap_start: time when gap starts
151 * @gap_duration: duration of initial gap
152 * @gap: true if we're in a gap
153 * @lirc_fh_lock: protects lirc_fh list
154 * @lirc_fh: list of open files
155 * @registered: set to true by rc_register_device(), false by
156 * rc_unregister_device
118 * @change_protocol: allow changing the protocol used on hardware decoders 157 * @change_protocol: allow changing the protocol used on hardware decoders
119 * @open: callback to allow drivers to enable polling/irq when IR input device 158 * @open: callback to allow drivers to enable polling/irq when IR input device
120 * is opened. 159 * is opened.
@@ -165,6 +204,7 @@ struct rc_dev {
165 bool keypressed; 204 bool keypressed;
166 unsigned long keyup_jiffies; 205 unsigned long keyup_jiffies;
167 struct timer_list timer_keyup; 206 struct timer_list timer_keyup;
207 struct timer_list timer_repeat;
168 u32 last_keycode; 208 u32 last_keycode;
169 enum rc_proto last_protocol; 209 enum rc_proto last_protocol;
170 u32 last_scancode; 210 u32 last_scancode;
@@ -174,6 +214,16 @@ struct rc_dev {
174 u32 max_timeout; 214 u32 max_timeout;
175 u32 rx_resolution; 215 u32 rx_resolution;
176 u32 tx_resolution; 216 u32 tx_resolution;
217#ifdef CONFIG_LIRC
218 struct device lirc_dev;
219 struct cdev lirc_cdev;
220 ktime_t gap_start;
221 u64 gap_duration;
222 bool gap;
223 spinlock_t lirc_fh_lock;
224 struct list_head lirc_fh;
225#endif
226 bool registered;
177 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); 227 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
178 int (*open)(struct rc_dev *dev); 228 int (*open)(struct rc_dev *dev);
179 void (*close)(struct rc_dev *dev); 229 void (*close)(struct rc_dev *dev);
@@ -248,20 +298,6 @@ int devm_rc_register_device(struct device *parent, struct rc_dev *dev);
248 */ 298 */
249void rc_unregister_device(struct rc_dev *dev); 299void rc_unregister_device(struct rc_dev *dev);
250 300
251/**
252 * rc_open - Opens a RC device
253 *
254 * @rdev: pointer to struct rc_dev.
255 */
256int rc_open(struct rc_dev *rdev);
257
258/**
259 * rc_close - Closes a RC device
260 *
261 * @rdev: pointer to struct rc_dev.
262 */
263void rc_close(struct rc_dev *rdev);
264
265void rc_repeat(struct rc_dev *dev); 301void rc_repeat(struct rc_dev *dev);
266void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode, 302void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode,
267 u8 toggle); 303 u8 toggle);
@@ -309,6 +345,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev,
309void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); 345void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
310int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode, 346int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode,
311 struct ir_raw_event *events, unsigned int max); 347 struct ir_raw_event *events, unsigned int max);
348int ir_raw_encode_carrier(enum rc_proto protocol);
312 349
313static inline void ir_raw_event_reset(struct rc_dev *dev) 350static inline void ir_raw_event_reset(struct rc_dev *dev)
314{ 351{