[RFC PATCH 3/4] rc-loopback: Add support for reading/writing wakeup scancodes via sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds sample support for reading/writing the wakeup scancodes
to rc-loopback device driver.

Signed-off-by: Antti Seppälä <a.seppala@xxxxxxxxx>
---
 drivers/media/rc/rc-loopback.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 53d0282..12bd1c5 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -26,12 +26,14 @@
 #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"
 #define dprintk(x...)	if (debug) printk(KERN_INFO DRIVER_NAME ": " x)
 #define RXMASK_REGULAR	0x1
 #define RXMASK_LEARNING	0x2
+#define WAKE_CODE_LEN	0xF
 
 static bool debug;
 
@@ -45,6 +47,7 @@ struct loopback_dev {
 	bool carrierreport;
 	u32 rxcarriermin;
 	u32 rxcarriermax;
+	u8 wake_codes[WAKE_CODE_LEN];
 };
 
 static struct loopback_dev loopdev;
@@ -176,6 +179,33 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable)
 	return 0;
 }
 
+static int loop_wakeup_scancodes(struct rc_dev *dev,
+				 struct list_head *scancode_list, int write)
+{
+	int i = 0;
+	struct rc_wakeup_scancode *scancode;
+	struct loopback_dev *lodev = dev->priv;
+
+	dprintk("%sing wakeup scancodes\n", write ? "writ" : "read");
+
+	if (write) {
+		list_for_each_entry_reverse(scancode, scancode_list,
+					    list_item) {
+			lodev->wake_codes[i] = scancode->value;
+			if (++i > WAKE_CODE_LEN)
+				return -EINVAL;
+		}
+	} else {
+		for (i = 0; i < WAKE_CODE_LEN; i++) {
+			scancode = kmalloc(sizeof(struct rc_wakeup_scancode),
+					   GFP_KERNEL);
+			scancode->value = lodev->wake_codes[i];
+			list_add(&scancode->list_item, scancode_list);
+		}
+	}
+	return 0;
+}
+
 static int __init loop_init(void)
 {
 	struct rc_dev *rc;
@@ -209,6 +239,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_scancodes	= loop_wakeup_scancodes;
 
 	loopdev.txmask		= RXMASK_REGULAR;
 	loopdev.txcarrier	= 36000;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux