diff mbox series

[v8,4/9] Input: wacom_i2c - Add touchscren properties

Message ID 20210803084902.336-4-alistair@alistair23.me (mailing list archive)
State New, archived
Headers show
Series [v8,1/9] dt-bindings: Add Wacom to vendor bindings | expand

Commit Message

Alistair Francis Aug. 3, 2021, 8:48 a.m. UTC
Connect touchscreen properties to the wacom_i2c.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 drivers/input/touchscreen/wacom_i2c.c | 28 ++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

Comments

kernel test robot Aug. 3, 2021, 2:45 p.m. UTC | #1
Hi Alistair,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20210802]
[also build test WARNING on v5.14-rc4]
[cannot apply to input/next robh/for-next hid/for-next linus/master v5.14-rc4 v5.14-rc3 v5.14-rc2]
[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]

url:    https://github.com/0day-ci/linux/commits/Alistair-Francis/dt-bindings-Add-Wacom-to-vendor-bindings/20210803-165202
base:    3a928c58ca10d61051e6a2be65a81418615ef92c
config: nds32-randconfig-p002-20210803 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/e05730114340bbb6573b02263781927ae727f53e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alistair-Francis/dt-bindings-Add-Wacom-to-vendor-bindings/20210803-165202
        git checkout e05730114340bbb6573b02263781927ae727f53e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/input/touchscreen/wacom_i2c.c: In function 'wacom_i2c_irq':
>> drivers/input/touchscreen/wacom_i2c.c:98:18: warning: variable 'y' set but not used [-Wunused-but-set-variable]
      98 |  unsigned int x, y, pressure;
         |                  ^
>> drivers/input/touchscreen/wacom_i2c.c:98:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
      98 |  unsigned int x, y, pressure;
         |               ^


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> kernel/trace/trace_osnoise.c:1612:8: warning: snprintf format string requires 2 parameters but only 1 is given. [wrongPrintfScanfArgNum]
    len = snprintf(NULL, 0, "%*pbln", cpumask_pr_args(&osnoise_cpumask)) + 1;
          ^
   kernel/trace/trace_osnoise.c:1619:8: warning: snprintf format string requires 2 parameters but only 1 is given. [wrongPrintfScanfArgNum]
    len = snprintf(mask_str, len, "%*pbln", cpumask_pr_args(&osnoise_cpumask));
          ^

vim +/y +98 drivers/input/touchscreen/wacom_i2c.c

5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   91  
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   92  static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   93  {
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   94  	struct wacom_i2c *wac_i2c = dev_id;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   95  	struct input_dev *input = wac_i2c->input;
e05730114340bb Alistair Francis   2021-08-03   96  	struct wacom_features *features = &wac_i2c->features;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   97  	u8 *data = wac_i2c->data;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  @98  	unsigned int x, y, pressure;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25   99  	unsigned char tsw, f1, f2, ers;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  100  	int error;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  101  
d568778298f583 Dmitry Torokhov    2012-04-10  102  	error = i2c_master_recv(wac_i2c->client,
d568778298f583 Dmitry Torokhov    2012-04-10  103  				wac_i2c->data, sizeof(wac_i2c->data));
d568778298f583 Dmitry Torokhov    2012-04-10  104  	if (error < 0)
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  105  		goto out;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  106  
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  107  	tsw = data[3] & 0x01;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  108  	ers = data[3] & 0x04;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  109  	f1 = data[3] & 0x02;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  110  	f2 = data[3] & 0x10;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  111  	x = le16_to_cpup((__le16 *)&data[4]);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  112  	y = le16_to_cpup((__le16 *)&data[6]);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  113  	pressure = le16_to_cpup((__le16 *)&data[8]);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  114  
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  115  	if (!wac_i2c->prox)
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  116  		wac_i2c->tool = (data[3] & 0x0c) ?
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  117  			BTN_TOOL_RUBBER : BTN_TOOL_PEN;
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  118  
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  119  	wac_i2c->prox = data[3] & 0x20;
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  120  
e05730114340bb Alistair Francis   2021-08-03  121  	touchscreen_report_pos(input, &wac_i2c->props, features->x_max,
e05730114340bb Alistair Francis   2021-08-03  122  			       features->y_max, true);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  123  	input_report_key(input, BTN_TOUCH, tsw || ers);
8855f30cd2b680 Tatsunosuke Tobita 2013-06-18  124  	input_report_key(input, wac_i2c->tool, wac_i2c->prox);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  125  	input_report_key(input, BTN_STYLUS, f1);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  126  	input_report_key(input, BTN_STYLUS2, f2);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  127  	input_report_abs(input, ABS_PRESSURE, pressure);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  128  	input_sync(input);
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  129  
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  130  out:
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  131  	return IRQ_HANDLED;
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  132  }
5a966261c0dfb8 Tatsunosuke Tobita 2012-03-25  133  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c
index 6053595f2b30..b47bc08efdd1 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,6 +11,7 @@ 
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/irq.h>
+#include <linux/input/touchscreen.h>
 #include <linux/interrupt.h>
 #include <linux/of.h>
 #include <asm/unaligned.h>
