All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Antti Seppälä" <a.seppala@gmail.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org, "Antti Seppälä" <a.seppala@gmail.com>
Subject: [RFC PATCH 3/4] rc-loopback: Add support for reading/writing wakeup scancodes via sysfs
Date: Mon, 20 Jan 2014 21:39:46 +0200	[thread overview]
Message-ID: <1390246787-15616-4-git-send-email-a.seppala@gmail.com> (raw)
In-Reply-To: <1390246787-15616-1-git-send-email-a.seppala@gmail.com>

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

Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
---
 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


  parent reply	other threads:[~2014-01-20 19:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03 14:18 [PATCH] nuvoton-cir: Add support for user configurable wake-up codes Antti Seppälä
2014-01-15 19:35 ` Mauro Carvalho Chehab
2014-01-20 19:39   ` [RFC PATCH 0/4] rc: Adding support for sysfs wakeup scancodes Antti Seppälä
2014-01-20 19:39     ` [RFC PATCH 1/4] rc-core: Add defintions needed for sysfs callback Antti Seppälä
2014-01-20 19:39     ` [RFC PATCH 2/4] rc-core: Add support for reading/writing wakeup scancodes via sysfs Antti Seppälä
2014-01-20 19:39     ` Antti Seppälä [this message]
2014-01-20 19:39     ` [RFC PATCH 4/4] nuvoton-cir: " Antti Seppälä
2014-01-21 12:28     ` [RFC PATCH 0/4] rc: Adding support for sysfs wakeup scancodes Sean Young
2014-01-22 15:46       ` Antti Seppälä
2014-01-22 16:29         ` Sean Young
2014-01-22 19:10           ` Antti Seppälä
2014-01-22 19:21             ` Antti Palosaari
2014-01-22 21:00             ` Sean Young
2014-01-22 22:01               ` Mauro Carvalho Chehab
2014-01-23 19:11                 ` Antti Seppälä
2014-02-04 17:54                   ` Mauro Carvalho Chehab
2014-02-05  7:03                     ` Antti Seppälä
2014-02-05  9:36                       ` Mauro Carvalho Chehab
2014-02-05  9:39                       ` James Hogan
2014-02-05  9:42                         ` James Hogan
2014-02-05 18:16                           ` Antti Seppälä
2014-02-05 21:21                             ` Mauro Carvalho Chehab
2014-02-06 10:46                               ` James Hogan
2014-02-06 14:55                                 ` Mauro Carvalho Chehab

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=1390246787-15616-4-git-send-email-a.seppala@gmail.com \
    --to=a.seppala@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.