Skip to contentSkip to conversation

ACPI video: Add video_switch_key option

PATCH In review Takashi Iwai 2 participants 11 messages Oct 27, 2010 – Nov 24, 2010 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI video: Add video_switch_key option

Some HP laptops send ACPI video events per lid open/close, and the ACPI video driver translates to SWITCHVIDEOMODE input key events. This behavior confuses the user-space daemon such as gnome-settings-daemon since it changes the video mode per this key, which results in a different video mode at each time you open/close the laptop lid. Fn-Fx keys are handled differently on such hardware, thus this key generation is simply superfluous.

This patch adds a module parameter "video_switch_key" to either assign a different key code for this ACPI event or disable by setting zero there.

---
 drivers/acpi/video.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/acpi/video.c +7 -4
index 5cd0228..a61162f 100644
@@ -80,6 +80,8 @@ module_param(brightness_switch_enabled, bool, 0644);
  */
 static int allow_duplicates;
 module_param(allow_duplicates, bool, 0644);
+static int video_switch_key = KEY_SWITCHVIDEOMODE;
+module_param(video_switch_key, int, 0644);
 
 static int register_count = 0;
 static int acpi_video_bus_add(struct acpi_device *device);
@@ -1511,7 +1513,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
 	case ACPI_VIDEO_NOTIFY_SWITCH:	/* User requested a switch,
 					 * most likely via hotkey. */
 		acpi_bus_generate_proc_event(device, event, 0);
-		keycode = KEY_SWITCHVIDEOMODE;
+		keycode = video_switch_key;
 		break;
 
 	case ACPI_VIDEO_NOTIFY_PROBE:	/* User plugged in or removed a video
@@ -1519,12 +1521,12 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
 		acpi_video_device_enumerate(video);
 		acpi_video_device_rebind(video);
 		acpi_bus_generate_proc_event(device, event, 0);
-		keycode = KEY_SWITCHVIDEOMODE;
+		keycode = video_switch_key;
 		break;
 
 	case ACPI_VIDEO_NOTIFY_CYCLE:	/* Cycle Display output hotkey pressed. */
 		acpi_bus_generate_proc_event(device, event, 0);
-		keycode = KEY_SWITCHVIDEOMODE;
+		keycode = video_switch_key;
 		break;
 	case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:	/* Next Display output hotkey pressed. */
 		acpi_bus_generate_proc_event(device, event, 0);
@@ -1736,7 +1738,8 @@ static int acpi_video_bus_add(struct acpi_device *device)
 	input->id.product = 0x06;
 	input->dev.parent = &device->dev;
 	input->evbit[0] = BIT(EV_KEY);
-	set_bit(KEY_SWITCHVIDEOMODE, input->keybit);
+	if (video_switch_key && video_switch_key < KEY_CNT)
+		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);
Signature · 1 line
1.7.3.1
#1 lore raw

Hi,

At Wed, 27 Oct 2010 12:39:17 +0200,

Quoted 9 lines · Takashi Iwai

Some HP laptops send ACPI video events per lid open/close, and the ACPI video driver translates to SWITCHVIDEOMODE input key events. This behavior confuses the user-space daemon such as gnome-settings-daemon since it changes the video mode per this key, which results in a different video mode at each time you open/close the laptop lid. Fn-Fx keys are handled differently on such hardware, thus this key generation is simply superfluous.

Quoted 5 lines

This patch adds a module parameter "video_switch_key" to either assign a different key code for this ACPI event or disable by setting zero there.

Any comments on this patch?

thanks,

Takashi

Quoted 54 lines
---
 drivers/acpi/video.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/acpi/video.c +7 -4
index 5cd0228..a61162f 100644
@@ -80,6 +80,8 @@ module_param(brightness_switch_enabled, bool, 0644);
  */
 static int allow_duplicates;
 module_param(allow_duplicates, bool, 0644);
+static int video_switch_key = KEY_SWITCHVIDEOMODE;
+module_param(video_switch_key, int, 0644);
 
 static int register_count = 0;
 static int acpi_video_bus_add(struct acpi_device *device);
