From patchwork Thu Jun 29 08:17:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9816225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 82AB7603F2 for ; Thu, 29 Jun 2017 08:19:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 787A92003F for ; Thu, 29 Jun 2017 08:19:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C0AE28688; Thu, 29 Jun 2017 08:19:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B65712003F for ; Thu, 29 Jun 2017 08:19:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQUdj-0000ru-CB; Thu, 29 Jun 2017 08:17:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQUdh-0000rm-Qh for xen-devel@lists.xenproject.org; Thu, 29 Jun 2017 08:17:25 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 28/B1-03704-597B4595; Thu, 29 Jun 2017 08:17:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRWlGSWpSXmKPExsXiVRvsojt5e0i kwY4NNhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aPZt+CD24V+5efZ2lgvGXVxcjFISQwk1Hi zqO/7CAOi8B8VonXP1awdjFyckgI7GaV6LvGC2HHSXw+8p0Jwq6QeNBygQ3EFhLQkNjxZBMjx KQfjBIrpv9iB0mwCKhKTHu3GMxmEzCU2NpwAcwWETCQuHBrGitIA7PAG0aJSUeus4AkhAWsJO 5snMoIYvMK6Eg8enKQCWKDk8Tqn5/YIeKCEidnPgGrZxbQkrjx7yVQDQeQLS2x/B8HSJhTwFl i97r3YCWiAioSU05uY5vAKDwLSfcsJN2zELoXMDKvYlQvTi0qSy3StdBLKspMzyjJTczM0TU0 MNPLTS0uTkxPzUlMKtZLzs/dxAgMcgYg2ME4+7L/IUZJDiYlUd7ohJBIIb6k/JTKjMTijPii0 pzU4kOMMhwcShK8FtuAcoJFqempFWmZOcB4g0lLcPAoifC2rwJK8xYXJOYWZ6ZDpE4xGnNsWL 3+CxPHpAPbvzAJseTl56VKifO+2ApUKgBSmlGaBzcIlgYuMcpKCfMyAp0mxFOQWpSbWYIq/4p RnINRSZi3FWQKT2ZeCdy+V0CnMAGdIjwD7JSSRISUVANjCUevSpIPf9Ezr4tLDCbdZFZIMfhU dtnS6UvJgWM7GwyK93pwf3wnUCooukOc5+qV0BsXm5Kecmf+nf+upnpDfpPennnKLl+CV163D JEPK2iJbQyyiup5d1OwVGy3duzsRhvj7tm/H/2XmCl2MmzWd/mP+km94kr/siJ6pOW6uzMzKx 6/mKvEUpyRaKjFXFScCACCIpjr/gIAAA== X-Env-Sender: dmitry.torokhov@gmail.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1498724242!47797087!1 X-Originating-IP: [74.125.83.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13386 invoked from network); 29 Jun 2017 08:17:23 -0000 Received: from mail-pg0-f68.google.com (HELO mail-pg0-f68.google.com) (74.125.83.68) by server-6.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Jun 2017 08:17:23 -0000 Received: by mail-pg0-f68.google.com with SMTP id f127so11047098pgc.2 for ; Thu, 29 Jun 2017 01:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+C+zUc9URsVEcP/+tDTXSmf90IENXQraQc/WHaJKdgo=; b=gdf9WLMyveX/t4clVFlctdtKTOHjjxXQcQ9jCHGj6CKA1FBrODexOyBV9+Iey4mgCj w5vok0XeF8kSXoUv/n7KtZSi3nCrM8Y0/zCYWDIxoQ+QzqHADvBqjqFaFXUSmV/GMl8r 407NxTaAs+mTVOVFUWuoP4zW8qf7q0RoIx3qvoj9EkSw/N+qE4TSDZfLyBsX81tIl9AC OP415NcqcwOjfqmMPY9SsrxuKbZdzPdPMuuIYW8wDN36ZpVx0T7wigplQHQyXExq0RQD lKKvJs8ZPBjxNqUR96J1dpbfI6/SIh9rDSLFFhvCdFJmEK2EQFhsp2F9gmat8/D1VV1q UArA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+C+zUc9URsVEcP/+tDTXSmf90IENXQraQc/WHaJKdgo=; b=H26OOkiD+TPbdCx6H9LKyQfNujoMEHCNa/a6Y0TdXqLPewu258Mv1q2xs0B0rqa+C/ uKqGQwHRw5uTFsT8BANqLx8t6mX7xcbGrKLUj7idOR22bJ+BVzm1UgAF3y5zCGlTEtwL 4wT59e8+3oHou4z5C0IRYRGXqM9U5oepB97IVsZ2uOk5OKQ1lrqLYd2lRPv46LcXZcfO FU7/OjXn3yU/mjTjimRmsLiqLEkWe61cGG9PqZKt+W7bOnsGB57uQgIPEuauEnSSw9Ut yoHp+vc3yG8vNklYP98T/AQTfTg+agShRxwExCmpqyE35VX3xh+32PTTr8fL4sXGMLmO yvBw== X-Gm-Message-State: AKS2vOy05Xj3e4REQ7CHZMWosPQH0y+5CWCCcux4DzKsPXws5jHgrXjA rZoHm/OzmO31DA== X-Received: by 10.98.7.11 with SMTP id b11mr15434949pfd.188.1498724242135; Thu, 29 Jun 2017 01:17:22 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:dce1:d46c:ae7c:b2d7]) by smtp.gmail.com with ESMTPSA id k73sm11206085pge.13.2017.06.29.01.17.21 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 29 Jun 2017 01:17:21 -0700 (PDT) Date: Thu, 29 Jun 2017 01:17:19 -0700 From: Dmitry Torokhov To: Oleksandr Andrushchenko Message-ID: <20170629081719.GA21557@dtor-ws> References: <1498198195-12293-1-git-send-email-andr2000@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1498198195-12293-1-git-send-email-andr2000@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Oleksandr Andrushchenko , vlad.babchuk@gmail.com, linux-kernel@vger.kernel.org, andrii.anisov@gmail.com, olekstysh@gmail.com, al1img@gmail.com, xen-devel@lists.xenproject.org, joculator@gmail.com Subject: Re: [Xen-devel] [PATCH v1] xen/input: add multi-touch support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi Oleksandr, On Fri, Jun 23, 2017 at 09:09:55AM +0300, Oleksandr Andrushchenko wrote: > + switch (event->mtouch.event_type) { > + case XENKBD_MT_EV_DOWN: > + input_mt_report_slot_state(dev, MT_TOOL_FINGER, > + true); > + input_event(dev, EV_ABS, ABS_MT_POSITION_X, > + event->mtouch.u.pos.abs_x); > + input_event(dev, EV_ABS, ABS_MT_POSITION_Y, > + event->mtouch.u.pos.abs_y); > + input_event(dev, EV_ABS, ABS_X, > + event->mtouch.u.pos.abs_x); > + input_event(dev, EV_ABS, ABS_Y, > + event->mtouch.u.pos.abs_y); I was looking at this and realized that this breaks the single touch emulation for MT interface: for ST you are supposed to report the oldest contact, here you report data for all of them. Luckily input_mt_report_pointer_emulation() that is called as part of input_mt_sync_frame() reports the correct ABS_X/ABS_Y data and fixes that for you. We should simply remove reporting ABS_X/ABS_Y here and in XENKBD_MT_EV_MOTION as well. > + > + input_set_capability(mtouch, EV_KEY, BTN_TOUCH); > + input_set_abs_params(mtouch, ABS_X, > + 0, width, 0, 0); > + input_set_abs_params(mtouch, ABS_Y, > + 0, height, 0, 0); > + input_set_abs_params(mtouch, ABS_PRESSURE, > + 0, 255, 0, 0); This is done automatically by input_mt_init_slots() when called with INPUT_MT_DIRECT (as in your case) or INPUT_MT_POINTER, so this can be removed as well. Does the patch below (on top of yours) work for you? Thanks. diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index 9fa005038773..fa130e7b734c 100644 --- a/drivers/input/misc/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c @@ -60,6 +60,112 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *); * to do that. */ +static void xenkbd_handle_motion_event(struct xenkbd_info *info, + struct xenkbd_motion *motion) +{ + input_report_rel(info->ptr, REL_X, motion->rel_x); + input_report_rel(info->ptr, REL_Y, motion->rel_y); + if (motion->rel_z) + input_report_rel(info->ptr, REL_WHEEL, -motion->rel_z); + input_sync(info->ptr); +} + +static void xenkbd_handle_position_event(struct xenkbd_info *info, + struct xenkbd_position *pos) +{ + input_report_abs(info->ptr, ABS_X, pos->abs_x); + input_report_abs(info->ptr, ABS_Y, pos->abs_y); + if (pos->rel_z) + input_report_rel(info->ptr, REL_WHEEL, -pos->rel_z); + input_sync(info->ptr); +} + +static void xenkbd_handle_key_event(struct xenkbd_info *info, + struct xenkbd_key *key) +{ + struct input_dev *dev; + + if (test_bit(key->keycode, info->ptr->keybit)) { + dev = info->ptr; + } else if (test_bit(key->keycode, info->kbd->keybit)) { + dev = info->kbd; + } else { + pr_warn("unhandled keycode 0x%x\n", key->keycode); + return; + } + + input_report_key(dev, key->keycode, key->pressed); + input_sync(dev); +} + +static void xenkbd_handle_mt_event(struct xenkbd_info *info, + struct xenkbd_mtouch *mtouch) +{ + if (unlikely(!info->mtouch)) + return; + + if (mtouch->contact_id != info->mtouch_cur_contact_id) { + info->mtouch_cur_contact_id = mtouch->contact_id; + input_mt_slot(info->mtouch, mtouch->contact_id); + } + + switch (mtouch->event_type) { + case XENKBD_MT_EV_DOWN: + input_mt_report_slot_state(info->mtouch, MT_TOOL_FINGER, true); + /* fall through */ + + case XENKBD_MT_EV_MOTION: + input_report_abs(info->mtouch, ABS_MT_POSITION_X, + mtouch->u.pos.abs_x); + input_report_abs(info->mtouch, ABS_MT_POSITION_Y, + mtouch->u.pos.abs_y); + break; + + case XENKBD_MT_EV_SHAPE: + input_report_abs(info->mtouch, ABS_MT_TOUCH_MAJOR, + mtouch->u.shape.major); + input_report_abs(info->mtouch, ABS_MT_TOUCH_MINOR, + mtouch->u.shape.minor); + break; + + case XENKBD_MT_EV_ORIENT: + input_report_abs(info->mtouch, ABS_MT_ORIENTATION, + mtouch->u.orientation); + break; + + case XENKBD_MT_EV_UP: + input_mt_report_slot_state(info->mtouch, MT_TOOL_FINGER, false); + break; + + case XENKBD_MT_EV_SYN: + input_mt_sync_frame(info->mtouch); + input_sync(info->mtouch); + break; + } +} + +static void xenkbd_handle_event(struct xenkbd_info *info, + union xenkbd_in_event *event) +{ + switch (event->type) { + case XENKBD_TYPE_MOTION: + xenkbd_handle_motion_event(info, &event->motion); + break; + + case XENKBD_TYPE_KEY: + xenkbd_handle_key_event(info, &event->key); + break; + + case XENKBD_TYPE_POS: + xenkbd_handle_position_event(info, &event->pos); + break; + + case XENKBD_TYPE_MTOUCH: + xenkbd_handle_mt_event(info, &event->mtouch); + break; + } +} + static irqreturn_t input_handler(int rq, void *dev_id) { struct xenkbd_info *info = dev_id; @@ -70,98 +176,8 @@ static irqreturn_t input_handler(int rq, void *dev_id) if (prod == page->in_cons) return IRQ_HANDLED; rmb(); /* ensure we see ring contents up to prod */ - for (cons = page->in_cons; cons != prod; cons++) { - union xenkbd_in_event *event; - struct input_dev *dev; - event = &XENKBD_IN_RING_REF(page, cons); - - dev = info->ptr; - switch (event->type) { - case XENKBD_TYPE_MOTION: - input_report_rel(dev, REL_X, event->motion.rel_x); - input_report_rel(dev, REL_Y, event->motion.rel_y); - if (event->motion.rel_z) - input_report_rel(dev, REL_WHEEL, - -event->motion.rel_z); - break; - case XENKBD_TYPE_KEY: - dev = NULL; - if (test_bit(event->key.keycode, info->kbd->keybit)) - dev = info->kbd; - if (test_bit(event->key.keycode, info->ptr->keybit)) - dev = info->ptr; - if (dev) - input_report_key(dev, event->key.keycode, - event->key.pressed); - else - pr_warn("unhandled keycode 0x%x\n", - event->key.keycode); - break; - case XENKBD_TYPE_POS: - input_report_abs(dev, ABS_X, event->pos.abs_x); - input_report_abs(dev, ABS_Y, event->pos.abs_y); - if (event->pos.rel_z) - input_report_rel(dev, REL_WHEEL, - -event->pos.rel_z); - break; - case XENKBD_TYPE_MTOUCH: - dev = info->mtouch; - if (unlikely(!dev)) - break; - if (event->mtouch.contact_id != - info->mtouch_cur_contact_id) { - info->mtouch_cur_contact_id = - event->mtouch.contact_id; - input_mt_slot(dev, event->mtouch.contact_id); - } - switch (event->mtouch.event_type) { - case XENKBD_MT_EV_DOWN: - input_mt_report_slot_state(dev, MT_TOOL_FINGER, - true); - input_event(dev, EV_ABS, ABS_MT_POSITION_X, - event->mtouch.u.pos.abs_x); - input_event(dev, EV_ABS, ABS_MT_POSITION_Y, - event->mtouch.u.pos.abs_y); - input_event(dev, EV_ABS, ABS_X, - event->mtouch.u.pos.abs_x); - input_event(dev, EV_ABS, ABS_Y, - event->mtouch.u.pos.abs_y); - break; - case XENKBD_MT_EV_UP: - input_mt_report_slot_state(dev, MT_TOOL_FINGER, - false); - break; - case XENKBD_MT_EV_MOTION: - input_event(dev, EV_ABS, ABS_MT_POSITION_X, - event->mtouch.u.pos.abs_x); - input_event(dev, EV_ABS, ABS_MT_POSITION_Y, - event->mtouch.u.pos.abs_y); - input_event(dev, EV_ABS, ABS_X, - event->mtouch.u.pos.abs_x); - input_event(dev, EV_ABS, ABS_Y, - event->mtouch.u.pos.abs_y); - break; - case XENKBD_MT_EV_SYN: - input_mt_sync_frame(dev); - break; - case XENKBD_MT_EV_SHAPE: - input_event(dev, EV_ABS, ABS_MT_TOUCH_MAJOR, - event->mtouch.u.shape.major); - input_event(dev, EV_ABS, ABS_MT_TOUCH_MINOR, - event->mtouch.u.shape.minor); - break; - case XENKBD_MT_EV_ORIENT: - input_event(dev, EV_ABS, ABS_MT_ORIENTATION, - event->mtouch.u.orientation); - break; - } - /* only report syn when requested */ - if (event->mtouch.event_type != XENKBD_MT_EV_SYN) - dev = NULL; - } - if (dev) - input_sync(dev); - } + for (cons = page->in_cons; cons != prod; cons++) + xenkbd_handle_event(info, &XENKBD_IN_RING_REF(page, cons)); mb(); /* ensure we got ring contents */ page->in_cons = cons; notify_remote_via_irq(info->irq); @@ -216,7 +232,7 @@ static int xenkbd_probe(struct xenbus_device *dev, ret = xenbus_write(XBT_NIL, dev->nodename, XENKBD_FIELD_REQ_MTOUCH, "1"); if (ret) { - pr_warning("xenkbd: can't request multi-touch"); + pr_warn("xenkbd: can't request multi-touch"); touch = 0; } } @@ -301,14 +317,6 @@ static int xenkbd_probe(struct xenbus_device *dev, mtouch->id.vendor = 0x5853; mtouch->id.product = 0xfffd; - input_set_capability(mtouch, EV_KEY, BTN_TOUCH); - input_set_abs_params(mtouch, ABS_X, - 0, width, 0, 0); - input_set_abs_params(mtouch, ABS_Y, - 0, height, 0, 0); - input_set_abs_params(mtouch, ABS_PRESSURE, - 0, 255, 0, 0); - input_set_abs_params(mtouch, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(mtouch, ABS_MT_POSITION_X,