summaryrefslogtreecommitdiffstats
path: root/drivers/media/IR/ir-sysfs.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-12-14 02:46:42 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 15:10:23 -0300
commit09b01b90eb08769a64159ff4f81efe4badf6a49b (patch)
tree1ef7014843303fbb9c257d97c73af286a486f0a0 /drivers/media/IR/ir-sysfs.c
parent53f870228db0855f2031270ba5774dab0f33facd (diff)
V4L/DVB (13636): ir-core: add method to change IR protocol
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR/ir-sysfs.c')
-rw-r--r--drivers/media/IR/ir-sysfs.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index 821345dbe7c..aede78ddbac 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -47,8 +47,50 @@ static ssize_t show_protocol(struct device *d,
return sprintf(buf, "%s\n", s);
}
+
+static ssize_t store_protocol(struct device *d,
+ struct device_attribute *mattr,
+ const char *data,
+ size_t len)
+{
+ struct ir_input_dev *ir_dev = dev_get_drvdata(d);
+ enum ir_type ir_type = IR_TYPE_UNKNOWN;
+ int rc = -EINVAL;
+ char *buf;
+
+ buf = strsep((char **) &data, "\n");
+
+ if (!strcasecmp(buf, "rc-5"))
+ ir_type = IR_TYPE_RC5;
+ else if (!strcasecmp(buf, "pd"))
+ ir_type = IR_TYPE_PD;
+ else if (!strcasecmp(buf, "nec"))
+ ir_type = IR_TYPE_NEC;
+
+ if (ir_type == IR_TYPE_UNKNOWN) {
+ IR_dprintk(1, "Error setting protocol to %ld\n", ir_type);
+ return -EINVAL;
+ }
+
+ if (ir_dev->props->change_protocol)
+ rc = ir_dev->props->change_protocol(ir_dev->props->priv,
+ ir_type);
+
+ if (rc < 0) {
+ IR_dprintk(1, "Error setting protocol to %ld\n", ir_type);
+ return -EINVAL;
+ }
+
+ ir_dev->rc_tab.ir_type = ir_type;
+
+ IR_dprintk(1, "Current protocol is %ld\n", ir_type);
+
+ return len;
+}
+
+
static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR,
- show_protocol, NULL);
+ show_protocol, store_protocol);
static struct attribute *ir_dev_attrs[] = {
&dev_attr_current_protocol.attr,