public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Rainer Koenig <Rainer.Koenig@ts.fujitsu.com>
To: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>
Subject: [PATCH] keymap function for quickstart driver
Date: Mon, 19 Mar 2012 09:35:37 +0100	[thread overview]
Message-ID: <4F66EFD9.7090408@ts.fujitsu.com> (raw)

Hi,

back again with a patch for the quickstart driver that implements a
keymap for the runtime events that quickstart generates. A custom
keymap can be assigned via a simple udev rule.

Background for this: Fujitsu is going to ship very small systems
with no direct eject button for the optical drive. Instead you have
a hotkey that is recognized by the quickstart driver. This patch now
allows to map the key event (0x1) to the keycode "ejectcd" and then
react to this in your desktop manager software.

Signed-off-by: Rainer Koenig <Rainer.Koenig@ts.fujitsu.com>

--- upstream/drivers/staging/quickstart/quickstart.c    2012-03-19 08:25:33.000000000 +0100
+++ new/drivers/staging/quickstart/quickstart.c 2012-03-19 09:03:02.000000000 +0100
@@ -216,6 +216,8 @@
 static void quickstart_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
        struct quickstart_acpi *quickstart = data;
+        unsigned int key;
+        struct input_keymap_entry ke;

        if (!quickstart)
                return;
@@ -223,9 +225,13 @@
        if (event == QUICKSTART_EVENT_WAKE)
                quickstart_data.pressed = quickstart->btn;
        else if (event == QUICKSTART_EVENT_RUNTIME) {
-               input_report_key(quickstart_input, quickstart->btn->id, 1);
+                ke.flags = INPUT_KEYMAP_BY_INDEX;
+                ke.index = quickstart->btn->id;
+                quickstart_input->getkeycode(quickstart_input, &ke);
+                key = ke.keycode;
+               input_report_key(quickstart_input, key, 1);
                input_sync(quickstart_input);
-               input_report_key(quickstart_input, quickstart->btn->id, 0);
+               input_report_key(quickstart_input, key, 0);
                input_sync(quickstart_input);
        }
        return;
@@ -374,8 +380,9 @@
 static int __init quickstart_init_input(void)
 {
        struct quickstart_btn **ptr = &quickstart_data.btn_lst;
-       int count;
        int ret;
+        int maxkey = 0, id;
+        unsigned int *keymap;

        quickstart_input = input_allocate_device();

@@ -386,11 +393,30 @@
        quickstart_input->id.bustype = BUS_HOST;

        while (*ptr) {
-               count++;
                set_bit(EV_KEY, quickstart_input->evbit);
                set_bit((*ptr)->id, quickstart_input->keybit);
+                if ((*ptr)->id > maxkey)
+                  maxkey = (*ptr)->id;
                ptr = &((*ptr)->next);
        }
+
+        /* build a character map that at the moment maps GHID ids to keycodes */
+        /* this map can be replaced from userspace to map the correct keycodes */
+        maxkey++;
+        quickstart_input->keycodemax = maxkey;
+        quickstart_input->keycodesize = sizeof(unsigned int);
+        quickstart_input->keycode =
kzalloc(quickstart_input->keycodemax*quickstart_input->keycodesize, GFP_KERNEL);
+        if (!quickstart_input->keycode)
+            return -ENOMEM;
+
+        keymap = quickstart_input->keycode;
+
+        ptr = &quickstart_data.btn_lst;
+        while(*ptr) {
+            id = (*ptr)->id;
+            keymap[id] = id;
+            ptr = &((*ptr)->next);
+        }

        ret = input_register_device(quickstart_input);
        if (ret) {



-- 
Dipl.-Inf. (FH) Rainer Koenig
Project Manager Linux Clients
Dept. PDG WPS R&D SW OSE

Fujitsu Technology Solutions
Bürgermeister-Ullrich-Str. 100
86199 Augsburg
Germany

Telephone: +49-821-804-3321
Telefax:   +49-821-804-2131
Mail:      mailto:Rainer.Koenig@ts.fujitsu.com

Internet         ts.fujtsu.com
Company Details  ts.fujitsu.com/imprint.html
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

                 reply	other threads:[~2012-03-19  8:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4F66EFD9.7090408@ts.fujitsu.com \
    --to=rainer.koenig@ts.fujitsu.com \
    --cc=linux-acpi@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