* [PATCH] Input: st1232 - add support resolution reading
@ 2020-10-30 9:33 Andrej Valek
2020-11-02 18:05 ` kernel test robot
0 siblings, 1 reply; 6+ messages in thread
From: Andrej Valek @ 2020-10-30 9:33 UTC (permalink / raw)
To: chinyeow.sim.xt, martin.kepplinger, dmitry.torokhov
Cc: linux-input, linux-kernel, Andrej Valek
Hard-coding resolution for st1633 device was wrong. Some of LCDs like
YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But
the resolution is not 320x480 as was hard-coded.
Add new function which reads correct resolution directly from register.
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
---
drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++---------
1 file changed, 36 insertions(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 63b29c7279e29..ea74c4ca7698b 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -26,15 +26,14 @@
#define ST1232_TS_NAME "st1232-ts"
#define ST1633_TS_NAME "st1633-ts"
+#define REG_XY_RESOLUTION 0x04
+#define REG_XY_COORDINATES 0x12
#define ST_TS_MAX_FINGERS 10
struct st_chip_info {
bool have_z;
- u16 max_x;
- u16 max_y;
u16 max_area;
u16 max_fingers;
- u8 start_reg;
};
struct st1232_ts_data {
@@ -48,15 +47,14 @@ struct st1232_ts_data {
u8 *read_buf;
};
-static int st1232_ts_read_data(struct st1232_ts_data *ts)
+static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
{
struct i2c_client *client = ts->client;
- u8 start_reg = ts->chip_info->start_reg;
struct i2c_msg msg[] = {
{
.addr = client->addr,
- .len = sizeof(start_reg),
- .buf = &start_reg,
+ .len = sizeof(reg),
+ .buf = ®,
},
{
.addr = client->addr,
@@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
return 0;
}
+static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
+ u16 *max_y)
+{
+ u8 *buf;
+ int error;
+
+ /* select resolution register */
+ error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
+ if (error)
+ return error;
+
+ buf = ts->read_buf;
+
+ *max_x = ((buf[0] & 0x0070) << 4) | buf[1];
+ *max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+
+ return 0;
+}
+
static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
{
struct input_dev *input = ts->input_dev;
@@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
int count;
int error;
- error = st1232_ts_read_data(ts);
+ error = st1232_ts_read_data(ts, REG_XY_COORDINATES);
if (error)
goto out;
@@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data)
static const struct st_chip_info st1232_chip_info = {
.have_z = true,
- .max_x = 0x31f, /* 800 - 1 */
- .max_y = 0x1df, /* 480 -1 */
.max_area = 0xff,
.max_fingers = 2,
- .start_reg = 0x12,
};
static const struct st_chip_info st1633_chip_info = {
.have_z = false,
- .max_x = 0x13f, /* 320 - 1 */
- .max_y = 0x1df, /* 480 -1 */
.max_area = 0x00,
.max_fingers = 5,
- .start_reg = 0x12,
};
static int st1232_ts_probe(struct i2c_client *client,
@@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client,
const struct st_chip_info *match;
struct st1232_ts_data *ts;
struct input_dev *input_dev;
+ u16 max_x, max_y;
int error;
match = device_get_match_data(&client->dev);
@@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client,
input_dev->name = "st1232-touchscreen";
input_dev->id.bustype = BUS_I2C;
+ /* read resolution from chip */
+ error = st1232_ts_read_resolution(ts, &max_x, &max_y);
+ if (error) {
+ dev_err(&client->dev,
+ "Failed to read resolution: %d\n", error);
+ return error;
+ }
+
if (ts->chip_info->have_z)
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
ts->chip_info->max_area, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_X,
- 0, ts->chip_info->max_x, 0, 0);
+ 0, max_x, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
- 0, ts->chip_info->max_y, 0, 0);
+ 0, max_y, 0, 0);
touchscreen_parse_properties(input_dev, true, &ts->prop);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Input: st1232 - add support resolution reading
2020-10-30 9:33 [PATCH] Input: st1232 - add support resolution reading Andrej Valek
@ 2020-11-02 18:05 ` kernel test robot
2020-11-03 7:39 ` [PATCH v2] " Andrej Valek
0 siblings, 1 reply; 6+ messages in thread
From: kernel test robot @ 2020-11-02 18:05 UTC (permalink / raw)
To: Andrej Valek, chinyeow.sim.xt, martin.kepplinger, dmitry.torokhov
Cc: kbuild-all, linux-input, linux-kernel, Andrej Valek
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
Hi Andrej,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on input/next]
[also build test WARNING on v5.10-rc2 next-20201102]
[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/Andrej-Valek/Input-st1232-add-support-resolution-reading/20201030-173555
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: i386-randconfig-m021-20201102 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
smatch warnings:
drivers/input/touchscreen/st1232.c:86 st1232_ts_read_resolution() warn: inconsistent indenting
vim +86 drivers/input/touchscreen/st1232.c
74
75 static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
76 u16 *max_y)
77 {
78 u8 *buf;
79 int error;
80
81 /* select resolution register */
82 error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
83 if (error)
84 return error;
85
> 86 buf = ts->read_buf;
87
88 *max_x = ((buf[0] & 0x0070) << 4) | buf[1];
89 *max_y = ((buf[0] & 0x0007) << 8) | buf[2];
90
91 return 0;
92 }
93
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35484 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] Input: st1232 - add support resolution reading
2020-11-02 18:05 ` kernel test robot
@ 2020-11-03 7:39 ` Andrej Valek
2020-11-12 1:53 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Andrej Valek @ 2020-11-03 7:39 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-kernel, kbuild-all, Andrej Valek
Hard-coding resolution for st1633 device was wrong. Some of LCDs like
YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But
the resolution is not 320x480 as was hard-coded.
Add new function which reads correct resolution directly from register.
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
---
drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++---------
1 file changed, 36 insertions(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 63b29c7279e29..1b4b139c85330 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -26,15 +26,14 @@
#define ST1232_TS_NAME "st1232-ts"
#define ST1633_TS_NAME "st1633-ts"
+#define REG_XY_RESOLUTION 0x04
+#define REG_XY_COORDINATES 0x12
#define ST_TS_MAX_FINGERS 10
struct st_chip_info {
bool have_z;
- u16 max_x;
- u16 max_y;
u16 max_area;
u16 max_fingers;
- u8 start_reg;
};
struct st1232_ts_data {
@@ -48,15 +47,14 @@ struct st1232_ts_data {
u8 *read_buf;
};
-static int st1232_ts_read_data(struct st1232_ts_data *ts)
+static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
{
struct i2c_client *client = ts->client;
- u8 start_reg = ts->chip_info->start_reg;
struct i2c_msg msg[] = {
{
.addr = client->addr,
- .len = sizeof(start_reg),
- .buf = &start_reg,
+ .len = sizeof(reg),
+ .buf = ®,
},
{
.addr = client->addr,
@@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
return 0;
}
+static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
+ u16 *max_y)
+{
+ u8 *buf;
+ int error;
+
+ /* select resolution register */
+ error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
+ if (error)
+ return error;
+
+ buf = ts->read_buf;
+
+ *max_x = ((buf[0] & 0x0070) << 4) | buf[1];
+ *max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+
+ return 0;
+}
+
static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
{
struct input_dev *input = ts->input_dev;
@@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
int count;
int error;
- error = st1232_ts_read_data(ts);
+ error = st1232_ts_read_data(ts, REG_XY_COORDINATES);
if (error)
goto out;
@@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data)
static const struct st_chip_info st1232_chip_info = {
.have_z = true,
- .max_x = 0x31f, /* 800 - 1 */
- .max_y = 0x1df, /* 480 -1 */
.max_area = 0xff,
.max_fingers = 2,
- .start_reg = 0x12,
};
static const struct st_chip_info st1633_chip_info = {
.have_z = false,
- .max_x = 0x13f, /* 320 - 1 */
- .max_y = 0x1df, /* 480 -1 */
.max_area = 0x00,
.max_fingers = 5,
- .start_reg = 0x12,
};
static int st1232_ts_probe(struct i2c_client *client,
@@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client,
const struct st_chip_info *match;
struct st1232_ts_data *ts;
struct input_dev *input_dev;
+ u16 max_x, max_y;
int error;
match = device_get_match_data(&client->dev);
@@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client,
input_dev->name = "st1232-touchscreen";
input_dev->id.bustype = BUS_I2C;
+ /* read resolution from chip */
+ error = st1232_ts_read_resolution(ts, &max_x, &max_y);
+ if (error) {
+ dev_err(&client->dev,
+ "Failed to read resolution: %d\n", error);
+ return error;
+ }
+
if (ts->chip_info->have_z)
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
ts->chip_info->max_area, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_X,
- 0, ts->chip_info->max_x, 0, 0);
+ 0, max_x, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
- 0, ts->chip_info->max_y, 0, 0);
+ 0, max_y, 0, 0);
touchscreen_parse_properties(input_dev, true, &ts->prop);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] Input: st1232 - add support resolution reading
2020-11-03 7:39 ` [PATCH v2] " Andrej Valek
@ 2020-11-12 1:53 ` Dmitry Torokhov
2020-11-12 8:11 ` Valek, Andrej
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2020-11-12 1:53 UTC (permalink / raw)
To: Andrej Valek; +Cc: linux-input, linux-kernel, kbuild-all
On Tue, Nov 03, 2020 at 08:39:49AM +0100, Andrej Valek wrote:
> Hard-coding resolution for st1633 device was wrong. Some of LCDs like
> YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But
> the resolution is not 320x480 as was hard-coded.
> Add new function which reads correct resolution directly from register.
>
> Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2] Input: st1232 - add support resolution reading
2020-11-12 1:53 ` Dmitry Torokhov
@ 2020-11-12 8:11 ` Valek, Andrej
2020-11-20 7:17 ` Valek, Andrej
0 siblings, 1 reply; 6+ messages in thread
From: Valek, Andrej @ 2020-11-12 8:11 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, kbuild-all
Hello Dimitry,
Thank you for that.
What about the other patches?
Regards,
Andrej
> -----Original Message-----
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Sent: Thursday, November 12, 2020 2:54 AM
> To: Valek, Andrej (ADV D EU SK SI-BP1) <andrej.valek@siemens.com>
> Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; kbuild-all@lists.01.org
> Subject: Re: [PATCH v2] Input: st1232 - add support resolution reading
>
> On Tue, Nov 03, 2020 at 08:39:49AM +0100, Andrej Valek wrote:
>> Hard-coding resolution for st1633 device was wrong. Some of LCDs like
>> YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too.
>> But the resolution is not 320x480 as was hard-coded.
>> Add new function which reads correct resolution directly from register.
>>
>> Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
>
> Applied, thank you.
>
> --
> Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2] Input: st1232 - add support resolution reading
2020-11-12 8:11 ` Valek, Andrej
@ 2020-11-20 7:17 ` Valek, Andrej
0 siblings, 0 replies; 6+ messages in thread
From: Valek, Andrej @ 2020-11-20 7:17 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, kbuild-all
Hello again Dimitry,
I haven't received any response yet, so I will ask again.
I would like to know, the current status about my other patches for goodix and atmel input.
Are there any problems, or what I have to do, to be applied?
Thanks,
Andrej
> Hello Dimitry,
>
> Thank you for that.
> What about the other patches?
>
> Regards,
> Andrej
>
>> -----Original Message-----
>> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Sent: Thursday, November 12, 2020 2:54 AM>
>> To: Valek, Andrej (ADV D EU SK SI-BP1) <andrej.valek@siemens.com>
>> Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org;
>> kbuild-all@lists.01.org
>> Subject: Re: [PATCH v2] Input: st1232 - add support resolution reading
>>
>> On Tue, Nov 03, 2020 at 08:39:49AM +0100, Andrej Valek wrote:
>>> Hard-coding resolution for st1633 device was wrong. Some of LCDs like
>>> YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too.
>>> But the resolution is not 320x480 as was hard-coded.
>>> Add new function which reads correct resolution directly from register.
>>>
>>> Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
>>
>> Applied, thank you.
>>
> --
>> Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-20 7:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 9:33 [PATCH] Input: st1232 - add support resolution reading Andrej Valek
2020-11-02 18:05 ` kernel test robot
2020-11-03 7:39 ` [PATCH v2] " Andrej Valek
2020-11-12 1:53 ` Dmitry Torokhov
2020-11-12 8:11 ` Valek, Andrej
2020-11-20 7:17 ` Valek, Andrej
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).