linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Marco Felsch <m.felsch@pengutronix.de>,
	Oliver Graute <oliver.graute@kococonnector.com>,
	linux-input@vger.kernel.org
Subject: [RESEND PATCH v4 3/6] Input: edt-ft5x06 - set report rate by dts property
Date: Tue,  7 Jun 2022 11:55:53 +0200	[thread overview]
Message-ID: <20220607095556.1034338-4-dario.binacchi@amarulasolutions.com> (raw)
In-Reply-To: <20220607095556.1034338-1-dario.binacchi@amarulasolutions.com>

It allows to change the M06/M12 default scan rate on driver probing.

Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

---

(no changes since v3)

Changes in v3:
- Check the lower and upper limits of the report-rate-hz value
- Convert the M06 report-rate-hz value

 drivers/input/touchscreen/edt-ft5x06.c | 30 ++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 77f061af5c61..843e8b0522f7 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -1084,6 +1084,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	struct input_dev *input;
 	unsigned long irq_flags;
 	int error;
+	u32 report_rate;
 	char fw_version[EDT_NAME_LEN];
 
 	dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
@@ -1213,6 +1214,35 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	edt_ft5x06_ts_get_defaults(&client->dev, tsdata);
 	edt_ft5x06_ts_get_parameters(tsdata);
 
+	if (tsdata->reg_addr.reg_report_rate != NO_REGISTER &&
+	    !of_property_read_u32(client->dev.of_node, "report-rate-hz",
+				  &report_rate)) {
+		tsdata->report_rate = report_rate;
+		if (tsdata->version == EDT_M06) {
+			if (report_rate < 30)
+				report_rate = 30;
+			else if (report_rate > 140)
+				report_rate = 140;
+		} else if (report_rate < 1) {
+			report_rate = 1;
+		} else if (report_rate > 255)
+			report_rate = 255;
+
+		if (report_rate != tsdata->report_rate)
+			dev_warn(&client->dev,
+				 "report-rate %dHz is unsupported, use %dHz\n",
+				 tsdata->report_rate, report_rate);
+
+		if (tsdata->version == EDT_M06)
+			report_rate /= 10;
+
+		tsdata->report_rate = report_rate;
+
+		edt_ft5x06_register_write(tsdata,
+					  tsdata->reg_addr.reg_report_rate,
+					  tsdata->report_rate);
+	}
+
 	dev_dbg(&client->dev,
 		"Model \"%s\", Rev. \"%s\", %dx%d sensors\n",
 		tsdata->name, fw_version, tsdata->num_x, tsdata->num_y);
-- 
2.32.0


  parent reply	other threads:[~2022-06-07  9:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07  9:55 [RESEND PATCH v4 0/6] Input: edt-ft5x06 - Improve configuration Dario Binacchi
2022-06-07  9:55 ` [RESEND PATCH v4 1/6] dt-bindings: input: touchscreen: edt-ft5x06: add report-rate-hz Dario Binacchi
2022-06-07  9:55 ` [RESEND PATCH v4 2/6] Input: edt-ft5x06 - get/set M12 report rate by sysfs Dario Binacchi
2022-06-07  9:55 ` Dario Binacchi [this message]
2022-06-07  9:55 ` [RESEND PATCH v4 4/6] Input: edt-ft5x06 - show model name " Dario Binacchi
2022-06-07  9:55 ` [RESEND PATCH v4 5/6] Input: edt-ft5x06 - show firmware version " Dario Binacchi
2022-06-07  9:55 ` [RESEND PATCH v4 6/6] Input: edt-ft5x06 - show crc and header errors " Dario Binacchi
  -- strict thread matches above, loose matches on Subject: below --
2022-06-21 12:39 [RESEND PATCH v4 0/6] Input: edt-ft5x06 - Improve configuration Dario Binacchi
2022-06-21 12:39 ` [RESEND PATCH v4 3/6] Input: edt-ft5x06 - set report rate by dts property Dario Binacchi
2022-06-29  5:04   ` Dmitry Torokhov
2022-05-05 15:56 [RESEND PATCH v4 0/6] Input: edt-ft5x06 - Improve configuration Dario Binacchi
2022-05-05 15:56 ` [RESEND PATCH v4 3/6] Input: edt-ft5x06 - set report rate by dts property Dario Binacchi
2022-04-21 18:59 [RESEND PATCH v4 0/6] Input: edt-ft5x06 - Improve configuration Dario Binacchi
2022-04-21 19:00 ` [RESEND PATCH v4 3/6] Input: edt-ft5x06 - set report rate by dts property Dario Binacchi

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=20220607095556.1034338-4-dario.binacchi@amarulasolutions.com \
    --to=dario.binacchi@amarulasolutions.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=michael@amarulasolutions.com \
    --cc=oliver.graute@kococonnector.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;
as well as URLs for NNTP newsgroup(s).