Lines Matching +full:tablet +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0+
13 #include <linux/input/sparse-keymap.h>
21 /* Returned when NOT in tablet mode on some HP Stream x360 11 models */
23 /* When NOT in tablet mode, VGBS returns with the flag 0x40 */
45 { KE_KEY, 0xC4, { KEY_VOLUMEUP } }, /* volume-up key press */
46 { KE_IGNORE, 0xC5, { KEY_VOLUMEUP } }, /* volume-up key release */
47 { KE_KEY, 0xC6, { KEY_VOLUMEDOWN } }, /* volume-down key press */
48 { KE_IGNORE, 0xC7, { KEY_VOLUMEDOWN } }, /* volume-down key release */
49 { KE_KEY, 0xC8, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key press */
50 { KE_KEY, 0xC9, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key release */
57 * intel-vbtn code, always seem to use this for 2-in-1s / convertibles and set
58 * SW_DOCK=1 when in laptop-mode (in tandem with setting SW_TABLET_MODE=0).
59 * This causes userspace to think the laptop is docked to a port-replicator
60 * and to disable suspend-on-lid-close, which is undesirable.
65 { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Tablet */
93 input_report_switch(priv->switches_dev, SW_TABLET_MODE, m); in detect_tablet_mode()
95 input_report_switch(priv->switches_dev, SW_DOCK, m); in detect_tablet_mode()
97 input_sync(priv->switches_dev); in detect_tablet_mode()
101 * Note this unconditionally creates the 2 input_dev-s and sets up
102 * the sparse-keymaps. Only the registration is conditional on
105 * on the input_dev-s do determine the event type.
109 struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); in intel_vbtn_input_setup()
112 priv->buttons_dev = devm_input_allocate_device(&device->dev); in intel_vbtn_input_setup()
113 if (!priv->buttons_dev) in intel_vbtn_input_setup()
114 return -ENOMEM; in intel_vbtn_input_setup()
116 ret = sparse_keymap_setup(priv->buttons_dev, intel_vbtn_keymap, NULL); in intel_vbtn_input_setup()
120 priv->buttons_dev->dev.parent = &device->dev; in intel_vbtn_input_setup()
121 priv->buttons_dev->name = "Intel Virtual Buttons"; in intel_vbtn_input_setup()
122 priv->buttons_dev->id.bustype = BUS_HOST; in intel_vbtn_input_setup()
124 if (priv->has_buttons) { in intel_vbtn_input_setup()
125 ret = input_register_device(priv->buttons_dev); in intel_vbtn_input_setup()
130 priv->switches_dev = devm_input_allocate_device(&device->dev); in intel_vbtn_input_setup()
131 if (!priv->switches_dev) in intel_vbtn_input_setup()
132 return -ENOMEM; in intel_vbtn_input_setup()
134 ret = sparse_keymap_setup(priv->switches_dev, intel_vbtn_switchmap, NULL); in intel_vbtn_input_setup()
138 priv->switches_dev->dev.parent = &device->dev; in intel_vbtn_input_setup()
139 priv->switches_dev->name = "Intel Virtual Switches"; in intel_vbtn_input_setup()
140 priv->switches_dev->id.bustype = BUS_HOST; in intel_vbtn_input_setup()
142 if (priv->has_switches) { in intel_vbtn_input_setup()
143 ret = input_register_device(priv->switches_dev); in intel_vbtn_input_setup()
154 struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); in notify_handler()
161 guard(mutex)(&priv->mutex); in notify_handler()
163 if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) { in notify_handler()
164 if (!priv->has_buttons) { in notify_handler()
165 …dev_warn(&device->dev, "Warning: received 0x%02x button event on a device without buttons, please … in notify_handler()
169 input_dev = priv->buttons_dev; in notify_handler()
170 } else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) { in notify_handler()
171 if (!priv->has_switches) { in notify_handler()
173 if (priv->dual_accel) in notify_handler()
176 …dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch even… in notify_handler()
177 ret = input_register_device(priv->switches_dev); in notify_handler()
181 priv->has_switches = true; in notify_handler()
183 input_dev = priv->switches_dev; in notify_handler()
185 dev_dbg(&device->dev, "unknown event index 0x%x\n", event); in notify_handler()
189 if (priv->wakeup_mode) { in notify_handler()
190 pm_wakeup_hard_event(&device->dev); in notify_handler()
196 if (ke->type == KE_KEY) in notify_handler()
205 autorelease = val && (!ke_rel || ke_rel->type == KE_IGNORE); in notify_handler()
211 * There are several laptops (non 2-in-1) models out there which support VGBS,
217 * with libinput, leads to a non-usable system. Where as OTOH many people will
219 * list is used here. This list mainly matches on the chassis-type of 2-in-1s.
221 * There are also some 2-in-1s which use the intel-vbtn ACPI interface to report
222 * SW_TABLET_MODE with a chassis-type of 8 ("Portable") or 10 ("Notebook"),
224 * possible broken VGBS ACPI-method also use these chassis-types.
245 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
252 DMI_MATCH(DMI_PRODUCT_NAME, "Switch SA5-271"),
278 acpi_handle handle = ACPI_HANDLE(&device->dev); in intel_vbtn_probe()
289 dev_warn(&device->dev, "failed to read Intel Virtual Button driver\n"); in intel_vbtn_probe()
290 return -ENODEV; in intel_vbtn_probe()
293 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); in intel_vbtn_probe()
295 return -ENOMEM; in intel_vbtn_probe()
296 dev_set_drvdata(&device->dev, priv); in intel_vbtn_probe()
298 err = devm_mutex_init(&device->dev, &priv->mutex); in intel_vbtn_probe()
302 priv->dual_accel = dual_accel; in intel_vbtn_probe()
303 priv->has_buttons = has_buttons; in intel_vbtn_probe()
304 priv->has_switches = has_switches; in intel_vbtn_probe()
317 return -EBUSY; in intel_vbtn_probe()
322 dev_err(&device->dev, "Error VBDL failed with ACPI status %d\n", status); in intel_vbtn_probe()
326 detect_tablet_mode(&device->dev); in intel_vbtn_probe()
328 device_init_wakeup(&device->dev, true); in intel_vbtn_probe()
340 acpi_handle handle = ACPI_HANDLE(&device->dev); in intel_vbtn_remove()
342 device_init_wakeup(&device->dev, false); in intel_vbtn_remove()
351 priv->wakeup_mode = true; in intel_vbtn_pm_prepare()
360 priv->wakeup_mode = false; in intel_vbtn_pm_complete()
369 if (priv->has_switches) in intel_vbtn_pm_resume()
385 .name = "intel-vbtn",
401 dev_info(&dev->dev, in check_acpi_dev()
402 "intel-vbtn: created platform device\n"); in check_acpi_dev()