From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Luming Yu <luming.yu@intel.com>, Zhang Rui <rui.zhang@intel.com>,
Len Brown <len.brown@intel.com>
Subject: [PATCH 12/25] ACPI video hotkey: export ACPI video hotkey events via input layer
Date: Fri, 24 Aug 2007 03:20:59 -0400 [thread overview]
Message-ID: <11879400882727-git-send-email-len.brown@intel.com> (raw)
Message-ID: <745ce81328d09b1a5ebddacd1fffc20905d1cce3.1187939442.git.len.brown@intel.com> (raw)
In-Reply-To: <11879400872911-git-send-email-len.brown@intel.com>
In-Reply-To: <3c1d36da1d5ed36979340efd233ddaacc45b0a02.1187939442.git.len.brown@intel.com>
From: Luming Yu <luming.yu@intel.com>
Export ACPI video hotkey events via input layer.
Signed-off-by: Yu Luming <luming.yu@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
drivers/acpi/video.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 88 insertions(+), 1 deletions(-)
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 8efdea5..d727d2c 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -31,7 +31,7 @@
#include <linux/list.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
-
+#include <linux/input.h>
#include <linux/backlight.h>
#include <linux/video_output.h>
#include <asm/uaccess.h>
@@ -138,6 +138,8 @@ struct acpi_video_bus {
struct semaphore sem;
struct list_head video_device_list;
struct proc_dir_entry *dir;
+ struct input_dev *input;
+ char phys[32]; /* for input device */
};
struct acpi_video_device_flags {
@@ -1764,6 +1766,9 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_video_bus *video = data;
struct acpi_device *device = NULL;
+ struct input_dev *input;
+ int keycode;
+
printk("video bus notify\n");
@@ -1771,11 +1776,13 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
return;
device = video->device;
+ input = video->input;
switch (event) {
case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch,
* most likely via hotkey. */
acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_SWITCHVIDEOMODE;
break;
case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video
@@ -1784,21 +1791,37 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
acpi_video_device_rebind(video);
acpi_video_switch_output(video, event);
acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_SWITCHVIDEOMODE;
break;
case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
+ acpi_video_switch_output(video, event);
+ acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_SWITCHVIDEOMODE;
+ break;
case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
+ acpi_video_switch_output(video, event);
+ acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_VIDEO_NEXT;
+ break;
case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
acpi_video_switch_output(video, event);
acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_VIDEO_PREV;
break;
default:
+ keycode = KEY_UNKNOWN;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
break;
}
+ input_report_key(input, keycode, 1);
+ input_sync(input);
+ input_report_key(input, keycode, 0);
+ input_sync(input);
+
return;
}
@@ -1806,26 +1829,55 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_video_device *video_device = data;
struct acpi_device *device = NULL;
+ struct acpi_video_bus *bus;
+ struct input_dev *input;
+ int keycode;
if (!video_device)
return;
device = video_device->dev;
+ bus = video_device->video;
+ input = bus->input;
switch (event) {
case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
+ acpi_video_switch_brightness(video_device, event);
+ acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_BRIGHTNESS_CYCLE;
+ break;
case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
+ acpi_video_switch_brightness(video_device, event);
+ acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_BRIGHTNESSUP;
+ break;
case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
+ acpi_video_switch_brightness(video_device, event);
+ acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_BRIGHTNESSDOWN;
+ break;
case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
+ acpi_video_switch_brightness(video_device, event);
+ acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_BRIGHTNESS_ZERO;
+ break;
case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
acpi_video_switch_brightness(video_device, event);
acpi_bus_generate_event(device, event, 0);
+ keycode = KEY_DISPLAY_OFF;
break;
default:
+ keycode = KEY_UNKNOWN;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
break;
}
+
+ input_report_key(input, keycode, 1);
+ input_sync(input);
+ input_report_key(input, keycode, 0);
+ input_sync(input);
+
return;
}
@@ -1834,6 +1886,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
int result = 0;
acpi_status status = 0;
struct acpi_video_bus *video = NULL;
+ struct input_dev *input;
if (!device)
@@ -1877,6 +1930,39 @@ static int acpi_video_bus_add(struct acpi_device *device)
goto end;
}
+
+ video->input = input = input_allocate_device();
+
+ snprintf(video->phys, sizeof(video->phys),
+ "%s/video/input0", acpi_device_hid(video->device));
+
+ input->name = acpi_device_name(video->device);
+ input->phys = video->phys;
+ input->id.bustype = BUS_HOST;
+ input->id.product = 0x06;
+ input->evbit[0] = BIT(EV_KEY);
+ set_bit(KEY_SWITCHVIDEOMODE, input->keybit);
+ set_bit(KEY_VIDEO_NEXT, input->keybit);
+ set_bit(KEY_VIDEO_PREV, input->keybit);
+ set_bit(KEY_BRIGHTNESS_CYCLE, input->keybit);
+ set_bit(KEY_BRIGHTNESSUP, input->keybit);
+ set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
+ set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
+ set_bit(KEY_DISPLAY_OFF, input->keybit);
+ set_bit(KEY_UNKNOWN, input->keybit);
+ result = input_register_device(input);
+ if (result) {
+ acpi_remove_notify_handler(video->device->handle,
+ ACPI_DEVICE_NOTIFY,
+ acpi_video_bus_notify);
+ acpi_video_bus_stop_devices(video);
+ acpi_video_bus_put_devices(video);
+ kfree(video->attached_array);
+ acpi_video_bus_remove_fs(device);
+ goto end;
+ }
+
+
printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
video->flags.multihead ? "yes" : "no",
@@ -1910,6 +1996,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
acpi_video_bus_put_devices(video);
acpi_video_bus_remove_fs(device);
+ input_unregister_device(video->input);
kfree(video->attached_array);
kfree(video);
--
1.5.3.rc6.17.g1911
next prev parent reply other threads:[~2007-08-24 7:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-24 7:20 ACPI patches for Linux-2.6.23-rc3 Len Brown
[not found] ` <3c1d36da1d5ed36979340efd233ddaacc45b0a02.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 01/25] ACPI: thermal: clean up MODULE_PARM_DESC newlines Len Brown
[not found] ` <c52a7419af18594426bc601d1ea346dbbcf71e28.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 02/25] ACPI: thermal: create "thermal.crt=C" bootparam Len Brown
[not found] ` <5b31d895874f56174e4d885c065c9fc4b24b28bb.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 03/25] Revert "ACPI: Battery: Synchronize battery operations." Len Brown
[not found] ` <8c99fdce30787b0d1fc00b907d4cd55a714e4cdd.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 04/25] ACPI: thermal: set "thermal.nocrt" via DMI on Gigabyte GA-7ZX Len Brown
[not found] ` <61ec7567db103d537329b0db9a887db570431ff4.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 05/25] ACPI: boot correctly with "nosmp" or "maxcpus=0" Len Brown
[not found] ` <a9a4d1771cbb3c97f247534358ed24b1abf0aacb.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 06/25] Subject: "ACPI handle has no context!" should be KERN_DEBUG Len Brown
[not found] ` <14e04fb34ffa82ee61ae69f98d8fca12d2e8e31c.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 08/25] ACPI: Schedule /proc/acpi/event for removal Len Brown
[not found] ` <f63211caacf6822049f02015faf1b78ba7a7984f.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 09/25] ACPI: Fix a warning of discarding qualifiers from pointer target type Len Brown
[not found] ` <a7ecd1ea913346a72f41a002c365882dc05c9bd5.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 10/25] ACPI: video: Add keycode for ACPI video driver hotkey events Len Brown
[not found] ` <a1eb96a2f635cdb8f626f4074dae2ba5a6fce1e8.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` [PATCH 11/25] ACPI video hotkey: remove invalid events handler for video output devices Len Brown
[not found] ` <745ce81328d09b1a5ebddacd1fffc20905d1cce3.1187939442.git.len.brown@intel.com>
2007-08-24 7:20 ` Len Brown [this message]
[not found] ` <f9319f903f898dd4b15dbc386499725ce6c59776.1187939442.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 13/25] ACPI: EC: revert fix for bugzilla 8709 Len Brown
[not found] ` <f46d1604ed84e5a4107bae1db7283e3a76d72ace.1187939442.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 14/25] sony-laptop: enable Vaio FZ events Len Brown
[not found] ` <015a916fbbf105bb15f4bbfd80c3b9b2f2e0d7db.1187939442.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 15/25] sony-laptop: call sonypi_compat_init earlier Len Brown
[not found] ` <e1996a69e162b1c99c3d3802684d1c388b54f47d.1187939442.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 16/25] asus-laptop: Fix rmmod of asus_laptop Len Brown
[not found] ` <79d2dfaa4e787f94b7f65f4611bc7d1c8d85fabc.1187939442.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 17/25] ACPI: enable GPEs before calling _WAK on resume Len Brown
[not found] ` <1e0aa9ad721349781b728ec4226876247e3fd431.1187939442.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 18/25] PNP: fix up after Lindent Len Brown
[not found] ` <4cec086b219224167c22dd020d3dd2d9220e1d98.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 19/25] PNPACPI: simplify irq_flags() Len Brown
[not found] ` <4721a4cc8864f0eb92958c3e0479e7994e8b0072.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 20/25] PNPACPI: remove unnecessary casts of "void *" Len Brown
[not found] ` <6c504d30a48157b7c05a0dfb6a799c72095e957d.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 21/25] ISAPNP: removed unused isapnp_detected and ISAPNP_DEBUG Len Brown
[not found] ` <4f0217e30249ac0eb13b65ef64f2aee627465da2.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 22/25] PNP: remove MODULE infrastructure Len Brown
[not found] ` <b173491339b9ae7f1322241ce6228c1268513a39.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 23/25] PNP: remove null pointer checks Len Brown
[not found] ` <29bb7fd39d8976d9d510a9ab79f8942fdcd2b2ea.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 24/25] make drivers/acpi/scan.c:create_modalias() static Len Brown
[not found] ` <3e069ee0c30d6f28b79e409ef2df1ffa427897ae.1187939443.git.len.brown@intel.com>
2007-08-24 7:21 ` [PATCH 25/25] ACPI: fix ia64 allnoconfig build Len Brown
2007-08-24 8:07 ` ACPI patches for Linux-2.6.23-rc3 Zhang Rui
2007-08-24 23:37 ` Len Brown
2007-08-25 5:26 ` Zhang Rui
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=11879400882727-git-send-email-len.brown@intel.com \
--to=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=luming.yu@intel.com \
--cc=rui.zhang@intel.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 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).