diff mbox series

input: touchscreen: imagis: Add touch key support

Message ID 20231112194124.24916-1-duje.mihanovic@skole.hr (mailing list archive)
State New
Headers show
Series input: touchscreen: imagis: Add touch key support | expand

Commit Message

Duje Mihanović Nov. 12, 2023, 7:41 p.m. UTC
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>
---
This patch depends on the series generalizing the driver and adding IST3032C
support: https://lore.kernel.org/all/20231003133440.4696-1-karelb@gimli.ms.mff.cuni.cz/
---
 drivers/input/touchscreen/imagis.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Yujie Liu Nov. 13, 2023, 12:55 a.m. UTC | #1
Hi Duje,

kernel test robot noticed the following build errors:

[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus linus/master v6.6 next-20231110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Duje-Mihanovi/input-touchscreen-imagis-Add-touch-key-support/20231113-034453
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link:    https://lore.kernel.org/r/20231112194124.24916-1-duje.mihanovic%40skole.hr
patch subject: [PATCH] input: touchscreen: imagis: Add touch key support
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20231113/202311130533.EStBdAmT-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231113/202311130533.EStBdAmT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yujie.liu@intel.com>
| Closes: https://lore.kernel.org/r/202311130533.EStBdAmT-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/input/touchscreen/imagis.c: In function 'imagis_interrupt':
>> drivers/input/touchscreen/imagis.c:149:23: error: implicit declaration of function 'FIELD_GET' [-Werror=implicit-function-declaration]
     149 |         key_pressed = FIELD_GET(IST3032C_KEY_STATUS_MASK, intr_message);
         |                       ^~~~~~~~~
   cc1: some warnings being treated as errors


vim +/FIELD_GET +149 drivers/input/touchscreen/imagis.c

a23ba3c043db9a Markuss Broks  2022-03-14   95  
a23ba3c043db9a Markuss Broks  2022-03-14   96  static irqreturn_t imagis_interrupt(int irq, void *dev_id)
a23ba3c043db9a Markuss Broks  2022-03-14   97  {
a23ba3c043db9a Markuss Broks  2022-03-14   98  	struct imagis_ts *ts = dev_id;
a23ba3c043db9a Markuss Broks  2022-03-14   99  	u32 intr_message, finger_status;
7371770ece2db7 Duje Mihanović 2023-11-12  100  	unsigned int finger_count, finger_pressed, key_pressed;
a23ba3c043db9a Markuss Broks  2022-03-14  101  	int i;
a23ba3c043db9a Markuss Broks  2022-03-14  102  	int error;
a23ba3c043db9a Markuss Broks  2022-03-14  103  
8eb834ae8a9b34 Markuss Broks  2023-10-03  104  	error = imagis_i2c_read_reg(ts, ts->tdata->interrupt_msg_cmd, &intr_message);
a23ba3c043db9a Markuss Broks  2022-03-14  105  	if (error) {
a23ba3c043db9a Markuss Broks  2022-03-14  106  		dev_err(&ts->client->dev,
a23ba3c043db9a Markuss Broks  2022-03-14  107  			"failed to read the interrupt message: %d\n", error);
a23ba3c043db9a Markuss Broks  2022-03-14  108  		goto out;
a23ba3c043db9a Markuss Broks  2022-03-14  109  	}
a23ba3c043db9a Markuss Broks  2022-03-14  110  
a23ba3c043db9a Markuss Broks  2022-03-14  111  	finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >>
a23ba3c043db9a Markuss Broks  2022-03-14  112  				IST3038C_FINGER_COUNT_SHIFT;
a23ba3c043db9a Markuss Broks  2022-03-14  113  	if (finger_count > IST3038C_MAX_FINGER_NUM) {
a23ba3c043db9a Markuss Broks  2022-03-14  114  		dev_err(&ts->client->dev,
a23ba3c043db9a Markuss Broks  2022-03-14  115  			"finger count %d is more than maximum supported\n",
a23ba3c043db9a Markuss Broks  2022-03-14  116  			finger_count);
a23ba3c043db9a Markuss Broks  2022-03-14  117  		goto out;
a23ba3c043db9a Markuss Broks  2022-03-14  118  	}
a23ba3c043db9a Markuss Broks  2022-03-14  119  
a23ba3c043db9a Markuss Broks  2022-03-14  120  	finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK;
a23ba3c043db9a Markuss Broks  2022-03-14  121  
a23ba3c043db9a Markuss Broks  2022-03-14  122  	for (i = 0; i < finger_count; i++) {
8eb834ae8a9b34 Markuss Broks  2023-10-03  123  		if (ts->tdata->protocol_b)
a23ba3c043db9a Markuss Broks  2022-03-14  124  			error = imagis_i2c_read_reg(ts,
8eb834ae8a9b34 Markuss Broks  2023-10-03  125  						    ts->tdata->touch_coord_cmd, &finger_status);
8eb834ae8a9b34 Markuss Broks  2023-10-03  126  		else
8eb834ae8a9b34 Markuss Broks  2023-10-03  127  			error = imagis_i2c_read_reg(ts,
8eb834ae8a9b34 Markuss Broks  2023-10-03  128  						    ts->tdata->touch_coord_cmd + (i * 4),
a23ba3c043db9a Markuss Broks  2022-03-14  129  						    &finger_status);
a23ba3c043db9a Markuss Broks  2022-03-14  130  		if (error) {
a23ba3c043db9a Markuss Broks  2022-03-14  131  			dev_err(&ts->client->dev,
a23ba3c043db9a Markuss Broks  2022-03-14  132  				"failed to read coordinates for finger %d: %d\n",
a23ba3c043db9a Markuss Broks  2022-03-14  133  				i, error);
a23ba3c043db9a Markuss Broks  2022-03-14  134  			goto out;
a23ba3c043db9a Markuss Broks  2022-03-14  135  		}
a23ba3c043db9a Markuss Broks  2022-03-14  136  
a23ba3c043db9a Markuss Broks  2022-03-14  137  		input_mt_slot(ts->input_dev, i);
a23ba3c043db9a Markuss Broks  2022-03-14  138  		input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER,
a23ba3c043db9a Markuss Broks  2022-03-14  139  					   finger_pressed & BIT(i));
a23ba3c043db9a Markuss Broks  2022-03-14  140  		touchscreen_report_pos(ts->input_dev, &ts->prop,
a23ba3c043db9a Markuss Broks  2022-03-14  141  				       (finger_status & IST3038C_X_MASK) >>
a23ba3c043db9a Markuss Broks  2022-03-14  142  						IST3038C_X_SHIFT,
a23ba3c043db9a Markuss Broks  2022-03-14  143  				       finger_status & IST3038C_Y_MASK, 1);
a23ba3c043db9a Markuss Broks  2022-03-14  144  		input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR,
a23ba3c043db9a Markuss Broks  2022-03-14  145  				 (finger_status & IST3038C_AREA_MASK) >>
a23ba3c043db9a Markuss Broks  2022-03-14  146  					IST3038C_AREA_SHIFT);
a23ba3c043db9a Markuss Broks  2022-03-14  147  	}
a23ba3c043db9a Markuss Broks  2022-03-14  148  
7371770ece2db7 Duje Mihanović 2023-11-12 @149  	key_pressed = FIELD_GET(IST3032C_KEY_STATUS_MASK, intr_message);
7371770ece2db7 Duje Mihanović 2023-11-12  150  
7371770ece2db7 Duje Mihanović 2023-11-12  151  	input_report_key(ts->input_dev, KEY_APPSELECT, (key_pressed & BIT(0)));
7371770ece2db7 Duje Mihanović 2023-11-12  152  	input_report_key(ts->input_dev, KEY_BACK, (key_pressed & BIT(1)));
7371770ece2db7 Duje Mihanović 2023-11-12  153  
a23ba3c043db9a Markuss Broks  2022-03-14  154  	input_mt_sync_frame(ts->input_dev);
a23ba3c043db9a Markuss Broks  2022-03-14  155  	input_sync(ts->input_dev);
a23ba3c043db9a Markuss Broks  2022-03-14  156  
a23ba3c043db9a Markuss Broks  2022-03-14  157  out:
a23ba3c043db9a Markuss Broks  2022-03-14  158  	return IRQ_HANDLED;
a23ba3c043db9a Markuss Broks  2022-03-14  159  }
a23ba3c043db9a Markuss Broks  2022-03-14  160
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
index 41f28e6e9cb1..5a54ce291655 100644
--- a/drivers/input/touchscreen/imagis.c
+++ b/drivers/input/touchscreen/imagis.c
@@ -30,6 +30,7 @@ 
 #define IST3038C_FINGER_COUNT_MASK	GENMASK(15, 12)
 #define IST3038C_FINGER_COUNT_SHIFT	12
 #define IST3038C_FINGER_STATUS_MASK	GENMASK(9, 0)
