It allows to change the M06/M12 default scan rate on driver probing.
Co-developed-by: Michael Trimarchi <[email protected]>
Signed-off-by: Michael Trimarchi <[email protected]>
Signed-off-by: Dario Binacchi <[email protected]>
---
(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
Hi Dario,
On Tue, Jun 21, 2022 at 02:39:34PM +0200, Dario Binacchi wrote:
> It allows to change the M06/M12 default scan rate on driver probing.
>
> Co-developed-by: Michael Trimarchi <[email protected]>
> Signed-off-by: Michael Trimarchi <[email protected]>
> Signed-off-by: Dario Binacchi <[email protected]>
>
> ---
>
> (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",
Unless there is a strong reason to use of-specific version of properties
API, generic device property API is preferred. I changed this to
device_property_read_u32().
> + &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;
We have a nice macro clamp_val() for this.
> + } else if (report_rate < 1) {
> + report_rate = 1;
> + } else if (report_rate > 255)
> + report_rate = 255;
Same here. I made the change and applied.
> +
> + 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
>
Thanks.
--
Dmitry