diff options
author | Maxim Levitsky <maximlevitsky@gmail.com> | 2010-07-31 10:59:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-08 22:43:00 -0400 |
commit | 4a702ebf61120906696f8366dd2be0653b1643e3 (patch) | |
tree | d83d2662edcf538ebcb6bac103bdcadbed430426 /include/media | |
parent | b378f43fe9466e7712a8b16be64795ffca3a937e (diff) |
V4L/DVB: IR: add helper function for hardware with small o/b buffer
Some ir input devices have small buffer, and interrupt the host
each time it is full (or half full)
Add a helper that automaticly handles timeouts, and also
automaticly merges samples of same time (space-space)
Such samples might be placed by hardware because size of
sample in the buffer is small (a byte for example).
Also remove constness from ir_dev_props, because it now contains timeout
settings that driver might want to change
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Acked-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/ir-core.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/include/media/ir-core.h b/include/media/ir-core.h index 197d05aa83dc..a781045aeed5 100644 --- a/include/media/ir-core.h +++ b/include/media/ir-core.h | |||
@@ -41,6 +41,9 @@ enum rc_driver_type { | |||
41 | * anything with it. Yet, as the same keycode table can be used with other | 41 | * anything with it. Yet, as the same keycode table can be used with other |
42 | * devices, a mask is provided to allow its usage. Drivers should generally | 42 | * devices, a mask is provided to allow its usage. Drivers should generally |
43 | * leave this field in blank | 43 | * leave this field in blank |
44 | * @timeout: optional time after which device stops sending data | ||
45 | * @min_timeout: minimum timeout supported by device | ||
46 | * @max_timeout: maximum timeout supported by device | ||
44 | * @priv: driver-specific data, to be used on the callbacks | 47 | * @priv: driver-specific data, to be used on the callbacks |
45 | * @change_protocol: allow changing the protocol used on hardware decoders | 48 | * @change_protocol: allow changing the protocol used on hardware decoders |
46 | * @open: callback to allow drivers to enable polling/irq when IR input device | 49 | * @open: callback to allow drivers to enable polling/irq when IR input device |
@@ -50,11 +53,19 @@ enum rc_driver_type { | |||
50 | * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) | 53 | * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) |
51 | * @s_tx_carrier: set transmit carrier frequency | 54 | * @s_tx_carrier: set transmit carrier frequency |
52 | * @tx_ir: transmit IR | 55 | * @tx_ir: transmit IR |
56 | * @s_idle: optional: enable/disable hardware idle mode, upon which, | ||
57 | * device doesn't interrupt host untill it sees IR data | ||
53 | */ | 58 | */ |
54 | struct ir_dev_props { | 59 | struct ir_dev_props { |
55 | enum rc_driver_type driver_type; | 60 | enum rc_driver_type driver_type; |
56 | unsigned long allowed_protos; | 61 | unsigned long allowed_protos; |
57 | u32 scanmask; | 62 | u32 scanmask; |
63 | |||
64 | u32 timeout; | ||
65 | u32 min_timeout; | ||
66 | u32 max_timeout; | ||
67 | |||
68 | |||
58 | void *priv; | 69 | void *priv; |
59 | int (*change_protocol)(void *priv, u64 ir_type); | 70 | int (*change_protocol)(void *priv, u64 ir_type); |
60 | int (*open)(void *priv); | 71 | int (*open)(void *priv); |
@@ -62,6 +73,7 @@ struct ir_dev_props { | |||
62 | int (*s_tx_mask)(void *priv, u32 mask); | 73 | int (*s_tx_mask)(void *priv, u32 mask); |
63 | int (*s_tx_carrier)(void *priv, u32 carrier); | 74 | int (*s_tx_carrier)(void *priv, u32 carrier); |
64 | int (*tx_ir)(void *priv, int *txbuf, u32 n); | 75 | int (*tx_ir)(void *priv, int *txbuf, u32 n); |
76 | void (*s_idle)(void *priv, int enable); | ||
65 | }; | 77 | }; |
66 | 78 | ||
67 | struct ir_input_dev { | 79 | struct ir_input_dev { |
@@ -69,9 +81,10 @@ struct ir_input_dev { | |||
69 | char *driver_name; /* Name of the driver module */ | 81 | char *driver_name; /* Name of the driver module */ |
70 | struct ir_scancode_table rc_tab; /* scan/key table */ | 82 | struct ir_scancode_table rc_tab; /* scan/key table */ |
71 | unsigned long devno; /* device number */ | 83 | unsigned long devno; /* device number */ |
72 | const struct ir_dev_props *props; /* Device properties */ | 84 | struct ir_dev_props *props; /* Device properties */ |
73 | struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */ | 85 | struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */ |
74 | struct input_dev *input_dev; /* the input device associated with this device */ | 86 | struct input_dev *input_dev; /* the input device associated with this device */ |
87 | bool idle; | ||
75 | 88 | ||
76 | /* key info - needed by IR keycode handlers */ | 89 | /* key info - needed by IR keycode handlers */ |
77 | spinlock_t keylock; /* protects the below members */ | 90 | spinlock_t keylock; /* protects the below members */ |
@@ -95,12 +108,12 @@ enum raw_event_type { | |||
95 | /* From ir-keytable.c */ | 108 | /* From ir-keytable.c */ |
96 | int __ir_input_register(struct input_dev *dev, | 109 | int __ir_input_register(struct input_dev *dev, |
97 | const struct ir_scancode_table *ir_codes, | 110 | const struct ir_scancode_table *ir_codes, |
98 | const struct ir_dev_props *props, | 111 | struct ir_dev_props *props, |
99 | const char *driver_name); | 112 | const char *driver_name); |
100 | 113 | ||
101 | static inline int ir_input_register(struct input_dev *dev, | 114 | static inline int ir_input_register(struct input_dev *dev, |
102 | const char *map_name, | 115 | const char *map_name, |
103 | const struct ir_dev_props *props, | 116 | struct ir_dev_props *props, |
104 | const char *driver_name) { | 117 | const char *driver_name) { |
105 | struct ir_scancode_table *ir_codes; | 118 | struct ir_scancode_table *ir_codes; |
106 | struct ir_input_dev *ir_dev; | 119 | struct ir_input_dev *ir_dev; |
@@ -148,6 +161,10 @@ struct ir_raw_event { | |||
148 | void ir_raw_event_handle(struct input_dev *input_dev); | 161 | void ir_raw_event_handle(struct input_dev *input_dev); |
149 | int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev); | 162 | int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev); |
150 | int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type); | 163 | int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type); |
164 | int ir_raw_event_store_with_filter(struct input_dev *input_dev, | ||
165 | struct ir_raw_event *ev); | ||
166 | void ir_raw_event_set_idle(struct input_dev *input_dev, int idle); | ||
167 | |||
151 | static inline void ir_raw_event_reset(struct input_dev *input_dev) | 168 | static inline void ir_raw_event_reset(struct input_dev *input_dev) |
152 | { | 169 | { |
153 | struct ir_raw_event ev = { .pulse = false, .duration = 0 }; | 170 | struct ir_raw_event ev = { .pulse = false, .duration = 0 }; |