summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Hogan <james@albanarts.com>2015-03-31 13:48:11 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-14 13:35:59 -0400
commit2e4ebde269236da2a41183522127715b6d9d80ce (patch)
tree9f1497f7acb179c4503dfc666c32f72c62019f9d
parent0d830b2d1295fee82546d57185da5a6604f11ae2 (diff)
[media] rc: rc-loopback: Add loopback of filter scancodes
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> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/rc/rc-loopback.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 63dace8198b0..d8bdf63ce985 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -26,6 +26,7 @@
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/slab.h>
29#include <media/rc-core.h> 30#include <media/rc-core.h>
30 31
31#define DRIVER_NAME "rc-loopback" 32#define DRIVER_NAME "rc-loopback"
@@ -176,6 +177,39 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable)
176 return 0; 177 return 0;
177} 178}
178 179
180static int loop_set_wakeup_filter(struct rc_dev *dev,
181 struct rc_scancode_filter *sc_filter)
182{
183 static const unsigned int max = 512;
184 struct ir_raw_event *raw;
185 int ret;
186 int i;
187
188 /* fine to disable filter */
189 if (!sc_filter->mask)
190 return 0;
191
192 /* encode the specified filter and loop it back */
193 raw = kmalloc_array(max, sizeof(*raw), GFP_KERNEL);
194 ret = ir_raw_encode_scancode(dev->enabled_wakeup_protocols, sc_filter,
195 raw, max);
196 /* still loop back the partial raw IR even if it's incomplete */
197 if (ret == -ENOBUFS)
198 ret = max;
199 if (ret >= 0) {
200 /* do the loopback */
201 for (i = 0; i < ret; ++i)
202 ir_raw_event_store(dev, &raw[i]);
203 ir_raw_event_handle(dev);
204
205 ret = 0;
206 }
207
208 kfree(raw);
209
210 return ret;
211}
212
179static int __init loop_init(void) 213static int __init loop_init(void)
180{ 214{
181 struct rc_dev *rc; 215 struct rc_dev *rc;
@@ -195,6 +229,7 @@ static int __init loop_init(void)
195 rc->map_name = RC_MAP_EMPTY; 229 rc->map_name = RC_MAP_EMPTY;
196 rc->priv = &loopdev; 230 rc->priv = &loopdev;
197 rc->driver_type = RC_DRIVER_IR_RAW; 231 rc->driver_type = RC_DRIVER_IR_RAW;
232 rc->encode_wakeup = true;
198 rc->allowed_protocols = RC_BIT_ALL; 233 rc->allowed_protocols = RC_BIT_ALL;
199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 234 rc->timeout = 100 * 1000 * 1000; /* 100 ms */
200 rc->min_timeout = 1; 235 rc->min_timeout = 1;
@@ -209,6 +244,7 @@ static int __init loop_init(void)
209 rc->s_idle = loop_set_idle; 244 rc->s_idle = loop_set_idle;
210 rc->s_learning_mode = loop_set_learning_mode; 245 rc->s_learning_mode = loop_set_learning_mode;
211 rc->s_carrier_report = loop_set_carrier_report; 246 rc->s_carrier_report = loop_set_carrier_report;
247 rc->s_wakeup_filter = loop_set_wakeup_filter;
212 248
213 loopdev.txmask = RXMASK_REGULAR; 249 loopdev.txmask = RXMASK_REGULAR;
214 loopdev.txcarrier = 36000; 250 loopdev.txcarrier = 36000;