Skip to contentSkip to conversation

Input: of_touchscreen - always issue warning if axis is not set up

PATCH In review Dmitry Torokhov 2 participants 10 messages Jul 7, 2015 – Jul 10, 2015

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/3 Input: of_touchscreen - always issue warning if axis is not set up

Do issue warning about axis that is present in device tree but not specified by the driver even in case of multi-touch axis as callers now tell us if they expect multi-touch data or not.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +3 -7
index 806cd0a..759cf4b 100644
@@ -39,13 +39,9 @@ static void touchscreen_set_params(struct input_dev *dev,
 	struct input_absinfo *absinfo;
 
 	if (!test_bit(axis, dev->absbit)) {
-		/*
-		 * Emit a warning only if the axis is not a multitouch
-		 * axis, which might not be set by the driver.
-		 */
-		if (!input_is_mt_axis(axis))
-			dev_warn(&dev->dev,
-				 "DT specifies parameters but the axis is not set up\n");
+		dev_warn(&dev->dev,
+			 "DT specifies parameters but the axis %lu is not set up\n",
+			 axis);
 		return;
 	}
 
Signature · 1 line
2.4.3.573.g4eafbef
author maintainer
#1 lore raw

PATCH 2/3 Input: of_touchscreen - fix setting max values on X/Y axis

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +6 -4
index 759cf4b..50bc0f2 100644
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,
 						&maximum) |
 		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-x",
 						input_abs_get_fuzz(dev, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
 	axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-y",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,
 						&maximum) |
 		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-y",
 						input_abs_get_fuzz(dev, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
 	axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-max-pressure",
Signature · 1 line
2.4.3.573.g4eafbef
#2 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Hi Dmitry,

Quoted 14 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
  drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 6 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
  	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
  	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

Quoted 14 lines
drivers/input/touchscreen/of_touchscreen.c +3 -2
  						&maximum) |
  		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-x",
  						input_abs_get_fuzz(dev, axis),
  						&fuzz);
  	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
  	axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
  	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-y",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 95

Quoted 10 lines
drivers/input/touchscreen/of_touchscreen.c +1 -1
  						&maximum) |
  		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-y",
  						input_abs_get_fuzz(dev, axis),
  						&fuzz);
  	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
  	axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
  	data_present = touchscreen_get_prop_u32(np, "touchscreen-max-pressure",

cheers,
-roger

author maintainer
#3 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Hi Roger,

Quoted 18 lines · Roger Quadros

Hi Dmitry,

Quoted 15 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
Quoted 9 lines

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 5 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

The binding can specify max, fuzz, both, or neither. If only one is specified we do not want to "undo" whatever the driver did (for example tsc2005 sets up the default maximums before trying to parse OF), so we fetch the current value and pass it on as default one.

Quoted 22 lines
Quoted 22 lines
drivers/input/touchscreen/of_touchscreen.c +4 -3
 						&maximum) |
 		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-x",
 						input_abs_get_fuzz(dev, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
 	axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-y",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,
 						&maximum) |
 		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-y",
 						input_abs_get_fuzz(dev, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
Quoted 4 lines

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 95

Quoted 3 lines
drivers/input/touchscreen/of_touchscreen.c +0 -0
 	axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-max-pressure",

Thanks.

Signature · 1 line
Dmitry
#4 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Dmitry,

Quoted 31 lines · Dmitry Torokhov

Hi Roger,

Quoted 18 lines · Roger Quadros

Hi Dmitry,

Quoted 15 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
  drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
Quoted 9 lines

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 5 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
  	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
  	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

Quoted 2 lines

The binding can specify max, fuzz, both, or neither. If only one is specified we do not want to "undo" whatever the driver did (for example

why not? At least that is not what touchscreen_parse_properties() does. It will update the touchscreen params if any one of the DT property is present.

Quoted 2 lines

tsc2005 sets up the default maximums before trying to parse OF), so we fetch the current value and pass it on as default one.

This is what would happen in tsc2005 case

-driver first sets ABS_X_max to 0xfff and ABS_Y_max to 0xfff.
-calls touchscreen_parse_properties()
-which calls touchscreen_get_prop_u32(dev, "touchscreen-size-x", 0xfff+1, &maximum) -if DT properties are missing, touchscreen_get_prop_u32() changes ABS_X_max to 0x1000 and returns false.
- as data_present is false we don't do a -1 and so we have ABS_X_max changed to 0x1000.

This doesn't look right.

So IMO default_value parameter can be removed from touchscreen_get_prop_u32() to make things simpler.

If the property doesn't exist it will not change *value and return false.

cheers,
-roger
-

Quoted 30 lines
Quoted 23 lines
Quoted 23 lines
drivers/input/touchscreen/of_touchscreen.c +4 -3
  						&maximum) |
  		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-x",
  						input_abs_get_fuzz(dev, axis),
  						&fuzz);
  	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
  	axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
  	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-y",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,
  						&maximum) |
  		       touchscreen_get_prop_u32(np, "touchscreen-fuzz-y",
  						input_abs_get_fuzz(dev, axis),
  						&fuzz);
  	if (data_present)
