From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH v3 4/4] touchscreen: pixcir_ts: Add support for axis inversion / swapping
Date: Fri, 15 Jul 2016 14:45:16 -0700 [thread overview]
Message-ID: <20160715214516.GE27847@dtor-ws> (raw)
In-Reply-To: <1468590491-10269-5-git-send-email-hdegoede@redhat.com>
On Fri, Jul 15, 2016 at 03:48:11PM +0200, Hans de Goede wrote:
> Add support for axis inversion / swapping using the new
> touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
> functionality.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -Add a fix which actually makes this patch compile, which accidentally ended
> up in a later commit in my tree
> Changes in v3:
> -Use new touchscreen_set_mt_pos helper
> ---
> drivers/input/touchscreen/pixcir_i2c_ts.c | 48 ++++++++++++-------------------
> 1 file changed, 18 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index f58784d..c696c5d 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -41,19 +41,15 @@ struct pixcir_i2c_ts_data {
> struct gpio_desc *gpio_enable;
> struct gpio_desc *gpio_wake;
> const struct pixcir_i2c_chip_data *chip;
> + struct touchscreen_properties prop;
> int max_fingers; /* Max fingers supported in this instance */
> bool running;
> };
>
> -struct pixcir_touch {
> - int x;
> - int y;
> - int id;
> -};
> -
> struct pixcir_report_data {
> int num_touches;
> - struct pixcir_touch touches[PIXCIR_MAX_SLOTS];
> + struct input_mt_pos pos[PIXCIR_MAX_SLOTS];
> + int ids[PIXCIR_MAX_SLOTS];
> };
>
> static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
> @@ -98,11 +94,11 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
> bufptr = &rdbuf[2];
>
> for (i = 0; i < touch; i++) {
> - report->touches[i].x = (bufptr[1] << 8) | bufptr[0];
> - report->touches[i].y = (bufptr[3] << 8) | bufptr[2];
> -
> + touchscreen_set_mt_pos(&report->pos[i], &tsdata->prop,
> + (bufptr[1] << 8) | bufptr[0],
> + (bufptr[3] << 8) | bufptr[2]);
I replaced this with calls to get_unaligned_le16() while we are at it.
> if (chip->has_hw_ids) {
> - report->touches[i].id = bufptr[4];
> + report->ids[i] = bufptr[4];
> bufptr = bufptr + 5;
> } else {
> bufptr = bufptr + 4;
> @@ -113,9 +109,7 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
> static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
> struct pixcir_report_data *report)
> {
> - struct input_mt_pos pos[PIXCIR_MAX_SLOTS];
> int slots[PIXCIR_MAX_SLOTS];
> - struct pixcir_touch *touch;
> int n, i, slot;
> struct device *dev = &ts->client->dev;
> const struct pixcir_i2c_chip_data *chip = ts->chip;
> @@ -124,24 +118,16 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
> if (n > PIXCIR_MAX_SLOTS)
> n = PIXCIR_MAX_SLOTS;
>
> - if (!ts->chip->has_hw_ids) {
> - for (i = 0; i < n; i++) {
> - touch = &report->touches[i];
> - pos[i].x = touch->x;
> - pos[i].y = touch->y;
> - }
> -
> - input_mt_assign_slots(ts->input, slots, pos, n, 0);
> - }
> + if (!ts->chip->has_hw_ids)
> + input_mt_assign_slots(ts->input, slots, report->pos, n, 0);
>
> for (i = 0; i < n; i++) {
> - touch = &report->touches[i];
> -
> if (chip->has_hw_ids) {
> - slot = input_mt_get_slot_by_key(ts->input, touch->id);
> + slot = input_mt_get_slot_by_key(ts->input,
> + report->ids[i]);
> if (slot < 0) {
> dev_dbg(dev, "no free slot for id 0x%x\n",
> - touch->id);
> + report->ids[i]);
> continue;
> }
> } else {
> @@ -152,11 +138,13 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
> input_mt_report_slot_state(ts->input,
> MT_TOOL_FINGER, true);
>
> - input_event(ts->input, EV_ABS, ABS_MT_POSITION_X, touch->x);
> - input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y, touch->y);
> + input_event(ts->input, EV_ABS, ABS_MT_POSITION_X,
> + report->pos[i].x);
> + input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y,
> + report->pos[i].y);
and this with input_report_abs().
>
> dev_dbg(dev, "%d: slot %d, x %d, y %d\n",
> - i, slot, touch->x, touch->y);
> + i, slot, report->pos[i].x, report->pos[i].y);
> }
>
> input_mt_sync_frame(ts->input);
> @@ -515,7 +503,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
> } else {
> input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
> input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
> - touchscreen_parse_properties(input, true, NULL);
> + touchscreen_parse_properties(input, true, &tsdata->prop);
> if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
> !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
> dev_err(dev, "Touchscreen size is not specified\n");
> --
> 2.7.4
>
Applied, thank you.
--
Dmitry
next prev parent reply other threads:[~2016-07-15 21:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 13:48 [PATCH v4 0/4] of_touchscreen-helpers: Add support for inverted / swapp Hans de Goede
2016-07-15 13:48 ` [PATCH v3 1/4] of_touchscreen-helpers: Add support for inverted / swapped axis Hans de Goede
2016-07-15 21:26 ` Dmitry Torokhov
2016-07-16 10:06 ` Hans de Goede
2016-07-15 13:48 ` [PATCH v3 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping Hans de Goede
2016-07-15 13:48 ` [PATCH v3 3/4] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers Hans de Goede
2016-07-15 13:48 ` [PATCH v3 4/4] touchscreen: pixcir_ts: Add support for axis inversion / swapping Hans de Goede
2016-07-15 21:45 ` Dmitry Torokhov [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-07-15 12:16 [PATCH v3 0/4] of_touchscreen-helpers: Add support for inverted / swapped axis Hans de Goede
2016-07-15 12:16 ` [PATCH v3 4/4] touchscreen: pixcir_ts: Add support for axis inversion / swapping Hans de Goede
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=20160715214516.GE27847@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=hdegoede@redhat.com \
--cc=linux-input@vger.kernel.org \
/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