Lines Matching +full:key +full:- +full:release

1 // SPDX-License-Identifier: GPL-2.0+
12 #include <linux/input/sparse-keymap.h>
38 { KE_KEY, 0xC0, { KEY_POWER } }, /* power key press */
39 { KE_IGNORE, 0xC1, { KEY_POWER } }, /* power key release */
40 { KE_KEY, 0xC2, { KEY_LEFTMETA } }, /* 'Windows' key press */
41 { KE_KEY, 0xC3, { KEY_LEFTMETA } }, /* 'Windows' key release */
42 { KE_KEY, 0xC4, { KEY_VOLUMEUP } }, /* volume-up key press */
43 { KE_IGNORE, 0xC5, { KEY_VOLUMEUP } }, /* volume-up key release */
44 { KE_KEY, 0xC6, { KEY_VOLUMEDOWN } }, /* volume-down key press */
45 { KE_IGNORE, 0xC7, { KEY_VOLUMEDOWN } }, /* volume-down key release */
46 { KE_KEY, 0xC8, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key press */
47 { KE_KEY, 0xC9, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key release */
54 * intel-vbtn code, always seem to use this for 2-in-1s / convertibles and set
55 * SW_DOCK=1 when in laptop-mode (in tandem with setting SW_TABLET_MODE=0).
56 * This causes userspace to think the laptop is docked to a port-replicator
57 * and to disable suspend-on-lid-close, which is undesirable.
78 struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); in detect_tablet_mode()
79 acpi_handle handle = ACPI_HANDLE(&device->dev); in detect_tablet_mode()
89 input_report_switch(priv->switches_dev, SW_TABLET_MODE, m); in detect_tablet_mode()
91 input_report_switch(priv->switches_dev, SW_DOCK, m); in detect_tablet_mode()
95 * Note this unconditionally creates the 2 input_dev-s and sets up
96 * the sparse-keymaps. Only the registration is conditional on
99 * on the input_dev-s do determine the event type.
103 struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); in intel_vbtn_input_setup()
106 priv->buttons_dev = devm_input_allocate_device(&device->dev); in intel_vbtn_input_setup()
107 if (!priv->buttons_dev) in intel_vbtn_input_setup()
108 return -ENOMEM; in intel_vbtn_input_setup()
110 ret = sparse_keymap_setup(priv->buttons_dev, intel_vbtn_keymap, NULL); in intel_vbtn_input_setup()
114 priv->buttons_dev->dev.parent = &device->dev; in intel_vbtn_input_setup()
115 priv->buttons_dev->name = "Intel Virtual Buttons"; in intel_vbtn_input_setup()
116 priv->buttons_dev->id.bustype = BUS_HOST; in intel_vbtn_input_setup()
118 if (priv->has_buttons) { in intel_vbtn_input_setup()
119 ret = input_register_device(priv->buttons_dev); in intel_vbtn_input_setup()
124 priv->switches_dev = devm_input_allocate_device(&device->dev); in intel_vbtn_input_setup()
125 if (!priv->switches_dev) in intel_vbtn_input_setup()
126 return -ENOMEM; in intel_vbtn_input_setup()
128 ret = sparse_keymap_setup(priv->switches_dev, intel_vbtn_switchmap, NULL); in intel_vbtn_input_setup()
132 priv->switches_dev->dev.parent = &device->dev; in intel_vbtn_input_setup()
133 priv->switches_dev->name = "Intel Virtual Switches"; in intel_vbtn_input_setup()
134 priv->switches_dev->id.bustype = BUS_HOST; in intel_vbtn_input_setup()
136 if (priv->has_switches) { in intel_vbtn_input_setup()
139 ret = input_register_device(priv->switches_dev); in intel_vbtn_input_setup()
150 struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); in notify_handler()
151 unsigned int val = !(event & 1); /* Even=press, Odd=release */ in notify_handler()
157 if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) { in notify_handler()
158 if (!priv->has_buttons) { in notify_handler()
159 …dev_warn(&device->dev, "Warning: received a button event on a device without buttons, please repor… in notify_handler()
162 input_dev = priv->buttons_dev; in notify_handler()
163 } else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) { in notify_handler()
164 if (!priv->has_switches) { in notify_handler()
166 if (priv->dual_accel) in notify_handler()
169 …dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch even… in notify_handler()
170 ret = input_register_device(priv->switches_dev); in notify_handler()
174 priv->has_switches = true; in notify_handler()
176 input_dev = priv->switches_dev; in notify_handler()
178 dev_dbg(&device->dev, "unknown event index 0x%x\n", event); in notify_handler()
182 if (priv->wakeup_mode) { in notify_handler()
183 pm_wakeup_hard_event(&device->dev); in notify_handler()
189 if (ke->type == KE_KEY) in notify_handler()
195 * release event, or if the odd event is KE_IGNORE. in notify_handler()
198 autorelease = val && (!ke_rel || ke_rel->type == KE_IGNORE); in notify_handler()
204 * There are several laptops (non 2-in-1) models out there which support VGBS,
210 * with libinput, leads to a non-usable system. Where as OTOH many people will
212 * list is used here. This list mainly matches on the chassis-type of 2-in-1s.
214 * There are also some 2-in-1s which use the intel-vbtn ACPI interface to report
215 * SW_TABLET_MODE with a chassis-type of 8 ("Portable") or 10 ("Notebook"),
217 * possible broken VGBS ACPI-method also use these chassis-types.
238 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
245 DMI_MATCH(DMI_PRODUCT_NAME, "Switch SA5-271"),
275 acpi_handle handle = ACPI_HANDLE(&device->dev); in intel_vbtn_probe()
286 dev_warn(&device->dev, "failed to read Intel Virtual Button driver\n"); in intel_vbtn_probe()
287 return -ENODEV; in intel_vbtn_probe()
290 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); in intel_vbtn_probe()
292 return -ENOMEM; in intel_vbtn_probe()
293 dev_set_drvdata(&device->dev, priv); in intel_vbtn_probe()
295 priv->dual_accel = dual_accel; in intel_vbtn_probe()
296 priv->has_buttons = has_buttons; in intel_vbtn_probe()
297 priv->has_switches = has_switches; in intel_vbtn_probe()
310 return -EBUSY; in intel_vbtn_probe()
315 dev_err(&device->dev, "Error VBDL failed with ACPI status %d\n", status); in intel_vbtn_probe()
318 device_init_wakeup(&device->dev, true); in intel_vbtn_probe()
330 acpi_handle handle = ACPI_HANDLE(&device->dev); in intel_vbtn_remove()
332 device_init_wakeup(&device->dev, false); in intel_vbtn_remove()
341 priv->wakeup_mode = true; in intel_vbtn_pm_prepare()
350 priv->wakeup_mode = false; in intel_vbtn_pm_complete()
369 .name = "intel-vbtn",
385 dev_info(&dev->dev, in check_acpi_dev()
386 "intel-vbtn: created platform device\n"); in check_acpi_dev()