diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-14 00:46:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:23 -0500 |
commit | 09b01b90eb08769a64159ff4f81efe4badf6a49b (patch) | |
tree | 1ef7014843303fbb9c257d97c73af286a486f0a0 /drivers/media/IR/ir-sysfs.c | |
parent | 53f870228db0855f2031270ba5774dab0f33facd (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.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index 821345dbe7c9..aede78ddbace 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, | |||
47 | return sprintf(buf, "%s\n", s); | 47 | return sprintf(buf, "%s\n", s); |
48 | } | 48 | } |
49 | 49 | ||
50 | |||
51 | static ssize_t store_protocol(struct device *d, | ||
52 | struct device_attribute *mattr, | ||
53 | const char *data, | ||
54 | size_t len) | ||
55 | { | ||
56 | struct ir_input_dev *ir_dev = dev_get_drvdata(d); | ||
57 | enum ir_type ir_type = IR_TYPE_UNKNOWN; | ||
58 | int rc = -EINVAL; | ||
59 | char *buf; | ||
60 | |||
61 | buf = strsep((char **) &data, "\n"); | ||
62 | |||
63 | if (!strcasecmp(buf, "rc-5")) | ||
64 | ir_type = IR_TYPE_RC5; | ||
65 | else if (!strcasecmp(buf, "pd")) | ||
66 | ir_type = IR_TYPE_PD; | ||
67 | else if (!strcasecmp(buf, "nec")) | ||
68 | ir_type = IR_TYPE_NEC; | ||
69 | |||
70 | if (ir_type == IR_TYPE_UNKNOWN) { | ||
71 | IR_dprintk(1, "Error setting protocol to %ld\n", ir_type); | ||
72 | return -EINVAL; | ||
73 | } | ||
74 | |||
75 | if (ir_dev->props->change_protocol) | ||
76 | rc = ir_dev->props->change_protocol(ir_dev->props->priv, | ||
77 | ir_type); | ||
78 | |||
79 | if (rc < 0) { | ||
80 | IR_dprintk(1, "Error setting protocol to %ld\n", ir_type); | ||
81 | return -EINVAL; | ||
82 | } | ||
83 | |||
84 | ir_dev->rc_tab.ir_type = ir_type; | ||
85 | |||
86 | IR_dprintk(1, "Current protocol is %ld\n", ir_type); | ||
87 | |||
88 | return len; | ||
89 | } | ||
90 | |||
91 | |||
50 | static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR, | 92 | static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR, |
51 | show_protocol, NULL); | 93 | show_protocol, store_protocol); |
52 | 94 | ||
53 | static struct attribute *ir_dev_attrs[] = { | 95 | static struct attribute *ir_dev_attrs[] = { |
54 | &dev_attr_current_protocol.attr, | 96 | &dev_attr_current_protocol.attr, |