Lines Matching full:raw

2 // rc-ir-raw.c - handle IR pulse/space events
13 /* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */
16 /* Used to handle IR raw handler extensions */
25 struct ir_raw_event_ctrl *raw = data; in ir_raw_event_thread() local
26 struct rc_dev *dev = raw->dev; in ir_raw_event_thread()
30 while (kfifo_out(&raw->kfifo, &ev, 1)) { in ir_raw_event_thread()
34 if (is_timing_event(raw->prev_ev) && in ir_raw_event_thread()
35 !is_transition(&ev, &raw->prev_ev)) in ir_raw_event_thread()
44 raw->prev_ev = ev; in ir_raw_event_thread()
53 } else if (!kfifo_is_empty(&raw->kfifo)) in ir_raw_event_thread()
63 * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
68 * pulse/space duration for the raw ir decoding state machines. Pulses are
74 if (!dev->raw) in ir_raw_event_store()
80 if (!kfifo_put(&dev->raw->kfifo, *ev)) { in ir_raw_event_store()
90 * ir_raw_event_store_edge() - notify raw ir decoders of the start of a pulse/space
96 * reception) for the raw ir decoding state machines. This is used by
105 if (!dev->raw) in ir_raw_event_store_edge()
109 ev.duration = ktime_to_us(ktime_sub(now, dev->raw->last_event)); in ir_raw_event_store_edge()
117 * ir_raw_event_store_with_timeout() - pass a pulse/space duration to the raw
124 * pulse/space duration for the raw ir decoding state machines, schedules
132 if (!dev->raw) in ir_raw_event_store_with_timeout()
137 spin_lock(&dev->raw->edge_spinlock); in ir_raw_event_store_with_timeout()
140 dev->raw->last_event = now; in ir_raw_event_store_with_timeout()
143 if (!timer_pending(&dev->raw->edge_handle) || in ir_raw_event_store_with_timeout()
144 time_after(dev->raw->edge_handle.expires, in ir_raw_event_store_with_timeout()
146 mod_timer(&dev->raw->edge_handle, in ir_raw_event_store_with_timeout()
149 spin_unlock(&dev->raw->edge_spinlock); in ir_raw_event_store_with_timeout()
169 if (!dev->raw) in ir_raw_event_store_with_filter()
178 if (!dev->raw->this_ev.duration) in ir_raw_event_store_with_filter()
179 dev->raw->this_ev = *ev; in ir_raw_event_store_with_filter()
180 else if (ev->pulse == dev->raw->this_ev.pulse) in ir_raw_event_store_with_filter()
181 dev->raw->this_ev.duration += ev->duration; in ir_raw_event_store_with_filter()
183 ir_raw_event_store(dev, &dev->raw->this_ev); in ir_raw_event_store_with_filter()
184 dev->raw->this_ev = *ev; in ir_raw_event_store_with_filter()
189 dev->raw->this_ev.duration >= dev->timeout) in ir_raw_event_store_with_filter()
203 if (!dev->raw) in ir_raw_event_set_idle()
209 dev->raw->this_ev.timeout = true; in ir_raw_event_set_idle()
210 ir_raw_event_store(dev, &dev->raw->this_ev); in ir_raw_event_set_idle()
211 dev->raw->this_ev = (struct ir_raw_event) {}; in ir_raw_event_set_idle()
229 if (!dev->raw || !dev->raw->thread) in ir_raw_event_handle()
232 wake_up_process(dev->raw->thread); in ir_raw_event_handle()
301 * each raw event filled.
302 * @max: Maximum number of raw events to fill.
309 * to @max raw IR events using the *@ev pointer.
381 * ir_raw_gen_pd() - Encode data to raw events with pulse-distance modulation.
383 * each raw event filled.
384 * @max: Maximum number of raw events to fill.
391 * to @max raw IR events using the *@ev pointer.
440 * ir_raw_gen_pl() - Encode data to raw events with pulse-length modulation.
442 * each raw event filled.
443 * @max: Maximum number of raw events to fill.
450 * to @max raw IR events using the *@ev pointer.
504 * ir_raw_encode_scancode() - Encode a scancode as raw events
508 * @events: array of raw events to write into
509 * @max: max number of raw events
511 * Attempts to encode the scancode as raw events.
555 struct ir_raw_event_ctrl *raw = from_timer(raw, t, edge_handle); in ir_raw_edge_handle() local
556 struct rc_dev *dev = raw->dev; in ir_raw_edge_handle()
560 spin_lock_irqsave(&dev->raw->edge_spinlock, flags); in ir_raw_edge_handle()
561 interval = ktime_sub(ktime_get(), dev->raw->last_event); in ir_raw_edge_handle()
570 mod_timer(&dev->raw->edge_handle, in ir_raw_edge_handle()
574 spin_unlock_irqrestore(&dev->raw->edge_spinlock, flags); in ir_raw_edge_handle()
610 * Used to (un)register raw event clients
617 dev->raw = kzalloc(sizeof(*dev->raw), GFP_KERNEL); in ir_raw_event_prepare()
618 if (!dev->raw) in ir_raw_event_prepare()
621 dev->raw->dev = dev; in ir_raw_event_prepare()
624 spin_lock_init(&dev->raw->edge_spinlock); in ir_raw_event_prepare()
625 timer_setup(&dev->raw->edge_handle, ir_raw_edge_handle, 0); in ir_raw_event_prepare()
626 INIT_KFIFO(dev->raw->kfifo); in ir_raw_event_prepare()
635 thread = kthread_run(ir_raw_event_thread, dev->raw, "rc%u", dev->minor); in ir_raw_event_register()
639 dev->raw->thread = thread; in ir_raw_event_register()
642 list_add_tail(&dev->raw->list, &ir_raw_client_list); in ir_raw_event_register()
653 kfree(dev->raw); in ir_raw_event_free()
654 dev->raw = NULL; in ir_raw_event_free()
661 if (!dev || !dev->raw) in ir_raw_event_unregister()
664 kthread_stop(dev->raw->thread); in ir_raw_event_unregister()
665 del_timer_sync(&dev->raw->edge_handle); in ir_raw_event_unregister()
668 list_del(&dev->raw->list); in ir_raw_event_unregister()
680 * ensure that the raw member is null on unlock; this is how in ir_raw_event_unregister()
703 struct ir_raw_event_ctrl *raw; in ir_raw_handler_unregister() local
708 list_for_each_entry(raw, &ir_raw_client_list, list) { in ir_raw_handler_unregister()
710 (raw->dev->enabled_protocols & protocols)) in ir_raw_handler_unregister()
711 ir_raw_handler->raw_unregister(raw->dev); in ir_raw_handler_unregister()
712 ir_raw_disable_protocols(raw->dev, protocols); in ir_raw_handler_unregister()