From patchwork Tue Mar 31 17:48:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QW50dGkgU2VwcMOkbMOk?= X-Patchwork-Id: 6133221 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D673E9F349 for ; Tue, 31 Mar 2015 17:49:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58E3E201BC for ; Tue, 31 Mar 2015 17:49:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B270A201BB for ; Tue, 31 Mar 2015 17:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbbCaRtJ (ORCPT ); Tue, 31 Mar 2015 13:49:09 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:33446 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752733AbbCaRtH (ORCPT ); Tue, 31 Mar 2015 13:49:07 -0400 Received: by lbbzk7 with SMTP id zk7so1973758lbb.0 for ; Tue, 31 Mar 2015 10:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=rgUVJwGz1AQn0lu03tFYMuPnAzMANZIhrrLCnjoZ00U=; b=vE5YmP7fkaPVf36d/XoJkjPeW8BOdbmd+91e2lw+ilw/4hJMSbCJQE+h00Pz+Rqe5U lc4r9BkDlT7OdOu7XkeZCuBq+eUoZdpGcb1Lc1CT9/+lmOzXLy80FKawAm6H/paB04XI +toaaSfMqsX0G9Yy3ZPX1xtX5DYALbrCbQI//DEM+i2Ozxx+SPpafS7zDTHRjrfBpIEl 9NZiBPBzlt3Cdd7RvlMa+iy9NCcqvi15yH3QbCAODd1+OdWpS2YDoNEPcxDuS+5A0FLO L66oNLUnIl3xJR/DfTRQU9tnDl1lbouO3XYweMm3zfTxI+OQM8hhYrDu3W3BNpZRQht+ zavA== X-Received: by 10.152.183.196 with SMTP id eo4mr31238010lac.22.1427824146206; Tue, 31 Mar 2015 10:49:06 -0700 (PDT) Received: from pixie.elisa-laajakaista.fi (a91-154-178-36.elisa-laajakaista.fi. [91.154.178.36]) by mx.google.com with ESMTPSA id qw1sm2771382lbb.21.2015.03.31.10.49.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Mar 2015 10:49:05 -0700 (PDT) From: =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= , James Hogan , =?UTF-8?q?David=20H=C3=A4rdeman?= Subject: [PATCH v3 6/7] rc: rc-loopback: Add loopback of filter scancodes Date: Tue, 31 Mar 2015 20:48:11 +0300 Message-Id: <1427824092-23163-7-git-send-email-a.seppala@gmail.com> X-Mailer: git-send-email 2.0.5 In-Reply-To: <1427824092-23163-1-git-send-email-a.seppala@gmail.com> References: <1427824092-23163-1-git-send-email-a.seppala@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: James Hogan Add the s_wakeup_filter callback to the rc-loopback driver, which instead of setting the filter just feeds the scancode back through the input device so that it can be verified. Signed-off-by: James Hogan Signed-off-by: Antti Seppälä Cc: David Härdeman --- Notes: Changes in v3: - Ported to apply against latest media-tree - Checkpatch.pl fixes Changes in v2: - Move img-ir-raw test code to rc-loopback. - Handle new encode API, specifically -ENOBUFS when the buffer isn't long enough. - Set encode_wakeup so that the set of allowed wakeup protocols matches the set of raw IR encoders. drivers/media/rc/rc-loopback.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c index 63dace8..d8bdf63 100644 --- a/drivers/media/rc/rc-loopback.c +++ b/drivers/media/rc/rc-loopback.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #define DRIVER_NAME "rc-loopback" @@ -176,6 +177,39 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable) return 0; } +static int loop_set_wakeup_filter(struct rc_dev *dev, + struct rc_scancode_filter *sc_filter) +{ + static const unsigned int max = 512; + struct ir_raw_event *raw; + int ret; + int i; + + /* fine to disable filter */ + if (!sc_filter->mask) + return 0; + + /* encode the specified filter and loop it back */ + raw = kmalloc_array(max, sizeof(*raw), GFP_KERNEL); + ret = ir_raw_encode_scancode(dev->enabled_wakeup_protocols, sc_filter, + raw, max); + /* still loop back the partial raw IR even if it's incomplete */ + if (ret == -ENOBUFS) + ret = max; + if (ret >= 0) { + /* do the loopback */ + for (i = 0; i < ret; ++i) + ir_raw_event_store(dev, &raw[i]); + ir_raw_event_handle(dev); + + ret = 0; + } + + kfree(raw); + + return ret; +} + static int __init loop_init(void) { struct rc_dev *rc; @@ -195,6 +229,7 @@ static int __init loop_init(void) rc->map_name = RC_MAP_EMPTY; rc->priv = &loopdev; rc->driver_type = RC_DRIVER_IR_RAW; + rc->encode_wakeup = true; rc->allowed_protocols = RC_BIT_ALL; rc->timeout = 100 * 1000 * 1000; /* 100 ms */ rc->min_timeout = 1; @@ -209,6 +244,7 @@ static int __init loop_init(void) rc->s_idle = loop_set_idle; rc->s_learning_mode = loop_set_learning_mode; rc->s_carrier_report = loop_set_carrier_report; + rc->s_wakeup_filter = loop_set_wakeup_filter; loopdev.txmask = RXMASK_REGULAR; loopdev.txcarrier = 36000;