Lines Matching +full:key +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org>
18 #define DRV_NAME "pinephone-keyboard"
46 KEY(0, 0, KEY_ESC),
47 KEY(0, 1, KEY_1),
48 KEY(0, 2, KEY_2),
49 KEY(0, 3, KEY_3),
50 KEY(0, 4, KEY_4),
51 KEY(0, 5, KEY_5),
52 KEY(0, 6, KEY_6),
53 KEY(0, 7, KEY_7),
54 KEY(0, 8, KEY_8),
55 KEY(0, 9, KEY_9),
56 KEY(0, 10, KEY_0),
57 KEY(0, 11, KEY_BACKSPACE),
59 KEY(1, 0, KEY_TAB),
60 KEY(1, 1, KEY_Q),
61 KEY(1, 2, KEY_W),
62 KEY(1, 3, KEY_E),
63 KEY(1, 4, KEY_R),
64 KEY(1, 5, KEY_T),
65 KEY(1, 6, KEY_Y),
66 KEY(1, 7, KEY_U),
67 KEY(1, 8, KEY_I),
68 KEY(1, 9, KEY_O),
69 KEY(1, 10, KEY_P),
70 KEY(1, 11, KEY_ENTER),
72 KEY(2, 0, KEY_LEFTMETA),
73 KEY(2, 1, KEY_A),
74 KEY(2, 2, KEY_S),
75 KEY(2, 3, KEY_D),
76 KEY(2, 4, KEY_F),
77 KEY(2, 5, KEY_G),
78 KEY(2, 6, KEY_H),
79 KEY(2, 7, KEY_J),
80 KEY(2, 8, KEY_K),
81 KEY(2, 9, KEY_L),
82 KEY(2, 10, KEY_SEMICOLON),
84 KEY(3, 0, KEY_LEFTSHIFT),
85 KEY(3, 1, KEY_Z),
86 KEY(3, 2, KEY_X),
87 KEY(3, 3, KEY_C),
88 KEY(3, 4, KEY_V),
89 KEY(3, 5, KEY_B),
90 KEY(3, 6, KEY_N),
91 KEY(3, 7, KEY_M),
92 KEY(3, 8, KEY_COMMA),
93 KEY(3, 9, KEY_DOT),
94 KEY(3, 10, KEY_SLASH),
96 KEY(4, 1, KEY_LEFTCTRL),
97 KEY(4, 4, KEY_SPACE),
98 KEY(4, 6, KEY_APOSTROPHE),
99 KEY(4, 8, KEY_RIGHTBRACE),
100 KEY(4, 9, KEY_LEFTBRACE),
102 KEY(5, 2, KEY_FN),
103 KEY(5, 3, KEY_LEFTALT),
104 KEY(5, 5, KEY_RIGHTALT),
107 KEY(PPKB_ROWS + 0, 0, KEY_FN_ESC),
108 KEY(PPKB_ROWS + 0, 1, KEY_F1),
109 KEY(PPKB_ROWS + 0, 2, KEY_F2),
110 KEY(PPKB_ROWS + 0, 3, KEY_F3),
111 KEY(PPKB_ROWS + 0, 4, KEY_F4),
112 KEY(PPKB_ROWS + 0, 5, KEY_F5),
113 KEY(PPKB_ROWS + 0, 6, KEY_F6),
114 KEY(PPKB_ROWS + 0, 7, KEY_F7),
115 KEY(PPKB_ROWS + 0, 8, KEY_F8),
116 KEY(PPKB_ROWS + 0, 9, KEY_F9),
117 KEY(PPKB_ROWS + 0, 10, KEY_F10),
118 KEY(PPKB_ROWS + 0, 11, KEY_DELETE),
120 KEY(PPKB_ROWS + 1, 10, KEY_PAGEUP),
122 KEY(PPKB_ROWS + 2, 0, KEY_SYSRQ),
123 KEY(PPKB_ROWS + 2, 9, KEY_PAGEDOWN),
124 KEY(PPKB_ROWS + 2, 10, KEY_INSERT),
126 KEY(PPKB_ROWS + 3, 0, KEY_LEFTSHIFT),
127 KEY(PPKB_ROWS + 3, 8, KEY_HOME),
128 KEY(PPKB_ROWS + 3, 9, KEY_UP),
129 KEY(PPKB_ROWS + 3, 10, KEY_END),
131 KEY(PPKB_ROWS + 4, 1, KEY_LEFTCTRL),
132 KEY(PPKB_ROWS + 4, 6, KEY_LEFT),
133 KEY(PPKB_ROWS + 4, 8, KEY_RIGHT),
134 KEY(PPKB_ROWS + 4, 9, KEY_DOWN),
136 KEY(PPKB_ROWS + 5, 3, KEY_LEFTALT),
137 KEY(PPKB_ROWS + 5, 5, KEY_RIGHTALT),
148 u8 buf[2][PPKB_BUF_LEN];
160 struct i2c_client *client = adap->algo_data; in ppkb_adap_smbus_xfer()
165 buf[1] = data->byte; in ppkb_adap_smbus_xfer()
166 buf[2] = read_write == I2C_SMBUS_READ ? PPKB_SYS_COMMAND_SMBUS_READ in ppkb_adap_smbus_xfer()
178 } while (ret == buf[2]); in ppkb_adap_smbus_xfer()
183 return -EIO; in ppkb_adap_smbus_xfer()
190 data->byte = ret; in ppkb_adap_smbus_xfer()
209 unsigned short *keymap = ppkb->input->keycode; in ppkb_update()
211 u8 *old_buf = ppkb->buf[!ppkb->buf_swap]; in ppkb_update()
212 u8 *new_buf = ppkb->buf[ppkb->buf_swap]; in ppkb_update()
214 struct device *dev = &client->dev; in ppkb_update()
223 crc = crc8(ppkb->crc_table, &new_buf[1], PPKB_COLS, CRC8_INIT_VALUE); in ppkb_update()
229 ppkb->buf_swap = !ppkb->buf_swap; in ppkb_update()
249 * Save off the FN key state when the key was pressed, in ppkb_update()
252 fn_state = value ? ppkb->fn_pressed : ppkb->fn_state[col] & mask; in ppkb_update()
254 ppkb->fn_state[col] ^= mask; in ppkb_update()
259 input_event(ppkb->input, EV_MSC, MSC_SCAN, code); in ppkb_update()
260 input_report_key(ppkb->input, keymap[code], value); in ppkb_update()
262 ppkb->fn_pressed = value; in ppkb_update()
265 input_sync(ppkb->input); in ppkb_update()
279 struct device *dev = &client->dev; in ppkb_set_scan()
323 struct device *dev = &client->dev; in ppkb_probe()
339 error = ret < 0 ? ret : -EIO; in ppkb_probe()
348 return -ENODEV; in ppkb_probe()
361 return -EINVAL; in ppkb_probe()
371 return -ENOMEM; in ppkb_probe()
375 i2c_bus = of_get_child_by_name(dev->of_node, "i2c"); in ppkb_probe()
377 ppkb->adapter.owner = THIS_MODULE; in ppkb_probe()
378 ppkb->adapter.algo = &ppkb_adap_algo; in ppkb_probe()
379 ppkb->adapter.algo_data = client; in ppkb_probe()
380 ppkb->adapter.dev.parent = dev; in ppkb_probe()
381 ppkb->adapter.dev.of_node = i2c_bus; in ppkb_probe()
382 strscpy(ppkb->adapter.name, DRV_NAME, sizeof(ppkb->adapter.name)); in ppkb_probe()
384 error = devm_i2c_add_adapter(dev, &ppkb->adapter); in ppkb_probe()
391 crc8_populate_msb(ppkb->crc_table, PPKB_CRC8_POLYNOMIAL); in ppkb_probe()
393 ppkb->input = devm_input_allocate_device(dev); in ppkb_probe()
394 if (!ppkb->input) in ppkb_probe()
395 return -ENOMEM; in ppkb_probe()
397 input_set_drvdata(ppkb->input, client); in ppkb_probe()
399 ppkb->input->name = "PinePhone Keyboard"; in ppkb_probe()
400 ppkb->input->phys = DRV_NAME "/input0"; in ppkb_probe()
401 ppkb->input->id.bustype = BUS_I2C; in ppkb_probe()
402 ppkb->input->open = ppkb_open; in ppkb_probe()
403 ppkb->input->close = ppkb_close; in ppkb_probe()
405 input_set_capability(ppkb->input, EV_MSC, MSC_SCAN); in ppkb_probe()
406 __set_bit(EV_REP, ppkb->input->evbit); in ppkb_probe()
409 2 * PPKB_ROWS, PPKB_COLS, NULL, in ppkb_probe()
410 ppkb->input); in ppkb_probe()
416 error = input_register_device(ppkb->input); in ppkb_probe()
422 error = devm_request_threaded_irq(dev, client->irq, in ppkb_probe()
424 IRQF_ONESHOT, client->name, client); in ppkb_probe()
434 { .compatible = "pine64,pinephone-keyboard" },