From: "Antti Seppälä" <a.seppala@gmail.com>
To: linux-media@vger.kernel.org
Cc: "Mauro Carvalho Chehab" <mchehab@osg.samsung.com>,
"Antti Seppälä" <a.seppala@gmail.com>,
"James Hogan" <james@albanarts.com>,
"David Härdeman" <david@hardeman.nu>
Subject: [PATCH v3 6/7] rc: rc-loopback: Add loopback of filter scancodes
Date: Tue, 31 Mar 2015 20:48:11 +0300 [thread overview]
Message-ID: <1427824092-23163-7-git-send-email-a.seppala@gmail.com> (raw)
In-Reply-To: <1427824092-23163-1-git-send-email-a.seppala@gmail.com>
From: James Hogan <james@albanarts.com>
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 <james@albanarts.com>
Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
Cc: David Härdeman <david@hardeman.nu>
---
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 <linux/device.h>
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/slab.h>
#include <media/rc-core.h>
#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;
--
2.0.5
next prev parent reply other threads:[~2015-03-31 17:49 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-31 17:48 [PATCH v3 0/7] rc: Add IR encode based wakeup filtering Antti Seppälä
2015-03-31 17:48 ` [PATCH v3 1/7] rc: rc-ir-raw: Add scancode encoder callback Antti Seppälä
2015-05-19 20:38 ` David Härdeman
2015-05-20 16:46 ` Antti Seppälä
2015-05-20 18:29 ` David Härdeman
2015-05-20 19:26 ` Antti Seppälä
2015-05-20 20:45 ` David Härdeman
2015-05-21 7:53 ` Antti Seppälä
2015-05-21 9:14 ` David Härdeman
2015-05-21 11:51 ` Antti Seppälä
2015-05-21 12:30 ` David Härdeman
2015-05-21 14:22 ` Antti Seppälä
2015-05-21 19:40 ` David Härdeman
2015-05-22 5:27 ` Antti Seppälä
2015-05-22 10:33 ` David Härdeman
2015-05-23 11:34 ` Antti Seppälä
2015-06-13 23:44 ` David Härdeman
2015-06-17 22:59 ` Antti Seppälä
2015-06-18 21:23 ` Mauro Carvalho Chehab
2015-06-23 20:45 ` David Härdeman
2015-06-29 19:05 ` David Härdeman
2015-07-13 17:47 ` David Härdeman
2015-07-17 13:15 ` Mauro Carvalho Chehab
2015-03-31 17:48 ` [PATCH v3 2/7] rc: rc-ir-raw: Add Manchester encoder (phase encoder) helper Antti Seppälä
2015-03-31 17:48 ` [PATCH v3 3/7] rc: ir-rc5-decoder: Add encode capability Antti Seppälä
2015-03-31 17:48 ` [PATCH v3 4/7] rc: ir-rc6-decoder: " Antti Seppälä
2015-03-31 17:48 ` [PATCH v3 5/7] rc: rc-core: Add support for encode_wakeup drivers Antti Seppälä
2015-03-31 17:48 ` Antti Seppälä [this message]
2015-03-31 17:48 ` [PATCH v3 7/7] rc: nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback Antti Seppälä
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427824092-23163-7-git-send-email-a.seppala@gmail.com \
--to=a.seppala@gmail.com \
--cc=david@hardeman.nu \
--cc=james@albanarts.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).