Lines Matching +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()
88 return size < 0 ? size : -EINVAL; in matrix_keypad_parse_keymap()
94 return -EINVAL; in matrix_keypad_parse_keymap()
99 return -ENOMEM; in matrix_keypad_parse_keymap()
109 if (!matrix_keypad_map_key(input_dev, rows, cols, in matrix_keypad_parse_keymap()
111 retval = -EINVAL; in matrix_keypad_parse_keymap()
124 * matrix_keypad_build_keymap - convert platform keymap into matrix keymap
128 * @rows: number of rows in target keymap array
147 * Callers are expected to set up input_dev->dev.parent before calling this
152 unsigned int rows, unsigned int cols, in matrix_keypad_build_keymap() argument
157 size_t max_keys = rows << row_shift; in matrix_keypad_build_keymap()
161 if (WARN_ON(!input_dev->dev.parent)) in matrix_keypad_build_keymap()
162 return -EINVAL; in matrix_keypad_build_keymap()
165 keymap = devm_kcalloc(input_dev->dev.parent, in matrix_keypad_build_keymap()
169 dev_err(input_dev->dev.parent, in matrix_keypad_build_keymap()
171 return -ENOMEM; in matrix_keypad_build_keymap()
175 input_dev->keycode = keymap; in matrix_keypad_build_keymap()
176 input_dev->keycodesize = sizeof(*keymap); in matrix_keypad_build_keymap()
177 input_dev->keycodemax = max_keys; in matrix_keypad_build_keymap()
179 __set_bit(EV_KEY, input_dev->evbit); in matrix_keypad_build_keymap()
182 for (i = 0; i < keymap_data->keymap_size; i++) { in matrix_keypad_build_keymap()
183 unsigned int key = keymap_data->keymap[i]; in matrix_keypad_build_keymap()
185 if (!matrix_keypad_map_key(input_dev, rows, cols, in matrix_keypad_build_keymap()
187 return -EINVAL; in matrix_keypad_build_keymap()
190 error = matrix_keypad_parse_keymap(keymap_name, rows, cols, in matrix_keypad_build_keymap()
196 __clear_bit(KEY_RESERVED, input_dev->keybit); in matrix_keypad_build_keymap()