-		touchscreen_set_params(dev, axis, maximum, fuzz);
+		touchscreen_set_params(dev, axis, maximum - 1, fuzz);
 
Quoted 4 lines

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 95

Quoted 3 lines
drivers/input/touchscreen/of_touchscreen.c +0 -0
  	axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
  	data_present = touchscreen_get_prop_u32(np, "touchscreen-max-pressure",

Thanks.

author maintainer
#5 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Quoted 34 lines · Roger Quadros

Dmitry,

Quoted 31 lines · Dmitry Torokhov

Hi Roger,

Quoted 27 lines · Roger Quadros

Hi Dmitry,

Quoted 14 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 6 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

Quoted 6 lines
Quoted 2 lines

The binding can specify max, fuzz, both, or neither. If only one is specified we do not want to "undo" whatever the driver did (for example

why not? At least that is not what touchscreen_parse_properties() does. It will update the touchscreen params if any one of the DT property is present.

Yes, but while keeping the old properties (max, fuzz) intact if they have not been specified in dts. That is why we are passing default value to touchscreen_get_prop_u32.

Quoted 9 lines
Quoted 3 lines

tsc2005 sets up the default maximums before trying to parse OF), so we fetch the current value and pass it on as default one.

This is what would happen in tsc2005 case

(quoted diff) +0 -3
-driver first sets ABS_X_max to 0xfff and ABS_Y_max to 0xfff.
-calls touchscreen_parse_properties()
-which calls touchscreen_get_prop_u32(dev, "touchscreen-size-x",
Quoted 5 lines

0xfff+1, &maximum)
-if DT properties are missing, touchscreen_get_prop_u32() changes ABS_X_max to 0x1000 and returns false.
- as data_present is false we don't do a -1 and so we have ABS_X_max changed to 0x1000.

If data_present is false we do not call input_set_abs_params() at all ans so nothing changes in input device settings. Now, if fuzz would be set up (but size was not) we would be calling input_set_abs_params(), but given that we subtract 1 from maximum returned by touchscreen_get_prop_u32() we'd be setting input_set_abs_params(input, ABS_X, 0, 0x1000 - 1, fuzz) thus preserving 0xfff value set by the driver.

Quoted 7 lines

This doesn't look right.

So IMO default_value parameter can be removed from touchscreen_get_prop_u32() to make things simpler.

If the property doesn't exist it will not change *value and return false.

But it will change if one of the properties set. For example, if you set fuzz but not size.

Thanks.

Signature · 1 line
Dmitry
#6 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Dmitry,

Quoted 52 lines · Dmitry Torokhov
Quoted 34 lines · Roger Quadros

Dmitry,

Quoted 31 lines · Dmitry Torokhov

Hi Roger,

Quoted 27 lines · Roger Quadros

Hi Dmitry,

Quoted 14 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 6 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

Quoted 6 lines
Quoted 2 lines

The binding can specify max, fuzz, both, or neither. If only one is specified we do not want to "undo" whatever the driver did (for example

why not? At least that is not what touchscreen_parse_properties() does. It will update the touchscreen params if any one of the DT property is present.

Yes, but while keeping the old properties (max, fuzz) intact if they have not been specified in dts. That is why we are passing default value to touchscreen_get_prop_u32.

Quoted 6 lines
Quoted 3 lines

tsc2005 sets up the default maximums before trying to parse OF), so we fetch the current value and pass it on as default one.

This is what would happen in tsc2005 case

Quoted 11 lines
Quoted 8 lines
(quoted diff) +0 -3
-driver first sets ABS_X_max to 0xfff and ABS_Y_max to 0xfff.
-calls touchscreen_parse_properties()
-which calls touchscreen_get_prop_u32(dev, "touchscreen-size-x",

0xfff+1, &maximum)
-if DT properties are missing, touchscreen_get_prop_u32() changes ABS_X_max to 0x1000 and returns false.
- as data_present is false we don't do a -1 and so we have ABS_X_max changed to 0x1000.

If data_present is false we do not call input_set_abs_params() at all ans so nothing changes in input device settings. Now, if fuzz would be

You are right. I missed the fact that we don't call input_set_abs_params() in data_present is false case hence my confusion.

Quoted 9 lines

set up (but size was not) we would be calling input_set_abs_params(), but given that we subtract 1 from maximum returned by touchscreen_get_prop_u32() we'd be setting input_set_abs_params(input, ABS_X, 0, 0x1000 - 1, fuzz) thus preserving 0xfff value set by the driver.

Quoted 3 lines

This doesn't look right.

Quoted 7 lines
Quoted 4 lines

So IMO default_value parameter can be removed from touchscreen_get_prop_u32() to make things simpler.

If the property doesn't exist it will not change *value and return false.

But it will change if one of the properties set. For example, if you set fuzz but not size.

Yes. Thanks for explaining :).

