15 #include <linux/sched.h>
16 #include <linux/wait.h>
17 #include <linux/module.h>
23 #define LIRCBUF_SIZE 256
35 struct lirc_codec *lirc = &dev->
raw->lirc;
41 if (!dev->
raw->lirc.drv || !dev->
raw->lirc.drv->rbuf)
51 IR_dprintk(2,
"carrier report (freq: %d)\n", sample);
63 if (!lirc->send_timeout_reports)
67 IR_dprintk(2,
"timeout report (duration: %d)\n", sample);
75 lirc->gap_duration += ktime_to_ns(ktime_sub(
ktime_get(),
79 do_div(lirc->gap_duration, 1000);
80 lirc->gap_duration =
min(lirc->gap_duration,
84 lirc_buffer_write(dev->
raw->lirc.drv->rbuf,
85 (
unsigned char *) &gap_sample);
91 IR_dprintk(2,
"delivering %uus %s to lirc_dev\n",
95 lirc_buffer_write(dev->
raw->lirc.drv->rbuf,
96 (
unsigned char *) &sample);
103 size_t n, loff_t *ppos)
105 struct lirc_codec *lirc;
121 if (n <
sizeof(
unsigned) || n %
sizeof(
unsigned))
124 count = n /
sizeof(unsigned);
130 return PTR_ERR(txbuf);
143 ret = dev->
tx_ir(dev, txbuf, count);
147 for (i = 0; i <
ret; i++)
148 duration += txbuf[i];
150 ret *=
sizeof(
unsigned int);
157 towait = ktime_us_delta(ktime_add_us(start, duration),
ktime_get());
168 static long ir_lirc_ioctl(
struct file *filep,
unsigned int cmd,
171 struct lirc_codec *lirc;
220 if (val <= 0 || val >= 100)
234 dev->
raw->lirc.carrier_low,
241 dev->
raw->lirc.carrier_low =
val;
287 lirc->send_timeout_reports = !!
val;
300 static int ir_lirc_open(
void *
data)
305 static void ir_lirc_close(
void *
data)
312 .write = ir_lirc_transmit_ir,
313 .unlocked_ioctl = ir_lirc_ioctl,
315 .compat_ioctl = ir_lirc_ioctl,
324 static int ir_lirc_register(
struct rc_dev *dev)
337 goto rbuf_alloc_failed;
341 goto rbuf_init_failed;
376 drv->
fops = &lirc_fops;
381 if (drv->
minor < 0) {
383 goto lirc_register_failed;
386 dev->
raw->lirc.drv = drv;
390 lirc_register_failed:
399 static int ir_lirc_unregister(
struct rc_dev *dev)
401 struct lirc_codec *lirc = &dev->
raw->lirc;
404 lirc_buffer_free(lirc->drv->rbuf);
412 .decode = ir_lirc_decode,
413 .raw_register = ir_lirc_register,
414 .raw_unregister = ir_lirc_unregister,
417 static int __init ir_lirc_codec_init(
void)
425 static void __exit ir_lirc_codec_exit(
void)