|
25 | 25 | #define REPORT_ID_RADIO 0x01
|
26 | 26 | #define REPORT_ID_CONSUMER 0x02
|
27 | 27 | #define REPORT_ID_SENSOR 0x03
|
| 28 | +#define REPORT_ID_DISPLAY 0x04 |
28 | 29 |
|
29 | 30 | #define ALS_REPORT_STOP 0x00
|
30 | 31 | #define ALS_REPORT_POLLING 0x01
|
@@ -74,18 +75,22 @@ struct als_feature_report {
|
74 | 75 | uint16_t minimum;
|
75 | 76 | } __packed;
|
76 | 77 |
|
| 78 | +struct display_report { |
| 79 | + uint8_t state; |
| 80 | +} __packed; |
77 | 81 |
|
78 | 82 | static struct radio_report radio_button;
|
79 | 83 | static struct consumer_button_report consumer_button;
|
80 | 84 | static struct als_input_report als_sensor;
|
81 | 85 | static struct als_feature_report als_feature;
|
| 86 | +static struct display_report display_button; |
82 | 87 |
|
83 | 88 | int update_hid_key(enum media_key key, bool pressed)
|
84 | 89 | {
|
85 | 90 | if (key >= HID_KEY_MAX) {
|
86 | 91 | return EC_ERROR_INVAL;
|
87 | 92 | }
|
88 |
| - if (key == HID_KEY_AIRPLANE_MODE) { |
| 93 | + if (key == HID_KEY_AIRPLANE_MODE || key == HID_KEY_DISPLAY_TOGGLE) { |
89 | 94 | key_states[key] = pressed;
|
90 | 95 | if (pressed)
|
91 | 96 | task_set_event(TASK_ID_HID, 1 << key, 0);
|
@@ -285,6 +290,21 @@ static const uint8_t report_desc[] = {
|
285 | 290 | 0x95, 0x01, /* Report Count (1) */
|
286 | 291 | 0x81, 0x02, /* Input (Data,Arr,Abs) */
|
287 | 292 | 0xC0, /* END_COLLECTION */
|
| 293 | + |
| 294 | + /* Display Toggle Collection */ |
| 295 | + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ |
| 296 | + 0x09, 0x80, /* USAGE (System Control) */ |
| 297 | + 0xA1, 0x01, /* COLLECTION (Application) */ |
| 298 | + 0x85, REPORT_ID_DISPLAY, /* Report ID (Display) */ |
| 299 | + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ |
| 300 | + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ |
| 301 | + 0x09, 0xB5, /* USAGE (System Display Toggle Int/Ext Mode) */ |
| 302 | + 0x95, 0x01, /* REPORT_COUNT (1) */ |
| 303 | + 0x75, 0x01, /* REPORT_SIZE (1) */ |
| 304 | + 0x81, 0x06, /* INPUT (Data,Var,Rel) */ |
| 305 | + 0x75, 0x07, /* REPORT_SIZE (7) */ |
| 306 | + 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ |
| 307 | + 0xC0, /* END_COLLECTION */ |
288 | 308 | };
|
289 | 309 |
|
290 | 310 |
|
@@ -478,6 +498,12 @@ static int i2c_hid_touchpad_command_process(size_t len, uint8_t *buffer)
|
478 | 498 | sizeof(struct als_feature_report));
|
479 | 499 | }
|
480 | 500 | break;
|
| 501 | + case REPORT_ID_DISPLAY: |
| 502 | + response_len = |
| 503 | + fill_report(buffer, report_id, |
| 504 | + &display_button, |
| 505 | + sizeof(struct display_report)); |
| 506 | + break; |
481 | 507 | default:
|
482 | 508 | response_len = 2;
|
483 | 509 | buffer[0] = response_len;
|
@@ -564,7 +590,12 @@ int i2c_hid_process(unsigned int len, uint8_t *buffer)
|
564 | 590 | fill_report(buffer, REPORT_ID_SENSOR,
|
565 | 591 | &als_sensor,
|
566 | 592 | sizeof(struct als_input_report));
|
567 |
| - } |
| 593 | + } else if (input_mode == REPORT_ID_DISPLAY) { |
| 594 | + response_len = |
| 595 | + fill_report(buffer, REPORT_ID_DISPLAY, |
| 596 | + &display_button, |
| 597 | + sizeof(struct display_report)); |
| 598 | + } |
568 | 599 | break;
|
569 | 600 | case I2C_HID_COMMAND_REGISTER:
|
570 | 601 | response_len = i2c_hid_touchpad_command_process(len, buffer);
|
@@ -673,6 +704,10 @@ void hid_handler_task(void *p)
|
673 | 704 | input_mode = REPORT_ID_RADIO;
|
674 | 705 | radio_button.state = key_states[i] ? 1 : 0;
|
675 | 706 | break;
|
| 707 | + case HID_KEY_DISPLAY_TOGGLE: |
| 708 | + input_mode = REPORT_ID_DISPLAY; |
| 709 | + display_button.state = key_states[i] ? 1 : 0; |
| 710 | + break; |
676 | 711 | case HID_ALS_REPORT_LUX:
|
677 | 712 |
|
678 | 713 | input_mode = REPORT_ID_SENSOR;
|
|
0 commit comments