cheers,
-roger

author maintainer
#7 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Quoted 82 lines · Roger Quadros

Dmitry,

Quoted 52 lines · Dmitry Torokhov
Quoted 34 lines · Roger Quadros

Dmitry,

Quoted 31 lines · Dmitry Torokhov

Hi Roger,

Quoted 27 lines · Roger Quadros

Hi Dmitry,

Quoted 14 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 6 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

Quoted 6 lines
Quoted 2 lines

The binding can specify max, fuzz, both, or neither. If only one is specified we do not want to "undo" whatever the driver did (for example

why not? At least that is not what touchscreen_parse_properties() does. It will update the touchscreen params if any one of the DT property is present.

Yes, but while keeping the old properties (max, fuzz) intact if they have not been specified in dts. That is why we are passing default value to touchscreen_get_prop_u32.

Quoted 6 lines
Quoted 3 lines

tsc2005 sets up the default maximums before trying to parse OF), so we fetch the current value and pass it on as default one.

This is what would happen in tsc2005 case

Quoted 11 lines
Quoted 8 lines
(quoted diff) +0 -3
-driver first sets ABS_X_max to 0xfff and ABS_Y_max to 0xfff.
-calls touchscreen_parse_properties()
-which calls touchscreen_get_prop_u32(dev, "touchscreen-size-x",

0xfff+1, &maximum)
-if DT properties are missing, touchscreen_get_prop_u32() changes ABS_X_max to 0x1000 and returns false.
- as data_present is false we don't do a -1 and so we have ABS_X_max changed to 0x1000.

If data_present is false we do not call input_set_abs_params() at all ans so nothing changes in input device settings. Now, if fuzz would be

