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 ;
40
41
unsigned int touch_coord_cmd ;
41
42
unsigned int whoami_cmd ;
42
43
unsigned int whoami_val ;
43
44
bool protocol_b ;
45
+ bool touch_keys_supported ;
44
46
};
45
47
46
48
struct imagis_ts {
@@ -49,6 +51,8 @@ struct imagis_ts {
49
51
struct input_dev * input_dev ;
50
52
struct touchscreen_properties prop ;
51
53
struct regulator_bulk_data supplies [2 ];
54
+ u32 keycodes [5 ];
55
+ int num_keycodes ;
52
56
};
53
57
54
58
static int imagis_i2c_read_reg (struct imagis_ts * ts ,
@@ -93,7 +97,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
93
97
{
94
98
struct imagis_ts * ts = dev_id ;
95
99
u32 intr_message , finger_status ;
96
- unsigned int finger_count , finger_pressed ;
100
+ unsigned int finger_count , finger_pressed , key_pressed ;
97
101
int i ;
98
102
int error ;
99
103
@@ -140,6 +144,12 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
140
144
FIELD_GET (IST3038C_AREA_MASK , finger_status ));
141
145
}
142
146
147
+ key_pressed = FIELD_GET (IST3032C_KEY_STATUS_MASK , intr_message );
148
+
149
+ for (int i = 0 ; i < ts -> num_keycodes ; i ++ )
150
+ input_report_key (ts -> input_dev , ts -> keycodes [i ],
151
+ key_pressed & BIT (i ));
152
+
143
153
input_mt_sync_frame (ts -> input_dev );
144
154
input_sync (ts -> input_dev );
145
155
@@ -225,6 +235,23 @@ static int imagis_init_input_dev(struct imagis_ts *ts)
225
235
input_set_capability (input_dev , EV_ABS , ABS_MT_POSITION_X );
226
236
input_set_capability (input_dev , EV_ABS , ABS_MT_POSITION_Y );
227
237
input_set_abs_params (input_dev , ABS_MT_TOUCH_MAJOR , 0 , 16 , 0 , 0 );
238
+ if (ts -> tdata -> touch_keys_supported ) {
239
+ ts -> num_keycodes = of_property_read_variable_u32_array (
240
+ ts -> client -> dev .of_node , "linux,keycodes" ,
241
+ ts -> keycodes , 0 , ARRAY_SIZE (ts -> keycodes ));
242
+ if (ts -> num_keycodes <= 0 ) {
243
+ ts -> keycodes [0 ] = KEY_APPSELECT ;
244
+ ts -> keycodes [1 ] = KEY_BACK ;
245
+ ts -> num_keycodes = 2 ;
246
+ }
247
+
248
+ input_dev -> keycodemax = ts -> num_keycodes ;
249
+ input_dev -> keycodesize = sizeof (ts -> keycodes [0 ]);
250
+ input_dev -> keycode = ts -> keycodes ;
251
+ }
252
+
253
+ for (int i = 0 ; i < ts -> num_keycodes ; i ++ )
254
+ input_set_capability (input_dev , EV_KEY , ts -> keycodes [i ]);
228
255
229
256
touchscreen_parse_properties (input_dev , true, & ts -> prop );
230
257
if (!ts -> prop .max_x || !ts -> prop .max_y ) {
@@ -366,6 +393,7 @@ static const struct imagis_properties imagis_3032c_data = {
366
393
.touch_coord_cmd = IST3038C_REG_TOUCH_COORD ,
367
394
.whoami_cmd = IST3038C_REG_CHIPID ,
368
395
.whoami_val = IST3032C_WHOAMI ,
396
+ .touch_keys_supported = true,
369
397
};
370
398
371
399
static const struct imagis_properties imagis_3038b_data = {
0 commit comments