diff options
Diffstat (limited to 'drivers/media/IR/ir-raw-event.c')
-rw-r--r-- | drivers/media/IR/ir-raw-event.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c index 119b567feeab..0d59ef7d1014 100644 --- a/drivers/media/IR/ir-raw-event.c +++ b/drivers/media/IR/ir-raw-event.c | |||
@@ -174,7 +174,7 @@ int ir_raw_event_store_with_filter(struct input_dev *input_dev, | |||
174 | if (ir->idle && !ev->pulse) | 174 | if (ir->idle && !ev->pulse) |
175 | return 0; | 175 | return 0; |
176 | else if (ir->idle) | 176 | else if (ir->idle) |
177 | ir_raw_event_set_idle(input_dev, 0); | 177 | ir_raw_event_set_idle(input_dev, false); |
178 | 178 | ||
179 | if (!raw->this_ev.duration) { | 179 | if (!raw->this_ev.duration) { |
180 | raw->this_ev = *ev; | 180 | raw->this_ev = *ev; |
@@ -187,48 +187,35 @@ int ir_raw_event_store_with_filter(struct input_dev *input_dev, | |||
187 | 187 | ||
188 | /* Enter idle mode if nessesary */ | 188 | /* Enter idle mode if nessesary */ |
189 | if (!ev->pulse && ir->props->timeout && | 189 | if (!ev->pulse && ir->props->timeout && |
190 | raw->this_ev.duration >= ir->props->timeout) | 190 | raw->this_ev.duration >= ir->props->timeout) { |
191 | ir_raw_event_set_idle(input_dev, 1); | 191 | ir_raw_event_set_idle(input_dev, true); |
192 | } | ||
192 | return 0; | 193 | return 0; |
193 | } | 194 | } |
194 | EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter); | 195 | EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter); |
195 | 196 | ||
196 | void ir_raw_event_set_idle(struct input_dev *input_dev, int idle) | 197 | /** |
198 | * ir_raw_event_set_idle() - hint the ir core if device is receiving | ||
199 | * IR data or not | ||
200 | * @input_dev: the struct input_dev device descriptor | ||
201 | * @idle: the hint value | ||
202 | */ | ||
203 | void ir_raw_event_set_idle(struct input_dev *input_dev, bool idle) | ||
197 | { | 204 | { |
198 | struct ir_input_dev *ir = input_get_drvdata(input_dev); | 205 | struct ir_input_dev *ir = input_get_drvdata(input_dev); |
199 | struct ir_raw_event_ctrl *raw = ir->raw; | 206 | struct ir_raw_event_ctrl *raw = ir->raw; |
200 | ktime_t now; | ||
201 | u64 delta; | ||
202 | 207 | ||
203 | if (!ir->props) | 208 | if (!ir->props || !ir->raw) |
204 | return; | 209 | return; |
205 | 210 | ||
206 | if (!ir->raw) | 211 | IR_dprintk(2, "%s idle mode\n", idle ? "enter" : "leave"); |
207 | goto out; | ||
208 | 212 | ||
209 | if (idle) { | 213 | if (idle) { |
210 | IR_dprintk(2, "enter idle mode\n"); | 214 | raw->this_ev.timeout = true; |
211 | raw->last_event = ktime_get(); | ||
212 | } else { | ||
213 | IR_dprintk(2, "exit idle mode\n"); | ||
214 | |||
215 | now = ktime_get(); | ||
216 | delta = ktime_to_ns(ktime_sub(now, ir->raw->last_event)); | ||
217 | |||
218 | WARN_ON(raw->this_ev.pulse); | ||
219 | |||
220 | raw->this_ev.duration = | ||
221 | min(raw->this_ev.duration + delta, | ||
222 | (u64)IR_MAX_DURATION); | ||
223 | |||
224 | ir_raw_event_store(input_dev, &raw->this_ev); | 215 | ir_raw_event_store(input_dev, &raw->this_ev); |
225 | 216 | init_ir_raw_event(&raw->this_ev); | |
226 | if (raw->this_ev.duration == IR_MAX_DURATION) | ||
227 | ir_raw_event_reset(input_dev); | ||
228 | |||
229 | raw->this_ev.duration = 0; | ||
230 | } | 217 | } |
231 | out: | 218 | |
232 | if (ir->props->s_idle) | 219 | if (ir->props->s_idle) |
233 | ir->props->s_idle(ir->props->priv, idle); | 220 | ir->props->s_idle(ir->props->priv, idle); |
234 | ir->idle = idle; | 221 | ir->idle = idle; |