From: Len Brown <lenb@kernel.org>
To: Zhang Rui <rui.zhang@intel.com>, linux-input@atrey.karlin.mff.cuni.cz
Cc: linux-acpi@vger.kernel.org, mjg59@srcf.ucam.org,
dmitry.torokhov@gmail.com, hmh@hmh.eng.hr, hughsient@gmail.com,
luming.yu@intel.com
Subject: Re: [RFC] [PATCH V2 3/3] ACPI video hotkey: export ACPI video hotkey events via input layer
Date: Wed, 15 Aug 2007 23:16:31 -0400 [thread overview]
Message-ID: <200708152316.31965.lenb@kernel.org> (raw)
In-Reply-To: <1186780051.6830.60.camel@rzhang-asus.sh.intel.com>
On Friday 10 August 2007 17:07, Zhang Rui wrote:
> From: Yu Luming <luming.yu@intel.com>
>
> Export ACPI video hotkey events via input layer.
>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
> drivers/acpi/video.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 86 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.23-rc2/drivers/acpi/video.c
> ===================================================================
> --- linux-2.6.23-rc2.orig/drivers/acpi/video.c
> +++ linux-2.6.23-rc2/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_h
> {
> struct acpi_video_bus *video = data;
> struct acpi_device *device = NULL;
> + struct input_dev *input;
> + int keycode;
> +
>
> printk("video bus notify\n");
please delete this printk
> @@ -1771,11 +1776,13 @@ static void acpi_video_bus_notify(acpi_h
> 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_h
> 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_UNKNOWN;
how about KEY_VIDEO_CYCLE_MODE?
> + 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(acp
> {
> 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_UNKNOWN;
How about 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_BRIGHTNESS_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 acp
> int result = 0;
> acpi_status status = 0;
> struct acpi_video_bus *video = NULL;
> + struct input_dev *input;
>
>
> if (!device)
> @@ -1877,6 +1930,37 @@ static int acpi_video_bus_add(struct acp
> 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_BRIGHTNESSUP, input->keybit);
> + set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
> + set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
> + set_bit(KEY_BRIGHTNESS_OFF, 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 +1994,7 @@ static int acpi_video_bus_remove(struct
> acpi_video_bus_put_devices(video);
> acpi_video_bus_remove_fs(device);
>
> + input_unregister_device(video->input);
> kfree(video->attached_array);
> kfree(video);
>
> -
> 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
>
prev parent reply other threads:[~2007-08-16 3:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-10 21:07 [RFC] [PATCH V2 3/3] ACPI video hotkey: export ACPI video hotkey events via input layer Zhang Rui
2007-08-16 3:16 ` Len Brown [this message]
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=200708152316.31965.lenb@kernel.org \
--to=lenb@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=hmh@hmh.eng.hr \
--cc=hughsient@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-input@atrey.karlin.mff.cuni.cz \
--cc=luming.yu@intel.com \
--cc=mjg59@srcf.ucam.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.