From: "Antti Seppälä" <a.seppala@gmail.com>
To: linux-media@vger.kernel.org
Cc: "Mauro Carvalho Chehab" <m.chehab@samsung.com>,
"Sean Young" <sean@mess.org>,
"Antti Seppälä" <a.seppala@gmail.com>
Subject: [RFCv2 PATCH 3/5] rc-loopback: Add support for reading/writing wakeup scancodes via sysfs
Date: Sun, 26 Jan 2014 23:50:24 +0200 [thread overview]
Message-ID: <1390773026-567-4-git-send-email-a.seppala@gmail.com> (raw)
In-Reply-To: <1390773026-567-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 | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 53d0282..46e76ad 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -26,6 +26,7 @@
#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"
@@ -45,6 +46,7 @@ struct loopback_dev {
bool carrierreport;
u32 rxcarriermin;
u32 rxcarriermax;
+ u32 wakeup_scancode;
};
static struct loopback_dev loopdev;
@@ -176,6 +178,41 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable)
return 0;
}
+static int loop_wakeup_codes(struct rc_dev *dev,
+ struct list_head *wakeup_code_list, int write)
+{
+ u32 value = 0;
+ struct rc_wakeup_code *code;
+ struct loopback_dev *lodev = dev->priv;
+
+ dprintk("%sing wakeup codes\n", write ? "writ" : "read");
+
+ if (write) {
+ code = list_first_entry_or_null(wakeup_code_list,
+ struct rc_wakeup_code,
+ list_item);
+ if (code)
+ value = code->value;
+
+ if (dev->enabled_wake_protos & RC_BIT_RC5) {
+ if (value > 0xFFF)
+ return -EINVAL;
+ } else if (dev->enabled_wake_protos & RC_BIT_RC6_0) {
+ if (value > 0xFFFF)
+ return -EINVAL;
+ }
+
+ lodev->wakeup_scancode = value;
+ } else {
+ code = kmalloc(sizeof(struct rc_wakeup_code), GFP_KERNEL);
+ if (!code)
+ return -ENOMEM;
+ code->value = lodev->wakeup_scancode;
+ list_add_tail(&code->list_item, wakeup_code_list);
+ }
+ return 0;
+}
+
static int __init loop_init(void)
{
struct rc_dev *rc;
@@ -196,6 +233,8 @@ static int __init loop_init(void)
rc->priv = &loopdev;
rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protos = RC_BIT_ALL;
+ rc->allowed_wake_protos = RC_BIT_RC6_0 | RC_BIT_RC5;
+ rc->enabled_wake_protos = RC_BIT_RC6_0;
rc->timeout = 100 * 1000 * 1000; /* 100 ms */
rc->min_timeout = 1;
rc->max_timeout = UINT_MAX;
@@ -209,6 +248,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_codes = loop_wakeup_codes;
loopdev.txmask = RXMASK_REGULAR;
loopdev.txcarrier = 36000;
--
1.8.3.2
next prev parent reply other threads:[~2014-01-26 21:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-26 21:50 [RFCv2 PATCH 0/5] rc: Add generic sysfs interface for handling wakeup codes Antti Seppälä
2014-01-26 21:50 ` [RFCv2 PATCH 1/5] rc-core: Add defintions needed for sysfs callback Antti Seppälä
2014-01-26 21:50 ` [RFCv2 PATCH 2/5] rc-core: Add support for reading/writing wakeup codes via sysfs Antti Seppälä
2014-01-26 21:50 ` Antti Seppälä [this message]
2014-01-26 21:50 ` [RFCv2 PATCH 4/5] nuvoton-cir: Add support for reading/writing wakeup samples " Antti Seppälä
2014-01-26 21:50 ` [RFCv2 PATCH 5/5] winbond-cir: Add support for reading/writing wakeup scancodes " Antti Seppälä
2014-01-30 19:24 ` Sean Young
2014-01-31 13:34 ` Antti Seppälä
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=1390773026-567-4-git-send-email-a.seppala@gmail.com \
--to=a.seppala@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=sean@mess.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox