V4L/DVB: IR: only initially registers protocol that matches loaded keymap
authorJarod Wilson <jarod@redhat.com>
Tue, 1 Jun 2010 20:27:07 +0000 (17:27 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 2 Aug 2010 17:05:46 +0000 (14:05 -0300)
Rather than registering all IR protocol decoders as enabled when bringing
up a new device, only enable the IR protocol decoder that matches the
keymap being loaded. Additional decoders can be enabled on the fly by
those that need to, either by twiddling sysfs bits or by using the
ir-keytable util from v4l-utils.

Functional testing done with the mceusb driver, and it behaves as expected,
only the rc6 decoder is enabled, keys are all handled properly, etc.

Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/IR/ir-jvc-decoder.c
drivers/media/IR/ir-nec-decoder.c
drivers/media/IR/ir-rc5-decoder.c
drivers/media/IR/ir-rc6-decoder.c
drivers/media/IR/ir-sony-decoder.c

index 0b804944cbb08a1bef55cc023568ce0138aa7265..b02e8013b9bbd3825e310dcc0e6515c31eff34b4 100644 (file)
@@ -253,6 +253,7 @@ static int ir_jvc_register(struct input_dev *input_dev)
 {
        struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
        struct decoder_data *data;
+       u64 ir_type = ir_dev->rc_tab.ir_type;
        int rc;
 
        rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
@@ -266,7 +267,8 @@ static int ir_jvc_register(struct input_dev *input_dev)
        }
 
        data->ir_dev = ir_dev;
-       data->enabled = 1;
+       if (ir_type == IR_TYPE_JVC || ir_type == IR_TYPE_UNKNOWN)
+               data->enabled = 1;
 
        spin_lock(&decoder_lock);
        list_add_tail(&data->list, &decoder_list);
index ba79233112efa526b04f2cfbc65acd4a16f70b00..6059a1f1e1514ebe5100e292b2b7fb5dc943569e 100644 (file)
@@ -260,6 +260,7 @@ static int ir_nec_register(struct input_dev *input_dev)
 {
        struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
        struct decoder_data *data;
+       u64 ir_type = ir_dev->rc_tab.ir_type;
        int rc;
 
        rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
@@ -273,7 +274,8 @@ static int ir_nec_register(struct input_dev *input_dev)
        }
 
        data->ir_dev = ir_dev;
-       data->enabled = 1;
+       if (ir_type == IR_TYPE_NEC || ir_type == IR_TYPE_UNKNOWN)
+               data->enabled = 1;
 
        spin_lock(&decoder_lock);
        list_add_tail(&data->list, &decoder_list);
index 23cdb1b1a3bc01679eea78702f778ffb45e15c5e..4aa797bc69fd50400f84701c007726d34c6f8337 100644 (file)
@@ -256,6 +256,7 @@ static int ir_rc5_register(struct input_dev *input_dev)
 {
        struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
        struct decoder_data *data;
+       u64 ir_type = ir_dev->rc_tab.ir_type;
        int rc;
 
        rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
@@ -269,7 +270,8 @@ static int ir_rc5_register(struct input_dev *input_dev)
        }
 
        data->ir_dev = ir_dev;
-       data->enabled = 1;
+       if (ir_type == IR_TYPE_RC5 || ir_type == IR_TYPE_UNKNOWN)
+               data->enabled = 1;
 
        spin_lock(&decoder_lock);
        list_add_tail(&data->list, &decoder_list);
index 2bf479f4f1bc6c3c42b66d161a48a40d46e4a134..9f61da29faceeb416f348f7061a20080361d641f 100644 (file)
@@ -352,6 +352,7 @@ static int ir_rc6_register(struct input_dev *input_dev)
 {
        struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
        struct decoder_data *data;
+       u64 ir_type = ir_dev->rc_tab.ir_type;
        int rc;
 
        rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
@@ -365,7 +366,8 @@ static int ir_rc6_register(struct input_dev *input_dev)
        }
 
        data->ir_dev = ir_dev;
-       data->enabled = 1;
+       if (ir_type == IR_TYPE_RC6 || ir_type == IR_TYPE_UNKNOWN)
+               data->enabled = 1;
 
        spin_lock(&decoder_lock);
        list_add_tail(&data->list, &decoder_list);
index 9f440c5c060d50e9b1cb5b64bce13816705fa890..219075ffd6b718a6e80b40f23a01a7270e3038fe 100644 (file)
@@ -245,6 +245,7 @@ static int ir_sony_register(struct input_dev *input_dev)
 {
        struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
        struct decoder_data *data;
+       u64 ir_type = ir_dev->rc_tab.ir_type;
        int rc;
 
        rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
@@ -258,7 +259,8 @@ static int ir_sony_register(struct input_dev *input_dev)
        }
 
        data->ir_dev = ir_dev;
-       data->enabled = 1;
+       if (ir_type == IR_TYPE_SONY || ir_type == IR_TYPE_UNKNOWN)
+               data->enabled = 1;
 
        spin_lock(&decoder_lock);
        list_add_tail(&data->list, &decoder_list);