You are right. I missed the fact that we don't call input_set_abs_params() in data_present is false case hence my confusion.

Quoted 12 lines

set up (but size was not) we would be calling input_set_abs_params(), but given that we subtract 1 from maximum returned by touchscreen_get_prop_u32() we'd be setting input_set_abs_params(input, ABS_X, 0, 0x1000 - 1, fuzz) thus preserving 0xfff value set by the driver.

Quoted 6 lines

This doesn't look right.

So IMO default_value parameter can be removed from touchscreen_get_prop_u32() to make things simpler.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

If the property doesn't exist it will not change *value and return false.

But it will change if one of the properties set. For example, if you set fuzz but not size.

Yes. Thanks for explaining :).

No problem. Can I put you down as "reviewed-by" on the of_touchscreen changes then?

Thanks.

Signature · 1 line
Dmitry
Reviewed-by
#8 lore raw

Re: [PATCH 2/3] Input: of_touchscreen - fix setting max values on X/Y axis

Quoted 85 lines · Dmitry Torokhov
Quoted 84 lines · Roger Quadros

Dmitry,

Quoted 52 lines · Dmitry Torokhov
Quoted 34 lines · Roger Quadros

Dmitry,

Quoted 31 lines · Dmitry Torokhov

Hi Roger,

Quoted 27 lines · Roger Quadros

Hi Dmitry,

Quoted 14 lines · Dmitry Torokhov

The binding specification says that "touchscreen-size-x" and "-y" specify horizontal and vertical resolution of the touchscreen and therefore maximum absolute coordinates should be reduced by 1 since we are starting with 0.

---
 drivers/input/touchscreen/of_touchscreen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/input/touchscreen/of_touchscreen.c +0 -0
index 759cf4b..50bc0f2 100644

drivers/input/touchscreen/of_touchscreen.c void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch) · line 75

Quoted 6 lines
drivers/input/touchscreen/of_touchscreen.c +2 -1
@@ -71,23 +71,25 @@ void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
 
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
 	data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
-						input_abs_get_max(dev, axis),
+						input_abs_get_max(dev,
+								  axis) + 1,

Why do we need to pass default_value to touchscreen_get_prop_u32()? If the property doesn't exist we are not updating the parameter anyway right?

Quoted 6 lines
Quoted 2 lines

The binding can specify max, fuzz, both, or neither. If only one is specified we do not want to "undo" whatever the driver did (for example

why not? At least that is not what touchscreen_parse_properties() does. It will update the touchscreen params if any one of the DT property is present.

Yes, but while keeping the old properties (max, fuzz) intact if they have not been specified in dts. That is why we are passing default value to touchscreen_get_prop_u32.

Quoted 6 lines
Quoted 3 lines

tsc2005 sets up the default maximums before trying to parse OF), so we fetch the current value and pass it on as default one.

This is what would happen in tsc2005 case

Quoted 11 lines
Quoted 8 lines
(quoted diff) +0 -3
-driver first sets ABS_X_max to 0xfff and ABS_Y_max to 0xfff.
-calls touchscreen_parse_properties()
-which calls touchscreen_get_prop_u32(dev, "touchscreen-size-x",

0xfff+1, &maximum)
-if DT properties are missing, touchscreen_get_prop_u32() changes ABS_X_max to 0x1000 and returns false.
- as data_present is false we don't do a -1 and so we have ABS_X_max changed to 0x1000.

If data_present is false we do not call input_set_abs_params() at all ans so nothing changes in input device settings. Now, if fuzz would be

You are right. I missed the fact that we don't call input_set_abs_params() in data_present is false case hence my confusion.

Quoted 14 lines

set up (but size was not) we would be calling input_set_abs_params(), but given that we subtract 1 from maximum returned by touchscreen_get_prop_u32() we'd be setting input_set_abs_params(input, ABS_X, 0, 0x1000 - 1, fuzz) thus preserving 0xfff value set by the driver.

