From patchwork Fri Jan 6 08:55:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 711753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tvzJZ2xrlz9t0w for ; Fri, 6 Jan 2017 20:09:34 +1100 (AEDT) Received: from localhost ([::1]:51278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPQWi-0001EX-0c for incoming@patchwork.ozlabs.org; Fri, 06 Jan 2017 04:09:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPQJh-0006RG-0q for qemu-devel@nongnu.org; Fri, 06 Jan 2017 03:56:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPQJe-0008NT-PG for qemu-devel@nongnu.org; Fri, 06 Jan 2017 03:56:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cPQJe-0008MO-Ie for qemu-devel@nongnu.org; Fri, 06 Jan 2017 03:56:02 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB96C7F7CE; Fri, 6 Jan 2017 08:56:02 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v068u1fu001772; Fri, 6 Jan 2017 03:56:02 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 9A3FD81659; Fri, 6 Jan 2017 09:55:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 6 Jan 2017 09:55:40 +0100 Message-Id: <1483692945-9866-13-git-send-email-kraxel@redhat.com> In-Reply-To: <1483692945-9866-1-git-send-email-kraxel@redhat.com> References: <1483692945-9866-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 06 Jan 2017 08:56:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 12/17] wctablet: drop timer, hook into chr->accept_input instead X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , avg.tolik@gmail.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Gerd Hoffmann --- backends/wctablet.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/backends/wctablet.c b/backends/wctablet.c index f21b1f4..28daf26 100644 --- a/backends/wctablet.c +++ b/backends/wctablet.c @@ -76,10 +76,7 @@ int COMMON_SPEAD = 900 * 1000; // This structure is used to save private info for Wacom Tablet. typedef struct { - struct QEMUTimer *transmit_timer; - /* QEMU timer */ - uint64_t transmit_time; - /* time to transmit a char in ticks */ + CharDriverState *chr; uint8_t query[100]; int query_index; /* Query string from serial */ @@ -89,6 +86,8 @@ typedef struct { int line_speed; } TabletState; +static void wctablet_chr_accept_input(CharDriverState *chr); + static void wctablet_shift_input(TabletState *tablet, int count) { tablet->query_index -= count; @@ -104,6 +103,7 @@ static void wctablet_queue_output(TabletState *tablet, uint8_t *buf, int count) memcpy(tablet->outbuf + tablet->outlen, buf, count); tablet->outlen += count; + wctablet_chr_accept_input(tablet->chr); } static void wctablet_reset(TabletState *tablet) @@ -146,9 +146,8 @@ static void wctablet_event(void *opaque, int x, wctablet_queue_output(tablet, codes, 7); } -static void wctablet_handler(void *opaque) +static void wctablet_chr_accept_input(CharDriverState *chr) { - CharDriverState *chr = (CharDriverState *) opaque; TabletState *tablet = (TabletState *) chr->opaque; int len, canWrite; // , i; @@ -165,9 +164,6 @@ static void wctablet_handler(void *opaque) memmove(tablet->outbuf, tablet->outbuf + len, tablet->outlen); } } - - timer_mod(tablet->transmit_timer, - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + tablet->transmit_time); } static int wctablet_chr_write(struct CharDriverState *s, @@ -285,24 +281,16 @@ static CharDriverState *qemu_chr_open_wctablet(const char *id, chr->chr_write = wctablet_chr_write; chr->chr_ioctl = wctablet_chr_ioctl; chr->chr_free = wctablet_chr_free; + chr->chr_accept_input = wctablet_chr_accept_input; *be_opened = true; - /* create a new QEMU's timer with wctablet_handler() as timeout handler. */ - tablet->transmit_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, - (QEMUTimerCB *) wctablet_handler, chr); - - tablet->transmit_time = COMMON_SPEAD; - - timer_mod(tablet->transmit_timer, - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + tablet->transmit_time); - - /* init state machine */ memcpy(tablet->outbuf, WC_FULL_CONFIG_STRING, WC_FULL_CONFIG_STRING_LENGTH); tablet->outlen = WC_FULL_CONFIG_STRING_LENGTH; tablet->query_index = 0; chr->opaque = tablet; + tablet->chr = chr; qemu_add_mouse_event_handler(wctablet_event, chr, 1, "QEMU Wacome Pen Tablet");