diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-14 00:16:36 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:23 -0500 |
commit | 53f870228db0855f2031270ba5774dab0f33facd (patch) | |
tree | 1bfb5fee77f174f13f98404788970cd3c3a7b772 | |
parent | e93854da880d6dc357c00625d8371b6a926fd19b (diff) |
V4L/DVB (13635): ir-core: Implement protocol table type reading
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/IR/ir-sysfs.c | 30 | ||||
-rw-r--r-- | include/media/ir-core.h | 4 |
2 files changed, 31 insertions, 3 deletions
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index 3c601421632b..821345dbe7c9 100644 --- a/drivers/media/IR/ir-sysfs.c +++ b/drivers/media/IR/ir-sysfs.c | |||
@@ -22,10 +22,36 @@ unsigned long ir_core_dev_number; | |||
22 | 22 | ||
23 | static struct class *ir_input_class; | 23 | static struct class *ir_input_class; |
24 | 24 | ||
25 | static DEVICE_ATTR(ir_protocol, S_IRUGO | S_IWUSR, NULL, NULL); | 25 | |
26 | static ssize_t show_protocol(struct device *d, | ||
27 | struct device_attribute *mattr, char *buf) | ||
28 | { | ||
29 | char *s; | ||
30 | struct ir_input_dev *ir_dev = dev_get_drvdata(d); | ||
31 | enum ir_type ir_type = ir_dev->rc_tab.ir_type; | ||
32 | |||
33 | IR_dprintk(1, "Current protocol is %ld\n", ir_type); | ||
34 | |||
35 | /* FIXME: doesn't support multiple protocols at the same time */ | ||
36 | if (ir_type == IR_TYPE_UNKNOWN) | ||
37 | s = "Unknown"; | ||
38 | else if (ir_type == IR_TYPE_RC5) | ||
39 | s = "RC-5"; | ||
40 | else if (ir_type == IR_TYPE_PD) | ||
41 | s = "Pulse/distance"; | ||
42 | else if (ir_type == IR_TYPE_NEC) | ||
43 | s = "NEC"; | ||
44 | else | ||
45 | s = "Other"; | ||
46 | |||
47 | return sprintf(buf, "%s\n", s); | ||
48 | } | ||
49 | |||
50 | static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR, | ||
51 | show_protocol, NULL); | ||
26 | 52 | ||
27 | static struct attribute *ir_dev_attrs[] = { | 53 | static struct attribute *ir_dev_attrs[] = { |
28 | &dev_attr_ir_protocol.attr, | 54 | &dev_attr_current_protocol.attr, |
29 | }; | 55 | }; |
30 | 56 | ||
31 | int ir_register_class(struct input_dev *input_dev) | 57 | int ir_register_class(struct input_dev *input_dev) |
diff --git a/include/media/ir-core.h b/include/media/ir-core.h index dbdffd1458fb..a6d07dede09f 100644 --- a/include/media/ir-core.h +++ b/include/media/ir-core.h | |||
@@ -44,9 +44,10 @@ struct ir_scancode_table { | |||
44 | struct ir_dev_props { | 44 | struct ir_dev_props { |
45 | unsigned long allowed_protos; | 45 | unsigned long allowed_protos; |
46 | void *priv; | 46 | void *priv; |
47 | int (*change_protocol)(void *priv, unsigned long protocol); | 47 | int (*change_protocol)(void *priv, enum ir_type ir_type); |
48 | }; | 48 | }; |
49 | 49 | ||
50 | |||
50 | struct ir_input_dev { | 51 | struct ir_input_dev { |
51 | struct input_dev *dev; /* Input device*/ | 52 | struct input_dev *dev; /* Input device*/ |
52 | struct ir_scancode_table rc_tab; /* scan/key table */ | 53 | struct ir_scancode_table rc_tab; /* scan/key table */ |
@@ -55,6 +56,7 @@ struct ir_input_dev { | |||
55 | struct device *class_dev; /* virtual class dev */ | 56 | struct device *class_dev; /* virtual class dev */ |
56 | const struct ir_dev_props *props; /* Device properties */ | 57 | const struct ir_dev_props *props; /* Device properties */ |
57 | }; | 58 | }; |
59 | #define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr) | ||
58 | 60 | ||
59 | /* Routines from ir-keytable.c */ | 61 | /* Routines from ir-keytable.c */ |
60 | 62 | ||