Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] rc: add allowed/enabled wakeup protocol masks

Only a single allowed and enabled protocol mask currently exists in
struct rc_dev, however to support a separate wakeup filter protocol two
of each are needed, ideally as an array.

Therefore make both rc_dev::allowed_protos and rc_dev::enabled_protocols
arrays, update all users to reference the first element
(RC_FILTER_NORMAL), and add a couple more helper functions for drivers
to use for setting the allowed and enabled wakeup protocols.

We also rename allowed_protos to allowed_protocols while we're at it,
which is more consistent with enabled_protocols.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

James Hogan and committed by
Mauro Carvalho Chehab
acff5f24 1a1934fa

+29 -13
+5 -5
drivers/media/rc/rc-main.c
··· 830 830 831 831 mutex_lock(&dev->lock); 832 832 833 - enabled = dev->enabled_protocols; 833 + enabled = dev->enabled_protocols[RC_FILTER_NORMAL]; 834 834 if (dev->driver_type == RC_DRIVER_SCANCODE) 835 - allowed = dev->allowed_protos; 835 + allowed = dev->allowed_protocols[RC_FILTER_NORMAL]; 836 836 else if (dev->raw) 837 837 allowed = ir_raw_get_allowed_protocols(); 838 838 else { ··· 906 906 ret = -EINVAL; 907 907 goto out; 908 908 } 909 - type = dev->enabled_protocols; 909 + type = dev->enabled_protocols[RC_FILTER_NORMAL]; 910 910 911 911 while ((tmp = strsep((char **) &data, " \n")) != NULL) { 912 912 if (!*tmp) ··· 964 964 } 965 965 } 966 966 967 - dev->enabled_protocols = type; 967 + dev->enabled_protocols[RC_FILTER_NORMAL] = type; 968 968 IR_dprintk(1, "Current protocol(s): 0x%llx\n", 969 969 (long long)type); 970 970 ··· 1316 1316 rc = dev->change_protocol(dev, &rc_type); 1317 1317 if (rc < 0) 1318 1318 goto out_raw; 1319 - dev->enabled_protocols = rc_type; 1319 + dev->enabled_protocols[RC_FILTER_NORMAL] = rc_type; 1320 1320 } 1321 1321 1322 1322 mutex_unlock(&dev->lock);
+24 -8
include/media/rc-core.h
··· 73 73 * @input_dev: the input child device used to communicate events to userspace 74 74 * @driver_type: specifies if protocol decoding is done in hardware or software 75 75 * @idle: used to keep track of RX state 76 - * @allowed_protos: bitmask with the supported RC_BIT_* protocols 77 - * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols 76 + * @allowed_protocols: bitmask with the supported RC_BIT_* protocols for each 77 + * filter type 78 + * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols for each 79 + * filter type 78 80 * @scanmask: some hardware decoders are not capable of providing the full 79 81 * scancode to the application. As this is a hardware limit, we can't do 80 82 * anything with it. Yet, as the same keycode table can be used with other ··· 126 124 struct input_dev *input_dev; 127 125 enum rc_driver_type driver_type; 128 126 bool idle; 129 - u64 allowed_protos; 130 - u64 enabled_protocols; 127 + u64 allowed_protocols[RC_FILTER_MAX]; 128 + u64 enabled_protocols[RC_FILTER_MAX]; 131 129 u32 users; 132 130 u32 scanmask; 133 131 void *priv; ··· 164 162 165 163 static inline bool rc_protocols_allowed(struct rc_dev *rdev, u64 protos) 166 164 { 167 - return rdev->allowed_protos & protos; 165 + return rdev->allowed_protocols[RC_FILTER_NORMAL] & protos; 168 166 } 169 167 170 168 /* should be called prior to registration or with mutex held */ 171 169 static inline void rc_set_allowed_protocols(struct rc_dev *rdev, u64 protos) 172 170 { 173 - rdev->allowed_protos = protos; 171 + rdev->allowed_protocols[RC_FILTER_NORMAL] = protos; 174 172 } 175 173 176 174 static inline bool rc_protocols_enabled(struct rc_dev *rdev, u64 protos) 177 175 { 178 - return rdev->enabled_protocols & protos; 176 + return rdev->enabled_protocols[RC_FILTER_NORMAL] & protos; 179 177 } 180 178 181 179 /* should be called prior to registration or with mutex held */ 182 180 static inline void rc_set_enabled_protocols(struct rc_dev *rdev, u64 protos) 183 181 { 184 - rdev->enabled_protocols = protos; 182 + rdev->enabled_protocols[RC_FILTER_NORMAL] = protos; 183 + } 184 + 185 + /* should be called prior to registration or with mutex held */ 186 + static inline void rc_set_allowed_wakeup_protocols(struct rc_dev *rdev, 187 + u64 protos) 188 + { 189 + rdev->allowed_protocols[RC_FILTER_WAKEUP] = protos; 190 + } 191 + 192 + /* should be called prior to registration or with mutex held */ 193 + static inline void rc_set_enabled_wakeup_protocols(struct rc_dev *rdev, 194 + u64 protos) 195 + { 196 + rdev->enabled_protocols[RC_FILTER_WAKEUP] = protos; 185 197 } 186 198 187 199 /*