History

[media] media: lirc: Allow lirc dev to talk to rc device

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.

Srinivas Kandagatla committed 13 years ago

Commit ca7a7221 parent 8b2ff323 files · +12 −0Browse files

Unified · Split

3 files
  1. drivers/media/rc/ir-lirc-codec.c +1 −0
  2. drivers/media/rc/lirc_dev.c +10 −0
  3. include/media/lirc_dev.h +1 −0
drivers/media/rc/ir-lirc-codec.c+1−0
@@ -384,6 +384,7 @@ static int ir_lirc_register(struct rc_dev *dev) · 383 unmodified lines
384384 drv->code_length = sizeof(struct ir_raw_event) * 8;
385385 drv->fops = &lirc_fops;
386386 drv->dev = &dev->dev;
387+ drv->rdev = dev;
387388 drv->owner = THIS_MODULE;
388389
389390 drv->minor = lirc_register_driver(drv);
drivers/media/rc/lirc_dev.c+10−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include <linux/device.h>
3636 #include <linux/cdev.h>
3737
38+#include <media/rc-core.h>
3839 #include <media/lirc.h>
3940 #include <media/lirc_dev.h>
4041
@@ -467,6 +468,12 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file) · 426 unmodified lines
467468 goto error;
468469 }
469470
471+ if (ir->d.rdev) {
472+ retval = rc_open(ir->d.rdev);
473+ if (retval)
474+ goto error;
475+ }
476+
470477 cdev = ir->cdev;
471478 if (try_module_get(cdev->owner)) {
472479 ir->open++;
@@ -511,6 +518,9 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file) · 38 unmodified lines
511518
512519 WARN_ON(mutex_lock_killable(&lirc_dev_lock));
513520
521+ if (ir->d.rdev)
522+ rc_close(ir->d.rdev);
523+
514524 ir->open--;
515525 if (ir->attached) {
516526 ir->d.set_use_dec(ir->d.data);
include/media/lirc_dev.h+1−0
@@ -139,6 +139,7 @@ struct lirc_driver { · 138 unmodified lines
139139 struct lirc_buffer *rbuf;
140140 int (*set_use_inc) (void *data);
141141 void (*set_use_dec) (void *data);
142+ struct rc_dev *rdev;
142143 const struct file_operations *fops;
143144 struct device *dev;
144145 struct module *owner;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t