V4L/DVB (13635): ir-core: Implement protocol table type reading
authorMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 14 Dec 2009 05:16:36 +0000 (02:16 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 26 Feb 2010 18:10:23 +0000 (15:10 -0300)
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/IR/ir-sysfs.c
include/media/ir-core.h

index 3c601421632b1b9f7955485683cbbe769cb6a2ab..821345dbe7c9d1c548bd85cf5330dc3972547020 100644 (file)
@@ -22,10 +22,36 @@ unsigned long ir_core_dev_number;
 
 static struct class *ir_input_class;
 
-static DEVICE_ATTR(ir_protocol, S_IRUGO | S_IWUSR, NULL, NULL);
+
+static ssize_t show_protocol(struct device *d,
+                            struct device_attribute *mattr, char *buf)
+{
+       char *s;
+       struct ir_input_dev *ir_dev = dev_get_drvdata(d);
+       enum ir_type ir_type = ir_dev->rc_tab.ir_type;
+
+       IR_dprintk(1, "Current protocol is %ld\n", ir_type);
+
+       /* FIXME: doesn't support multiple protocols at the same time */
+       if (ir_type == IR_TYPE_UNKNOWN)
+               s = "Unknown";
+       else if (ir_type == IR_TYPE_RC5)
+               s = "RC-5";
+       else if (ir_type == IR_TYPE_PD)
+               s = "Pulse/distance";
+       else if (ir_type == IR_TYPE_NEC)
+               s = "NEC";
+       else
+               s = "Other";
+
+       return sprintf(buf, "%s\n", s);
+}
+
+static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR,
+                  show_protocol, NULL);
 
 static struct attribute *ir_dev_attrs[] = {
-       &dev_attr_ir_protocol.attr,
+       &dev_attr_current_protocol.attr,
 };
 
 int ir_register_class(struct input_dev *input_dev)
index dbdffd1458fb3a56c3704ac03f614c6c7db12302..a6d07dede09f2b79b47962eb5c6c4c934d36776b 100644 (file)
@@ -44,9 +44,10 @@ struct ir_scancode_table {
 struct ir_dev_props {
        unsigned long allowed_protos;
        void            *priv;
-       int (*change_protocol)(void *priv, unsigned long protocol);
+       int (*change_protocol)(void *priv, enum ir_type ir_type);
 };
 
+
 struct ir_input_dev {
        struct input_dev                *dev;           /* Input device*/
        struct ir_scancode_table        rc_tab;         /* scan/key table */
@@ -55,6 +56,7 @@ struct ir_input_dev {
        struct device                   *class_dev;     /* virtual class dev */
        const struct ir_dev_props       *props;         /* Device properties */
 };
+#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
 
 /* Routines from ir-keytable.c */