Lines Matching +full:tablet +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0+
6 * Author: Wei-Ning Huang <wnhuang@google.com>
18 #include <linux/input/vivaldi-fmap.h>
28 #include "hid-ids.h"
29 #include "hid-vivaldi-common.h"
32 * C(hrome)B(ase)A(ttached)S(witch) - switch exported by Chrome EC and reporting
33 * state of the "Whiskers" base - attached or detached. Whiskers USB device also
34 * reports position of the keyboard - folded or not. Combining base state and
35 * position allows us to generate proper "Tablet mode" events.
66 return -ENOMEM; in cbas_ec_query_base()
68 msg->command = EC_CMD_MKBP_INFO; in cbas_ec_query_base()
69 msg->version = 1; in cbas_ec_query_base()
70 msg->outsize = sizeof(*params); in cbas_ec_query_base()
71 msg->insize = sizeof(u32); in cbas_ec_query_base()
72 params = (struct ec_params_mkbp_info *)msg->data; in cbas_ec_query_base()
73 params->info_type = get_state ? in cbas_ec_query_base()
75 params->event_type = EC_MKBP_EVENT_SWITCH; in cbas_ec_query_base()
80 dev_warn(ec_dev->dev, "wrong result size: %d != %zu\n", in cbas_ec_query_base()
82 ret = -EPROTO; in cbas_ec_query_base()
84 *state = cbas_parse_base_state(msg->data); in cbas_ec_query_base()
102 if (ec->event_data.event_type == EC_MKBP_EVENT_SWITCH) { in cbas_ec_notify()
104 &ec->event_data.data.switches); in cbas_ec_notify()
139 struct cros_ec_device *ec = dev_get_drvdata(dev->parent); in cbas_ec_resume()
180 struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); in __cbas_ec_probe()
190 return -ENXIO; in __cbas_ec_probe()
192 input = devm_input_allocate_device(&pdev->dev); in __cbas_ec_probe()
194 return -ENOMEM; in __cbas_ec_probe()
196 input->name = "Whiskers Tablet Mode Switch"; in __cbas_ec_probe()
197 input->id.bustype = BUS_HOST; in __cbas_ec_probe()
203 dev_err(&pdev->dev, "cannot register input device: %d\n", in __cbas_ec_probe()
211 dev_err(&pdev->dev, "cannot query base state: %d\n", error); in __cbas_ec_probe()
218 dev_dbg(&pdev->dev, "%s: base: %d, folded: %d\n", __func__, in __cbas_ec_probe()
226 cbas_ec.dev = &pdev->dev; in __cbas_ec_probe()
228 error = blocking_notifier_chain_register(&ec->event_notifier, in __cbas_ec_probe()
231 dev_err(&pdev->dev, "cannot register notifier: %d\n", error); in __cbas_ec_probe()
236 device_init_wakeup(&pdev->dev, true); in __cbas_ec_probe()
247 retval = -EBUSY; in cbas_ec_probe()
260 struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); in cbas_ec_remove()
264 blocking_notifier_chain_unregister(&ec->event_notifier, in cbas_ec_remove()
280 { .compatible = "google,cros-cbas" },
313 led->buf[0] = 0; in hammer_kbd_brightness_set_blocking()
314 led->buf[1] = br; in hammer_kbd_brightness_set_blocking()
317 * Request USB HID device to be in Full On mode, so that sending in hammer_kbd_brightness_set_blocking()
320 ret = hid_hw_power(led->hdev, PM_HINT_FULLON); in hammer_kbd_brightness_set_blocking()
322 hid_err(led->hdev, "failed: device not resumed %d\n", ret); in hammer_kbd_brightness_set_blocking()
326 ret = hid_hw_output_report(led->hdev, led->buf, sizeof(led->buf)); in hammer_kbd_brightness_set_blocking()
327 if (ret == -ENOSYS) in hammer_kbd_brightness_set_blocking()
328 ret = hid_hw_raw_request(led->hdev, 0, led->buf, in hammer_kbd_brightness_set_blocking()
329 sizeof(led->buf), in hammer_kbd_brightness_set_blocking()
333 hid_err(led->hdev, "failed to set keyboard backlight: %d\n", in hammer_kbd_brightness_set_blocking()
336 /* Request USB HID device back to Normal Mode. */ in hammer_kbd_brightness_set_blocking()
337 hid_hw_power(led->hdev, PM_HINT_NORMAL); in hammer_kbd_brightness_set_blocking()
346 kbd_backlight = devm_kzalloc(&hdev->dev, sizeof(*kbd_backlight), in hammer_register_leds()
349 return -ENOMEM; in hammer_register_leds()
351 kbd_backlight->hdev = hdev; in hammer_register_leds()
352 kbd_backlight->cdev.name = "hammer::kbd_backlight"; in hammer_register_leds()
353 kbd_backlight->cdev.max_brightness = MAX_BRIGHTNESS; in hammer_register_leds()
354 kbd_backlight->cdev.brightness_set_blocking = in hammer_register_leds()
356 kbd_backlight->cdev.flags = LED_HW_PLUGGABLE; in hammer_register_leds()
359 hammer_kbd_brightness_set_blocking(&kbd_backlight->cdev, 0); in hammer_register_leds()
361 return devm_led_classdev_register(&hdev->dev, &kbd_backlight->cdev); in hammer_register_leds()
376 if (usage->hid == HID_USAGE_KBD_FOLDED) { in hammer_input_mapping()
380 * separate input device for tablet switch mode. in hammer_input_mapping()
382 return -1; in hammer_input_mapping()
414 if (usage->hid == HID_USAGE_KBD_FOLDED) { in hammer_event()
425 struct hid_report_enum *re = &hdev->report_enum[report_type]; in hammer_has_usage()
429 list_for_each_entry(report, &re->report_list, list) { in hammer_has_usage()
430 if (report->application != application) in hammer_has_usage()
433 for (i = 0; i < report->maxfield; i++) { in hammer_has_usage()
434 struct hid_field *field = report->field[i]; in hammer_has_usage()
436 for (j = 0; j < field->maxusage; j++) in hammer_has_usage()
437 if (field->usage[j].hid == usage) in hammer_has_usage()
464 report = hdev->report_enum[HID_INPUT_REPORT].report_id_hash[0x0]; in hammer_get_folded_state()
466 if (!report || report->maxfield < 1) in hammer_get_folded_state()
475 rlen = hid_hw_raw_request(hdev, report->id, buf, len, report->type, HID_REQ_GET_REPORT); in hammer_get_folded_state()
482 for (a = 0; a < report->maxfield; a++) { in hammer_get_folded_state()
483 struct hid_field *field = report->field[a]; in hammer_get_folded_state()
485 if (field->usage->hid == HID_USAGE_KBD_FOLDED) { in hammer_get_folded_state()
487 field->report_offset, field->report_size); in hammer_get_folded_state()
509 vdata = devm_kzalloc(&hdev->dev, sizeof(*vdata), GFP_KERNEL); in hammer_probe()
511 return -ENOMEM; in hammer_probe()
523 error = devm_add_action(&hdev->dev, hammer_stop, hdev); in hammer_probe()
528 * We always want to poll for, and handle tablet mode events from in hammer_probe()
530 * device. This also prevents the hid core from dropping early tablet in hammer_probe()
531 * mode events from the device. in hammer_probe()
534 hdev->quirks |= HID_QUIRK_ALWAYS_POLL; in hammer_probe()
563 * keyboard we should not stay in clamshell mode. in hammer_remove()
568 * resulting in devices being stuck in clamshell mode. in hammer_remove()