Lines Matching +full:keypad +full:- +full:num +full:- +full:rows

1 // SPDX-License-Identifier: GPL-2.0-only
23 unsigned int rows, unsigned int cols, in matrix_keypad_map_key() argument
26 unsigned short *keymap = input_dev->keycode; in matrix_keypad_map_key()
31 if (row >= rows || col >= cols) { in matrix_keypad_map_key()
32 dev_err(input_dev->dev.parent, in matrix_keypad_map_key()
33 "%s: invalid keymap entry 0x%x (row: %d, col: %d, rows: %d, cols: %d)\n", in matrix_keypad_map_key()
34 __func__, key, row, col, rows, cols); in matrix_keypad_map_key()
39 __set_bit(code, input_dev->keybit); in matrix_keypad_map_key()
45 * matrix_keypad_parse_properties() - Read properties of matrix keypad
48 * @rows: Returns number of matrix rows
53 unsigned int *rows, unsigned int *cols) in matrix_keypad_parse_properties() argument
55 *rows = *cols = 0; in matrix_keypad_parse_properties()
57 device_property_read_u32(dev, "keypad,num-rows", rows); in matrix_keypad_parse_properties()
58 device_property_read_u32(dev, "keypad,num-columns", cols); in matrix_keypad_parse_properties()
60 if (!*rows || !*cols) { in matrix_keypad_parse_properties()
61 dev_err(dev, "number of keypad rows/columns not specified\n"); in matrix_keypad_parse_properties()
62 return -EINVAL; in matrix_keypad_parse_properties()
70 unsigned int rows, unsigned int cols, in matrix_keypad_parse_keymap() argument
73 struct device *dev = input_dev->dev.parent; in matrix_keypad_parse_keymap()
75 unsigned int max_keys = rows << row_shift; in matrix_keypad_parse_keymap()
87 return size < 0 ? size : -EINVAL; in matrix_keypad_parse_keymap()
93 return -EINVAL; in matrix_keypad_parse_keymap()
98 return -ENOMEM; in matrix_keypad_parse_keymap()
108 if (!matrix_keypad_map_key(input_dev, rows, cols, in matrix_keypad_parse_keymap()
110 return -EINVAL; in matrix_keypad_parse_keymap()
117 * matrix_keypad_build_keymap - convert platform keymap into matrix keymap
121 * @rows: number of rows in target keymap array
140 * Callers are expected to set up input_dev->dev.parent before calling this
145 unsigned int rows, unsigned int cols, in matrix_keypad_build_keymap() argument
150 size_t max_keys = rows << row_shift; in matrix_keypad_build_keymap()
154 if (WARN_ON(!input_dev->dev.parent)) in matrix_keypad_build_keymap()
155 return -EINVAL; in matrix_keypad_build_keymap()
158 keymap = devm_kcalloc(input_dev->dev.parent, in matrix_keypad_build_keymap()
162 dev_err(input_dev->dev.parent, in matrix_keypad_build_keymap()
164 return -ENOMEM; in matrix_keypad_build_keymap()
168 input_dev->keycode = keymap; in matrix_keypad_build_keymap()
169 input_dev->keycodesize = sizeof(*keymap); in matrix_keypad_build_keymap()
170 input_dev->keycodemax = max_keys; in matrix_keypad_build_keymap()
172 __set_bit(EV_KEY, input_dev->evbit); in matrix_keypad_build_keymap()
175 for (i = 0; i < keymap_data->keymap_size; i++) { in matrix_keypad_build_keymap()
176 unsigned int key = keymap_data->keymap[i]; in matrix_keypad_build_keymap()
178 if (!matrix_keypad_map_key(input_dev, rows, cols, in matrix_keypad_build_keymap()
180 return -EINVAL; in matrix_keypad_build_keymap()
183 error = matrix_keypad_parse_keymap(keymap_name, rows, cols, in matrix_keypad_build_keymap()
189 __clear_bit(KEY_RESERVED, input_dev->keybit); in matrix_keypad_build_keymap()