aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/rc-main.c
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2015-11-16 14:52:08 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-11-19 08:37:40 -0500
commit9f0bf366d70beaae64975dcb89272ea6d6fc4a03 (patch)
treea6278b382dbf642c827256950eb029f7cc984d3b /drivers/media/rc/rc-main.c
parent93cffffc18f6894f90ae03552e8a228eb402347c (diff)
[media] media: rc: preparation for on-demand decoder module loading
Prepare on-demand decoder module loading by adding a module_name member to struct proto_names and introducing the related load function. After this patch of the series the decoder modules are still loaded unconditionally. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/rc/rc-main.c')
-rw-r--r--drivers/media/rc/rc-main.c72
1 files changed, 59 insertions, 13 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 784be5ebc7ab..ba5df4b81b9d 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -780,27 +780,28 @@ static struct class rc_class = {
780static struct { 780static struct {
781 u64 type; 781 u64 type;
782 char *name; 782 char *name;
783 const char *module_name;
783} proto_names[] = { 784} proto_names[] = {
784 { RC_BIT_NONE, "none" }, 785 { RC_BIT_NONE, "none", NULL },
785 { RC_BIT_OTHER, "other" }, 786 { RC_BIT_OTHER, "other", NULL },
786 { RC_BIT_UNKNOWN, "unknown" }, 787 { RC_BIT_UNKNOWN, "unknown", NULL },
787 { RC_BIT_RC5 | 788 { RC_BIT_RC5 |
788 RC_BIT_RC5X, "rc-5" }, 789 RC_BIT_RC5X, "rc-5", "ir-rc5-decoder" },
789 { RC_BIT_NEC, "nec" }, 790 { RC_BIT_NEC, "nec", "ir-nec-decoder" },
790 { RC_BIT_RC6_0 | 791 { RC_BIT_RC6_0 |
791 RC_BIT_RC6_6A_20 | 792 RC_BIT_RC6_6A_20 |
792 RC_BIT_RC6_6A_24 | 793 RC_BIT_RC6_6A_24 |
793 RC_BIT_RC6_6A_32 | 794 RC_BIT_RC6_6A_32 |
794 RC_BIT_RC6_MCE, "rc-6" }, 795 RC_BIT_RC6_MCE, "rc-6", "ir-rc6-decoder" },
795 { RC_BIT_JVC, "jvc" }, 796 { RC_BIT_JVC, "jvc", "ir-jvc-decoder" },
796 { RC_BIT_SONY12 | 797 { RC_BIT_SONY12 |
797 RC_BIT_SONY15 | 798 RC_BIT_SONY15 |
798 RC_BIT_SONY20, "sony" }, 799 RC_BIT_SONY20, "sony", "ir-sony-decoder" },
799 { RC_BIT_RC5_SZ, "rc-5-sz" }, 800 { RC_BIT_RC5_SZ, "rc-5-sz", "ir-rc5-decoder" },
800 { RC_BIT_SANYO, "sanyo" }, 801 { RC_BIT_SANYO, "sanyo", "ir-sanyo-decoder" },
801 { RC_BIT_SHARP, "sharp" }, 802 { RC_BIT_SHARP, "sharp", "ir-sharp-decoder" },
802 { RC_BIT_MCE_KBD, "mce_kbd" }, 803 { RC_BIT_MCE_KBD, "mce_kbd", "ir-mce_kbd-decoder" },
803 { RC_BIT_XMP, "xmp" }, 804 { RC_BIT_XMP, "xmp", "ir-xmp-decoder" },
804}; 805};
805 806
806/** 807/**
@@ -979,6 +980,48 @@ static int parse_protocol_change(u64 *protocols, const char *buf)
979 return count; 980 return count;
980} 981}
981 982
983static void ir_raw_load_modules(u64 *protocols)
984
985{
986 u64 available;
987 int i, ret;
988
989 for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
990 if (proto_names[i].type == RC_BIT_NONE ||
991 proto_names[i].type & (RC_BIT_OTHER | RC_BIT_UNKNOWN))
992 continue;
993
994 available = ir_raw_get_allowed_protocols();
995 if (!(*protocols & proto_names[i].type & ~available))
996 continue;
997
998 if (!proto_names[i].module_name) {
999 pr_err("Can't enable IR protocol %s\n",
1000 proto_names[i].name);
1001 *protocols &= ~proto_names[i].type;
1002 continue;
1003 }
1004
1005 ret = request_module("%s", proto_names[i].module_name);
1006 if (ret < 0) {
1007 pr_err("Couldn't load IR protocol module %s\n",
1008 proto_names[i].module_name);
1009 *protocols &= ~proto_names[i].type;
1010 continue;
1011 }
1012 msleep(20);
1013 available = ir_raw_get_allowed_protocols();
1014 if (!(*protocols & proto_names[i].type & ~available))
1015 continue;
1016
1017 pr_err("Loaded IR protocol module %s, \
1018 but protocol %s still not available\n",
1019 proto_names[i].module_name,
1020 proto_names[i].name);
1021 *protocols &= ~proto_names[i].type;
1022 }
1023}
1024
982/** 1025/**
983 * store_protocols() - changes the current/wakeup IR protocol(s) 1026 * store_protocols() - changes the current/wakeup IR protocol(s)
984 * @device: the device descriptor 1027 * @device: the device descriptor
@@ -1045,6 +1088,9 @@ static ssize_t store_protocols(struct device *device,
1045 goto out; 1088 goto out;
1046 } 1089 }
1047 1090
1091 if (dev->driver_type == RC_DRIVER_IR_RAW)
1092 ir_raw_load_modules(&new_protocols);
1093
1048 if (new_protocols != old_protocols) { 1094 if (new_protocols != old_protocols) {
1049 *current_protocols = new_protocols; 1095 *current_protocols = new_protocols;
1050 IR_dprintk(1, "Protocols changed to 0x%llx\n", 1096 IR_dprintk(1, "Protocols changed to 0x%llx\n",