]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] media: lirc: Allow lirc dev to talk to rc device
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>
Mon, 22 Jul 2013 07:23:07 +0000 (04:23 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 31 Jul 2013 19:30:27 +0000 (16:30 -0300)
The use case is simple, if any rc device has allowed protocols =
RC_TYPE_LIRC and map_name = RC_MAP_LIRC set, the driver open will be never
called. The reason for this is, all of the key maps except lirc have some
KEYS in there map, so during rc_register_device process these keys are
matched against the input drivers and open is performed, so for the case
of RC_MAP_EMPTY, a vt/keyboard is matched and the driver open is
performed.
In case of lirc, there is no match and result is that there is no open
performed, however the lirc-dev will go ahead and create a /dev/lirc0
node. Now when lircd/mode2 opens this device, no data is available
because the driver was never opened.
Other case pointed by Sean Young, As rc device gets opened via the
input interface. If the input device is never opened (e.g. embedded with
no console) then the rc open is never called and lirc will not work
either. So that's another case.
lirc_dev seems to have no link with actual rc device w.r.t open/close.
This patch adds rc_dev pointer to lirc_driver structure for cases like
this, so that it can do the open/close of the real driver in accordance
to lircd/mode2 open/close.
Without this patch its impossible to open a rc device which has
RC_TYPE_LIRC ad RC_MAP_LIRC set.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/rc/ir-lirc-codec.c
drivers/media/rc/lirc_dev.c
include/media/lirc_dev.h

index e5be920c059978d3194d1159c1f1a1419879eb58..ed2c8a1ed8caf39ee9eae20c8ec5b5f534c33c0a 100644 (file)
@@ -384,6 +384,7 @@ static int ir_lirc_register(struct rc_dev *dev)
        drv->code_length = sizeof(struct ir_raw_event) * 8;
        drv->fops = &lirc_fops;
        drv->dev = &dev->dev;
+       drv->rdev = dev;
        drv->owner = THIS_MODULE;
 
        drv->minor = lirc_register_driver(drv);
index 8dc057b273f25b49f7f4960896828c9437e3b489..dc5cbffcd5a26a4702b578e97c995e527b644236 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/device.h>
 #include <linux/cdev.h>
 
+#include <media/rc-core.h>
 #include <media/lirc.h>
 #include <media/lirc_dev.h>
 
@@ -467,6 +468,12 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file)
                goto error;
        }
 
+       if (ir->d.rdev) {
+               retval = rc_open(ir->d.rdev);
+               if (retval)
+                       goto error;
+       }
+
        cdev = ir->cdev;
        if (try_module_get(cdev->owner)) {
                ir->open++;
@@ -511,6 +518,9 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
 
        WARN_ON(mutex_lock_killable(&lirc_dev_lock));
 
+       if (ir->d.rdev)
+               rc_close(ir->d.rdev);
+
        ir->open--;
        if (ir->attached) {
                ir->d.set_use_dec(ir->d.data);
index 168dd0b1bae236ea3859e1fb384b6cc79766a1da..78f0637ca68d91d1fc45639141bb6f9d39acd82e 100644 (file)
@@ -139,6 +139,7 @@ struct lirc_driver {
        struct lirc_buffer *rbuf;
        int (*set_use_inc) (void *data);
        void (*set_use_dec) (void *data);
+       struct rc_dev *rdev;
        const struct file_operations *fops;
        struct device *dev;
        struct module *owner;