From patchwork Thu Feb 6 19:59:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 3598201 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EF15BBF418 for ; Thu, 6 Feb 2014 20:00:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 165AF20136 for ; Thu, 6 Feb 2014 20:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13ABA20131 for ; Thu, 6 Feb 2014 20:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757014AbaBFUA3 (ORCPT ); Thu, 6 Feb 2014 15:00:29 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:63848 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756850AbaBFT77 (ORCPT ); Thu, 6 Feb 2014 14:59:59 -0500 Received: by mail-wi0-f169.google.com with SMTP id e4so190284wiv.4 for ; Thu, 06 Feb 2014 11:59:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=W/sG+nqZNc5mGsBOcCaOdPe3641JLTaHmMkzJlliO7g=; b=hOFk3RCyiIbcYpCdcM4Cmxpfd9gebjZ5fC7IijmpdsTFEg8F6Kr3hEyP9VUuFp5t22 Q8kcVX9z7uDw6fwQZ7oS/cgYcA8lLdBmP+hCbeDim0xWOsrzsl+Q0nzeurHL6pq+3+0k QNpJ5tvjfNqsVN5KcuuXpPMyWIozvizVvbblJuCYp32xXa+iD501a2umHC/4zvWZEvHf YOe3sdNjDud/V9p+sqTQTZLf/bKG98JcKB+/ZEc8caXxIHcIb2sOPYCMVtyjWT2TekJI JmzIpmItF0NAzP0XBBVZEZuf9SFdq9JjojQEs20Ehat6lobHJYzIb77NqGEOYFwW5qpM IUCg== X-Gm-Message-State: ALoCoQlPIfV9GgLM0Wm+Dn3/SieH+NFwXgGIfbSyJUSowXTYudd06ETUASb5P1ho3AA9eG+uiY0c X-Received: by 10.194.60.103 with SMTP id g7mr7383838wjr.37.1391716797863; Thu, 06 Feb 2014 11:59:57 -0800 (PST) Received: from radagast.lan (jahogan.plus.com. [212.159.75.221]) by mx.google.com with ESMTPSA id f3sm1493472wiv.2.2014.02.06.11.59.57 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Thu, 06 Feb 2014 11:59:57 -0800 (PST) From: James Hogan To: Mauro Carvalho Chehab , =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= Cc: linux-media@vger.kernel.org, James Hogan Subject: [RFC 1/4] rc: ir-raw: add scancode encoder callback Date: Thu, 6 Feb 2014 19:59:20 +0000 Message-Id: <1391716763-2689-2-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391716763-2689-1-git-send-email-james.hogan@imgtec.com> References: <1391716763-2689-1-git-send-email-james.hogan@imgtec.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a callback to raw ir handlers for encoding and modulating a scancode to a set of raw events. This could be used for transmit, or for converting a wakeup scancode filter to a form that is more suitable for raw hardware wake up filters. Signed-off-by: James Hogan --- drivers/media/rc/ir-raw.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/media/rc/rc-core-priv.h | 2 ++ include/media/rc-core.h | 3 +++ 3 files changed, 42 insertions(+) diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c index 79a9cb6..9aea407 100644 --- a/drivers/media/rc/ir-raw.c +++ b/drivers/media/rc/ir-raw.c @@ -240,6 +240,43 @@ ir_raw_get_allowed_protocols(void) return protocols; } +/** + * ir_raw_encode_scancode() - Encode a scancode as raw events + * + * @protocols: permitted protocols + * @scancode: scancode filter describing a single scancode + * @events: array of raw events to write into + * @max: max number of raw events + * + * Attempts to encode the scancode as raw events. + * + * Returns -EINVAL if the scancode is ambiguous or invalid, or there isn't + * enough space in the array to fit the encoding. + * + * Returns -ENOTSUPP if no compatible encoder is found. + */ +int ir_raw_encode_scancode(u64 protocols, + const struct rc_scancode_filter *scancode, + struct ir_raw_event *events, unsigned int max) +{ + struct ir_raw_handler *handler; + int ret = -ENOTSUPP; + + mutex_lock(&ir_raw_handler_lock); + list_for_each_entry(handler, &ir_raw_handler_list, list) { + if (handler->protocols & protocols && handler->encode) { + ret = handler->encode(protocols, scancode, events, max); + if (ret >= 0) + break; + } + } + mutex_unlock(&ir_raw_handler_lock); + + return ret; +} +EXPORT_SYMBOL(ir_raw_encode_scancode); + + /* * Used to (un)register raw event clients */ diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index dc3b0b7..dfbaad0 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -25,6 +25,8 @@ struct ir_raw_handler { u64 protocols; /* which are handled by this handler */ int (*decode)(struct rc_dev *dev, struct ir_raw_event event); + int (*encode)(u64 protocols, const struct rc_scancode_filter *scancode, + struct ir_raw_event *events, unsigned int max); /* These two should only be used by the lirc decoder */ int (*raw_register)(struct rc_dev *dev); diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 4a72176..7bd66be 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -234,6 +234,9 @@ int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type); int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev); void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); +int ir_raw_encode_scancode(u64 protocols, + const struct rc_scancode_filter *scancode, + struct ir_raw_event *events, unsigned int max); static inline void ir_raw_event_reset(struct rc_dev *dev) {