diff mbox

Input: tsc2007 - switch to using input_set_capability()

Message ID 20170217225627.GA27132@dtor-ws (mailing list archive)
State New, archived
Headers show

Commit Message

Dmitry Torokhov Feb. 17, 2017, 10:56 p.m. UTC
Do not manipulate evbit/keybit directly, use helper for that.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/tsc2007_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

H. Nikolaus Schaller Feb. 18, 2017, 2:58 p.m. UTC | #1
Hi Dmitry,

> Am 17.02.2017 um 23:56 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> 
> Do not manipulate evbit/keybit directly, use helper for that.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/input/touchscreen/tsc2007_core.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> index fdf81a2b989a..98dbefc3357d 100644
> --- a/drivers/input/touchscreen/tsc2007_core.c
> +++ b/drivers/input/touchscreen/tsc2007_core.c
> @@ -364,8 +364,7 @@ static int tsc2007_probe(struct i2c_client *client,
> 
> 	input_set_drvdata(input_dev, ts);
> 
> -	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
> -	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
> +	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);

basically a good improvement, but removing the BIT_MASK(EV_ABS) makes problems
when replacing the next lines

> 
> 	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
> 	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);

by touchscreen_parse_properties() as done by my patch set.

The problem is that touchscreen_parse_properties() does not call input_set_abs_params()
but touchscreen_set_params(). This does not call some input_set_capability(dev, EV_ABS, axis)
but rather checks that it has been set before! Hence we only see warnings in the log
and no input event properties (BTN_TOUCH works but without position information).

So we either must explicitly input_set_capability(dev, EV_ABS, axis) for all three
axises or remove the test in touchscreen_set_params and call
input_set_capability(dev, EV_ABS, axis); in the end.

This patch improves the existing driver but breaks my tsc2007 patch set in a location
that my patch set does not even touch (touchscreen_set_params).

Scratching my head how to come out of this...

BR and thanks,
Nikolaus

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Feb. 20, 2017, 1:10 a.m. UTC | #2
On Sat, Feb 18, 2017 at 03:58:39PM +0100, H. Nikolaus Schaller wrote:
> Hi Dmitry,
> 
> > Am 17.02.2017 um 23:56 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> > 
> > Do not manipulate evbit/keybit directly, use helper for that.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > drivers/input/touchscreen/tsc2007_core.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> > index fdf81a2b989a..98dbefc3357d 100644
> > --- a/drivers/input/touchscreen/tsc2007_core.c
> > +++ b/drivers/input/touchscreen/tsc2007_core.c
> > @@ -364,8 +364,7 @@ static int tsc2007_probe(struct i2c_client *client,
> > 
> > 	input_set_drvdata(input_dev, ts);
> > 
> > -	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
> > -	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
> > +	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
> 
> basically a good improvement, but removing the BIT_MASK(EV_ABS) makes problems
> when replacing the next lines
> 
> > 
> > 	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
> > 	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
> 
> by touchscreen_parse_properties() as done by my patch set.
> 
> The problem is that touchscreen_parse_properties() does not call
> input_set_abs_params() but touchscreen_set_params(). This does not
> call some input_set_capability(dev, EV_ABS, axis) but rather checks
> that it has been set before! Hence we only see warnings in the log and
> no input event properties (BTN_TOUCH works but without position
> information).

Yes, the driver is supposed to set defaults, then OF data may augment
them (or it may omit them and leave driver's defaults). You should not
have removed calls to

	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);

We may end up setting initial fuzz to 0, that's fine.

Thanks.
H. Nikolaus Schaller Feb. 20, 2017, 4:51 p.m. UTC | #3
Hi Dmitry,

> Am 20.02.2017 um 02:10 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> 
> On Sat, Feb 18, 2017 at 03:58:39PM +0100, H. Nikolaus Schaller wrote:
>> Hi Dmitry,
>> 
>>> Am 17.02.2017 um 23:56 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:
>>> 
>>> Do not manipulate evbit/keybit directly, use helper for that.
>>> 
>>> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>>> ---
>>> drivers/input/touchscreen/tsc2007_core.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>> 
>>> diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
>>> index fdf81a2b989a..98dbefc3357d 100644
>>> --- a/drivers/input/touchscreen/tsc2007_core.c
>>> +++ b/drivers/input/touchscreen/tsc2007_core.c
>>> @@ -364,8 +364,7 @@ static int tsc2007_probe(struct i2c_client *client,
>>> 
>>> 	input_set_drvdata(input_dev, ts);
>>> 
>>> -	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
>>> -	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
>>> +	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
>> 
>> basically a good improvement, but removing the BIT_MASK(EV_ABS) makes problems
>> when replacing the next lines
>> 
>>> 
>>> 	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
>>> 	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
>> 
>> by touchscreen_parse_properties() as done by my patch set.
>> 
>> The problem is that touchscreen_parse_properties() does not call
>> input_set_abs_params() but touchscreen_set_params(). This does not
>> call some input_set_capability(dev, EV_ABS, axis) but rather checks
>> that it has been set before! Hence we only see warnings in the log and
>> no input event properties (BTN_TOUCH works but without position
>> information).
> 
> Yes, the driver is supposed to set defaults, then OF data may augment
> them (or it may omit them and leave driver's defaults).

Ok.

> You should not
> have removed calls to
> 
> 	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);

Wouldn't it suffice to call

	input_set_capability(input_dev, EV_ABS, ABS_X);
	input_set_capability(input_dev, EV_ABS, ABS_Y);

since fuzz default is already 0?

BR,
Nikolaus

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index fdf81a2b989a..98dbefc3357d 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -364,8 +364,7 @@  static int tsc2007_probe(struct i2c_client *client,
 
 	input_set_drvdata(input_dev, ts);
 
-	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
 
 	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
 	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);