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

[media] rc: rc-core: Add support for encode_wakeup drivers

Add support in rc-core for drivers which implement the wakeup scancode
filter by encoding the scancode using the raw IR encoders. This is by
way of rc_dev::encode_wakeup which should be set to true to make the
allowed wakeup protocols the same as the set of raw IR encoders.

As well as updating the sysfs interface to know which wakeup protocols
are allowed for encode_wakeup drivers, also ensure that the IR
decoders/encoders are loaded when an encode_wakeup driver is registered.

Signed-off-by: James Hogan <james@albanarts.com>
Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
Cc: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

James Hogan and committed by
Mauro Carvalho Chehab
0d830b2d cf257e28

+27 -1
+1
drivers/media/rc/rc-core-priv.h
··· 189 189 * Routines from rc-raw.c to be used internally and by decoders 190 190 */ 191 191 u64 ir_raw_get_allowed_protocols(void); 192 + u64 ir_raw_get_encode_protocols(void); 192 193 int ir_raw_event_register(struct rc_dev *dev); 193 194 void ir_raw_event_unregister(struct rc_dev *dev); 194 195 int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
+17
drivers/media/rc/rc-ir-raw.c
··· 30 30 static DEFINE_MUTEX(ir_raw_handler_lock); 31 31 static LIST_HEAD(ir_raw_handler_list); 32 32 static u64 available_protocols; 33 + static u64 encode_protocols; 33 34 34 35 static int ir_raw_event_thread(void *data) 35 36 { ··· 237 236 u64 protocols; 238 237 mutex_lock(&ir_raw_handler_lock); 239 238 protocols = available_protocols; 239 + mutex_unlock(&ir_raw_handler_lock); 240 + return protocols; 241 + } 242 + 243 + /* used internally by the sysfs interface */ 244 + u64 245 + ir_raw_get_encode_protocols(void) 246 + { 247 + u64 protocols; 248 + 249 + mutex_lock(&ir_raw_handler_lock); 250 + protocols = encode_protocols; 240 251 mutex_unlock(&ir_raw_handler_lock); 241 252 return protocols; 242 253 } ··· 463 450 list_for_each_entry(raw, &ir_raw_client_list, list) 464 451 ir_raw_handler->raw_register(raw->dev); 465 452 available_protocols |= ir_raw_handler->protocols; 453 + if (ir_raw_handler->encode) 454 + encode_protocols |= ir_raw_handler->protocols; 466 455 mutex_unlock(&ir_raw_handler_lock); 467 456 468 457 return 0; ··· 481 466 list_for_each_entry(raw, &ir_raw_client_list, list) 482 467 ir_raw_handler->raw_unregister(raw->dev); 483 468 available_protocols &= ~ir_raw_handler->protocols; 469 + if (ir_raw_handler->encode) 470 + encode_protocols &= ~ir_raw_handler->protocols; 484 471 mutex_unlock(&ir_raw_handler_lock); 485 472 } 486 473 EXPORT_SYMBOL(ir_raw_handler_unregister);
+6 -1
drivers/media/rc/rc-main.c
··· 865 865 } else { 866 866 enabled = dev->enabled_wakeup_protocols; 867 867 allowed = dev->allowed_wakeup_protocols; 868 + if (dev->encode_wakeup && !allowed) 869 + allowed = ir_raw_get_encode_protocols(); 868 870 } 869 871 870 872 mutex_unlock(&dev->lock); ··· 1408 1406 path ? path : "N/A"); 1409 1407 kfree(path); 1410 1408 1411 - if (dev->driver_type == RC_DRIVER_IR_RAW) { 1409 + if (dev->driver_type == RC_DRIVER_IR_RAW || dev->encode_wakeup) { 1412 1410 /* Load raw decoders, if they aren't already */ 1413 1411 if (!raw_init) { 1414 1412 IR_dprintk(1, "Loading raw decoders\n"); 1415 1413 ir_raw_init(); 1416 1414 raw_init = true; 1417 1415 } 1416 + } 1417 + 1418 + if (dev->driver_type == RC_DRIVER_IR_RAW) { 1418 1419 /* calls ir_register_device so unlock mutex here*/ 1419 1420 mutex_unlock(&dev->lock); 1420 1421 rc = ir_raw_event_register(dev);
+3
include/media/rc-core.h
··· 74 74 * @input_dev: the input child device used to communicate events to userspace 75 75 * @driver_type: specifies if protocol decoding is done in hardware or software 76 76 * @idle: used to keep track of RX state 77 + * @encode_wakeup: wakeup filtering uses IR encode API, therefore the allowed 78 + * wakeup protocols is the set of all raw encoders 77 79 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols 78 80 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols 79 81 * @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols ··· 136 134 struct input_dev *input_dev; 137 135 enum rc_driver_type driver_type; 138 136 bool idle; 137 + bool encode_wakeup; 139 138 u64 allowed_protocols; 140 139 u64 enabled_protocols; 141 140 u64 allowed_wakeup_protocols;