Message ID | 20190124011554.25418-5-philmd@redhat.com |
---|---|
State | New |
Headers | show |
Series | sdl: Let it be optional (in particular, on OpenBSD) | expand |
On Thu, Jan 24, 2019 at 02:15:54AM +0100, Philippe Mathieu-Daudé wrote: > 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. Oops, fails the build: LINK lm32-softmmu/qemu-system-lm32 hw/lm32/milkymist.o: In function `milkymist_init': milkymist.c:(.text+0xb0f): undefined reference to `milkymist_tmu2_create' cheers, Gerd
On 1/24/19 12:43 PM, Gerd Hoffmann wrote: > On Thu, Jan 24, 2019 at 02:15:54AM +0100, Philippe Mathieu-Daudé wrote: >> 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. > > Oops, fails the build: > > LINK lm32-softmmu/qemu-system-lm32 > hw/lm32/milkymist.o: In function `milkymist_init': > milkymist.c:(.text+0xb0f): undefined reference to `milkymist_tmu2_create' Funny, I was busy testing your other audio series while you were testing mine :) I'll have a look, thanks. Phil.
Cc'ing Thomas/Paolo for Makefile rules... On 1/24/19 12:43 PM, Gerd Hoffmann wrote: > On Thu, Jan 24, 2019 at 02:15:54AM +0100, Philippe Mathieu-Daudé wrote: >> 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. > > Oops, fails the build: > > LINK lm32-softmmu/qemu-system-lm32 > hw/lm32/milkymist.o: In function `milkymist_init': > milkymist.c:(.text+0xb0f): undefined reference to `milkymist_tmu2_create' The problem comes from patch #2: > diff --git a/default-configs/lm32-softmmu.mak b/default-configs/lm32-softmmu.mak > index 4889348a10..4049b23562 100644 > --- a/default-configs/lm32-softmmu.mak > +++ b/default-configs/lm32-softmmu.mak > @@ -2,7 +2,7 @@ > > CONFIG_LM32=y > CONFIG_MILKYMIST=y > -CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) > +CONFIG_MILKYMIST_TMU2=$(call land,$(CONFIG_X11),$(CONFIG_OPENGL)) > CONFIG_FRAMEBUFFER=y > CONFIG_PTIMER=y > CONFIG_PFLASH_CFI01=y > diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs > index 97acd5b6cb..079e702f25 100644 > --- a/hw/display/Makefile.objs > +++ b/hw/display/Makefile.objs > @@ -29,8 +29,8 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o > common-obj-$(CONFIG_ZAURUS) += tc6393xb.o > > common-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 Using $(call land) seems to break CONFIG_MILKYMIST_TMU2 availability in $(common-obj), while it works correctly in the per-target $(obj). I'm not sure what is the cause, but moving milkymist-tmu2.o to $(obj) makes more sense and fix this, so I'll go this way. Regards, Phil.
On Mon, 28 Jan 2019 at 17:47, Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > > Cc'ing Thomas/Paolo for Makefile rules... > > On 1/24/19 12:43 PM, Gerd Hoffmann wrote: > > Oops, fails the build: > > > > LINK lm32-softmmu/qemu-system-lm32 > > hw/lm32/milkymist.o: In function `milkymist_init': > > milkymist.c:(.text+0xb0f): undefined reference to `milkymist_tmu2_create' > > The problem comes from patch #2: > > > diff --git a/default-configs/lm32-softmmu.mak > b/default-configs/lm32-softmmu.mak > > index 4889348a10..4049b23562 100644 > > --- a/default-configs/lm32-softmmu.mak > > +++ b/default-configs/lm32-softmmu.mak > > @@ -2,7 +2,7 @@ > > > > CONFIG_LM32=y > > CONFIG_MILKYMIST=y > > -CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) > > +CONFIG_MILKYMIST_TMU2=$(call land,$(CONFIG_X11),$(CONFIG_OPENGL)) > > CONFIG_FRAMEBUFFER=y > > CONFIG_PTIMER=y > > CONFIG_PFLASH_CFI01=y > > diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs > > index 97acd5b6cb..079e702f25 100644 > > --- a/hw/display/Makefile.objs > > +++ b/hw/display/Makefile.objs > > @@ -29,8 +29,8 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o > > common-obj-$(CONFIG_ZAURUS) += tc6393xb.o > > > > common-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 > > Using $(call land) seems to break CONFIG_MILKYMIST_TMU2 availability in > $(common-obj), while it works correctly in the per-target $(obj). > I'm not sure what is the cause, but moving milkymist-tmu2.o to $(obj) > makes more sense and fix this, so I'll go this way. Something weird definitely seems to be going on here -- 'call land' ought not to be broken in this situation. I don't understand why the build/config-all-devices.mak versions of the defines of CONFIG_FOO variables are so weird: CONFIG_ACPI:=$(findstring y,$(CONFIG_ACPI)y) ...are they really intended to be self-referential like that? The per-target ones in build/foo-softmmu/config-devices.mak are more like what I expected: CONFIG_VGA=y Paolo, git blame says you wrote the makefile rune back in 2013: I don't suppose you can remember the intent ? thanks -- PMM
On 1/28/19 7:02 PM, Peter Maydell wrote: > On Mon, 28 Jan 2019 at 17:47, Philippe Mathieu-Daudé <philmd@redhat.com> wrote: >> >> Cc'ing Thomas/Paolo for Makefile rules... >> >> On 1/24/19 12:43 PM, Gerd Hoffmann wrote: >>> Oops, fails the build: >>> >>> LINK lm32-softmmu/qemu-system-lm32 >>> hw/lm32/milkymist.o: In function `milkymist_init': >>> milkymist.c:(.text+0xb0f): undefined reference to `milkymist_tmu2_create' >> >> The problem comes from patch #2: >> >>> diff --git a/default-configs/lm32-softmmu.mak >> b/default-configs/lm32-softmmu.mak >>> index 4889348a10..4049b23562 100644 >>> --- a/default-configs/lm32-softmmu.mak >>> +++ b/default-configs/lm32-softmmu.mak >>> @@ -2,7 +2,7 @@ >>> >>> CONFIG_LM32=y >>> CONFIG_MILKYMIST=y >>> -CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) >>> +CONFIG_MILKYMIST_TMU2=$(call land,$(CONFIG_X11),$(CONFIG_OPENGL)) >>> CONFIG_FRAMEBUFFER=y >>> CONFIG_PTIMER=y >>> CONFIG_PFLASH_CFI01=y >>> diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs >>> index 97acd5b6cb..079e702f25 100644 >>> --- a/hw/display/Makefile.objs >>> +++ b/hw/display/Makefile.objs >>> @@ -29,8 +29,8 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o >>> common-obj-$(CONFIG_ZAURUS) += tc6393xb.o >>> >>> common-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 >> >> Using $(call land) seems to break CONFIG_MILKYMIST_TMU2 availability in >> $(common-obj), while it works correctly in the per-target $(obj). >> I'm not sure what is the cause, but moving milkymist-tmu2.o to $(obj) >> makes more sense and fix this, so I'll go this way. > > Something weird definitely seems to be going on here -- 'call land' > ought not to be broken in this situation. > > I don't understand why the build/config-all-devices.mak versions of > the defines of CONFIG_FOO variables are so weird: > > CONFIG_ACPI:=$(findstring y,$(CONFIG_ACPI)y) > > ...are they really intended to be self-referential like that? > > The per-target ones in build/foo-softmmu/config-devices.mak are > more like what I expected: > > CONFIG_VGA=y > > Paolo, git blame says you wrote the makefile rune back in 2013: > I don't suppose you can remember the intent ? Now than Kconfig is in good usable shape, I'm pretty sure Paolo doesn't want to remember ;) Our time is better worth spent on Kconfig than fixing those issues. For this series goal (remove SDL1!) I'll go with moving LM32/Milkymist devices to $(obj). Hopefully the next patch will be in Kconfig :)
On 2019-01-28 18:47, Philippe Mathieu-Daudé wrote: > Cc'ing Thomas/Paolo for Makefile rules... > > On 1/24/19 12:43 PM, Gerd Hoffmann wrote: >> On Thu, Jan 24, 2019 at 02:15:54AM +0100, Philippe Mathieu-Daudé wrote: >>> 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. >> >> Oops, fails the build: >> >> LINK lm32-softmmu/qemu-system-lm32 >> hw/lm32/milkymist.o: In function `milkymist_init': >> milkymist.c:(.text+0xb0f): undefined reference to `milkymist_tmu2_create' > > The problem comes from patch #2: > >> diff --git a/default-configs/lm32-softmmu.mak > b/default-configs/lm32-softmmu.mak >> index 4889348a10..4049b23562 100644 >> --- a/default-configs/lm32-softmmu.mak >> +++ b/default-configs/lm32-softmmu.mak >> @@ -2,7 +2,7 @@ >> >> CONFIG_LM32=y >> CONFIG_MILKYMIST=y >> -CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) >> +CONFIG_MILKYMIST_TMU2=$(call land,$(CONFIG_X11),$(CONFIG_OPENGL)) >> CONFIG_FRAMEBUFFER=y >> CONFIG_PTIMER=y >> CONFIG_PFLASH_CFI01=y >> diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs >> index 97acd5b6cb..079e702f25 100644 >> --- a/hw/display/Makefile.objs >> +++ b/hw/display/Makefile.objs >> @@ -29,8 +29,8 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o >> common-obj-$(CONFIG_ZAURUS) += tc6393xb.o >> >> common-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 > > Using $(call land) seems to break CONFIG_MILKYMIST_TMU2 availability in > $(common-obj), while it works correctly in the per-target $(obj). > I'm not sure what is the cause, but moving milkymist-tmu2.o to $(obj) > makes more sense and fix this, so I'll go this way. You could try whether adding an additional common-obj-$(CONFIG_ALL) += milkymist-tmu2.o fixes the issue for you, too. OTOH, milkymist is only used by one target, so there is really no reason that this file should be added to common-obj, thus using $(obj) is fine here. Thomas
On 28/01/19 19:02, Peter Maydell wrote: > > I don't understand why the build/config-all-devices.mak versions of > the defines of CONFIG_FOO variables are so weird: > > CONFIG_ACPI:=$(findstring y,$(CONFIG_ACPI)y) > > ...are they really intended to be self-referential like that? Yes, config-all-devices.mak is basically on "OR" of all the config-devices.mak files. Are CONFIG_X11 and CONFIG_OPENGL defined at the time config-all-devices.mak is included? Paolo
On Tue, 29 Jan 2019 at 08:21, Paolo Bonzini <pbonzini@redhat.com> wrote: > > On 28/01/19 19:02, Peter Maydell wrote: > > > > I don't understand why the build/config-all-devices.mak versions of > > the defines of CONFIG_FOO variables are so weird: > > > > CONFIG_ACPI:=$(findstring y,$(CONFIG_ACPI)y) > > > > ...are they really intended to be self-referential like that? > > Yes, config-all-devices.mak is basically on "OR" of all the > config-devices.mak files. > > Are CONFIG_X11 and CONFIG_OPENGL defined at the time > config-all-devices.mak is included? They should be -- they're defined in config-host.mak, which Makefile includes before config-all-devices.mak. thanks -- PMM
diff --git a/MAINTAINERS b/MAINTAINERS index af339b86db..3c040f21e7 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/ 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 <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; +} 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 <X11/Xlib.h> -#include <epoxy/gl.h> -#include <epoxy/glx.h> -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 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/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 <michael@walle.cc> + * Copyright (c) 2010 Sebastien Bourdeauducq + * <sebastien.bourdeauducq@lekernel.net> + * + * 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 <http://www.gnu.org/licenses/>. + * + * + * 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 */
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> --- MAINTAINERS | 1 + hw/display/milkymist-tmu2.c | 49 ++++++++++++++++++++++ hw/lm32/milkymist-hw.h | 63 ----------------------------- hw/lm32/milkymist.c | 1 + include/hw/display/milkymist_tmu2.h | 41 +++++++++++++++++++ 5 files changed, 92 insertions(+), 63 deletions(-) create mode 100644 include/hw/display/milkymist_tmu2.h