@@ -1511,7 +1513,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
 	case ACPI_VIDEO_NOTIFY_SWITCH:	/* User requested a switch,
 					 * most likely via hotkey. */
 		acpi_bus_generate_proc_event(device, event, 0);
-		keycode = KEY_SWITCHVIDEOMODE;
+		keycode = video_switch_key;
 		break;
 
 	case ACPI_VIDEO_NOTIFY_PROBE:	/* User plugged in or removed a video
@@ -1519,12 +1521,12 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
 		acpi_video_device_enumerate(video);
 		acpi_video_device_rebind(video);
 		acpi_bus_generate_proc_event(device, event, 0);
-		keycode = KEY_SWITCHVIDEOMODE;
+		keycode = video_switch_key;
 		break;
 
 	case ACPI_VIDEO_NOTIFY_CYCLE:	/* Cycle Display output hotkey pressed. */
 		acpi_bus_generate_proc_event(device, event, 0);
-		keycode = KEY_SWITCHVIDEOMODE;
+		keycode = video_switch_key;
 		break;
 	case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:	/* Next Display output hotkey pressed. */
 		acpi_bus_generate_proc_event(device, event, 0);
@@ -1736,7 +1738,8 @@ static int acpi_video_bus_add(struct acpi_device *device)
 	input->id.product = 0x06;
 	input->dev.parent = &device->dev;
 	input->evbit[0] = BIT(EV_KEY);
-	set_bit(KEY_SWITCHVIDEOMODE, input->keybit);
+	if (video_switch_key && video_switch_key < KEY_CNT)
+		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);
Signature · 1 line
1.7.3.1
#2 lore raw
Quoted 12 lines · Takashi Iwai

Hi,

At Wed, 27 Oct 2010 12:39:17 +0200,

Quoted 8 lines · Takashi Iwai

Some HP laptops send ACPI video events per lid open/close, and the ACPI video driver translates to SWITCHVIDEOMODE input key events. This behavior confuses the user-space daemon such as gnome-settings-daemon since it changes the video mode per this key, which results in a different video mode at each time you open/close the laptop lid. Fn-Fx keys are handled differently on such hardware, thus this key generation is simply superfluous.

Quoted 7 lines
Quoted 5 lines

This patch adds a module parameter "video_switch_key" to either assign a different key code for this ACPI event or disable by setting zero there.

Any comments on this patch?

I'm not entirely clear on why this is wanted. Lid state changes seem to be a reasonable proxy for "Reprobe outputs" - what's userspace actually doing that causes problems?

Signature · 1 line
Matthew Garrett | [email protected]
#3 lore raw

At Wed, 24 Nov 2010 14:26:18 +0000,

Quoted 18 lines · Matthew Garrett
Quoted 16 lines · Takashi Iwai

Hi,

At Wed, 27 Oct 2010 12:39:17 +0200,

Quoted 12 lines · Takashi Iwai

Some HP laptops send ACPI video events per lid open/close, and the ACPI video driver translates to SWITCHVIDEOMODE input key events. This behavior confuses the user-space daemon such as gnome-settings-daemon since it changes the video mode per this key, which results in a different video mode at each time you open/close the laptop lid. Fn-Fx keys are handled differently on such hardware, thus this key generation is simply superfluous.

This patch adds a module parameter "video_switch_key" to either assign a different key code for this ACPI event or disable by setting zero there.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any comments on this patch?

I'm not entirely clear on why this is wanted. Lid state changes seem to be a reasonable proxy for "Reprobe outputs" - what's userspace actually doing that causes problems?

Typically GNOME changes to the next monitor mode (e.g. xinearama, clone, laptop-only, external-only) by each XF86VideoSwitch key event. If you connect your laptop to a monitor, and sets to clone mode, close the lid, and reopen. Then you'll find the video mode is now external-monitor only. It's because two XF86VideoSwitch key events are issued during close/open the lid.

thanks,

Takashi

#4 lore raw
Quoted 6 lines · Takashi Iwai

