From patchwork Thu Aug 11 07:03:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 109550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 16191B6F7B for ; Thu, 11 Aug 2011 17:07:40 +1000 (EST) Received: from localhost ([::1]:41349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrPMf-0007vZ-Gb for incoming@patchwork.ozlabs.org; Thu, 11 Aug 2011 03:07:37 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrPMX-0007vS-UW for qemu-devel@nongnu.org; Thu, 11 Aug 2011 03:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrPMT-0007Ld-PO for qemu-devel@nongnu.org; Thu, 11 Aug 2011 03:07:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrPMT-0007LU-CK for qemu-devel@nongnu.org; Thu, 11 Aug 2011 03:07:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7B73xtt020300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Aug 2011 03:03:59 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7B73kB7019769; Thu, 11 Aug 2011 03:03:47 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 590FA412E4; Thu, 11 Aug 2011 09:03:46 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 11 Aug 2011 09:03:42 +0200 Message-Id: <1313046225-1064-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1313046225-1064-1-git-send-email-kraxel@redhat.com> References: <1313046225-1064-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Michael Walle , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 3/6] hid: introduce hid vmstate macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Michael Walle Add VMSTATE macros to describe a HIDState. Based on usb-hid.c descriptions. Signed-off-by: Michael Walle Signed-off-by: Gerd Hoffmann --- hw/hid.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/hw.h | 20 ++++++++++++++++++++ 2 files changed, 78 insertions(+), 0 deletions(-) diff --git a/hw/hid.c b/hw/hid.c index 3dc4246..ec066cf 100644 --- a/hw/hid.c +++ b/hw/hid.c @@ -407,3 +407,61 @@ void hid_init(HIDState *hs, int kind, HIDEventFunc event) 1, "QEMU HID Tablet"); } } + +static int hid_post_load(void *opaque, int version_id) +{ + HIDState *s = opaque; + + if (s->idle) { + hid_set_next_idle(s, qemu_get_clock_ns(vm_clock)); + } + return 0; +} + +static const VMStateDescription vmstate_hid_ptr_queue = { + .name = "HIDPointerEventQueue", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_INT32(xdx, HIDPointerEvent), + VMSTATE_INT32(ydy, HIDPointerEvent), + VMSTATE_INT32(dz, HIDPointerEvent), + VMSTATE_INT32(buttons_state, HIDPointerEvent), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_hid_ptr_device = { + .name = "HIDPointerDevice", + .version_id = 1, + .minimum_version_id = 1, + .post_load = hid_post_load, + .fields = (VMStateField[]) { + VMSTATE_STRUCT_ARRAY(ptr.queue, HIDState, QUEUE_LENGTH, 0, + vmstate_hid_ptr_queue, HIDPointerEvent), + VMSTATE_UINT32(head, HIDState), + VMSTATE_UINT32(n, HIDState), + VMSTATE_INT32(protocol, HIDState), + VMSTATE_UINT8(idle, HIDState), + VMSTATE_END_OF_LIST(), + } +}; + +const VMStateDescription vmstate_hid_keyboard_device = { + .name = "HIDKeyboardDevice", + .version_id = 1, + .minimum_version_id = 1, + .post_load = hid_post_load, + .fields = (VMStateField[]) { + VMSTATE_UINT32_ARRAY(kbd.keycodes, HIDState, QUEUE_LENGTH), + VMSTATE_UINT32(head, HIDState), + VMSTATE_UINT32(n, HIDState), + VMSTATE_UINT16(kbd.modifiers, HIDState), + VMSTATE_UINT8(kbd.leds, HIDState), + VMSTATE_UINT8_ARRAY(kbd.key, HIDState, 16), + VMSTATE_INT32(kbd.keys, HIDState), + VMSTATE_INT32(protocol, HIDState), + VMSTATE_UINT8(idle, HIDState), + VMSTATE_END_OF_LIST(), + } +}; diff --git a/hw/hw.h b/hw/hw.h index df6ca65..a124da9 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -701,6 +701,26 @@ extern const VMStateDescription vmstate_ptimer; .offset = vmstate_offset_pointer(_state, _field, ptimer_state), \ } +extern const VMStateDescription vmstate_hid_keyboard_device; + +#define VMSTATE_HID_KEYBOARD_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(HIDState), \ + .vmsd = &vmstate_hid_keyboard_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, HIDState), \ +} + +extern const VMStateDescription vmstate_hid_ptr_device; + +#define VMSTATE_HID_POINTER_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(HIDState), \ + .vmsd = &vmstate_hid_ptr_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, HIDState), \ +} + /* _f : field name _f_n : num of elements field_name _n : num of elements