* [PATCH 3/3] input: keyboard: MCS5080: support led blink when it's touched.
@ 2010-11-15 4:33 Kim, HeungJun
2010-11-15 8:36 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Kim, HeungJun @ 2010-11-15 4:33 UTC (permalink / raw)
To: linux-input, dmitry.torokhov, kyungmin.park
This patch supports touchkey led blinking. The touchkey led lights
on as soon as it touched. After LED_TIME, the led lights-off.
Signed-off-by: Heungjun Kim <riverful.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/input/keyboard/mcs_touchkey.c | 39 +++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 931b28c..e3fd31f 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -19,6 +19,7 @@
#include <linux/input.h>
#include <linux/irq.h>
#include <linux/slab.h>
+#include <linux/workqueue.h>
/* MCS5000 Touchkey */
#define MCS5000_TOUCHKEY_STATUS 0x04
@@ -32,6 +33,8 @@
#define MCS5080_TOUCHKEY_FW 0x01
#define MCS5080_TOUCHKEY_BASE_VAL 0x1
+#define LED_TIME 500
+
enum mcs_touchkey_type {
MCS5000_TOUCHKEY,
MCS5080_TOUCHKEY,
@@ -46,6 +49,8 @@ struct mcs_touchkey_chip {
struct mcs_touchkey_data {
void (*poweron)(int);
+ struct delayed_work work;
+ int suspended;
struct i2c_client *client;
struct input_dev *input_dev;
@@ -55,6 +60,30 @@ struct mcs_touchkey_data {
unsigned short keycodes[];
};
+static void mcs_touchkey_led(struct mcs_touchkey_data *data, int on)
+{
+ unsigned char buf;
+
+ if (data->suspended)
+ return;
+
+ if (on)
+ buf = 0x1;
+ else
+ buf = 0x2;
+ i2c_master_send(data->client, &buf, 1);
+}
+
+static void mcs_touchkey_work(struct work_struct *work)
+{
+ struct delayed_work *dw = to_delayed_work(work);
+ struct mcs_touchkey_data *data;
+
+ data = container_of(dw, struct mcs_touchkey_data, work);
+
+ mcs_touchkey_led(data, 0);
+}
+
static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
{
struct mcs_touchkey_data *data = dev_id;
@@ -89,6 +118,14 @@ static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
input_report_key(input, data->key_code, pressed);
input_sync(input);
+ if (pressed) {
+ cancel_work_sync(&data->work.work);
+ mcs_touchkey_led(data, 1);
+ } else {
+ if (!delayed_work_pending(&data->work))
+ schedule_delayed_work(&data->work, msecs_to_jiffies(LED_TIME));
+ }
+
dev_dbg(&client->dev, "key %d %d %s\n", data->key_val, data->key_code,
pressed ? "pressed" : "released");
@@ -173,6 +210,8 @@ static int __devinit mcs_touchkey_probe(struct i2c_client *client,
if (pdata->poweron)
data->poweron = pdata->poweron;
+ INIT_DELAYED_WORK(&data->work, mcs_touchkey_work);
+
error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
IRQF_TRIGGER_FALLING, client->dev.driver->name, data);
if (error) {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] input: keyboard: MCS5080: support led blink when it's touched.
2010-11-15 4:33 [PATCH 3/3] input: keyboard: MCS5080: support led blink when it's touched Kim, HeungJun
@ 2010-11-15 8:36 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2010-11-15 8:36 UTC (permalink / raw)
To: Kim, HeungJun; +Cc: linux-input, kyungmin.park
On Mon, Nov 15, 2010 at 01:33:30PM +0900, Kim, HeungJun wrote:
> This patch supports touchkey led blinking. The touchkey led lights
> on as soon as it touched. After LED_TIME, the led lights-off.
>
I do not think it should be kept in the driver... Not everyone might
want that, for starters. I wonder if it needs to be plugged into LED
layer and then keyboard input might be used as a trigger for that LED.
Thanks.
> Signed-off-by: Heungjun Kim <riverful.kim@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/input/keyboard/mcs_touchkey.c | 39 +++++++++++++++++++++++++++++++++
> 1 files changed, 39 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
> index 931b28c..e3fd31f 100644
> --- a/drivers/input/keyboard/mcs_touchkey.c
> +++ b/drivers/input/keyboard/mcs_touchkey.c
> @@ -19,6 +19,7 @@
> #include <linux/input.h>
> #include <linux/irq.h>
> #include <linux/slab.h>
> +#include <linux/workqueue.h>
>
> /* MCS5000 Touchkey */
> #define MCS5000_TOUCHKEY_STATUS 0x04
> @@ -32,6 +33,8 @@
> #define MCS5080_TOUCHKEY_FW 0x01
> #define MCS5080_TOUCHKEY_BASE_VAL 0x1
>
> +#define LED_TIME 500
> +
> enum mcs_touchkey_type {
> MCS5000_TOUCHKEY,
> MCS5080_TOUCHKEY,
> @@ -46,6 +49,8 @@ struct mcs_touchkey_chip {
>
> struct mcs_touchkey_data {
> void (*poweron)(int);
> + struct delayed_work work;
> + int suspended;
>
> struct i2c_client *client;
> struct input_dev *input_dev;
> @@ -55,6 +60,30 @@ struct mcs_touchkey_data {
> unsigned short keycodes[];
> };
>
> +static void mcs_touchkey_led(struct mcs_touchkey_data *data, int on)
> +{
> + unsigned char buf;
> +
> + if (data->suspended)
> + return;
> +
> + if (on)
> + buf = 0x1;
> + else
> + buf = 0x2;
> + i2c_master_send(data->client, &buf, 1);
> +}
> +
> +static void mcs_touchkey_work(struct work_struct *work)
> +{
> + struct delayed_work *dw = to_delayed_work(work);
> + struct mcs_touchkey_data *data;
> +
> + data = container_of(dw, struct mcs_touchkey_data, work);
> +
> + mcs_touchkey_led(data, 0);
> +}
> +
> static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
> {
> struct mcs_touchkey_data *data = dev_id;
> @@ -89,6 +118,14 @@ static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
> input_report_key(input, data->key_code, pressed);
> input_sync(input);
>
> + if (pressed) {
> + cancel_work_sync(&data->work.work);
> + mcs_touchkey_led(data, 1);
> + } else {
> + if (!delayed_work_pending(&data->work))
> + schedule_delayed_work(&data->work, msecs_to_jiffies(LED_TIME));
> + }
> +
> dev_dbg(&client->dev, "key %d %d %s\n", data->key_val, data->key_code,
> pressed ? "pressed" : "released");
>
> @@ -173,6 +210,8 @@ static int __devinit mcs_touchkey_probe(struct i2c_client *client,
> if (pdata->poweron)
> data->poweron = pdata->poweron;
>
> + INIT_DELAYED_WORK(&data->work, mcs_touchkey_work);
> +
> error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
> IRQF_TRIGGER_FALLING, client->dev.driver->name, data);
> if (error) {
> --
> 1.7.0.4
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-15 8:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 4:33 [PATCH 3/3] input: keyboard: MCS5080: support led blink when it's touched Kim, HeungJun
2010-11-15 8:36 ` Dmitry Torokhov
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).