From 3a831fc0dfa5620cbd2ba1d66e8aa3a83bf475ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 30 Jan 2019 13:00:02 +0100 Subject: hw/display: Move Milkymist specific hardware out of common-obj list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Milkymist specific hardware is only used by the LM32 target, it is pointless to compile those objects in other targets. Signed-off-by: Philippe Mathieu-Daudé Message-id: 20190130120005.23123-2-philmd@redhat.com Signed-off-by: Gerd Hoffmann --- hw/display/Makefile.objs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs index 97acd5b..5b77081 100644 --- a/hw/display/Makefile.objs +++ b/hw/display/Makefile.objs @@ -25,10 +25,10 @@ common-obj-$(CONFIG_BOCHS_DISPLAY) += edid-region.o common-obj-$(CONFIG_BLIZZARD) += blizzard.o common-obj-$(CONFIG_EXYNOS4) += exynos4210_fimd.o common-obj-$(CONFIG_FRAMEBUFFER) += framebuffer.o -common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o +obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o common-obj-$(CONFIG_ZAURUS) += tc6393xb.o -common-obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o +obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o milkymist-tmu2.o-cflags := $(X11_CFLAGS) milkymist-tmu2.o-libs := $(X11_LIBS) -- cgit v1.1 From 57d434407adc967a696d7afad0cc32f8f7eb4a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 30 Jan 2019 13:00:04 +0100 Subject: hw/display/milkymist-tmu2: Explicit the dependency to both X11 / OpenGL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TMU device requires both X11 and OpenGL. Signed-off-by: Philippe Mathieu-Daudé Message-id: 20190130120005.23123-4-philmd@redhat.com Signed-off-by: Gerd Hoffmann --- hw/display/Makefile.objs | 4 ++-- hw/lm32/milkymist-hw.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'hw') diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs index 5b77081..7c4ae9a 100644 --- a/hw/display/Makefile.objs +++ b/hw/display/Makefile.objs @@ -29,8 +29,8 @@ obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o common-obj-$(CONFIG_ZAURUS) += tc6393xb.o obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o -milkymist-tmu2.o-cflags := $(X11_CFLAGS) -milkymist-tmu2.o-libs := $(X11_LIBS) +milkymist-tmu2.o-cflags := $(X11_CFLAGS) $(OPENGL_CFLAGS) +milkymist-tmu2.o-libs := $(X11_LIBS) $(OPENGL_LIBS) obj-$(CONFIG_OMAP) += omap_dss.o obj-$(CONFIG_OMAP) += omap_lcdc.o diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h index d3be0cf..32c344e 100644 --- a/hw/lm32/milkymist-hw.h +++ b/hw/lm32/milkymist-hw.h @@ -88,7 +88,7 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base, return dev; } -#ifdef CONFIG_OPENGL +#if defined(CONFIG_X11) && defined(CONFIG_OPENGL) #include #include #include @@ -103,7 +103,7 @@ static const int glx_fbconfig_attr[] = { static inline DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq) { -#ifdef CONFIG_OPENGL +#if defined(CONFIG_X11) && defined(CONFIG_OPENGL) DeviceState *dev; Display *d; GLXFBConfig *configs; -- cgit v1.1 From 70cc0c1fb0b7b7bc185ca4a233e215ef44f35913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 30 Jan 2019 13:00:05 +0100 Subject: hw/display/milkymist-tmu2: Move inlined code from header to source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/display/milkymist-tmu2.c | 49 +++++++++++++++++++++++++++++++++++ hw/lm32/milkymist-hw.h | 63 --------------------------------------------- hw/lm32/milkymist.c | 1 + 3 files changed, 50 insertions(+), 63 deletions(-) (limited to 'hw') diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c index 3ce44fd..b33fc23 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-hw.h b/hw/lm32/milkymist-hw.h index 32c344e..976cf92 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/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index 63c6894..26a2398 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" -- cgit v1.1