+#define IST3032C_KEY_STATUS_MASK	GENMASK(20, 16)
 
 #define IST3038B_REG_STATUS		0x20
 #define IST3038B_REG_CHIPID		0x30
@@ -43,6 +44,7 @@  struct imagis_properties {
 	unsigned int whoami_cmd;
 	unsigned int whoami_val;
 	bool protocol_b;
+	bool touch_keys_supported;
 };
 
 struct imagis_ts {
@@ -95,7 +97,7 @@  static irqreturn_t imagis_interrupt(int irq, void *dev_id)
 {
 	struct imagis_ts *ts = dev_id;
 	u32 intr_message, finger_status;
-	unsigned int finger_count, finger_pressed;
+	unsigned int finger_count, finger_pressed, key_pressed;
 	int i;
 	int error;
 
@@ -144,6 +146,11 @@  static irqreturn_t imagis_interrupt(int irq, void *dev_id)
 					IST3038C_AREA_SHIFT);
 	}
 
+	key_pressed = FIELD_GET(IST3032C_KEY_STATUS_MASK, intr_message);
+
+	input_report_key(ts->input_dev, KEY_APPSELECT, (key_pressed & BIT(0)));
+	input_report_key(ts->input_dev, KEY_BACK, (key_pressed & BIT(1)));
+
 	input_mt_sync_frame(ts->input_dev);
 	input_sync(ts->input_dev);
 
@@ -229,6 +236,10 @@  static int imagis_init_input_dev(struct imagis_ts *ts)
 	input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X);
 	input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y);
 	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 16, 0, 0);
+	if (ts->tdata->touch_keys_supported) {
+		input_set_capability(input_dev, EV_KEY, KEY_BACK);
+		input_set_capability(input_dev, EV_KEY, KEY_APPSELECT);
+	}
 
 	touchscreen_parse_properties(input_dev, true, &ts->prop);
 	if (!ts->prop.max_x || !ts->prop.max_y) {
@@ -370,6 +381,7 @@  static const struct imagis_properties imagis_3032c_data = {
 	.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
 	.whoami_cmd = IST3038C_REG_CHIPID,
 	.whoami_val = IST3032C_WHOAMI,
+	.touch_keys_supported = true,
 };
 
 static const struct imagis_properties imagis_3038b_data = {