linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kyungmin Park <kmpark@infradead.org>
To: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com
Subject: [PATCH] Input notifier support
Date: Wed, 25 Feb 2009 13:47:30 +0900	[thread overview]
Message-ID: <20090225044730.GA9106@july> (raw)

Some hardware doesn't connected with key button and led. In this case key should be connected with led by software. Of course each application can control it however it's too big burden to application programmer.

So add input notifier and then use it at other frameworks such as led.
Of course, other input device can use this one.

Any commnets are welcome.

Thank you,
Kyungmin Park

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 4c9c745..99feb46 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -5,7 +5,7 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_INPUT)		+= input-core.o
-input-core-objs := input.o input-compat.o ff-core.o
+input-core-objs := input.o input-compat.o ff-core.o input_notify.o
 
 obj-$(CONFIG_INPUT_FF_MEMLESS)	+= ff-memless.o
 obj-$(CONFIG_INPUT_POLLDEV)	+= input-polldev.o
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1730d73..7e96635 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -274,6 +274,8 @@ void input_event(struct input_dev *dev,
 		add_input_randomness(type, code, value);
 		input_handle_event(dev, type, code, value);
 		spin_unlock_irqrestore(&dev->event_lock, flags);
+		if (type == EV_KEY)
+			input_notifier_call_chain(value, &code);
 	}
 }
 EXPORT_SYMBOL(input_event);
diff --git a/drivers/input/input_notify.c b/drivers/input/input_notify.c
new file mode 100644
index 0000000..a89cfb6
--- /dev/null
+++ b/drivers/input/input_notify.c
@@ -0,0 +1,43 @@
+/*
+ * Input Notifier
+ *
+ * Copyright (C) 2009 Samsung Electronics
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#include <linux/input.h>
+#include <linux/notifier.h>
+
+static BLOCKING_NOTIFIER_HEAD(input_notifier_list);
+
+/**
+ *	input_register_client - register a client notifier
+ *	@nb: notifier block to callback on events
+ */
+int input_register_client(struct notifier_block *nb)
+{
+        return blocking_notifier_chain_register(&input_notifier_list, nb);
+}
+EXPORT_SYMBOL(input_register_client);
+
+/**
+ *	input_unregister_client - unregister a client notifier
+ *	@nb: notifier block to callback on events
+ */
+int input_unregister_client(struct notifier_block *nb)
+{
+        return blocking_notifier_chain_unregister(&input_notifier_list, nb);
+}
+EXPORT_SYMBOL(input_unregister_client);
+
+/**
+ *	input_notifier_call_chain - notify clients of input_events
+ */
+int input_notifier_call_chain(unsigned long val, void *v)
+{
+        return blocking_notifier_call_chain(&input_notifier_list, val, v);
+}
+EXPORT_SYMBOL(input_notifier_call_chain);
diff --git a/include/linux/input.h b/include/linux/input.h
index 1249a0c..7e07bf3 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1325,6 +1325,10 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min
 int input_get_keycode(struct input_dev *dev, int scancode, int *keycode);
 int input_set_keycode(struct input_dev *dev, int scancode, int keycode);
 
+extern int input_register_client(struct notifier_block *nb);
+extern int input_unregister_client(struct notifier_block *nb);
+extern int input_notifier_call_chain(unsigned long val, void *v);
+
 extern struct class input_class;
 
 /**

             reply	other threads:[~2009-02-25  4:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-25  4:47 Kyungmin Park [this message]
2009-02-25  8:03 ` [PATCH] Input notifier support Trilok Soni
2009-02-25  9:55   ` Kyungmin Park
2009-02-26  7:01 ` Trilok Soni
2009-02-27  2:11   ` Kyungmin Park
2009-02-27 12:35     ` Trilok Soni
2009-02-28 22:30 ` Dmitry Torokhov
2009-02-28 23:34 ` Andi Kleen
2009-03-01  0:42   ` Dmitry Torokhov
2009-03-01  2:52     ` Kyungmin Park
2009-03-01  3:07       ` Dmitry Torokhov
2009-03-01  3:16         ` Kyungmin Park
2009-03-01  6:29           ` Dmitry Torokhov

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=20090225044730.GA9106@july \
    --to=kmpark@infradead.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).