Quoted 7 lines

This doesn't look right.

So IMO default_value parameter can be removed from touchscreen_get_prop_u32() to make things simpler.

If the property doesn't exist it will not change *value and return false.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

But it will change if one of the properties set. For example, if you set fuzz but not size.

Yes. Thanks for explaining :).

No problem. Can I put you down as "reviewed-by" on the of_touchscreen changes then?

Yes please.
For all 3 patches.

cheers,
-roger

author maintainer
#9 lore raw

PATCH 3/3 Input: of_touchscreen - switch to using device properties

In reply to Dmitry Torokhov

Let's switch form OF to device properties so that common parsing code could work not only on device tree but also on ACPI-based platforms.

---
 drivers/input/touchscreen/Kconfig          |  4 +--
 drivers/input/touchscreen/Makefile         |  2 +-
 drivers/input/touchscreen/edt-ft5x06.c     |  2 +-
 drivers/input/touchscreen/of_touchscreen.c | 56 ++++++++++++++++--------------
 drivers/input/touchscreen/tsc2005.c        |  2 +-
 include/linux/input/touchscreen.h          | 11 ++----
 6 files changed, 37 insertions(+), 40 deletions(-)
drivers/input/touchscreen/Kconfig +2 -2
index 2dc9d62..38d0f99 100644
@@ -11,9 +11,9 @@ menuconfig INPUT_TOUCHSCREEN
 
 if INPUT_TOUCHSCREEN
 
-config OF_TOUCHSCREEN
+config TOUCHSCREEN_PROPERTIES
 	def_tristate INPUT
-	depends on INPUT && OF
+	depends on INPUT
 
 config TOUCHSCREEN_88PM860X
 	tristate "Marvell 88PM860x touchscreen"
drivers/input/touchscreen/Makefile +1 -1
index fa3d33b..c85aae2 100644
@@ -6,7 +6,7 @@
 
 wm97xx-ts-y := wm97xx-core.o
 
-obj-$(CONFIG_OF_TOUCHSCREEN)		+= of_touchscreen.o
+obj-$(CONFIG_TOUCHSCREEN_PROPERTIES)	+= of_touchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_88PM860X)	+= 88pm860x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_AD7877)	+= ad7877.o
 obj-$(CONFIG_TOUCHSCREEN_AD7879)	+= ad7879.o
drivers/input/touchscreen/edt-ft5x06.c +1 -1
index 394b1de..8f8f319 100644
@@ -1041,7 +1041,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 			     0, tsdata->num_y * 64 - 1, 0, 0);
 
 	if (!pdata)
-		touchscreen_parse_of_params(input, true);
+		touchscreen_parse_properties(input, true);
 
 	error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT);
 	if (error) {
drivers/input/touchscreen/of_touchscreen.c +30 -26

103 lines not on this page · raw message

drivers/input/touchscreen/tsc2005.c +1 -1
index d8c025b..aaf94752 100644
@@ -709,7 +709,7 @@ static int tsc2005_probe(struct spi_device *spi)
 	input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
 
 	if (np)
-		touchscreen_parse_of_params(input_dev, false);
+		touchscreen_parse_properties(input_dev, false);
 
 	input_dev->open = tsc2005_open;
 	input_dev->close = tsc2005_close;
include/linux/input/touchscreen.h +2 -9
index eecc9ea..c91e137 100644
@@ -9,15 +9,8 @@
 #ifndef _TOUCHSCREEN_H
 #define _TOUCHSCREEN_H
 
-#include <linux/input.h>
+struct input_dev;
 
-#ifdef CONFIG_OF
-void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch);
-#else
-static inline void touchscreen_parse_of_params(struct input_dev *dev,
-					       bool multitouch)
-{
-}
-#endif
+void touchscreen_parse_properties(struct input_dev *dev, bool multitouch);
 
 #endif
Signature · 1 line
2.4.3.573.g4eafbef