From patchwork Fri Feb 28 23:17:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 3744961 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 B5FEC9F489 for ; Fri, 28 Feb 2014 23:17:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D832E201EF for ; Fri, 28 Feb 2014 23:17:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA5D320225 for ; Fri, 28 Feb 2014 23:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbaB1XRm (ORCPT ); Fri, 28 Feb 2014 18:17:42 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:40479 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787AbaB1XRj (ORCPT ); Fri, 28 Feb 2014 18:17:39 -0500 Received: by mail-wi0-f180.google.com with SMTP id hm4so1203580wib.13 for ; Fri, 28 Feb 2014 15:17:38 -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:mime-version:content-type :content-transfer-encoding; bh=aCSqnFxA8lc5hfe/VOU5yM1pY9L8zDKNVxu2b1Fq+F8=; b=MCnq4fdYmSmPZqalB/0LKpIuuWIJ5sJ+bNW7UJCX5JOTQ8B9h19GaznPv25nL5+pwU +gWzPnGO3ngWZuFPZpSX3RCZT46cWSX0pBLugXUPwx9HYAJZKkiOe4iEY9vzy1l9nDin E0JGEgNgnUmM6OuXZNitoEuojZ0zv+dLqS62oQEafqg2doEDIGuP1EPYToEWhBVZMGBt H1V669dkRLH9krEIGfPxh7T/ikkEaESMI2vWO9tcMEgafDQKXvHyW7NScCz5tbJhO2Zf bv33+4YXyYroSwqFUo8qUblk9SIbyUwwGYUT/TOsyZ9SeCyI4mx2nT6deAGWYmhp9/oH tggw== X-Gm-Message-State: ALoCoQnP+8ru5Cp6bfVMz/ISGHvJZyTGvJzKJzgkK/CWZ0yDyNaiZZWna1nxJK+RtUeO8CS0CPAr X-Received: by 10.194.104.39 with SMTP id gb7mr4673203wjb.69.1393629458433; Fri, 28 Feb 2014 15:17:38 -0800 (PST) Received: from radagast.lan (jahogan.plus.com. [212.159.75.221]) by mx.google.com with ESMTPSA id dk9sm7934562wjb.4.2014.02.28.15.17.36 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 28 Feb 2014 15:17:37 -0800 (PST) From: James Hogan To: Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: James Hogan , =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= Subject: [PATCH 1/5] rc-main: add generic scancode filtering Date: Fri, 28 Feb 2014 23:17:02 +0000 Message-Id: <1393629426-31341-2-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393629426-31341-1-git-send-email-james.hogan@imgtec.com> References: <1393629426-31341-1-git-send-email-james.hogan@imgtec.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, 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 generic scancode filtering of RC input events, and fall back to permitting any RC_FILTER_NORMAL scancode filter to be set if no s_filter callback exists. This allows raw IR decoder events to be filtered, and potentially allows hardware decoders to set looser filters and rely on generic code to filter out the corner cases. Signed-off-by: James Hogan Cc: Mauro Carvalho Chehab Cc: Antti Seppälä Cc: linux-media@vger.kernel.org --- drivers/media/rc/rc-main.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 6448128..0a4f680 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -633,6 +633,7 @@ EXPORT_SYMBOL_GPL(rc_repeat); static void ir_do_keydown(struct rc_dev *dev, int scancode, u32 keycode, u8 toggle) { + struct rc_scancode_filter *filter; bool new_event = !dev->keypressed || dev->last_scancode != scancode || dev->last_toggle != toggle; @@ -640,6 +641,11 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode, if (new_event && dev->keypressed) ir_do_keyup(dev, false); + /* Generic scancode filtering */ + filter = &dev->scancode_filters[RC_FILTER_NORMAL]; + if (filter->mask && ((scancode ^ filter->data) & filter->mask)) + return; + input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); if (new_event && keycode != KEY_RESERVED) { @@ -1019,9 +1025,7 @@ static ssize_t show_filter(struct device *device, return -EINVAL; mutex_lock(&dev->lock); - if (!dev->s_filter) - val = 0; - else if (fattr->mask) + if (fattr->mask) val = dev->scancode_filters[fattr->type].mask; else val = dev->scancode_filters[fattr->type].data; @@ -1069,7 +1073,7 @@ static ssize_t store_filter(struct device *device, return ret; /* Scancode filter not supported (but still accept 0) */ - if (!dev->s_filter) + if (!dev->s_filter && fattr->type != RC_FILTER_NORMAL) return val ? -EINVAL : count; mutex_lock(&dev->lock); @@ -1081,9 +1085,11 @@ static ssize_t store_filter(struct device *device, local_filter.mask = val; else local_filter.data = val; - ret = dev->s_filter(dev, fattr->type, &local_filter); - if (ret < 0) - goto unlock; + if (dev->s_filter) { + ret = dev->s_filter(dev, fattr->type, &local_filter); + if (ret < 0) + goto unlock; + } /* Success, commit the new filter */ *filter = local_filter;