• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0+
6 * Author: Wei-Ning Huang <wnhuang@google.com>
26 #include "hid-ids.h"
29 * C(hrome)B(ase)A(ttached)S(witch) - switch exported by Chrome EC and reporting
30 * state of the "Whiskers" base - attached or detached. Whiskers USB device also
31 * reports position of the keyboard - folded or not. Combining base state and
32 * position allows us to generate proper "Tablet mode" events.
63 return -ENOMEM; in cbas_ec_query_base()
65 msg->command = EC_CMD_MKBP_INFO; in cbas_ec_query_base()
66 msg->version = 1; in cbas_ec_query_base()
67 msg->outsize = sizeof(*params); in cbas_ec_query_base()
68 msg->insize = sizeof(u32); in cbas_ec_query_base()
69 params = (struct ec_params_mkbp_info *)msg->data; in cbas_ec_query_base()
70 params->info_type = get_state ? in cbas_ec_query_base()
72 params->event_type = EC_MKBP_EVENT_SWITCH; in cbas_ec_query_base()
77 dev_warn(ec_dev->dev, "wrong result size: %d != %zu\n", in cbas_ec_query_base()
79 ret = -EPROTO; in cbas_ec_query_base()
81 *state = cbas_parse_base_state(msg->data); in cbas_ec_query_base()
99 if (ec->event_data.event_type == EC_MKBP_EVENT_SWITCH) { in cbas_ec_notify()
101 &ec->event_data.data.switches); in cbas_ec_notify()
136 struct cros_ec_device *ec = dev_get_drvdata(dev->parent); in cbas_ec_resume()
177 struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); in __cbas_ec_probe()
187 return -ENXIO; in __cbas_ec_probe()
189 input = devm_input_allocate_device(&pdev->dev); in __cbas_ec_probe()
191 return -ENOMEM; in __cbas_ec_probe()
193 input->name = "Whiskers Tablet Mode Switch"; in __cbas_ec_probe()
194 input->id.bustype = BUS_HOST; in __cbas_ec_probe()
200 dev_err(&pdev->dev, "cannot register input device: %d\n", in __cbas_ec_probe()
208 dev_err(&pdev->dev, "cannot query base state: %d\n", error); in __cbas_ec_probe()
215 dev_dbg(&pdev->dev, "%s: base: %d, folded: %d\n", __func__, in __cbas_ec_probe()
223 cbas_ec.dev = &pdev->dev; in __cbas_ec_probe()
225 error = blocking_notifier_chain_register(&ec->event_notifier, in __cbas_ec_probe()
228 dev_err(&pdev->dev, "cannot register notifier: %d\n", error); in __cbas_ec_probe()
233 device_init_wakeup(&pdev->dev, true); in __cbas_ec_probe()
244 retval = -EBUSY; in cbas_ec_probe()
257 struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); in cbas_ec_remove()
261 blocking_notifier_chain_unregister(&ec->event_notifier, in cbas_ec_remove()
301 led->buf[0] = 0; in hammer_kbd_brightness_set_blocking()
302 led->buf[1] = br; in hammer_kbd_brightness_set_blocking()
305 * Request USB HID device to be in Full On mode, so that sending in hammer_kbd_brightness_set_blocking()
308 ret = hid_hw_power(led->hdev, PM_HINT_FULLON); in hammer_kbd_brightness_set_blocking()
310 hid_err(led->hdev, "failed: device not resumed %d\n", ret); in hammer_kbd_brightness_set_blocking()
314 ret = hid_hw_output_report(led->hdev, led->buf, sizeof(led->buf)); in hammer_kbd_brightness_set_blocking()
315 if (ret == -ENOSYS) in hammer_kbd_brightness_set_blocking()
316 ret = hid_hw_raw_request(led->hdev, 0, led->buf, in hammer_kbd_brightness_set_blocking()
317 sizeof(led->buf), in hammer_kbd_brightness_set_blocking()
321 hid_err(led->hdev, "failed to set keyboard backlight: %d\n", in hammer_kbd_brightness_set_blocking()
324 /* Request USB HID device back to Normal Mode. */ in hammer_kbd_brightness_set_blocking()
325 hid_hw_power(led->hdev, PM_HINT_NORMAL); in hammer_kbd_brightness_set_blocking()
337 return -ENOMEM; in hammer_register_leds()
339 kbd_backlight->hdev = hdev; in hammer_register_leds()
340 kbd_backlight->cdev.name = "hammer::kbd_backlight"; in hammer_register_leds()
341 kbd_backlight->cdev.max_brightness = MAX_BRIGHTNESS; in hammer_register_leds()
342 kbd_backlight->cdev.brightness_set_blocking = in hammer_register_leds()
344 kbd_backlight->cdev.flags = LED_HW_PLUGGABLE; in hammer_register_leds()
347 hammer_kbd_brightness_set_blocking(&kbd_backlight->cdev, 0); in hammer_register_leds()
349 error = led_classdev_register(&hdev->dev, &kbd_backlight->cdev); in hammer_register_leds()
366 led_classdev_unregister(&kbd_backlight->cdev); in hammer_unregister_leds()
383 if (usage->hid == HID_USAGE_KBD_FOLDED) { in hammer_input_mapping()
387 * separate input device for tablet switch mode. in hammer_input_mapping()
389 return -1; in hammer_input_mapping()
400 if (usage->hid == HID_USAGE_KBD_FOLDED) { in hammer_event()
428 struct hid_report_enum *re = &hdev->report_enum[report_type]; in hammer_has_usage()
432 list_for_each_entry(report, &re->report_list, list) { in hammer_has_usage()
433 if (report->application != application) in hammer_has_usage()
436 for (i = 0; i < report->maxfield; i++) { in hammer_has_usage()
437 struct hid_field *field = report->field[i]; in hammer_has_usage()
439 for (j = 0; j < field->maxusage; j++) in hammer_has_usage()
440 if (field->usage[j].hid == usage) in hammer_has_usage()
474 * We always want to poll for, and handle tablet mode events from in hammer_probe()
476 * device. This also prevents the hid core from dropping early tablet in hammer_probe()
477 * mode events from the device. in hammer_probe()
480 hdev->quirks |= HID_QUIRK_ALWAYS_POLL; in hammer_probe()
507 * keyboard we should not stay in clamshell mode. in hammer_remove()
512 * resulting in devices being stuck in clamshell mode. in hammer_remove()