@@ -33,6 +34,8 @@  struct wacom_features {
 struct wacom_i2c {
 	struct i2c_client *client;
 	struct input_dev *input;
+	struct touchscreen_properties props;
+	struct wacom_features features;
 	u8 data[WACOM_QUERY_SIZE];
 	bool prox;
 	int tool;
@@ -90,6 +93,7 @@  static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
 {
 	struct wacom_i2c *wac_i2c = dev_id;
 	struct input_dev *input = wac_i2c->input;
+	struct wacom_features *features = &wac_i2c->features;
 	u8 *data = wac_i2c->data;
 	unsigned int x, y, pressure;
 	unsigned char tsw, f1, f2, ers;
@@ -114,12 +118,12 @@  static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
 
 	wac_i2c->prox = data[3] & 0x20;
 
+	touchscreen_report_pos(input, &wac_i2c->props, features->x_max,
+			       features->y_max, true);
 	input_report_key(input, BTN_TOUCH, tsw || ers);
 	input_report_key(input, wac_i2c->tool, wac_i2c->prox);
 	input_report_key(input, BTN_STYLUS, f1);
 	input_report_key(input, BTN_STYLUS2, f2);
-	input_report_abs(input, ABS_X, x);
-	input_report_abs(input, ABS_Y, y);
 	input_report_abs(input, ABS_PRESSURE, pressure);
 	input_sync(input);
 
@@ -151,7 +155,7 @@  static int wacom_i2c_probe(struct i2c_client *client,
 	struct device *dev = &client->dev;
 	struct wacom_i2c *wac_i2c;
 	struct input_dev *input;
-	struct wacom_features features = { 0 };
+	struct wacom_features *features;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@@ -159,14 +163,15 @@  static int wacom_i2c_probe(struct i2c_client *client,
 		return -EIO;
 	}
 
-	error = wacom_query_device(client, &features);
-	if (error)
-		return error;
-
 	wac_i2c = devm_kzalloc(dev, sizeof(*wac_i2c), GFP_KERNEL);
 	if (!wac_i2c)
 		return -ENOMEM;
 
+	features = &wac_i2c->features;
+	error = wacom_query_device(client, features);
+	if (error)
+		return error;
+
 	wac_i2c->client = client;
 
 	input = devm_input_allocate_device(dev);
@@ -178,7 +183,7 @@  static int wacom_i2c_probe(struct i2c_client *client,
 	input->name = "Wacom I2C Digitizer";
 	input->id.bustype = BUS_I2C;
 	input->id.vendor = 0x56a;
-	input->id.version = features.fw_version;
+	input->id.version = features->fw_version;
 	input->open = wacom_i2c_open;
 	input->close = wacom_i2c_close;
 
@@ -190,10 +195,11 @@  static int wacom_i2c_probe(struct i2c_client *client,
 	__set_bit(BTN_STYLUS2, input->keybit);
 	__set_bit(BTN_TOUCH, input->keybit);
 
-	input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
-	input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
+	touchscreen_parse_properties(input, true, &wac_i2c->props);
+	input_set_abs_params(input, ABS_X, 0, features->x_max, 0, 0);
+	input_set_abs_params(input, ABS_Y, 0, features->y_max, 0, 0);
 	input_set_abs_params(input, ABS_PRESSURE,
-			     0, features.pressure_max, 0, 0);
+			     0, features->pressure_max, 0, 0);
 
 	input_set_drvdata(input, wac_i2c);