Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: imagis - add touch key support

IST3032C (and possibly some other models) has touch keys. Add support
for them to the imagis driver.

Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
Link: https://lore.kernel.org/r/20240306-b4-imagis-keys-v3-3-2c429afa8420@skole.hr
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Duje Mihanović and committed by
Dmitry Torokhov
2d77f70b 44b6cee0

+29 -1
+29 -1
drivers/input/touchscreen/imagis.c
··· 34 34 #define IST3038C_AREA_MASK GENMASK(27, 24) 35 35 #define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12) 36 36 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) 37 + #define IST3032C_KEY_STATUS_MASK GENMASK(20, 16) 37 38 38 39 struct imagis_properties { 39 40 unsigned int interrupt_msg_cmd; ··· 42 41 unsigned int whoami_cmd; 43 42 unsigned int whoami_val; 44 43 bool protocol_b; 44 + bool touch_keys_supported; 45 45 }; 46 46 47 47 struct imagis_ts { ··· 51 49 struct input_dev *input_dev; 52 50 struct touchscreen_properties prop; 53 51 struct regulator_bulk_data supplies[2]; 52 + u32 keycodes[5]; 53 + int num_keycodes; 54 54 }; 55 55 56 56 static int imagis_i2c_read_reg(struct imagis_ts *ts, ··· 97 93 { 98 94 struct imagis_ts *ts = dev_id; 99 95 u32 intr_message, finger_status; 100 - unsigned int finger_count, finger_pressed; 96 + unsigned int finger_count, finger_pressed, key_pressed; 101 97 int i; 102 98 int error; 103 99 ··· 143 139 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 144 140 FIELD_GET(IST3038C_AREA_MASK, finger_status)); 145 141 } 142 + 143 + key_pressed = FIELD_GET(IST3032C_KEY_STATUS_MASK, intr_message); 144 + 145 + for (int i = 0; i < ts->num_keycodes; i++) 146 + input_report_key(ts->input_dev, ts->keycodes[i], 147 + key_pressed & BIT(i)); 146 148 147 149 input_mt_sync_frame(ts->input_dev); 148 150 input_sync(ts->input_dev); ··· 235 225 input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); 236 226 input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); 237 227 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 16, 0, 0); 228 + if (ts->tdata->touch_keys_supported) { 229 + ts->num_keycodes = of_property_read_variable_u32_array( 230 + ts->client->dev.of_node, "linux,keycodes", 231 + ts->keycodes, 0, ARRAY_SIZE(ts->keycodes)); 232 + if (ts->num_keycodes <= 0) { 233 + ts->keycodes[0] = KEY_APPSELECT; 234 + ts->keycodes[1] = KEY_BACK; 235 + ts->num_keycodes = 2; 236 + } 237 + 238 + input_dev->keycodemax = ts->num_keycodes; 239 + input_dev->keycodesize = sizeof(ts->keycodes[0]); 240 + input_dev->keycode = ts->keycodes; 241 + } 242 + 243 + for (int i = 0; i < ts->num_keycodes; i++) 244 + input_set_capability(input_dev, EV_KEY, ts->keycodes[i]); 238 245 239 246 touchscreen_parse_properties(input_dev, true, &ts->prop); 240 247 if (!ts->prop.max_x || !ts->prop.max_y) { ··· 393 366 .touch_coord_cmd = IST3038C_REG_TOUCH_COORD, 394 367 .whoami_cmd = IST3038C_REG_CHIPID, 395 368 .whoami_val = IST3032C_WHOAMI, 369 + .touch_keys_supported = true, 396 370 }; 397 371 398 372 static const struct imagis_properties imagis_3038b_data = {