From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590302384469.6335479820126; Fri, 12 May 2017 04:58:22 -0700 (PDT) Received: from localhost ([::1]:53078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99DB-0000SG-1h for importer@patchew.org; Fri, 12 May 2017 07:58:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996p-0002tF-0G for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996n-00055p-J2 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996n-00055B-8q for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D29C3DBF9; Fri, 12 May 2017 11:51:44 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 901EF8D558; Fri, 12 May 2017 11:51:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8D24180B30; Fri, 12 May 2017 13:51:38 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D29C3DBF9 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2D29C3DBF9 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:26 +0200 Message-Id: <20170512115135.17379-2-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 12 May 2017 11:51:44 +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] [PULL 01/10] ui: Support non-zero minimum values for absolute input axes 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: Peter Maydell , "Michael S. Tsirkin" , Philippe Voinov , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Philippe Voinov This patch refactors ui/input.c to support absolute axis minimum values other than 0. All dependent calls to qemu_input_queue_abs have been updated to explicitly supply 0 as the axis minimum value. Signed-off-by: Philippe Voinov Message-id: 20170505133952.29885-1-philippevoinov@gmail.com Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 11 +++++++---- hw/input/virtio-input-hid.c | 6 ++++-- ui/gtk.c | 4 ++-- ui/input.c | 31 ++++++++++++++++++++++--------- ui/sdl.c | 4 ++-- ui/sdl2.c | 4 ++-- ui/spice-input.c | 4 ++-- ui/vnc.c | 4 ++-- ui/cocoa.m | 4 ++-- 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index d06a12dd4c..3cfd0f3363 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -8,7 +8,8 @@ #define INPUT_EVENT_MASK_REL (1<gfx.dcl.con, INPUT_AXIS_X, x, - surface_width(vc->gfx.ds)); + 0, surface_width(vc->gfx.ds)); qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_Y, y, - surface_height(vc->gfx.ds)); + 0, surface_height(vc->gfx.ds)); qemu_input_event_sync(); } else if (s->last_set && s->ptr_owner =3D=3D vc) { qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, x - s->last_x); diff --git a/ui/input.c b/ui/input.c index 830f912f99..290ca9f54d 100644 --- a/ui/input.c +++ b/ui/input.c @@ -166,6 +166,11 @@ void qmp_input_send_event(bool has_device, const char = *device, qemu_input_event_sync(); } =20 +static int qemu_input_transform_invert_abs_value(int value) +{ + return (int64_t)INPUT_EVENT_ABS_MAX - value + INPUT_EVENT_ABS_MIN; +} + static void qemu_input_transform_abs_rotate(InputEvent *evt) { InputMoveEvent *move =3D evt->u.abs.data; @@ -175,16 +180,16 @@ static void qemu_input_transform_abs_rotate(InputEven= t *evt) move->axis =3D INPUT_AXIS_Y; } else if (move->axis =3D=3D INPUT_AXIS_Y) { move->axis =3D INPUT_AXIS_X; - move->value =3D INPUT_EVENT_ABS_SIZE - 1 - move->value; + move->value =3D qemu_input_transform_invert_abs_value(move->va= lue); } break; case 180: - move->value =3D INPUT_EVENT_ABS_SIZE - 1 - move->value; + move->value =3D qemu_input_transform_invert_abs_value(move->value); break; case 270: if (move->axis =3D=3D INPUT_AXIS_X) { move->axis =3D INPUT_AXIS_Y; - move->value =3D INPUT_EVENT_ABS_SIZE - 1 - move->value; + move->value =3D qemu_input_transform_invert_abs_value(move->va= lue); } else if (move->axis =3D=3D INPUT_AXIS_Y) { move->axis =3D INPUT_AXIS_X; } @@ -467,12 +472,17 @@ bool qemu_input_is_absolute(void) return (s !=3D NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS); } =20 -int qemu_input_scale_axis(int value, int size_in, int size_out) +int qemu_input_scale_axis(int value, + int min_in, int max_in, + int min_out, int max_out) { - if (size_in < 2) { - return size_out / 2; + int64_t range_in =3D (int64_t)max_in - min_in; + int64_t range_out =3D (int64_t)max_out - min_out; + + if (range_in < 1) { + return min_out + range_out / 2; } - return (int64_t)value * (size_out - 1) / (size_in - 1); + return ((int64_t)value - min_in) * range_out / range_in + min_out; } =20 InputEvent *qemu_input_event_new_move(InputEventKind kind, @@ -496,10 +506,13 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis= axis, int value) qapi_free_InputEvent(evt); } =20 -void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int= size) +void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, + int min_in, int max_in) { InputEvent *evt; - int scaled =3D qemu_input_scale_axis(value, size, INPUT_EVENT_ABS_SIZE= ); + int scaled =3D qemu_input_scale_axis(value, min_in, max_in, + INPUT_EVENT_ABS_MIN, + INPUT_EVENT_ABS_MAX); evt =3D qemu_input_event_new_move(INPUT_EVENT_KIND_ABS, axis, scaled); qemu_input_event_send(src, evt); qapi_free_InputEvent(evt); diff --git a/ui/sdl.c b/ui/sdl.c index 37c21a00fb..b35a67855f 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -490,9 +490,9 @@ static void sdl_send_mouse_event(int dx, int dy, int x,= int y, int state) =20 if (qemu_input_is_absolute()) { qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, x, - real_screen->w); + 0, real_screen->w); qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, y, - real_screen->h); + 0, real_screen->h); } else { if (guest_cursor) { x -=3D guest_x; diff --git a/ui/sdl2.c b/ui/sdl2.c index faf9bdff5c..21de05200e 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -298,8 +298,8 @@ static void sdl_send_mouse_event(struct sdl2_console *s= con, int dx, int dy, } } } - qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X, off_x + x, max_w= ); - qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y, off_y + y, max_h= ); + qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X, off_x + x, 0, ma= x_w); + qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y, off_y + y, 0, ma= x_h); } else { if (guest_cursor) { x -=3D guest_x; diff --git a/ui/spice-input.c b/ui/spice-input.c index 8eeebdbb2e..86293dd2ce 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -172,8 +172,8 @@ static void tablet_position(SpiceTabletInstance* sin, i= nt x, int y, QemuSpicePointer *pointer =3D container_of(sin, QemuSpicePointer, tabl= et); =20 spice_update_buttons(pointer, 0, buttons_state); - qemu_input_queue_abs(NULL, INPUT_AXIS_X, x, pointer->width); - qemu_input_queue_abs(NULL, INPUT_AXIS_Y, y, pointer->height); + qemu_input_queue_abs(NULL, INPUT_AXIS_X, x, 0, pointer->width); + qemu_input_queue_abs(NULL, INPUT_AXIS_Y, y, 0, pointer->height); qemu_input_event_sync(); } =20 diff --git a/ui/vnc.c b/ui/vnc.c index 9c4edcdbf5..601f9ec539 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1556,8 +1556,8 @@ static void pointer_event(VncState *vs, int button_ma= sk, int x, int y) } =20 if (vs->absolute) { - qemu_input_queue_abs(con, INPUT_AXIS_X, x, width); - qemu_input_queue_abs(con, INPUT_AXIS_Y, y, height); + qemu_input_queue_abs(con, INPUT_AXIS_X, x, 0, width); + qemu_input_queue_abs(con, INPUT_AXIS_Y, y, 0, height); } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) { qemu_input_queue_rel(con, INPUT_AXIS_X, x - 0x7FFF); qemu_input_queue_rel(con, INPUT_AXIS_Y, y - 0x7FFF); diff --git a/ui/cocoa.m b/ui/cocoa.m index 207555edf7..3a9bc4da5f 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -749,8 +749,8 @@ QemuCocoaView *cocoaView; * clicks in the titlebar. */ if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, p.x, scre= en.width); - qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, screen.he= ight - p.y, screen.height); + qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, p.x, 0, s= creen.width); + qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, screen.he= ight - p.y, 0, screen.height); } } else { qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, (int)[event d= eltaX]); --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14945900245291005.8397000154271; Fri, 12 May 2017 04:53:44 -0700 (PDT) Received: from localhost ([::1]:53054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d998h-00045t-9u for importer@patchew.org; Fri, 12 May 2017 07:53:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996n-0002t0-4y for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996l-00054a-P9 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46236) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996l-000543-GP for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 353FF824; Fri, 12 May 2017 11:51:42 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE3BB8B762; Fri, 12 May 2017 11:51:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A6C1480D5B; Fri, 12 May 2017 13:51:38 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 353FF824 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 353FF824 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:27 +0200 Message-Id: <20170512115135.17379-3-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 11:51:42 +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] [PULL 02/10] ui: input-linux: Add absolute event support 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: Philippe Voinov , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Philippe Voinov This patch adds support for absolute pointer events to the input-linux subsystem. This support was omitted from the original input-linux patch, however most of the code required for it is already in place. Support for absolute events is especially useful for guests with vga passthrough. Since they have a physical monitor, none of normal channels for sending video output (vnc, etc) are used, meaning they also can't be used to send absolute input events. This leaves QMP as the only option to send absolute input into vga passthrough guests, which is not its intended use and is not efficient. This patch allows, for example, uinput to be used to create virtual absolute input devices. This lets you build external systems which share physical input devices between guests. Without absolute input capability, such external systems can't seamlessly share pointer devices between guests. Signed-off-by: Philippe Voinov Message-id: 20170505134231.30210-1-philippevoinov@gmail.com Signed-off-by: Gerd Hoffmann --- ui/input-linux.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index dc0613ca1f..49d52a69cc 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -169,6 +169,10 @@ struct InputLinux { bool has_abs_x; int num_keys; int num_btns; + int abs_x_min; + int abs_x_max; + int abs_y_min; + int abs_y_max; struct input_event event; int read_offset; =20 @@ -314,6 +318,18 @@ static void input_linux_handle_mouse(InputLinux *il, s= truct input_event *event) break; } break; + case EV_ABS: + switch (event->code) { + case ABS_X: + qemu_input_queue_abs(NULL, INPUT_AXIS_X, event->value, + il->abs_x_min, il->abs_x_max); + break; + case ABS_Y: + qemu_input_queue_abs(NULL, INPUT_AXIS_Y, event->value, + il->abs_y_min, il->abs_y_max); + break; + } + break; case EV_SYN: qemu_input_event_sync(); if (il->wheel !=3D 0) { @@ -351,7 +367,7 @@ static void input_linux_event(void *opaque) if (il->num_keys) { input_linux_handle_keyboard(il, &il->event); } - if (il->has_rel_x && il->num_btns) { + if ((il->has_rel_x || il->has_abs_x) && il->num_btns) { input_linux_handle_mouse(il, &il->event); } } @@ -364,6 +380,7 @@ static void input_linux_complete(UserCreatable *uc, Err= or **errp) uint8_t keymap[KEY_CNT / 8], keystate[KEY_CNT / 8]; unsigned int i; int rc, ver; + struct input_absinfo absinfo; =20 if (!il->evdev) { error_setg(errp, "no input device specified"); @@ -402,6 +419,12 @@ static void input_linux_complete(UserCreatable *uc, Er= ror **errp) rc =3D ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); if (absmap & (1 << ABS_X)) { il->has_abs_x =3D true; + rc =3D ioctl(il->fd, EVIOCGABS(ABS_X), &absinfo); + il->abs_x_min =3D absinfo.minimum; + il->abs_x_max =3D absinfo.maximum; + rc =3D ioctl(il->fd, EVIOCGABS(ABS_Y), &absinfo); + il->abs_y_min =3D absinfo.minimum; + il->abs_y_max =3D absinfo.maximum; } } =20 --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590172596137.22675997187616; Fri, 12 May 2017 04:56:12 -0700 (PDT) Received: from localhost ([::1]:53066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99B5-0006dM-5o for importer@patchew.org; Fri, 12 May 2017 07:56:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996p-0002tH-KK for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996o-00056b-Nz for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50418) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996o-000560-FS for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C864AE184D for ; Fri, 12 May 2017 11:51:44 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACB534DA7C; Fri, 12 May 2017 11:51:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id BEE0F80DC2; Fri, 12 May 2017 13:51:38 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C864AE184D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C864AE184D From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:28 +0200 Message-Id: <20170512115135.17379-4-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 12 May 2017 11:51:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 03/10] virtio-gpu: move virtio_gpu_gl_block 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 , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move to virtio-gpu-3d.c where all the other virgl code lives too. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20170505104101.30589-2-kraxel@redhat.com --- include/hw/virtio/virtio-gpu.h | 1 + hw/display/virtio-gpu-3d.c | 16 ++++++++++++++++ hw/display/virtio-gpu.c | 18 ++---------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index f3ffdceca4..83f474ffc3 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -169,6 +169,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd); void virtio_gpu_virgl_fence_poll(VirtIOGPU *g); void virtio_gpu_virgl_reset(VirtIOGPU *g); +void virtio_gpu_gl_block(void *opaque, bool block); int virtio_gpu_virgl_init(VirtIOGPU *g); =20 #endif diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index f49b7fe8cd..8c106a662d 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -600,6 +600,22 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g) } } =20 +void virtio_gpu_gl_block(void *opaque, bool block) +{ + VirtIOGPU *g =3D opaque; + + if (block) { + g->renderer_blocked++; + } else { + g->renderer_blocked--; + } + assert(g->renderer_blocked >=3D 0); + + if (g->renderer_blocked =3D=3D 0) { + virtio_gpu_process_cmdq(g); + } +} + int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index e1056f34df..cfb5dfa336 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -929,28 +929,14 @@ static int virtio_gpu_ui_info(void *opaque, uint32_t = idx, QemuUIInfo *info) return 0; } =20 -static void virtio_gpu_gl_block(void *opaque, bool block) -{ - VirtIOGPU *g =3D opaque; - - if (block) { - g->renderer_blocked++; - } else { - g->renderer_blocked--; - } - assert(g->renderer_blocked >=3D 0); - - if (g->renderer_blocked =3D=3D 0) { - virtio_gpu_process_cmdq(g); - } -} - const GraphicHwOps virtio_gpu_ops =3D { .invalidate =3D virtio_gpu_invalidate_display, .gfx_update =3D virtio_gpu_update_display, .text_update =3D virtio_gpu_text_update, .ui_info =3D virtio_gpu_ui_info, +#ifdef CONFIG_VIRGL .gl_block =3D virtio_gpu_gl_block, +#endif }; =20 static const VMStateDescription vmstate_virtio_gpu_scanout =3D { --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590173959966.9720495180586; Fri, 12 May 2017 04:56:13 -0700 (PDT) Received: from localhost ([::1]:53067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99B6-0006eI-K6 for importer@patchew.org; Fri, 12 May 2017 07:56:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996o-0002tD-6a for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996m-000556-K7 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10237) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996m-00054W-Ak for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49FBD5277D for ; Fri, 12 May 2017 11:51:43 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACBE15C541; Fri, 12 May 2017 11:51:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E124E80E42; Fri, 12 May 2017 13:51:38 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49FBD5277D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49FBD5277D From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:29 +0200 Message-Id: <20170512115135.17379-5-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 11:51:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 04/10] egl-helpers: drop support for gles and debug logging 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Leftover from the early opengl days. Unused now, so delete the dead code. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Message-id: 20170505104101.30589-3-kraxel@redhat.com --- include/ui/egl-helpers.h | 2 +- ui/egl-helpers.c | 52 +++++---------------------------------------= ---- ui/gtk-egl.c | 2 +- 3 files changed, 7 insertions(+), 49 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 88a13e827b..fec7da14a5 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -21,7 +21,7 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *strid= e, EGLint *fourcc); =20 EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool gles, bool debug); +int qemu_egl_init_dpy(EGLNativeDisplayType dpy); EGLContext qemu_egl_init_ctx(void); =20 #endif /* EGL_HELPERS_H */ diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index b7b6b2e3cc..a3d7c3d7f5 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -26,18 +26,6 @@ EGLConfig qemu_egl_config; =20 /* ---------------------------------------------------------------------- = */ =20 -static bool egl_gles; -static int egl_debug; - -#define egl_dbg(_x ...) \ - do { \ - if (egl_debug) { \ - fprintf(stderr, "egl: " _x); \ - } \ - } while (0); - -/* ---------------------------------------------------------------------- = */ - #ifdef CONFIG_OPENGL_DMABUF =20 int qemu_egl_rn_fd; @@ -105,7 +93,7 @@ int egl_rendernode_init(const char *rendernode) goto err; } =20 - qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev, false, fa= lse); + qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); =20 if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { @@ -171,8 +159,6 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, W= indow win) EGLSurface esurface; EGLBoolean b; =20 - egl_dbg("eglCreateWindowSurface (x11 win id 0x%lx) ...\n", - (unsigned long) win); esurface =3D eglCreateWindowSurface(qemu_egl_display, qemu_egl_config, (EGLNativeWindowType)win, NULL); @@ -242,7 +228,7 @@ static EGLDisplay qemu_egl_get_display(void *native) return dpy; } =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool gles, bool debug) +int qemu_egl_init_dpy(EGLNativeDisplayType dpy) { static const EGLint conf_att_gl[] =3D { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, @@ -253,56 +239,34 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool = gles, bool debug) EGL_ALPHA_SIZE, 0, EGL_NONE, }; - static const EGLint conf_att_gles[] =3D { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 5, - EGL_BLUE_SIZE, 5, - EGL_ALPHA_SIZE, 0, - EGL_NONE, - }; EGLint major, minor; EGLBoolean b; EGLint n; =20 - if (debug) { - egl_debug =3D 1; - setenv("EGL_LOG_LEVEL", "debug", true); - setenv("LIBGL_DEBUG", "verbose", true); - } - - egl_dbg("qemu_egl_get_display (dpy %p) ...\n", dpy); qemu_egl_display =3D qemu_egl_get_display(dpy); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { error_report("egl: eglGetDisplay failed"); return -1; } =20 - egl_dbg("eglInitialize ...\n"); b =3D eglInitialize(qemu_egl_display, &major, &minor); if (b =3D=3D EGL_FALSE) { error_report("egl: eglInitialize failed"); return -1; } =20 - egl_dbg("eglBindAPI ...\n"); - b =3D eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API); + b =3D eglBindAPI(EGL_OPENGL_API); if (b =3D=3D EGL_FALSE) { error_report("egl: eglBindAPI failed"); return -1; } =20 - egl_dbg("eglChooseConfig ...\n"); - b =3D eglChooseConfig(qemu_egl_display, - gles ? conf_att_gles : conf_att_gl, + b =3D eglChooseConfig(qemu_egl_display, conf_att_gl, &qemu_egl_config, 1, &n); if (b =3D=3D EGL_FALSE || n !=3D 1) { error_report("egl: eglChooseConfig failed"); return -1; } - - egl_gles =3D gles; return 0; } =20 @@ -311,17 +275,11 @@ EGLContext qemu_egl_init_ctx(void) static const EGLint ctx_att_gl[] =3D { EGL_NONE }; - static const EGLint ctx_att_gles[] =3D { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - EGLContext ectx; EGLBoolean b; =20 - egl_dbg("eglCreateContext ...\n"); ectx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, EGL_NO_CO= NTEXT, - egl_gles ? ctx_att_gles : ctx_att_gl); + ctx_att_gl); if (ectx =3D=3D EGL_NO_CONTEXT) { error_report("egl: eglCreateContext failed"); return NULL; diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index d53288f027..89492c0e02 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -246,7 +246,7 @@ void gtk_egl_init(void) GdkDisplay *gdk_display =3D gdk_display_get_default(); Display *x11_display =3D gdk_x11_display_get_xdisplay(gdk_display); =20 - if (qemu_egl_init_dpy(x11_display, false, false) < 0) { + if (qemu_egl_init_dpy(x11_display) < 0) { return; } =20 --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590302001533.1643730185087; Fri, 12 May 2017 04:58:22 -0700 (PDT) Received: from localhost ([::1]:53077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99DA-0000Rr-Lm for importer@patchew.org; Fri, 12 May 2017 07:58:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996n-0002t4-F1 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996m-00054v-8E for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996l-00054N-VJ for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8EE28BE70 for ; Fri, 12 May 2017 11:51:42 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 161984DA8E; Fri, 12 May 2017 11:51:41 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 0EEF780E6F; Fri, 12 May 2017 13:51:39 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D8EE28BE70 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D8EE28BE70 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:30 +0200 Message-Id: <20170512115135.17379-6-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 12 May 2017 11:51:43 +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] [PULL 05/10] egl-helpers: fix display init for x11 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When running on gtk we need X11 platform not mesa platform. Create separate functions for mesa and x11 so we can keep the egl #ifdef mess local to egl-helpers.c Fixes: 0ea1523fb6703aa0dcd65e66b59e96fec028e60a Signed-off-by: Gerd Hoffmann Message-id: 20170505104101.30589-4-kraxel@redhat.com --- include/ui/egl-helpers.h | 3 ++- ui/egl-helpers.c | 34 ++++++++++++++++++++++++++-------- ui/gtk-egl.c | 2 +- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index fec7da14a5..c785d60e91 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -21,7 +21,8 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *strid= e, EGLint *fourcc); =20 EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy); +int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy); +int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy); EGLContext qemu_egl_init_ctx(void); =20 #endif /* EGL_HELPERS_H */ diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index a3d7c3d7f5..ec2e325e21 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -93,7 +93,7 @@ int egl_rendernode_init(const char *rendernode) goto err; } =20 - qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); + qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); =20 if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { @@ -206,20 +206,19 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx,= Window win) * platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't s= eem * like mesa will be able to advertise these (even though it can do EGL 1.= 5). */ -static EGLDisplay qemu_egl_get_display(void *native) +static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native, + EGLenum platform) { EGLDisplay dpy =3D EGL_NO_DISPLAY; =20 -#ifdef EGL_MESA_platform_gbm /* In practise any EGL 1.5 implementation would support the EXT extens= ion */ if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) { PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =3D (void *) eglGetProcAddress("eglGetPlatformDisplayEXT"); - if (getPlatformDisplayEXT) { - dpy =3D getPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, native, N= ULL); + if (getPlatformDisplayEXT && platform !=3D 0) { + dpy =3D getPlatformDisplayEXT(platform, native, NULL); } } -#endif =20 if (dpy =3D=3D EGL_NO_DISPLAY) { /* fallback */ @@ -228,7 +227,8 @@ static EGLDisplay qemu_egl_get_display(void *native) return dpy; } =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy) +static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, + EGLenum platform) { static const EGLint conf_att_gl[] =3D { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, @@ -243,7 +243,7 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy) EGLBoolean b; EGLint n; =20 - qemu_egl_display =3D qemu_egl_get_display(dpy); + qemu_egl_display =3D qemu_egl_get_display(dpy, platform); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { error_report("egl: eglGetDisplay failed"); return -1; @@ -270,6 +270,24 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy) return 0; } =20 +int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy) +{ +#ifdef EGL_KHR_platform_x11 + return qemu_egl_init_dpy(dpy, EGL_PLATFORM_X11_KHR); +#else + return qemu_egl_init_dpy(dpy, 0); +#endif +} + +int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy) +{ +#ifdef EGL_MESA_platform_gbm + return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA); +#else + return qemu_egl_init_dpy(dpy, 0); +#endif +} + EGLContext qemu_egl_init_ctx(void) { static const EGLint ctx_att_gl[] =3D { diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 89492c0e02..cf48cca259 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -246,7 +246,7 @@ void gtk_egl_init(void) GdkDisplay *gdk_display =3D gdk_display_get_default(); Display *x11_display =3D gdk_x11_display_get_xdisplay(gdk_display); =20 - if (qemu_egl_init_dpy(x11_display) < 0) { + if (qemu_egl_init_dpy_x11(x11_display) < 0) { return; } =20 --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590024104957.3631916184653; Fri, 12 May 2017 04:53:44 -0700 (PDT) Received: from localhost ([::1]:53051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d998e-00043E-Va for importer@patchew.org; Fri, 12 May 2017 07:53:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996n-0002t1-5M for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996k-00053w-Mf for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996k-00053P-FZ for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C2B57F4BD for ; Fri, 12 May 2017 11:51:41 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1348D19E3D; Fri, 12 May 2017 11:51:41 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 280CA80F35; Fri, 12 May 2017 13:51:39 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5C2B57F4BD Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5C2B57F4BD From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:31 +0200 Message-Id: <20170512115135.17379-7-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 12 May 2017 11:51:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 06/10] egl-helpers: add missing error check 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Code didn't check for qemu_egl_init_dpy_mesa() failures, add it. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20170505104101.30589-5-kraxel@redhat.com --- ui/egl-helpers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index ec2e325e21..b50225158b 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -80,6 +80,7 @@ static int qemu_egl_rendernode_open(const char *rendernod= e) int egl_rendernode_init(const char *rendernode) { qemu_egl_rn_fd =3D -1; + int rc; =20 qemu_egl_rn_fd =3D qemu_egl_rendernode_open(rendernode); if (qemu_egl_rn_fd =3D=3D -1) { @@ -93,7 +94,11 @@ int egl_rendernode_init(const char *rendernode) goto err; } =20 - qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); + rc =3D qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_de= v); + if (rc !=3D 0) { + /* qemu_egl_init_dpy_mesa reports error */ + goto err; + } =20 if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590023923913.0002018383033; Fri, 12 May 2017 04:53:43 -0700 (PDT) Received: from localhost ([::1]:53053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d998g-00045M-Fe for importer@patchew.org; Fri, 12 May 2017 07:53:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996n-0002t3-5O for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996m-00054o-37 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996l-00054K-Ss for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B46B38B11B for ; Fri, 12 May 2017 11:51:42 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id B91BC19E3D; Fri, 12 May 2017 11:51:41 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 4442580A74; Fri, 12 May 2017 13:51:39 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B46B38B11B Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B46B38B11B From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:32 +0200 Message-Id: <20170512115135.17379-8-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 12 May 2017 11:51:42 +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] [PULL 07/10] egl: explicitly ask for core context 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann Message-id: 20170505104101.30589-6-kraxel@redhat.com --- ui/egl-context.c | 7 ++++--- ui/egl-helpers.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/egl-context.c b/ui/egl-context.c index 3a02b68d1a..2161969abe 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -7,9 +7,10 @@ QEMUGLContext qemu_egl_create_context(DisplayChangeListene= r *dcl, { EGLContext ctx; EGLint ctx_att[] =3D { - EGL_CONTEXT_CLIENT_VERSION, params->major_ver, - EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, - EGL_NONE + EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BI= T, + EGL_CONTEXT_CLIENT_VERSION, params->major_ver, + EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, + EGL_NONE }; =20 ctx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index b50225158b..4a4d3370ee 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -296,6 +296,7 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy) EGLContext qemu_egl_init_ctx(void) { static const EGLint ctx_att_gl[] =3D { + EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_B= IT, EGL_NONE }; EGLContext ectx; --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590418049708.8818519781205; Fri, 12 May 2017 05:00:18 -0700 (PDT) Received: from localhost ([::1]:53090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99F1-0001yG-Pt for importer@patchew.org; Fri, 12 May 2017 08:00:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996q-0002tI-7A for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996o-00056j-TW for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996o-000563-Kz for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 846EC7AE8B for ; Fri, 12 May 2017 11:51:45 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 336D278F04; Fri, 12 May 2017 11:51:42 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 69A5180FC5; Fri, 12 May 2017 13:51:39 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 846EC7AE8B Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 846EC7AE8B From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:33 +0200 Message-Id: <20170512115135.17379-9-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 12 May 2017 11:51:45 +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] [PULL 08/10] opengl: add egl-headless display 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: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add egl-headless user interface. It doesn't provide a real user interface, it only provides opengl support using drm render nodes. It will copy back the bits rendered by the guest using virgl back to a DisplaySurface and kick the usual display update code paths, so spice and vnc and screendump can pick it up. Use it this way: qemu -display egl-headless -vnc $display qemu -display egl-headless -spice gl=3Doff,$args Note that you should prefer native spice opengl support (-spice gl=3Don) if possible because that delivers better performance. Signed-off-by: Gerd Hoffmann Message-id: 20170505104101.30589-7-kraxel@redhat.com --- include/ui/console.h | 3 + ui/egl-headless.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ vl.c | 16 ++++++ ui/Makefile.objs | 1 + 4 files changed, 178 insertions(+) create mode 100644 ui/egl-headless.c diff --git a/include/ui/console.h b/include/ui/console.h index d759338816..7262bef6d3 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -527,4 +527,7 @@ static inline void early_gtk_display_init(int opengl) } #endif =20 +/* egl-headless.c */ +void egl_headless_init(void); + #endif diff --git a/ui/egl-headless.c b/ui/egl-headless.c new file mode 100644 index 0000000000..d8d800f8a6 --- /dev/null +++ b/ui/egl-headless.c @@ -0,0 +1,158 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "ui/console.h" +#include "ui/egl-helpers.h" +#include "ui/egl-context.h" + +typedef struct egl_dpy { + DisplayChangeListener dcl; + DisplaySurface *ds; + int width, height; + GLuint texture; + GLuint framebuffer; + GLuint blit_texture; + GLuint blit_framebuffer; + bool y_0_top; +} egl_dpy; + +static void egl_refresh(DisplayChangeListener *dcl) +{ + graphic_hw_update(dcl->con); +} + +static void egl_gfx_update(DisplayChangeListener *dcl, + int x, int y, int w, int h) +{ +} + +static void egl_gfx_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_surface) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->ds =3D new_surface; +} + +static void egl_scanout_disable(DisplayChangeListener *dcl) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->texture =3D 0; + /* XXX: delete framebuffers here ??? */ +} + +static void egl_scanout_texture(DisplayChangeListener *dcl, + uint32_t backing_id, + bool backing_y_0_top, + uint32_t backing_width, + uint32_t backing_height, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->texture =3D backing_id; + edpy->y_0_top =3D backing_y_0_top; + + /* source framebuffer */ + if (!edpy->framebuffer) { + glGenFramebuffers(1, &edpy->framebuffer); + } + glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->framebuffer); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, edpy->texture, 0); + + /* dest framebuffer */ + if (!edpy->blit_framebuffer) { + glGenFramebuffers(1, &edpy->blit_framebuffer); + glGenTextures(1, &edpy->blit_texture); + edpy->width =3D 0; + edpy->height =3D 0; + } + if (edpy->width !=3D backing_width || edpy->height !=3D backing_height= ) { + edpy->width =3D backing_width; + edpy->height =3D backing_height; + glBindTexture(GL_TEXTURE_2D, edpy->blit_texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, + edpy->width, edpy->height, + 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->blit_framebuffer); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0= _EXT, + GL_TEXTURE_2D, edpy->blit_texture, 0); + } +} + +static void egl_scanout_flush(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + GLuint y1, y2; + + if (!edpy->texture || !edpy->ds) { + return; + } + assert(surface_width(edpy->ds) =3D=3D edpy->width); + assert(surface_height(edpy->ds) =3D=3D edpy->height); + assert(surface_format(edpy->ds) =3D=3D PIXMAN_x8r8g8b8); + + /* blit framebuffer, flip if needed */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->framebuffer); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, edpy->blit_framebuffer); + glViewport(0, 0, edpy->width, edpy->height); + y1 =3D edpy->y_0_top ? edpy->height : 0; + y2 =3D edpy->y_0_top ? 0 : edpy->height; + glBlitFramebuffer(0, y1, edpy->width, y2, + 0, 0, edpy->width, edpy->height, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + /* read pixels to surface */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->blit_framebuffer); + glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); + glReadPixels(0, 0, edpy->width, edpy->height, + GL_BGRA, GL_UNSIGNED_BYTE, surface_data(edpy->ds)); + + /* notify about updates */ + dpy_gfx_update(edpy->dcl.con, x, y, w, h); +} + +static const DisplayChangeListenerOps egl_ops =3D { + .dpy_name =3D "egl-headless", + .dpy_refresh =3D egl_refresh, + .dpy_gfx_update =3D egl_gfx_update, + .dpy_gfx_switch =3D egl_gfx_switch, + + .dpy_gl_ctx_create =3D qemu_egl_create_context, + .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, + .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, + .dpy_gl_ctx_get_current =3D qemu_egl_get_current_context, + + .dpy_gl_scanout_disable =3D egl_scanout_disable, + .dpy_gl_scanout_texture =3D egl_scanout_texture, + .dpy_gl_update =3D egl_scanout_flush, +}; + +void egl_headless_init(void) +{ + QemuConsole *con; + egl_dpy *edpy; + int idx; + + if (egl_rendernode_init(NULL) < 0) { + error_report("egl: render node init failed"); + exit(1); + } + + for (idx =3D 0;; idx++) { + con =3D qemu_console_lookup_by_index(idx); + if (!con || !qemu_console_is_graphic(con)) { + break; + } + + edpy =3D g_new0(egl_dpy, 1); + edpy->dcl.con =3D con; + edpy->dcl.ops =3D &egl_ops; + register_displaychangelistener(&edpy->dcl); + } +} diff --git a/vl.c b/vl.c index 58023fca02..aca99e1c77 100644 --- a/vl.c +++ b/vl.c @@ -2050,6 +2050,7 @@ typedef enum DisplayType { DT_SDL, DT_COCOA, DT_GTK, + DT_EGL, DT_NONE, } DisplayType; =20 @@ -2127,6 +2128,15 @@ static DisplayType select_display(const char *p) error_report("VNC requires a display argument vnc=3D"= ); exit(1); } + } else if (strstart(p, "egl-headless", &opts)) { +#ifdef CONFIG_OPENGL + request_opengl =3D 1; + display_opengl =3D 1; + display =3D DT_EGL; +#else + fprintf(stderr, "egl support is disabled\n"); + exit(1); +#endif } else if (strstart(p, "curses", &opts)) { #ifdef CONFIG_CURSES display =3D DT_CURSES; @@ -4659,6 +4669,12 @@ int main(int argc, char **argv, char **envp) qemu_spice_display_init(); } =20 +#ifdef CONFIG_OPENGL + if (display_type =3D=3D DT_EGL) { + egl_headless_init(); + } +#endif + if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { exit(1); } diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 27566b32f1..aac6ae8bef 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -33,6 +33,7 @@ common-obj-y +=3D shader.o common-obj-y +=3D console-gl.o common-obj-y +=3D egl-helpers.o common-obj-y +=3D egl-context.o +common-obj-y +=3D egl-headless.o ifeq ($(CONFIG_GTK_GL),y) common-obj-$(CONFIG_GTK) +=3D gtk-gl-area.o else --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494590170965319.65613507588944; Fri, 12 May 2017 04:56:10 -0700 (PDT) Received: from localhost ([::1]:53065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99B3-0006by-K6 for importer@patchew.org; Fri, 12 May 2017 07:56:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996o-0002tE-86 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996n-00055J-5g for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46282) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996m-00054z-VY for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7BD337EE1; Fri, 12 May 2017 11:51:43 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5259B8D56D; Fri, 12 May 2017 11:51:42 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8224F80FD1; Fri, 12 May 2017 13:51:39 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7BD337EE1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D7BD337EE1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:34 +0200 Message-Id: <20170512115135.17379-10-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 11:51:44 +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] [PULL 09/10] vnc: simple clean up 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: Wei Qi , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Qi It is unnecessary to assign 'packed_bytes' to 'estimated_bytes', because 'e= stimated_bytes' unused after assignment. Signed-off-by: Wei Qi Reviewed-by: Sahid Orentino Ferdjaoui Signed-off-by: Gerd Hoffmann --- ui/vnc-enc-zrle.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/vnc-enc-zrle.c b/ui/vnc-enc-zrle.c index 5489870e70..fd63d4f688 100644 --- a/ui/vnc-enc-zrle.c +++ b/ui/vnc-enc-zrle.c @@ -163,7 +163,6 @@ static void zrle_choose_palette_rle(VncState *vs, int w= , int h, if (packed_bytes < estimated_bytes) { *use_rle =3D false; *use_palette =3D true; - estimated_bytes =3D packed_bytes; } } } --=20 2.9.3 From nobody Thu May 2 05:05:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149459017484838.28637134748794; Fri, 12 May 2017 04:56:14 -0700 (PDT) Received: from localhost ([::1]:53068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d99B6-0006eQ-H3 for importer@patchew.org; Fri, 12 May 2017 07:56:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d996p-0002tG-Ig for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d996o-00056R-JM for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7915) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d996o-00055x-E6 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49219C05AA42; Fri, 12 May 2017 11:51:44 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1D054DA83; Fri, 12 May 2017 11:51:43 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 9EC6480F99; Fri, 12 May 2017 13:51:39 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49219C05AA42 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49219C05AA42 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 13:51:35 +0200 Message-Id: <20170512115135.17379-11-kraxel@redhat.com> In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com> References: <20170512115135.17379-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 11:51:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 10/10] vnc: replace hweight_long() with ctpopl() 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater ctpopl() has a better implementation than hweight_long() and ui/vnc.c being the last user of hweight_long(), we can simply remove it. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Message-id: 1489415605-13105-1-git-send-email-clg@kaod.org Signed-off-by: Gerd Hoffmann --- include/qemu/bitops.h | 10 ---------- ui/vnc.c | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index 1881284cb5..3f0926cf40 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -201,16 +201,6 @@ static inline unsigned long find_first_zero_bit(const = unsigned long *addr, return find_next_zero_bit(addr, size, 0); } =20 -static inline unsigned long hweight_long(unsigned long w) -{ - unsigned long count; - - for (count =3D 0; w; w >>=3D 1) { - count +=3D w & 1; - } - return count; -} - /** * rol8 - rotate an 8-bit value left * @word: value to rotate diff --git a/ui/vnc.c b/ui/vnc.c index 601f9ec539..47b49c7318 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2061,15 +2061,15 @@ static void set_pixel_format(VncState *vs, int bits= _per_pixel, } =20 vs->client_pf.rmax =3D red_max ? red_max : 0xFF; - vs->client_pf.rbits =3D hweight_long(red_max); + vs->client_pf.rbits =3D ctpopl(red_max); vs->client_pf.rshift =3D red_shift; vs->client_pf.rmask =3D red_max << red_shift; vs->client_pf.gmax =3D green_max ? green_max : 0xFF; - vs->client_pf.gbits =3D hweight_long(green_max); + vs->client_pf.gbits =3D ctpopl(green_max); vs->client_pf.gshift =3D green_shift; vs->client_pf.gmask =3D green_max << green_shift; vs->client_pf.bmax =3D blue_max ? blue_max : 0xFF; - vs->client_pf.bbits =3D hweight_long(blue_max); + vs->client_pf.bbits =3D ctpopl(blue_max); vs->client_pf.bshift =3D blue_shift; vs->client_pf.bmask =3D blue_max << blue_shift; vs->client_pf.bits_per_pixel =3D bits_per_pixel; --=20 2.9.3