From patchwork Fri Mar 14 23:04:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 3835901 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4AFFF9F1CD for ; Fri, 14 Mar 2014 23:07:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58A04202A7 for ; Fri, 14 Mar 2014 23:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AB1A20279 for ; Fri, 14 Mar 2014 23:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756008AbaCNXHP (ORCPT ); Fri, 14 Mar 2014 19:07:15 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:41937 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755970AbaCNXHG (ORCPT ); Fri, 14 Mar 2014 19:07:06 -0400 Received: by mail-wi0-f172.google.com with SMTP id hi5so165909wib.11 for ; Fri, 14 Mar 2014 16:07:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=obYZInWlw3dULS1MoNZ5f7YwO6JI4tyjudiBhk5Whwk=; b=L2ysuBorhRgFvVPGumjflNY5TX0Zu8mqBCSmCj1z+u0+eNpdXeOHpm1t64U/Z9KaDP ZA0JycT8zkJyiQmyobQbU31uKIK++eNWILxm8P7Boo6WM/N2VsNTjBnUgFKFYoUscEU2 ZzWHEHDQmd6Gda2OZdSvTdp1kFmB8vmbKQH35FO8VOdev/dqx56tgejPcmodSyRvi2tX YpVs7IE6sXIEEK12IzOy/9lgxSlIVtHDDRC+7sm+pTZEahrs3YhuHU4dNWJTGTmzD+Sx 546Yt3OZU5Y1zXxQiGv0CGwYACXnuw84jSQv3JrtPzepRBzDRbnkjwhtCMjze172OHkV TsXQ== X-Gm-Message-State: ALoCoQlnpOc/Jp420pI21bIflj2YYc/9eTtr520S6C3zJihvlNiQ/fYR8+3hY4l2XdEz1oJY97fb X-Received: by 10.180.108.199 with SMTP id hm7mr355635wib.1.1394838425511; Fri, 14 Mar 2014 16:07:05 -0700 (PDT) Received: from localhost.localdomain (jahogan.plus.com. [212.159.75.221]) by mx.google.com with ESMTPSA id dd3sm17220342wjb.9.2014.03.14.16.07.03 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 14 Mar 2014 16:07:04 -0700 (PDT) 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: [PATCH v2 8/9] rc: rc-loopback: Add loopback of filter scancodes Date: Fri, 14 Mar 2014 23:04:18 +0000 Message-Id: <1394838259-14260-9-git-send-email-james@albanarts.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1394838259-14260-1-git-send-email-james@albanarts.com> References: <1394838259-14260-1-git-send-email-james@albanarts.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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 the s_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 Cc: Mauro Carvalho Chehab Cc: Antti Seppälä --- 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 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c index 0a88e0c..aefd335 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,42 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable) return 0; } +static int loop_set_filter(struct rc_dev *dev, enum rc_filter_type type, + 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(max * sizeof(*raw), GFP_KERNEL); + ret = ir_raw_encode_scancode(dev->enabled_protocols[type], 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; + } else if (type == RC_FILTER_NORMAL) { + /* accept any normal filter */ + ret = 0; + } + + kfree(raw); + + return ret; +} + static int __init loop_init(void) { struct rc_dev *rc; @@ -195,6 +232,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_set_allowed_protocols(rc, RC_BIT_ALL); rc->timeout = 100 * 1000 * 1000; /* 100 ms */ rc->min_timeout = 1; @@ -209,6 +247,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_filter = loop_set_filter; loopdev.txmask = RXMASK_REGULAR; loopdev.txcarrier = 36000;