From patchwork Fri Feb 1 12:30:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10792647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 118D0746 for ; Fri, 1 Feb 2019 12:33:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0141D3200F for ; Fri, 1 Feb 2019 12:33:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E91E132014; Fri, 1 Feb 2019 12:33:05 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 462113200F for ; Fri, 1 Feb 2019 12:33:05 +0000 (UTC) Received: from localhost ([127.0.0.1]:52841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpY0G-0003Uz-DZ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Feb 2019 07:33:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpXz0-0002Vw-Rc for qemu-devel@nongnu.org; Fri, 01 Feb 2019 07:31:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpXyz-0004kp-8Q for qemu-devel@nongnu.org; Fri, 01 Feb 2019 07:31:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47902) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpXyx-0004gS-8M for qemu-devel@nongnu.org; Fri, 01 Feb 2019 07:31:45 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C061414AF86; Fri, 1 Feb 2019 12:31:36 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6977E19742; Fri, 1 Feb 2019 12:31:01 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9ED1497BA; Fri, 1 Feb 2019 13:31:00 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 13:30:59 +0100 Message-Id: <20190201123100.27419-5-kraxel@redhat.com> In-Reply-To: <20190201123100.27419-1-kraxel@redhat.com> References: <20190201123100.27419-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 01 Feb 2019 12:31:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/5] hw/display/milkymist-tmu2: Move inlined code from header to source 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: libvir-list@redhat.com, Michael Walle , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Mathieu-Daudé Move the complexity of milkymist_tmu2_create() into the source file. Doing so we avoid to include the X11/OpenGL headers in all LM32 devices, and we also avoid the duplicate declaration of glx_fbconfig_attr[] (it is already declared in hw/display/milkymist-tmu2.c). Since TYPE_MILKYMIST_TMU2 is now accessible, use it. Signed-off-by: Philippe Mathieu-Daudé Message-id: 20190130120005.23123-5-philmd@redhat.com Signed-off-by: Gerd Hoffmann --- hw/lm32/milkymist-hw.h | 63 ------------------------------------- include/hw/display/milkymist_tmu2.h | 41 ++++++++++++++++++++++++ hw/display/milkymist-tmu2.c | 49 +++++++++++++++++++++++++++++ hw/lm32/milkymist.c | 1 + MAINTAINERS | 1 + 5 files changed, 92 insertions(+), 63 deletions(-) create mode 100644 include/hw/display/milkymist_tmu2.h diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h index 32c344ef9f..976cf9254d 100644 --- a/hw/lm32/milkymist-hw.h +++ b/hw/lm32/milkymist-hw.h @@ -88,69 +88,6 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base, return dev; } -#if defined(CONFIG_X11) && defined(CONFIG_OPENGL) -#include -#include -#include -static const int glx_fbconfig_attr[] = { - GLX_GREEN_SIZE, 5, - GLX_GREEN_SIZE, 6, - GLX_BLUE_SIZE, 5, - None -}; -#endif - -static inline DeviceState *milkymist_tmu2_create(hwaddr base, - qemu_irq irq) -{ -#if defined(CONFIG_X11) && defined(CONFIG_OPENGL) - DeviceState *dev; - Display *d; - GLXFBConfig *configs; - int nelements; - int ver_major, ver_minor; - - /* check that GLX will work */ - d = XOpenDisplay(NULL); - if (d == NULL) { - return NULL; - } - - if (!glXQueryVersion(d, &ver_major, &ver_minor)) { - /* Yeah, sometimes getting the GLX version can fail. - * Isn't X beautiful? */ - XCloseDisplay(d); - return NULL; - } - - if ((ver_major < 1) || ((ver_major == 1) && (ver_minor < 3))) { - printf("Your GLX version is %d.%d," - "but TMU emulation needs at least 1.3. TMU disabled.\n", - ver_major, ver_minor); - XCloseDisplay(d); - return NULL; - } - - configs = glXChooseFBConfig(d, 0, glx_fbconfig_attr, &nelements); - if (configs == NULL) { - XCloseDisplay(d); - return NULL; - } - - XFree(configs); - XCloseDisplay(d); - - dev = qdev_create(NULL, "milkymist-tmu2"); - qdev_init_nofail(dev); - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); - - return dev; -#else - return NULL; -#endif -} - static inline DeviceState *milkymist_ac97_create(hwaddr base, qemu_irq crrequest_irq, qemu_irq crreply_irq, qemu_irq dmar_irq, qemu_irq dmaw_irq) diff --git a/include/hw/display/milkymist_tmu2.h b/include/hw/display/milkymist_tmu2.h new file mode 100644 index 0000000000..148a119a1d --- /dev/null +++ b/include/hw/display/milkymist_tmu2.h @@ -0,0 +1,41 @@ +/* + * QEMU model of the Milkymist texture mapping unit. + * + * Copyright (c) 2010 Michael Walle + * Copyright (c) 2010 Sebastien Bourdeauducq + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * + * Specification available at: + * http://milkymist.walle.cc/socdoc/tmu2.pdf + * + */ + +#ifndef HW_DISPLAY_MILKYMIST_TMU2_H +#define HW_DISPLAY_MILKYMIST_TMU2_H + +#include "hw/qdev.h" + +#if defined(CONFIG_X11) && defined(CONFIG_OPENGL) +DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq); +#else +static inline DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq) +{ + return NULL; +} +#endif + +#endif /* HW_DISPLAY_MILKYMIST_TMU2_H */ diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c index 3ce44fdfce..b33fc234e9 100644 --- a/hw/display/milkymist-tmu2.c +++ b/hw/display/milkymist-tmu2.c @@ -31,6 +31,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "hw/display/milkymist_tmu2.h" #include #include @@ -499,3 +500,51 @@ static void milkymist_tmu2_register_types(void) } type_init(milkymist_tmu2_register_types) + +DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq) +{ + DeviceState *dev; + Display *d; + GLXFBConfig *configs; + int nelements; + int ver_major, ver_minor; + + /* check that GLX will work */ + d = XOpenDisplay(NULL); + if (d == NULL) { + return NULL; + } + + if (!glXQueryVersion(d, &ver_major, &ver_minor)) { + /* + * Yeah, sometimes getting the GLX version can fail. + * Isn't X beautiful? + */ + XCloseDisplay(d); + return NULL; + } + + if ((ver_major < 1) || ((ver_major == 1) && (ver_minor < 3))) { + printf("Your GLX version is %d.%d," + "but TMU emulation needs at least 1.3. TMU disabled.\n", + ver_major, ver_minor); + XCloseDisplay(d); + return NULL; + } + + configs = glXChooseFBConfig(d, 0, glx_fbconfig_attr, &nelements); + if (configs == NULL) { + XCloseDisplay(d); + return NULL; + } + + XFree(configs); + XCloseDisplay(d); + + dev = qdev_create(NULL, TYPE_MILKYMIST_TMU2); + qdev_init_nofail(dev); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); + + return dev; +} diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index 63c6894c95..26a2398354 100644 --- a/hw/lm32/milkymist.c +++ b/hw/lm32/milkymist.c @@ -32,6 +32,7 @@ #include "hw/loader.h" #include "elf.h" #include "milkymist-hw.h" +#include "hw/display/milkymist_tmu2.h" #include "lm32.h" #include "exec/address-spaces.h" diff --git a/MAINTAINERS b/MAINTAINERS index 234e5c413b..37ceda468f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -185,6 +185,7 @@ F: disas/lm32.c F: hw/lm32/ F: hw/*/lm32_* F: hw/*/milkymist-* +F: include/hw/display/milkymist_tmu2.h F: include/hw/char/lm32_juart.h F: include/hw/lm32/ F: tests/tcg/lm32/