Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

James Hogan and committed by
Mauro Carvalho Chehab
2e4ebde2 0d830b2d

+36
+36
drivers/media/rc/rc-loopback.c
··· 26 26 #include <linux/device.h> 27 27 #include <linux/module.h> 28 28 #include <linux/sched.h> 29 + #include <linux/slab.h> 29 30 #include <media/rc-core.h> 30 31 31 32 #define DRIVER_NAME "rc-loopback" ··· 177 176 return 0; 178 177 } 179 178 179 + static int loop_set_wakeup_filter(struct rc_dev *dev, 180 + struct rc_scancode_filter *sc_filter) 181 + { 182 + static const unsigned int max = 512; 183 + struct ir_raw_event *raw; 184 + int ret; 185 + int i; 186 + 187 + /* fine to disable filter */ 188 + if (!sc_filter->mask) 189 + return 0; 190 + 191 + /* encode the specified filter and loop it back */ 192 + raw = kmalloc_array(max, sizeof(*raw), GFP_KERNEL); 193 + ret = ir_raw_encode_scancode(dev->enabled_wakeup_protocols, sc_filter, 194 + raw, max); 195 + /* still loop back the partial raw IR even if it's incomplete */ 196 + if (ret == -ENOBUFS) 197 + ret = max; 198 + if (ret >= 0) { 199 + /* do the loopback */ 200 + for (i = 0; i < ret; ++i) 201 + ir_raw_event_store(dev, &raw[i]); 202 + ir_raw_event_handle(dev); 203 + 204 + ret = 0; 205 + } 206 + 207 + kfree(raw); 208 + 209 + return ret; 210 + } 211 + 180 212 static int __init loop_init(void) 181 213 { 182 214 struct rc_dev *rc; ··· 229 195 rc->map_name = RC_MAP_EMPTY; 230 196 rc->priv = &loopdev; 231 197 rc->driver_type = RC_DRIVER_IR_RAW; 198 + rc->encode_wakeup = true; 232 199 rc->allowed_protocols = RC_BIT_ALL; 233 200 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 234 201 rc->min_timeout = 1; ··· 244 209 rc->s_idle = loop_set_idle; 245 210 rc->s_learning_mode = loop_set_learning_mode; 246 211 rc->s_carrier_report = loop_set_carrier_report; 212 + rc->s_wakeup_filter = loop_set_wakeup_filter; 247 213 248 214 loopdev.txmask = RXMASK_REGULAR; 249 215 loopdev.txcarrier = 36000;