From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com,
"Dario Binacchi" <dario.binacchi@amarulasolutions.com>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"Oliver Graute" <oliver.graute@kococonnector.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
linux-input@vger.kernel.org
Subject: [PATCH 9/9] Input: edt-ft5x06: Calculate points data length only once
Date: Sun, 2 Apr 2023 22:09:51 +0200 [thread overview]
Message-ID: <20230402200951.1032513-10-dario.binacchi@amarulasolutions.com> (raw)
In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com>
It is pointless and expensive to calculate data in the interrupt that
depends on the type of touchscreen, which is detected on the driver
probe and cannot then be changed.
So calculate the size of the data buffer on the driver probe, as well as
the data retrieval command, and then use them in the ISR.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 56 +++++++++++++-------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index fdb32e3591be..24ab9e9f5b21 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -135,6 +135,10 @@ struct edt_ft5x06_ts_data {
int offset_y;
int report_rate;
int max_support_points;
+ int point_len;
+ u8 tdata_cmd;
+ int tdata_len;
+ int tdata_offset;
char name[EDT_NAME_LEN];
char fw_version[EDT_NAME_LEN];
@@ -296,38 +300,13 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
{
struct edt_ft5x06_ts_data *tsdata = dev_id;
struct device *dev = &tsdata->client->dev;
- u8 cmd;
u8 rdbuf[63];
int i, type, x, y, id;
- int offset, tplen, datalen, crclen;
int error;
- switch (tsdata->version) {
- case EDT_M06:
- cmd = 0xf9; /* tell the controller to send touch data */
- offset = 5; /* where the actual touch data starts */
- tplen = 4; /* data comes in so called frames */
- crclen = 1; /* length of the crc data */
- break;
-
- case EDT_M09:
- case EDT_M12:
- case EV_FT:
- case GENERIC_FT:
- cmd = 0x0;
- offset = 3;
- tplen = 6;
- crclen = 0;
- break;
-
- default:
- goto out;
- }
-
memset(rdbuf, 0, sizeof(rdbuf));
- datalen = tplen * tsdata->max_support_points + offset + crclen;
-
- error = regmap_bulk_read(tsdata->regmap, cmd, rdbuf, datalen);
+ error = regmap_bulk_read(tsdata->regmap, tsdata->tdata_cmd, rdbuf,
+ tsdata->tdata_len);
if (error) {
dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n",
error);
@@ -335,7 +314,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
}
for (i = 0; i < tsdata->max_support_points; i++) {
- u8 *buf = &rdbuf[i * tplen + offset];
+ u8 *buf = &rdbuf[i * tsdata->point_len + tsdata->tdata_offset];
type = buf[0] >> 6;
/* ignore Reserved events */
@@ -1071,6 +1050,26 @@ static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata)
}
}
+static void edt_ft5x06_ts_set_tdata_parameters(struct edt_ft5x06_ts_data *tsdata)
+{
+ int crclen;
+
+ if (tsdata->version == EDT_M06) {
+ tsdata->tdata_cmd = 0xf9;
+ tsdata->tdata_offset = 5;
+ tsdata->point_len = 4;
+ crclen = 1;
+ } else {
+ tsdata->tdata_cmd = 0x0;
+ tsdata->tdata_offset = 3;
+ tsdata->point_len = 6;
+ crclen = 0;
+ }
+
+ tsdata->tdata_len = tsdata->point_len * tsdata->max_support_points +
+ tsdata->tdata_offset + crclen;
+}
+
static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
{
struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
@@ -1274,6 +1273,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client)
*/
regmap_read(tsdata->regmap, 0x00, &val);
+ edt_ft5x06_ts_set_tdata_parameters(tsdata);
edt_ft5x06_ts_set_regs(tsdata);
edt_ft5x06_ts_get_defaults(&client->dev, tsdata);
edt_ft5x06_ts_get_parameters(tsdata);
--
2.32.0
next prev parent reply other threads:[~2023-04-02 20:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-02 20:09 [PATCH 0/9] Input: edt-ft5x06 - convert to use regmap API Dario Binacchi
2023-04-02 20:09 ` [PATCH 1/9] Input: edt-ft5x06 - fix indentation Dario Binacchi
2023-04-02 20:09 ` [PATCH 2/9] Input: edt-ft5x06 - remove unnecessary blank lines Dario Binacchi
2023-04-02 20:09 ` [PATCH 3/9] Input: edt-ft5x06 - add spaces to ensure format specification Dario Binacchi
2023-04-02 20:09 ` [PATCH 4/9] Input: edt-ft5x06 - don't recalculate the CRC Dario Binacchi
2023-04-02 20:09 ` [PATCH 5/9] Input: edt-ft5x06 - remove code duplication Dario Binacchi
2023-04-02 20:09 ` [PATCH 6/9] Input: edt-ft5x06 - don't print error messages with dev_dbg() Dario Binacchi
2023-04-02 20:09 ` [PATCH 7/9] Input: edt-ft5x06 - convert to use regmap API Dario Binacchi
2023-04-02 20:09 ` [PATCH 8/9] Input: edt-ft5x06 - unify the crc check Dario Binacchi
2023-04-02 20:09 ` Dario Binacchi [this message]
2023-04-03 4:40 ` [PATCH 0/9] Input: edt-ft5x06 - convert to use regmap API Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230402200951.1032513-10-dario.binacchi@amarulasolutions.com \
--to=dario.binacchi@amarulasolutions.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-amarula@amarulasolutions.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@amarulasolutions.com \
--cc=oliver.graute@kococonnector.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®