Skip to contentSkip to conversation

Input: ili210x - add resolution to chip operations structure

PATCH Applied Sven Van Asbroeck 2 participants 4 messages Nov 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Input: ili210x - add resolution to chip operations structure

Optionally allow the touch screen resolution to be set by adding it to the chip operations structure. If it is omitted (left zero), the resolution defaults to 64K. Which is the previously hard-coded value.

Set the ili2117 resolution to 2048, as indicated in its datasheet.

Tree: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next

---
 drivers/input/touchscreen/ili210x.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/ili210x.c +6 -2
index a6feae5ce887..3b8e24815a1f 100644
@@ -31,6 +31,7 @@ struct ili2xxx_chip {
 				 unsigned int *x, unsigned int *y);
 	bool (*continue_polling)(const u8 *data, bool touch);
 	unsigned int max_touches;
+	unsigned int resolution;
 };
 
 struct ili210x {
@@ -160,6 +161,7 @@ static const struct ili2xxx_chip ili211x_chip = {
 	.parse_touch_data	= ili211x_touchdata_to_coords,
 	.continue_polling	= ili211x_decline_polling,
 	.max_touches		= 10,
+	.resolution		= 2048,
 };
 
 static int ili251x_read_reg(struct i2c_client *client,
@@ -336,6 +338,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
 	struct gpio_desc *reset_gpio;
 	struct input_dev *input;
 	int error;
+	unsigned int max_xy;
 
 	dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver");
 
@@ -386,8 +389,9 @@ static int ili210x_i2c_probe(struct i2c_client *client,
 	input->id.bustype = BUS_I2C;
 
 	/* Multi touch */
-	input_set_abs_params(input, ABS_MT_POSITION_X, 0, 0xffff, 0, 0);
-	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 0xffff, 0, 0);
+	max_xy = (chip->resolution ?: SZ_64K) - 1;
+	input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0);
+	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_xy, 0, 0);
 	touchscreen_parse_properties(input, true, &priv->prop);
 
 	error = input_mt_init_slots(input, priv->chip->max_touches,
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 2/2 Input: ili210x - optionally show calibrate sysfs attribute

Only show the 'calibrate' sysfs attribute on chip flavours which support calibration by writing to a calibration register.

Do this by adding a flag to the chip operations structure.

Tree: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next

---
 drivers/input/touchscreen/ili210x.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/input/touchscreen/ili210x.c +14 -0
index 3b8e24815a1f..b0454cdacf38 100644
@@ -32,6 +32,7 @@ struct ili2xxx_chip {
 	bool (*continue_polling)(const u8 *data, bool touch);
 	unsigned int max_touches;
 	unsigned int resolution;
+	bool has_calibrate_reg;
 };
 
 struct ili210x {
@@ -102,6 +103,7 @@ static const struct ili2xxx_chip ili210x_chip = {
 	.parse_touch_data	= ili210x_touchdata_to_coords,
 	.continue_polling	= ili210x_check_continue_polling,
 	.max_touches		= 2,
+	.has_calibrate_reg	= true,
 };
 
 static int ili211x_read_touch_data(struct i2c_client *client, u8 *data)
@@ -227,6 +229,7 @@ static const struct ili2xxx_chip ili251x_chip = {
 	.parse_touch_data	= ili251x_touchdata_to_coords,
 	.continue_polling	= ili251x_check_continue_polling,
 	.max_touches		= 10,
+	.has_calibrate_reg	= true,
 };
 
 static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
@@ -310,8 +313,19 @@ static struct attribute *ili210x_attributes[] = {
 	NULL,
 };
 
+static umode_t ili210x_calibrate_visible(struct kobject *kobj,
+					  struct attribute *attr, int index)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct i2c_client *client = to_i2c_client(dev);
+	struct ili210x *priv = i2c_get_clientdata(client);
+
+	return priv->chip->has_calibrate_reg;
+}
+
 static const struct attribute_group ili210x_attr_group = {
 	.attrs = ili210x_attributes,
+	.is_visible = ili210x_calibrate_visible,
 };
 
 static void ili210x_power_down(void *data)
Signature · 1 line
2.17.1
maintainer Applied
#2 lore raw

Re: [PATCH v2 2/2] Input: ili210x - optionally show calibrate sysfs attribute

Quoted 5 lines · Sven Van Asbroeck

Only show the 'calibrate' sysfs attribute on chip flavours which support calibration by writing to a calibration register.

Do this by adding a flag to the chip operations structure.

Quoted 7 lines

Tree: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next

Applied, thank you.

Quoted 55 lines
---
 drivers/input/touchscreen/ili210x.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/input/touchscreen/ili210x.c +14 -0
index 3b8e24815a1f..b0454cdacf38 100644
@@ -32,6 +32,7 @@ struct ili2xxx_chip {
 	bool (*continue_polling)(const u8 *data, bool touch);
 	unsigned int max_touches;
 	unsigned int resolution;
+	bool has_calibrate_reg;
 };
 
 struct ili210x {
@@ -102,6 +103,7 @@ static const struct ili2xxx_chip ili210x_chip = {
 	.parse_touch_data	= ili210x_touchdata_to_coords,
 	.continue_polling	= ili210x_check_continue_polling,
 	.max_touches		= 2,
+	.has_calibrate_reg	= true,
 };
 
 static int ili211x_read_touch_data(struct i2c_client *client, u8 *data)
@@ -227,6 +229,7 @@ static const struct ili2xxx_chip ili251x_chip = {
 	.parse_touch_data	= ili251x_touchdata_to_coords,
 	.continue_polling	= ili251x_check_continue_polling,
 	.max_touches		= 10,
+	.has_calibrate_reg	= true,
 };
 
 static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
@@ -310,8 +313,19 @@ static struct attribute *ili210x_attributes[] = {
 	NULL,
 };
 
+static umode_t ili210x_calibrate_visible(struct kobject *kobj,
+					  struct attribute *attr, int index)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct i2c_client *client = to_i2c_client(dev);
+	struct ili210x *priv = i2c_get_clientdata(client);
+
+	return priv->chip->has_calibrate_reg;
+}
+
 static const struct attribute_group ili210x_attr_group = {
 	.attrs = ili210x_attributes,
+	.is_visible = ili210x_calibrate_visible,
 };
 
 static void ili210x_power_down(void *data)
Signature · 1 line
2.17.1
Signature · 1 line
Dmitry
maintainer Applied
#3 lore raw
In reply to Sven Van Asbroeck
Quoted 47 lines · Sven Van Asbroeck

Optionally allow the touch screen resolution to be set by adding it to the chip operations structure. If it is omitted (left zero), the resolution defaults to 64K. Which is the previously hard-coded value.

Set the ili2117 resolution to 2048, as indicated in its datasheet.

Tree: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next

---
 drivers/input/touchscreen/ili210x.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/ili210x.c +3 -0
index a6feae5ce887..3b8e24815a1f 100644
@@ -31,6 +31,7 @@ struct ili2xxx_chip {
 				 unsigned int *x, unsigned int *y);
 	bool (*continue_polling)(const u8 *data, bool touch);
 	unsigned int max_touches;
+	unsigned int resolution;
 };
 
 struct ili210x {
@@ -160,6 +161,7 @@ static const struct ili2xxx_chip ili211x_chip = {
 	.parse_touch_data	= ili211x_touchdata_to_coords,
 	.continue_polling	= ili211x_decline_polling,
 	.max_touches		= 10,
+	.resolution		= 2048,
 };
 
 static int ili251x_read_reg(struct i2c_client *client,
@@ -336,6 +338,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
 	struct gpio_desc *reset_gpio;
 	struct input_dev *input;
 	int error;
+	unsigned int max_xy;
 
 	dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver");
 

drivers/input/touchscreen/ili210x.c static int ili210x_i2c_probe(struct i2c_client *client, · line 392

Quoted 6 lines
drivers/input/touchscreen/ili210x.c +1 -2
@@ -386,8 +389,9 @@ static int ili210x_i2c_probe(struct i2c_client *client,
 	input->id.bustype = BUS_I2C;
 
 	/* Multi touch */
-	input_set_abs_params(input, ABS_MT_POSITION_X, 0, 0xffff, 0, 0);
-	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 0xffff, 0, 0);
+	max_xy = (chip->resolution ?: SZ_64K) - 1;

I had to add linux/sizes.h for this.

Applied, thank you.

Signature · 1 line
Dmitry