Typically GNOME changes to the next monitor mode (e.g. xinearama, clone, laptop-only, external-only) by each XF86VideoSwitch key event. If you connect your laptop to a monitor, and sets to clone mode, close the lid, and reopen. Then you'll find the video mode is now external-monitor only. It's because two XF86VideoSwitch key events are issued during close/open the lid.

That's not what that keystroke is expected to do. Userspace needs to either interpret it as "Reprobe devices" or pay attention to the configuration that the firmware requested.

Signature · 1 line
Matthew Garrett | [email protected]
#5 lore raw

At Wed, 24 Nov 2010 14:35:17 +0000,

Quoted 10 lines · Matthew Garrett
Quoted 6 lines · Takashi Iwai

Typically GNOME changes to the next monitor mode (e.g. xinearama, clone, laptop-only, external-only) by each XF86VideoSwitch key event. If you connect your laptop to a monitor, and sets to clone mode, close the lid, and reopen. Then you'll find the video mode is now external-monitor only. It's because two XF86VideoSwitch key events are issued during close/open the lid.

Quoted 3 lines

That's not what that keystroke is expected to do. Userspace needs to either interpret it as "Reprobe devices" or pay attention to the configuration that the firmware requested.

Unfortunately, this is the standard behavior on most desktops :-< Fn-F4 (or whatever) media key produces this exact key code, and the desktops (including Windows) expect this behavior.

thanks,

Takashi

#6 lore raw
Quoted 3 lines · Takashi Iwai

Unfortunately, this is the standard behavior on most desktops :-< Fn-F4 (or whatever) media key produces this exact key code, and the desktops (including Windows) expect this behavior.

Hm. Ok, let's make sure that we're doing this right. There's several different notifications which can generate the same keycode (ACPI_VIDEO_NOTIFY_SWITCH, ACPI_VIDEO_NOTIFY_PROBE and ACPI_VIDEO_NOTIFY_CYCLE) - which of them's actually being triggered here?

Signature · 1 line
Matthew Garrett | [email protected]
#7 lore raw

At Wed, 24 Nov 2010 14:42:39 +0000,

Quoted 7 lines · Matthew Garrett
Quoted 3 lines · Takashi Iwai

Unfortunately, this is the standard behavior on most desktops :-< Fn-F4 (or whatever) media key produces this exact key code, and the desktops (including Windows) expect this behavior.

Quoted 5 lines

Hm. Ok, let's make sure that we're doing this right. There's several different notifications which can generate the same keycode (ACPI_VIDEO_NOTIFY_SWITCH, ACPI_VIDEO_NOTIFY_PROBE and ACPI_VIDEO_NOTIFY_CYCLE) - which of them's actually being triggered here?

It's ACPI_VIDEO_NOTIFY_SWITCH.

But, note that I'm checking only HP laptops. There might be other laptops behaving in a different manner.

thanks,

Takashi

#9 lore raw

At Wed, 24 Nov 2010 14:54:08 +0000,

Quoted 2 lines · Matthew Garrett

Ok. Can you give me an example of a model with this behaviour?

HP ProBook 6xxx, HP ProBook 4xxx, HP EliteBook, HP Compaq 65xx, HP Compaq 67xx, and lots of other HP laptops sold in this year. (I have access to two dozen of machines here, but unfortunately official names are not always known.)

thanks,

Takashi

#10 lore raw
Quoted 9 lines · Takashi Iwai

At Wed, 24 Nov 2010 14:54:08 +0000,

Quoted 2 lines · Matthew Garrett

Ok. Can you give me an example of a model with this behaviour?

HP ProBook 6xxx, HP ProBook 4xxx, HP EliteBook, HP Compaq 65xx, HP Compaq 67xx, and lots of other HP laptops sold in this year. (I have access to two dozen of machines here, but unfortunately official names are not always known.)

Can you check what _DOS is set to? I'm having a little trouble reproducing this here on an HP 2530p.

Signature · 1 line
Matthew Garrett | [email protected]