@@ -7,6 +7,7 @@
* signal edges are reported and decoded by generic software decoders.
*/
+#include <linux/slab.h>
#include <linux/spinlock.h>
#include <media/rc-core.h>
#include "img-ir.h"
@@ -95,6 +96,34 @@ void img_ir_setup_raw(struct img_ir_priv *priv)
spin_unlock_irq(&priv->lock);
}
+static int img_ir_raw_set_filter(struct rc_dev *dev, enum rc_filter_type type,
+ struct rc_scancode_filter *sc_filter)
+{
+ struct ir_raw_event *raw;
+ int ret;
+ int i;
+
+ /* fine to disable filter */
+ if (!sc_filter->mask)
+ return 0;
+
+ raw = kmalloc(512 * sizeof(*raw), GFP_KERNEL);
+ ret = ir_raw_encode_scancode(dev->enabled_protocols, sc_filter, raw,
+ 512);
+ if (ret >= 0) {
+ /* loop back the scancode just for fun! */
+ for (i = 0; i < ret; ++i)
+ ir_raw_event_store(dev, &raw[i]);
+ ir_raw_event_handle(dev);
+
+ ret = 0;
+ }
+
+ kfree(raw);
+
+ return ret;
+}
+
int img_ir_probe_raw(struct img_ir_priv *priv)
{
struct img_ir_priv_raw *raw = &priv->raw;
@@ -114,6 +143,7 @@ int img_ir_probe_raw(struct img_ir_priv *priv)
rdev->map_name = RC_MAP_EMPTY;
rdev->input_name = "IMG Infrared Decoder Raw";
rdev->driver_type = RC_DRIVER_IR_RAW;
+ rdev->s_filter = img_ir_raw_set_filter;
/* Register raw decoder */
error = rc_register_device(rdev);