From: Igor Mitsyanko Date: Wed, 27 Jun 2012 13:05:26 +0000 (+0400) Subject: virtio-gl: allow multitarget configuration with virtio GL support X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1405^2~89 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2317d8c3df927b11ad93695f7698481baceb654f;p=sdk%2Femulator%2Fqemu.git virtio-gl: allow multitarget configuration with virtio GL support Virtio GL support now is separated into host and target parts, therefore making it possible to configure QEMU for miltiple targets even if one target doesn't have a virtio GL support. Drop #ifdef _WIN32 around #ifdef CONFIG_GL in source and makefile files, check this in configure script instead. Signed-off-by: Igor Mitsyanko --- diff --git a/configure b/configure index be236b800f..c36afd2f84 100755 --- a/configure +++ b/configure @@ -3490,7 +3490,14 @@ if test "$maru" = "yes" ; then echo "CONFIG_MARU=y" >> $config_host_mak fi # - +if test "$gl" = "yes" ; then + if test "$mingw32" = "yes" ; then + echo "ERROR: Virtio GL not supported for Windows" + gl="no" + else + echo "CONFIG_VIRTIO_GL=y" >> $config_host_mak + fi +fi # use default implementation for tracing backend-specific routines trace_default=yes echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak @@ -3825,9 +3832,6 @@ case "$target_arch2" in else echo "CONFIG_NO_XEN=y" >> $config_target_mak fi - if test "$gl" = "yes" ; then - echo "CONFIG_GL=y" >> $config_target_mak - fi ;; *) echo "CONFIG_NO_XEN=y" >> $config_target_mak @@ -3863,6 +3867,21 @@ if test "$ldst_optimization" = "yes" ; then echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_target_mak fi fi +if test "$gl" = "yes" ; then + case "$target_arch2" in + i386|x86_64) + echo "CONFIG_GL=y" >> $config_target_mak + if test "$mingw32" = "yes" ; then + echo "LIBS+=-lopengl32 -lglu32" >> $config_target_mak + else + echo "LIBS+=-lGL -lGLU -lXcomposite -lXext -ldl" >> $config_target_mak + fi + ;; + *) + echo "CONFIG_NO_GL=y" >> $config_target_mak + ;; + esac +fi if test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then echo "CONFIG_PSERIES=y" >> $config_target_mak fi @@ -4047,14 +4066,6 @@ if test "$target_softmmu" = "yes" ; then ;; i386|mips|ppc) cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags" - if test "$gl" = "yes" ; then - echo "CONFIG_GL=y" >> $config_host_mak - if test "$mingw32" = "yes" ; then - echo "LIBS+=-lopengl32 -lglu32" >> $config_host_mak - else - echo "LIBS+=-lGL -lGLU -lXcomposite -lXext -ldl" >> $config_host_mak - fi - fi ;; esac fi diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 5c02ca5988..19c0b078fd 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -810,9 +810,7 @@ static int virtio_balloon_exit_pci(PCIDevice *pci_dev) return virtio_exit_pci(pci_dev); } -#ifndef _WIN32 -#ifdef CONFIG_GL -extern VirtIODevice *virtio_gl_init(DeviceState *dev); +#ifdef CONFIG_VIRTIO_GL static int virtio_gl_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); @@ -826,7 +824,6 @@ static int virtio_gl_init_pci(PCIDevice *pci_dev) return 0; } #endif -#endif static Property virtio_blk_properties[] = { DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0), @@ -1011,8 +1008,7 @@ static TypeInfo virtio_scsi_info = { }; -#ifndef _WIN32 -#ifdef CONFIG_GL +#ifdef CONFIG_VIRTIO_GL static void virtio_gl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -1034,7 +1030,6 @@ static TypeInfo virtio_gl_info = { .class_init = virtio_gl_class_init, }; #endif -#endif static void virtio_pci_register_types(void) { @@ -1043,12 +1038,9 @@ static void virtio_pci_register_types(void) type_register_static(&virtio_serial_info); type_register_static(&virtio_balloon_info); type_register_static(&virtio_scsi_info); -#ifndef _WIN32 -#ifdef CONFIG_GL +#ifdef CONFIG_VIRTIO_GL type_register_static(&virtio_gl_info); #endif -#endif - } type_init(virtio_pci_register_types) diff --git a/hw/virtio.h b/hw/virtio.h index f5ae77fa2d..0b73282578 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -207,7 +207,9 @@ VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *conf); #ifdef CONFIG_LINUX VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf); #endif - +#ifdef CONFIG_VIRTIO_GL +VirtIODevice *virtio_gl_init(DeviceState *dev); +#endif void virtio_net_exit(VirtIODevice *vdev); void virtio_blk_exit(VirtIODevice *vdev); diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index fcffc99911..bc071a7bb6 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -30,11 +30,10 @@ else GL_CFLAGS := -Wall -g -O2 -fno-strict-aliasing endif -ifndef CONFIG_WIN32 ########################################################### ## Build openGL # i386 -ifeq ($(TARGET_ARCH), i386) +ifdef CONFIG_GL GL_CUR_PATH = $(SRC_PATH)/tizen/src/hw @@ -57,9 +56,8 @@ mesa_mipmap.o : mesa_mipmap.c opengl_exec.o : opengl_exec.c server_stub.c opengl_func.h gl_beginend.h opengl_process.h mesa_mipmap.o $(CC) $(GL_CFLAGS) $(DEFINES) $(GL_LDFLAGS) -c -o $@ $< -endif #($(TARGET_ARCH), i386) +endif #CONFIG_GL ########################################################### -endif #CONFIG_WIN32 # maru loader obj-y += emulator.o emul_state.o option.o maru_err_table.o @@ -118,6 +116,9 @@ obj-arm-y += guest_server.o ifndef CONFIG_WIN32 ########################################################### ## opengl library for i386 -obj-i386-y += virtio-gl.o helper_opengl.o opengl_exec.o mesa_mipmap.o gloffscreen_common.o gloffscreen_xcomposite.o gloffscreen_wgl.o gloffscreen_test.o +obj-$(CONFIG_GL) += virtio-gl.o +obj-$(CONFIG_GL) += helper_opengl.o opengl_exec.o mesa_mipmap.o gloffscreen_common.o +obj-$(CONFIG_GL) += gloffscreen_test.o gloffscreen_xcomposite.o gloffscreen_wgl.o +obj-$(CONFIG_NO_GL) += virtio-gl-stub.o ########################################################### endif diff --git a/tizen/src/hw/virtio-gl-stub.c b/tizen/src/hw/virtio-gl-stub.c new file mode 100644 index 0000000000..57fc77a3a3 --- /dev/null +++ b/tizen/src/hw/virtio-gl-stub.c @@ -0,0 +1,30 @@ +/* + * Virtio GL stub functions + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "virtio.h" +int gl_acceleration_capability_check(void); + +VirtIODevice *virtio_gl_init(DeviceState *dev) +{ + return NULL; +} + +int gl_acceleration_capability_check (void) +{ + return 1; +} diff --git a/vl.c b/vl.c index 9ce9d987c1..0b25199577 100644 --- a/vl.c +++ b/vl.c @@ -195,7 +195,6 @@ int qemu_main(int argc, char **argv, char **envp); #define MAX_VIRTIO_CONSOLES 1 #ifdef CONFIG_MARU -#define VIRTIOGL_DEV_NAME "virtio-gl-pci" extern int tizen_base_port; int skin_disabled = 0; #endif @@ -262,8 +261,9 @@ int boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; //virtio-gl -#ifndef _WIN32 -extern int gl_acceleration_capability_check (void); +#ifdef CONFIG_VIRTIO_GL +#define VIRTIOGL_DEV_NAME "virtio-gl-pci" +int gl_acceleration_capability_check(void); int enable_gl = 1; #endif @@ -1896,7 +1896,7 @@ static int device_init_func(QemuOpts *opts, void *opaque) { DeviceState *dev; -#ifndef _WIN32 +#ifdef CONFIG_VIRTIO_GL // virtio-gl pci device if (!enable_gl) { // ignore virtio-gl-pci device, even if users set it in option. @@ -3110,7 +3110,7 @@ int main(int argc, char **argv, char **envp) qemu_opts_parse(olist, "accel=kvm", 0); break; case QEMU_OPTION_enable_gl: -#ifndef _WIN32 +#ifdef CONFIG_VIRTIO_GL enable_gl = 1; #endif break; @@ -3384,18 +3384,16 @@ int main(int argc, char **argv, char **envp) exit(0); } -#ifndef _WIN32 -#ifdef CONFIG_GL +#ifdef CONFIG_VIRTIO_GL if (enable_gl && (gl_acceleration_capability_check () != 0)) { enable_gl = 0; fprintf (stderr, "Warn: GL acceleration was disabled due to the fail of GL check!\n"); } - + // To check host gl driver capability and notify to guest. gchar *tmp = tmp_cmdline; tmp_cmdline = g_strdup_printf("%s gles=%d", tmp, enable_gl); - qemu_opts_set(qemu_find_opts("machine"), 0, "append", - tmp_cmdline); + qemu_opts_set(qemu_find_opts("machine"), 0, "append", tmp_cmdline); fprintf(stdout, "kernel command : %s\n", tmp_cmdline); g_free(tmp); @@ -3408,7 +3406,6 @@ int main(int argc, char **argv, char **envp) } } } -#endif #endif /* Open the logfile at this point, if necessary. We can't open the logfile