Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812825/?format=api
{ "id": 812825, "url": "http://patchwork.ozlabs.org/api/patches/812825/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170912123744.14730-13-berrange@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170912123744.14730-13-berrange@redhat.com>", "list_archive_url": null, "date": "2017-09-12T12:37:44", "name": "[v5,12/12] display: convert XenInput keyboard to keycodemapdb", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d0f6537f64f15ed8b60fdee8332e628f80c2ca91", "submitter": { "id": 2694, "url": "http://patchwork.ozlabs.org/api/people/2694/?format=api", "name": "Daniel P. Berrangé", "email": "berrange@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170912123744.14730-13-berrange@redhat.com/mbox/", "series": [ { "id": 2692, "url": "http://patchwork.ozlabs.org/api/series/2692/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2692", "date": "2017-09-12T12:37:33", "name": "Convert over to use keycodemapdb", "version": 5, "mbox": "http://patchwork.ozlabs.org/series/2692/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812825/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812825/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xs4B01fcKz9t7r\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 22:39:24 +1000 (AEST)", "from localhost ([::1]:35573 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drkT2-0000qu-Dm\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 08:39:04 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:48657)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drkSA-0000nv-1E\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 08:38:11 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drkS8-0003VR-Ez\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 08:38:10 -0400", "from mx1.redhat.com ([209.132.183.28]:46256)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1drkS8-0003V5-5L\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 08:38:08 -0400", "from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 2DF66859FA\n\tfor <qemu-devel@nongnu.org>; Tue, 12 Sep 2017 12:38:07 +0000 (UTC)", "from localhost.localdomain.com (unknown [10.42.22.189])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 55B2C77DCA;\n\tTue, 12 Sep 2017 12:38:06 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 2DF66859FA", "From": "\"Daniel P. Berrange\" <berrange@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Tue, 12 Sep 2017 13:37:44 +0100", "Message-Id": "<20170912123744.14730-13-berrange@redhat.com>", "In-Reply-To": "<20170912123744.14730-1-berrange@redhat.com>", "References": "<20170912123744.14730-1-berrange@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tTue, 12 Sep 2017 12:38:07 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH v5 12/12] display: convert XenInput keyboard to\n\tkeycodemapdb", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Gerd Hoffmann <kraxel@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Replace the scancode2linux table with an automatically\ngenerated table. In doing so, the XenFB keyboard\nhandler is also converted to the modern InputEvent\nframework.\n\nSigned-off-by: Daniel P. Berrange <berrange@redhat.com>\n---\n hw/display/xenfb.c | 133 ++++++++++++-----------------------------------------\n 1 file changed, 30 insertions(+), 103 deletions(-)", "diff": "diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c\nindex df8b78f6f4..b4668dfce4 100644\n--- a/hw/display/xenfb.c\n+++ b/hw/display/xenfb.c\n@@ -28,6 +28,7 @@\n \n #include \"hw/hw.h\"\n #include \"ui/console.h\"\n+#include \"ui/input.h\"\n #include \"hw/xen/xen_backend.h\"\n \n #include <xen/event_channel.h>\n@@ -52,7 +53,7 @@ struct XenInput {\n struct common c;\n int abs_pointer_wanted; /* Whether guest supports absolute pointer */\n int button_state; /* Last seen pointer button state */\n- int extended;\n+ QemuInputHandlerState *qkbd;\n QEMUPutMouseEntry *qmouse;\n };\n \n@@ -120,78 +121,6 @@ static void common_unbind(struct common *c)\n \n /* -------------------------------------------------------------------- */\n \n-#if 0\n-/*\n- * These two tables are not needed any more, but left in here\n- * intentionally as documentation, to show how scancode2linux[]\n- * was generated.\n- *\n- * Tables to map from scancode to Linux input layer keycode.\n- * Scancodes are hardware-specific. These maps assumes a\n- * standard AT or PS/2 keyboard which is what QEMU feeds us.\n- */\n-const unsigned char atkbd_set2_keycode[512] = {\n-\n- 0, 67, 65, 63, 61, 59, 60, 88, 0, 68, 66, 64, 62, 15, 41,117,\n- 0, 56, 42, 93, 29, 16, 2, 0, 0, 0, 44, 31, 30, 17, 3, 0,\n- 0, 46, 45, 32, 18, 5, 4, 95, 0, 57, 47, 33, 20, 19, 6,183,\n- 0, 49, 48, 35, 34, 21, 7,184, 0, 0, 50, 36, 22, 8, 9,185,\n- 0, 51, 37, 23, 24, 11, 10, 0, 0, 52, 53, 38, 39, 25, 12, 0,\n- 0, 89, 40, 0, 26, 13, 0, 0, 58, 54, 28, 27, 0, 43, 0, 85,\n- 0, 86, 91, 90, 92, 0, 14, 94, 0, 79,124, 75, 71,121, 0, 0,\n- 82, 83, 80, 76, 77, 72, 1, 69, 87, 78, 81, 74, 55, 73, 70, 99,\n-\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 217,100,255, 0, 97,165, 0, 0,156, 0, 0, 0, 0, 0, 0,125,\n- 173,114, 0,113, 0, 0, 0,126,128, 0, 0,140, 0, 0, 0,127,\n- 159, 0,115, 0,164, 0, 0,116,158, 0,150,166, 0, 0, 0,142,\n- 157, 0, 0, 0, 0, 0, 0, 0,155, 0, 98, 0, 0,163, 0, 0,\n- 226, 0, 0, 0, 0, 0, 0, 0, 0,255, 96, 0, 0, 0,143, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0,107, 0,105,102, 0, 0,112,\n- 110,111,108,112,106,103, 0,119, 0,118,109, 0, 99,104,119, 0,\n-\n-};\n-\n-const unsigned char atkbd_unxlate_table[128] = {\n-\n- 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,\n- 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,\n- 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,\n- 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3,\n- 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105,\n- 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63,\n- 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111,\n- 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110\n-\n-};\n-#endif\n-\n-/*\n- * for (i = 0; i < 128; i++) {\n- * scancode2linux[i] = atkbd_set2_keycode[atkbd_unxlate_table[i]];\n- * scancode2linux[i | 0x80] = atkbd_set2_keycode[atkbd_unxlate_table[i] | 0x80];\n- * }\n- */\n-static const unsigned char scancode2linux[512] = {\n- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,\n- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\n- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,\n- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,\n- 80, 81, 82, 83, 99, 0, 86, 87, 88,117, 0, 0, 95,183,184,185,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 93, 0, 0, 89, 0, 0, 85, 91, 90, 92, 0, 94, 0,124,121, 0,\n-\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 165, 0, 0, 0, 0, 0, 0, 0, 0,163, 0, 0, 96, 97, 0, 0,\n- 113,140,164, 0,166, 0, 0, 0, 0, 0,255, 0, 0, 0,114, 0,\n- 115, 0,150, 0, 0, 98,255, 99,100, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0,119,119,102,103,104, 0,105,112,106,118,107,\n- 108,109,110,111, 0, 0, 0, 0, 0, 0, 0,125,126,127,116,142,\n- 0, 0, 0,143, 0,217,156,173,128,159,158,157,155,226, 0,112,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n-};\n-\n /* Send an event to the keyboard frontend driver */\n static int xenfb_kbd_event(struct XenInput *xenfb,\n \t\t\t union xenkbd_in_event *event)\n@@ -260,37 +189,21 @@ static int xenfb_send_position(struct XenInput *xenfb,\n return xenfb_kbd_event(xenfb, &event);\n }\n \n-/*\n- * Send a key event from the client to the guest OS\n- * QEMU gives us a raw scancode from an AT / PS/2 style keyboard.\n- * We have to turn this into a Linux Input layer keycode.\n- *\n- * Extra complexity from the fact that with extended scancodes\n- * (like those produced by arrow keys) this method gets called\n- * twice, but we only want to send a single event. So we have to\n- * track the '0xe0' scancode state & collapse the extended keys\n- * as needed.\n- *\n- * Wish we could just send scancodes straight to the guest which\n- * already has code for dealing with this...\n- */\n-static void xenfb_key_event(void *opaque, int scancode)\n+static void xenfb_key_event(DeviceState *dev, QemuConsole *src,\n+ InputEvent *evt)\n {\n- struct XenInput *xenfb = opaque;\n- int down = 1;\n+ struct XenInput *xenfb = container_of(dev, struct XenInput,\n+ c.xendev.qdev);\n+ InputKeyEvent *key = evt->u.key.data;\n+ int qcode;\n \n- if (scancode == 0xe0) {\n-\txenfb->extended = 1;\n-\treturn;\n- } else if (scancode & 0x80) {\n-\tscancode &= 0x7f;\n-\tdown = 0;\n- }\n- if (xenfb->extended) {\n-\tscancode |= 0x80;\n-\txenfb->extended = 0;\n+ assert(evt->type == INPUT_EVENT_KIND_KEY);\n+\n+ qcode = qemu_input_key_value_to_qcode(key->key);\n+ if (qcode < qemu_input_map_qcode_to_linux_len) {\n+ xenfb_send_key(xenfb, key->down,\n+ qemu_input_map_qcode_to_linux[qcode]);\n }\n- xenfb_send_key(xenfb, down, scancode2linux[scancode]);\n }\n \n /*\n@@ -347,6 +260,12 @@ static int input_init(struct XenDevice *xendev)\n return 0;\n }\n \n+static QemuInputHandler xenfb_keyboard_handler = {\n+ .name = \"Xen FB Keyboard\",\n+ .mask = INPUT_EVENT_MASK_KEY,\n+ .event = xenfb_key_event,\n+};\n+\n static int input_initialise(struct XenDevice *xendev)\n {\n struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);\n@@ -356,7 +275,6 @@ static int input_initialise(struct XenDevice *xendev)\n if (rc != 0)\n \treturn rc;\n \n- qemu_add_kbd_event_handler(xenfb_key_event, in);\n return 0;\n }\n \n@@ -376,6 +294,12 @@ static void input_connected(struct XenDevice *xendev)\n in->qmouse = qemu_add_mouse_event_handler(xenfb_mouse_event, in,\n \t\t\t\t\t in->abs_pointer_wanted,\n \t\t\t\t\t \"Xen PVFB Mouse\");\n+\n+ if (in->qkbd) {\n+ qemu_input_handler_unregister(in->qkbd);\n+ }\n+ in->qkbd = qemu_input_handler_register((DeviceState *)in,\n+ &xenfb_keyboard_handler);\n }\n \n static void input_disconnect(struct XenDevice *xendev)\n@@ -386,7 +310,10 @@ static void input_disconnect(struct XenDevice *xendev)\n \tqemu_remove_mouse_event_handler(in->qmouse);\n \tin->qmouse = NULL;\n }\n- qemu_add_kbd_event_handler(NULL, NULL);\n+ if (in->qkbd) {\n+ qemu_input_handler_unregister(in->qkbd);\n+ in->qkbd = NULL;\n+ }\n common_unbind(&in->c);\n }\n \n", "prefixes": [ "v5", "12/12" ] }