Input: driver for the Goodix touchpanel
Subsystems (3)
PATCH 1/1 Input: driver for the Goodix touchpanel
Add a driver for the Goodix touchscreen panel found in Onda v975w tablets. The driver is based off the Android driver gt9xx.c found in some Android code dumps, but now bears no resemblance to the original driver.
The driver was tested on the aforementioned tablet.
--- MAINTAINERS | 6 + drivers/input/touchscreen/Kconfig | 13 ++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/goodix.c | 452 +++++++++++++++++++++++++++++++++++++ 4 files changed, 472 insertions(+) create mode 100644 drivers/input/touchscreen/goodix.c
MAINTAINERS +6 -0
@@ -4057,6 +4057,12 @@ L: [email protected] S: Maintained F: drivers/media/usb/go7007/ +GOODIX TOUCHSCREEN +M: Bastien Nocera <[email protected]> +L: [email protected] +S: Maintained +F: drivers/input/touchscreen/goodix.c + GPIO SUBSYSTEM M: Linus Walleij <[email protected]> M: Alexandre Courbot <[email protected]>
drivers/input/touchscreen/Kconfig +13 -0
@@ -283,6 +283,19 @@ config TOUCHSCREEN_FUJITSU To compile this driver as a module, choose M here: the module will be called fujitsu-ts. +config TOUCHSCREEN_GOODIX + tristate "Goodix I2C touchscreen" + depends on I2C && ACPI + help + Say Y here if you have the Goodix touchscreen (such as one + installed in Onda v975w tablets) connected to your + system. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called goodix. + config TOUCHSCREEN_ILI210X tristate "Ilitek ILI210X based touchscreen" depends on I2C
drivers/input/touchscreen/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o obj-$(CONFIG_TOUCHSCREEN_EGALAX) += egalax_ts.o obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o +obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o
drivers/input/touchscreen/goodix.c new file +452 -0
452 lines not on this page · raw message
Signature · 1 line
2.1.0
Dmitry Torokhov
maintainerHi Bastien,
Quoted 119 lines · Bastien Nocera
Add a driver for the Goodix touchscreen panel found in Onda v975w tablets. The driver is based off the Android driver
gt9xx.cfound in some Android code dumps, but now bears no resemblance to the original driver.The driver was tested on the aforementioned tablet.
Signed-off-by Bastien Nocera <[email protected]>Tested-by Bastien Nocera <[email protected]>--- MAINTAINERS | 6 + drivers/input/touchscreen/Kconfig | 13 ++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/goodix.c | 452 +++++++++++++++++++++++++++++++++++++ 4 files changed, 472 insertions(+) create mode 100644 drivers/input/touchscreen/goodix.cMAINTAINERS +6
-0@@ -4057,6 +4057,12 @@ L: [email protected] S: Maintained F: drivers/media/usb/go7007/ +GOODIX TOUCHSCREEN +M: Bastien Nocera <[email protected]> +L: [email protected] +S: Maintained +F: drivers/input/touchscreen/goodix.c + GPIO SUBSYSTEM M: Linus Walleij <[email protected]> M: Alexandre Courbot <[email protected]>drivers/input/touchscreen/Kconfig +13
-0@@ -283,6 +283,19 @@ config TOUCHSCREEN_FUJITSU To compile this driver as a module, choose M here: the module will be called fujitsu-ts. +config TOUCHSCREEN_GOODIX + tristate "Goodix I2C touchscreen" + depends on I2C && ACPI + help + Say Y here if you have the Goodix touchscreen (such as one + installed in Onda v975w tablets) connected to your + system. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called goodix. + config TOUCHSCREEN_ILI210X tristate "Ilitek ILI210X based touchscreen" depends on I2Cdrivers/input/touchscreen/Makefile +1
-0@@ -33,6 +33,7 @@ obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o obj-$(CONFIG_TOUCHSCREEN_EGALAX) += egalax_ts.o obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o +obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.odrivers/input/touchscreen/goodix.c new file +43
-0@@ -0,0 +1,452 @@ +/* +* driver for Goodix Touchscreens +* +* Copyright (c) 2014 Red Hat Inc. +* +* This code is based on gt9xx.c authored by [email protected]: +* +* 2010 - 2012 Goodix Technology. +*/ + +/* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; version 2 of the License. +*/ + +#include <linux/kernel.h> +#include <linux/i2c.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/irq.h> +#include <linux/interrupt.h> +#include <linux/slab.h> +#include <asm/unaligned.h> + +struct goodix_ts_data { +struct i2c_client *client; +struct input_dev *input_dev; +int abs_x_max; +int abs_y_max; +unsigned int max_touch_num; +unsigned int int_trigger_type; +}; + +#define GOODIX_MAX_HEIGHT 4096 +#define GOODIX_MAX_WIDTH 4096 +#define GOODIX_INT_TRIGGER 1 +#define GOODIX_MAX_TOUCH 10 + +#define GOODIX_CONFIG_MAX_LENGTH 240 +
drivers/input/touchscreen/goodix.c line 53
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+/* Register defineS */ +#define GOODIX_READ_COOR_ADDR 0x814E +#define GOODIX_REG_CONFIG_DATA 0x8047 +#define GOODIX_REG_VERSION 0x8140 + +#define RESOLUTION_LOC 1 +#define TRIGGER_LOC 6 + +#define GOODIX_INFO(fmt, arg...) pr_info("<<-GTP-INFO->> "fmt"\n", ##arg) +#define GOODIX_ERROR(fmt, arg...) pr_err("<<-GTP-ERROR->> "fmt"\n", ##arg)
Let's use standard dev_xxx()
drivers/input/touchscreen/goodix.c line 61
Quoted 8 lines
drivers/input/touchscreen/goodix.c new file +8
-0+ +static const char *goodix_ts_name ="Goodix Capacitive TouchScreen" ; +static const unsigned long goodix_irq_flags[] = { +IRQ_TYPE_EDGE_RISING |IRQF_ONESHOT , +IRQ_TYPE_EDGE_FALLING |IRQF_ONESHOT , +IRQ_TYPE_LEVEL_LOW |IRQF_ONESHOT , +IRQ_TYPE_LEVEL_HIGH |IRQF_ONESHOT +};
I'd rather you pulled out IRQF_ONESHOT and specified it explicitly in request_threaded_irq().
Quoted 4 lines
drivers/input/touchscreen/goodix.c new file +4
-0+ +/** +* goodix_i2c_read - read data from a register of the i2c slave device. +*
drivers/input/touchscreen/goodix.c line 75
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+* @client: i2c device. +* @reg: the register to read from. +* @buf: raw write data buffer. +* @len: length of the buffer to write +*/ +static int goodix_i2c_read (struct i2c_client *client, +u16 reg,u8 *buf,int len) +{ +struct i2c_msg msgs[2 ]; +u8 wbuf[2 ] = { reg >>8 , reg &0xff };
cpu_to_be16()?
drivers/input/touchscreen/goodix.c line 77
Quoted 2 lines
drivers/input/touchscreen/goodix.c new file +2
-0+ + msgs[0 ].flags = !I2C_M_RD ;
I2C_M_RD is not a boolean, do not negate it.
drivers/input/touchscreen/goodix.c line 87
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ msgs[0 ].addr = client->addr; + msgs[0 ].len =2 ; + msgs[0 ].buf = wbuf; + + msgs[1 ].flags =I2C_M_RD ; + msgs[1 ].addr = client->addr; + msgs[1 ].len = len; + msgs[1 ].buf = buf; + +return i2c_transfer (client->adapter, msgs,2 );
return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);
I really need to get that i2c_transfer_exact() going again.
Quoted 13 lines
drivers/input/touchscreen/goodix.c new file +13
-0+} + +/** +* goodix_i2c_write - write data to the i2c slave device. +* +* @client: i2c device. +* @reg: the register to read to. +* @buf: raw write data buffer. +* @len: length of the buffer to write +*/ +static int goodix_i2c_write (struct i2c_client *client, +u16 reg,u8 *buf,int len) +{
drivers/input/touchscreen/goodix.c line 110
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+struct i2c_msg msg; +int ret; +u8 *wbuf; + + wbuf =kzalloc (len +2 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + wbuf[0 ] = reg >>8 ; + wbuf[1 ] = reg &0xFF ;
Again cpu_to_be16().
drivers/input/touchscreen/goodix.c line 113
Quoted 3 lines
drivers/input/touchscreen/goodix.c new file +3
-0+memcpy (&wbuf[2 ], buf, len); + + msg.flags = !I2C_M_RD ;
Same here, not boolean.
Quoted 68 lines
drivers/input/touchscreen/goodix.c new file +68
-0+ msg.addr = client->addr; + msg.len = len +2 ; + msg.buf = wbuf; + + ret =i2c_transfer (client->adapter, &msg,1 ); +kfree (wbuf); +return ret; +} + +static int goodix_ts_read_input_report (struct goodix_ts_data *ts,u8 *data) +{ +int touch_num; +int ret; + + ret =goodix_i2c_read (ts->client,GOODIX_READ_COOR_ADDR , data,10 ); +if (ret <0 ) { +GOODIX_ERROR ("I2C transfer error (%d)\n" , ret); +return ret; + } + + touch_num = data[0 ] &0x0f ; +if (touch_num >GOODIX_MAX_TOUCH ) +return -EPROTO ; + +if (touch_num >1 ) { + ret =goodix_i2c_read (ts->client,GOODIX_READ_COOR_ADDR +10 , + &data[10 ],8 * (touch_num -1 )); +if (ret <0 ) +return ret; + } + +return touch_num; +} + +static void goodix_ts_parse_touch (struct goodix_ts_data *ts,u8 *coor_data) +{ +int id = coor_data[0 ] &0x0F ; +int input_x =get_unaligned_le16 (&coor_data[1 ]); +int input_y =get_unaligned_le16 (&coor_data[3 ]); +int input_w =get_unaligned_le16 (&coor_data[5 ]); + +input_mt_slot (ts->input_dev, id); +input_mt_report_slot_state (ts->input_dev,MT_TOOL_FINGER , true); +input_report_abs (ts->input_dev,ABS_MT_POSITION_X , input_x); +input_report_abs (ts->input_dev,ABS_MT_POSITION_Y , input_y); +input_report_abs (ts->input_dev,ABS_MT_TOUCH_MAJOR , input_w); +input_report_abs (ts->input_dev,ABS_MT_WIDTH_MAJOR , input_w); +} + +/** +* goodix_ts_work_func - Process incoming IRQ +* +* @ts: our goodix_ts_data pointer +* +* Called when the IRQ is triggered. Read the current device state, and push +* the input events to the user space. +*/ +static void goodix_ts_work_func (struct goodix_ts_data *ts) +{ +u8 end_cmd[1 ] = {0 }; +u8 point_data[1 +8 *GOODIX_MAX_TOUCH +1 ]; +int touch_num; +int i; + + touch_num =goodix_ts_read_input_report (ts, point_data); +if (touch_num <0 ) + goto exit_work_func; +
drivers/input/touchscreen/goodix.c line 191
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+for (i =0 ; i < touch_num; i++) +goodix_ts_parse_touch (ts, &point_data[1 +8 * i]); + +input_mt_sync_frame (ts->input_dev); +input_sync (ts->input_dev); + +exit_work_func: +if (goodix_i2c_write (ts->client, +GOODIX_READ_COOR_ADDR , end_cmd,1 ) <0 ) +GOODIX_INFO ("I2C write end_cmd error" );
Why did you need to pull it out of goodix_ts_irq_handler()?
Quoted 64 lines
drivers/input/touchscreen/goodix.c new file +64
-0+} + +/** +* goodix_ts_irq_handler - The IRQ handler +* +* @irq: interrupt number. +* @dev_id: private data pointer. +*/ +static irqreturn_t goodix_ts_irq_handler (int irq,void *dev_id) +{ +struct goodix_ts_data *ts = dev_id; + +goodix_ts_work_func (ts); + +return IRQ_HANDLED ; +} + +/** +* goodix_read_config - Read the embedded configuration of the panel +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static void goodix_read_config (struct goodix_ts_data *ts) +{ +int ret; +u8 config[GOODIX_CONFIG_MAX_LENGTH ]; + + ret =goodix_i2c_read (ts->client,GOODIX_REG_CONFIG_DATA , config, +GOODIX_CONFIG_MAX_LENGTH ); +if (ret <0 ) { +GOODIX_ERROR ("Error reading config, use default value!" ); + ts->abs_x_max =GOODIX_MAX_WIDTH ; + ts->abs_y_max =GOODIX_MAX_HEIGHT ; + ts->int_trigger_type =GOODIX_INT_TRIGGER ; +return ; + } + + ts->abs_x_max =get_unaligned_le16 (&config[RESOLUTION_LOC ]); + ts->abs_y_max =get_unaligned_le16 (&config[RESOLUTION_LOC +2 ]); + ts->int_trigger_type = (config[TRIGGER_LOC ]) &0x03 ; +if ((!ts->abs_x_max) || (!ts->abs_y_max)) { +GOODIX_ERROR ("Invalid config, use default value!" ); + ts->abs_x_max =GOODIX_MAX_WIDTH ; + ts->abs_y_max =GOODIX_MAX_HEIGHT ; + } +} + + +/** +* goodix_read_version - Read goodix touchscreen version +* +* @client: the i2c client +* @version: output buffer containing the version on success +*/ +static int goodix_read_version (struct i2c_client *client,u16 *version) +{ +int ret; +int i; +u8 buf[6 ]; + + ret =goodix_i2c_read (client,GOODIX_REG_VERSION , buf,sizeof (buf)); +if (ret <0 ) {
drivers/input/touchscreen/goodix.c line 265
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+GOODIX_ERROR ("GTP read version failed" ); +return ret; + } + +if (version) + *version =get_unaligned_le16 (&buf[4 ]); + +for (i =0 ; i <4 ; i++) { +if (!buf[i]) + buf[i] =0x30 ;
buf[i] = '0';
but what if they happen to have some other nonprintable garbage there?
Quoted 43 lines
drivers/input/touchscreen/goodix.c new file +43
-0+ } +GOODIX_INFO ("IC VERSION: %c%c%c%c_%02x%02x" , + buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[5 ], buf[4 ]); + +return ret; +} + +/** +* goodix_i2c_test - I2C test function to check if the device answers. +* +* @client: the i2c client +*/ +static int goodix_i2c_test (struct i2c_client *client) +{ +u8 test; +int ret; +int retry =0 ; + +while (retry++ <2 ) { + ret =goodix_i2c_read (client,GOODIX_REG_CONFIG_DATA , + &test,1 ); +if (ret >0 ) +return ret; + +GOODIX_ERROR ("GTP i2c test failed time %d." , retry); +msleep (20 ); + } +return ret; +} + +/** +* goodix_request_irq - Request the IRQ handler +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static int goodix_request_irq (struct goodix_ts_data *ts) +{ +int ret; + + ret = devm_request_threaded_irq(&ts->client->dev, + ts->client->irq, NULL,
drivers/input/touchscreen/goodix.c line 318
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ goodix_ts_irq_handler, + goodix_irq_flags[ts->int_trigger_type], + ts->client->name, + ts); +if (ret) { +GOODIX_ERROR ("Request IRQ failed! ERRNO:%d." , ret); +return -1 ; + } + +disable_irq_nosync (ts->client->irq);
Why nosync? And why do you need to disable? Yo just need to request it later, after you've done querying the device. And why a separate funcion for basically one statement?
Quoted 36 lines
drivers/input/touchscreen/goodix.c new file +36
-0+return 0 ; +} + +/** +* goodix_request_input_dev - Allocate, populate and register the input device +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static int goodix_request_input_dev (struct goodix_ts_data *ts) +{ +int ret; + + ts->input_dev =devm_input_allocate_device (&ts->client->dev); +if (ts->input_dev ==NULL ) { +GOODIX_ERROR ("Failed to allocate input device." ); +return -ENOMEM ; + } + + ts->input_dev->evbit[0 ] =BIT_MASK (EV_SYN ) | +BIT_MASK (EV_KEY ) | +BIT_MASK (EV_ABS ); + +input_set_abs_params (ts->input_dev,ABS_MT_POSITION_X ,0 , + ts->abs_x_max,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_POSITION_Y ,0 , + ts->abs_y_max,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_WIDTH_MAJOR ,0 ,255 ,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_TOUCH_MAJOR ,0 ,255 ,0 ,0 ); + +input_mt_init_slots (ts->input_dev,GOODIX_MAX_TOUCH , +INPUT_MT_DIRECT |INPUT_MT_DROP_UNUSED ); + + ts->input_dev->name = goodix_ts_name; + ts->input_dev->phys ="input/ts" ;
drivers/input/touchscreen/goodix.c line 364
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ ts->input_dev->id.bustype =BUS_I2C ; + ts->input_dev->id.vendor =0x0416 ; + ts->input_dev->id.product =0x1001 ; + ts->input_dev->id.version =10427 ; + + ret =input_register_device (ts->input_dev); +if (ret) { +GOODIX_ERROR ("Failed to register %s input device" , + ts->input_dev->name); +return -ENODEV ;
Why -ENODEV instead of ret?
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ } + +return 0 ; +} + +static int goodix_ts_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +int ret; +struct goodix_ts_data *ts;
drivers/input/touchscreen/goodix.c line 384
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+u16 version_info; + +GOODIX_INFO ("GTP I2C Address: 0x%02x" , client->addr); + +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) { +GOODIX_ERROR ("I2C check functionality failed." ); +return -ENODEV ; + } + ts =devm_kzalloc (&client->dev,sizeof (*ts),GFP_KERNEL ); +if (ts ==NULL ) {
if (!ts)
is a preferred form (by me at least).
drivers/input/touchscreen/goodix.c line 394
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+GOODIX_ERROR ("Alloc GFP_KERNEL memory failed." ); +return -ENOMEM ; + } + + ts->client = client; +i2c_set_clientdata (client, ts); + + ret =goodix_i2c_test (client); +if (ret <0 ) { + client->addr =0x5d ;
Umm, why? Let's trust board code/i2c core to configure the i2c device properly.
Quoted 24 lines
drivers/input/touchscreen/goodix.c new file +24
-0+ ret =goodix_i2c_test (client); +if (ret <0 ) { +GOODIX_ERROR ("I2C communication ERROR!" ); +return -ENODEV ; + } +GOODIX_INFO ("GTP I2C new Address: 0x%02x" , client->addr); + } + +goodix_read_config (ts); + + ret =goodix_request_input_dev (ts); +if (ret <0 ) { +GOODIX_ERROR ("GTP request input dev failed" ); +return ret; + } + + ret =goodix_request_irq (ts); +if (ret <0 ) +return ret; + + ret =goodix_read_version (client, &version_info); +if (ret <0 ) { +GOODIX_ERROR ("Read version failed." ); +return ret;
drivers/input/touchscreen/goodix.c line 428
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ } + +enable_irq (ts->client->irq); + +return 0 ; +} + +static const struct i2c_device_id goodix_ts_id[] = { + {"GDIX1001:00" ,0 }, + { }
Do we have to have this table?
Quoted 28 lines
drivers/input/touchscreen/goodix.c new file +24
-0+}; + +static const struct acpi_device_id goodix_acpi_match[] = { + {"GDIX1001" ,0 }, + { } +}; +MODULE_DEVICE_TABLE (acpi, goodix_acpi_match); + +static struct i2c_driver goodix_ts_driver = { + .probe = goodix_ts_probe, + .id_table = goodix_ts_id, + .driver = { + .name ="Goodix-TS" , + .owner =THIS_MODULE , + .acpi_match_table = goodix_acpi_match, + }, +}; + +module_i2c_driver (goodix_ts_driver); + +MODULE_AUTHOR ("Benjamin Tissoires <[email protected]>" ); +MODULE_AUTHOR ("Bastien Nocera <[email protected]>" ); +MODULE_DESCRIPTION ("Goodix touchscreen driver" ); +MODULE_LICENSE ("GPL v2" );Signature · 1 line
2.1.0
Thanks.
Signature · 1 line
Dmitry
Quoted 1 line · Dmitry Torokhov
Hi Bastien,
Hey Dmitry,
As a reference, Benjamin and I have a downstream/stand-alone repository for the driver, as we needed to greatly modify the original Android driver.
I'm making all the changes there before pushing them for review to you, which might make it easier for you to review.
See: https://github.com/hadess/gt9xx
<snip>
Quoted 4 lines
drivers/input/touchscreen/goodix.c line 53
Quoted 2 lines
drivers/input/touchscreen/goodix.c new file +2
-0+#define GOODIX_INFO(fmt, arg...) pr_info("<<-GTP-INFO->> "fmt"\n", ##arg) +#define GOODIX_ERROR(fmt, arg...) pr_err("<<-GTP-ERROR->> "fmt"\n", ##arg)Let's use standard
dev_xxx()
Done.
Quoted 11 lines
drivers/input/touchscreen/goodix.c line 61
Quoted 8 lines
drivers/input/touchscreen/goodix.c new file +8
-0+ +static const char *goodix_ts_name ="Goodix Capacitive TouchScreen" ; +static const unsigned long goodix_irq_flags[] = { +IRQ_TYPE_EDGE_RISING |IRQF_ONESHOT , +IRQ_TYPE_EDGE_FALLING |IRQF_ONESHOT , +IRQ_TYPE_LEVEL_LOW |IRQF_ONESHOT , +IRQ_TYPE_LEVEL_HIGH |IRQF_ONESHOT +};I'd rather you pulled out
IRQF_ONESHOTand specified it explicitly inrequest_threaded_irq().
Done.
Quoted 8 lines
Quoted 8 lines
drivers/input/touchscreen/goodix.c new file +8
-0+ +/** +* goodix_i2c_read - read data from a register of the i2c slave device. +* +* @client: i2c device. +* @reg: the register to read from. +* @buf: raw write data buffer. +* @len: length of the buffer to write
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 75
Quoted 6 lines
+ */
drivers/input/touchscreen/goodix.c new file +5
-0+static int goodix_i2c_read (struct i2c_client *client, +u16 reg,u8 *buf,int len) +{ +struct i2c_msg msgs[2 ]; +u8 wbuf[2 ] = { reg >>8 , reg &0xff };
cpu_to_be16()?
Fixed (hopefully)
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + msgs[0].flags = !I2C_M_RD;
I2C_M_RDis not a boolean, do not negate it.
Done.
Quoted 13 lines
drivers/input/touchscreen/goodix.c line 87
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ msgs[0 ].addr = client->addr; + msgs[0 ].len =2 ; + msgs[0 ].buf = wbuf; + + msgs[1 ].flags =I2C_M_RD ; + msgs[1 ].addr = client->addr; + msgs[1 ].len = len; + msgs[1 ].buf = buf; + +return i2c_transfer (client->adapter, msgs,2 );return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);
Quoted 1 line
I really need to get that
i2c_transfer_exact()going again.
Done.
Quoted 17 lines
Quoted 17 lines
drivers/input/touchscreen/goodix.c new file +17
-0+} + +/** +* goodix_i2c_write - write data to the i2c slave device. +* +* @client: i2c device. +* @reg: the register to read to. +* @buf: raw write data buffer. +* @len: length of the buffer to write +*/ +static int goodix_i2c_write (struct i2c_client *client, +u16 reg,u8 *buf,int len) +{ +struct i2c_msg msg; +int ret; +u8 *wbuf; +
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 110
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+ wbuf =kzalloc (len +2 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + wbuf[0 ] = reg >>8 ; + wbuf[1 ] = reg &0xFF ;Again
cpu_to_be16().
Done.
Quoted 5 lines
drivers/input/touchscreen/goodix.c line 113
Quoted 3 lines
drivers/input/touchscreen/goodix.c new file +3
-0+memcpy (&wbuf[2 ], buf, len); + + msg.flags = !I2C_M_RD ;Same here, not boolean.
Done.
<snip>
Quoted 23 lines
Quoted 23 lines
drivers/input/touchscreen/goodix.c new file +23
-0+/** +* goodix_ts_work_func - Process incoming IRQ +* +* @ts: our goodix_ts_data pointer +* +* Called when the IRQ is triggered. Read the current device state, and push +* the input events to the user space. +*/ +static void goodix_ts_work_func (struct goodix_ts_data *ts) +{ +u8 end_cmd[1 ] = {0 }; +u8 point_data[1 +8 *GOODIX_MAX_TOUCH +1 ]; +int touch_num; +int i; + + touch_num =goodix_ts_read_input_report (ts, point_data); +if (touch_num <0 ) + goto exit_work_func; + +for (i =0 ; i < touch_num; i++) +goodix_ts_parse_touch (ts, &point_data[1 +8 * i]); + +input_mt_sync_frame (ts->input_dev);
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 191
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+input_sync (ts->input_dev); + +exit_work_func: +if (goodix_i2c_write (ts->client, +GOODIX_READ_COOR_ADDR , end_cmd,1 ) <0 ) +GOODIX_INFO ("I2C write end_cmd error" );Why did you need to pull it out of
goodix_ts_irq_handler()?
True, moved now.
Quoted 1 line
Quoted 1 line
+}
<snip>
Quoted 27 lines
Quoted 14 lines
drivers/input/touchscreen/goodix.c new file +14
-0+/** +* goodix_read_version - Read goodix touchscreen version +* +* @client: the i2c client +* @version: output buffer containing the version on success +*/ +static int goodix_read_version (struct i2c_client *client,u16 *version) +{ +int ret; +int i; +u8 buf[6 ]; + + ret =goodix_i2c_read (client,GOODIX_REG_VERSION , buf,sizeof (buf)); +if (ret <0 ) {drivers/input/touchscreen/goodix.c line 265
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+GOODIX_ERROR ("GTP read version failed" ); +return ret; + } + +if (version) + *version =get_unaligned_le16 (&buf[4 ]); + +for (i =0 ; i <4 ; i++) { +if (!buf[i]) + buf[i] =0x30 ;buf[i] = '0';
Quoted 1 line
but what if they happen to have some other nonprintable garbage there?
True. Not sure what to do here, Benjamin?
Quoted 6 lines
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+ } +GOODIX_INFO ("IC VERSION: %c%c%c%c_%02x%02x" , + buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[5 ], buf[4 ]); + +return ret; +}
<snip>
Quoted 19 lines
Quoted 19 lines
drivers/input/touchscreen/goodix.c new file +19
-0+/** +* goodix_request_irq - Request the IRQ handler +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static int goodix_request_irq (struct goodix_ts_data *ts) +{ +int ret; + + ret =devm_request_threaded_irq (&ts->client->dev, + goodix_i2c_writets->client->irq,NULL , + goodix_ts_irq_handler, + goodix_irq_flags[ts->int_trigger_type], + ts->client->name, + ts); +if (ret) { +GOODIX_ERROR ("Request IRQ failed! ERRNO:%d." , ret);
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 318
Quoted 4 lines
drivers/input/touchscreen/goodix.c new file +4
-0+return -1 ; + } + +disable_irq_nosync (ts->client->irq);Why nosync? And why do you need to disable? Yo just need to request it later, after you've done querying the device. And why a separate funcion for basically one statement?
Removed, and merged into the calling function.
Quoted 40 lines
Quoted 40 lines
drivers/input/touchscreen/goodix.c new file +40
-0+return 0 ; +} + +/** +* goodix_request_input_dev - Allocate, populate and register the input device +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static int goodix_request_input_dev (struct goodix_ts_data *ts) +{ +int ret; + + ts->input_dev =devm_input_allocate_device (&ts->client->dev); +if (ts->input_dev ==NULL ) { +GOODIX_ERROR ("Failed to allocate input device." ); +return -ENOMEM ; + } + + ts->input_dev->evbit[0 ] =BIT_MASK (EV_SYN ) | +BIT_MASK (EV_KEY ) | +BIT_MASK (EV_ABS ); + +input_set_abs_params (ts->input_dev,ABS_MT_POSITION_X ,0 , + ts->abs_x_max,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_POSITION_Y ,0 , + ts->abs_y_max,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_WIDTH_MAJOR ,0 ,255 ,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_TOUCH_MAJOR ,0 ,255 ,0 ,0 ); + +input_mt_init_slots (ts->input_dev,GOODIX_MAX_TOUCH , +INPUT_MT_DIRECT |INPUT_MT_DROP_UNUSED ); + + ts->input_dev->name = goodix_ts_name; + ts->input_dev->phys ="input/ts" ; + ts->input_dev->id.bustype =BUS_I2C ; + ts->input_dev->id.vendor =0x0416 ; + ts->input_dev->id.product =0x1001 ; + ts->input_dev->id.version =10427 ;
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 364
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+ + ret =input_register_device (ts->input_dev); +if (ret) { +GOODIX_ERROR ("Failed to register %s input device" , + ts->input_dev->name); +return -ENODEV ;Why
-ENODEVinstead of ret?
Fixed.
Quoted 23 lines
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ } + +return 0 ; +} + +static int goodix_ts_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +int ret; +struct goodix_ts_data *ts;drivers/input/touchscreen/goodix.c line 384
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+u16 version_info; + +GOODIX_INFO ("GTP I2C Address: 0x%02x" , client->addr); + +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) { +GOODIX_ERROR ("I2C check functionality failed." ); +return -ENODEV ; + } + ts =devm_kzalloc (&client->dev,sizeof (*ts),GFP_KERNEL ); +if (ts ==NULL ) {if (!ts)
Quoted 1 line
is a preferred form (by me at least).
Fixed here and in goodix_request_input_dev().
Quoted 5 lines
Quoted 5 lines
drivers/input/touchscreen/goodix.c new file +5
-0+GOODIX_ERROR ("Alloc GFP_KERNEL memory failed." ); +return -ENOMEM ; + } + + ts->client = client;
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 394
Quoted 5 lines
drivers/input/touchscreen/goodix.c new file +5
-0+i2c_set_clientdata (client, ts); + + ret =goodix_i2c_test (client); +if (ret <0 ) { + client->addr =0x5d ;Umm, why? Let's trust board code/i2c core to configure the i2c device properly.
Done.
Quoted 28 lines
Quoted 28 lines
drivers/input/touchscreen/goodix.c new file +28
-0+ ret =goodix_i2c_test (client); +if (ret <0 ) { +GOODIX_ERROR ("I2C communication ERROR!" ); +return -ENODEV ; + } +GOODIX_INFO ("GTP I2C new Address: 0x%02x" , client->addr); + } + +goodix_read_config (ts); + + ret =goodix_request_input_dev (ts); +if (ret <0 ) { +GOODIX_ERROR ("GTP request input dev failed" ); +return ret; + } + + ret =goodix_request_irq (ts); +if (ret <0 ) +return ret; + + ret =goodix_read_version (client, &version_info); +if (ret <0 ) { +GOODIX_ERROR ("Read version failed." ); +return ret; + } + +enable_irq (ts->client->irq); +
Quoted 8 lines
drivers/input/touchscreen/goodix.c line 428
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+return 0 ; +} + +static const struct i2c_device_id goodix_ts_id[] = { + {"GDIX1001:00" ,0 }, + { }Do we have to have this table?
Yep, otherwise the driver won't detect the device. Benjamin tried to remove it as well ;)
<snip>
Quoted 2 lines
Thanks.
Thank YOU for the thorough review.
Hi Dmitry,
Thanks for the review. As a foreword, most of the things you mentioned were left over from the original driver that we did not spot. Anyway, enough of excuses, let's go in details.
Quoted 14 lines · Bastien Nocera
Quoted 1 line · Dmitry Torokhov
Hi Bastien,
Hey Dmitry,
As a reference, Benjamin and I have a downstream/stand-alone repository for the driver, as we needed to greatly modify the original Android driver.
I'm making all the changes there before pushing them for review to you, which might make it easier for you to review.
Quoted 7 lines
<snip>
Quoted 4 lines
drivers/input/touchscreen/goodix.c line 53
Quoted 2 lines
drivers/input/touchscreen/goodix.c new file +2
-0+#define GOODIX_INFO(fmt, arg...) pr_info("<<-GTP-INFO->> "fmt"\n", ##arg) +#define GOODIX_ERROR(fmt, arg...) pr_err("<<-GTP-ERROR->> "fmt"\n", ##arg)Let's use standard
dev_xxx()Done.
Yep. I was not sure about keeping that or not, but we can drop the defines entirely and rely on dev_xxx as you suggest.
Quoted 32 lines
Quoted 12 lines
drivers/input/touchscreen/goodix.c line 61
Quoted 9 lines
drivers/input/touchscreen/goodix.c new file +8
-0+ +static const char *goodix_ts_name ="Goodix Capacitive TouchScreen" ; +static const unsigned long goodix_irq_flags[] = { +IRQ_TYPE_EDGE_RISING |IRQF_ONESHOT , +IRQ_TYPE_EDGE_FALLING |IRQF_ONESHOT , +IRQ_TYPE_LEVEL_LOW |IRQF_ONESHOT , +IRQ_TYPE_LEVEL_HIGH |IRQF_ONESHOT +};I'd rather you pulled out
IRQF_ONESHOTand specified it explicitly inrequest_threaded_irq().Done.
Quoted 8 lines
Quoted 8 lines
drivers/input/touchscreen/goodix.c new file +8
-0+ +/** +* goodix_i2c_read - read data from a register of the i2c slave device. +* +* @client: i2c device. +* @reg: the register to read from. +* @buf: raw write data buffer. +* @len: length of the buffer to write Quoted 8 lines
drivers/input/touchscreen/goodix.c line 75
Quoted 6 lines
+ */
drivers/input/touchscreen/goodix.c new file +5
-0+static int goodix_i2c_read (struct i2c_client *client, +u16 reg,u8 *buf,int len) +{ +struct i2c_msg msgs[2 ]; +u8 wbuf[2 ] = { reg >>8 , reg &0xff };
cpu_to_be16()?
Quoted 1 line
Fixed (hopefully)
You should be more confident Bastien :)
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ + msgs[0].flags = !I2C_M_RD;
I2C_M_RDis not a boolean, do not negate it.
Ouch, I have seen that and forgot about it. We will set the flags to 0 directly.
Quoted 46 lines
Done.
Quoted 13 lines
drivers/input/touchscreen/goodix.c line 87
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ msgs[0 ].addr = client->addr; + msgs[0 ].len =2 ; + msgs[0 ].buf = wbuf; + + msgs[1 ].flags =I2C_M_RD ; + msgs[1 ].addr = client->addr; + msgs[1 ].len = len; + msgs[1 ].buf = buf; + +return i2c_transfer (client->adapter, msgs,2 );return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);Quoted 1 line
I really need to get that
i2c_transfer_exact()going again.Done.
Quoted 17 lines
Quoted 17 lines
drivers/input/touchscreen/goodix.c new file +17
-0+} + +/** +* goodix_i2c_write - write data to the i2c slave device. +* +* @client: i2c device. +* @reg: the register to read to. +* @buf: raw write data buffer. +* @len: length of the buffer to write +*/ +static int goodix_i2c_write (struct i2c_client *client, +u16 reg,u8 *buf,int len) +{ +struct i2c_msg msg; +int ret; +u8 *wbuf; +Quoted 8 lines
drivers/input/touchscreen/goodix.c line 110
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+ wbuf =kzalloc (len +2 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + wbuf[0 ] = reg >>8 ; + wbuf[1 ] = reg &0xFF ;Again
cpu_to_be16().
Quoted 8 lines
Done.
Quoted 5 lines
drivers/input/touchscreen/goodix.c line 113
Quoted 3 lines
drivers/input/touchscreen/goodix.c new file +3
-0+memcpy (&wbuf[2 ], buf, len); + + msg.flags = !I2C_M_RD ;Same here, not boolean.
sigh. sorry.
Quoted 34 lines
Done.
<snip>
Quoted 31 lines
Quoted 19 lines
drivers/input/touchscreen/goodix.c new file +19
-0+/** +* goodix_ts_work_func - Process incoming IRQ +* +* @ts: our goodix_ts_data pointer +* +* Called when the IRQ is triggered. Read the current device state, and push +* the input events to the user space. +*/ +static void goodix_ts_work_func (struct goodix_ts_data *ts) +{ +u8 end_cmd[1 ] = {0 }; +u8 point_data[1 +8 *GOODIX_MAX_TOUCH +1 ]; +int touch_num; +int i; + + touch_num =goodix_ts_read_input_report (ts, point_data); +if (touch_num <0 ) + goto exit_work_func; +drivers/input/touchscreen/goodix.c line 191
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+for (i =0 ; i < touch_num; i++) +goodix_ts_parse_touch (ts, &point_data[1 +8 * i]); + +input_mt_sync_frame (ts->input_dev); +input_sync (ts->input_dev); + +exit_work_func: +if (goodix_i2c_write (ts->client, +GOODIX_READ_COOR_ADDR , end_cmd,1 ) <0 ) +GOODIX_INFO ("I2C write end_cmd error" );Why did you need to pull it out of
goodix_ts_irq_handler()?
I can surely get a very good reason, but I will have to digg too much for it to be acceptable :)
We will drop goodix_ts_work_func() (I did not liked the name BTW) and merge the code in the irq handler directly.
Quoted 32 lines
True, moved now.
Quoted 1 line
Quoted 1 line
+}
<snip>
Quoted 27 lines
Quoted 14 lines
drivers/input/touchscreen/goodix.c new file +14
-0+/** +* goodix_read_version - Read goodix touchscreen version +* +* @client: the i2c client +* @version: output buffer containing the version on success +*/ +static int goodix_read_version (struct i2c_client *client,u16 *version) +{ +int ret; +int i; +u8 buf[6 ]; + + ret =goodix_i2c_read (client,GOODIX_REG_VERSION , buf,sizeof (buf)); +if (ret <0 ) {drivers/input/touchscreen/goodix.c line 265
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+GOODIX_ERROR ("GTP read version failed" ); +return ret; + } + +if (version) + *version =get_unaligned_le16 (&buf[4 ]); + +for (i =0 ; i <4 ; i++) { +if (!buf[i]) + buf[i] =0x30 ;buf[i] = '0';
Quoted 3 lines
Quoted 1 line
but what if they happen to have some other nonprintable garbage there?
True. Not sure what to do here, Benjamin?
So at first i was thinking at just using %*ph in the following message, but then I realized about the char part of it.
I guess we will just drop the previous for loop, and have the message as follow:dev_info(..., "IC VERSION: %6ph", buf);
Quoted 112 lines
Quoted 7 lines
Quoted 7 lines
drivers/input/touchscreen/goodix.c new file +6
-0+ } +GOODIX_INFO ("IC VERSION: %c%c%c%c_%02x%02x" , + buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[5 ], buf[4 ]); + +return ret; +}<snip>
Quoted 19 lines
Quoted 19 lines
drivers/input/touchscreen/goodix.c new file +19
-0+/** +* goodix_request_irq - Request the IRQ handler +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static int goodix_request_irq (struct goodix_ts_data *ts) +{ +int ret; + + ret =devm_request_threaded_irq (&ts->client->dev, + goodix_i2c_writets->client->irq,NULL , + goodix_ts_irq_handler, + goodix_irq_flags[ts->int_trigger_type], + ts->client->name, + ts); +if (ret) { +GOODIX_ERROR ("Request IRQ failed! ERRNO:%d." , ret);Quoted 8 lines
drivers/input/touchscreen/goodix.c line 318
Quoted 4 lines
drivers/input/touchscreen/goodix.c new file +4
-0+return -1 ; + } + +disable_irq_nosync (ts->client->irq);Why nosync? And why do you need to disable? Yo just need to request it later, after you've done querying the device. And why a separate funcion for basically one statement?
Removed, and merged into the calling function.
Quoted 40 lines
Quoted 40 lines
drivers/input/touchscreen/goodix.c new file +40
-0+return 0 ; +} + +/** +* goodix_request_input_dev - Allocate, populate and register the input device +* +* @ts: our goodix_ts_data pointer +* +* Must be called during probe +*/ +static int goodix_request_input_dev (struct goodix_ts_data *ts) +{ +int ret; + + ts->input_dev =devm_input_allocate_device (&ts->client->dev); +if (ts->input_dev ==NULL ) { +GOODIX_ERROR ("Failed to allocate input device." ); +return -ENOMEM ; + } + + ts->input_dev->evbit[0 ] =BIT_MASK (EV_SYN ) | +BIT_MASK (EV_KEY ) | +BIT_MASK (EV_ABS ); + +input_set_abs_params (ts->input_dev,ABS_MT_POSITION_X ,0 , + ts->abs_x_max,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_POSITION_Y ,0 , + ts->abs_y_max,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_WIDTH_MAJOR ,0 ,255 ,0 ,0 ); +input_set_abs_params (ts->input_dev,ABS_MT_TOUCH_MAJOR ,0 ,255 ,0 ,0 ); + +input_mt_init_slots (ts->input_dev,GOODIX_MAX_TOUCH , +INPUT_MT_DIRECT |INPUT_MT_DROP_UNUSED ); + + ts->input_dev->name = goodix_ts_name; + ts->input_dev->phys ="input/ts" ; + ts->input_dev->id.bustype =BUS_I2C ; + ts->input_dev->id.vendor =0x0416 ; + ts->input_dev->id.product =0x1001 ; + ts->input_dev->id.version =10427 ;Quoted 8 lines
drivers/input/touchscreen/goodix.c line 364
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+ + ret =input_register_device (ts->input_dev); +if (ret) { +GOODIX_ERROR ("Failed to register %s input device" , + ts->input_dev->name); +return -ENODEV ;Why
-ENODEVinstead of ret?Fixed.
Quoted 23 lines
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+ } + +return 0 ; +} + +static int goodix_ts_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +int ret; +struct goodix_ts_data *ts;drivers/input/touchscreen/goodix.c line 384
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+u16 version_info; + +GOODIX_INFO ("GTP I2C Address: 0x%02x" , client->addr); + +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) { +GOODIX_ERROR ("I2C check functionality failed." ); +return -ENODEV ; + } + ts =devm_kzalloc (&client->dev,sizeof (*ts),GFP_KERNEL ); +if (ts ==NULL ) {if (!ts)
Quoted 17 lines
Quoted 1 line
is a preferred form (by me at least).
Fixed here and in
goodix_request_input_dev().Quoted 13 lines
drivers/input/touchscreen/goodix.c line 394
Quoted 10 lines
drivers/input/touchscreen/goodix.c new file +10
-0+GOODIX_ERROR ("Alloc GFP_KERNEL memory failed." ); +return -ENOMEM ; + } + + ts->client = client; +i2c_set_clientdata (client, ts); + + ret =goodix_i2c_test (client); +if (ret <0 ) { + client->addr =0x5d ;Umm, why? Let's trust board code/i2c core to configure the i2c device properly.
This is also a left over from the original driver. They used to change the address in case of a reset of the device to check if it was in bootloader mode or not. We just missed this one.
Quoted 40 lines
Done.
Quoted 28 lines
Quoted 28 lines
drivers/input/touchscreen/goodix.c new file +28
-0+ ret =goodix_i2c_test (client); +if (ret <0 ) { +GOODIX_ERROR ("I2C communication ERROR!" ); +return -ENODEV ; + } +GOODIX_INFO ("GTP I2C new Address: 0x%02x" , client->addr); + } + +goodix_read_config (ts); + + ret =goodix_request_input_dev (ts); +if (ret <0 ) { +GOODIX_ERROR ("GTP request input dev failed" ); +return ret; + } + + ret =goodix_request_irq (ts); +if (ret <0 ) +return ret; + + ret =goodix_read_version (client, &version_info); +if (ret <0 ) { +GOODIX_ERROR ("Read version failed." ); +return ret; + } + +enable_irq (ts->client->irq); +Quoted 8 lines
drivers/input/touchscreen/goodix.c line 428
Quoted 6 lines
drivers/input/touchscreen/goodix.c new file +6
-0+return 0 ; +} + +static const struct i2c_device_id goodix_ts_id[] = { + {"GDIX1001:00" ,0 }, + { }Do we have to have this table?
Quoted 9 lines
Yep, otherwise the driver won't detect the device. Benjamin tried to remove it as well ;)
<snip>
Quoted 2 lines
Thanks.
Thank YOU for the thorough review.
Cheers,
Benjamin