From cdfaa01c1cfeb828e6d3c0c5e4f54375fc3ccb95 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:30 -0500 Subject: media: lirc: use the correct carrier for scancode transmit If the lirc device supports it, set the carrier for the protocol. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/rc-ir-raw.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'drivers/media/rc/rc-ir-raw.c') diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 0616eee564a8..208db8a5adff 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -484,6 +484,36 @@ static void edge_handle(struct timer_list *t) ir_raw_event_handle(dev); } +/** + * ir_raw_encode_carrier() - Get carrier used for protocol + * + * @protocol: protocol + * + * Attempts to find the carrier for the specified protocol + * + * Returns: The carrier in Hz + * -EINVAL if the protocol is invalid, or if no + * compatible encoder was found. + */ +int ir_raw_encode_carrier(enum rc_proto protocol) +{ + struct ir_raw_handler *handler; + int ret = -EINVAL; + u64 mask = BIT_ULL(protocol); + + mutex_lock(&ir_raw_handler_lock); + list_for_each_entry(handler, &ir_raw_handler_list, list) { + if (handler->protocols & mask && handler->encode) { + ret = handler->carrier; + break; + } + } + mutex_unlock(&ir_raw_handler_lock); + + return ret; +} +EXPORT_SYMBOL(ir_raw_encode_carrier); + /* * Used to (un)register raw event clients */ -- cgit