3434#define IST3038C_AREA_MASK GENMASK(27, 24)
3535#define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
3636#define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
37+ #define IST3032C_KEY_STATUS_MASK GENMASK(20, 16)
3738
3839struct imagis_properties {
3940 unsigned int interrupt_msg_cmd ;
4041 unsigned int touch_coord_cmd ;
4142 unsigned int whoami_cmd ;
4243 unsigned int whoami_val ;
4344 bool protocol_b ;
45+ bool touch_keys_supported ;
4446};
4547
4648struct imagis_ts {
@@ -49,6 +51,8 @@ struct imagis_ts {
4951 struct input_dev * input_dev ;
5052 struct touchscreen_properties prop ;
5153 struct regulator_bulk_data supplies [2 ];
54+ u32 keycodes [5 ];
55+ int num_keycodes ;
5256};
5357
5458static int imagis_i2c_read_reg (struct imagis_ts * ts ,
@@ -93,7 +97,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
9397{
9498 struct imagis_ts * ts = dev_id ;
9599 u32 intr_message , finger_status ;
96- unsigned int finger_count , finger_pressed ;
100+ unsigned int finger_count , finger_pressed , key_pressed ;
97101 int i ;
98102 int error ;
99103
@@ -140,6 +144,12 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
140144 FIELD_GET (IST3038C_AREA_MASK , finger_status ));
141145 }
142146
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+
143153 input_mt_sync_frame (ts -> input_dev );
144154 input_sync (ts -> input_dev );
145155
@@ -225,6 +235,23 @@ static int imagis_init_input_dev(struct imagis_ts *ts)
225235 input_set_capability (input_dev , EV_ABS , ABS_MT_POSITION_X );
226236 input_set_capability (input_dev , EV_ABS , ABS_MT_POSITION_Y );
227237 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 ]);
228255
229256 touchscreen_parse_properties (input_dev , true, & ts -> prop );
230257 if (!ts -> prop .max_x || !ts -> prop .max_y ) {
@@ -366,6 +393,7 @@ static const struct imagis_properties imagis_3032c_data = {
366393 .touch_coord_cmd = IST3038C_REG_TOUCH_COORD ,
367394 .whoami_cmd = IST3038C_REG_CHIPID ,
368395 .whoami_val = IST3032C_WHOAMI ,
396+ .touch_keys_supported = true,
369397};
370398
371399static const struct imagis_properties imagis_3038b_data = {
0 commit comments