virtio-gl: allow multitarget configuration with virtio GL support
authorIgor Mitsyanko <i.mitsyanko@samsung.com>
Wed, 27 Jun 2012 13:05:26 +0000 (17:05 +0400)
committerEvgeny Voevodin <e.voevodin@samsung.com>
Fri, 6 Jul 2012 07:58:31 +0000 (11:58 +0400)
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 <i.mitsyanko@samsung.com>
configure
hw/virtio-pci.c
hw/virtio.h
tizen/src/Makefile.tizen
tizen/src/hw/virtio-gl-stub.c [new file with mode: 0644]
vl.c

index be236b8..c36afd2 100755 (executable)
--- 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
index 5c02ca5..19c0b07 100644 (file)
@@ -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)
index f5ae77f..0b73282 100644 (file)
@@ -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);
index fcffc99..bc071a7 100755 (executable)
@@ -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 (file)
index 0000000..57fc77a
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+
+#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 9ce9d98..0b25199 100644 (file)
--- 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);
 
@@ -3409,7 +3407,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
      * when encountering either of the logging options (-d or -D) because the