Commit 9719afae5e589b409e137c36f89073d134f0de33
Committed by
Mauro Carvalho Chehab
1 parent
efa914d7d0
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
[media] rc-core: don't treat dev->rc_map.rc_type as a bitmap
store_protocols() treats dev->rc_map.rc_type as a bitmap which is wrong for two reasons. First of all, it is pretty bogus to change the protocol type of the keymap just because the hardware has been asked to decode a different protocol. Second, dev->rc_map.rc_type is an enum (i.e. a single protocol) as pointed out by James Hogan <james.hogan@imgtec.com>. Fix both issues by introducing a separate enabled_protocols member to struct rc_dev. Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Showing 14 changed files with 28 additions and 38 deletions Side-by-side Diff
- drivers/media/i2c/ir-kbd-i2c.c
- drivers/media/rc/ir-jvc-decoder.c
- drivers/media/rc/ir-lirc-codec.c
- drivers/media/rc/ir-mce_kbd-decoder.c
- drivers/media/rc/ir-nec-decoder.c
- drivers/media/rc/ir-raw.c
- drivers/media/rc/ir-rc5-decoder.c
- drivers/media/rc/ir-rc5-sz-decoder.c
- drivers/media/rc/ir-rc6-decoder.c
- drivers/media/rc/ir-sanyo-decoder.c
- drivers/media/rc/ir-sony-decoder.c
- drivers/media/rc/rc-core-priv.h
- drivers/media/rc/rc-main.c
- include/media/rc-core.h
drivers/media/i2c/ir-kbd-i2c.c
drivers/media/rc/ir-jvc-decoder.c
drivers/media/rc/ir-lirc-codec.c
drivers/media/rc/ir-mce_kbd-decoder.c
drivers/media/rc/ir-nec-decoder.c
drivers/media/rc/ir-raw.c
drivers/media/rc/ir-rc5-decoder.c
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | u8 toggle; |
53 | 53 | u32 scancode; |
54 | 54 | |
55 | - if (!(dev->raw->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) | |
55 | + if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) | |
56 | 56 | return 0; |
57 | 57 | |
58 | 58 | if (!is_timing_event(ev)) { |
... | ... | @@ -128,7 +128,7 @@ |
128 | 128 | if (data->wanted_bits == RC5X_NBITS) { |
129 | 129 | /* RC5X */ |
130 | 130 | u8 xdata, command, system; |
131 | - if (!(dev->raw->enabled_protocols & RC_BIT_RC5X)) { | |
131 | + if (!(dev->enabled_protocols & RC_BIT_RC5X)) { | |
132 | 132 | data->state = STATE_INACTIVE; |
133 | 133 | return 0; |
134 | 134 | } |
... | ... | @@ -145,7 +145,7 @@ |
145 | 145 | } else { |
146 | 146 | /* RC5 */ |
147 | 147 | u8 command, system; |
148 | - if (!(dev->raw->enabled_protocols & RC_BIT_RC5)) { | |
148 | + if (!(dev->enabled_protocols & RC_BIT_RC5)) { | |
149 | 149 | data->state = STATE_INACTIVE; |
150 | 150 | return 0; |
151 | 151 | } |
drivers/media/rc/ir-rc5-sz-decoder.c
drivers/media/rc/ir-rc6-decoder.c
drivers/media/rc/ir-sanyo-decoder.c
drivers/media/rc/ir-sony-decoder.c
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | u32 scancode; |
46 | 46 | u8 device, subdevice, function; |
47 | 47 | |
48 | - if (!(dev->raw->enabled_protocols & | |
48 | + if (!(dev->enabled_protocols & | |
49 | 49 | (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20))) |
50 | 50 | return 0; |
51 | 51 | |
... | ... | @@ -124,7 +124,7 @@ |
124 | 124 | |
125 | 125 | switch (data->count) { |
126 | 126 | case 12: |
127 | - if (!(dev->raw->enabled_protocols & RC_BIT_SONY12)) { | |
127 | + if (!(dev->enabled_protocols & RC_BIT_SONY12)) { | |
128 | 128 | data->state = STATE_INACTIVE; |
129 | 129 | return 0; |
130 | 130 | } |
... | ... | @@ -133,7 +133,7 @@ |
133 | 133 | function = bitrev8((data->bits >> 4) & 0xFE); |
134 | 134 | break; |
135 | 135 | case 15: |
136 | - if (!(dev->raw->enabled_protocols & RC_BIT_SONY15)) { | |
136 | + if (!(dev->enabled_protocols & RC_BIT_SONY15)) { | |
137 | 137 | data->state = STATE_INACTIVE; |
138 | 138 | return 0; |
139 | 139 | } |
... | ... | @@ -142,7 +142,7 @@ |
142 | 142 | function = bitrev8((data->bits >> 7) & 0xFE); |
143 | 143 | break; |
144 | 144 | case 20: |
145 | - if (!(dev->raw->enabled_protocols & RC_BIT_SONY20)) { | |
145 | + if (!(dev->enabled_protocols & RC_BIT_SONY20)) { | |
146 | 146 | data->state = STATE_INACTIVE; |
147 | 147 | return 0; |
148 | 148 | } |
drivers/media/rc/rc-core-priv.h
... | ... | @@ -39,7 +39,6 @@ |
39 | 39 | ktime_t last_event; /* when last event occurred */ |
40 | 40 | enum raw_event_type last_type; /* last event type */ |
41 | 41 | struct rc_dev *dev; /* pointer to the parent rc_dev */ |
42 | - u64 enabled_protocols; /* enabled raw protocol decoders */ | |
43 | 42 | |
44 | 43 | /* raw decoder state follows */ |
45 | 44 | struct ir_raw_event prev_ev; |
drivers/media/rc/rc-main.c
... | ... | @@ -783,13 +783,12 @@ |
783 | 783 | |
784 | 784 | mutex_lock(&dev->lock); |
785 | 785 | |
786 | - if (dev->driver_type == RC_DRIVER_SCANCODE) { | |
787 | - enabled = dev->rc_map.rc_type; | |
786 | + enabled = dev->enabled_protocols; | |
787 | + if (dev->driver_type == RC_DRIVER_SCANCODE) | |
788 | 788 | allowed = dev->allowed_protos; |
789 | - } else if (dev->raw) { | |
790 | - enabled = dev->raw->enabled_protocols; | |
789 | + else if (dev->raw) | |
791 | 790 | allowed = ir_raw_get_allowed_protocols(); |
792 | - } else { | |
791 | + else { | |
793 | 792 | mutex_unlock(&dev->lock); |
794 | 793 | return -ENODEV; |
795 | 794 | } |
... | ... | @@ -847,7 +846,6 @@ |
847 | 846 | u64 type; |
848 | 847 | u64 mask; |
849 | 848 | int rc, i, count = 0; |
850 | - unsigned long flags; | |
851 | 849 | ssize_t ret; |
852 | 850 | |
853 | 851 | /* Device is being removed */ |
854 | 852 | |
... | ... | @@ -856,15 +854,12 @@ |
856 | 854 | |
857 | 855 | mutex_lock(&dev->lock); |
858 | 856 | |
859 | - if (dev->driver_type == RC_DRIVER_SCANCODE) | |
860 | - type = dev->rc_map.rc_type; | |
861 | - else if (dev->raw) | |
862 | - type = dev->raw->enabled_protocols; | |
863 | - else { | |
857 | + if (dev->driver_type != RC_DRIVER_SCANCODE && !dev->raw) { | |
864 | 858 | IR_dprintk(1, "Protocol switching not supported\n"); |
865 | 859 | ret = -EINVAL; |
866 | 860 | goto out; |
867 | 861 | } |
862 | + type = dev->enabled_protocols; | |
868 | 863 | |
869 | 864 | while ((tmp = strsep((char **) &data, " \n")) != NULL) { |
870 | 865 | if (!*tmp) |
... | ... | @@ -922,14 +917,7 @@ |
922 | 917 | } |
923 | 918 | } |
924 | 919 | |
925 | - if (dev->driver_type == RC_DRIVER_SCANCODE) { | |
926 | - spin_lock_irqsave(&dev->rc_map.lock, flags); | |
927 | - dev->rc_map.rc_type = type; | |
928 | - spin_unlock_irqrestore(&dev->rc_map.lock, flags); | |
929 | - } else { | |
930 | - dev->raw->enabled_protocols = type; | |
931 | - } | |
932 | - | |
920 | + dev->enabled_protocols = type; | |
933 | 921 | IR_dprintk(1, "Current protocol(s): 0x%llx\n", |
934 | 922 | (long long)type); |
935 | 923 | |
... | ... | @@ -1068,9 +1056,8 @@ |
1068 | 1056 | /* |
1069 | 1057 | * Take the lock here, as the device sysfs node will appear |
1070 | 1058 | * when device_add() is called, which may trigger an ir-keytable udev |
1071 | - * rule, which will in turn call show_protocols and access either | |
1072 | - * dev->rc_map.rc_type or dev->raw->enabled_protocols before it has | |
1073 | - * been initialized. | |
1059 | + * rule, which will in turn call show_protocols and access | |
1060 | + * dev->enabled_protocols before it has been initialized. | |
1074 | 1061 | */ |
1075 | 1062 | mutex_lock(&dev->lock); |
1076 | 1063 | |
... | ... | @@ -1132,6 +1119,7 @@ |
1132 | 1119 | rc = dev->change_protocol(dev, &rc_type); |
1133 | 1120 | if (rc < 0) |
1134 | 1121 | goto out_raw; |
1122 | + dev->enabled_protocols = rc_type; | |
1135 | 1123 | } |
1136 | 1124 | |
1137 | 1125 | mutex_unlock(&dev->lock); |
include/media/rc-core.h
... | ... | @@ -51,6 +51,7 @@ |
51 | 51 | * @driver_type: specifies if protocol decoding is done in hardware or software |
52 | 52 | * @idle: used to keep track of RX state |
53 | 53 | * @allowed_protos: bitmask with the supported RC_BIT_* protocols |
54 | + * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols | |
54 | 55 | * @scanmask: some hardware decoders are not capable of providing the full |
55 | 56 | * scancode to the application. As this is a hardware limit, we can't do |
56 | 57 | * anything with it. Yet, as the same keycode table can be used with other |
... | ... | @@ -99,6 +100,7 @@ |
99 | 100 | enum rc_driver_type driver_type; |
100 | 101 | bool idle; |
101 | 102 | u64 allowed_protos; |
103 | + u64 enabled_protocols; | |
102 | 104 | u32 scanmask; |
103 | 105 | void *priv; |
104 | 106 | spinlock_t keylock; |