Commit 510fcb70 authored by Maxim Levitsky's avatar Maxim Levitsky Committed by Mauro Carvalho Chehab

V4L/DVB: IR: minor fixes

* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* Make TO_US macro actualy print what it should.
Signed-off-by: default avatarMaxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent ade321c5
...@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl { ...@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {
struct lirc_codec { struct lirc_codec {
struct ir_input_dev *ir_dev; struct ir_input_dev *ir_dev;
struct lirc_driver *drv; struct lirc_driver *drv;
int lircdata;
} lirc; } lirc;
}; };
...@@ -104,10 +103,9 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) ...@@ -104,10 +103,9 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration)
ev->duration -= duration; ev->duration -= duration;
} }
#define TO_US(duration) (((duration) + 500) / 1000) #define TO_US(duration) DIV_ROUND_CLOSEST((duration), 1000)
#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space") #define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space")
#define IS_RESET(ev) (ev.duration == 0) #define IS_RESET(ev) (ev.duration == 0)
/* /*
* Routines from ir-sysfs.c - Meant to be called only internally inside * Routines from ir-sysfs.c - Meant to be called only internally inside
* ir-core * ir-core
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev) static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
{ {
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
int sample;
if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC)) if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC))
return 0; return 0;
...@@ -39,18 +40,21 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev) ...@@ -39,18 +40,21 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf) if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf)
return -EINVAL; return -EINVAL;
if (IS_RESET(ev))
return 0;
IR_dprintk(2, "LIRC data transfer started (%uus %s)\n", IR_dprintk(2, "LIRC data transfer started (%uus %s)\n",
TO_US(ev.duration), TO_STR(ev.pulse)); TO_US(ev.duration), TO_STR(ev.pulse));
ir_dev->raw->lirc.lircdata += ev.duration / 1000;
sample = ev.duration / 1000;
if (ev.pulse) if (ev.pulse)
ir_dev->raw->lirc.lircdata |= PULSE_BIT; sample |= PULSE_BIT;
lirc_buffer_write(ir_dev->raw->lirc.drv->rbuf, lirc_buffer_write(ir_dev->raw->lirc.drv->rbuf,
(unsigned char *) &ir_dev->raw->lirc.lircdata); (unsigned char *) &sample);
wake_up(&ir_dev->raw->lirc.drv->rbuf->wait_poll); wake_up(&ir_dev->raw->lirc.drv->rbuf->wait_poll);
ir_dev->raw->lirc.lircdata = 0;
return 0; return 0;
} }
...@@ -224,8 +228,6 @@ static int ir_lirc_register(struct input_dev *input_dev) ...@@ -224,8 +228,6 @@ static int ir_lirc_register(struct input_dev *input_dev)
ir_dev->raw->lirc.drv = drv; ir_dev->raw->lirc.drv = drv;
ir_dev->raw->lirc.ir_dev = ir_dev; ir_dev->raw->lirc.ir_dev = ir_dev;
ir_dev->raw->lirc.lircdata = PULSE_MASK;
return 0; return 0;
lirc_register_failed: lirc_register_failed:
......
...@@ -66,6 +66,9 @@ int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev) ...@@ -66,6 +66,9 @@ int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev)
if (!ir->raw) if (!ir->raw)
return -EINVAL; return -EINVAL;
IR_dprintk(2, "sample: (05%dus %s)\n",
TO_US(ev->duration), TO_STR(ev->pulse));
if (kfifo_in(&ir->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev)) if (kfifo_in(&ir->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment