summaryrefslogtreecommitdiff
path: root/board/banshee/keyboard.c
blob: 3891955b46573b558dbf296b95ab266084ebad40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* Copyright 2022 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "common.h"
#include "ec_commands.h"
#include "keyboard_scan.h"
#include "timer.h"

/* Keyboard scan setting */
__override struct keyboard_scan_config keyscan_config = {
	/* Increase from 50 us, because KSO_02 passes through the H1. */
	.output_settle_us = 80,
	/* Other values should be the same as the default configuration. */
	.debounce_down_us = 9 * MSEC,
	.debounce_up_us = 30 * MSEC,
	.scan_period_us = 3 * MSEC,
	.min_post_scan_delay_us = 1000,
	.poll_timeout_us = 100 * MSEC,
	.actual_key_mask = {
		0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff,
		0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xff,
		0xff, 0xef  /* full set */
	},
};

static const struct ec_response_keybd_config banshee_kb_id1 = {
	.num_top_row_keys = 12,
	.action_keys = {
		TK_BACK,		/* T1 */
		TK_FORWARD,		/* T2 */
		TK_REFRESH,		/* T3 */
		TK_FULLSCREEN,		/* T4 */
		TK_OVERVIEW,		/* T5 */
		TK_SNAPSHOT,		/* T6 */
		TK_BRIGHTNESS_DOWN,	/* T7 */
		TK_BRIGHTNESS_UP,	/* T8 */
		TK_PLAY_PAUSE,		/* T9 */
		TK_VOL_MUTE,		/* T10 */
		TK_VOL_DOWN,		/* T11 */
		TK_VOL_UP,		/* T12 */
	},
	.capabilities = KEYBD_CAP_SCRNLOCK_KEY,
};

static const struct ec_response_keybd_config banshee_kb_id2 = {
	.num_top_row_keys = 12,
	.action_keys = {
		TK_BACK,		/* T1 */
		TK_REFRESH,		/* T2 */
		TK_FULLSCREEN,		/* T3 */
		TK_OVERVIEW,		/* T4 */
		TK_SNAPSHOT,		/* T5 */
		TK_BRIGHTNESS_DOWN,	/* T6 */
		TK_BRIGHTNESS_UP,	/* T7 */
		TK_KBD_BKLIGHT_TOGGLE,	/* T8 */
		TK_PLAY_PAUSE,		/* T9 */
		TK_VOL_MUTE,		/* T10 */
		TK_VOL_DOWN,		/* T11 */
		TK_VOL_UP,		/* T12 */
	},
	.capabilities = KEYBD_CAP_SCRNLOCK_KEY,
};

__override const struct ec_response_keybd_config
*board_vivaldi_keybd_config(void)
{
	if (get_board_id() <= 1)
		return &banshee_kb_id1;
	else
		return &banshee_kb_id2;
}

/*
 * Row Column info for Top row keys T1 - T15.
 * on banshee keyboard Row Column is customization
 * need define row col to mapping matrix layout.
 */
__override const struct key {
	uint8_t row;
	uint8_t col;
} vivaldi_keys[] = {
	{.row = 3, .col = 5},	/* T1 */
	{.row = 2, .col = 5},	/* T2 */
	{.row = 6, .col = 4},	/* T3 */
	{.row = 3, .col = 4},	/* T4 */
	{.row = 4, .col = 10},	/* T5 */
	{.row = 3, .col = 10},	/* T6 */
	{.row = 2, .col = 10},	/* T7 */
	{.row = 1, .col = 15},	/* T8 */
	{.row = 3, .col = 11},	/* T9 */
	{.row = 4, .col = 8},	/* T10 */
	{.row = 6, .col = 8},	/* T11 */
	{.row = 3, .col = 13},	/* T12 */
	{.row = 3, .col = 5},	/* T13 */
	{.row = 0, .col = 9},	/* T14 */
	{.row = 0, .col = 11},	/* T15 */
};
BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS);