aboutsummaryrefslogtreecommitdiff
path: root/hw/display
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2019-01-30 13:00:05 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-02-01 11:58:50 +0100
commit70cc0c1fb0b7b7bc185ca4a233e215ef44f35913 (patch)
treee27600fffa8afa5da73c536cd1d63c6b80f8023d /hw/display
parent57d434407adc967a696d7afad0cc32f8f7eb4a4f (diff)
downloadqemu-70cc0c1fb0b7b7bc185ca4a233e215ef44f35913.zip
qemu-70cc0c1fb0b7b7bc185ca4a233e215ef44f35913.tar.gz
qemu-70cc0c1fb0b7b7bc185ca4a233e215ef44f35913.tar.bz2
hw/display/milkymist-tmu2: Move inlined code from header to source
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é <philmd@redhat.com> Message-id: 20190130120005.23123-5-philmd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/display')
-rw-r--r--hw/display/milkymist-tmu2.c49
1 files changed, 49 insertions, 0 deletions
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 <X11/Xlib.h>
#include <epoxy/gl.h>
@@ -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;
+}