build: Clean-up build related files 20/23320/8
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 23 Jun 2014 12:59:44 +0000 (21:59 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 24 Jun 2014 04:43:16 +0000 (13:43 +0900)
Apply new style Makefile system for emulator.
Clean-up Some include path and build path.
Make new directory "display", "util" under "tizen/src/"

We have no common object(common-obj) yet.

Change-Id: I3cb0dab21a8fc22e6b145b251906c4e53f0a86a4
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
99 files changed:
Makefile.target
hw/virtio/virtio-pci.h
hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen.c
hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_display.c
hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c
hw/yagl/yagl_device.c
hw/yagl/yagl_thread.c
hw/yagl/yagl_thread.h
tizen/src/Makefile
tizen/src/Makefile.objs [new file with mode: 0644]
tizen/src/Makefile.tizen [deleted file]
tizen/src/Makefile.tizen.arm [deleted file]
tizen/src/Makefile.tizen.i386 [deleted file]
tizen/src/check_cam.c [deleted file]
tizen/src/check_gl.c [deleted file]
tizen/src/check_gl.h [deleted file]
tizen/src/check_gl_cgl.c [deleted file]
tizen/src/check_gl_core.c [deleted file]
tizen/src/check_gl_glx.c [deleted file]
tizen/src/check_gl_wgl.c [deleted file]
tizen/src/check_hax.c [deleted file]
tizen/src/debug_ch.c
tizen/src/display/Makefile.objs [new file with mode: 0644]
tizen/src/display/maru_display.c [new file with mode: 0644]
tizen/src/display/maru_display.h [new file with mode: 0644]
tizen/src/display/maru_finger.c [new file with mode: 0644]
tizen/src/display/maru_finger.h [new file with mode: 0644]
tizen/src/display/maru_sdl.c [new file with mode: 0644]
tizen/src/display/maru_sdl.h [new file with mode: 0644]
tizen/src/display/maru_sdl_processing.c [new file with mode: 0644]
tizen/src/display/maru_sdl_processing.h [new file with mode: 0644]
tizen/src/display/maru_shm.c [new file with mode: 0644]
tizen/src/display/maru_shm.h [new file with mode: 0644]
tizen/src/ecs/Makefile.objs [new file with mode: 0644]
tizen/src/ecs/Makefile.tizen [deleted file]
tizen/src/ecs/ecs.c
tizen/src/ecs/ecs.h
tizen/src/ecs/ecs_msg.c
tizen/src/ecs/ecs_tethering.c
tizen/src/emul_state.h
tizen/src/emulator.c
tizen/src/emulator_legacy.c
tizen/src/guest_server.c
tizen/src/hw/Makefile.objs [new file with mode: 0644]
tizen/src/hw/Makefile.objs.arm [new file with mode: 0644]
tizen/src/hw/maru_arm_board.c
tizen/src/hw/maru_brill_codec.h
tizen/src/hw/maru_camera_common_pci.c
tizen/src/hw/maru_camera_darwin_converter.c
tizen/src/hw/maru_camera_darwin_pci.m
tizen/src/hw/maru_camera_linux_pci.c
tizen/src/hw/maru_camera_win32_pci.c
tizen/src/hw/maru_codec.h
tizen/src/hw/maru_virtio_evdi.c
tizen/src/hw/maru_virtio_keyboard.c
tizen/src/hw/maru_virtio_nfc.c
tizen/src/hw/maru_virtio_sensor.c
tizen/src/hw/maru_virtio_vmodem.c
tizen/src/maru_display.c [deleted file]
tizen/src/maru_display.h [deleted file]
tizen/src/maru_finger.c [deleted file]
tizen/src/maru_finger.h [deleted file]
tizen/src/maru_sdl.c [deleted file]
tizen/src/maru_sdl.h [deleted file]
tizen/src/maru_sdl_processing.c [deleted file]
tizen/src/maru_sdl_processing.h [deleted file]
tizen/src/maru_shm.c [deleted file]
tizen/src/maru_shm.h [deleted file]
tizen/src/osutil-darwin.c [deleted file]
tizen/src/osutil-linux.c [deleted file]
tizen/src/osutil-win32.c [deleted file]
tizen/src/osutil.c [deleted file]
tizen/src/osutil.h [deleted file]
tizen/src/sdb.c [deleted file]
tizen/src/sdb.h [deleted file]
tizen/src/skin/Makefile.objs [new file with mode: 0644]
tizen/src/skin/maruskin_client.c
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_server.c
tizen/src/tethering/Makefile.objs [new file with mode: 0644]
tizen/src/tethering/Makefile.tizen [deleted file]
tizen/src/tethering/app_tethering.c
tizen/src/util/Makefile.objs [new file with mode: 0644]
tizen/src/util/check_cam.c [new file with mode: 0644]
tizen/src/util/check_gl.c [new file with mode: 0644]
tizen/src/util/check_gl.h [new file with mode: 0644]
tizen/src/util/check_gl_cgl.c [new file with mode: 0644]
tizen/src/util/check_gl_core.c [new file with mode: 0644]
tizen/src/util/check_gl_glx.c [new file with mode: 0644]
tizen/src/util/check_gl_wgl.c [new file with mode: 0644]
tizen/src/util/check_hax.c [new file with mode: 0644]
tizen/src/util/osutil-darwin.c [new file with mode: 0644]
tizen/src/util/osutil-linux.c [new file with mode: 0644]
tizen/src/util/osutil-win32.c [new file with mode: 0644]
tizen/src/util/osutil.c [new file with mode: 0644]
tizen/src/util/osutil.h [new file with mode: 0644]
tizen/src/util/sdb.c [new file with mode: 0644]
tizen/src/util/sdb.h [new file with mode: 0644]
vl.c

index 3f214964a464d85028e5387b4e54ea84a8f54808..5d3bb3fb56bc68a71e13f9f642ca97ccfe6bd609 100644 (file)
@@ -142,6 +142,12 @@ endif
 
 GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
 
+# Makefile for TIZEN-maru
+ifdef CONFIG_MARU
+obj-y += tizen/src/
+endif
+##
+
 endif # CONFIG_SOFTMMU
 
 # Workaround for http://gcc.gnu.org/PR55489, see configure.
@@ -166,12 +172,6 @@ dummy := $(call unnest-vars,.., \
 # Now restore obj-y
 obj-y := $(obj-y-save)
 
-# Makefile for TIZEN-maru
-ifdef CONFIG_MARU
-include $(SRC_PATH)/tizen/src/Makefile.tizen
-endif
-##
-
 all-obj-y = $(obj-y) $(common-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
@@ -213,16 +213,16 @@ endif
 
 check-gl: $(CHECK_GL_OBJS)
        gcc -o $(CHECK_GL_TARGET) $(CHECK_GL_OBJS) $(CHECK_GL_LDFLAGS)
-check_gl.o: check_gl.c
-       gcc -c ../tizen/src/check_gl.c -I../hw/yagl/yagl_inc
-check_gl_core.o: check_gl_core.c
-       gcc -c ../tizen/src/check_gl_core.c -I../hw/yagl/yagl_inc
-check_gl_glx.o: check_gl_glx.c
-       gcc -c ../tizen/src/check_gl_glx.c -I../hw/yagl/yagl_inc
-check_gl_wgl.o: check_gl_wgl.c
-       gcc -c ../tizen/src/check_gl_wgl.c -I../hw/yagl/yagl_inc
-check_gl_cgl.o: check_gl_cgl.c
-       gcc -c ../tizen/src/check_gl_cgl.c -I../hw/yagl/yagl_inc
+check_gl.o:
+       gcc -c $(SRC_PATH)/tizen/src/util/check_gl.c -I$(SRC_PATH)/hw/yagl/yagl_inc
+check_gl_core.o:
+       gcc -c $(SRC_PATH)/tizen/src/util/check_gl_core.c -I$(SRC_PATH)/hw/yagl/yagl_inc
+check_gl_glx.o:
+       gcc -c $(SRC_PATH)/tizen/src/util/check_gl_glx.c -I$(SRC_PATH)/hw/yagl/yagl_inc
+check_gl_wgl.o:
+       gcc -c $(SRC_PATH)/tizen/src/util/check_gl_wgl.c -I$(SRC_PATH)/hw/yagl/yagl_inc
+check_gl_cgl.o:
+       gcc -c $(SRC_PATH)/tizen/src/util/check_gl_cgl.c -I$(SRC_PATH)/hw/yagl/yagl_inc
 
 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
        $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"  GEN   $(TARGET_DIR)$@")
index 685bef908157e5a89aae75e58b57a6767f706c27..219893ebe76ddf33e4c8f1d449e6c15a995213cf 100644 (file)
 #endif
 
 #ifdef CONFIG_MARU
-#include "../tizen/src/mloop_event.h"
-#include "../tizen/src/hw/maru_device_ids.h"
-#include "../tizen/src/hw/maru_virtio_evdi.h"
-#include "../tizen/src/hw/maru_virtio_esm.h"
-#include "../tizen/src/hw/maru_virtio_hwkey.h"
-#include "../tizen/src/hw/maru_virtio_keyboard.h"
-#include "../tizen/src/hw/maru_virtio_touchscreen.h"
-#include "../tizen/src/hw/maru_virtio_sensor.h"
-#include "../tizen/src/hw/maru_virtio_jack.h"
-#include "../tizen/src/hw/maru_virtio_power.h"
-#include "../tizen/src/hw/maru_virtio_nfc.h"
-#include "../tizen/src/hw/maru_virtio_vmodem.h"
+#include "tizen/src/mloop_event.h"
+#include "tizen/src/hw/maru_device_ids.h"
+#include "tizen/src/hw/maru_virtio_evdi.h"
+#include "tizen/src/hw/maru_virtio_esm.h"
+#include "tizen/src/hw/maru_virtio_hwkey.h"
+#include "tizen/src/hw/maru_virtio_keyboard.h"
+#include "tizen/src/hw/maru_virtio_touchscreen.h"
+#include "tizen/src/hw/maru_virtio_sensor.h"
+#include "tizen/src/hw/maru_virtio_jack.h"
+#include "tizen/src/hw/maru_virtio_power.h"
+#include "tizen/src/hw/maru_virtio_nfc.h"
+#include "tizen/src/hw/maru_virtio_vmodem.h"
 #endif
 
 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
index 7c550fa9fce58fec785b256e081e8c2d29273370..958e807d4d3b3fa36f997249225aef107626b641 100644 (file)
@@ -38,7 +38,7 @@
 #include "yagl_process.h"
 #include "yagl_thread.h"
 #include "yagl_gles_driver.h"
-#include "vigs/winsys_gl.h"
+#include "hw/vigs/winsys_gl.h"
 
 YAGL_DEFINE_TLS(struct yagl_egl_onscreen_ts*, egl_onscreen_ts);
 
index 563772a4e4b456a49aad09efea6f5537e31a0353..1fc73a4bda73d6ce78d28de8482a6b988714cb3a 100644 (file)
@@ -38,7 +38,7 @@
 #include "yagl_process.h"
 #include "yagl_thread.h"
 #include "yagl_object_map.h"
-#include "vigs/winsys_gl.h"
+#include "hw/vigs/winsys_gl.h"
 
 struct yagl_egl_onscreen_image
 {
index 9f53cf98192551855993fd277246f7e02fe5c1ec..501dc667c3a868ef1bb59f7778397029d8a172d1 100644 (file)
@@ -37,7 +37,7 @@
 #include "yagl_process.h"
 #include "yagl_thread.h"
 #include "yagl_gles_driver.h"
-#include "vigs/winsys_gl.h"
+#include "hw/vigs/winsys_gl.h"
 
 YAGL_DECLARE_TLS(struct yagl_egl_onscreen_ts*, egl_onscreen_ts);
 
index b77151f0ba1f246ab7928e895d7cb56b0745d54f..8a8b07f9663e9c0de19198bfe7a76471e1dba6e0 100644 (file)
@@ -43,9 +43,8 @@
 #include "hw/pci/pci.h"
 #include "qemu/error-report.h"
 #include <GL/gl.h>
-#include "vigs/display.h"
-#include "vigs/work_queue.h"
-#include "vigs/winsys.h"
+#include "hw/vigs/display.h"
+#include "hw/vigs/winsys.h"
 #include "yagl_gles_driver.h"
 
 #define PCI_VENDOR_ID_YAGL 0x19B1
index 8d82dbe463f1c2afd5e0ebe0c12f9a48ef5dcfb3..82a7b81f00483249c6431379c2f53cdac731d4ff 100644 (file)
@@ -35,7 +35,7 @@
 #include "yagl_stats.h"
 #include "yagl_transport.h"
 #include "yagl_object_map.h"
-#include "vigs/winsys.h"
+#include "hw/vigs/winsys.h"
 #include "sysemu/kvm.h"
 #include "sysemu/hax.h"
 
index 928c9051673cf0be2665dcda0ad1e61493fb93c8..0dfa297921558936b3cf8e3bb0f343a0c5754233 100644 (file)
@@ -33,7 +33,7 @@
 #include "yagl_types.h"
 #include "yagl_event.h"
 #include "yagl_tls.h"
-#include "vigs/work_queue.h"
+#include "hw/vigs/work_queue.h"
 #include "qemu/queue.h"
 #include "qemu/thread.h"
 
index 6080e15e4940650d846a819b5534a55beb91b08d..1e1e65002493b6c55002f509eb0378e815ae11ad 100644 (file)
@@ -31,24 +31,24 @@ qemu_distclean:
        cd ../../ && $(MAKE) distclean
 
 check_hax:
-       @echo "build check hax" 
+       @echo "build check hax"
 ifdef CONFIG_WIN32
-       $(CC) -o check-hax.exe check_hax.c      
+       $(CC) -o check-hax.exe util/check_hax.c
 endif
 ifdef CONFIG_DARWIN
-       $(CC) -mmacosx-version-min=10.4 -o check-hax check_hax.c        
+       $(CC) -mmacosx-version-min=10.4 -o check-hax util/check_hax.c
 endif
 
 check_cam:
        @echo "build check cam"
 ifdef CONFIG_LINUX
-       $(CC) -o check-cam check_cam.c -lv4l2 -lv4lconvert
+       $(CC) -o check-cam util/check_cam.c -lv4l2 -lv4lconvert
 endif
 ifdef CONFIG_WIN32
-       $(CC) -o check-cam.exe check_cam.c -lole32 -loleaut32 -luuid -lstrmiids
+       $(CC) -o check-cam.exe util/check_cam.c -I. -lole32 -loleaut32 -luuid -lstrmiids
 endif
 ifdef CONFIG_DARWIN
-       $(CC) -o check-cam check_cam.c
+       $(CC) -o check-cam util/check_cam.c
 endif
 
 skin_client:
diff --git a/tizen/src/Makefile.objs b/tizen/src/Makefile.objs
new file mode 100644 (file)
index 0000000..3cf8dac
--- /dev/null
@@ -0,0 +1,40 @@
+# for TIZEN emulator, MARU board
+
+QEMU_CFLAGS += -I$(SRC_PATH)/tizen/src
+LIBS += $(CURL_LIBS)
+
+# emulator base
+obj-y += emulator.o emulator_legacy.o emulator_options.o emul_state.o maru_err_table.o
+
+# utils
+obj-y += util/
+
+# mloop event
+obj-y += mloop_event.o
+
+# maru display
+obj-y += display/
+
+# ECS
+obj-y += ecs/
+
+# tethering
+obj-y += tethering/
+
+# maru skin
+obj-y += skin/
+
+# guest server
+obj-y += guest_server.o
+
+# debug channel
+obj-y += debug_ch.o
+
+# maru hardware
+obj-y += hw/
+
+# NSRunLoop and emul_state_darwin
+obj-$(CONFIG_DARWIN) += ns_event.o
+obj-$(CONFIG_DARWIN) += emul_state_darwin.o
+
+$(obj)/emulator.o $(obj)/emulator_legacy.o: QEMU_CFLAGS += $(SDL_CFLAGS)
diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen
deleted file mode 100644 (file)
index bffd2ea..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-# Makefile.tizen
-# for TIZEN-maru board
-
-$(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/tizen/src:$(SRC_PATH)/tizen/src/hw:$(SRC_PATH)/tizen/src/skin:$(SRC_PATH)/tizen/src/SDL_gfx)
-
-QEMU_CFLAGS += -I$(SRC_PATH)/hw -I$(SRC_PATH)/tizen/src
-QEMU_CFLAGS += $(SDL_CFLAGS)
-QEMU_CFLAGS += $(GLIB_CFLAGS)
-ifdef CONFIG_DARWIN
-QEMU_CFLAGS += -framework Foundation -framework SystemConfiguration
-QEMU_CFLAGS += -framework Cocoa -framework QTKit -framework CoreVideo
-QEMU_CFLAGS += -framework AppKit
-endif
-ifndef CONFIG_DEBUG_EXEC
-CFLAGS += -g -O2
-else
-CFLAGS += -g -O0
-endif
-
-ifdef CONFIG_WIN32
-LIBS += -lpng14
-endif
-ifdef CONFIG_LINUX
-LIBS += -lpng
-endif
-
-ifdef CONFIG_DEBUG_EXEC
-GL_CFLAGS := -Wall -g -O0 -fno-strict-aliasing
-else
-GL_CFLAGS := -Wall -g -O2 -fno-strict-aliasing
-endif
-
-# maru loader
-obj-y += emulator.o emulator_legacy.o emulator_options.o emul_state.o maru_err_table.o
-
-# osutil
-obj-y += osutil.o
-QEMU_CFLAGS += $(CURL_CFLAGS)
-LIBS += $(CURL_LIBS)
-
-ifdef CONFIG_LINUX
-obj-y += osutil-linux.o
-endif
-ifdef CONFIG_WIN32
-obj-y += osutil-win32.o
-endif
-ifdef CONFIG_DARWIN
-obj-y += osutil-darwin.o
-endif
-
-# maru display
-obj-y += maru_display.o
-ifdef CONFIG_USE_SHM
-obj-y += maru_shm.o
-else
-obj-y += maru_sdl.o maru_sdl_processing.o maru_finger.o
-endif
-
-# sdb
-obj-y += sdb.o
-
-# mloop event
-obj-y += mloop_event.o
-
-# NSRunLoop on Mac
-ifdef CONFIG_DARWIN
-obj-y += ns_event.o
-endif
-
-# debug channel
-obj-y += debug_ch.o
-
-# ECS
-include $(SRC_PATH)/tizen/src/ecs/Makefile.tizen
-
-# tethering
-include $(SRC_PATH)/tizen/src/tethering/Makefile.tizen
-
-# maru hardware
-include $(SRC_PATH)/tizen/src/Makefile.tizen.$(TARGET_BASE_ARCH)
-
-obj-y += maru_brightness.o
-obj-y += maru_virtio_touchscreen.o
-#obj-y += maru_usb_touchscreen.o
-obj-y += maru_virtio_keyboard.o
-obj-y += maru_virtio_hwkey.o
-obj-y += maru_virtio_evdi.o
-obj-y += maru_virtio_sensor.o
-obj-y += maru_virtio_nfc.o
-obj-y += maru_virtio_jack.o
-obj-y += maru_virtio_power.o
-obj-y += maru_virtio_esm.o
-obj-y += maru_virtio_vmodem.o
-#obj-y += maru_brill_codec.o
-obj-$(CONFIG_LIBAV) += maru_brill_codec.o
-
-obj-$(CONFIG_PCI) += maru_camera_common_pci.o
-obj-$(CONFIG_LINUX) += maru_camera_linux_pci.o
-obj-$(CONFIG_WIN32) += maru_camera_win32_pci.o
-obj-$(CONFIG_DARWIN) += maru_camera_darwin_converter.o
-obj-$(CONFIG_DARWIN) += maru_camera_darwin_pci.o
-obj-$(CONFIG_DARWIN) += emul_state_darwin.o
-
-obj-y += check_gl_core.o
-obj-$(CONFIG_LINUX) += check_gl_glx.o
-obj-$(CONFIG_WIN32) += check_gl_wgl.o
-obj-$(CONFIG_DARWIN) += check_gl_cgl.o
-
-ifdef CONFIG_LINUX # libs for maru camera on linux host
-LIBS += -lv4l2 -lv4lconvert
-endif
-
-ifdef CONFIG_WIN32 # libs for maru camera on windows host
-LIBS += -lole32 -loleaut32 -luuid -lstrmiids
-endif
-
-# maru skin
-obj-y += maruskin_client.o maruskin_server.o maruskin_operation.o maruskin_keymap.o
-
-# guest server
-obj-y += guest_server.o
diff --git a/tizen/src/Makefile.tizen.arm b/tizen/src/Makefile.tizen.arm
deleted file mode 100644 (file)
index e93bd3a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# Makefile.tizen
-# for TIZEN-maru board
-
-obj-y += maru_arm_soc.o
-
-ifndef  CONFIG_DARWIN
-obj-y += maru_arm_board.o
-endif
-
-obj-y += maru_arm_vpci.o
-obj-y += maru_arm_pmu.o
diff --git a/tizen/src/Makefile.tizen.i386 b/tizen/src/Makefile.tizen.i386
deleted file mode 100644 (file)
index e8034c6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-# Makefile.tizen
-# for TIZEN-maru-x86 board
-
-obj-y += maru_board.o
-obj-y += maru_pm.o
diff --git a/tizen/src/check_cam.c b/tizen/src/check_cam.c
deleted file mode 100644 (file)
index 90a24a3..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * check the availability of a host webcam.
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include <stdio.h>
-
-#ifdef _WIN32
-/* Windows implement */
-#include <windows.h>
-#define CINTERFACE
-#define COBJMACROS
-#include "ocidl.h"
-#include "errors.h"      /* for VFW_E_XXXX */
-#include "mmsystem.h"    /* for MAKEFOURCC macro */
-#include "hw/maru_camera_win32_interface.h"
-
-/*
- * COM Interface implementations
- *
- */
-
-#define SAFE_RELEASE(x) \
-    do { \
-        if (x) { \
-            (x)->lpVtbl->Release(x); \
-            x = NULL; \
-        } \
-    } while (0)
-
-static int check_cam(void)
-{
-    int ret = 0;
-    char *device_name = NULL;
-    HRESULT hr = E_FAIL;
-    ICreateDevEnum *pCreateDevEnum = NULL;
-    IGraphBuilder *pGB = NULL;
-    ICaptureGraphBuilder2 *pCGB = NULL;
-    IEnumMoniker *pEnumMK = NULL;
-    IMoniker *pMoniKer = NULL;
-
-    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
-    if (FAILED(hr)) {
-        fprintf(stdout, "[Webcam] failed to CoInitailizeEx\n");
-        return ret;
-    }
-
-    hr = CoCreateInstance(&CLSID_FilterGraph, NULL,
-                          CLSCTX_INPROC,
-                          &IID_IGraphBuilder,
-                          (void **)&pGB);
-    if (FAILED(hr)) {
-        fprintf(stdout, "[Webcam] Failed to create GraphBuilder, 0x%x\n", hr);
-        CoUninitialize();
-        return ret;
-    }
-
-    hr = CoCreateInstance(&CLSID_CaptureGraphBuilder2, NULL,
-                          CLSCTX_INPROC,
-                          &IID_ICaptureGraphBuilder2,
-                          (void **)&pCGB);
-    if (FAILED(hr)) {
-        fprintf(stdout,
-        "[Webcam] Failed to create CaptureGraphBuilder2, 0x%x\n", hr);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    }
-
-    hr = pCGB->lpVtbl->SetFiltergraph(pCGB, pGB);
-    if (FAILED(hr)) {
-        fprintf(stdout, "[Webcam] Failed to SetFiltergraph, 0x%x\n", hr);
-        SAFE_RELEASE(pCGB);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    }
-
-    hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL,
-                          CLSCTX_INPROC,
-                          &IID_ICreateDevEnum,
-                          (void **)&pCreateDevEnum);
-    if (FAILED(hr)) {
-        fprintf(stdout,
-            "[Webcam] failed to create instance of CLSID_SystemDeviceEnum\n");
-        SAFE_RELEASE(pCGB);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    }
-
-    hr = pCreateDevEnum->lpVtbl->CreateClassEnumerator(pCreateDevEnum,
-                                  &CLSID_VideoInputDeviceCategory, &pEnumMK, 0);
-    if (FAILED(hr)) {
-        fprintf(stdout, "[Webcam] failed to create class enumerator\n");
-        SAFE_RELEASE(pCreateDevEnum);
-        SAFE_RELEASE(pCGB);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    }
-
-    if (!pEnumMK) {
-        fprintf(stdout, "[Webcam] class enumerator is NULL!!\n");
-        SAFE_RELEASE(pCreateDevEnum);
-        SAFE_RELEASE(pCGB);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    }
-
-    pEnumMK->lpVtbl->Reset(pEnumMK);
-    hr = pEnumMK->lpVtbl->Next(pEnumMK, 1, &pMoniKer, NULL);
-    if (FAILED(hr) || (hr == S_FALSE)) {
-        fprintf(stdout, "[Webcam] enum moniker returns a invalid value.\n");
-        SAFE_RELEASE(pEnumMK);
-        SAFE_RELEASE(pCreateDevEnum);
-        SAFE_RELEASE(pCGB);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    }
-
-    IPropertyBag *pBag = NULL;
-    hr = pMoniKer->lpVtbl->BindToStorage(pMoniKer, 0, 0,
-                                         &IID_IPropertyBag,
-                                         (void **)&pBag);
-    if (FAILED(hr)) {
-        fprintf(stdout, "[Webcam] failed to bind to storage.\n");
-        SAFE_RELEASE(pEnumMK);
-        SAFE_RELEASE(pCreateDevEnum);
-        SAFE_RELEASE(pCGB);
-        SAFE_RELEASE(pGB);
-        CoUninitialize();
-        return ret;
-    } else {
-        VARIANT var;
-        var.vt = VT_BSTR;
-        hr = pBag->lpVtbl->Read(pBag, L"FriendlyName", &var, NULL);
-        if (hr == S_OK) {
-            ret = 1;
-            fprintf(stdout, "[Webcam] Check success\n");
-        } else {
-            fprintf(stdout, "[Webcam] failed to find to webcam device.\n");
-        }
-        SysFreeString(var.bstrVal);
-        SAFE_RELEASE(pBag);
-    }
-    SAFE_RELEASE(pMoniKer);
-    SAFE_RELEASE(pCGB);
-    SAFE_RELEASE(pGB);
-    SAFE_RELEASE(pEnumMK);
-    SAFE_RELEASE(pCreateDevEnum);
-    CoUninitialize();
-
-    return ret;
-}
-
-
-#elif __linux
-
-/* Linux implement */
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <linux/videodev2.h>
-
-static int check_cam(void)
-{
-    int tmp_fd;
-    struct stat st;
-    struct v4l2_fmtdesc format;
-    struct v4l2_frmsizeenum size;
-    struct v4l2_capability cap;
-    char dev_name[] = "/dev/video0";
-    int ret = 0;
-
-    if (stat(dev_name, &st) < 0) {
-        fprintf(stdout, "[Webcam] <WARNING> Cannot identify '%s': %d\n",
-                dev_name, errno);
-    } else {
-        if (!S_ISCHR(st.st_mode)) {
-            fprintf(stdout, "[Webcam] <WARNING>%s is no character device\n",
-                    dev_name);
-        }
-    }
-
-    tmp_fd = open(dev_name, O_RDWR | O_NONBLOCK, 0);
-    if (tmp_fd < 0) {
-        fprintf(stdout, "[Webcam] Camera device open failed: %s\n", dev_name);
-        return ret;
-    }
-    if (ioctl(tmp_fd, VIDIOC_QUERYCAP, &cap) < 0) {
-        fprintf(stdout, "[Webcam] Could not qeury video capabilities\n");
-        close(tmp_fd);
-        return ret;
-    }
-    if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) ||
-            !(cap.capabilities & V4L2_CAP_STREAMING)) {
-        fprintf(stdout, "[Webcam] Not supported video driver\n");
-        close(tmp_fd);
-        return ret;
-    }
-    fprintf(stdout, "[Webcam] Check success\n");
-    close(tmp_fd);
-
-    return 1;
-}
-
-#elif __APPLE__
-/* MacOS, Now, not implemented. */
-static int check_cam(void)
-{
-    fprintf(stdout, "[Webcam] Not implemented.\n");
-    return 1;
-}
-
-#else
-/* Unsupported OS */
-static int check_cam(void)
-{
-    fprintf(stdout, "[Webcam] Unsupported OS. Not available.\n");
-    return 0;
-}
-#endif    /* end of the if statement */
-
-int main(int argc, char** argv)
-{
-    return check_cam();
-}
-
diff --git a/tizen/src/check_gl.c b/tizen/src/check_gl.c
deleted file mode 100644 (file)
index 1da7a18..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "check_gl.h"
-
-int main(int argc, char *argv[])
-{
-    return check_gl();
-}
diff --git a/tizen/src/check_gl.h b/tizen/src/check_gl.h
deleted file mode 100644 (file)
index 89594a7..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#ifndef __CHECK_GL_H__
-#define __CHECK_GL_H__
-
-struct gl_context;
-
-typedef enum
-{
-    gl_info = 0,
-    gl_warn = 1,
-    gl_error = 2
-} gl_log_level;
-
-typedef enum
-{
-    gl_2 = 0,
-    gl_3_1 = 1,
-    gl_3_2 = 2
-} gl_version;
-
-int check_gl(void);
-
-void check_gl_log(gl_log_level level, const char *format, ...);
-
-int check_gl_init(void);
-
-void check_gl_cleanup(void);
-
-struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
-                                           gl_version version);
-
-int check_gl_make_current(struct gl_context *ctx);
-
-void check_gl_context_destroy(struct gl_context *ctx);
-
-int check_gl_procaddr(void **func, const char *sym, int opt);
-
-#endif
diff --git a/tizen/src/check_gl_cgl.c b/tizen/src/check_gl_cgl.c
deleted file mode 100644 (file)
index 379bab3..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "check_gl.h"
-#include <OpenGL/OpenGL.h>
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#define LIBGL_IMAGE_NAME \
-"/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
-
-#ifndef kCGLPFAOpenGLProfile
-#   define kCGLPFAOpenGLProfile 99
-#   define kCGLOGLPVersion_3_2_Core 0x3200
-#   define kCGLOGLPVersion_Legacy 0x1000
-#endif
-
-struct gl_context
-{
-    CGLContextObj base;
-};
-
-static void *handle;
-
-int check_gl_init(void)
-{
-    handle = dlopen(LIBGL_IMAGE_NAME, RTLD_NOW | RTLD_GLOBAL);
-
-    if (!handle) {
-        check_gl_log(gl_error, "%s", dlerror());
-        return 0;
-    }
-
-    return 1;
-}
-
-void check_gl_cleanup(void)
-{
-}
-
-struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
-                                           gl_version version)
-{
-    static const CGLPixelFormatAttribute pixel_format_legacy_attrs[] =
-    {
-        kCGLPFAAccelerated,
-        kCGLPFAMinimumPolicy,
-        kCGLPFAColorSize, 32,
-        kCGLPFAAlphaSize, 8,
-        kCGLPFADepthSize, 24,
-        kCGLPFAStencilSize, 8,
-        kCGLPFANoRecovery,
-        kCGLPFAPBuffer,
-        0
-    };
-
-    static const CGLPixelFormatAttribute pixel_format_3_2_core_attrs[] =
-    {
-        kCGLPFAAccelerated,
-        kCGLPFAMinimumPolicy,
-        kCGLPFAColorSize, 32,
-        kCGLPFAAlphaSize, 8,
-        kCGLPFADepthSize, 24,
-        kCGLPFAStencilSize, 8,
-        kCGLPFANoRecovery,
-        kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core,
-        0
-    };
-    CGLError error;
-    CGLPixelFormatObj pixel_format;
-    int n;
-    CGLContextObj base = NULL;
-    struct gl_context *ctx;
-
-    switch (version) {
-    case gl_2:
-        error = CGLChoosePixelFormat(pixel_format_legacy_attrs,
-                                     &pixel_format,
-                                     &n);
-
-        if (error || !pixel_format) {
-            break;
-        }
-
-        error = CGLCreateContext(pixel_format,
-                                 (share_ctx ? share_ctx->base : NULL),
-                                 &base);
-
-        CGLDestroyPixelFormat(pixel_format);
-
-        if (error) {
-            base = NULL;
-        }
-
-        break;
-    case gl_3_1:
-        break;
-    case gl_3_2:
-        error = CGLChoosePixelFormat(pixel_format_3_2_core_attrs,
-                                     &pixel_format,
-                                     &n);
-
-        if (error || !pixel_format) {
-            break;
-        }
-
-        error = CGLCreateContext(pixel_format,
-                                 (share_ctx ? share_ctx->base : NULL),
-                                 &base);
-
-        CGLDestroyPixelFormat(pixel_format);
-
-        if (error) {
-            base = NULL;
-        }
-
-        break;
-    default:
-        assert(0);
-        return NULL;
-    }
-
-    if (!base) {
-        return NULL;
-    }
-
-    ctx = malloc(sizeof(*ctx));
-
-    if (!ctx) {
-        CGLDestroyContext(base);
-        return NULL;
-    }
-
-    ctx->base = base;
-
-    return ctx;
-}
-
-int check_gl_make_current(struct gl_context *ctx)
-{
-    return !CGLSetCurrentContext(ctx ? ctx->base : NULL);
-}
-
-void check_gl_context_destroy(struct gl_context *ctx)
-{
-    CGLDestroyContext(ctx->base);
-    free(ctx);
-}
-
-int check_gl_procaddr(void **func, const char *sym, int opt)
-{
-    *func = dlsym(handle, sym);
-
-    if (!*func && !opt) {
-        check_gl_log(gl_error, "Unable to find symbol \"%s\"", sym);
-        return 0;
-    }
-
-    return 1;
-}
diff --git a/tizen/src/check_gl_core.c b/tizen/src/check_gl_core.c
deleted file mode 100644 (file)
index 3912a69..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "check_gl.h"
-#include <GL/gl.h>
-#include <GL/glext.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-
-static const char *log_level_str[gl_error + 1] =
-{
-    "INFO",
-    "WARN",
-    "ERROR"
-};
-
-static const char *gl_version_str[gl_3_2 + 1] =
-{
-    "2.1",
-    "3.1",
-    "3.2"
-};
-
-static const char *gl_3_2_check_funcs[] =
-{
-    "glGenTransformFeedbacks",
-    "glBindTransformFeedback",
-    "glPauseTransformFeedback",
-    "glResumeTransformFeedback",
-    "glDeleteTransformFeedbacks",
-    "glVertexAttribDivisor"
-};
-
-void check_gl_log(gl_log_level level, const char *format, ...)
-{
-    va_list args;
-
-    fprintf(stderr, "%-5s", log_level_str[level]);
-
-    va_start(args, format);
-    fprintf(stderr, " - ");
-    vfprintf(stderr, format, args);
-    va_end(args);
-
-    fprintf(stderr, "\n");
-}
-
-static const GLubyte *(GLAPIENTRY *get_string)(GLenum);
-static const GLubyte *(GLAPIENTRY *get_stringi)(GLenum, GLuint);
-static void (GLAPIENTRY *get_integerv)(GLenum, GLint*);
-static void (GLAPIENTRY *dummy)();
-
-static struct gl_context *check_gl_version(gl_version version)
-{
-    struct gl_context *ctx = NULL;
-    int hw = 1;
-
-    ctx = check_gl_context_create(NULL, version);
-
-    if (!ctx) {
-        goto fail;
-    }
-
-    if (!check_gl_make_current(ctx)) {
-        goto fail;
-    }
-
-    if ((strstr((const char*)get_string(GL_RENDERER), "Software") != NULL)) {
-        check_gl_log(gl_warn,
-                     "Host OpenGL %s - software",
-                     gl_version_str[version]);
-        hw = 0;
-    } else if (strncmp((const char*)get_string(GL_VERSION),
-                       "1.4", strlen("1.4")) == 0) {
-        /*
-         * Handle LIBGL_ALWAYS_INDIRECT=1 case.
-         */
-        check_gl_log(gl_warn,
-                     "Host OpenGL %s - NOT supported",
-                     gl_version_str[version]);
-        hw = 0;
-    } else {
-        check_gl_log(gl_info,
-                     "Host OpenGL %s - supported",
-                     gl_version_str[version]);
-    }
-
-    check_gl_log(gl_info, "+ GL_VENDOR = %s", (const char*)get_string(GL_VENDOR));
-    check_gl_log(gl_info, "+ GL_RENDERER = %s", (const char*)get_string(GL_RENDERER));
-    check_gl_log(gl_info, "+ GL_VERSION = %s", (const char*)get_string(GL_VERSION));
-
-    if (!hw) {
-        check_gl_context_destroy(ctx);
-        ctx = NULL;
-    }
-
-    check_gl_make_current(NULL);
-
-    return ctx;
-
-fail:
-    if (ctx) {
-        check_gl_context_destroy(ctx);
-    }
-
-    check_gl_log(gl_info,
-                 "Host OpenGL %s - NOT supported",
-                 gl_version_str[version]);
-
-    return NULL;
-}
-
-int check_gl(void)
-{
-    int res = 1;
-    struct gl_context *ctx_2 = NULL;
-    struct gl_context *ctx_3_1 = NULL;
-    struct gl_context *ctx_3_2 = NULL;
-    int have_es3 = 0;
-    int have_es3_compatibility = 0;
-    int have_es1 = 0;
-
-    if (!check_gl_init()) {
-        return 1;
-    }
-
-    if (!check_gl_procaddr((void**)&get_string, "glGetString", 0) ||
-        !check_gl_procaddr((void**)&get_stringi, "glGetStringi", 1) ||
-        !check_gl_procaddr((void**)&get_integerv, "glGetIntegerv", 0)) {
-        goto out;
-    }
-
-    ctx_2 = check_gl_version(gl_2);
-    ctx_3_1 = check_gl_version(gl_3_1);
-    ctx_3_2 = check_gl_version(gl_3_2);
-
-    if (!ctx_2 && !ctx_3_1 && !ctx_3_2) {
-        check_gl_log(gl_info, "Host does not have hardware GL acceleration!");
-        goto out;
-    }
-
-    have_es1 = (ctx_2 != NULL);
-
-    if (ctx_3_2) {
-        unsigned int i;
-        int found_all = 1;
-
-        for (i = 0;
-             i < sizeof(gl_3_2_check_funcs)/sizeof(gl_3_2_check_funcs[0]);
-             ++i) {
-            if (!check_gl_procaddr((void**)&dummy, gl_3_2_check_funcs[i], 1) ||
-                !dummy) {
-                found_all = 0;
-                break;
-            }
-        }
-
-        if (found_all) {
-            have_es3 = 1;
-        }
-    }
-
-    /*
-     * Check if GL_ARB_ES3_compatibility is supported within
-     * OpenGL 3.1 context.
-     */
-
-    if (ctx_3_1 && get_stringi && check_gl_make_current(ctx_3_1)) {
-        GLint i, num_extensions = 0;
-
-        get_integerv(GL_NUM_EXTENSIONS, &num_extensions);
-
-        for (i = 0; i < num_extensions; ++i) {
-            const char *tmp;
-
-            tmp = (const char*)get_stringi(GL_EXTENSIONS, i);
-
-            if (strcmp(tmp, "GL_ARB_ES3_compatibility") == 0) {
-                have_es3 = 1;
-                have_es3_compatibility = 1;
-                break;
-            }
-        }
-
-        check_gl_make_current(NULL);
-    }
-
-    /*
-     * Check if OpenGL 2.1 contexts can be shared with OpenGL 3.x contexts
-     */
-
-    if (ctx_2 && have_es3) {
-        struct gl_context *ctx = NULL;
-
-        ctx = check_gl_context_create(((ctx_3_1 && have_es3_compatibility) ? ctx_3_1
-                                                                           : ctx_3_2),
-                                      gl_2);
-
-        if (ctx) {
-            if (check_gl_make_current(ctx)) {
-                check_gl_make_current(NULL);
-            } else {
-                have_es1 = 0;
-            }
-            check_gl_context_destroy(ctx);
-        } else {
-            have_es1 = 0;
-        }
-    }
-
-    if (have_es1) {
-        check_gl_log(gl_info, "Guest OpenGL ES v1_CM - supported");
-    } else {
-        check_gl_log(gl_warn, "Guest OpenGL ES v1_CM - NOT supported");
-    }
-    check_gl_log(gl_info, "Guest OpenGL ES 2.0 - supported");
-    if (have_es3) {
-        check_gl_log(gl_info, "Guest OpenGL ES 3.0 - supported");
-    } else {
-        check_gl_log(gl_warn, "Guest OpenGL ES 3.0 - NOT supported");
-    }
-
-    check_gl_log(gl_info, "Host has hardware GL acceleration!");
-
-    res = 0;
-
-out:
-    if (ctx_2) {
-        check_gl_context_destroy(ctx_2);
-    }
-
-    if (ctx_3_1) {
-        check_gl_context_destroy(ctx_3_1);
-    }
-
-    if (ctx_3_2) {
-        check_gl_context_destroy(ctx_3_2);
-    }
-
-    check_gl_cleanup();
-
-    return res;
-}
diff --git a/tizen/src/check_gl_glx.c b/tizen/src/check_gl_glx.c
deleted file mode 100644 (file)
index 8034c5c..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "check_gl.h"
-#include <GL/glx.h>
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <assert.h>
-
-#ifndef GLX_VERSION_1_4
-#error GL/glx.h must be equal to or greater than GLX 1.4
-#endif
-
-#define GLX_GET_PROC(func, sym) \
-    do { \
-        *(void**)(&func) = (void*)get_proc_address((const GLubyte*)#sym); \
-        if (!func) { \
-            check_gl_log(gl_error, "%s", dlerror()); \
-            return 0; \
-        } \
-    } while (0)
-
-struct gl_context
-{
-    GLXContext base;
-    GLXPbuffer sfc;
-};
-
-typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display *dpy, GLXContext ctx);
-
-static void *handle;
-static Display *x_dpy;
-static GLXFBConfig x_config;
-static PFNGLXGETPROCADDRESSPROC get_proc_address;
-static PFNGLXCHOOSEFBCONFIGPROC choose_fb_config;
-static PFNGLXCREATEPBUFFERPROC create_pbuffer;
-static PFNGLXDESTROYPBUFFERPROC destroy_pbuffer;
-static PFNGLXCREATENEWCONTEXTPROC create_context;
-static PFNGLXDESTROYCONTEXTPROC destroy_context;
-static PFNGLXMAKECONTEXTCURRENTPROC make_current;
-
-/* GLX_ARB_create_context */
-static PFNGLXCREATECONTEXTATTRIBSARBPROC create_context_attribs;
-
-static int check_gl_error_handler(Display *dpy, XErrorEvent *e)
-{
-    return 0;
-}
-
-int check_gl_init(void)
-{
-    static const int config_attribs[] =
-    {
-        GLX_DOUBLEBUFFER, True,
-        GLX_RED_SIZE, 8,
-        GLX_GREEN_SIZE, 8,
-        GLX_BLUE_SIZE, 8,
-        GLX_ALPHA_SIZE, 8,
-        GLX_BUFFER_SIZE, 32,
-        GLX_DEPTH_SIZE, 24,
-        GLX_STENCIL_SIZE, 8,
-        GLX_RENDER_TYPE, GLX_RGBA_BIT,
-        GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
-        None
-    };
-    int n = 0;
-    GLXFBConfig *configs;
-
-    x_dpy = XOpenDisplay(NULL);
-
-    if (!x_dpy) {
-        check_gl_log(gl_error, "Unable to open X display");
-        return 0;
-    }
-
-    XSetErrorHandler(check_gl_error_handler);
-
-    handle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
-
-    if (!handle) {
-        check_gl_log(gl_error, "%s", dlerror());
-        goto fail;
-    }
-
-    get_proc_address = dlsym(handle, "glXGetProcAddress");
-
-    if (!get_proc_address) {
-        get_proc_address = dlsym(handle, "glXGetProcAddressARB");
-    }
-
-    if (!get_proc_address) {
-        check_gl_log(gl_error, "%s", dlerror());
-        goto fail;
-    }
-
-    GLX_GET_PROC(choose_fb_config, glXChooseFBConfig);
-    GLX_GET_PROC(create_pbuffer, glXCreatePbuffer);
-    GLX_GET_PROC(destroy_pbuffer, glXDestroyPbuffer);
-    GLX_GET_PROC(create_context, glXCreateNewContext);
-    GLX_GET_PROC(destroy_context, glXDestroyContext);
-    GLX_GET_PROC(make_current, glXMakeContextCurrent);
-    GLX_GET_PROC(create_context_attribs, glXCreateContextAttribsARB);
-
-    configs = choose_fb_config(x_dpy,
-                               DefaultScreen(x_dpy),
-                               config_attribs,
-                               &n);
-
-    if (!configs || (n <= 0)) {
-        check_gl_log(gl_error, "Unable to find suitable FB config");
-        goto fail;
-    }
-
-    x_config = configs[0];
-
-    XFree(configs);
-
-    return 1;
-
-fail:
-    XCloseDisplay(x_dpy);
-
-    return 0;
-}
-
-void check_gl_cleanup(void)
-{
-    XCloseDisplay(x_dpy);
-}
-
-struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
-                                           gl_version version)
-{
-    static const int ctx_attribs_3_1[] =
-    {
-        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
-        GLX_CONTEXT_MINOR_VERSION_ARB, 1,
-        GLX_RENDER_TYPE, GLX_RGBA_TYPE,
-        GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
-        None
-    };
-    static const int ctx_attribs_3_2[] =
-    {
-        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
-        GLX_CONTEXT_MINOR_VERSION_ARB, 2,
-        GLX_RENDER_TYPE, GLX_RGBA_TYPE,
-        GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
-        None
-    };
-    static const int surface_attribs[] =
-    {
-        GLX_PBUFFER_WIDTH, 1,
-        GLX_PBUFFER_HEIGHT, 1,
-        GLX_LARGEST_PBUFFER, False,
-        None
-    };
-    GLXContext base;
-    GLXPbuffer sfc;
-    struct gl_context *ctx;
-
-    switch (version) {
-    case gl_2:
-        base = create_context(x_dpy,
-                              x_config,
-                              GLX_RGBA_TYPE,
-                              (share_ctx ? share_ctx->base : NULL),
-                              True);
-        break;
-    case gl_3_1:
-        base = create_context_attribs(x_dpy,
-                                      x_config,
-                                      (share_ctx ? share_ctx->base : NULL),
-                                      True,
-                                      ctx_attribs_3_1);
-        break;
-    case gl_3_2:
-        base = create_context_attribs(x_dpy,
-                                      x_config,
-                                      (share_ctx ? share_ctx->base : NULL),
-                                      True,
-                                      ctx_attribs_3_2);
-        break;
-    default:
-        assert(0);
-        return NULL;
-    }
-
-    if (!base) {
-        return NULL;
-    }
-
-    sfc = create_pbuffer(x_dpy,
-                         x_config,
-                         surface_attribs);
-
-    if (!sfc) {
-        destroy_context(x_dpy, base);
-        return NULL;
-    }
-
-    ctx = malloc(sizeof(*ctx));
-
-    if (!ctx) {
-        destroy_pbuffer(x_dpy, sfc);
-        destroy_context(x_dpy, base);
-        return NULL;
-    }
-
-    ctx->base = base;
-    ctx->sfc = sfc;
-
-    return ctx;
-}
-
-int check_gl_make_current(struct gl_context *ctx)
-{
-    return make_current(x_dpy,
-                        (ctx ? ctx->sfc : None),
-                        (ctx ? ctx->sfc : None),
-                        (ctx ? ctx->base : NULL));
-}
-
-void check_gl_context_destroy(struct gl_context *ctx)
-{
-    destroy_pbuffer(x_dpy, ctx->sfc);
-    destroy_context(x_dpy, ctx->base);
-    free(ctx);
-}
-
-int check_gl_procaddr(void **func, const char *sym, int opt)
-{
-    *func = (void*)get_proc_address((const GLubyte*)sym);
-
-    if (!*func) {
-        *func = dlsym(handle, sym);
-    }
-
-    if (!*func && !opt) {
-        check_gl_log(gl_error, "Unable to find symbol \"%s\"", sym);
-        return 0;
-    }
-
-    return 1;
-}
diff --git a/tizen/src/check_gl_wgl.c b/tizen/src/check_gl_wgl.c
deleted file mode 100644 (file)
index 702b555..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "check_gl.h"
-#include <windows.h>
-#include <wingdi.h>
-#include <GL/gl.h>
-#include <GL/wglext.h>
-#include <assert.h>
-
-#define WGL_GET_PROC(func, sym) \
-    do { \
-        *(void**)(&func) = (void*)GetProcAddress(handle, #sym); \
-        if (!func) { \
-            check_gl_log(gl_error, "Unable to load %s symbol", #sym); \
-            goto fail; \
-        } \
-    } while (0)
-
-#define WGL_GET_EXT_PROC(func, ext, sym) \
-    do { \
-        if ((strstr(ext_str, #ext " ") == NULL)) { \
-            check_gl_log(gl_error, "Extension %s not supported", #ext); \
-            goto fail; \
-        } \
-        *(void**)(&func) = (void*)get_proc_address((LPCSTR)#sym); \
-        if (!func) { \
-            check_gl_log(gl_error, "Unable to load %s symbol", #sym); \
-            goto fail; \
-        } \
-    } while (0)
-
-struct gl_context
-{
-    HGLRC base;
-    HPBUFFERARB sfc;
-    HDC sfc_dc;
-};
-
-typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTPROC)(HDC hdl);
-typedef BOOL (WINAPI *PFNWGLDELETECONTEXTPROC)(HGLRC hdl);
-typedef PROC (WINAPI *PFNWGLGETPROCADDRESSPROC)(LPCSTR sym);
-typedef BOOL (WINAPI *PFNWGLMAKECURRENTPROC)(HDC dev_ctx, HGLRC rend_ctx);
-typedef BOOL (WINAPI *PFNWGLSHARELISTSPROC)(HGLRC ctx1, HGLRC ctx2);
-
-static HINSTANCE handle = NULL;
-static HWND init_win = NULL;
-static HDC init_dc = NULL;
-static HGLRC init_ctx = NULL;
-static HWND win = NULL;
-static HDC dc = NULL;
-static int config_id = 0;
-static struct gl_context *current = NULL;
-static PFNWGLCREATECONTEXTPROC create_context;
-static PFNWGLDELETECONTEXTPROC delete_context;
-static PFNWGLGETPROCADDRESSPROC get_proc_address;
-static PFNWGLMAKECURRENTPROC make_current;
-static PFNWGLSHARELISTSPROC share_lists;
-
-/* WGL extensions */
-static PFNWGLGETEXTENSIONSSTRINGEXTPROC get_extensions_string_ext;
-static PFNWGLGETEXTENSIONSSTRINGARBPROC get_extensions_string_arb;
-static PFNWGLCHOOSEPIXELFORMATARBPROC choose_pixel_format;
-static PFNWGLCREATEPBUFFERARBPROC create_pbuffer;
-static PFNWGLGETPBUFFERDCARBPROC get_pbuffer_dc;
-static PFNWGLRELEASEPBUFFERDCARBPROC release_pbuffer_dc;
-static PFNWGLDESTROYPBUFFERARBPROC destroy_pbuffer;
-
-/* WGL_ARB_create_context */
-static PFNWGLCREATECONTEXTATTRIBSARBPROC create_context_attribs;
-
-int check_gl_init(void)
-{
-    WNDCLASSEXA win_class;
-    PIXELFORMATDESCRIPTOR init_pixfmt =
-    {
-        .nSize = sizeof(PIXELFORMATDESCRIPTOR),
-        .nVersion = 1,
-        .dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
-        .iPixelType = PFD_TYPE_RGBA,
-        .cColorBits = 32,
-        .cDepthBits = 24,
-        .cStencilBits = 8,
-        .iLayerType = PFD_MAIN_PLANE,
-    };
-    int init_config_id = 0;
-    const char *ext_str = NULL;
-    const int config_attribs[] =
-    {
-        WGL_SUPPORT_OPENGL_ARB, TRUE,
-        WGL_DOUBLE_BUFFER_ARB, TRUE,
-        WGL_DRAW_TO_PBUFFER_ARB, TRUE,
-        WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
-        WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
-        WGL_RED_BITS_ARB, 8,
-        WGL_GREEN_BITS_ARB, 8,
-        WGL_BLUE_BITS_ARB, 8,
-        WGL_ALPHA_BITS_ARB, 8,
-        WGL_COLOR_BITS_ARB, 32,
-        WGL_DEPTH_BITS_ARB, 24,
-        WGL_STENCIL_BITS_ARB, 8,
-        0,
-    };
-    UINT n = 0;
-    PIXELFORMATDESCRIPTOR pixfmt;
-
-    win_class.cbSize = sizeof(WNDCLASSEXA);
-    win_class.style = 0;
-    win_class.lpfnWndProc = &DefWindowProcA;
-    win_class.cbClsExtra = 0;
-    win_class.cbWndExtra = 0;
-    win_class.hInstance = NULL;
-    win_class.hIcon = NULL;
-    win_class.hCursor = NULL;
-    win_class.hbrBackground = NULL;
-    win_class.lpszMenuName =  NULL;
-    win_class.lpszClassName = "CheckGLWinClass";
-    win_class.hIconSm = NULL;
-
-    if (!RegisterClassExA(&win_class)) {
-        check_gl_log(gl_error, "Unable to register window class");
-        return 0;
-    }
-
-    handle = LoadLibraryA("opengl32");
-
-    if (!handle) {
-        check_gl_log(gl_error, "Unable to load opengl32.dll");
-        goto fail;
-    }
-
-    WGL_GET_PROC(create_context, wglCreateContext);
-    WGL_GET_PROC(delete_context, wglDeleteContext);
-    WGL_GET_PROC(get_proc_address, wglGetProcAddress);
-    WGL_GET_PROC(make_current, wglMakeCurrent);
-    WGL_GET_PROC(share_lists, wglShareLists);
-
-    init_win = CreateWindow("CheckGLWinClass", "CheckGLWin",
-                            WS_DISABLED | WS_POPUP,
-                            0, 0, 1, 1, NULL, NULL, 0, 0);
-
-    if (!init_win) {
-        check_gl_log(gl_error, "Unable to create window");
-        goto fail;
-    }
-
-    init_dc = GetDC(init_win);
-
-    if (!init_dc) {
-        check_gl_log(gl_error, "Unable to get window DC");
-        goto fail;
-    }
-
-    init_config_id = ChoosePixelFormat(init_dc, &init_pixfmt);
-
-    if (!init_config_id) {
-        check_gl_log(gl_error, "ChoosePixelFormat failed");
-        goto fail;
-    }
-
-    if (!SetPixelFormat(init_dc, init_config_id, &init_pixfmt)) {
-        check_gl_log(gl_error, "SetPixelFormat failed");
-        goto fail;
-    }
-
-    init_ctx = create_context(init_dc);
-    if (!init_ctx) {
-        check_gl_log(gl_error, "wglCreateContext failed");
-        goto fail;
-    }
-
-    if (!make_current(init_dc, init_ctx)) {
-        check_gl_log(gl_error, "wglMakeCurrent failed");
-        goto fail;
-    }
-
-    /*
-     * WGL extensions couldn't be queried by glGetString(), we need to use
-     * wglGetExtensionsStringARB or wglGetExtensionsStringEXT for this, which
-     * themselves are extensions
-     */
-    get_extensions_string_arb = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
-        get_proc_address((LPCSTR)"wglGetExtensionsStringARB");
-    get_extensions_string_ext = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
-        get_proc_address((LPCSTR)"wglGetExtensionsStringEXT");
-
-    if (get_extensions_string_arb) {
-        ext_str = get_extensions_string_arb(init_dc);
-    } else if (get_extensions_string_ext) {
-        ext_str = get_extensions_string_ext();
-    }
-
-    if (!ext_str) {
-        check_gl_log(gl_error, "Unable to obtain WGL extension string");
-        goto fail;
-    }
-
-    WGL_GET_EXT_PROC(create_pbuffer, WGL_ARB_pbuffer, wglCreatePbufferARB);
-    WGL_GET_EXT_PROC(get_pbuffer_dc, WGL_ARB_pbuffer, wglGetPbufferDCARB);
-    WGL_GET_EXT_PROC(release_pbuffer_dc, WGL_ARB_pbuffer, wglReleasePbufferDCARB);
-    WGL_GET_EXT_PROC(destroy_pbuffer, WGL_ARB_pbuffer, wglDestroyPbufferARB);
-    WGL_GET_EXT_PROC(choose_pixel_format, WGL_ARB_pixel_format, wglChoosePixelFormatARB);
-    WGL_GET_EXT_PROC(create_context_attribs, WGL_ARB_create_context, wglCreateContextAttribsARB);
-
-    make_current(NULL, NULL);
-
-    win = CreateWindow("CheckGLWinClass", "CheckGLWin2",
-                       WS_DISABLED | WS_POPUP,
-                       0, 0, 1, 1, NULL, NULL, 0, 0);
-
-    if (!win) {
-        check_gl_log(gl_error, "Unable to create window");
-        goto fail;
-    }
-
-    dc = GetDC(win);
-
-    if (!dc) {
-        check_gl_log(gl_error, "Unable to get window DC");
-        goto fail;
-    }
-
-    if (!choose_pixel_format(dc,
-                             config_attribs,
-                             NULL,
-                             1,
-                             &config_id,
-                             &n) || (n == 0)) {
-        check_gl_log(gl_error, "wglChoosePixelFormat failed");
-        goto fail;
-    }
-
-    if (!DescribePixelFormat(dc,
-                             config_id,
-                             sizeof(PIXELFORMATDESCRIPTOR),
-                             &pixfmt)) {
-        check_gl_log(gl_error, "DescribePixelFormat failed");
-        goto fail;
-    }
-
-    if (!SetPixelFormat(dc,
-                        config_id,
-                        &pixfmt)) {
-        check_gl_log(gl_error, "SetPixelFormat failed");
-        goto fail;
-    }
-
-    return 1;
-
-fail:
-    if (dc) {
-        ReleaseDC(win, dc);
-    }
-    if (win) {
-        DestroyWindow(win);
-    }
-    if (init_ctx) {
-        make_current(NULL, NULL);
-        delete_context(init_ctx);
-    }
-    if (init_dc) {
-        ReleaseDC(init_win, init_dc);
-    }
-    if (init_win) {
-        DestroyWindow(init_win);
-    }
-    if (handle) {
-        FreeLibrary(handle);
-    }
-
-    UnregisterClassA((LPCTSTR)"CheckGLWinClass", NULL);
-
-    return 0;
-}
-
-void check_gl_cleanup(void)
-{
-    ReleaseDC(win, dc);
-    DestroyWindow(win);
-    delete_context(init_ctx);
-    ReleaseDC(init_win, init_dc);
-    DestroyWindow(init_win);
-
-    UnregisterClassA((LPCTSTR)"CheckGLWinClass", NULL);
-}
-
-struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
-                                           gl_version version)
-{
-    static const int ctx_attribs_3_1[] =
-    {
-        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
-        WGL_CONTEXT_MINOR_VERSION_ARB, 1,
-        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
-        0
-    };
-    static const int ctx_attribs_3_2[] =
-    {
-        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
-        WGL_CONTEXT_MINOR_VERSION_ARB, 2,
-        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
-        0
-    };
-    static const int surface_attribs[] =
-    {
-        WGL_PBUFFER_LARGEST_ARB, FALSE,
-        WGL_TEXTURE_TARGET_ARB, WGL_NO_TEXTURE_ARB,
-        WGL_TEXTURE_FORMAT_ARB, WGL_NO_TEXTURE_ARB,
-        0
-    };
-    HGLRC base;
-    HPBUFFERARB sfc;
-    HDC sfc_dc;
-    struct gl_context *ctx;
-
-    switch (version) {
-    case gl_2:
-        base = create_context(dc);
-        if (share_ctx && !share_lists(share_ctx->base, base)) {
-            delete_context(base);
-            base = NULL;
-        }
-        break;
-    case gl_3_1:
-        base = create_context_attribs(dc,
-                                      (share_ctx ? share_ctx->base : NULL),
-                                      ctx_attribs_3_1);
-        break;
-    case gl_3_2:
-        base = create_context_attribs(dc,
-                                      (share_ctx ? share_ctx->base : NULL),
-                                      ctx_attribs_3_2);
-        break;
-    default:
-        assert(0);
-        return NULL;
-    }
-
-    if (!base) {
-        return NULL;
-    }
-
-    sfc = create_pbuffer(dc,
-                         config_id, 1, 1,
-                         surface_attribs);
-
-    if (!sfc) {
-        delete_context(base);
-        return NULL;
-    }
-
-    sfc_dc = get_pbuffer_dc(sfc);
-
-    if (!sfc_dc) {
-        destroy_pbuffer(sfc);
-        delete_context(base);
-        return NULL;
-    }
-
-    ctx = malloc(sizeof(*ctx));
-
-    if (!ctx) {
-        release_pbuffer_dc(sfc, sfc_dc);
-        destroy_pbuffer(sfc);
-        delete_context(base);
-        return NULL;
-    }
-
-    ctx->base = base;
-    ctx->sfc = sfc;
-    ctx->sfc_dc = sfc_dc;
-
-    return ctx;
-}
-
-int check_gl_make_current(struct gl_context *ctx)
-{
-    current = ctx;
-    return make_current((ctx ? ctx->sfc_dc : NULL),
-                        (ctx ? ctx->base : NULL));
-}
-
-void check_gl_context_destroy(struct gl_context *ctx)
-{
-    release_pbuffer_dc(ctx->sfc, ctx->sfc_dc);
-    destroy_pbuffer(ctx->sfc);
-    delete_context(ctx->base);
-    free(ctx);
-}
-
-int check_gl_procaddr(void **func, const char *sym, int opt)
-{
-    if (!make_current(init_dc, init_ctx)) {
-        return 0;
-    }
-
-    *func = (void*)get_proc_address((LPCSTR)sym);
-
-    if (!*func) {
-        *func = GetProcAddress(handle, sym);
-    }
-
-    make_current((current ? current->sfc_dc : NULL),
-                 (current ? current->base : NULL));
-
-    if (!*func && !opt) {
-        check_gl_log(gl_error, "Unable to find symbol \"%s\"", sym);
-        return 0;
-    }
-
-    return 1;
-}
diff --git a/tizen/src/check_hax.c b/tizen/src/check_hax.c
deleted file mode 100644 (file)
index 7c072e3..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * check if hax is available. reference:target-i386/hax-all.c
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * Hyunjun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef _WIN32
-#include <stdint.h>
-#include <errno.h>
-#include <windows.h>
-#include <winioctl.h>
-#endif
-
-#ifdef __APPLE__
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#endif
-
-
-
-#define HAX_MAX_VCPU 0x10
-
-#define HAX_CAP_STATUS_NOTWORKING  0x0
-#define HAX_CAP_WORKSTATUS_MASK 0x1
-#define HAX_CAP_FAILREASON_VT   0x1
-#define HAX_CAP_FAILREASON_NX   0x2
-
-#define HAX_CAP_MEMQUOTA    0x2
-
-#ifdef __APPLE__
-#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
-typedef int hax_fd;
-#endif
-
-#ifdef _WIN32
-#define HAX_DEVICE_TYPE 0x4000
-#define HAX_IOCTL_CAPABILITY    CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
-typedef HANDLE hax_fd;
-#endif
-
-struct hax_vm {
-    hax_fd fd;
-    int id;
-    struct hax_vcpu_state *vcpus[HAX_MAX_VCPU];
-};
-
-struct hax_state {
-    hax_fd fd; /* the global hax device interface */
-    uint32_t version;
-    struct hax_vm *vm;
-    uint64_t mem_quota;
-};
-
-struct hax_capabilityinfo {
-    /* bit 0: 1 - working
-     *        0 - not working, possibly because NT/NX disabled
-     * bit 1: 1 - memory limitation working
-     *        0 - no memory limitation
-     */
-    uint16_t wstatus;
-    /* valid when not working
-     * bit 0: VT not enabeld
-     * bit 1: NX not enabled*/
-    uint16_t winfo;
-    uint32_t pad;
-    uint64_t mem_quota;
-};
-#ifdef _WIN32
-static inline int hax_invalid_fd( hax_fd fd ) {
-    return ( fd == INVALID_HANDLE_VALUE );
-}
-#endif
-#ifdef __APPLE__
-static inline int hax_invalid_fd(hax_fd fd)
-{
-    return fd <= 0;
-}
-#endif
-
-
-static hax_fd hax_mod_open( void );
-static int hax_open_device( hax_fd *fd );
-static int hax_get_capability( struct hax_state *hax );
-static int hax_capability( struct hax_state *hax, struct hax_capabilityinfo *cap );
-
-static int check_hax( void ) {
-
-    struct hax_state hax;
-    memset( &hax, 0, sizeof( struct hax_state ) );
-
-    hax.fd = hax_mod_open();
-
-    int ret_fd = hax_invalid_fd( hax.fd );
-    if ( ret_fd ) {
-        fprintf( stderr, "Invalid fd:%d\n", ret_fd );
-        return ret_fd;
-    }
-
-    int ret_cap = hax_get_capability( &hax );
-    if ( ret_cap ) {
-        fprintf( stderr, "Not capable:%d\n", ret_cap );
-        return ret_cap;
-    }
-
-    return 0;
-
-}
-#ifdef _WIN32
-static int hax_open_device( hax_fd *fd ) {
-    uint32_t errNum = 0;
-    HANDLE hDevice;
-
-    if ( !fd )
-        return -2;
-
-    hDevice = CreateFile( "\\\\.\\HAX", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
-        NULL );
-
-    if ( hDevice == INVALID_HANDLE_VALUE ) {
-        fprintf( stderr, "Failed to open the HAX device!\n" );
-        errNum = GetLastError();
-        if ( errNum == ERROR_FILE_NOT_FOUND )
-            return -1;
-        return -2;
-    }
-    *fd = hDevice;
-    fprintf( stdout, "device fd:%d\n", *fd );
-    return 0;
-}
-
-static hax_fd hax_mod_open( void ) {
-    int ret;
-    hax_fd fd;
-
-    ret = hax_open_device( &fd );
-    if ( ret != 0 ) {
-        fprintf( stderr, "Open HAX device failed\n" );
-    }
-
-    return fd;
-}
-#else
-static hax_fd hax_mod_open(void)
-{
-    int fd = open("/dev/HAX", O_RDWR);
-
-    if (fd == -1)
-    {
-        fprintf(stderr, "hahFailed to open the hax module\n");
-        //return -errno;
-    }
-
-    return fd;
-}
-
-#endif
-
-static int hax_get_capability( struct hax_state *hax ) {
-    int ret;
-    struct hax_capabilityinfo capinfo, *cap = &capinfo;
-
-    ret = hax_capability( hax, cap );
-    if ( ret )
-        return ret;
-
-    if ( ( ( cap->wstatus & HAX_CAP_WORKSTATUS_MASK ) == HAX_CAP_STATUS_NOTWORKING ) ) {
-        if ( cap->winfo & HAX_CAP_FAILREASON_VT )
-            fprintf( stderr, "VTX feature is not enabled. which will cause HAX driver not working.\n" );
-        else if ( cap->winfo & HAX_CAP_FAILREASON_NX )
-            fprintf( stderr, "NX feature is not enabled, which will cause HAX driver not working.\n" );
-        return -ENXIO;
-    }
-
-/*
-    if ( cap->wstatus & HAX_CAP_MEMQUOTA ) {
-        if ( cap->mem_quota < hax->mem_quota ) {
-            fprintf( stderr, "The memory needed by this VM exceeds the driver limit.\n" );
-            return -ENOSPC;
-        }
-    }
-*/
-    return 0;
-}
-#ifdef _WIN32
-static int hax_capability( struct hax_state *hax, struct hax_capabilityinfo *cap ) {
-    int ret;
-    HANDLE hDevice = hax->fd; //handle to hax module
-    DWORD dSize = 0;
-    DWORD err = 0;
-
-    if ( hax_invalid_fd( hDevice ) ) {
-        fprintf( stderr, "Invalid fd for hax device!\n" );
-        return -ENODEV;
-    }
-
-    ret = DeviceIoControl( hDevice, HAX_IOCTL_CAPABILITY, NULL, 0, cap, sizeof( *cap ), &dSize, ( LPOVERLAPPED ) NULL );
-
-    if ( !ret ) {
-        err = GetLastError();
-        if ( err == ERROR_INSUFFICIENT_BUFFER || err == ERROR_MORE_DATA )
-            fprintf( stderr, "hax capability is too long to hold.\n" );
-        fprintf( stderr, "Failed to get Hax capability:%d\n", err );
-        return -EFAULT;
-    } else
-        return 0;
-
-}
-#endif
-
-#ifdef __APPLE__
-int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
-{
-    int ret;
-
-    ret = ioctl(hax->fd, HAX_IOCTL_CAPABILITY, cap);
-    if (ret == -1)
-    {
-        fprintf(stderr, "Failed to get HAX capability\n");
-        return -errno;
-    }
-
-    return 0;
-}
-#endif
-
-int main(int argc, char* argv[]) {
-    return check_hax();
-}
index ea43d45554c20bbac9d8faa377610bf08f3bd931..213d564cb13df4c0afd403b568fc1081216beff6 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "emulator.h"
 #include "debug_ch.h"
-#include "osutil.h"
+#include "util/osutil.h"
 
 static char debugchfile[512] = {0, };
 #ifdef _WIN32
diff --git a/tizen/src/display/Makefile.objs b/tizen/src/display/Makefile.objs
new file mode 100644 (file)
index 0000000..df03c53
--- /dev/null
@@ -0,0 +1,5 @@
+obj-y += maru_display.o
+obj-$(CONFIG_USE_SHM) += maru_shm.o
+obj-y += maru_sdl.o maru_sdl_processing.o maru_finger.o
+
+$(obj)/maru_display.o $(obj)/maru_sdl.o $(obj)/maru_sdl_processing.o $(obj)/maru_finger.o: QEMU_CFLAGS += $(SDL_CFLAGS)
diff --git a/tizen/src/display/maru_display.c b/tizen/src/display/maru_display.c
new file mode 100644 (file)
index 0000000..b00f144
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * MARU display driver
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#include "emulator.h"
+#include "maru_common.h"
+#include "maru_display.h"
+#include "debug_ch.h"
+
+#ifndef CONFIG_USE_SHM
+#include "maru_sdl.h"
+#else
+#include "maru_shm.h"
+#endif
+
+MULTI_DEBUG_CHANNEL(tizen, display);
+
+MaruScreenShot* screenshot = NULL;
+
+static void maru_display_fini(void)
+{
+    INFO("fini qemu display\n");
+
+    g_free(screenshot);
+
+#ifndef CONFIG_USE_SHM
+    maru_sdl_quit();
+#else
+    maru_shm_quit();
+#endif
+}
+
+static void maru_display_notify_exit(Notifier *notifier, void *data) {
+    maru_display_fini();
+}
+static Notifier maru_display_exit = { .notify = maru_display_notify_exit };
+
+//TODO: interface
+void maru_display_init(DisplayState *ds)
+{
+    INFO("init qemu display\n");
+
+#ifndef CONFIG_USE_SHM
+    maru_sdl_pre_init();
+#else
+    /* do nothing */
+#endif
+
+    /*  graphics context information */
+    DisplayChangeListener *dcl;
+
+    dcl = g_malloc0(sizeof(DisplayChangeListener));
+    dcl->ops = &maru_dcl_ops;
+    register_displaychangelistener(dcl);
+
+    screenshot = g_malloc0(sizeof(MaruScreenShot));
+    screenshot->pixels = NULL;
+    screenshot->request = false;
+    screenshot->ready = false;
+
+    emulator_add_exit_notifier(&maru_display_exit);
+}
+
+void maru_display_resize(void)
+{
+#ifndef CONFIG_USE_SHM
+    maru_sdl_resize();
+#else
+    maru_shm_resize();
+#endif
+}
+
+void maru_display_update(void)
+{
+#ifndef CONFIG_USE_SHM
+    maru_sdl_update();
+#else
+    /* do nothing */
+#endif
+}
+
+void maru_display_invalidate(bool on)
+{
+#ifndef CONFIG_USE_SHM
+    maru_sdl_invalidate(on);
+#else
+    /* do nothing */
+#endif
+}
+
+void maru_display_interpolation(bool on)
+{
+#ifndef CONFIG_USE_SHM
+    maru_sdl_interpolation(on);
+#else
+    /* do nothing */
+#endif
+}
+
+void maru_ds_surface_init(uint64 swt_handle,
+    unsigned int display_width, unsigned int display_height,
+    bool blank_guide)
+{
+#ifndef CONFIG_USE_SHM
+    maru_sdl_init(swt_handle,
+        display_width, display_height, blank_guide);
+#else
+    maru_shm_init(swt_handle,
+        display_width, display_height, blank_guide);
+#endif
+}
+
+MaruScreenShot *get_screenshot(void)
+{
+    return screenshot;
+}
+
+/* save_screenshot() implemented in maruskin_operation.c */
diff --git a/tizen/src/display/maru_display.h b/tizen/src/display/maru_display.h
new file mode 100644 (file)
index 0000000..c9c4552
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * MARU display driver
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef __MARU_DISPLAY_H__
+#define __MARU_DISPLAY_H__
+
+#include "ui/console.h"
+
+typedef struct MaruScreenShot {
+    unsigned char *pixels;
+    bool request;
+    bool ready;
+} MaruScreenShot;
+
+void maru_display_init(DisplayState *ds);
+void maru_display_resize(void);
+void maru_display_update(void);
+void maru_display_invalidate(bool on);
+void maru_display_interpolation(bool on);
+void maru_ds_surface_init(uint64 swt_handle,
+    unsigned int display_width, unsigned int display_height,
+    bool blank_guide);
+
+MaruScreenShot *get_screenshot(void);
+void save_screenshot(DisplaySurface *surface);
+
+#endif /* __MARU_DISPLAY_H__ */
diff --git a/tizen/src/display/maru_finger.c b/tizen/src/display/maru_finger.c
new file mode 100644 (file)
index 0000000..b97a71e
--- /dev/null
@@ -0,0 +1,589 @@
+/*
+ * Multi-touch processing
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#include <math.h>
+#include <glib.h>
+#include <SDL.h>
+#include "maru_finger.h"
+#include "emul_state.h"
+#include "hw/maru_virtio_touchscreen.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(qemu, maru_finger);
+
+
+/* ===== Reference: http://content.gpwiki.org/index.php/SDL:Tutorials:Drawing_and_Filling_Circles ===== */
+
+/*
+* This is a 32-bit pixel function created with help from this
+* website: http://www.libsdl.org/intro.en/usingvideo.html
+*
+* You will need to make changes if you want it to work with
+* 8-, 16- or 24-bit surfaces.  Consult the above website for
+* more information.
+*/
+static void sdl_set_pixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
+{
+   Uint8 *target_pixel = (Uint8 *)surface->pixels + y * surface->pitch + x * 4;
+   *(Uint32 *)target_pixel = pixel;
+}
+
+/*
+* This is an implementation of the Midpoint Circle Algorithm
+* found on Wikipedia at the following link:
+*
+*   http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
+*
+* The algorithm elegantly draws a circle quickly, using a
+* set_pixel function for clarity.
+*/
+static void sdl_draw_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel)
+{
+   int error = -radius;
+   int x = radius;
+   int y = 0;
+
+   while (x >= y) {
+       sdl_set_pixel(surface, cx + x, cy + y, pixel);
+       sdl_set_pixel(surface, cx + y, cy + x, pixel);
+
+       if (x != 0) {
+           sdl_set_pixel(surface, cx - x, cy + y, pixel);
+           sdl_set_pixel(surface, cx + y, cy - x, pixel);
+       }
+
+       if (y != 0) {
+           sdl_set_pixel(surface, cx + x, cy - y, pixel);
+           sdl_set_pixel(surface, cx - y, cy + x, pixel);
+       }
+
+       if (x != 0 && y != 0) {
+           sdl_set_pixel(surface, cx - x, cy - y, pixel);
+           sdl_set_pixel(surface, cx - y, cy - x, pixel);
+       }
+
+       error += y;
+       ++y;
+       error += y;
+
+       if (error >= 0) {
+           --x;
+           error -= x;
+           error -= x;
+       }
+   }
+}
+
+/*
+* SDL_Surface 32-bit circle-fill algorithm without using trig
+*
+* While I humbly call this "Celdecea's Method", odds are that the
+* procedure has already been documented somewhere long ago.  All of
+* the circle-fill examples I came across utilized trig functions or
+* scanning neighbor pixels.  This algorithm identifies the width of
+* a semi-circle at each pixel height and draws a scan-line covering
+* that width.
+*
+* The code is not optimized but very fast, owing to the fact that it
+* alters pixels in the provided surface directly rather than through
+* function calls.
+*
+* WARNING:  This function does not lock surfaces before altering, so
+* use SDL_LockSurface in any release situation.
+*/
+static void sdl_fill_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel)
+{
+   /* Note that there is more to altering the bitrate of this
+   * method than just changing this value.  See how pixels are
+   * altered at the following web page for tips:
+   *   http://www.libsdl.org/intro.en/usingvideo.html */
+
+   const int bpp = 4;
+   double dy;
+
+   double r = (double)radius;
+
+   for (dy = 1; dy <= r; dy += 1.0)
+   {
+       /* This loop is unrolled a bit, only iterating through half of the
+       * height of the circle.  The result is used to draw a scan line and
+       * its mirror image below it.
+       * The following formula has been simplified from our original.  We
+       * are using half of the width of the circle because we are provided
+       * with a center and we need left/right coordinates. */
+
+       double dx = floor(sqrt((2.0 * r * dy) - (dy * dy)));
+       int x = cx - dx;
+
+       /* Grab a pointer to the left-most pixel for each half of the circle */
+       Uint8 *target_pixel_a = (Uint8 *)surface->pixels +
+           ((int)(cy + r - dy)) * surface->pitch + x * bpp;
+
+       Uint8 *target_pixel_b = (Uint8 *)surface->pixels +
+            ((int)(cy - r + dy)) * surface->pitch + x * bpp;
+
+       for ( ; x <= cx + dx; x++)
+       {
+           *(Uint32 *)target_pixel_a = pixel;
+           *(Uint32 *)target_pixel_b = pixel;
+           target_pixel_a += bpp;
+           target_pixel_b += bpp;
+       }
+   }
+}
+
+/* ==================================================================================================== */
+
+
+void init_multi_touch_state(void)
+{
+    int i;
+    MultiTouchState* mts = get_emul_multi_touch_state();
+    FingerPoint *finger = NULL;
+
+    INFO("multi-touch state initialization\n");
+
+    mts->multitouch_enable = 0;
+
+    mts->finger_cnt_max = get_emul_max_touch_point();
+    if (mts->finger_cnt_max > MAX_FINGER_CNT) {
+        mts->finger_cnt_max = MAX_FINGER_CNT;
+        set_emul_max_touch_point(mts->finger_cnt_max);
+    }
+    INFO("maxTouchPoint : %d\n", get_emul_max_touch_point());
+
+    mts->finger_cnt = 0;
+
+    if (mts->finger_slot != NULL) {
+        g_free(mts->finger_slot);
+        mts->finger_slot = NULL;
+    }
+    mts->finger_slot =
+        (FingerPoint *) g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max);
+
+    for (i = 0; i < mts->finger_cnt_max; i++) {
+        finger = get_finger_point_from_slot(i);
+        if (finger != NULL) {
+            finger->origin_x = finger->origin_y = -1;
+            finger->x = finger->y = -1;
+        }
+    }
+
+    mts->finger_point_size = DEFAULT_FINGER_POINT_SIZE;
+    int finger_point_size_half = mts->finger_point_size / 2;
+    mts->finger_point_color = DEFAULT_FINGER_POINT_COLOR;
+    mts->finger_point_outline_color = DEFAULT_FINGER_POINT_OUTLINE_COLOR;
+
+    /* create finger point surface */
+    Uint32 rmask, gmask, bmask, amask;
+#ifdef HOST_WORDS_BIGENDIAN
+    rmask = 0xff000000;
+    gmask = 0x00ff0000;
+    bmask = 0x0000ff00;
+    amask = 0x000000ff;
+#else
+    rmask = 0x000000ff;
+    gmask = 0x0000ff00;
+    bmask = 0x00ff0000;
+    amask = 0xff000000;
+#endif
+
+    SDL_Surface *point = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_HWSURFACE,
+        mts->finger_point_size + 2, mts->finger_point_size + 2,
+        get_emul_sdl_bpp(), rmask, gmask, bmask, amask);
+
+    /* finger point circle */
+    sdl_fill_circle(point, finger_point_size_half, finger_point_size_half,
+        finger_point_size_half, mts->finger_point_color);
+
+    /* finger point circle outline */
+    sdl_draw_circle(point, finger_point_size_half, finger_point_size_half,
+        finger_point_size_half, mts->finger_point_outline_color);
+
+    mts->finger_point_surface = (void *)point;
+}
+
+void set_multi_touch_enable(int enable)
+{
+    get_emul_multi_touch_state()->multitouch_enable = enable;
+}
+
+int get_multi_touch_enable(void)
+{
+    return get_emul_multi_touch_state()->multitouch_enable;
+}
+
+int add_finger_point(int origin_x, int origin_y, int x, int y)
+{
+    MultiTouchState *mts = get_emul_multi_touch_state();
+
+    if (mts->finger_cnt == mts->finger_cnt_max) {
+        WARN("support multi-touch up to %d fingers\n", mts->finger_cnt_max);
+        return -1;
+    }
+
+    mts->finger_cnt += 1;
+
+    mts->finger_slot[mts->finger_cnt - 1].id = mts->finger_cnt;
+    mts->finger_slot[mts->finger_cnt - 1].origin_x = origin_x;
+    mts->finger_slot[mts->finger_cnt - 1].origin_y = origin_y;
+    mts->finger_slot[mts->finger_cnt - 1].x = x;
+    mts->finger_slot[mts->finger_cnt - 1].y = y;
+
+    INFO("%d finger touching\n", mts->finger_cnt);
+
+    return mts->finger_cnt;
+}
+
+FingerPoint *get_finger_point_from_slot(int index)
+{
+    MultiTouchState *mts = get_emul_multi_touch_state();
+
+    if (index < 0 || index > mts->finger_cnt_max) {
+        return NULL;
+    }
+
+    return &(mts->finger_slot[index]);
+}
+
+FingerPoint *get_finger_point_search(int x, int y)
+{
+    int i;
+    MultiTouchState *mts = get_emul_multi_touch_state();
+    FingerPoint *finger = NULL;
+    int finger_region = (mts->finger_point_size / 2) +
+        2 + (int)((1 - get_emul_win_scale()) * 4);
+
+    for (i = mts->finger_cnt - 1; i >= 0; i--) {
+        finger = get_finger_point_from_slot(i);
+
+        if (finger != NULL) {
+            if (x >= (finger->x - finger_region) &&
+                x < (finger->x + finger_region) &&
+                y >= (finger->y - finger_region) &&
+                y < (finger->y + finger_region)) {
+                    return finger;
+            }
+        }
+    }
+
+    return NULL;
+}
+
+
+static int _grab_finger_id = 0;
+#define QEMU_MOUSE_PRESSED 1
+#define QEMU_MOUSE_RELEASEED 0
+
+void maru_finger_processing_1(
+    int touch_type, int origin_x, int origin_y, int x, int y)
+{
+    MultiTouchState *mts = get_emul_multi_touch_state();
+    FingerPoint *finger = NULL;
+
+    if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */
+        if (_grab_finger_id > 0) {
+            finger = get_finger_point_from_slot(_grab_finger_id - 1);
+            if (finger != NULL) {
+                finger->origin_x = origin_x;
+                finger->origin_y = origin_y;
+                finger->x = x;
+                finger->y = y;
+
+                if (finger->id != 0) {
+                    virtio_touchscreen_event(x, y,
+                        _grab_finger_id - 1, QEMU_MOUSE_PRESSED);
+                    TRACE("id %d finger multi-touch dragging : (%d, %d)\n",
+                        _grab_finger_id, x, y);
+                }
+            }
+            return;
+        }
+
+        if (mts->finger_cnt == 0)
+        { /* first finger touch input */
+
+            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
+                return;
+            }
+
+            virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED);
+        }
+        else if ((finger = get_finger_point_search(x, y)) != NULL)
+        { /* check the position of previous touch event */
+
+            /* finger point is selected */
+            _grab_finger_id = finger->id;
+            TRACE("id %d finger is grabbed\n", _grab_finger_id);
+        }
+        else if (mts->finger_cnt == mts->finger_cnt_max)
+        { /* Let's assume that this event is last finger touch input */
+
+            finger = get_finger_point_from_slot(mts->finger_cnt_max - 1);
+            if (finger != NULL) {
+#if 1 /* send release event?? */
+                virtio_touchscreen_event(finger->x, finger->y,
+                    mts->finger_cnt_max - 1, QEMU_MOUSE_RELEASEED);
+#endif
+
+                finger->origin_x = origin_x;
+                finger->origin_y = origin_y;
+                finger->x = x;
+                finger->y = y;
+                if (finger->id != 0) {
+                    virtio_touchscreen_event(x, y,
+                        mts->finger_cnt_max - 1, QEMU_MOUSE_PRESSED);
+                }
+            }
+        }
+        else /* one more finger */
+        {
+            add_finger_point(origin_x, origin_y, x, y);
+            virtio_touchscreen_event(x, y,
+                mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
+        }
+
+    } else if (touch_type == MOUSE_UP) { /* released */
+        _grab_finger_id = 0;
+    }
+}
+
+void maru_finger_processing_2(
+    int touch_type, int origin_x, int origin_y, int x, int y)
+{
+    MultiTouchState *mts = get_emul_multi_touch_state();
+    FingerPoint *finger = NULL;
+
+    if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */
+        if (_grab_finger_id > 0) {
+            finger = get_finger_point_from_slot(_grab_finger_id - 1);
+            if (finger != NULL) {
+                int origin_distance_x = origin_x - finger->origin_x;
+                int origin_distance_y = origin_y - finger->origin_y;
+                int distance_x = x - finger->x;
+                int distance_y = y - finger->y;
+
+                int current_screen_w = get_emul_resolution_width();
+                int current_screen_h = get_emul_resolution_height();
+                int temp_finger_x, temp_finger_y;
+
+                int i = 0;
+
+                /* bounds checking */
+                for(i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) {
+                    finger = get_finger_point_from_slot(i);
+                    if (finger == NULL) {
+                        continue;
+                    }
+
+                    temp_finger_x = finger->x + distance_x;
+                    temp_finger_y = finger->y + distance_y;
+
+                    if (temp_finger_x > current_screen_w || temp_finger_x < 0
+                        || temp_finger_y > current_screen_h || temp_finger_y < 0) {
+                        TRACE("id %d finger is out of bounds (%d, %d)\n",
+                            i + 1, temp_finger_x, temp_finger_y);
+                        return;
+                    }
+                }
+
+                for(i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) {
+                    finger = get_finger_point_from_slot(i);
+                    if (finger == NULL) {
+                        continue;
+                    }
+
+                    finger->origin_x += origin_distance_x;
+                    finger->origin_y += origin_distance_y;
+                    finger->x += distance_x;
+                    finger->y += distance_y;
+
+                    if (finger->id != 0) {
+                        virtio_touchscreen_event(finger->x, finger->y,
+                            i, QEMU_MOUSE_PRESSED);
+                        TRACE("id %d finger multi-touch dragging = (%d, %d)\n",
+                            i + 1, finger->x, finger->y);
+                    }
+#ifdef _WIN32
+                    Sleep(2);
+#else
+                    usleep(2000);
+#endif
+
+                }
+            }
+
+            return;
+        }
+
+        if (mts->finger_cnt == 0)
+        { /* first finger touch input */
+
+            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
+                return;
+            }
+
+            virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED);
+        }
+        else if ((finger = get_finger_point_search(x, y)) != NULL)
+        { /* check the position of previous touch event */
+
+            /* finger point is selected */
+            _grab_finger_id = finger->id;
+            TRACE("id %d finger is grabbed\n", _grab_finger_id);
+        }
+        else if (mts->finger_cnt == mts->finger_cnt_max)
+        { /* Let's assume that this event is last finger touch input */
+
+            /* do nothing */
+        }
+        else /* one more finger */
+        {
+
+            add_finger_point(origin_x, origin_y, x, y) ;
+            virtio_touchscreen_event(x, y, mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
+        }
+
+    } else if (touch_type == MOUSE_UP) { /* released */
+        _grab_finger_id = 0;
+    }
+}
+
+static bool _calculate_origin_coordinates(
+    int scaled_display_w, int scaled_display_h,
+    double scale_factor, int rotaton_type, FingerPoint *finger)
+{
+    int point_x = 0, point_y = 0;
+    int rotated_point_x = 0, rotated_point_y = 0;
+    int flag = 0;
+
+    rotated_point_x = point_x = (int)(finger->x * scale_factor);
+    rotated_point_y = point_y = (int)(finger->y * scale_factor);
+
+    if (rotaton_type == ROTATION_LANDSCAPE) {
+        rotated_point_x = point_y;
+        rotated_point_y = scaled_display_w - point_x;
+    } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
+        rotated_point_x = scaled_display_w - point_x;
+        rotated_point_y = scaled_display_h - point_y;
+    } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
+        rotated_point_x = scaled_display_h - point_y;
+        rotated_point_y = point_x;
+    }
+
+    if (finger->origin_x != rotated_point_x) {
+        finger->origin_x = rotated_point_x;
+        flag = 1;
+    }
+    if (finger->origin_y != rotated_point_y) {
+        finger->origin_y = rotated_point_y;
+        flag = 1;
+    }
+
+    if (flag != 0) {
+        return true;
+    }
+
+    return false;
+}
+
+int rearrange_finger_points(
+    int lcd_w, int lcd_h, double scale_factor, int rotaton_type)
+{
+    int i = 0;
+    int count = 0;
+    MultiTouchState *mts = get_emul_multi_touch_state();
+    FingerPoint *finger = NULL;
+
+    if (mts->multitouch_enable == 0) {
+        return 0;
+    }
+
+    lcd_w *= scale_factor;
+    lcd_h *= scale_factor;
+
+    for (i = 0; i < mts->finger_cnt; i++) {
+        finger = get_finger_point_from_slot(i);
+        if (finger != NULL && finger->id != 0) {
+            if (_calculate_origin_coordinates(lcd_w, lcd_h,
+                scale_factor, rotaton_type, finger) == true) {
+                count++;
+            }
+        }
+    }
+
+    if (count != 0) {
+        _grab_finger_id = 0;
+    }
+
+    return count;
+}
+
+void clear_finger_slot(bool keep_enable)
+{
+    int i = 0;
+    MultiTouchState *mts = get_emul_multi_touch_state();
+    FingerPoint *finger = NULL;
+
+    if (keep_enable == false) {
+        set_multi_touch_enable(0);
+    }
+
+    INFO("clear multi-touch : %d\n", get_multi_touch_enable());
+
+    for (i = 0; i < mts->finger_cnt; i++) {
+        finger = get_finger_point_from_slot(i);
+        if (finger != NULL) {
+            if (finger->id > 0) {
+                virtio_touchscreen_event(finger->x, finger->y,
+                    finger->id - 1, QEMU_MOUSE_RELEASEED);
+            }
+
+            finger->id = 0;
+            finger->origin_x = finger->origin_y = finger->x = finger->y = -1;
+        }
+    }
+
+    _grab_finger_id = 0;
+    mts->finger_cnt = 0;
+}
+
+void cleanup_multi_touch_state(void)
+{
+    MultiTouchState *mts = get_emul_multi_touch_state();
+    SDL_Surface *point = (SDL_Surface *)mts->finger_point_surface;
+
+    clear_finger_slot(false);
+    g_free(mts->finger_slot);
+
+    mts->finger_point_surface = NULL;
+    SDL_FreeSurface(point);
+}
+
diff --git a/tizen/src/display/maru_finger.h b/tizen/src/display/maru_finger.h
new file mode 100644 (file)
index 0000000..61a32e8
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Multi-touch processing
+ *
+ * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef __MARU_FINGER_H__
+#define __MARU_FINGER_H__
+
+#include "qemu-common.h"
+
+
+/* definitions relating to multi-touch */
+#define MAX_FINGER_CNT 10
+#define DEFAULT_FINGER_POINT_SIZE 32
+#define DEFAULT_FINGER_POINT_COLOR 0x7E0F0F0F
+#define DEFAULT_FINGER_POINT_OUTLINE_COLOR 0xDDDDDDDD
+
+typedef struct FingerPoint {
+    int id;
+    int origin_x;
+    int origin_y;
+    int x;
+    int y;
+} FingerPoint;
+
+typedef struct MultiTouchState {
+    int multitouch_enable;
+    int finger_cnt;
+    int finger_cnt_max;
+    FingerPoint *finger_slot;
+
+    int finger_point_size;
+    int finger_point_color;
+    int finger_point_outline_color;
+    void *finger_point_surface; //SDL_Surface
+} MultiTouchState;
+
+
+void init_multi_touch_state(void);
+void set_multi_touch_enable(int enable);
+int get_multi_touch_enable(void);
+FingerPoint *get_finger_point_from_slot(int index);
+FingerPoint *get_finger_point_search(int x, int y);
+int add_finger_point(int origin_x, int origin_y, int x, int y);
+
+void maru_finger_processing_1(int touch_type, int origin_x, int origin_y, int x, int y);
+void maru_finger_processing_2(int touch_type, int origin_x, int origin_y, int x, int y);
+int rearrange_finger_points(int lcd_w, int lcd_h, double scale_factor, int rotaton_type);
+void clear_finger_slot(bool keep_enable);
+void cleanup_multi_touch_state(void);
+
+
+#endif /* __MARU_FINGER_H__ */
diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c
new file mode 100644 (file)
index 0000000..35be462
--- /dev/null
@@ -0,0 +1,609 @@
+/*
+ * SDL_WINDOWID hack
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#include <png.h>
+#include "qemu/main-loop.h"
+#include "emulator.h"
+#include "emul_state.h"
+#include "maru_display.h"
+#include "maru_sdl.h"
+#include "maru_sdl_processing.h"
+#include "hw/maru_brightness.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
+
+static QEMUBH *sdl_init_bh;
+static QEMUBH *sdl_resize_bh;
+static QEMUBH *sdl_update_bh;
+static DisplaySurface *dpy_surface;
+
+static SDL_Surface *surface_screen;
+static SDL_Surface *surface_qemu;
+static SDL_Surface *scaled_screen;
+static SDL_Surface *rotated_screen;
+static SDL_Surface *surface_guide; /* blank guide image */
+
+static double current_scale_factor = 1.0;
+static double current_screen_degree;
+static pixman_filter_t sdl_pixman_filter;
+
+static bool sdl_invalidate;
+static int sdl_alteration;
+
+static unsigned int sdl_skip_update;
+static unsigned int sdl_skip_count;
+
+static bool blank_guide_enable;
+static unsigned int blank_cnt;
+#define MAX_BLANK_FRAME_CNT 10
+#define BLANK_GUIDE_IMAGE_PATH "../images/"
+#define BLANK_GUIDE_IMAGE_NAME "blank-guide.png"
+
+#ifdef SDL_THREAD
+QemuMutex sdl_mutex;
+QemuCond sdl_cond;
+static int sdl_thread_initialized;
+
+QemuThread sdl_thread;
+static bool sdl_thread_exit;
+#endif
+
+#define SDL_FLAGS (SDL_SWSURFACE | SDL_ASYNCBLIT | SDL_NOFRAME)
+#define SDL_BPP 32
+
+static void qemu_update(void);
+
+
+static void qemu_ds_sdl_update(DisplayChangeListener *dcl,
+                               int x, int y, int w, int h)
+{
+    /* call sdl update */
+#ifdef SDL_THREAD
+    qemu_mutex_lock(&sdl_mutex);
+
+    qemu_cond_signal(&sdl_cond);
+
+    qemu_mutex_unlock(&sdl_mutex);
+#else
+    qemu_update();
+#endif
+}
+
+static void qemu_ds_sdl_switch(DisplayChangeListener *dcl,
+                               struct DisplaySurface *new_surface)
+{
+    int console_width = 0, console_height = 0;
+
+    sdl_skip_update = 0;
+    sdl_skip_count = 0;
+
+    if (!new_surface) {
+        ERR("qemu_ds_sdl_switch : new_surface is NULL\n");
+        return;
+    }
+
+    console_width = surface_width(new_surface);
+    console_height = surface_height(new_surface);
+
+    INFO("qemu_ds_sdl_switch : (%d, %d)\n", console_width, console_height);
+
+    /* switch */
+    dpy_surface = new_surface;
+
+    if (surface_qemu != NULL) {
+        SDL_FreeSurface(surface_qemu);
+        surface_qemu = NULL;
+    }
+
+    /* create surface_qemu */
+    if (console_width == get_emul_resolution_width() &&
+        console_height == get_emul_resolution_height()) {
+        INFO("create SDL screen : (%d, %d)\n",
+             console_width, console_height);
+
+        surface_qemu = SDL_CreateRGBSurfaceFrom(
+            surface_data(dpy_surface),
+            console_width, console_height,
+            surface_bits_per_pixel(dpy_surface),
+            surface_stride(dpy_surface),
+            dpy_surface->pf.rmask,
+            dpy_surface->pf.gmask,
+            dpy_surface->pf.bmask,
+            dpy_surface->pf.amask);
+    } else {
+        INFO("create blank screen : (%d, %d)\n",
+             get_emul_resolution_width(), get_emul_resolution_height());
+
+        surface_qemu = SDL_CreateRGBSurface(
+            SDL_SWSURFACE,
+            console_width, console_height,
+            surface_bits_per_pixel(dpy_surface),
+            0, 0, 0, 0);
+    }
+
+    if (surface_qemu == NULL) {
+        ERR("Unable to set the RGBSurface: %s\n", SDL_GetError());
+        return;
+    }
+}
+
+static SDL_Surface *get_blank_guide_image(void)
+{
+    if (surface_guide == NULL) {
+        unsigned int width = 0;
+        unsigned int height = 0;
+        char *guide_image_path = NULL;
+        void *guide_image_data = NULL;
+
+        /* load png image */
+        int path_len = strlen(get_bin_path()) +
+            strlen(BLANK_GUIDE_IMAGE_PATH) +
+            strlen(BLANK_GUIDE_IMAGE_NAME) + 1;
+        guide_image_path = g_malloc0(sizeof(char) * path_len);
+        snprintf(guide_image_path, path_len, "%s%s%s",
+            get_bin_path(), BLANK_GUIDE_IMAGE_PATH,
+            BLANK_GUIDE_IMAGE_NAME);
+
+        guide_image_data = (void *) read_png_file(
+            guide_image_path, &width, &height);
+
+        if (guide_image_data != NULL) {
+            surface_guide = SDL_CreateRGBSurfaceFrom(
+                guide_image_data, width, height,
+                get_emul_sdl_bpp(), width * 4,
+                dpy_surface->pf.bmask,
+                dpy_surface->pf.gmask,
+                dpy_surface->pf.rmask,
+                dpy_surface->pf.amask);
+        } else {
+            ERR("failed to draw a blank guide image\n");
+        }
+
+        g_free(guide_image_path);
+    }
+
+    return surface_guide;
+}
+
+static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl)
+{
+    if (sdl_alteration == 1) {
+        sdl_alteration = 0;
+        sdl_skip_update = 0;
+        sdl_skip_count = 0;
+    }
+
+    /* draw cover image */
+    if (sdl_skip_update && display_off) {
+        if (blank_cnt > MAX_BLANK_FRAME_CNT) {
+#ifdef CONFIG_WIN32
+            if (sdl_invalidate && get_emul_skin_enable()) {
+                draw_image(surface_screen, get_blank_guide_image());
+            }
+#endif
+
+            return;
+        } else if (blank_cnt == MAX_BLANK_FRAME_CNT) {
+            if (blank_guide_enable == true && get_emul_skin_enable()) {
+                INFO("draw a blank guide image\n");
+
+                draw_image(surface_screen, get_blank_guide_image());
+            }
+        } else if (blank_cnt == 0) {
+            /* If the display is turned off,
+            the screen does not update until the display is turned on */
+            INFO("skipping of the display updating is started\n");
+        }
+
+        blank_cnt++;
+
+        return;
+    } else {
+        if (blank_cnt != 0) {
+            INFO("skipping of the display updating is ended\n");
+            blank_cnt = 0;
+        }
+    }
+
+    /* draw framebuffer */
+    if (sdl_invalidate) {
+        graphic_hw_invalidate(NULL);
+    }
+    graphic_hw_update(NULL);
+
+    /* Usually, continuously updated.
+       When the display is turned off,
+       ten more updates the screen for a black screen. */
+    if (display_off) {
+        if (++sdl_skip_count > 10) {
+            sdl_skip_update = 1;
+        } else {
+            sdl_skip_update = 0;
+        }
+    } else {
+        sdl_skip_count = 0;
+        sdl_skip_update = 0;
+    }
+
+#ifdef TARGET_ARM
+#ifdef SDL_THREAD
+    qemu_mutex_lock(&sdl_mutex);
+#endif
+
+    /*
+    * It is necessary only for exynos4210 FIMD in connection with
+    * some WM (xfwm4, for example)
+    */
+
+    SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
+
+#ifdef SDL_THREAD
+    qemu_mutex_unlock(&sdl_mutex);
+#endif
+#endif
+}
+
+DisplayChangeListenerOps maru_dcl_ops = {
+    .dpy_name          = "maru_sdl",
+    .dpy_gfx_update    = qemu_ds_sdl_update,
+    .dpy_gfx_switch    = qemu_ds_sdl_switch,
+    .dpy_refresh       = qemu_ds_sdl_refresh,
+};
+
+void maru_sdl_interpolation(bool on)
+{
+    if (on == true) {
+        INFO("set PIXMAN_FILTER_BEST filter for image processing\n");
+
+        /* PIXMAN_FILTER_BILINEAR */
+        sdl_pixman_filter = PIXMAN_FILTER_BEST;
+    } else {
+        INFO("set PIXMAN_FILTER_FAST filter for image processing\n");
+
+        /* PIXMAN_FILTER_NEAREST */
+        sdl_pixman_filter = PIXMAN_FILTER_FAST;
+    }
+}
+
+static void qemu_update(void)
+{
+    if (sdl_alteration < 0) {
+        SDL_FreeSurface(scaled_screen);
+        SDL_FreeSurface(rotated_screen);
+        SDL_FreeSurface(surface_qemu);
+        surface_qemu = NULL;
+
+        return;
+    }
+
+    if (surface_qemu != NULL) {
+        maru_do_pixman_dpy_surface(dpy_surface->image);
+
+        save_screenshot(dpy_surface);
+
+        if (current_scale_factor != 1.0) {
+            rotated_screen = maru_do_pixman_rotate(
+                surface_qemu, rotated_screen,
+                (int)current_screen_degree);
+            scaled_screen = maru_do_pixman_scale(
+                rotated_screen, scaled_screen, sdl_pixman_filter);
+
+            SDL_BlitSurface(scaled_screen, NULL, surface_screen, NULL);
+        }
+        else {/* current_scale_factor == 1.0 */
+            if (current_screen_degree != 0.0) {
+                rotated_screen = maru_do_pixman_rotate(
+                    surface_qemu, rotated_screen,
+                    (int)current_screen_degree);
+
+                SDL_BlitSurface(rotated_screen, NULL, surface_screen, NULL);
+            } else {
+                /* as-is */
+                SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL);
+            }
+        }
+
+        /* draw multi-touch finger points */
+        MultiTouchState *mts = get_emul_multi_touch_state();
+        if (mts->multitouch_enable != 0 && mts->finger_point_surface != NULL) {
+            int i = 0;
+            FingerPoint *finger = NULL;
+            int finger_point_size_half = mts->finger_point_size / 2;
+            SDL_Rect rect;
+
+            for (i = 0; i < mts->finger_cnt; i++) {
+                finger = get_finger_point_from_slot(i);
+                if (finger != NULL && finger->id != 0) {
+                    rect.x = finger->origin_x - finger_point_size_half;
+                    rect.y = finger->origin_y - finger_point_size_half;
+                    rect.w = rect.h = mts->finger_point_size;
+
+                    SDL_BlitSurface(
+                        (SDL_Surface *)mts->finger_point_surface,
+                        NULL, surface_screen, &rect);
+                }
+            }
+        } /* end of draw multi-touch */
+    }
+
+    SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
+}
+
+
+#ifdef SDL_THREAD
+static void *run_qemu_update(void *arg)
+{
+    qemu_mutex_lock(&sdl_mutex);
+
+    while (1) {
+        qemu_cond_wait(&sdl_cond, &sdl_mutex);
+        if (sdl_thread_exit) {
+            INFO("make SDL Thread exit\n");
+            break;
+        }
+        qemu_update();
+    }
+
+    qemu_mutex_unlock(&sdl_mutex);
+
+    INFO("finish qemu_update routine\n");
+    return NULL;
+}
+#endif
+
+static void maru_sdl_update_bh(void *opaque)
+{
+    graphic_hw_invalidate(NULL);
+}
+
+static void maru_sdl_resize_bh(void *opaque)
+{
+    int surface_width = 0, surface_height = 0;
+    int display_width = 0, display_height = 0;
+    int temp = 0;
+
+    INFO("Set up a video mode with the specified width, "
+         "height and bits-per-pixel\n");
+
+    sdl_alteration = 1;
+    sdl_skip_update = 0;
+
+#ifdef SDL_THREAD
+    qemu_mutex_lock(&sdl_mutex);
+#endif
+
+    /* get current setting information and calculate screen size */
+    display_width = get_emul_resolution_width();
+    display_height = get_emul_resolution_height();
+    current_scale_factor = get_emul_win_scale();
+
+    short rotaton_type = get_emul_rotation();
+    if (rotaton_type == ROTATION_PORTRAIT) {
+        current_screen_degree = 0.0;
+    } else if (rotaton_type == ROTATION_LANDSCAPE) {
+        current_screen_degree = 90.0;
+        temp = display_width;
+        display_width = display_height;
+        display_height = temp;
+    } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
+        current_screen_degree = 180.0;
+    } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
+        current_screen_degree = 270.0;
+        temp = display_width;
+        display_width = display_height;
+        display_height = temp;
+    }
+
+    surface_width = display_width * current_scale_factor;
+    surface_height = display_height * current_scale_factor;
+
+    surface_screen = SDL_SetVideoMode(
+        surface_width, surface_height,
+        get_emul_sdl_bpp(), SDL_FLAGS);
+
+    INFO("SDL_SetVideoMode\n");
+
+    if (surface_screen == NULL) {
+        ERR("Could not open SDL display (%dx%dx%d) : %s\n",
+            surface_width, surface_height,
+            get_emul_sdl_bpp(), SDL_GetError());
+
+#ifdef SDL_THREAD
+        qemu_mutex_unlock(&sdl_mutex);
+#endif
+
+        return;
+    }
+
+    SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
+
+    /* create buffer for image processing */
+    SDL_FreeSurface(scaled_screen);
+    scaled_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
+        surface_width, surface_height,
+        surface_qemu->format->BitsPerPixel,
+        surface_qemu->format->Rmask,
+        surface_qemu->format->Gmask,
+        surface_qemu->format->Bmask,
+        surface_qemu->format->Amask);
+
+    SDL_FreeSurface(rotated_screen);
+    rotated_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
+        display_width, display_height,
+        surface_qemu->format->BitsPerPixel,
+        surface_qemu->format->Rmask,
+        surface_qemu->format->Gmask,
+        surface_qemu->format->Bmask,
+        surface_qemu->format->Amask);
+
+    /* rearrange multi-touch finger points */
+    if (get_emul_multi_touch_state()->multitouch_enable == 1 ||
+            get_emul_multi_touch_state()->multitouch_enable == 2) {
+        rearrange_finger_points(get_emul_resolution_width(), get_emul_resolution_height(),
+            current_scale_factor, rotaton_type);
+    }
+
+#ifdef SDL_THREAD
+    qemu_mutex_unlock(&sdl_mutex);
+#endif
+
+    graphic_hw_invalidate(NULL);
+}
+
+static void maru_sdl_init_bh(void *opaque)
+{
+    INFO("SDL_Init\n");
+
+    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+        ERR("unable to init SDL: %s\n", SDL_GetError());
+        // TODO:
+    }
+
+#ifndef CONFIG_WIN32
+    SDL_SysWMinfo info;
+    SDL_VERSION(&info.version);
+    SDL_GetWMInfo(&info);
+#endif
+
+    qemu_bh_schedule(sdl_resize_bh);
+
+#ifdef SDL_THREAD
+    if (sdl_thread_initialized == 0) {
+        sdl_thread_initialized = 1;
+
+        INFO("sdl update thread create\n");
+
+        sdl_thread_exit = false;
+        qemu_thread_create(&sdl_thread, "sdl-workthread", run_qemu_update,
+            NULL, QEMU_THREAD_JOINABLE);
+    }
+#endif
+}
+
+void maru_sdl_pre_init(void) {
+    sdl_init_bh = qemu_bh_new(maru_sdl_init_bh, NULL);
+    sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL);
+    sdl_update_bh = qemu_bh_new(maru_sdl_update_bh, NULL);
+
+#ifdef SDL_THREAD
+    qemu_mutex_init(&sdl_mutex);
+    qemu_cond_init(&sdl_cond);
+#endif
+}
+
+void maru_sdl_init(uint64 swt_handle,
+    unsigned int display_width, unsigned int display_height,
+    bool blank_guide)
+{
+    gchar SDL_windowhack[32] = { 0, };
+    long window_id = swt_handle;
+    blank_guide_enable = blank_guide;
+
+    INFO("maru sdl init\n");
+
+    sprintf(SDL_windowhack, "%ld", window_id);
+    g_setenv("SDL_WINDOWID", SDL_windowhack, 1);
+
+    INFO("register SDL environment variable. "
+        "(SDL_WINDOWID = %s)\n", SDL_windowhack);
+
+    set_emul_resolution(display_width, display_height);
+    set_emul_sdl_bpp(SDL_BPP);
+    maru_sdl_interpolation(false);
+    init_multi_touch_state();
+
+    if (blank_guide_enable == true) {
+        INFO("blank guide is on\n");
+    }
+
+    qemu_bh_schedule(sdl_init_bh);
+}
+
+void maru_sdl_quit(void)
+{
+    INFO("maru sdl quit\n");
+
+    if (surface_guide != NULL) {
+        g_free(surface_guide->pixels);
+        SDL_FreeSurface(surface_guide);
+    }
+
+    /* remove multi-touch finger points */
+    cleanup_multi_touch_state();
+
+    if (sdl_init_bh != NULL) {
+        qemu_bh_delete(sdl_init_bh);
+    }
+    if (sdl_resize_bh != NULL) {
+        qemu_bh_delete(sdl_resize_bh);
+    }
+
+    sdl_alteration = -1;
+
+#ifdef SDL_THREAD
+    qemu_mutex_lock(&sdl_mutex);
+#endif
+
+    SDL_Quit();
+
+#ifdef SDL_THREAD
+    sdl_thread_exit = true;
+    qemu_cond_signal(&sdl_cond);
+    qemu_mutex_unlock(&sdl_mutex);
+
+    INFO("join SDL thread\n");
+    qemu_thread_join(&sdl_thread);
+
+    INFO("destroy cond and mutex of SDL thread\n");
+    qemu_cond_destroy(&sdl_cond);
+    qemu_mutex_destroy(&sdl_mutex);
+#endif
+}
+
+void maru_sdl_resize(void)
+{
+    INFO("maru sdl resize\n");
+
+    qemu_bh_schedule(sdl_resize_bh);
+}
+
+void maru_sdl_update(void)
+{
+    if (sdl_update_bh != NULL) {
+        qemu_bh_schedule(sdl_update_bh);
+    }
+}
+
+void maru_sdl_invalidate(bool on)
+{
+    sdl_invalidate = on;
+}
diff --git a/tizen/src/display/maru_sdl.h b/tizen/src/display/maru_sdl.h
new file mode 100644 (file)
index 0000000..342f4d2
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SDL_WINDOWID hack
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef MARU_SDL_H_
+#define MARU_SDL_H_
+
+#include <SDL.h>
+#include <SDL_syswm.h>
+#include "ui/console.h"
+
+extern DisplayChangeListenerOps maru_dcl_ops;
+
+void maru_sdl_pre_init(void);
+void maru_sdl_init(uint64 swt_handle,
+    unsigned int display_width, unsigned int display_height,
+    bool blank_guide);
+void maru_sdl_resize(void);
+void maru_sdl_update(void);
+void maru_sdl_invalidate(bool on);
+void maru_sdl_interpolation(bool on);
+void maru_sdl_quit(void);
+
+#endif /* MARU_SDL_H_ */
diff --git a/tizen/src/display/maru_sdl_processing.c b/tizen/src/display/maru_sdl_processing.c
new file mode 100644 (file)
index 0000000..4e28eb8
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * Image Processing
+ *
+ * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * SangHo Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#include "maru_sdl_processing.h"
+#include "hw/maru_brightness.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(tizen, sdl_processing);
+
+
+/* Image processing functions using the pixman library */
+void maru_do_pixman_dpy_surface(pixman_image_t *dst_image)
+{
+    /* apply the brightness level */
+    if (brightness_level < BRIGHTNESS_MAX) {
+        pixman_image_composite(PIXMAN_OP_OVER,
+                               brightness_image, NULL, dst_image,
+                               0, 0, 0, 0, 0, 0,
+                               pixman_image_get_width(dst_image),
+                               pixman_image_get_height(dst_image));
+    }
+}
+
+SDL_Surface *maru_do_pixman_scale(SDL_Surface *rz_src,
+                                  SDL_Surface *rz_dst,
+                                  pixman_filter_t filter)
+{
+    pixman_image_t *src = NULL;
+    pixman_image_t *dst = NULL;
+    double sx = 0;
+    double sy = 0;
+    pixman_transform_t matrix;
+    struct pixman_f_transform matrix_f;
+
+    SDL_LockSurface(rz_src);
+    SDL_LockSurface(rz_dst);
+
+    src = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+        rz_src->w, rz_src->h, rz_src->pixels, rz_src->w * 4);
+    dst = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+        rz_dst->w, rz_dst->h, rz_dst->pixels, rz_dst->w * 4);
+
+    sx = (double)rz_src->w / (double)rz_dst->w;
+    sy = (double)rz_src->h / (double)rz_dst->h;
+    pixman_f_transform_init_identity(&matrix_f);
+    pixman_f_transform_scale(&matrix_f, NULL, sx, sy);
+    pixman_transform_from_pixman_f_transform(&matrix, &matrix_f);
+    pixman_image_set_transform(src, &matrix);
+    pixman_image_set_filter(src, filter, NULL, 0);
+    pixman_image_composite(PIXMAN_OP_SRC, src, NULL, dst,
+                           0, 0, 0, 0, 0, 0,
+                           rz_dst->w, rz_dst->h);
+
+    pixman_image_unref(src);
+    pixman_image_unref(dst);
+
+    SDL_UnlockSurface(rz_src);
+    SDL_UnlockSurface(rz_dst);
+
+    return rz_dst;
+}
+
+SDL_Surface *maru_do_pixman_rotate(SDL_Surface *rz_src,
+                                   SDL_Surface *rz_dst,
+                                   int angle)
+{
+    pixman_image_t *src = NULL;
+    pixman_image_t *dst = NULL;
+    pixman_transform_t matrix;
+    struct pixman_f_transform matrix_f;
+
+    SDL_LockSurface(rz_src);
+    SDL_LockSurface(rz_dst);
+
+    src = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+        rz_src->w, rz_src->h, rz_src->pixels, rz_src->w * 4);
+    dst = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+        rz_dst->w, rz_dst->h, rz_dst->pixels, rz_dst->w * 4);
+
+    pixman_f_transform_init_identity(&matrix_f);
+    switch(angle) {
+        case 0:
+            pixman_f_transform_rotate(&matrix_f, NULL, 1.0, 0.0);
+            pixman_f_transform_translate(&matrix_f, NULL, 0.0, 0.0);
+            break;
+        case 90:
+            pixman_f_transform_rotate(&matrix_f, NULL, 0.0, 1.0);
+            pixman_f_transform_translate(&matrix_f, NULL,
+                                         (double)rz_dst->h, 0.0);
+            break;
+        case 180:
+            pixman_f_transform_rotate(&matrix_f, NULL, -1.0, 0.0);
+            pixman_f_transform_translate(&matrix_f, NULL,
+                                         (double)rz_dst->w, (double)rz_dst->h);
+            break;
+        case 270:
+            pixman_f_transform_rotate(&matrix_f, NULL, 0.0, -1.0);
+            pixman_f_transform_translate(&matrix_f, NULL,
+                                         0.0, (double)rz_dst->w);
+            break;
+        default:
+            ERR("Not supported angle factor (angle=%d)\n", angle);
+            break;
+    }
+    pixman_transform_from_pixman_f_transform(&matrix, &matrix_f);
+    pixman_image_set_transform(src, &matrix);
+    pixman_image_composite(PIXMAN_OP_SRC, src, NULL, dst,
+                           0, 0, 0, 0, 0, 0,
+                           rz_dst->w, rz_dst->h);
+
+    pixman_image_unref(src);
+    pixman_image_unref(dst);
+
+    SDL_UnlockSurface(rz_src);
+    SDL_UnlockSurface(rz_dst);
+
+    return rz_dst;
+}
+
+png_bytep read_png_file(const char *file_name,
+    unsigned int *width_out, unsigned int *height_out)
+{
+#define PNG_HEADER_SIZE 8
+
+    FILE *fp = NULL;
+    png_byte header[PNG_HEADER_SIZE] = { 0, };
+    png_structp png_ptr = NULL;
+
+    png_infop info_ptr = NULL;
+    png_uint_32 width = 0;
+    png_uint_32 height = 0;
+    png_byte channels = 0;
+    unsigned int stride = 0;
+    int bit_depth = 0;
+    int color_type = 0;
+    int i = 0;
+
+    png_bytep pixel_data = NULL;
+    png_bytepp row_ptr_data = NULL;
+
+    if (file_name == NULL) {
+        ERR("file name is empty\n");
+        return NULL;
+    }
+
+    fp = fopen(file_name, "rb");
+    if (fp == NULL) {
+        ERR("file %s could not be opened\n", file_name);
+        return NULL;
+    }
+
+    if (fread(header, sizeof(png_byte), PNG_HEADER_SIZE, fp) != PNG_HEADER_SIZE) {
+        ERR("failed to read header from png file\n");
+        fclose(fp);
+        return NULL;
+    }
+
+    if (png_sig_cmp(header, 0, PNG_HEADER_SIZE) != 0) {
+        ERR("file %s is not recognized as a PNG image\n", file_name);
+        fclose(fp);
+        return NULL;
+    }
+
+    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+    if (png_ptr == NULL) {
+        ERR("failed to allocate png read struct\n");
+        fclose(fp);
+        return NULL;
+    }
+
+    info_ptr = png_create_info_struct(png_ptr);
+    if (info_ptr == NULL) {
+        ERR("failed to allocate png info struct\n");
+        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+        fclose(fp);
+        return NULL;
+    }
+
+    if (setjmp(png_jmpbuf(png_ptr)) != 0) {
+        ERR("error during init_io\n");
+        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+        png_destroy_info_struct(png_ptr, &info_ptr);
+        fclose(fp);
+        return NULL;
+    }
+
+    png_init_io(png_ptr, fp);
+    png_set_sig_bytes(png_ptr, PNG_HEADER_SIZE);
+
+    /* read the PNG image information */
+    png_read_info(png_ptr, info_ptr);
+    png_get_IHDR(png_ptr, info_ptr,
+        &width, &height, &bit_depth, &color_type,
+        NULL, NULL, NULL);
+
+    channels = png_get_channels(png_ptr, info_ptr);
+    stride = width * bit_depth * channels / 8;
+
+    pixel_data = (png_bytep) g_malloc0(stride * height);
+    if (pixel_data == NULL) {
+        ERR("could not allocate data buffer for pixels\n");
+
+        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+        png_destroy_info_struct(png_ptr, &info_ptr);
+        fclose(fp);
+        return NULL;
+    }
+
+    row_ptr_data = (png_bytepp) g_malloc0(sizeof(png_bytep) * height);
+    if (row_ptr_data == NULL) {
+        ERR("could not allocate data buffer for row_ptr\n");
+
+        g_free(pixel_data);
+        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+        png_destroy_info_struct(png_ptr, &info_ptr);
+        fclose(fp);
+        return NULL;
+    }
+
+    switch(color_type) {
+        case PNG_COLOR_TYPE_PALETTE :
+            png_set_palette_to_rgb(png_ptr);
+            break;
+        case PNG_COLOR_TYPE_RGB :
+            if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+                /* transparency data for image */
+                png_set_tRNS_to_alpha(png_ptr);
+            } else {
+                png_set_filter(png_ptr, 0xff, PNG_FILLER_AFTER);
+            }
+            break;
+        case PNG_COLOR_TYPE_RGB_ALPHA :
+            break;
+        default :
+            INFO("png file has an unsupported color type\n");
+            break;
+    }
+
+    for (i = 0; i < height; i++) {
+        row_ptr_data[i] = pixel_data + (stride * i);
+    }
+
+    /* read the entire image into memory */
+    png_read_image(png_ptr, row_ptr_data);
+
+    /* image information */
+    INFO("=== blank guide image was loaded ===============\n");
+    INFO("file path : %s\n", file_name);
+    INFO("width : %d, height : %d, stride : %d\n",
+        width, height, stride);
+    INFO("color type : %d, channels : %d, bit depth : %d\n",
+        color_type, channels, bit_depth);
+    INFO("================================================\n");
+
+    if (width_out != NULL) {
+        *width_out = (unsigned int) width;
+    }
+    if (height_out != NULL) {
+        *height_out = (unsigned int) height;
+    }
+
+    g_free(row_ptr_data);
+    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+    png_destroy_info_struct(png_ptr, &info_ptr);
+    fclose(fp);
+
+    return pixel_data;
+}
+
+void draw_image(SDL_Surface *screen, SDL_Surface *image)
+{
+    if (screen == NULL || image == NULL) {
+        return;
+    }
+
+    int dst_x = 0; int dst_y = 0;
+    int dst_w = 0; int dst_h = 0;
+
+    int margin_w = screen->w - image->w;
+    int margin_h = screen->h - image->h;
+
+    if (margin_w < 0 || margin_h < 0) {
+        /* guide image scaling */
+        int margin = (margin_w < margin_h)? margin_w : margin_h;
+        dst_w = image->w + margin;
+        dst_h = image->h + margin;
+
+        SDL_Surface *scaled_image = SDL_CreateRGBSurface(
+                SDL_SWSURFACE, dst_w, dst_h,
+                image->format->BitsPerPixel,
+                image->format->Rmask, image->format->Gmask,
+                image->format->Bmask, image->format->Amask);
+
+        scaled_image = maru_do_pixman_scale(
+                image, scaled_image, PIXMAN_FILTER_BEST);
+
+        dst_x = (screen->w - dst_w) / 2;
+        dst_y = (screen->h - dst_h) / 2;
+        SDL_Rect dst_rect = { dst_x, dst_y, dst_w, dst_h };
+
+        SDL_BlitSurface(scaled_image, NULL, screen, &dst_rect);
+        SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+        SDL_FreeSurface(scaled_image);
+    } else {
+        dst_w = image->w;
+        dst_h = image->h;
+        dst_x = (screen->w - dst_w) / 2;
+        dst_y = (screen->h - dst_h) / 2;
+        SDL_Rect dst_rect = { dst_x, dst_y, dst_w, dst_h };
+
+        SDL_BlitSurface(image, NULL, screen, &dst_rect);
+        SDL_UpdateRect(screen, 0, 0, 0, 0);
+    }
+}
diff --git a/tizen/src/display/maru_sdl_processing.h b/tizen/src/display/maru_sdl_processing.h
new file mode 100644 (file)
index 0000000..ad7d320
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Image Processing
+ *
+ * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * SangHo Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef MARU_SDL_PROCESSING_H_
+#define MARU_SDL_PROCESSING_H_
+
+#include <SDL.h>
+#include <png.h>
+#include "ui/console.h"
+
+void maru_do_pixman_dpy_surface(pixman_image_t *dst);
+SDL_Surface *maru_do_pixman_scale(SDL_Surface *src, SDL_Surface *dst, pixman_filter_t filter);
+SDL_Surface *maru_do_pixman_rotate(SDL_Surface *src, SDL_Surface *dst, int angle);
+
+png_bytep read_png_file(const char *file_name,
+    unsigned int *width_out, unsigned int *height_out);
+void draw_image(SDL_Surface *screen, SDL_Surface *image);
+
+#endif /* MARU_SDL_PROCESSING_H_ */
diff --git a/tizen/src/display/maru_shm.c b/tizen/src/display/maru_shm.c
new file mode 100644 (file)
index 0000000..8c49cf2
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * Shared memory
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include "maru_shm.h"
+#include "emul_state.h"
+#include "hw/maru_brightness.h"
+#include "skin/maruskin_server.h"
+#include "debug_ch.h"
+#include "maru_err_table.h"
+
+MULTI_DEBUG_CHANNEL(tizen, maru_shm);
+
+static DisplaySurface *dpy_surface;
+static void *shared_memory = (void *) 0;
+static int skin_shmid;
+static bool is_fit_console_size;
+
+static int shm_skip_update;
+static int shm_skip_count;
+
+static bool blank_guide_enable;
+static int blank_cnt;
+#define MAX_BLANK_FRAME_CNT 10
+
+extern QemuMutex mutex_draw_display;
+extern int draw_display_state;
+
+//#define INFO_FRAME_DROP_RATE
+#ifdef INFO_FRAME_DROP_RATE
+static unsigned int draw_frame;
+static unsigned int drop_frame;
+#endif
+
+/* Image processing functions using the pixman library */
+static void maru_do_pixman_dpy_surface(pixman_image_t *dst_image)
+{
+    /* apply the brightness level */
+    if (brightness_level < BRIGHTNESS_MAX) {
+        pixman_image_composite(PIXMAN_OP_OVER,
+                               brightness_image, NULL, dst_image,
+                               0, 0, 0, 0, 0, 0,
+                               pixman_image_get_width(dst_image),
+                               pixman_image_get_height(dst_image));
+    }
+}
+
+static void qemu_ds_shm_update(DisplayChangeListener *dcl,
+                               int x, int y, int w, int h)
+{
+    if (shared_memory != NULL) {
+        qemu_mutex_lock(&mutex_draw_display);
+
+        if (draw_display_state == 0) {
+            draw_display_state = 1;
+
+            qemu_mutex_unlock(&mutex_draw_display);
+
+            if (is_fit_console_size == true) {
+                maru_do_pixman_dpy_surface(dpy_surface->image);
+
+                memcpy(shared_memory,
+                    surface_data(dpy_surface),
+                    surface_stride(dpy_surface) *
+                    surface_height(dpy_surface));
+            } else {
+                int shm_size =
+                   get_emul_resolution_width() * get_emul_resolution_height() * 4;
+                memset(shared_memory, 0x00, (size_t)shm_size);
+            }
+
+#ifdef INFO_FRAME_DROP_RATE
+            draw_frame++;
+#endif
+            notify_draw_frame();
+        } else {
+#ifdef INFO_FRAME_DROP_RATE
+            drop_frame++;
+#endif
+            qemu_mutex_unlock(&mutex_draw_display);
+        }
+
+#ifdef INFO_FRAME_DROP_RATE
+        INFO("! frame drop rate = (%d/%d)\n",
+             drop_frame, draw_frame + drop_frame);
+#endif
+    }
+}
+
+static void qemu_ds_shm_switch(DisplayChangeListener *dcl,
+                        struct DisplaySurface *new_surface)
+{
+    int console_width = 0, console_height = 0;
+
+    shm_skip_update = 0;
+    shm_skip_count = 0;
+
+    if (!new_surface) {
+        ERR("qemu_ds_shm_switch : new_surface is NULL\n");
+        return;
+    }
+
+    dpy_surface = new_surface;
+    console_width = surface_width(new_surface);
+    console_height = surface_height(new_surface);
+
+    INFO("qemu_ds_shm_switch : (%d, %d)\n",
+        console_width, console_height);
+
+    if (console_width == get_emul_resolution_width() &&
+        console_height == get_emul_resolution_height()) {
+        is_fit_console_size = true;
+    }
+}
+
+static void qemu_ds_shm_refresh(DisplayChangeListener *dcl)
+{
+    /* If the display is turned off,
+    the screen does not update until the it is turned on */
+    if (shm_skip_update && display_off) {
+        if (blank_cnt > MAX_BLANK_FRAME_CNT) {
+            /* do nothing */
+            return;
+        } else if (blank_cnt == MAX_BLANK_FRAME_CNT) {
+            if (blank_guide_enable == true) {
+                INFO("draw a blank guide image\n");
+
+                if (get_emul_skin_enable()) {
+                    /* draw guide image */
+                    notify_draw_blank_guide();
+                }
+            }
+        } else if (blank_cnt == 0) {
+            INFO("skipping of the display updating is started\n");
+        }
+
+        blank_cnt++;
+
+        return;
+    } else {
+        if (blank_cnt != 0) {
+            INFO("skipping of the display updating is ended\n");
+            blank_cnt = 0;
+        }
+    }
+
+    graphic_hw_update(NULL);
+
+    /* Usually, continuously updated.
+    But when the display is turned off,
+    ten more updates the surface for a black screen. */
+    if (display_off) {
+        if (++shm_skip_count > 10) {
+            shm_skip_update = 1;
+        } else {
+            shm_skip_update = 0;
+        }
+    } else {
+        shm_skip_count = 0;
+        shm_skip_update = 0;
+    }
+}
+
+DisplayChangeListenerOps maru_dcl_ops = {
+    .dpy_name          = "maru_shm",
+    .dpy_refresh       = qemu_ds_shm_refresh,
+    .dpy_gfx_update    = qemu_ds_shm_update,
+    .dpy_gfx_switch    = qemu_ds_shm_switch,
+};
+
+void maru_shm_init(uint64 swt_handle,
+    unsigned int display_width, unsigned int display_height,
+    bool blank_guide)
+{
+    blank_guide_enable = blank_guide;
+
+    INFO("maru shm init\n");
+
+    set_emul_resolution(display_width, display_height);
+    set_emul_sdl_bpp(32);
+
+    if (blank_guide_enable == true) {
+        INFO("blank guide is on\n");
+    }
+
+    /* byte */
+    int shm_size =
+        get_emul_resolution_width() * get_emul_resolution_height() * 4;
+
+    /* base + 1 = sdb port */
+    /* base + 2 = shared memory key */
+    int mykey = get_emul_vm_base_port() + 2;
+
+    INFO("shared memory key: %d, size: %d bytes\n", mykey, shm_size);
+
+    /* make a shared framebuffer */
+    skin_shmid = shmget((key_t)mykey, (size_t)shm_size, 0666 | IPC_CREAT);
+    if (skin_shmid == -1) {
+        ERR("shmget failed\n");
+        perror("maru_vga: ");
+
+        maru_register_exit_msg(MARU_EXIT_UNKNOWN,
+            (char*) "Cannot launch this VM.\n"
+            "Failed to get identifier of the shared memory segment.");
+        exit(1);
+    }
+
+    shared_memory = shmat(skin_shmid, (void*)0, 0);
+    if (shared_memory == (void *)-1) {
+        ERR("shmat failed\n");
+        perror("maru_vga: ");
+
+        maru_register_exit_msg(MARU_EXIT_UNKNOWN,
+            (char*) "Cannot launch this VM.\n"
+            "Failed to attach the shared memory segment.");
+        exit(1);
+    }
+
+    /* default screen */
+    memset(shared_memory, 0x00, (size_t)shm_size);
+    INFO("Memory attached at 0x%X\n", (int)shared_memory);
+}
+
+void maru_shm_quit(void)
+{
+    struct shmid_ds shm_info;
+
+    INFO("maru shm quit\n");
+
+    if (shmctl(skin_shmid, IPC_STAT, &shm_info) == -1) {
+        ERR("shmctl failed\n");
+        shm_info.shm_nattch = -1;
+    }
+
+    if (shmdt(shared_memory) == -1) {
+        ERR("shmdt failed\n");
+        perror("maru_vga: ");
+        return;
+    }
+    shared_memory = NULL;
+
+    if (shm_info.shm_nattch == 1) {
+        /* remove */
+        if (shmctl(skin_shmid, IPC_RMID, 0) == -1) {
+            INFO("segment was already removed\n");
+            perror("maru_vga: ");
+        } else {
+            INFO("shared memory was removed\n");
+        }
+    } else if (shm_info.shm_nattch != -1) {
+        INFO("number of current attaches = %d\n",
+            (int)shm_info.shm_nattch);
+    }
+}
+
+void maru_shm_resize(void)
+{
+    shm_skip_update = 0;
+}
diff --git a/tizen/src/display/maru_shm.h b/tizen/src/display/maru_shm.h
new file mode 100644 (file)
index 0000000..d24b1b6
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Shared memory
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef MARU_SHM_H_
+#define MARU_SHM_H_
+
+#include "ui/console.h"
+
+extern DisplayChangeListenerOps maru_dcl_ops;
+
+void maru_shm_init(uint64 swt_handle,
+    unsigned int display_width, unsigned int display_height,
+    bool blank_guide);
+void maru_shm_resize(void);
+void maru_shm_quit(void);
+
+#endif /* MARU_SHM_H_ */
diff --git a/tizen/src/ecs/Makefile.objs b/tizen/src/ecs/Makefile.objs
new file mode 100644 (file)
index 0000000..6f68dfb
--- /dev/null
@@ -0,0 +1,4 @@
+obj-y += genmsg/ecs.pb-c.o genmsg/ecs_ids.pb-c.o ../../distrib/protobuf/protobuf-c.o
+obj-y += ecs_msg.o ecs.o ecs_sensor.o
+obj-y += ecs_mon.o ecs-json-streamer.o
+obj-y += ecs_tethering.o
diff --git a/tizen/src/ecs/Makefile.tizen b/tizen/src/ecs/Makefile.tizen
deleted file mode 100644 (file)
index 0d1a74f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# ECS Makefile.tizen
-
-$(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/tizen/src/ecs:$(SRC_PATH)/tizen/src/ecs/genmsg:$(SRC_PATH)/tizen/distrib/protobuf)
-
-QEMU_CFLAGS += -I$(SRC_PATH)/tizen/distrib/protobuf
-QEMU_CFLAGS += -I$(SRC_PATH)/tizen/src/ecs/genmsg
-
-obj-y += ecs.pb-c.o ecs_ids.pb-c.o protobuf-c.o
-obj-y += ecs_msg.o ecs.o ecs_sensor.o
-obj-y += ecs_mon.o ecs-json-streamer.o
-obj-y += ecs_tethering.o
index 27b94a1e3c75f7639d634307887101efa22acabc..ee7c3baa84d55599485c5f942723702e85bd7e04 100644 (file)
@@ -46,7 +46,7 @@
 #include "qapi/qmp/qint.h"
 
 #include "emulator.h"
-#include "sdb.h"
+#include "util/sdb.h"
 #include "ecs.h"
 #include "guest_server.h"
 #include "emul_state.h"
index 1dfd862354a55fdaf2c874da63ac00774438e75b..2f70c463bbe00ced2bc82d59e6dc69d5a090ed1f 100644 (file)
@@ -40,7 +40,6 @@
 #include "ecs-json-streamer.h"
 #include "genmsg/ecs.pb-c.h"
 #include "genmsg/ecs_ids.pb-c.h"
-#include "../osutil.h"
 
 #define ECS_VERSION   "1.0"
 
index 10bd171b6189c5639249056084c88d194b72d4b3..227cab975dd0f2c93b346d0eda6cfd1dcec9f2e3 100644 (file)
 #include <stdbool.h>
 #include <glib.h>
 
+#ifdef CONFIG_LINUX
+#include <sys/epoll.h>
+#endif
+
 #include "hw/qdev.h"
 #include "net/net.h"
 #include "net/slirp.h"
 #include "qemu/option.h"
 #include "sysemu/char.h"
 #include "qemu/main-loop.h"
-
-#ifdef CONFIG_LINUX
-#include <sys/epoll.h>
-#endif
-
 #include "qemu-common.h"
-#include "sdb.h"
+#include "util/sdb.h"
 #include "ecs-json-streamer.h"
 #include "qmp-commands.h"
 
 #include "ecs.h"
 #include "mloop_event.h"
 #ifndef CONFIG_USE_SHM
-#include "maru_finger.h"
+#include "display/maru_finger.h"
 #endif
 
 #include "hw/maru_virtio_evdi.h"
index defb4e635cc0780c3412a66d84b97153c7eab41e..0b588b28e73cc214a9c3c9d7895ada670d00c540 100644 (file)
@@ -31,9 +31,9 @@
 
 #include "ecs.h"
 #include "ecs_tethering.h"
-#include "../tethering/app_tethering.h"
-#include "../hw/maru_virtio_touchscreen.h"
-#include "../debug_ch.h"
+#include "tethering/app_tethering.h"
+#include "hw/maru_virtio_touchscreen.h"
+#include "debug_ch.h"
 
 MULTI_DEBUG_CHANNEL(tizen, ecs_tethering);
 
index c2755221984888fb3f2ef078e9f754998984c737..5dc74daf3cd2b2a137c96ad9889edfba1af5aaa3 100644 (file)
@@ -35,7 +35,7 @@
 
 
 #include "maru_common.h"
-#include "maru_finger.h"
+#include "display/maru_finger.h"
 
 enum {
     RESET = 0,
index 01098156cbf32b754d3d6ae584863f420dd713d0..b921ec8a09e111d5d5a9fc5273fb188adf6286f7 100644 (file)
 #include "emul_state.h"
 #include "guest_server.h"
 #include "emulator_options.h"
-#include "check_gl.h"
+#include "util/check_gl.h"
 #include "maru_err_table.h"
 #include "mloop_event.h"
-#include "osutil.h"
-#include "sdb.h"
+#include "util/osutil.h"
+#include "util/sdb.h"
 #include "skin/maruskin_server.h"
 #include "debug_ch.h"
 #include "ecs/ecs.h"
index e8304eb9f5ef9b1e8d613b044f45d072cf18c782..f305866b012a045b1a6464814f6b9a99855e7dda 100644 (file)
 #include "guest_debug.h"
 #include "guest_server.h"
 #include "hw/maru_virtio_touchscreen.h"
-#include "check_gl.h"
+#include "util/check_gl.h"
 #include "maru_err_table.h"
-#include "maru_display.h"
+#include "display/maru_display.h"
 #include "mloop_event.h"
-#include "osutil.h"
-#include "sdb.h"
+#include "util/osutil.h"
+#include "util/sdb.h"
 #include "skin/maruskin_server.h"
 #include "debug_ch.h"
 #include "ecs/ecs.h"
index 6306637efb2e47a81fe46f94ba6f99de15f2d0bb..97ebe4d0a33b2f25eb377720e540f3ef285d001d 100644 (file)
@@ -50,7 +50,7 @@
 #include "mloop_event.h"
 #include "skin/maruskin_server.h"
 #include "debug_ch.h"
-#include "sdb.h"
+#include "util/sdb.h"
 #include "maru_common.h"
 #include "hw/maru_virtio_hwkey.h"
 #include "hw/maru_pm.h"
diff --git a/tizen/src/hw/Makefile.objs b/tizen/src/hw/Makefile.objs
new file mode 100644 (file)
index 0000000..547da02
--- /dev/null
@@ -0,0 +1,34 @@
+obj-y += maru_board.o maru_pm.o
+
+obj-y += maru_brill_codec.o
+obj-y += maru_brightness.o
+obj-y += maru_virtio_touchscreen.o
+obj-y += maru_virtio_esm.o
+obj-y += maru_virtio_evdi.o
+obj-y += maru_virtio_hwkey.o
+obj-y += maru_virtio_jack.o
+obj-y += maru_virtio_keyboard.o
+obj-y += maru_virtio_nfc.o
+obj-y += maru_virtio_power.o
+obj-y += maru_virtio_sensor.o
+obj-y += maru_virtio_vmodem.o
+
+obj-y += maru_camera_common_pci.o
+ifdef CONFIG_LINUX
+obj-y += maru_camera_linux_pci.o
+LIBS += -lv4l2 -lv4lconvert
+endif
+ifdef CONFIG_WIN32
+obj-y += maru_camera_win32_pci.o
+LIBS += -lole32 -loleaut32 -luuid -lstrmiids
+endif
+ifdef CONFIG_DARWIN
+obj-y += maru_camera_darwin_converter.o
+obj-y += maru_camera_darwin_pci.o
+QEMU_CFLAGS += -framework Foundation -framework SystemConfiguration
+QEMU_CFLAGS += -framework Cocoa -framework QTKit -framework CoreVideo
+QEMU_CFLAGS += -framework AppKit
+endif
+
+#obj-y += maru_codec.o
+#obj-y += maru_usb_touchscreen.o
diff --git a/tizen/src/hw/Makefile.objs.arm b/tizen/src/hw/Makefile.objs.arm
new file mode 100644 (file)
index 0000000..f216625
--- /dev/null
@@ -0,0 +1,8 @@
+obj-y += maru_arm_soc.o
+
+ifndef  CONFIG_DARWIN
+obj-y += maru_arm_board.o
+endif
+
+obj-y += maru_arm_vpci.o
+obj-y += maru_arm_pmu.o
index 6a4eb9a87aa6f0f45be426227f2fa3dfd81d636a..dae753425477d67fcfcccae9649039a28b3c6eb4 100644 (file)
@@ -30,7 +30,7 @@
 #include "maru_arm.h"
 #include "i2c.h"
 #include "exec-memory.h"
-#include "../tizen/src/hw/maru_brightness.h"
+#include "hw/maru_brightness.h"
 #include "arch_init.h"
 
 #include "xen.h"
index b7130cbcbcf7db55c0bb5b08ea1874ba0b67af2f..5a0cc6d2c079f02d2496755c08e15b5cd97aa353 100644 (file)
@@ -39,8 +39,8 @@
 #include "qemu-common.h"
 #include "qemu/thread.h"
 
-#include "osutil.h"
-#include "tizen/src/debug_ch.h"
+#include "util/osutil.h"
+#include "debug_ch.h"
 #include "maru_device_ids.h"
 
 #include "libavformat/avformat.h"
index 2845e261792b8ed1f4156406a60d0c40f0867903..f3f21514bbe1828e883ff6bfe90c64907e1a0aaa 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "maru_camera_common.h"
 #include "maru_device_ids.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 
 MULTI_DEBUG_CHANNEL(tizen, maru-camera);
 
index 7105e663d449941c36983ed9ae07349224255765..24c560f48fadecba38dcb97df91cea08a96fc46d 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "qemu-common.h"
 #include "maru_camera_darwin.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 
 MULTI_DEBUG_CHANNEL(tizen, camera_darwin);
 
index bb7fa230813fa13b3e296c6a8458abccb0caf161..d90b490952768c9c5771baf5d85acd5ae0c78734 100644 (file)
@@ -36,7 +36,7 @@
 #include "qemu-common.h"
 #include "maru_camera_common.h"
 #include "maru_camera_darwin.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 
 MULTI_DEBUG_CHANNEL(tizen, maru-camera);
 
index adcee1e2f35f1f5546a2306a632aa8dc9b8ffa28..c4e13403b595314f2f8a8f00a4a48af4d8032ac1 100644 (file)
@@ -30,7 +30,7 @@
 #include "qemu-common.h"
 #include "sysemu/kvm.h"
 #include "maru_camera_common.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 
 #include <linux/videodev2.h>
 
index 10fb0f331deb4a39f56d30347c92da23fd15e527..60ae64831e7b9e2875c772bc4520ac01ceedae19 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "qemu-common.h"
 #include "maru_camera_common.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 
 #define CINTERFACE
 #define COBJMACROS
index d13d13d39a029ec3f57a6da12d25dfe86df41901..999d232a63c4d6609065116327919296c2807135 100644 (file)
@@ -35,7 +35,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_ids.h"
 #include "qemu/thread.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 #include "maru_device_ids.h"
 
 #include <libavformat/avformat.h>
index 71da1b2ca1374dea41f1a96638c9d6bfe8f02f52..b04c6868b4d3931f5c161787597dd31cdf742154 100644 (file)
@@ -31,7 +31,7 @@
 #include "maru_device_ids.h"
 #include "maru_virtio_evdi.h"
 #include "debug_ch.h"
-#include "../ecs/ecs.h"
+#include "ecs/ecs.h"
 
 MULTI_DEBUG_CHANNEL(qemu, virtio-evdi);
 
index 5d9b5b6a225ae54b11b88dbd46f07b0e851daaee..341b6f930d48556c36f3383ea7ce2984edaf676f 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "maru_device_ids.h"
 #include "maru_virtio_keyboard.h"
-#include "tizen/src/debug_ch.h"
+#include "debug_ch.h"
 
 
 MULTI_DEBUG_CHANNEL(qemu, virtio-kbd);
index 83fdae3b52cecac819b78127a240d0af04395d24..2afafef67b35e801782b9495d2789719a2bbedc0 100644 (file)
@@ -31,7 +31,7 @@
 #include "maru_device_ids.h"
 #include "maru_virtio_nfc.h"
 #include "debug_ch.h"
-#include "../ecs/ecs.h"
+#include "ecs/ecs.h"
 
 MULTI_DEBUG_CHANNEL(qemu, virtio-nfc);
 
index 10db96c94a54f132eec131234852d44a4187bd63..5627433d2cb7a9906f31ec67bc39b25ecc1f39fd 100644 (file)
@@ -34,7 +34,7 @@
 #include "maru_device_ids.h"
 #include "maru_virtio_sensor.h"
 #include "debug_ch.h"
-#include "../ecs/ecs.h"
+#include "ecs/ecs.h"
 
 MULTI_DEBUG_CHANNEL(qemu, virtio-sensor);
 
index dd93d06a044a80ac035067fcdccb9c7f98eaa22a..bb4e4d538b775fc7b49996d2e79502370160c6cb 100644 (file)
@@ -32,7 +32,7 @@
 #include "maru_virtio_vmodem.h"
 #include "maru_virtio_evdi.h"
 #include "debug_ch.h"
-#include "../ecs/ecs.h"
+#include "ecs/ecs.h"
 
 MULTI_DEBUG_CHANNEL(qemu, virtio-vmodem);
 
diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c
deleted file mode 100644 (file)
index b00f144..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * MARU display driver
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#include "emulator.h"
-#include "maru_common.h"
-#include "maru_display.h"
-#include "debug_ch.h"
-
-#ifndef CONFIG_USE_SHM
-#include "maru_sdl.h"
-#else
-#include "maru_shm.h"
-#endif
-
-MULTI_DEBUG_CHANNEL(tizen, display);
-
-MaruScreenShot* screenshot = NULL;
-
-static void maru_display_fini(void)
-{
-    INFO("fini qemu display\n");
-
-    g_free(screenshot);
-
-#ifndef CONFIG_USE_SHM
-    maru_sdl_quit();
-#else
-    maru_shm_quit();
-#endif
-}
-
-static void maru_display_notify_exit(Notifier *notifier, void *data) {
-    maru_display_fini();
-}
-static Notifier maru_display_exit = { .notify = maru_display_notify_exit };
-
-//TODO: interface
-void maru_display_init(DisplayState *ds)
-{
-    INFO("init qemu display\n");
-
-#ifndef CONFIG_USE_SHM
-    maru_sdl_pre_init();
-#else
-    /* do nothing */
-#endif
-
-    /*  graphics context information */
-    DisplayChangeListener *dcl;
-
-    dcl = g_malloc0(sizeof(DisplayChangeListener));
-    dcl->ops = &maru_dcl_ops;
-    register_displaychangelistener(dcl);
-
-    screenshot = g_malloc0(sizeof(MaruScreenShot));
-    screenshot->pixels = NULL;
-    screenshot->request = false;
-    screenshot->ready = false;
-
-    emulator_add_exit_notifier(&maru_display_exit);
-}
-
-void maru_display_resize(void)
-{
-#ifndef CONFIG_USE_SHM
-    maru_sdl_resize();
-#else
-    maru_shm_resize();
-#endif
-}
-
-void maru_display_update(void)
-{
-#ifndef CONFIG_USE_SHM
-    maru_sdl_update();
-#else
-    /* do nothing */
-#endif
-}
-
-void maru_display_invalidate(bool on)
-{
-#ifndef CONFIG_USE_SHM
-    maru_sdl_invalidate(on);
-#else
-    /* do nothing */
-#endif
-}
-
-void maru_display_interpolation(bool on)
-{
-#ifndef CONFIG_USE_SHM
-    maru_sdl_interpolation(on);
-#else
-    /* do nothing */
-#endif
-}
-
-void maru_ds_surface_init(uint64 swt_handle,
-    unsigned int display_width, unsigned int display_height,
-    bool blank_guide)
-{
-#ifndef CONFIG_USE_SHM
-    maru_sdl_init(swt_handle,
-        display_width, display_height, blank_guide);
-#else
-    maru_shm_init(swt_handle,
-        display_width, display_height, blank_guide);
-#endif
-}
-
-MaruScreenShot *get_screenshot(void)
-{
-    return screenshot;
-}
-
-/* save_screenshot() implemented in maruskin_operation.c */
diff --git a/tizen/src/maru_display.h b/tizen/src/maru_display.h
deleted file mode 100644 (file)
index c9c4552..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * MARU display driver
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#ifndef __MARU_DISPLAY_H__
-#define __MARU_DISPLAY_H__
-
-#include "ui/console.h"
-
-typedef struct MaruScreenShot {
-    unsigned char *pixels;
-    bool request;
-    bool ready;
-} MaruScreenShot;
-
-void maru_display_init(DisplayState *ds);
-void maru_display_resize(void);
-void maru_display_update(void);
-void maru_display_invalidate(bool on);
-void maru_display_interpolation(bool on);
-void maru_ds_surface_init(uint64 swt_handle,
-    unsigned int display_width, unsigned int display_height,
-    bool blank_guide);
-
-MaruScreenShot *get_screenshot(void);
-void save_screenshot(DisplaySurface *surface);
-
-#endif /* __MARU_DISPLAY_H__ */
diff --git a/tizen/src/maru_finger.c b/tizen/src/maru_finger.c
deleted file mode 100644 (file)
index b97a71e..0000000
+++ /dev/null
@@ -1,589 +0,0 @@
-/*
- * Multi-touch processing
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#include <math.h>
-#include <glib.h>
-#include <SDL.h>
-#include "maru_finger.h"
-#include "emul_state.h"
-#include "hw/maru_virtio_touchscreen.h"
-#include "debug_ch.h"
-
-MULTI_DEBUG_CHANNEL(qemu, maru_finger);
-
-
-/* ===== Reference: http://content.gpwiki.org/index.php/SDL:Tutorials:Drawing_and_Filling_Circles ===== */
-
-/*
-* This is a 32-bit pixel function created with help from this
-* website: http://www.libsdl.org/intro.en/usingvideo.html
-*
-* You will need to make changes if you want it to work with
-* 8-, 16- or 24-bit surfaces.  Consult the above website for
-* more information.
-*/
-static void sdl_set_pixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
-{
-   Uint8 *target_pixel = (Uint8 *)surface->pixels + y * surface->pitch + x * 4;
-   *(Uint32 *)target_pixel = pixel;
-}
-
-/*
-* This is an implementation of the Midpoint Circle Algorithm
-* found on Wikipedia at the following link:
-*
-*   http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
-*
-* The algorithm elegantly draws a circle quickly, using a
-* set_pixel function for clarity.
-*/
-static void sdl_draw_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel)
-{
-   int error = -radius;
-   int x = radius;
-   int y = 0;
-
-   while (x >= y) {
-       sdl_set_pixel(surface, cx + x, cy + y, pixel);
-       sdl_set_pixel(surface, cx + y, cy + x, pixel);
-
-       if (x != 0) {
-           sdl_set_pixel(surface, cx - x, cy + y, pixel);
-           sdl_set_pixel(surface, cx + y, cy - x, pixel);
-       }
-
-       if (y != 0) {
-           sdl_set_pixel(surface, cx + x, cy - y, pixel);
-           sdl_set_pixel(surface, cx - y, cy + x, pixel);
-       }
-
-       if (x != 0 && y != 0) {
-           sdl_set_pixel(surface, cx - x, cy - y, pixel);
-           sdl_set_pixel(surface, cx - y, cy - x, pixel);
-       }
-
-       error += y;
-       ++y;
-       error += y;
-
-       if (error >= 0) {
-           --x;
-           error -= x;
-           error -= x;
-       }
-   }
-}
-
-/*
-* SDL_Surface 32-bit circle-fill algorithm without using trig
-*
-* While I humbly call this "Celdecea's Method", odds are that the
-* procedure has already been documented somewhere long ago.  All of
-* the circle-fill examples I came across utilized trig functions or
-* scanning neighbor pixels.  This algorithm identifies the width of
-* a semi-circle at each pixel height and draws a scan-line covering
-* that width.
-*
-* The code is not optimized but very fast, owing to the fact that it
-* alters pixels in the provided surface directly rather than through
-* function calls.
-*
-* WARNING:  This function does not lock surfaces before altering, so
-* use SDL_LockSurface in any release situation.
-*/
-static void sdl_fill_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel)
-{
-   /* Note that there is more to altering the bitrate of this
-   * method than just changing this value.  See how pixels are
-   * altered at the following web page for tips:
-   *   http://www.libsdl.org/intro.en/usingvideo.html */
-
-   const int bpp = 4;
-   double dy;
-
-   double r = (double)radius;
-
-   for (dy = 1; dy <= r; dy += 1.0)
-   {
-       /* This loop is unrolled a bit, only iterating through half of the
-       * height of the circle.  The result is used to draw a scan line and
-       * its mirror image below it.
-       * The following formula has been simplified from our original.  We
-       * are using half of the width of the circle because we are provided
-       * with a center and we need left/right coordinates. */
-
-       double dx = floor(sqrt((2.0 * r * dy) - (dy * dy)));
-       int x = cx - dx;
-
-       /* Grab a pointer to the left-most pixel for each half of the circle */
-       Uint8 *target_pixel_a = (Uint8 *)surface->pixels +
-           ((int)(cy + r - dy)) * surface->pitch + x * bpp;
-
-       Uint8 *target_pixel_b = (Uint8 *)surface->pixels +
-            ((int)(cy - r + dy)) * surface->pitch + x * bpp;
-
-       for ( ; x <= cx + dx; x++)
-       {
-           *(Uint32 *)target_pixel_a = pixel;
-           *(Uint32 *)target_pixel_b = pixel;
-           target_pixel_a += bpp;
-           target_pixel_b += bpp;
-       }
-   }
-}
-
-/* ==================================================================================================== */
-
-
-void init_multi_touch_state(void)
-{
-    int i;
-    MultiTouchState* mts = get_emul_multi_touch_state();
-    FingerPoint *finger = NULL;
-
-    INFO("multi-touch state initialization\n");
-
-    mts->multitouch_enable = 0;
-
-    mts->finger_cnt_max = get_emul_max_touch_point();
-    if (mts->finger_cnt_max > MAX_FINGER_CNT) {
-        mts->finger_cnt_max = MAX_FINGER_CNT;
-        set_emul_max_touch_point(mts->finger_cnt_max);
-    }
-    INFO("maxTouchPoint : %d\n", get_emul_max_touch_point());
-
-    mts->finger_cnt = 0;
-
-    if (mts->finger_slot != NULL) {
-        g_free(mts->finger_slot);
-        mts->finger_slot = NULL;
-    }
-    mts->finger_slot =
-        (FingerPoint *) g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max);
-
-    for (i = 0; i < mts->finger_cnt_max; i++) {
-        finger = get_finger_point_from_slot(i);
-        if (finger != NULL) {
-            finger->origin_x = finger->origin_y = -1;
-            finger->x = finger->y = -1;
-        }
-    }
-
-    mts->finger_point_size = DEFAULT_FINGER_POINT_SIZE;
-    int finger_point_size_half = mts->finger_point_size / 2;
-    mts->finger_point_color = DEFAULT_FINGER_POINT_COLOR;
-    mts->finger_point_outline_color = DEFAULT_FINGER_POINT_OUTLINE_COLOR;
-
-    /* create finger point surface */
-    Uint32 rmask, gmask, bmask, amask;
-#ifdef HOST_WORDS_BIGENDIAN
-    rmask = 0xff000000;
-    gmask = 0x00ff0000;
-    bmask = 0x0000ff00;
-    amask = 0x000000ff;
-#else
-    rmask = 0x000000ff;
-    gmask = 0x0000ff00;
-    bmask = 0x00ff0000;
-    amask = 0xff000000;
-#endif
-
-    SDL_Surface *point = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_HWSURFACE,
-        mts->finger_point_size + 2, mts->finger_point_size + 2,
-        get_emul_sdl_bpp(), rmask, gmask, bmask, amask);
-
-    /* finger point circle */
-    sdl_fill_circle(point, finger_point_size_half, finger_point_size_half,
-        finger_point_size_half, mts->finger_point_color);
-
-    /* finger point circle outline */
-    sdl_draw_circle(point, finger_point_size_half, finger_point_size_half,
-        finger_point_size_half, mts->finger_point_outline_color);
-
-    mts->finger_point_surface = (void *)point;
-}
-
-void set_multi_touch_enable(int enable)
-{
-    get_emul_multi_touch_state()->multitouch_enable = enable;
-}
-
-int get_multi_touch_enable(void)
-{
-    return get_emul_multi_touch_state()->multitouch_enable;
-}
-
-int add_finger_point(int origin_x, int origin_y, int x, int y)
-{
-    MultiTouchState *mts = get_emul_multi_touch_state();
-
-    if (mts->finger_cnt == mts->finger_cnt_max) {
-        WARN("support multi-touch up to %d fingers\n", mts->finger_cnt_max);
-        return -1;
-    }
-
-    mts->finger_cnt += 1;
-
-    mts->finger_slot[mts->finger_cnt - 1].id = mts->finger_cnt;
-    mts->finger_slot[mts->finger_cnt - 1].origin_x = origin_x;
-    mts->finger_slot[mts->finger_cnt - 1].origin_y = origin_y;
-    mts->finger_slot[mts->finger_cnt - 1].x = x;
-    mts->finger_slot[mts->finger_cnt - 1].y = y;
-
-    INFO("%d finger touching\n", mts->finger_cnt);
-
-    return mts->finger_cnt;
-}
-
-FingerPoint *get_finger_point_from_slot(int index)
-{
-    MultiTouchState *mts = get_emul_multi_touch_state();
-
-    if (index < 0 || index > mts->finger_cnt_max) {
-        return NULL;
-    }
-
-    return &(mts->finger_slot[index]);
-}
-
-FingerPoint *get_finger_point_search(int x, int y)
-{
-    int i;
-    MultiTouchState *mts = get_emul_multi_touch_state();
-    FingerPoint *finger = NULL;
-    int finger_region = (mts->finger_point_size / 2) +
-        2 + (int)((1 - get_emul_win_scale()) * 4);
-
-    for (i = mts->finger_cnt - 1; i >= 0; i--) {
-        finger = get_finger_point_from_slot(i);
-
-        if (finger != NULL) {
-            if (x >= (finger->x - finger_region) &&
-                x < (finger->x + finger_region) &&
-                y >= (finger->y - finger_region) &&
-                y < (finger->y + finger_region)) {
-                    return finger;
-            }
-        }
-    }
-
-    return NULL;
-}
-
-
-static int _grab_finger_id = 0;
-#define QEMU_MOUSE_PRESSED 1
-#define QEMU_MOUSE_RELEASEED 0
-
-void maru_finger_processing_1(
-    int touch_type, int origin_x, int origin_y, int x, int y)
-{
-    MultiTouchState *mts = get_emul_multi_touch_state();
-    FingerPoint *finger = NULL;
-
-    if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */
-        if (_grab_finger_id > 0) {
-            finger = get_finger_point_from_slot(_grab_finger_id - 1);
-            if (finger != NULL) {
-                finger->origin_x = origin_x;
-                finger->origin_y = origin_y;
-                finger->x = x;
-                finger->y = y;
-
-                if (finger->id != 0) {
-                    virtio_touchscreen_event(x, y,
-                        _grab_finger_id - 1, QEMU_MOUSE_PRESSED);
-                    TRACE("id %d finger multi-touch dragging : (%d, %d)\n",
-                        _grab_finger_id, x, y);
-                }
-            }
-            return;
-        }
-
-        if (mts->finger_cnt == 0)
-        { /* first finger touch input */
-
-            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
-                return;
-            }
-
-            virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED);
-        }
-        else if ((finger = get_finger_point_search(x, y)) != NULL)
-        { /* check the position of previous touch event */
-
-            /* finger point is selected */
-            _grab_finger_id = finger->id;
-            TRACE("id %d finger is grabbed\n", _grab_finger_id);
-        }
-        else if (mts->finger_cnt == mts->finger_cnt_max)
-        { /* Let's assume that this event is last finger touch input */
-
-            finger = get_finger_point_from_slot(mts->finger_cnt_max - 1);
-            if (finger != NULL) {
-#if 1 /* send release event?? */
-                virtio_touchscreen_event(finger->x, finger->y,
-                    mts->finger_cnt_max - 1, QEMU_MOUSE_RELEASEED);
-#endif
-
-                finger->origin_x = origin_x;
-                finger->origin_y = origin_y;
-                finger->x = x;
-                finger->y = y;
-                if (finger->id != 0) {
-                    virtio_touchscreen_event(x, y,
-                        mts->finger_cnt_max - 1, QEMU_MOUSE_PRESSED);
-                }
-            }
-        }
-        else /* one more finger */
-        {
-            add_finger_point(origin_x, origin_y, x, y);
-            virtio_touchscreen_event(x, y,
-                mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
-        }
-
-    } else if (touch_type == MOUSE_UP) { /* released */
-        _grab_finger_id = 0;
-    }
-}
-
-void maru_finger_processing_2(
-    int touch_type, int origin_x, int origin_y, int x, int y)
-{
-    MultiTouchState *mts = get_emul_multi_touch_state();
-    FingerPoint *finger = NULL;
-
-    if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */
-        if (_grab_finger_id > 0) {
-            finger = get_finger_point_from_slot(_grab_finger_id - 1);
-            if (finger != NULL) {
-                int origin_distance_x = origin_x - finger->origin_x;
-                int origin_distance_y = origin_y - finger->origin_y;
-                int distance_x = x - finger->x;
-                int distance_y = y - finger->y;
-
-                int current_screen_w = get_emul_resolution_width();
-                int current_screen_h = get_emul_resolution_height();
-                int temp_finger_x, temp_finger_y;
-
-                int i = 0;
-
-                /* bounds checking */
-                for(i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) {
-                    finger = get_finger_point_from_slot(i);
-                    if (finger == NULL) {
-                        continue;
-                    }
-
-                    temp_finger_x = finger->x + distance_x;
-                    temp_finger_y = finger->y + distance_y;
-
-                    if (temp_finger_x > current_screen_w || temp_finger_x < 0
-                        || temp_finger_y > current_screen_h || temp_finger_y < 0) {
-                        TRACE("id %d finger is out of bounds (%d, %d)\n",
-                            i + 1, temp_finger_x, temp_finger_y);
-                        return;
-                    }
-                }
-
-                for(i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) {
-                    finger = get_finger_point_from_slot(i);
-                    if (finger == NULL) {
-                        continue;
-                    }
-
-                    finger->origin_x += origin_distance_x;
-                    finger->origin_y += origin_distance_y;
-                    finger->x += distance_x;
-                    finger->y += distance_y;
-
-                    if (finger->id != 0) {
-                        virtio_touchscreen_event(finger->x, finger->y,
-                            i, QEMU_MOUSE_PRESSED);
-                        TRACE("id %d finger multi-touch dragging = (%d, %d)\n",
-                            i + 1, finger->x, finger->y);
-                    }
-#ifdef _WIN32
-                    Sleep(2);
-#else
-                    usleep(2000);
-#endif
-
-                }
-            }
-
-            return;
-        }
-
-        if (mts->finger_cnt == 0)
-        { /* first finger touch input */
-
-            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
-                return;
-            }
-
-            virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED);
-        }
-        else if ((finger = get_finger_point_search(x, y)) != NULL)
-        { /* check the position of previous touch event */
-
-            /* finger point is selected */
-            _grab_finger_id = finger->id;
-            TRACE("id %d finger is grabbed\n", _grab_finger_id);
-        }
-        else if (mts->finger_cnt == mts->finger_cnt_max)
-        { /* Let's assume that this event is last finger touch input */
-
-            /* do nothing */
-        }
-        else /* one more finger */
-        {
-
-            add_finger_point(origin_x, origin_y, x, y) ;
-            virtio_touchscreen_event(x, y, mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
-        }
-
-    } else if (touch_type == MOUSE_UP) { /* released */
-        _grab_finger_id = 0;
-    }
-}
-
-static bool _calculate_origin_coordinates(
-    int scaled_display_w, int scaled_display_h,
-    double scale_factor, int rotaton_type, FingerPoint *finger)
-{
-    int point_x = 0, point_y = 0;
-    int rotated_point_x = 0, rotated_point_y = 0;
-    int flag = 0;
-
-    rotated_point_x = point_x = (int)(finger->x * scale_factor);
-    rotated_point_y = point_y = (int)(finger->y * scale_factor);
-
-    if (rotaton_type == ROTATION_LANDSCAPE) {
-        rotated_point_x = point_y;
-        rotated_point_y = scaled_display_w - point_x;
-    } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
-        rotated_point_x = scaled_display_w - point_x;
-        rotated_point_y = scaled_display_h - point_y;
-    } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
-        rotated_point_x = scaled_display_h - point_y;
-        rotated_point_y = point_x;
-    }
-
-    if (finger->origin_x != rotated_point_x) {
-        finger->origin_x = rotated_point_x;
-        flag = 1;
-    }
-    if (finger->origin_y != rotated_point_y) {
-        finger->origin_y = rotated_point_y;
-        flag = 1;
-    }
-
-    if (flag != 0) {
-        return true;
-    }
-
-    return false;
-}
-
-int rearrange_finger_points(
-    int lcd_w, int lcd_h, double scale_factor, int rotaton_type)
-{
-    int i = 0;
-    int count = 0;
-    MultiTouchState *mts = get_emul_multi_touch_state();
-    FingerPoint *finger = NULL;
-
-    if (mts->multitouch_enable == 0) {
-        return 0;
-    }
-
-    lcd_w *= scale_factor;
-    lcd_h *= scale_factor;
-
-    for (i = 0; i < mts->finger_cnt; i++) {
-        finger = get_finger_point_from_slot(i);
-        if (finger != NULL && finger->id != 0) {
-            if (_calculate_origin_coordinates(lcd_w, lcd_h,
-                scale_factor, rotaton_type, finger) == true) {
-                count++;
-            }
-        }
-    }
-
-    if (count != 0) {
-        _grab_finger_id = 0;
-    }
-
-    return count;
-}
-
-void clear_finger_slot(bool keep_enable)
-{
-    int i = 0;
-    MultiTouchState *mts = get_emul_multi_touch_state();
-    FingerPoint *finger = NULL;
-
-    if (keep_enable == false) {
-        set_multi_touch_enable(0);
-    }
-
-    INFO("clear multi-touch : %d\n", get_multi_touch_enable());
-
-    for (i = 0; i < mts->finger_cnt; i++) {
-        finger = get_finger_point_from_slot(i);
-        if (finger != NULL) {
-            if (finger->id > 0) {
-                virtio_touchscreen_event(finger->x, finger->y,
-                    finger->id - 1, QEMU_MOUSE_RELEASEED);
-            }
-
-            finger->id = 0;
-            finger->origin_x = finger->origin_y = finger->x = finger->y = -1;
-        }
-    }
-
-    _grab_finger_id = 0;
-    mts->finger_cnt = 0;
-}
-
-void cleanup_multi_touch_state(void)
-{
-    MultiTouchState *mts = get_emul_multi_touch_state();
-    SDL_Surface *point = (SDL_Surface *)mts->finger_point_surface;
-
-    clear_finger_slot(false);
-    g_free(mts->finger_slot);
-
-    mts->finger_point_surface = NULL;
-    SDL_FreeSurface(point);
-}
-
diff --git a/tizen/src/maru_finger.h b/tizen/src/maru_finger.h
deleted file mode 100644 (file)
index 61a32e8..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Multi-touch processing
- *
- * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#ifndef __MARU_FINGER_H__
-#define __MARU_FINGER_H__
-
-#include "qemu-common.h"
-
-
-/* definitions relating to multi-touch */
-#define MAX_FINGER_CNT 10
-#define DEFAULT_FINGER_POINT_SIZE 32
-#define DEFAULT_FINGER_POINT_COLOR 0x7E0F0F0F
-#define DEFAULT_FINGER_POINT_OUTLINE_COLOR 0xDDDDDDDD
-
-typedef struct FingerPoint {
-    int id;
-    int origin_x;
-    int origin_y;
-    int x;
-    int y;
-} FingerPoint;
-
-typedef struct MultiTouchState {
-    int multitouch_enable;
-    int finger_cnt;
-    int finger_cnt_max;
-    FingerPoint *finger_slot;
-
-    int finger_point_size;
-    int finger_point_color;
-    int finger_point_outline_color;
-    void *finger_point_surface; //SDL_Surface
-} MultiTouchState;
-
-
-void init_multi_touch_state(void);
-void set_multi_touch_enable(int enable);
-int get_multi_touch_enable(void);
-FingerPoint *get_finger_point_from_slot(int index);
-FingerPoint *get_finger_point_search(int x, int y);
-int add_finger_point(int origin_x, int origin_y, int x, int y);
-
-void maru_finger_processing_1(int touch_type, int origin_x, int origin_y, int x, int y);
-void maru_finger_processing_2(int touch_type, int origin_x, int origin_y, int x, int y);
-int rearrange_finger_points(int lcd_w, int lcd_h, double scale_factor, int rotaton_type);
-void clear_finger_slot(bool keep_enable);
-void cleanup_multi_touch_state(void);
-
-
-#endif /* __MARU_FINGER_H__ */
diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c
deleted file mode 100644 (file)
index 35be462..0000000
+++ /dev/null
@@ -1,609 +0,0 @@
-/*
- * SDL_WINDOWID hack
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#include <png.h>
-#include "qemu/main-loop.h"
-#include "emulator.h"
-#include "emul_state.h"
-#include "maru_display.h"
-#include "maru_sdl.h"
-#include "maru_sdl_processing.h"
-#include "hw/maru_brightness.h"
-#include "debug_ch.h"
-
-MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
-
-static QEMUBH *sdl_init_bh;
-static QEMUBH *sdl_resize_bh;
-static QEMUBH *sdl_update_bh;
-static DisplaySurface *dpy_surface;
-
-static SDL_Surface *surface_screen;
-static SDL_Surface *surface_qemu;
-static SDL_Surface *scaled_screen;
-static SDL_Surface *rotated_screen;
-static SDL_Surface *surface_guide; /* blank guide image */
-
-static double current_scale_factor = 1.0;
-static double current_screen_degree;
-static pixman_filter_t sdl_pixman_filter;
-
-static bool sdl_invalidate;
-static int sdl_alteration;
-
-static unsigned int sdl_skip_update;
-static unsigned int sdl_skip_count;
-
-static bool blank_guide_enable;
-static unsigned int blank_cnt;
-#define MAX_BLANK_FRAME_CNT 10
-#define BLANK_GUIDE_IMAGE_PATH "../images/"
-#define BLANK_GUIDE_IMAGE_NAME "blank-guide.png"
-
-#ifdef SDL_THREAD
-QemuMutex sdl_mutex;
-QemuCond sdl_cond;
-static int sdl_thread_initialized;
-
-QemuThread sdl_thread;
-static bool sdl_thread_exit;
-#endif
-
-#define SDL_FLAGS (SDL_SWSURFACE | SDL_ASYNCBLIT | SDL_NOFRAME)
-#define SDL_BPP 32
-
-static void qemu_update(void);
-
-
-static void qemu_ds_sdl_update(DisplayChangeListener *dcl,
-                               int x, int y, int w, int h)
-{
-    /* call sdl update */
-#ifdef SDL_THREAD
-    qemu_mutex_lock(&sdl_mutex);
-
-    qemu_cond_signal(&sdl_cond);
-
-    qemu_mutex_unlock(&sdl_mutex);
-#else
-    qemu_update();
-#endif
-}
-
-static void qemu_ds_sdl_switch(DisplayChangeListener *dcl,
-                               struct DisplaySurface *new_surface)
-{
-    int console_width = 0, console_height = 0;
-
-    sdl_skip_update = 0;
-    sdl_skip_count = 0;
-
-    if (!new_surface) {
-        ERR("qemu_ds_sdl_switch : new_surface is NULL\n");
-        return;
-    }
-
-    console_width = surface_width(new_surface);
-    console_height = surface_height(new_surface);
-
-    INFO("qemu_ds_sdl_switch : (%d, %d)\n", console_width, console_height);
-
-    /* switch */
-    dpy_surface = new_surface;
-
-    if (surface_qemu != NULL) {
-        SDL_FreeSurface(surface_qemu);
-        surface_qemu = NULL;
-    }
-
-    /* create surface_qemu */
-    if (console_width == get_emul_resolution_width() &&
-        console_height == get_emul_resolution_height()) {
-        INFO("create SDL screen : (%d, %d)\n",
-             console_width, console_height);
-
-        surface_qemu = SDL_CreateRGBSurfaceFrom(
-            surface_data(dpy_surface),
-            console_width, console_height,
-            surface_bits_per_pixel(dpy_surface),
-            surface_stride(dpy_surface),
-            dpy_surface->pf.rmask,
-            dpy_surface->pf.gmask,
-            dpy_surface->pf.bmask,
-            dpy_surface->pf.amask);
-    } else {
-        INFO("create blank screen : (%d, %d)\n",
-             get_emul_resolution_width(), get_emul_resolution_height());
-
-        surface_qemu = SDL_CreateRGBSurface(
-            SDL_SWSURFACE,
-            console_width, console_height,
-            surface_bits_per_pixel(dpy_surface),
-            0, 0, 0, 0);
-    }
-
-    if (surface_qemu == NULL) {
-        ERR("Unable to set the RGBSurface: %s\n", SDL_GetError());
-        return;
-    }
-}
-
-static SDL_Surface *get_blank_guide_image(void)
-{
-    if (surface_guide == NULL) {
-        unsigned int width = 0;
-        unsigned int height = 0;
-        char *guide_image_path = NULL;
-        void *guide_image_data = NULL;
-
-        /* load png image */
-        int path_len = strlen(get_bin_path()) +
-            strlen(BLANK_GUIDE_IMAGE_PATH) +
-            strlen(BLANK_GUIDE_IMAGE_NAME) + 1;
-        guide_image_path = g_malloc0(sizeof(char) * path_len);
-        snprintf(guide_image_path, path_len, "%s%s%s",
-            get_bin_path(), BLANK_GUIDE_IMAGE_PATH,
-            BLANK_GUIDE_IMAGE_NAME);
-
-        guide_image_data = (void *) read_png_file(
-            guide_image_path, &width, &height);
-
-        if (guide_image_data != NULL) {
-            surface_guide = SDL_CreateRGBSurfaceFrom(
-                guide_image_data, width, height,
-                get_emul_sdl_bpp(), width * 4,
-                dpy_surface->pf.bmask,
-                dpy_surface->pf.gmask,
-                dpy_surface->pf.rmask,
-                dpy_surface->pf.amask);
-        } else {
-            ERR("failed to draw a blank guide image\n");
-        }
-
-        g_free(guide_image_path);
-    }
-
-    return surface_guide;
-}
-
-static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl)
-{
-    if (sdl_alteration == 1) {
-        sdl_alteration = 0;
-        sdl_skip_update = 0;
-        sdl_skip_count = 0;
-    }
-
-    /* draw cover image */
-    if (sdl_skip_update && display_off) {
-        if (blank_cnt > MAX_BLANK_FRAME_CNT) {
-#ifdef CONFIG_WIN32
-            if (sdl_invalidate && get_emul_skin_enable()) {
-                draw_image(surface_screen, get_blank_guide_image());
-            }
-#endif
-
-            return;
-        } else if (blank_cnt == MAX_BLANK_FRAME_CNT) {
-            if (blank_guide_enable == true && get_emul_skin_enable()) {
-                INFO("draw a blank guide image\n");
-
-                draw_image(surface_screen, get_blank_guide_image());
-            }
-        } else if (blank_cnt == 0) {
-            /* If the display is turned off,
-            the screen does not update until the display is turned on */
-            INFO("skipping of the display updating is started\n");
-        }
-
-        blank_cnt++;
-
-        return;
-    } else {
-        if (blank_cnt != 0) {
-            INFO("skipping of the display updating is ended\n");
-            blank_cnt = 0;
-        }
-    }
-
-    /* draw framebuffer */
-    if (sdl_invalidate) {
-        graphic_hw_invalidate(NULL);
-    }
-    graphic_hw_update(NULL);
-
-    /* Usually, continuously updated.
-       When the display is turned off,
-       ten more updates the screen for a black screen. */
-    if (display_off) {
-        if (++sdl_skip_count > 10) {
-            sdl_skip_update = 1;
-        } else {
-            sdl_skip_update = 0;
-        }
-    } else {
-        sdl_skip_count = 0;
-        sdl_skip_update = 0;
-    }
-
-#ifdef TARGET_ARM
-#ifdef SDL_THREAD
-    qemu_mutex_lock(&sdl_mutex);
-#endif
-
-    /*
-    * It is necessary only for exynos4210 FIMD in connection with
-    * some WM (xfwm4, for example)
-    */
-
-    SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
-
-#ifdef SDL_THREAD
-    qemu_mutex_unlock(&sdl_mutex);
-#endif
-#endif
-}
-
-DisplayChangeListenerOps maru_dcl_ops = {
-    .dpy_name          = "maru_sdl",
-    .dpy_gfx_update    = qemu_ds_sdl_update,
-    .dpy_gfx_switch    = qemu_ds_sdl_switch,
-    .dpy_refresh       = qemu_ds_sdl_refresh,
-};
-
-void maru_sdl_interpolation(bool on)
-{
-    if (on == true) {
-        INFO("set PIXMAN_FILTER_BEST filter for image processing\n");
-
-        /* PIXMAN_FILTER_BILINEAR */
-        sdl_pixman_filter = PIXMAN_FILTER_BEST;
-    } else {
-        INFO("set PIXMAN_FILTER_FAST filter for image processing\n");
-
-        /* PIXMAN_FILTER_NEAREST */
-        sdl_pixman_filter = PIXMAN_FILTER_FAST;
-    }
-}
-
-static void qemu_update(void)
-{
-    if (sdl_alteration < 0) {
-        SDL_FreeSurface(scaled_screen);
-        SDL_FreeSurface(rotated_screen);
-        SDL_FreeSurface(surface_qemu);
-        surface_qemu = NULL;
-
-        return;
-    }
-
-    if (surface_qemu != NULL) {
-        maru_do_pixman_dpy_surface(dpy_surface->image);
-
-        save_screenshot(dpy_surface);
-
-        if (current_scale_factor != 1.0) {
-            rotated_screen = maru_do_pixman_rotate(
-                surface_qemu, rotated_screen,
-                (int)current_screen_degree);
-            scaled_screen = maru_do_pixman_scale(
-                rotated_screen, scaled_screen, sdl_pixman_filter);
-
-            SDL_BlitSurface(scaled_screen, NULL, surface_screen, NULL);
-        }
-        else {/* current_scale_factor == 1.0 */
-            if (current_screen_degree != 0.0) {
-                rotated_screen = maru_do_pixman_rotate(
-                    surface_qemu, rotated_screen,
-                    (int)current_screen_degree);
-
-                SDL_BlitSurface(rotated_screen, NULL, surface_screen, NULL);
-            } else {
-                /* as-is */
-                SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL);
-            }
-        }
-
-        /* draw multi-touch finger points */
-        MultiTouchState *mts = get_emul_multi_touch_state();
-        if (mts->multitouch_enable != 0 && mts->finger_point_surface != NULL) {
-            int i = 0;
-            FingerPoint *finger = NULL;
-            int finger_point_size_half = mts->finger_point_size / 2;
-            SDL_Rect rect;
-
-            for (i = 0; i < mts->finger_cnt; i++) {
-                finger = get_finger_point_from_slot(i);
-                if (finger != NULL && finger->id != 0) {
-                    rect.x = finger->origin_x - finger_point_size_half;
-                    rect.y = finger->origin_y - finger_point_size_half;
-                    rect.w = rect.h = mts->finger_point_size;
-
-                    SDL_BlitSurface(
-                        (SDL_Surface *)mts->finger_point_surface,
-                        NULL, surface_screen, &rect);
-                }
-            }
-        } /* end of draw multi-touch */
-    }
-
-    SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
-}
-
-
-#ifdef SDL_THREAD
-static void *run_qemu_update(void *arg)
-{
-    qemu_mutex_lock(&sdl_mutex);
-
-    while (1) {
-        qemu_cond_wait(&sdl_cond, &sdl_mutex);
-        if (sdl_thread_exit) {
-            INFO("make SDL Thread exit\n");
-            break;
-        }
-        qemu_update();
-    }
-
-    qemu_mutex_unlock(&sdl_mutex);
-
-    INFO("finish qemu_update routine\n");
-    return NULL;
-}
-#endif
-
-static void maru_sdl_update_bh(void *opaque)
-{
-    graphic_hw_invalidate(NULL);
-}
-
-static void maru_sdl_resize_bh(void *opaque)
-{
-    int surface_width = 0, surface_height = 0;
-    int display_width = 0, display_height = 0;
-    int temp = 0;
-
-    INFO("Set up a video mode with the specified width, "
-         "height and bits-per-pixel\n");
-
-    sdl_alteration = 1;
-    sdl_skip_update = 0;
-
-#ifdef SDL_THREAD
-    qemu_mutex_lock(&sdl_mutex);
-#endif
-
-    /* get current setting information and calculate screen size */
-    display_width = get_emul_resolution_width();
-    display_height = get_emul_resolution_height();
-    current_scale_factor = get_emul_win_scale();
-
-    short rotaton_type = get_emul_rotation();
-    if (rotaton_type == ROTATION_PORTRAIT) {
-        current_screen_degree = 0.0;
-    } else if (rotaton_type == ROTATION_LANDSCAPE) {
-        current_screen_degree = 90.0;
-        temp = display_width;
-        display_width = display_height;
-        display_height = temp;
-    } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
-        current_screen_degree = 180.0;
-    } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
-        current_screen_degree = 270.0;
-        temp = display_width;
-        display_width = display_height;
-        display_height = temp;
-    }
-
-    surface_width = display_width * current_scale_factor;
-    surface_height = display_height * current_scale_factor;
-
-    surface_screen = SDL_SetVideoMode(
-        surface_width, surface_height,
-        get_emul_sdl_bpp(), SDL_FLAGS);
-
-    INFO("SDL_SetVideoMode\n");
-
-    if (surface_screen == NULL) {
-        ERR("Could not open SDL display (%dx%dx%d) : %s\n",
-            surface_width, surface_height,
-            get_emul_sdl_bpp(), SDL_GetError());
-
-#ifdef SDL_THREAD
-        qemu_mutex_unlock(&sdl_mutex);
-#endif
-
-        return;
-    }
-
-    SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
-
-    /* create buffer for image processing */
-    SDL_FreeSurface(scaled_screen);
-    scaled_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
-        surface_width, surface_height,
-        surface_qemu->format->BitsPerPixel,
-        surface_qemu->format->Rmask,
-        surface_qemu->format->Gmask,
-        surface_qemu->format->Bmask,
-        surface_qemu->format->Amask);
-
-    SDL_FreeSurface(rotated_screen);
-    rotated_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
-        display_width, display_height,
-        surface_qemu->format->BitsPerPixel,
-        surface_qemu->format->Rmask,
-        surface_qemu->format->Gmask,
-        surface_qemu->format->Bmask,
-        surface_qemu->format->Amask);
-
-    /* rearrange multi-touch finger points */
-    if (get_emul_multi_touch_state()->multitouch_enable == 1 ||
-            get_emul_multi_touch_state()->multitouch_enable == 2) {
-        rearrange_finger_points(get_emul_resolution_width(), get_emul_resolution_height(),
-            current_scale_factor, rotaton_type);
-    }
-
-#ifdef SDL_THREAD
-    qemu_mutex_unlock(&sdl_mutex);
-#endif
-
-    graphic_hw_invalidate(NULL);
-}
-
-static void maru_sdl_init_bh(void *opaque)
-{
-    INFO("SDL_Init\n");
-
-    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        ERR("unable to init SDL: %s\n", SDL_GetError());
-        // TODO:
-    }
-
-#ifndef CONFIG_WIN32
-    SDL_SysWMinfo info;
-    SDL_VERSION(&info.version);
-    SDL_GetWMInfo(&info);
-#endif
-
-    qemu_bh_schedule(sdl_resize_bh);
-
-#ifdef SDL_THREAD
-    if (sdl_thread_initialized == 0) {
-        sdl_thread_initialized = 1;
-
-        INFO("sdl update thread create\n");
-
-        sdl_thread_exit = false;
-        qemu_thread_create(&sdl_thread, "sdl-workthread", run_qemu_update,
-            NULL, QEMU_THREAD_JOINABLE);
-    }
-#endif
-}
-
-void maru_sdl_pre_init(void) {
-    sdl_init_bh = qemu_bh_new(maru_sdl_init_bh, NULL);
-    sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL);
-    sdl_update_bh = qemu_bh_new(maru_sdl_update_bh, NULL);
-
-#ifdef SDL_THREAD
-    qemu_mutex_init(&sdl_mutex);
-    qemu_cond_init(&sdl_cond);
-#endif
-}
-
-void maru_sdl_init(uint64 swt_handle,
-    unsigned int display_width, unsigned int display_height,
-    bool blank_guide)
-{
-    gchar SDL_windowhack[32] = { 0, };
-    long window_id = swt_handle;
-    blank_guide_enable = blank_guide;
-
-    INFO("maru sdl init\n");
-
-    sprintf(SDL_windowhack, "%ld", window_id);
-    g_setenv("SDL_WINDOWID", SDL_windowhack, 1);
-
-    INFO("register SDL environment variable. "
-        "(SDL_WINDOWID = %s)\n", SDL_windowhack);
-
-    set_emul_resolution(display_width, display_height);
-    set_emul_sdl_bpp(SDL_BPP);
-    maru_sdl_interpolation(false);
-    init_multi_touch_state();
-
-    if (blank_guide_enable == true) {
-        INFO("blank guide is on\n");
-    }
-
-    qemu_bh_schedule(sdl_init_bh);
-}
-
-void maru_sdl_quit(void)
-{
-    INFO("maru sdl quit\n");
-
-    if (surface_guide != NULL) {
-        g_free(surface_guide->pixels);
-        SDL_FreeSurface(surface_guide);
-    }
-
-    /* remove multi-touch finger points */
-    cleanup_multi_touch_state();
-
-    if (sdl_init_bh != NULL) {
-        qemu_bh_delete(sdl_init_bh);
-    }
-    if (sdl_resize_bh != NULL) {
-        qemu_bh_delete(sdl_resize_bh);
-    }
-
-    sdl_alteration = -1;
-
-#ifdef SDL_THREAD
-    qemu_mutex_lock(&sdl_mutex);
-#endif
-
-    SDL_Quit();
-
-#ifdef SDL_THREAD
-    sdl_thread_exit = true;
-    qemu_cond_signal(&sdl_cond);
-    qemu_mutex_unlock(&sdl_mutex);
-
-    INFO("join SDL thread\n");
-    qemu_thread_join(&sdl_thread);
-
-    INFO("destroy cond and mutex of SDL thread\n");
-    qemu_cond_destroy(&sdl_cond);
-    qemu_mutex_destroy(&sdl_mutex);
-#endif
-}
-
-void maru_sdl_resize(void)
-{
-    INFO("maru sdl resize\n");
-
-    qemu_bh_schedule(sdl_resize_bh);
-}
-
-void maru_sdl_update(void)
-{
-    if (sdl_update_bh != NULL) {
-        qemu_bh_schedule(sdl_update_bh);
-    }
-}
-
-void maru_sdl_invalidate(bool on)
-{
-    sdl_invalidate = on;
-}
diff --git a/tizen/src/maru_sdl.h b/tizen/src/maru_sdl.h
deleted file mode 100644 (file)
index 342f4d2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SDL_WINDOWID hack
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#ifndef MARU_SDL_H_
-#define MARU_SDL_H_
-
-#include <SDL.h>
-#include <SDL_syswm.h>
-#include "ui/console.h"
-
-extern DisplayChangeListenerOps maru_dcl_ops;
-
-void maru_sdl_pre_init(void);
-void maru_sdl_init(uint64 swt_handle,
-    unsigned int display_width, unsigned int display_height,
-    bool blank_guide);
-void maru_sdl_resize(void);
-void maru_sdl_update(void);
-void maru_sdl_invalidate(bool on);
-void maru_sdl_interpolation(bool on);
-void maru_sdl_quit(void);
-
-#endif /* MARU_SDL_H_ */
diff --git a/tizen/src/maru_sdl_processing.c b/tizen/src/maru_sdl_processing.c
deleted file mode 100644 (file)
index 4e28eb8..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Image Processing
- *
- * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * SangHo Park <sangho1206.park@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#include "maru_sdl_processing.h"
-#include "hw/maru_brightness.h"
-#include "debug_ch.h"
-
-MULTI_DEBUG_CHANNEL(tizen, sdl_processing);
-
-
-/* Image processing functions using the pixman library */
-void maru_do_pixman_dpy_surface(pixman_image_t *dst_image)
-{
-    /* apply the brightness level */
-    if (brightness_level < BRIGHTNESS_MAX) {
-        pixman_image_composite(PIXMAN_OP_OVER,
-                               brightness_image, NULL, dst_image,
-                               0, 0, 0, 0, 0, 0,
-                               pixman_image_get_width(dst_image),
-                               pixman_image_get_height(dst_image));
-    }
-}
-
-SDL_Surface *maru_do_pixman_scale(SDL_Surface *rz_src,
-                                  SDL_Surface *rz_dst,
-                                  pixman_filter_t filter)
-{
-    pixman_image_t *src = NULL;
-    pixman_image_t *dst = NULL;
-    double sx = 0;
-    double sy = 0;
-    pixman_transform_t matrix;
-    struct pixman_f_transform matrix_f;
-
-    SDL_LockSurface(rz_src);
-    SDL_LockSurface(rz_dst);
-
-    src = pixman_image_create_bits(PIXMAN_a8r8g8b8,
-        rz_src->w, rz_src->h, rz_src->pixels, rz_src->w * 4);
-    dst = pixman_image_create_bits(PIXMAN_a8r8g8b8,
-        rz_dst->w, rz_dst->h, rz_dst->pixels, rz_dst->w * 4);
-
-    sx = (double)rz_src->w / (double)rz_dst->w;
-    sy = (double)rz_src->h / (double)rz_dst->h;
-    pixman_f_transform_init_identity(&matrix_f);
-    pixman_f_transform_scale(&matrix_f, NULL, sx, sy);
-    pixman_transform_from_pixman_f_transform(&matrix, &matrix_f);
-    pixman_image_set_transform(src, &matrix);
-    pixman_image_set_filter(src, filter, NULL, 0);
-    pixman_image_composite(PIXMAN_OP_SRC, src, NULL, dst,
-                           0, 0, 0, 0, 0, 0,
-                           rz_dst->w, rz_dst->h);
-
-    pixman_image_unref(src);
-    pixman_image_unref(dst);
-
-    SDL_UnlockSurface(rz_src);
-    SDL_UnlockSurface(rz_dst);
-
-    return rz_dst;
-}
-
-SDL_Surface *maru_do_pixman_rotate(SDL_Surface *rz_src,
-                                   SDL_Surface *rz_dst,
-                                   int angle)
-{
-    pixman_image_t *src = NULL;
-    pixman_image_t *dst = NULL;
-    pixman_transform_t matrix;
-    struct pixman_f_transform matrix_f;
-
-    SDL_LockSurface(rz_src);
-    SDL_LockSurface(rz_dst);
-
-    src = pixman_image_create_bits(PIXMAN_a8r8g8b8,
-        rz_src->w, rz_src->h, rz_src->pixels, rz_src->w * 4);
-    dst = pixman_image_create_bits(PIXMAN_a8r8g8b8,
-        rz_dst->w, rz_dst->h, rz_dst->pixels, rz_dst->w * 4);
-
-    pixman_f_transform_init_identity(&matrix_f);
-    switch(angle) {
-        case 0:
-            pixman_f_transform_rotate(&matrix_f, NULL, 1.0, 0.0);
-            pixman_f_transform_translate(&matrix_f, NULL, 0.0, 0.0);
-            break;
-        case 90:
-            pixman_f_transform_rotate(&matrix_f, NULL, 0.0, 1.0);
-            pixman_f_transform_translate(&matrix_f, NULL,
-                                         (double)rz_dst->h, 0.0);
-            break;
-        case 180:
-            pixman_f_transform_rotate(&matrix_f, NULL, -1.0, 0.0);
-            pixman_f_transform_translate(&matrix_f, NULL,
-                                         (double)rz_dst->w, (double)rz_dst->h);
-            break;
-        case 270:
-            pixman_f_transform_rotate(&matrix_f, NULL, 0.0, -1.0);
-            pixman_f_transform_translate(&matrix_f, NULL,
-                                         0.0, (double)rz_dst->w);
-            break;
-        default:
-            ERR("Not supported angle factor (angle=%d)\n", angle);
-            break;
-    }
-    pixman_transform_from_pixman_f_transform(&matrix, &matrix_f);
-    pixman_image_set_transform(src, &matrix);
-    pixman_image_composite(PIXMAN_OP_SRC, src, NULL, dst,
-                           0, 0, 0, 0, 0, 0,
-                           rz_dst->w, rz_dst->h);
-
-    pixman_image_unref(src);
-    pixman_image_unref(dst);
-
-    SDL_UnlockSurface(rz_src);
-    SDL_UnlockSurface(rz_dst);
-
-    return rz_dst;
-}
-
-png_bytep read_png_file(const char *file_name,
-    unsigned int *width_out, unsigned int *height_out)
-{
-#define PNG_HEADER_SIZE 8
-
-    FILE *fp = NULL;
-    png_byte header[PNG_HEADER_SIZE] = { 0, };
-    png_structp png_ptr = NULL;
-
-    png_infop info_ptr = NULL;
-    png_uint_32 width = 0;
-    png_uint_32 height = 0;
-    png_byte channels = 0;
-    unsigned int stride = 0;
-    int bit_depth = 0;
-    int color_type = 0;
-    int i = 0;
-
-    png_bytep pixel_data = NULL;
-    png_bytepp row_ptr_data = NULL;
-
-    if (file_name == NULL) {
-        ERR("file name is empty\n");
-        return NULL;
-    }
-
-    fp = fopen(file_name, "rb");
-    if (fp == NULL) {
-        ERR("file %s could not be opened\n", file_name);
-        return NULL;
-    }
-
-    if (fread(header, sizeof(png_byte), PNG_HEADER_SIZE, fp) != PNG_HEADER_SIZE) {
-        ERR("failed to read header from png file\n");
-        fclose(fp);
-        return NULL;
-    }
-
-    if (png_sig_cmp(header, 0, PNG_HEADER_SIZE) != 0) {
-        ERR("file %s is not recognized as a PNG image\n", file_name);
-        fclose(fp);
-        return NULL;
-    }
-
-    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-    if (png_ptr == NULL) {
-        ERR("failed to allocate png read struct\n");
-        fclose(fp);
-        return NULL;
-    }
-
-    info_ptr = png_create_info_struct(png_ptr);
-    if (info_ptr == NULL) {
-        ERR("failed to allocate png info struct\n");
-        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-        fclose(fp);
-        return NULL;
-    }
-
-    if (setjmp(png_jmpbuf(png_ptr)) != 0) {
-        ERR("error during init_io\n");
-        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-        png_destroy_info_struct(png_ptr, &info_ptr);
-        fclose(fp);
-        return NULL;
-    }
-
-    png_init_io(png_ptr, fp);
-    png_set_sig_bytes(png_ptr, PNG_HEADER_SIZE);
-
-    /* read the PNG image information */
-    png_read_info(png_ptr, info_ptr);
-    png_get_IHDR(png_ptr, info_ptr,
-        &width, &height, &bit_depth, &color_type,
-        NULL, NULL, NULL);
-
-    channels = png_get_channels(png_ptr, info_ptr);
-    stride = width * bit_depth * channels / 8;
-
-    pixel_data = (png_bytep) g_malloc0(stride * height);
-    if (pixel_data == NULL) {
-        ERR("could not allocate data buffer for pixels\n");
-
-        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-        png_destroy_info_struct(png_ptr, &info_ptr);
-        fclose(fp);
-        return NULL;
-    }
-
-    row_ptr_data = (png_bytepp) g_malloc0(sizeof(png_bytep) * height);
-    if (row_ptr_data == NULL) {
-        ERR("could not allocate data buffer for row_ptr\n");
-
-        g_free(pixel_data);
-        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-        png_destroy_info_struct(png_ptr, &info_ptr);
-        fclose(fp);
-        return NULL;
-    }
-
-    switch(color_type) {
-        case PNG_COLOR_TYPE_PALETTE :
-            png_set_palette_to_rgb(png_ptr);
-            break;
-        case PNG_COLOR_TYPE_RGB :
-            if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
-                /* transparency data for image */
-                png_set_tRNS_to_alpha(png_ptr);
-            } else {
-                png_set_filter(png_ptr, 0xff, PNG_FILLER_AFTER);
-            }
-            break;
-        case PNG_COLOR_TYPE_RGB_ALPHA :
-            break;
-        default :
-            INFO("png file has an unsupported color type\n");
-            break;
-    }
-
-    for (i = 0; i < height; i++) {
-        row_ptr_data[i] = pixel_data + (stride * i);
-    }
-
-    /* read the entire image into memory */
-    png_read_image(png_ptr, row_ptr_data);
-
-    /* image information */
-    INFO("=== blank guide image was loaded ===============\n");
-    INFO("file path : %s\n", file_name);
-    INFO("width : %d, height : %d, stride : %d\n",
-        width, height, stride);
-    INFO("color type : %d, channels : %d, bit depth : %d\n",
-        color_type, channels, bit_depth);
-    INFO("================================================\n");
-
-    if (width_out != NULL) {
-        *width_out = (unsigned int) width;
-    }
-    if (height_out != NULL) {
-        *height_out = (unsigned int) height;
-    }
-
-    g_free(row_ptr_data);
-    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-    png_destroy_info_struct(png_ptr, &info_ptr);
-    fclose(fp);
-
-    return pixel_data;
-}
-
-void draw_image(SDL_Surface *screen, SDL_Surface *image)
-{
-    if (screen == NULL || image == NULL) {
-        return;
-    }
-
-    int dst_x = 0; int dst_y = 0;
-    int dst_w = 0; int dst_h = 0;
-
-    int margin_w = screen->w - image->w;
-    int margin_h = screen->h - image->h;
-
-    if (margin_w < 0 || margin_h < 0) {
-        /* guide image scaling */
-        int margin = (margin_w < margin_h)? margin_w : margin_h;
-        dst_w = image->w + margin;
-        dst_h = image->h + margin;
-
-        SDL_Surface *scaled_image = SDL_CreateRGBSurface(
-                SDL_SWSURFACE, dst_w, dst_h,
-                image->format->BitsPerPixel,
-                image->format->Rmask, image->format->Gmask,
-                image->format->Bmask, image->format->Amask);
-
-        scaled_image = maru_do_pixman_scale(
-                image, scaled_image, PIXMAN_FILTER_BEST);
-
-        dst_x = (screen->w - dst_w) / 2;
-        dst_y = (screen->h - dst_h) / 2;
-        SDL_Rect dst_rect = { dst_x, dst_y, dst_w, dst_h };
-
-        SDL_BlitSurface(scaled_image, NULL, screen, &dst_rect);
-        SDL_UpdateRect(screen, 0, 0, 0, 0);
-
-        SDL_FreeSurface(scaled_image);
-    } else {
-        dst_w = image->w;
-        dst_h = image->h;
-        dst_x = (screen->w - dst_w) / 2;
-        dst_y = (screen->h - dst_h) / 2;
-        SDL_Rect dst_rect = { dst_x, dst_y, dst_w, dst_h };
-
-        SDL_BlitSurface(image, NULL, screen, &dst_rect);
-        SDL_UpdateRect(screen, 0, 0, 0, 0);
-    }
-}
diff --git a/tizen/src/maru_sdl_processing.h b/tizen/src/maru_sdl_processing.h
deleted file mode 100644 (file)
index ad7d320..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Image Processing
- *
- * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * SangHo Park <sangho1206.park@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#ifndef MARU_SDL_PROCESSING_H_
-#define MARU_SDL_PROCESSING_H_
-
-#include <SDL.h>
-#include <png.h>
-#include "ui/console.h"
-
-void maru_do_pixman_dpy_surface(pixman_image_t *dst);
-SDL_Surface *maru_do_pixman_scale(SDL_Surface *src, SDL_Surface *dst, pixman_filter_t filter);
-SDL_Surface *maru_do_pixman_rotate(SDL_Surface *src, SDL_Surface *dst, int angle);
-
-png_bytep read_png_file(const char *file_name,
-    unsigned int *width_out, unsigned int *height_out);
-void draw_image(SDL_Surface *screen, SDL_Surface *image);
-
-#endif /* MARU_SDL_PROCESSING_H_ */
diff --git a/tizen/src/maru_shm.c b/tizen/src/maru_shm.c
deleted file mode 100644 (file)
index 8c49cf2..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Shared memory
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#include "maru_shm.h"
-#include "emul_state.h"
-#include "hw/maru_brightness.h"
-#include "skin/maruskin_server.h"
-#include "debug_ch.h"
-#include "maru_err_table.h"
-
-MULTI_DEBUG_CHANNEL(tizen, maru_shm);
-
-static DisplaySurface *dpy_surface;
-static void *shared_memory = (void *) 0;
-static int skin_shmid;
-static bool is_fit_console_size;
-
-static int shm_skip_update;
-static int shm_skip_count;
-
-static bool blank_guide_enable;
-static int blank_cnt;
-#define MAX_BLANK_FRAME_CNT 10
-
-extern QemuMutex mutex_draw_display;
-extern int draw_display_state;
-
-//#define INFO_FRAME_DROP_RATE
-#ifdef INFO_FRAME_DROP_RATE
-static unsigned int draw_frame;
-static unsigned int drop_frame;
-#endif
-
-/* Image processing functions using the pixman library */
-static void maru_do_pixman_dpy_surface(pixman_image_t *dst_image)
-{
-    /* apply the brightness level */
-    if (brightness_level < BRIGHTNESS_MAX) {
-        pixman_image_composite(PIXMAN_OP_OVER,
-                               brightness_image, NULL, dst_image,
-                               0, 0, 0, 0, 0, 0,
-                               pixman_image_get_width(dst_image),
-                               pixman_image_get_height(dst_image));
-    }
-}
-
-static void qemu_ds_shm_update(DisplayChangeListener *dcl,
-                               int x, int y, int w, int h)
-{
-    if (shared_memory != NULL) {
-        qemu_mutex_lock(&mutex_draw_display);
-
-        if (draw_display_state == 0) {
-            draw_display_state = 1;
-
-            qemu_mutex_unlock(&mutex_draw_display);
-
-            if (is_fit_console_size == true) {
-                maru_do_pixman_dpy_surface(dpy_surface->image);
-
-                memcpy(shared_memory,
-                    surface_data(dpy_surface),
-                    surface_stride(dpy_surface) *
-                    surface_height(dpy_surface));
-            } else {
-                int shm_size =
-                   get_emul_resolution_width() * get_emul_resolution_height() * 4;
-                memset(shared_memory, 0x00, (size_t)shm_size);
-            }
-
-#ifdef INFO_FRAME_DROP_RATE
-            draw_frame++;
-#endif
-            notify_draw_frame();
-        } else {
-#ifdef INFO_FRAME_DROP_RATE
-            drop_frame++;
-#endif
-            qemu_mutex_unlock(&mutex_draw_display);
-        }
-
-#ifdef INFO_FRAME_DROP_RATE
-        INFO("! frame drop rate = (%d/%d)\n",
-             drop_frame, draw_frame + drop_frame);
-#endif
-    }
-}
-
-static void qemu_ds_shm_switch(DisplayChangeListener *dcl,
-                        struct DisplaySurface *new_surface)
-{
-    int console_width = 0, console_height = 0;
-
-    shm_skip_update = 0;
-    shm_skip_count = 0;
-
-    if (!new_surface) {
-        ERR("qemu_ds_shm_switch : new_surface is NULL\n");
-        return;
-    }
-
-    dpy_surface = new_surface;
-    console_width = surface_width(new_surface);
-    console_height = surface_height(new_surface);
-
-    INFO("qemu_ds_shm_switch : (%d, %d)\n",
-        console_width, console_height);
-
-    if (console_width == get_emul_resolution_width() &&
-        console_height == get_emul_resolution_height()) {
-        is_fit_console_size = true;
-    }
-}
-
-static void qemu_ds_shm_refresh(DisplayChangeListener *dcl)
-{
-    /* If the display is turned off,
-    the screen does not update until the it is turned on */
-    if (shm_skip_update && display_off) {
-        if (blank_cnt > MAX_BLANK_FRAME_CNT) {
-            /* do nothing */
-            return;
-        } else if (blank_cnt == MAX_BLANK_FRAME_CNT) {
-            if (blank_guide_enable == true) {
-                INFO("draw a blank guide image\n");
-
-                if (get_emul_skin_enable()) {
-                    /* draw guide image */
-                    notify_draw_blank_guide();
-                }
-            }
-        } else if (blank_cnt == 0) {
-            INFO("skipping of the display updating is started\n");
-        }
-
-        blank_cnt++;
-
-        return;
-    } else {
-        if (blank_cnt != 0) {
-            INFO("skipping of the display updating is ended\n");
-            blank_cnt = 0;
-        }
-    }
-
-    graphic_hw_update(NULL);
-
-    /* Usually, continuously updated.
-    But when the display is turned off,
-    ten more updates the surface for a black screen. */
-    if (display_off) {
-        if (++shm_skip_count > 10) {
-            shm_skip_update = 1;
-        } else {
-            shm_skip_update = 0;
-        }
-    } else {
-        shm_skip_count = 0;
-        shm_skip_update = 0;
-    }
-}
-
-DisplayChangeListenerOps maru_dcl_ops = {
-    .dpy_name          = "maru_shm",
-    .dpy_refresh       = qemu_ds_shm_refresh,
-    .dpy_gfx_update    = qemu_ds_shm_update,
-    .dpy_gfx_switch    = qemu_ds_shm_switch,
-};
-
-void maru_shm_init(uint64 swt_handle,
-    unsigned int display_width, unsigned int display_height,
-    bool blank_guide)
-{
-    blank_guide_enable = blank_guide;
-
-    INFO("maru shm init\n");
-
-    set_emul_resolution(display_width, display_height);
-    set_emul_sdl_bpp(32);
-
-    if (blank_guide_enable == true) {
-        INFO("blank guide is on\n");
-    }
-
-    /* byte */
-    int shm_size =
-        get_emul_resolution_width() * get_emul_resolution_height() * 4;
-
-    /* base + 1 = sdb port */
-    /* base + 2 = shared memory key */
-    int mykey = get_emul_vm_base_port() + 2;
-
-    INFO("shared memory key: %d, size: %d bytes\n", mykey, shm_size);
-
-    /* make a shared framebuffer */
-    skin_shmid = shmget((key_t)mykey, (size_t)shm_size, 0666 | IPC_CREAT);
-    if (skin_shmid == -1) {
-        ERR("shmget failed\n");
-        perror("maru_vga: ");
-
-        maru_register_exit_msg(MARU_EXIT_UNKNOWN,
-            (char*) "Cannot launch this VM.\n"
-            "Failed to get identifier of the shared memory segment.");
-        exit(1);
-    }
-
-    shared_memory = shmat(skin_shmid, (void*)0, 0);
-    if (shared_memory == (void *)-1) {
-        ERR("shmat failed\n");
-        perror("maru_vga: ");
-
-        maru_register_exit_msg(MARU_EXIT_UNKNOWN,
-            (char*) "Cannot launch this VM.\n"
-            "Failed to attach the shared memory segment.");
-        exit(1);
-    }
-
-    /* default screen */
-    memset(shared_memory, 0x00, (size_t)shm_size);
-    INFO("Memory attached at 0x%X\n", (int)shared_memory);
-}
-
-void maru_shm_quit(void)
-{
-    struct shmid_ds shm_info;
-
-    INFO("maru shm quit\n");
-
-    if (shmctl(skin_shmid, IPC_STAT, &shm_info) == -1) {
-        ERR("shmctl failed\n");
-        shm_info.shm_nattch = -1;
-    }
-
-    if (shmdt(shared_memory) == -1) {
-        ERR("shmdt failed\n");
-        perror("maru_vga: ");
-        return;
-    }
-    shared_memory = NULL;
-
-    if (shm_info.shm_nattch == 1) {
-        /* remove */
-        if (shmctl(skin_shmid, IPC_RMID, 0) == -1) {
-            INFO("segment was already removed\n");
-            perror("maru_vga: ");
-        } else {
-            INFO("shared memory was removed\n");
-        }
-    } else if (shm_info.shm_nattch != -1) {
-        INFO("number of current attaches = %d\n",
-            (int)shm_info.shm_nattch);
-    }
-}
-
-void maru_shm_resize(void)
-{
-    shm_skip_update = 0;
-}
diff --git a/tizen/src/maru_shm.h b/tizen/src/maru_shm.h
deleted file mode 100644 (file)
index d24b1b6..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Shared memory
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-
-#ifndef MARU_SHM_H_
-#define MARU_SHM_H_
-
-#include "ui/console.h"
-
-extern DisplayChangeListenerOps maru_dcl_ops;
-
-void maru_shm_init(uint64 swt_handle,
-    unsigned int display_width, unsigned int display_height,
-    bool blank_guide);
-void maru_shm_resize(void);
-void maru_shm_quit(void);
-
-#endif /* MARU_SHM_H_ */
diff --git a/tizen/src/osutil-darwin.c b/tizen/src/osutil-darwin.c
deleted file mode 100644 (file)
index 74a4182..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Emulator
- *
- * Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * MunKyu Im <munkyu.im@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-/**
-  @file     osutil-darwin.c
-  @brief    Collection of utilities for darwin
- */
-
-#include "maru_common.h"
-#include "osutil.h"
-#include "emulator.h"
-#include "debug_ch.h"
-#include "maru_err_table.h"
-#include "sdb.h"
-
-#ifndef CONFIG_DARWIN
-#error
-#endif
-
-#include <string.h>
-#include <sys/shm.h>
-#include <sys/sysctl.h>
-#include <SystemConfiguration/SystemConfiguration.h>
-
-MULTI_DEBUG_CHANNEL(qemu, osutil);
-
-
-static qemu_timeval tv = { 0, 0 };
-static time_t ti;
-static char buf_time[64];
-static int g_shmid;
-static CFDictionaryRef proxySettings;
-
-extern char tizen_target_img_path[];
-
-static char *cfstring_to_cstring(CFStringRef str) {
-    if (str == NULL) {
-        return NULL;
-    }
-
-    CFIndex length = CFStringGetLength(str);
-    CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
-    char *buffer = (char *)malloc(maxSize);
-    if (CFStringGetCString(str, buffer, maxSize, kCFStringEncodingUTF8))
-        return buffer;
-    return NULL;
-}
-
-static int cfnumber_to_int(CFNumberRef num) {
-    if (!num)
-        return 0;
-
-    int value;
-    CFNumberGetValue(num, kCFNumberIntType, &value);
-    return value;
-}
-
-void check_vm_lock_os(void)
-{
-    /* TODO: */
-}
-
-void make_vm_lock_os(void)
-{
-    char *shared_memory;
-    int base_port;
-    base_port = get_emul_vm_base_port();
-    g_shmid = shmget((key_t)base_port, MAXLEN, 0666|IPC_CREAT);
-    if (g_shmid == -1) {
-        ERR("shmget failed\n");
-        perror("osutil-darwin: ");
-        return;
-    }
-
-    shared_memory = shmat(g_shmid, (char *)0x00, 0);
-    if (shared_memory == (void *)-1) {
-        ERR("shmat failed\n");
-        perror("osutil-darwin: ");
-        return;
-    }
-    g_sprintf(shared_memory, "%s", tizen_target_img_path);
-    INFO("shared memory key: %d, value: %s\n", base_port, (char *)shared_memory);
-
-    if (shmdt(shared_memory) == -1) {
-        ERR("shmdt failed\n");
-        perror("osutil-darwin: ");
-    }
-
-}
-
-void remove_vm_lock_os(void)
-{
-    if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
-        ERR("shmctl failed\n");
-        perror("osutil-linux: ");
-    }
-}
-
-void set_bin_path_os(gchar * exec_argv)
-{
-    gchar *file_name = NULL;
-
-    if (!exec_argv) {
-        return;
-    }
-
-    char *data = g_strdup(exec_argv);
-    if (!data) {
-        ERR("Fail to strdup for paring a binary directory.\n");
-        return;
-    }
-
-    file_name = g_strrstr(data, "/");
-    if (!file_name) {
-        free(data);
-        return;
-    }
-
-    g_strlcpy(bin_path, data, strlen(data) - strlen(file_name) + 1);
-
-    g_strlcat(bin_path, "/", PATH_MAX);
-    free(data);
-}
-
-int get_number_of_processors(void)
-{
-    int mib[2], sys_num = 0;
-    size_t len;
-
-    mib[0] = CTL_HW;
-    mib[1] = HW_AVAILCPU;
-
-    sysctl(mib, 2, &sys_num, &len, NULL, 0);
-    if (sys_num < 1) {
-        mib[1] = HW_NCPU;
-        sysctl(mib, 2, &sys_num, &len, NULL, 0);
-
-        if (sys_num < 1) {
-            sys_num = 1;
-        }
-    }
-    INFO("* Number of processors : %d\n", sys_num);
-
-    return sys_num;
-}
-
-void print_system_info_os(void)
-{
-    INFO("* Mac\n");
-
-    /* uname */
-    INFO("* Host machine uname :\n");
-    char uname_cmd[MAXLEN] = "uname -a";
-    if(system(uname_cmd) < 0) {
-        INFO("system function command '%s' \
-            returns error !", uname_cmd);
-    }
-
-    /* hw information */
-    int mib[2];
-    size_t len;
-    char *sys_info;
-    int sys_num = 0;
-
-    mib[0] = CTL_HW;
-    mib[1] = HW_MODEL;
-    sysctl(mib, 2, NULL, &len, NULL, 0);
-    sys_info = malloc(len * sizeof(char));
-    if (sysctl(mib, 2, sys_info, &len, NULL, 0) >= 0) {
-        INFO("* Machine model : %s\n", sys_info);
-    }
-    free(sys_info);
-
-    mib[0] = CTL_HW;
-    mib[1] = HW_MACHINE;
-    sysctl(mib, 2, NULL, &len, NULL, 0);
-    sys_info = malloc(len * sizeof(char));
-    if (sysctl(mib, 2, sys_info, &len, NULL, 0) >= 0) {
-        INFO("* Machine class : %s\n", sys_info);
-    }
-    free(sys_info);
-
-#if 0
-    mib[0] = CTL_HW;
-    mib[1] = HW_NCPU;
-    len = sizeof(sys_num);
-    if (sysctl(mib, 2, &sys_num, &len, NULL, 0) >= 0) {
-        INFO("* Number of processors : %d\n", sys_num);
-    }
-#endif
-    get_number_of_processors();
-
-    mib[0] = CTL_HW;
-    mib[1] = HW_PHYSMEM;
-    len = sizeof(sys_num);
-    if (sysctl(mib, 2, &sys_num, &len, NULL, 0) >= 0) {
-        INFO("* Total memory : %llu bytes\n", sys_num);
-    }
-
-    /* java version */
-    INFO("* Java version :\n");
-    char lspci_cmd[MAXLEN] = "java -version";
-
-    fflush(stdout);
-    if(system(lspci_cmd) < 0) {
-        INFO("system function command '%s' \
-            returns error !", lspci_cmd);
-    }
-}
-
-char *get_timeofday(void)
-{
-    qemu_gettimeofday(&tv);
-    ti = tv.tv_sec;
-
-    struct tm tm;
-    localtime_r(&ti, &tm);
-    strftime(buf_time, sizeof(buf_time),
-             "%H:%M:%S", &tm);
-
-    return buf_time;
-}
-
-static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    char type[MAXLEN];
-    char proxy[MAXLEN];
-    char line[MAXLEN];
-    FILE *fp_pacfile;
-    char *p = NULL;
-
-    CFStringRef pacURL = (CFStringRef)CFDictionaryGetValue(proxySettings,
-                    kSCPropNetProxiesProxyAutoConfigURLString);
-    if (pacURL) {
-        char url[MAXLEN] = {};
-        CFStringGetCString(pacURL, url, sizeof url, kCFStringEncodingASCII);
-                INFO("pac address: %s\n", (char*)url);
-        download_url(url);
-        }
-
-    fp_pacfile = fopen(pac_tempfile, "r");
-    if(fp_pacfile != NULL) {
-        while(fgets(line, MAXLEN, fp_pacfile) != NULL) {
-            if( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
-                INFO("line found %s", line);
-                sscanf(line, "%*[^\"]\"%s %s", type, proxy);
-            }
-        }
-
-        if(g_str_has_prefix(type, DIRECT)) {
-            INFO("auto proxy is set to direct mode\n");
-            fclose(fp_pacfile);
-        }
-        else if(g_str_has_prefix(type, PROXY)) {
-            INFO("auto proxy is set to proxy mode\n");
-            INFO("type: %s, proxy: %s\n", type, proxy);
-            p = strtok(proxy, "\";");
-            if(p != NULL) {
-                INFO("auto proxy to set: %s\n",p);
-                strcpy(http_proxy, p);
-                strcpy(https_proxy, p);
-                strcpy(ftp_proxy, p);
-                strcpy(socks_proxy, p);
-            }
-            fclose(fp_pacfile);
-        }
-        else
-        {
-            ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
-            fclose(fp_pacfile);
-        }
-    }
-    else {
-        ERR("fail to get pacfile fp\n");
-    return -1;
-    }
-
-    remove(pac_tempfile);
-    return 0;
-}
-
-static void get_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    char *hostname;
-    int port;
-    CFNumberRef isEnable;
-    CFStringRef proxyHostname;
-    CFNumberRef proxyPort;
-    CFDictionaryRef proxySettings;
-    proxySettings = SCDynamicStoreCopyProxies(NULL);
-
-    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPEnable);
-    if (cfnumber_to_int(isEnable)) {
-        // Get proxy hostname
-        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPProxy);
-        hostname = cfstring_to_cstring(proxyHostname);
-        // Get proxy port
-        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPPort);
-        port = cfnumber_to_int(proxyPort);
-        // Save hostname & port
-        snprintf(http_proxy, MAXLEN, "%s:%d", hostname, port);
-
-        free(hostname);
-    } else {
-        INFO("http proxy is null\n");
-    }
-
-    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSEnable);
-    if (cfnumber_to_int(isEnable)) {
-        // Get proxy hostname
-        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSProxy);
-        hostname = cfstring_to_cstring(proxyHostname);
-        // Get proxy port
-        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSPort);
-        port = cfnumber_to_int(proxyPort);
-        // Save hostname & port
-        snprintf(https_proxy, MAXLEN, "%s:%d", hostname, port);
-
-        free(hostname);
-    } else {
-        INFO("https proxy is null\n");
-    }
-
-    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPEnable);
-    if (cfnumber_to_int(isEnable)) {
-        // Get proxy hostname
-        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPProxy);
-        hostname = cfstring_to_cstring(proxyHostname);
-        // Get proxy port
-        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPPort);
-        port = cfnumber_to_int(proxyPort);
-        // Save hostname & port
-        snprintf(ftp_proxy, MAXLEN, "%s:%d", hostname, port);
-
-        free(hostname);
-    } else {
-        INFO("ftp proxy is null\n");
-    }
-
-    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSEnable);
-    if (cfnumber_to_int(isEnable)) {
-        // Get proxy hostname
-        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSProxy);
-        hostname = cfstring_to_cstring(proxyHostname);
-        // Get proxy port
-        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSPort);
-        port = cfnumber_to_int(proxyPort);
-        // Save hostname & port
-        snprintf(socks_proxy, MAXLEN, "%s:%d", hostname, port);
-
-        free(hostname);
-    } else {
-        INFO("socks proxy is null\n");
-    }
-    CFRelease(proxySettings);
-}
-
-void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    int ret;
-    proxySettings = SCDynamicStoreCopyProxies(NULL);
-    if(proxySettings) {
-        INFO("AUTO PROXY MODE\n");
-        ret = get_auto_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
-        if(strlen(http_proxy) == 0 && ret < 0) {
-            INFO("MANUAL PROXY MODE\n");
-            get_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
-        }
-    }
-}
diff --git a/tizen/src/osutil-linux.c b/tizen/src/osutil-linux.c
deleted file mode 100644 (file)
index 8ebbb89..0000000
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Emulator
- *
- * Copyright (C) 2012 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * MunKyu Im <munkyu.im@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-/**
-  @file     osutil-linux.c
-  @brief    Collection of utilities for linux
- */
-
-#include <png.h>
-#include "maru_common.h"
-#include "osutil.h"
-#include "emulator.h"
-#include "debug_ch.h"
-#include "maru_err_table.h"
-#include "sdb.h"
-
-#ifndef CONFIG_LINUX
-#error
-#endif
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <linux/version.h>
-#include <sys/utsname.h>
-#include <sys/sysinfo.h>
-
-MULTI_DEBUG_CHANNEL(emulator, osutil);
-
-
-static qemu_timeval tv = { 0, 0 };
-static time_t ti;
-static char buf_time[64];
-
-static int g_shmid;
-static char *g_shared_memory;
-static int gproxytool = GSETTINGS;
-
-extern char tizen_target_img_path[];
-
-/* Getting proxy commands */
-static const char* gproxycmds[][2] = {
-    { "gconftool-2 -g /system/proxy/mode" , "gsettings get org.gnome.system.proxy mode" },
-    { "gconftool-2 -g /system/proxy/autoconfig_url", "gsettings get org.gnome.system.proxy autoconfig-url" },
-    { "gconftool-2 -g /system/http_proxy/host", "gsettings get org.gnome.system.proxy.http host" },
-    { "gconftool-2 -g /system/http_proxy/port", "gsettings get org.gnome.system.proxy.http port"},
-    { "gconftool-2 -g /system/proxy/secure_host", "gsettings get org.gnome.system.proxy.https host" },
-    { "gconftool-2 -g /system/proxy/secure_port", "gsettings get org.gnome.system.proxy.https port" },
-    { "gconftool-2 -g /system/proxy/ftp_host", "gsettings get org.gnome.system.proxy.ftp host" },
-    { "gconftool-2 -g /system/proxy/ftp_port", "gsettings get org.gnome.system.proxy.ftp port" },
-    { "gconftool-2 -g /system/proxy/socks_host", "gsettings get org.gnome.system.proxy.socks host" },
-    { "gconftool-2 -g /system/proxy/socks_port", "gsettings get org.gnome.system.proxy.socks port" },
-};
-
-void check_vm_lock_os(void)
-{
-    int shm_id;
-    void *shm_addr;
-    uint32_t port;
-    int val;
-    struct shmid_ds shm_info;
-
-    for (port = 26100; port < 26200; port += 10) {
-        shm_id = shmget((key_t)port, 0, 0);
-        if (shm_id != -1) {
-            shm_addr = shmat(shm_id, (void *)0, 0);
-            if ((void *)-1 == shm_addr) {
-                ERR("error occured at shmat()\n");
-                break;
-            }
-
-            val = shmctl(shm_id, IPC_STAT, &shm_info);
-            if (val != -1) {
-                INFO("count of process that use shared memory : %d\n",
-                    shm_info.shm_nattch);
-                if ((shm_info.shm_nattch > 0) &&
-                    g_strcmp0(tizen_target_img_path, (char *)shm_addr) == 0) {
-                    if (check_port_bind_listen(port + 1) > 0) {
-                        shmdt(shm_addr);
-                        continue;
-                    }
-                    shmdt(shm_addr);
-                    maru_register_exit_msg(MARU_EXIT_UNKNOWN,
-                                        "Can not execute this VM.\n"
-                                        "The same name is running now.");
-                    exit(0);
-                } else {
-                    shmdt(shm_addr);
-                }
-            }
-        }
-    }
-}
-
-void make_vm_lock_os(void)
-{
-    int base_port;
-
-    base_port = get_emul_vm_base_port();
-
-    g_shmid = shmget((key_t)base_port, MAXLEN, 0666|IPC_CREAT);
-    if (g_shmid == -1) {
-        ERR("shmget failed\n");
-        perror("osutil-linux: ");
-        return;
-    }
-
-    g_shared_memory = shmat(g_shmid, (char *)0x00, 0);
-    if (g_shared_memory == (void *)-1) {
-        ERR("shmat failed\n");
-        perror("osutil-linux: ");
-        return;
-    }
-
-    g_sprintf(g_shared_memory, "%s", tizen_target_img_path);
-    INFO("shared memory key: %d value: %s\n",
-        base_port, (char *)g_shared_memory);
-
-    if (shmdt(g_shared_memory) == -1) {
-        ERR("shmdt failed\n");
-        perror("osutil-linux: ");
-    }
-}
-
-void remove_vm_lock_os(void)
-{
-    if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
-        ERR("shmctl failed\n");
-        perror("osutil-linux: ");
-    }
-}
-
-
-void set_bin_path_os(gchar * exec_argv)
-{
-    gchar link_path[PATH_MAX] = { 0, };
-    char *file_name = NULL;
-
-    ssize_t len = readlink("/proc/self/exe", link_path, sizeof(link_path) - 1);
-
-    if (len < 0 || len > (sizeof(link_path) - 1)) {
-        perror("set_bin_path error : ");
-        return;
-    }
-
-    link_path[len] = '\0';
-
-    file_name = g_strrstr(link_path, "/");
-    g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
-
-    g_strlcat(bin_path, "/", PATH_MAX);
-}
-
-int get_number_of_processors(void)
-{
-    int num_processors = 0;
-
-    num_processors = sysconf(_SC_NPROCESSORS_ONLN);
-    if (num_processors < 1) {
-        num_processors = 1;
-    }
-    TRACE("Number of processors : %d\n", num_processors);
-
-    return num_processors;
-}
-
-void print_system_info_os(void)
-{
-    INFO("* Linux\n");
-
-    INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING);
-
-    /* depends on building */
-    INFO("* QEMU build machine linux kernel version : (%d, %d, %d)\n",
-        LINUX_VERSION_CODE >> 16,
-        (LINUX_VERSION_CODE >> 8) & 0xff,
-        LINUX_VERSION_CODE & 0xff);
-
-     /* depends on launching */
-    struct utsname host_uname_buf;
-    if (uname(&host_uname_buf) == 0) {
-        INFO("* Host machine uname : %s %s %s %s %s\n",
-            host_uname_buf.sysname, host_uname_buf.nodename,
-            host_uname_buf.release, host_uname_buf.version,
-            host_uname_buf.machine);
-    }
-
-    struct sysinfo sys_info;
-    if (sysinfo(&sys_info) == 0) {
-        INFO("* Total Ram : %llu kB, Free: %llu kB\n",
-            sys_info.totalram * (unsigned long long)sys_info.mem_unit / 1024,
-            sys_info.freeram * (unsigned long long)sys_info.mem_unit / 1024);
-    }
-
-    /* get linux distribution information */
-    INFO("* Linux distribution infomation :\n");
-    const gchar lsb_release_cmd[MAXLEN] = "lsb_release -d -r -c";
-    gchar *buffer = NULL;
-    gint buffer_size = strlen(lsb_release_cmd) + 1;
-
-    buffer = g_malloc(buffer_size);
-
-    g_snprintf(buffer, buffer_size, "%s", lsb_release_cmd);
-
-    if (system(buffer) < 0) {
-        INFO("system function command '%s' \
-                returns error !", buffer);
-    }
-    g_free(buffer);
-
-    /* pci device description */
-    INFO("* Host PCI devices :\n");
-    const gchar lspci_cmd[MAXLEN] = "lspci";
-    buffer_size = strlen(lspci_cmd) + 1;
-
-    buffer = g_malloc(buffer_size);
-
-    g_snprintf(buffer, buffer_size, "%s", lspci_cmd);
-
-    fflush(stdout);
-    if (system(buffer) < 0) {
-        INFO("system function command '%s' \
-                returns error !", buffer);
-    }
-    g_free(buffer);
-}
-
-char *get_timeofday(void)
-{
-    qemu_gettimeofday(&tv);
-    ti = tv.tv_sec;
-
-    struct tm tm;
-    localtime_r(&ti, &tm);
-    strftime(buf_time, sizeof(buf_time),
-             "%H:%M:%S", &tm);
-
-    return buf_time;
-}
-
-static void process_string(char *buf)
-{
-    char tmp_buf[MAXLEN];
-
-    /* remove single quotes of strings gotten by gsettings */
-    if (gproxytool == GSETTINGS) {
-        remove_string(buf, tmp_buf, "\'");
-        memset(buf, 0, MAXLEN);
-        strncpy(buf, tmp_buf, strlen(tmp_buf)-1);
-    }
-}
-
-static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    char type[MAXLEN];
-    char proxy[MAXLEN];
-    char line[MAXLEN];
-    FILE *fp_pacfile;
-    char *p = NULL;
-    FILE *output;
-    char buf[MAXLEN];
-
-    output = popen(gproxycmds[GNOME_PROXY_AUTOCONFIG_URL][gproxytool], "r");
-    if (fscanf(output, "%s", buf) > 0) {
-        process_string(buf);
-        INFO("pac address: %s\n", buf);
-        download_url(buf);
-    }
-
-    pclose(output);
-    fp_pacfile = fopen(pac_tempfile, "r");
-    if (fp_pacfile != NULL) {
-        while (fgets(line, MAXLEN, fp_pacfile) != NULL) {
-            if ((strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
-                INFO("line found %s", line);
-                sscanf(line, "%*[^\"]\"%s %s", type, proxy);
-            }
-        }
-
-        if (g_str_has_prefix(type, DIRECT)) {
-            INFO("auto proxy is set to direct mode\n");
-            fclose(fp_pacfile);
-        } else if (g_str_has_prefix(type, PROXY)) {
-            INFO("auto proxy is set to proxy mode\n");
-            INFO("type: %s, proxy: %s\n", type, proxy);
-
-            p = strtok(proxy, "\";");
-            if (p != NULL) {
-                INFO("auto proxy to set: %s\n",p);
-                strcpy(http_proxy, p);
-                strcpy(https_proxy, p);
-                strcpy(ftp_proxy, p);
-                strcpy(socks_proxy, p);
-            }
-            fclose(fp_pacfile);
-        } else {
-            ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
-            fclose(fp_pacfile);
-        }
-    } else {
-        ERR("fail to get pacfile fp\n");
-        return -1;
-    }
-
-    if (remove(pac_tempfile) < 0) {
-        WARN("fail to remove the temporary pacfile\n");
-    }
-
-    return 0;
-}
-
-static void get_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    char buf[MAXLEN] = {0,};
-    char buf_port[MAXPORTLEN] = {0,};
-    char buf_proxy[MAXLEN] = {0,};
-    char *buf_proxy_bak;
-    char *proxy;
-    FILE *output;
-    int MAXPROXYLEN = MAXLEN + MAXPORTLEN;
-
-    output = popen(gproxycmds[GNOME_PROXY_HTTP_HOST][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        process_string(buf);
-        snprintf(buf_proxy, MAXLEN, "%s", buf);
-    }
-    pclose(output);
-
-    output = popen(gproxycmds[GNOME_PROXY_HTTP_PORT][gproxytool], "r");
-    if(fscanf(output, "%s", buf_port) <= 0) {
-        //for abnormal case: if can't find the key of http port, get from environment value.
-        buf_proxy_bak = getenv("http_proxy");
-        INFO("http_proxy from env: %s\n", buf_proxy_bak);
-        if(buf_proxy_bak != NULL) {
-            proxy = malloc(MAXLEN);
-            remove_string(buf_proxy_bak, proxy, HTTP_PREFIX);
-            strncpy(http_proxy, proxy, strlen(proxy)-1);
-            INFO("final http_proxy value: %s\n", http_proxy);
-            free(proxy);
-        }
-        else {
-            INFO("http_proxy is not set on env.\n");
-            pclose(output);
-            return;
-        }
-
-    }
-    else {
-        snprintf(http_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf_port);
-        memset(buf_proxy, 0, MAXLEN);
-        INFO("http_proxy: %s\n", http_proxy);
-    }
-    pclose(output);
-
-    memset(buf, 0, MAXLEN);
-
-    output = popen(gproxycmds[GNOME_PROXY_HTTPS_HOST][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        process_string(buf);
-        snprintf(buf_proxy, MAXLEN, "%s", buf);
-    }
-    pclose(output);
-
-    output = popen(gproxycmds[GNOME_PROXY_HTTPS_PORT][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        snprintf(https_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
-    }
-    pclose(output);
-    memset(buf, 0, MAXLEN);
-    memset(buf_proxy, 0, MAXLEN);
-    INFO("https_proxy : %s\n", https_proxy);
-
-    output = popen(gproxycmds[GNOME_PROXY_FTP_HOST][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        process_string(buf);
-        snprintf(buf_proxy, MAXLEN, "%s", buf);
-    }
-    pclose(output);
-
-    output = popen(gproxycmds[GNOME_PROXY_FTP_PORT][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        snprintf(ftp_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
-    }
-    pclose(output);
-    memset(buf, 0, MAXLEN);
-    memset(buf_proxy, 0, MAXLEN);
-    INFO("ftp_proxy : %s\n", ftp_proxy);
-
-    output = popen(gproxycmds[GNOME_PROXY_SOCKS_HOST][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        process_string(buf);
-        snprintf(buf_proxy, MAXLEN, "%s", buf);
-    }
-    pclose(output);
-
-    output = popen(gproxycmds[GNOME_PROXY_SOCKS_PORT][gproxytool], "r");
-    if(fscanf(output, "%s", buf) > 0) {
-        snprintf(socks_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
-    }
-    pclose(output);
-    INFO("socks_proxy : %s\n", socks_proxy);
-}
-
-
-void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    char buf[MAXLEN];
-    FILE *output;
-    int ret;
-
-    output = popen(gproxycmds[GNOME_PROXY_MODE][gproxytool], "r");
-    ret = fscanf(output, "%s", buf);
-    if (ret <= 0) {
-        pclose(output);
-        INFO("Try to use gsettings to get proxy\n");
-        gproxytool = GSETTINGS;
-        output = popen(gproxycmds[GNOME_PROXY_MODE][gproxytool], "r");
-        ret = fscanf(output, "%s", buf);
-    }
-    if (ret > 0) {
-        process_string(buf);
-        //priority : auto > manual > none
-        if (strcmp(buf, "auto") == 0) {
-            INFO("AUTO PROXY MODE\n");
-            get_auto_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
-        }
-        else if (strcmp(buf, "manual") == 0) {
-            INFO("MANUAL PROXY MODE\n");
-            get_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
-        }
-        else if (strcmp(buf, "none") == 0) {
-            INFO("DIRECT PROXY MODE\n");
-        }
-    }
-    pclose(output);
-}
diff --git a/tizen/src/osutil-win32.c b/tizen/src/osutil-win32.c
deleted file mode 100644 (file)
index 457279b..0000000
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Emulator
- *
- * Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * MunKyu Im <munkyu.im@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-/**
-  @file     osutil-win32.c
-  @brief    Collection of utilities for win32
- */
-
-#include <png.h>
-#include "maru_common.h"
-#include "osutil.h"
-#include "emulator.h"
-#include "debug_ch.h"
-#include "maru_err_table.h"
-#include "sdb.h"
-
-#ifndef CONFIG_WIN32
-#error
-#endif
-
-#include <windows.h>
-
-MULTI_DEBUG_CHANNEL (emulator, osutil);
-
-
-static qemu_timeval tv = { 0, 0 };
-static time_t ti;
-static char buf_time[64];
-static HANDLE g_hMapFile;
-static char *g_pBuf;
-
-extern char tizen_target_img_path[];
-
-static const char *pactempfile = ".autoproxy";
-
-void check_vm_lock_os(void)
-{
-    uint32_t port;
-    char *base_port = NULL;
-    char *pBuf;
-    HANDLE hMapFile;
-
-    for (port = 26100; port < 26200; port += 10) {
-        base_port = g_strdup_printf("%d", port);
-        hMapFile = OpenFileMapping(FILE_MAP_READ, TRUE, base_port);
-        if (hMapFile == NULL) {
-            INFO("port %s is not used.\n", base_port);
-            continue;
-        } else {
-             pBuf = (char *)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 50);
-            if (pBuf == NULL) {
-                ERR("Could not map view of file (%d).\n", GetLastError());
-                CloseHandle(hMapFile);
-            }
-
-            if (strcmp(pBuf, tizen_target_img_path) == 0) {
-                maru_register_exit_msg(MARU_EXIT_UNKNOWN,
-                    "Can not execute this VM.\n"
-                    "The same name is running now.");
-                UnmapViewOfFile(pBuf);
-                CloseHandle(hMapFile);
-                free(base_port);
-                exit(0);
-            } else {
-                UnmapViewOfFile(pBuf);
-            }
-        }
-
-        CloseHandle(hMapFile);
-        free(base_port);
-    }
-}
-
-void make_vm_lock_os(void)
-{
-    char *port_in_use;
-    char *shared_memory;
-    int base_port;
-
-    base_port = get_emul_vm_base_port();
-    shared_memory = g_strdup_printf("%s", tizen_target_img_path);
-    port_in_use =  g_strdup_printf("%d", base_port);
-    g_hMapFile = CreateFileMapping(
-                 INVALID_HANDLE_VALUE, /* use paging file */
-                 NULL,                 /* default security */
-                 PAGE_READWRITE,       /* read/write access */
-                 0,                /* maximum object size (high-order DWORD) */
-                 50,               /* maximum object size (low-order DWORD) */
-                 port_in_use);         /* name of mapping object */
-    if (g_hMapFile == NULL) {
-        ERR("Could not create file mapping object (%d).\n", GetLastError());
-        return;
-    }
-
-    g_pBuf = MapViewOfFile(g_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 50);
-    if (g_pBuf == NULL) {
-        ERR("Could not map view of file (%d).\n", GetLastError());
-        CloseHandle(g_hMapFile);
-        return;
-    }
-
-    CopyMemory((PVOID)g_pBuf, shared_memory, strlen(shared_memory));
-    free(port_in_use);
-    free(shared_memory);
-}
-
-void remove_vm_lock_os(void)
-{
-    if (g_pBuf != NULL) {
-        UnmapViewOfFile(g_pBuf);
-    }
-    if (g_hMapFile != NULL) {
-        CloseHandle(g_hMapFile);
-    }
-}
-
-
-void set_bin_path_os(gchar * exec_argv)
-{
-    gchar link_path[PATH_MAX] = { 0, };
-    gchar *file_name = NULL;
-
-    if (!GetModuleFileName(NULL, link_path, PATH_MAX)) {
-        return;
-    }
-
-    file_name = g_strrstr(link_path, "\\");
-    g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
-
-    g_strlcat(bin_path, "\\", PATH_MAX);
-}
-
-int get_number_of_processors(void)
-{
-    SYSTEM_INFO sysi;
-    int num_processors = 0;
-
-    GetSystemInfo(&sysi);
-    TRACE("Processor type: %d, Core number: %d\n",
-        sysi.dwProcessorType, sysi.dwNumberOfProcessors);
-
-    num_processors = sysi.dwNumberOfProcessors;
-    if (num_processors < 1) {
-        num_processors = 1;
-    }
-
-    return num_processors;
-}
-
-void print_system_info_os(void)
-{
-    INFO("* Windows\n");
-
-    INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING);
-
-    /* Retrieves information about the current os */
-    OSVERSIONINFO osvi;
-    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
-    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-
-    if (GetVersionEx(&osvi)) {
-        INFO("* MajorVersion : %d, MinorVersion : %d, BuildNumber : %d, "
-            "PlatformId : %d, CSDVersion : %s\n", osvi.dwMajorVersion,
-            osvi.dwMinorVersion, osvi.dwBuildNumber,
-            osvi.dwPlatformId, osvi.szCSDVersion);
-    }
-
-    /* Retrieves information about the current system */
-    SYSTEM_INFO sysi;
-    ZeroMemory(&sysi, sizeof(SYSTEM_INFO));
-
-#if 0
-    GetSystemInfo(&sysi);
-    INFO("* Processor type : %d, Number of processors : %d\n",
-            sysi.dwProcessorType, sysi.dwNumberOfProcessors);
-#endif
-    get_number_of_processors();
-
-    MEMORYSTATUSEX memInfo;
-    memInfo.dwLength = sizeof(MEMORYSTATUSEX);
-    GlobalMemoryStatusEx(&memInfo);
-    INFO("* Total Ram : %llu kB, Free: %lld kB\n",
-            memInfo.ullTotalPhys / 1024, memInfo.ullAvailPhys / 1024);
-}
-
-char *get_timeofday(void)
-{
-    qemu_gettimeofday(&tv);
-    ti = tv.tv_sec;
-
-    struct tm *ptm = localtime(&ti);
-    strftime(buf_time, sizeof(buf_time),
-             "%H:%M:%S", ptm);
-
-    return buf_time;
-}
-
-static int get_auto_proxy(BYTE *url, char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    char type[MAXLEN];
-    char proxy[MAXLEN];
-    char line[MAXLEN];
-    FILE *fp_pacfile;
-    char *p = NULL;
-
-    INFO("pac address: %s\n", (char*)url);
-    download_url((char*)url);
-
-    fp_pacfile = fopen(pactempfile, "r");
-    if(fp_pacfile != NULL) {
-        while(fgets(line, MAXLEN, fp_pacfile) != NULL) {
-            if( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
-                INFO("line found %s", line);
-                sscanf(line, "%*[^\"]\"%s %s", type, proxy);
-            }
-        }
-
-        if(g_str_has_prefix(type, DIRECT)) {
-            INFO("auto proxy is set to direct mode\n");
-            fclose(fp_pacfile);
-        }
-        else if(g_str_has_prefix(type, PROXY)) {
-            INFO("auto proxy is set to proxy mode\n");
-            INFO("type: %s, proxy: %s\n", type, proxy);
-            p = strtok(proxy, "\";");
-            if(p != NULL) {
-                INFO("auto proxy to set: %s\n",p);
-                strcpy(http_proxy, p);
-                strcpy(https_proxy, p);
-                strcpy(ftp_proxy, p);
-                strcpy(socks_proxy, p);
-            }
-            fclose(fp_pacfile);
-        }
-        else
-        {
-            ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
-            fclose(fp_pacfile);
-        }
-    }
-    else {
-        ERR("fail to get pacfile fp\n");
-        return -1;
-    }
-
-    remove(pactempfile);
-
-    return 0;
-}
-
-void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
-    HKEY hKey;
-    int nRet;
-    LONG lRet;
-    BYTE *proxyenable, *proxyserver;
-    char *p;
-    char *real_proxy;
-    BYTE *url;
-
-    DWORD dwLength = 0;
-    nRet = RegOpenKeyEx(HKEY_CURRENT_USER,
-            "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
-            0, KEY_QUERY_VALUE, &hKey);
-    if (nRet != ERROR_SUCCESS) {
-        ERR("Failed to open registry from %s\n",
-                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
-        return 0;
-    }
-    //check auto proxy key exists
-    lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, NULL, &dwLength);
-    if (lRet != ERROR_SUCCESS && dwLength == 0) {
-        ERR("Failed to query value from %s\n",
-                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\AutoConfigURL");
-    }
-    else {
-        //if exists
-        url = (char*)malloc(dwLength);
-        if (url == NULL) {
-            ERR( "Failed to allocate a buffer\n");
-        }
-        else {
-            memset(url, 0x00, dwLength);
-            lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, url, &dwLength);
-            if (lRet == ERROR_SUCCESS && dwLength != 0) {
-                get_auto_proxy(url, http_proxy, https_proxy, ftp_proxy, socks_proxy);
-                RegCloseKey(hKey);
-                return 0;
-            }
-        }
-    }
-    //check manual proxy key exists
-    lRet = RegQueryValueEx(hKey, "ProxyEnable", 0, NULL, NULL, &dwLength);
-    if (lRet != ERROR_SUCCESS && dwLength == 0) {
-        ERR(stderr, "Failed to query value from %s\n",
-                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable");
-        RegCloseKey(hKey);
-        return 0;
-    }
-    proxyenable = (BYTE*)malloc(dwLength);
-    if (proxyenable == NULL) {
-        ERR( "Failed to allocate a buffer\n");
-        RegCloseKey(hKey);
-        return 0;
-    }
-
-    lRet = RegQueryValueEx(hKey, "ProxyEnable", 0, NULL, proxyenable, &dwLength);
-    if (lRet != ERROR_SUCCESS) {
-        free(proxyenable);
-        ERR("Failed to query value from %s\n",
-                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable");
-        RegCloseKey(hKey);
-        return 0;
-    }
-    if (*(char*)proxyenable == 0) {
-        free(proxyenable);
-        RegCloseKey(hKey);
-        return 0;
-    }
-
-    dwLength = 0;
-    lRet = RegQueryValueEx(hKey, "ProxyServer", 0, NULL, NULL, &dwLength);
-    if (lRet != ERROR_SUCCESS && dwLength == 0) {
-        ERR("Failed to query value from from %s\n",
-                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
-        RegCloseKey(hKey);
-        return 0;
-    }
-
-    proxyserver = (BYTE*)malloc(dwLength);
-    if (proxyserver == NULL) {
-        ERR( "Failed to allocate a buffer\n");
-        RegCloseKey(hKey);
-        return 0;
-    }
-
-    memset(proxyserver, 0x00, dwLength);
-    lRet = RegQueryValueEx(hKey, "ProxyServer", 0, NULL, proxyserver, &dwLength);
-    if (lRet != ERROR_SUCCESS) {
-        free(proxyserver);
-        ERR( "Failed to query value from from %s\n",
-                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
-        RegCloseKey(hKey);
-        return 0;
-    }
-
-    if((char*)proxyserver != NULL) {
-        INFO("proxy value: %s\n", (char*)proxyserver);
-        real_proxy = malloc(MAXLEN);
-
-        for(p = strtok((char*)proxyserver, ";"); p; p = strtok(NULL, ";")){
-            if(strstr(p, HTTP_PROTOCOL)) {
-                remove_string(p, real_proxy, HTTP_PROTOCOL);
-                strcpy(http_proxy, real_proxy);
-            }
-            else if(strstr(p, HTTPS_PROTOCOL)) {
-                remove_string(p, real_proxy, HTTPS_PROTOCOL);
-                strcpy(https_proxy, real_proxy);
-            }
-            else if(strstr(p, FTP_PROTOCOL)) {
-                remove_string(p, real_proxy, FTP_PROTOCOL);
-                strcpy(ftp_proxy, real_proxy);
-            }
-            else if(strstr(p, SOCKS_PROTOCOL)) {
-                remove_string(p, real_proxy, SOCKS_PROTOCOL);
-                strcpy(socks_proxy, real_proxy);
-            }
-            else {
-                INFO("all protocol uses the same proxy server: %s\n", p);
-                strcpy(http_proxy, p);
-                strcpy(https_proxy, p);
-                strcpy(ftp_proxy, p);
-                strcpy(socks_proxy, p);
-            }
-        }
-        free(real_proxy);
-    }
-    else {
-        INFO("proxy is null\n");
-        return 0;
-    }
-    RegCloseKey(hKey);
-}
diff --git a/tizen/src/osutil.c b/tizen/src/osutil.c
deleted file mode 100644 (file)
index 07fc65d..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Emulator
- *
- * Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * MunKyu Im <munkyu.im@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-/**
-  @file     osutil.c
-  @brief    Common functions for osutil
- */
-
-#include "osutil.h"
-#include "debug_ch.h"
-
-#include <curl/curl.h>
-#include <string.h>
-
-MULTI_DEBUG_CHANNEL(emulator, osutil);
-
-
-const char *pac_tempfile = ".autoproxy";
-
-inline size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
-{
-    size_t written;
-    written = fwrite(ptr, size, nmemb, stream);
-    return written;
-}
-
-inline void download_url(char *url)
-{
-    CURL *curl;
-    FILE *fp;
-    CURLcode res;
-
-    curl = curl_easy_init();
-    if (curl) {
-        fp = fopen(pac_tempfile, "wb");
-        if(fp == NULL) {
-            ERR("failed to fopen(): %s\n", pac_tempfile);
-            return;
-        }
-        curl_easy_setopt(curl, CURLOPT_URL, url);
-        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
-        /* just in case network does not work */
-        curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 3000);
-        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
-
-        res = curl_easy_perform(curl);
-        if (res != 0) {
-            ERR("Fail to download pac file: %s\n", url);
-        }
-
-        curl_easy_cleanup(curl);
-        fclose(fp);
-    }
-
-    return;
-}
-
-inline void remove_string(char *src, char *dst, const char *toremove)
-{
-    int len = strlen(toremove);
-    int i, j;
-    int max_len = strlen(src);
-
-    for(i = len, j = 0; i < max_len; i++)
-    {
-        dst[j++] = src[i];
-    }
-
-    dst[j] = '\0';
-}
diff --git a/tizen/src/osutil.h b/tizen/src/osutil.h
deleted file mode 100644 (file)
index 338d1cb..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Emulator
- *
- * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * MunKyu Im <munkyu.im@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#ifndef __OSUTIL_H__
-#define __OSUTIL_H__
-
-#include "qemu-common.h"
-#include "maru_common.h"
-#include "emul_state.h"
-
-#define HTTP_PROTOCOL "http="
-#define HTTP_PREFIX "http://"
-#define HTTPS_PROTOCOL "https="
-#define FTP_PROTOCOL "ftp="
-#define SOCKS_PROTOCOL "socks="
-#define DIRECT "DIRECT"
-#define PROXY "PROXY"
-#define MAXPORTLEN 6
-
-#define GNOME_PROXY_MODE 0
-#define GNOME_PROXY_AUTOCONFIG_URL 1
-#define GNOME_PROXY_HTTP_HOST 2
-#define GNOME_PROXY_HTTP_PORT 3
-#define GNOME_PROXY_HTTPS_HOST 4
-#define GNOME_PROXY_HTTPS_PORT 5
-#define GNOME_PROXY_FTP_HOST 6
-#define GNOME_PROXY_FTP_PORT 7
-#define GNOME_PROXY_SOCKS_HOST 8
-#define GNOME_PROXY_SOCKS_PORT 9
-#define GCONFTOOL 0
-#define GSETTINGS 1
-
-extern const char *pac_tempfile;
-
-void check_vm_lock_os(void);
-void make_vm_lock_os(void);
-void remove_vm_lock_os(void);
-
-void set_bin_path_os(gchar *);
-
-void print_system_info_os(void);
-
-void get_host_proxy_os(char *, char *, char *, char *);
-
-void download_url(char *);
-size_t write_data(void *, size_t, size_t, FILE *);
-void remove_string(char *, char *, const char *);
-char *get_timeofday(void);
-
-int get_number_of_processors(void);
-
-#endif // __OS_UTIL_H__
-
diff --git a/tizen/src/sdb.c b/tizen/src/sdb.c
deleted file mode 100644 (file)
index b4cbb46..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/* Copyright (C) 2006-2010 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** 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.
-*/
-
-
-#include "emulator.h"
-#include "net/slirp.h"
-#include "qemu/sockets.h"
-#include "sdb.h"
-#include "include/block/nbd.h"
-#include "tizen/src/debug_ch.h"
-#include "emul_state.h"
-
-MULTI_DEBUG_CHANNEL(qemu, sdb);
-
-extern char tizen_target_path[];
-
-#ifdef _WIN32
-
-#include "qemu/main-loop.h"
-
-static void socket_close_handler( void*  _fd )
-{
-    int   fd = (int)_fd;
-    int   ret;
-    char  buff[64];
-
-    /* we want to drain the read side of the socket before closing it */
-    do {
-        ret = recv( fd, buff, sizeof(buff), 0 );
-    } while (ret < 0 && WSAGetLastError() == WSAEINTR);
-
-    if (ret < 0 && WSAGetLastError() == EWOULDBLOCK)
-        return;
-
-    qemu_set_fd_handler( fd, NULL, NULL, NULL );
-    closesocket( fd );
-}
-
-void socket_close( int  fd )
-{
-    int  old_errno = errno;
-
-    shutdown( fd, SD_BOTH );
-    /* we want to drain the socket before closing it */
-    qemu_set_fd_handler( fd, socket_close_handler, NULL, (void*)fd );
-
-    errno = old_errno;
-}
-
-#else /* !_WIN32 */
-
-#include <unistd.h>
-
-void socket_close( int  fd )
-{
-    int  old_errno = errno;
-
-    shutdown( fd, SHUT_RDWR );
-    close( fd );
-
-    errno = old_errno;
-}
-
-#endif /* !_WIN32 */
-
-int inet_strtoip(const char*  str, uint32_t  *ip)
-{
-    int  comp[4];
-
-    if (sscanf(str, "%d.%d.%d.%d", &comp[0], &comp[1], &comp[2], &comp[3]) != 4)
-        return -1;
-
-    if ((unsigned)comp[0] >= 256 ||
-            (unsigned)comp[1] >= 256 ||
-            (unsigned)comp[2] >= 256 ||
-            (unsigned)comp[3] >= 256)
-        return -1;
-
-    *ip = (uint32_t)((comp[0] << 24) | (comp[1] << 16) |
-            (comp[2] << 8)  |  comp[3]);
-    return 0;
-}
-
-int check_port_bind_listen(uint32_t port)
-{
-    struct sockaddr_in addr;
-    int s, opt = 1;
-    int ret = -1;
-    socklen_t addrlen = sizeof(addr);
-    memset(&addr, 0, addrlen);
-
-    addr.sin_family = AF_INET;
-    addr.sin_addr.s_addr = INADDR_ANY;
-    addr.sin_port = htons(port);
-
-    s = qemu_socket(AF_INET, SOCK_STREAM, 0);
-    if (s < 0) {
-        ERR("failed to create a socket\n", port);
-        return -1;
-    }
-
-#ifndef _WIN32
-    ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
-                    (char *)&opt, sizeof(int));
-    if (ret < 0) {
-        ERR("setsockopt failure\n");
-        close(s);
-        return -1;
-    }
-#endif
-
-    if ((bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) ||
-        (listen(s, 1) < 0)) {
-        /* failure */
-        ret = -1;
-        ERR("port(%d) listen failure\n", port);
-    } else {
-        /* success */
-        ret = 1;
-        INFO("port(%d) listen success\n", port);
-    }
-
-#ifdef _WIN32
-    closesocket(s);
-#else
-    close(s);
-#endif
-
-    return ret;
-}
-
-void set_base_port(void)
-{
-    int   tries     = 10;
-    int   success   = 0;
-    uint32_t port = 26100;
-    int base_port;
-
-    base_port = get_emul_vm_base_port();
-
-    if(base_port == 0){
-
-        for ( ; tries > 0; tries--, port += 10 ) {
-            if(check_port_bind_listen(port + 1) < 0 )
-                continue;
-
-            success = 1;
-            break;
-        }
-
-        if (!success) {
-            ERR( "it seems too many emulator instances are running on this machine. Aborting\n" );
-            exit(1);
-        }
-
-        base_port = port;
-        INFO( "sdb port is %d \n", base_port);
-    }
-
-    set_emul_vm_base_port(base_port);
-}
-
-void sdb_setup(void)
-{
-    int   tries     = 10;
-    int   success   = 0;
-    uint32_t  guest_ip;
-    char buf[64] = {0,};
-    int number;
-
-    number = get_device_serial_number();
-
-    inet_strtoip("10.0.2.16", &guest_ip);
-
-    for ( ; tries > 0; tries--, number += 10 ) {
-        // redir form [tcp:26101:10.0.2.16:26101]
-        sprintf(buf, "tcp:%d:10.0.2.16:26101", number);
-        if(net_slirp_redir((char*)buf) < 0)
-            continue;
-
-        INFO( "SDBD established on port %d\n", number);
-        success = 1;
-        break;
-    }
-
-    INFO("redirect [%s] success\n", buf);
-    if (!success) {
-        ERR( "it seems too many emulator instances are running on this machine. Aborting\n" );
-        exit(1);
-    }
-
-    INFO( "Port(%d/tcp) listen for SDB \n", number);
-}
-
-int sdb_loopback_client(int port, int type)
-{
-    struct sockaddr_in addr;
-    int s;
-
-    memset(&addr, 0, sizeof(addr));
-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-    addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
-    s = socket(AF_INET, type, 0);
-    if(s < 0) return -1;
-
-    if(connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-        close(s);
-        return -1;
-    }
-
-    return s;
-
-}
diff --git a/tizen/src/sdb.h b/tizen/src/sdb.h
deleted file mode 100644 (file)
index 2e1acfc..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 2006-2010 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** 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.
-*/
-
-#include "maru_common.h"
-
-#include <errno.h>
-
-#ifdef _WIN32
-#include <windows.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#else /* !_WIN32 */
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#endif /* !_WIN32 */
-
-
-#define SDB_HOST_PORT 26099
-
-#define SDB_TCP_EMULD_INDEX  2    /* emulator daemon port */
-#define SDB_TCP_OPENGL_INDEX  3   /* opengl server port */
-#define SDB_UDP_SENSOR_INDEX  2   /* sensor server port */
-
-void sdb_setup(void);
-void set_base_port(void);
-int inet_strtoip(const char*  str, uint32_t  *ip);
-int socket_send(int fd, const void*  buf, int  buflen);
-void socket_close(int fd);
-int check_port_bind_listen(uint32_t port);
-int sdb_loopback_client(int port, int type);
-
diff --git a/tizen/src/skin/Makefile.objs b/tizen/src/skin/Makefile.objs
new file mode 100644 (file)
index 0000000..4825f20
--- /dev/null
@@ -0,0 +1,3 @@
+obj-y += maruskin_client.o maruskin_server.o
+obj-y += maruskin_operation.o
+obj-y += maruskin_keymap.o
index 1a236cfa087a5870fd799af21f63824acc6e4b5d..243037a0a6e4c7d1ed02f377369139e1b28efa30 100644 (file)
@@ -39,7 +39,7 @@
 #include "maruskin_client.h"
 #include "maruskin_server.h"
 #include "emulator.h"
-#include "sdb.h"
+#include "util/sdb.h"
 #include "debug_ch.h"
 #include "emul_state.h"
 #include "maruskin_operation.h"
index 44993f258749e05a1f132bdc2fbbd0bf40d5be11..d4fb8f97add94fa0b6e5cc4a5a9bdba0dfe6f7ab 100644 (file)
 #include "hw/maru_brightness.h"
 #include "hw/maru_virtio_hwkey.h"
 #include "hw/maru_virtio_touchscreen.h"
-#include "maru_display.h"
+#include "display/maru_display.h"
 #include "emulator.h"
 #include "debug_ch.h"
-#include "sdb.h"
+#include "util/sdb.h"
 #include "mloop_event.h"
 #include "emul_state.h"
 #include "maruskin_keymap.h"
 #include "maruskin_server.h"
-#include "maru_display.h"
+#include "display/maru_display.h"
 #include "hw/maru_pm.h"
 #include "ecs/ecs.h"
 
index ebf6ce6cdca4b8ccbd197b164484492033adc45f..3b24c7e099b8587d45d75869b4e6fe4943925580 100644 (file)
 #include "maru_common.h"
 #include "maruskin_server.h"
 #include "maruskin_operation.h"
-#include "maru_display.h"
+#include "display/maru_display.h"
 #include "maru_err_table.h"
 #include "ecs/ecs.h"
+#include "emul_state.h"
 
 #ifdef CONFIG_WIN32
 #include <windows.h>
diff --git a/tizen/src/tethering/Makefile.objs b/tizen/src/tethering/Makefile.objs
new file mode 100644 (file)
index 0000000..3a0b9e4
--- /dev/null
@@ -0,0 +1,2 @@
+obj-y += genmsg/tethering.pb-c.o # protobuf-c.o
+obj-y += app_tethering.o
diff --git a/tizen/src/tethering/Makefile.tizen b/tizen/src/tethering/Makefile.tizen
deleted file mode 100644 (file)
index afc81e2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# tethering Makefile.tizen
-
-$(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/tizen/src/tethering:$(SRC_PATH)/tizen/src/tethering/genmsg:$(SRC_PATH)/tizen/distrib/protobuf)
-
-QEMU_CFLAGS += -I$(SRC_PATH)/tizen/distrib/protobuf
-QEMU_CFLAGS += -I$(SRC_PATH)/tizen/src/tethering/genmsg
-
-obj-y += tethering.pb-c.o # protobuf-c.o
-obj-y += app_tethering.o
index dfdf43a3bfb8de4662b752f79cb1fc335c53566a..5607e38a9ee8b93c2f1496ff6dfa7615e91b0a10 100644 (file)
 #include "emulator.h"
 #include "emul_state.h"
 #include "app_tethering.h"
-#include "../ecs/ecs_tethering.h"
+#include "ecs/ecs_tethering.h"
 #include "genmsg/tethering.pb-c.h"
 
-#include "../debug_ch.h"
+#include "debug_ch.h"
+
 MULTI_DEBUG_CHANNEL(tizen, app_tethering);
 
 #define TETHERING_MSG_HANDSHAKE_KEY     100
diff --git a/tizen/src/util/Makefile.objs b/tizen/src/util/Makefile.objs
new file mode 100644 (file)
index 0000000..f66b840
--- /dev/null
@@ -0,0 +1,14 @@
+# osutil
+obj-y += osutil.o
+obj-$(CONFIG_LINUX) += osutil-linux.o
+obj-$(CONFIG_WIN32) += osutil-win32.o
+obj-$(CONFIG_DARWIN) += osutil-darwin.o
+
+#sdb
+obj-y += sdb.o
+
+# check gl
+obj-y += check_gl_core.o
+obj-$(CONFIG_LINUX) += check_gl_glx.o
+obj-$(CONFIG_WIN32) += check_gl_wgl.o
+obj-$(CONFIG_DARWIN) += check_gl_cgl.o
diff --git a/tizen/src/util/check_cam.c b/tizen/src/util/check_cam.c
new file mode 100644 (file)
index 0000000..90a24a3
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * check the availability of a host webcam.
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdio.h>
+
+#ifdef _WIN32
+/* Windows implement */
+#include <windows.h>
+#define CINTERFACE
+#define COBJMACROS
+#include "ocidl.h"
+#include "errors.h"      /* for VFW_E_XXXX */
+#include "mmsystem.h"    /* for MAKEFOURCC macro */
+#include "hw/maru_camera_win32_interface.h"
+
+/*
+ * COM Interface implementations
+ *
+ */
+
+#define SAFE_RELEASE(x) \
+    do { \
+        if (x) { \
+            (x)->lpVtbl->Release(x); \
+            x = NULL; \
+        } \
+    } while (0)
+
+static int check_cam(void)
+{
+    int ret = 0;
+    char *device_name = NULL;
+    HRESULT hr = E_FAIL;
+    ICreateDevEnum *pCreateDevEnum = NULL;
+    IGraphBuilder *pGB = NULL;
+    ICaptureGraphBuilder2 *pCGB = NULL;
+    IEnumMoniker *pEnumMK = NULL;
+    IMoniker *pMoniKer = NULL;
+
+    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+    if (FAILED(hr)) {
+        fprintf(stdout, "[Webcam] failed to CoInitailizeEx\n");
+        return ret;
+    }
+
+    hr = CoCreateInstance(&CLSID_FilterGraph, NULL,
+                          CLSCTX_INPROC,
+                          &IID_IGraphBuilder,
+                          (void **)&pGB);
+    if (FAILED(hr)) {
+        fprintf(stdout, "[Webcam] Failed to create GraphBuilder, 0x%x\n", hr);
+        CoUninitialize();
+        return ret;
+    }
+
+    hr = CoCreateInstance(&CLSID_CaptureGraphBuilder2, NULL,
+                          CLSCTX_INPROC,
+                          &IID_ICaptureGraphBuilder2,
+                          (void **)&pCGB);
+    if (FAILED(hr)) {
+        fprintf(stdout,
+        "[Webcam] Failed to create CaptureGraphBuilder2, 0x%x\n", hr);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    }
+
+    hr = pCGB->lpVtbl->SetFiltergraph(pCGB, pGB);
+    if (FAILED(hr)) {
+        fprintf(stdout, "[Webcam] Failed to SetFiltergraph, 0x%x\n", hr);
+        SAFE_RELEASE(pCGB);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    }
+
+    hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL,
+                          CLSCTX_INPROC,
+                          &IID_ICreateDevEnum,
+                          (void **)&pCreateDevEnum);
+    if (FAILED(hr)) {
+        fprintf(stdout,
+            "[Webcam] failed to create instance of CLSID_SystemDeviceEnum\n");
+        SAFE_RELEASE(pCGB);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    }
+
+    hr = pCreateDevEnum->lpVtbl->CreateClassEnumerator(pCreateDevEnum,
+                                  &CLSID_VideoInputDeviceCategory, &pEnumMK, 0);
+    if (FAILED(hr)) {
+        fprintf(stdout, "[Webcam] failed to create class enumerator\n");
+        SAFE_RELEASE(pCreateDevEnum);
+        SAFE_RELEASE(pCGB);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    }
+
+    if (!pEnumMK) {
+        fprintf(stdout, "[Webcam] class enumerator is NULL!!\n");
+        SAFE_RELEASE(pCreateDevEnum);
+        SAFE_RELEASE(pCGB);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    }
+
+    pEnumMK->lpVtbl->Reset(pEnumMK);
+    hr = pEnumMK->lpVtbl->Next(pEnumMK, 1, &pMoniKer, NULL);
+    if (FAILED(hr) || (hr == S_FALSE)) {
+        fprintf(stdout, "[Webcam] enum moniker returns a invalid value.\n");
+        SAFE_RELEASE(pEnumMK);
+        SAFE_RELEASE(pCreateDevEnum);
+        SAFE_RELEASE(pCGB);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    }
+
+    IPropertyBag *pBag = NULL;
+    hr = pMoniKer->lpVtbl->BindToStorage(pMoniKer, 0, 0,
+                                         &IID_IPropertyBag,
+                                         (void **)&pBag);
+    if (FAILED(hr)) {
+        fprintf(stdout, "[Webcam] failed to bind to storage.\n");
+        SAFE_RELEASE(pEnumMK);
+        SAFE_RELEASE(pCreateDevEnum);
+        SAFE_RELEASE(pCGB);
+        SAFE_RELEASE(pGB);
+        CoUninitialize();
+        return ret;
+    } else {
+        VARIANT var;
+        var.vt = VT_BSTR;
+        hr = pBag->lpVtbl->Read(pBag, L"FriendlyName", &var, NULL);
+        if (hr == S_OK) {
+            ret = 1;
+            fprintf(stdout, "[Webcam] Check success\n");
+        } else {
+            fprintf(stdout, "[Webcam] failed to find to webcam device.\n");
+        }
+        SysFreeString(var.bstrVal);
+        SAFE_RELEASE(pBag);
+    }
+    SAFE_RELEASE(pMoniKer);
+    SAFE_RELEASE(pCGB);
+    SAFE_RELEASE(pGB);
+    SAFE_RELEASE(pEnumMK);
+    SAFE_RELEASE(pCreateDevEnum);
+    CoUninitialize();
+
+    return ret;
+}
+
+
+#elif __linux
+
+/* Linux implement */
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <linux/videodev2.h>
+
+static int check_cam(void)
+{
+    int tmp_fd;
+    struct stat st;
+    struct v4l2_fmtdesc format;
+    struct v4l2_frmsizeenum size;
+    struct v4l2_capability cap;
+    char dev_name[] = "/dev/video0";
+    int ret = 0;
+
+    if (stat(dev_name, &st) < 0) {
+        fprintf(stdout, "[Webcam] <WARNING> Cannot identify '%s': %d\n",
+                dev_name, errno);
+    } else {
+        if (!S_ISCHR(st.st_mode)) {
+            fprintf(stdout, "[Webcam] <WARNING>%s is no character device\n",
+                    dev_name);
+        }
+    }
+
+    tmp_fd = open(dev_name, O_RDWR | O_NONBLOCK, 0);
+    if (tmp_fd < 0) {
+        fprintf(stdout, "[Webcam] Camera device open failed: %s\n", dev_name);
+        return ret;
+    }
+    if (ioctl(tmp_fd, VIDIOC_QUERYCAP, &cap) < 0) {
+        fprintf(stdout, "[Webcam] Could not qeury video capabilities\n");
+        close(tmp_fd);
+        return ret;
+    }
+    if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) ||
+            !(cap.capabilities & V4L2_CAP_STREAMING)) {
+        fprintf(stdout, "[Webcam] Not supported video driver\n");
+        close(tmp_fd);
+        return ret;
+    }
+    fprintf(stdout, "[Webcam] Check success\n");
+    close(tmp_fd);
+
+    return 1;
+}
+
+#elif __APPLE__
+/* MacOS, Now, not implemented. */
+static int check_cam(void)
+{
+    fprintf(stdout, "[Webcam] Not implemented.\n");
+    return 1;
+}
+
+#else
+/* Unsupported OS */
+static int check_cam(void)
+{
+    fprintf(stdout, "[Webcam] Unsupported OS. Not available.\n");
+    return 0;
+}
+#endif    /* end of the if statement */
+
+int main(int argc, char** argv)
+{
+    return check_cam();
+}
+
diff --git a/tizen/src/util/check_gl.c b/tizen/src/util/check_gl.c
new file mode 100644 (file)
index 0000000..1da7a18
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Stanislav Vorobiov <s.vorobiov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "check_gl.h"
+
+int main(int argc, char *argv[])
+{
+    return check_gl();
+}
diff --git a/tizen/src/util/check_gl.h b/tizen/src/util/check_gl.h
new file mode 100644 (file)
index 0000000..89594a7
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Stanislav Vorobiov <s.vorobiov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef __CHECK_GL_H__
+#define __CHECK_GL_H__
+
+struct gl_context;
+
+typedef enum
+{
+    gl_info = 0,
+    gl_warn = 1,
+    gl_error = 2
+} gl_log_level;
+
+typedef enum
+{
+    gl_2 = 0,
+    gl_3_1 = 1,
+    gl_3_2 = 2
+} gl_version;
+
+int check_gl(void);
+
+void check_gl_log(gl_log_level level, const char *format, ...);
+
+int check_gl_init(void);
+
+void check_gl_cleanup(void);
+
+struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
+                                           gl_version version);
+
+int check_gl_make_current(struct gl_context *ctx);
+
+void check_gl_context_destroy(struct gl_context *ctx);
+
+int check_gl_procaddr(void **func, const char *sym, int opt);
+
+#endif
diff --git a/tizen/src/util/check_gl_cgl.c b/tizen/src/util/check_gl_cgl.c
new file mode 100644 (file)
index 0000000..379bab3
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Stanislav Vorobiov <s.vorobiov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "check_gl.h"
+#include <OpenGL/OpenGL.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#define LIBGL_IMAGE_NAME \
+"/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
+
+#ifndef kCGLPFAOpenGLProfile
+#   define kCGLPFAOpenGLProfile 99
+#   define kCGLOGLPVersion_3_2_Core 0x3200
+#   define kCGLOGLPVersion_Legacy 0x1000
+#endif
+
+struct gl_context
+{
+    CGLContextObj base;
+};
+
+static void *handle;
+
+int check_gl_init(void)
+{
+    handle = dlopen(LIBGL_IMAGE_NAME, RTLD_NOW | RTLD_GLOBAL);
+
+    if (!handle) {
+        check_gl_log(gl_error, "%s", dlerror());
+        return 0;
+    }
+
+    return 1;
+}
+
+void check_gl_cleanup(void)
+{
+}
+
+struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
+                                           gl_version version)
+{
+    static const CGLPixelFormatAttribute pixel_format_legacy_attrs[] =
+    {
+        kCGLPFAAccelerated,
+        kCGLPFAMinimumPolicy,
+        kCGLPFAColorSize, 32,
+        kCGLPFAAlphaSize, 8,
+        kCGLPFADepthSize, 24,
+        kCGLPFAStencilSize, 8,
+        kCGLPFANoRecovery,
+        kCGLPFAPBuffer,
+        0
+    };
+
+    static const CGLPixelFormatAttribute pixel_format_3_2_core_attrs[] =
+    {
+        kCGLPFAAccelerated,
+        kCGLPFAMinimumPolicy,
+        kCGLPFAColorSize, 32,
+        kCGLPFAAlphaSize, 8,
+        kCGLPFADepthSize, 24,
+        kCGLPFAStencilSize, 8,
+        kCGLPFANoRecovery,
+        kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core,
+        0
+    };
+    CGLError error;
+    CGLPixelFormatObj pixel_format;
+    int n;
+    CGLContextObj base = NULL;
+    struct gl_context *ctx;
+
+    switch (version) {
+    case gl_2:
+        error = CGLChoosePixelFormat(pixel_format_legacy_attrs,
+                                     &pixel_format,
+                                     &n);
+
+        if (error || !pixel_format) {
+            break;
+        }
+
+        error = CGLCreateContext(pixel_format,
+                                 (share_ctx ? share_ctx->base : NULL),
+                                 &base);
+
+        CGLDestroyPixelFormat(pixel_format);
+
+        if (error) {
+            base = NULL;
+        }
+
+        break;
+    case gl_3_1:
+        break;
+    case gl_3_2:
+        error = CGLChoosePixelFormat(pixel_format_3_2_core_attrs,
+                                     &pixel_format,
+                                     &n);
+
+        if (error || !pixel_format) {
+            break;
+        }
+
+        error = CGLCreateContext(pixel_format,
+                                 (share_ctx ? share_ctx->base : NULL),
+                                 &base);
+
+        CGLDestroyPixelFormat(pixel_format);
+
+        if (error) {
+            base = NULL;
+        }
+
+        break;
+    default:
+        assert(0);
+        return NULL;
+    }
+
+    if (!base) {
+        return NULL;
+    }
+
+    ctx = malloc(sizeof(*ctx));
+
+    if (!ctx) {
+        CGLDestroyContext(base);
+        return NULL;
+    }
+
+    ctx->base = base;
+
+    return ctx;
+}
+
+int check_gl_make_current(struct gl_context *ctx)
+{
+    return !CGLSetCurrentContext(ctx ? ctx->base : NULL);
+}
+
+void check_gl_context_destroy(struct gl_context *ctx)
+{
+    CGLDestroyContext(ctx->base);
+    free(ctx);
+}
+
+int check_gl_procaddr(void **func, const char *sym, int opt)
+{
+    *func = dlsym(handle, sym);
+
+    if (!*func && !opt) {
+        check_gl_log(gl_error, "Unable to find symbol \"%s\"", sym);
+        return 0;
+    }
+
+    return 1;
+}
diff --git a/tizen/src/util/check_gl_core.c b/tizen/src/util/check_gl_core.c
new file mode 100644 (file)
index 0000000..c2280cf
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Stanislav Vorobiov <s.vorobiov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "check_gl.h"
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+static const char *log_level_str[gl_error + 1] =
+{
+    "INFO",
+    "WARN",
+    "ERROR"
+};
+
+static const char *gl_version_str[gl_3_2 + 1] =
+{
+    "2.1",
+    "3.1",
+    "3.2"
+};
+
+static const char *gl_3_2_check_funcs[] =
+{
+    "glGenTransformFeedbacks",
+    "glBindTransformFeedback",
+    "glPauseTransformFeedback",
+    "glResumeTransformFeedback",
+    "glDeleteTransformFeedbacks",
+    "glVertexAttribDivisor"
+};
+
+void check_gl_log(gl_log_level level, const char *format, ...)
+{
+    va_list args;
+
+    fprintf(stderr, "%-5s", log_level_str[level]);
+
+    va_start(args, format);
+    fprintf(stderr, " - ");
+    vfprintf(stderr, format, args);
+    va_end(args);
+
+    fprintf(stderr, "\n");
+}
+
+static const GLubyte *(GLAPIENTRY *get_string)(GLenum);
+static const GLubyte *(GLAPIENTRY *get_stringi)(GLenum, GLuint);
+static void (GLAPIENTRY *get_integerv)(GLenum, GLint*);
+static void (GLAPIENTRY *dummy)(void);
+
+static struct gl_context *check_gl_version(gl_version version)
+{
+    struct gl_context *ctx = NULL;
+    int hw = 1;
+
+    ctx = check_gl_context_create(NULL, version);
+
+    if (!ctx) {
+        goto fail;
+    }
+
+    if (!check_gl_make_current(ctx)) {
+        goto fail;
+    }
+
+    if ((strstr((const char*)get_string(GL_RENDERER), "Software") != NULL)) {
+        check_gl_log(gl_warn,
+                     "Host OpenGL %s - software",
+                     gl_version_str[version]);
+        hw = 0;
+    } else if (strncmp((const char*)get_string(GL_VERSION),
+                       "1.4", strlen("1.4")) == 0) {
+        /*
+         * Handle LIBGL_ALWAYS_INDIRECT=1 case.
+         */
+        check_gl_log(gl_warn,
+                     "Host OpenGL %s - NOT supported",
+                     gl_version_str[version]);
+        hw = 0;
+    } else {
+        check_gl_log(gl_info,
+                     "Host OpenGL %s - supported",
+                     gl_version_str[version]);
+    }
+
+    check_gl_log(gl_info, "+ GL_VENDOR = %s", (const char*)get_string(GL_VENDOR));
+    check_gl_log(gl_info, "+ GL_RENDERER = %s", (const char*)get_string(GL_RENDERER));
+    check_gl_log(gl_info, "+ GL_VERSION = %s", (const char*)get_string(GL_VERSION));
+
+    if (!hw) {
+        check_gl_context_destroy(ctx);
+        ctx = NULL;
+    }
+
+    check_gl_make_current(NULL);
+
+    return ctx;
+
+fail:
+    if (ctx) {
+        check_gl_context_destroy(ctx);
+    }
+
+    check_gl_log(gl_info,
+                 "Host OpenGL %s - NOT supported",
+                 gl_version_str[version]);
+
+    return NULL;
+}
+
+int check_gl(void)
+{
+    int res = 1;
+    struct gl_context *ctx_2 = NULL;
+    struct gl_context *ctx_3_1 = NULL;
+    struct gl_context *ctx_3_2 = NULL;
+    int have_es3 = 0;
+    int have_es3_compatibility = 0;
+    int have_es1 = 0;
+
+    if (!check_gl_init()) {
+        return 1;
+    }
+
+    if (!check_gl_procaddr((void**)&get_string, "glGetString", 0) ||
+        !check_gl_procaddr((void**)&get_stringi, "glGetStringi", 1) ||
+        !check_gl_procaddr((void**)&get_integerv, "glGetIntegerv", 0)) {
+        goto out;
+    }
+
+    ctx_2 = check_gl_version(gl_2);
+    ctx_3_1 = check_gl_version(gl_3_1);
+    ctx_3_2 = check_gl_version(gl_3_2);
+
+    if (!ctx_2 && !ctx_3_1 && !ctx_3_2) {
+        check_gl_log(gl_info, "Host does not have hardware GL acceleration!");
+        goto out;
+    }
+
+    have_es1 = (ctx_2 != NULL);
+
+    if (ctx_3_2) {
+        unsigned int i;
+        int found_all = 1;
+
+        for (i = 0;
+             i < sizeof(gl_3_2_check_funcs)/sizeof(gl_3_2_check_funcs[0]);
+             ++i) {
+            if (!check_gl_procaddr((void**)&dummy, gl_3_2_check_funcs[i], 1) ||
+                !dummy) {
+                found_all = 0;
+                break;
+            }
+        }
+
+        if (found_all) {
+            have_es3 = 1;
+        }
+    }
+
+    /*
+     * Check if GL_ARB_ES3_compatibility is supported within
+     * OpenGL 3.1 context.
+     */
+
+    if (ctx_3_1 && get_stringi && check_gl_make_current(ctx_3_1)) {
+        GLint i, num_extensions = 0;
+
+        get_integerv(GL_NUM_EXTENSIONS, &num_extensions);
+
+        for (i = 0; i < num_extensions; ++i) {
+            const char *tmp;
+
+            tmp = (const char*)get_stringi(GL_EXTENSIONS, i);
+
+            if (strcmp(tmp, "GL_ARB_ES3_compatibility") == 0) {
+                have_es3 = 1;
+                have_es3_compatibility = 1;
+                break;
+            }
+        }
+
+        check_gl_make_current(NULL);
+    }
+
+    /*
+     * Check if OpenGL 2.1 contexts can be shared with OpenGL 3.x contexts
+     */
+
+    if (ctx_2 && have_es3) {
+        struct gl_context *ctx = NULL;
+
+        ctx = check_gl_context_create(((ctx_3_1 && have_es3_compatibility) ? ctx_3_1
+                                                                           : ctx_3_2),
+                                      gl_2);
+
+        if (ctx) {
+            if (check_gl_make_current(ctx)) {
+                check_gl_make_current(NULL);
+            } else {
+                have_es1 = 0;
+            }
+            check_gl_context_destroy(ctx);
+        } else {
+            have_es1 = 0;
+        }
+    }
+
+    if (have_es1) {
+        check_gl_log(gl_info, "Guest OpenGL ES v1_CM - supported");
+    } else {
+        check_gl_log(gl_warn, "Guest OpenGL ES v1_CM - NOT supported");
+    }
+    check_gl_log(gl_info, "Guest OpenGL ES 2.0 - supported");
+    if (have_es3) {
+        check_gl_log(gl_info, "Guest OpenGL ES 3.0 - supported");
+    } else {
+        check_gl_log(gl_warn, "Guest OpenGL ES 3.0 - NOT supported");
+    }
+
+    check_gl_log(gl_info, "Host has hardware GL acceleration!");
+
+    res = 0;
+
+out:
+    if (ctx_2) {
+        check_gl_context_destroy(ctx_2);
+    }
+
+    if (ctx_3_1) {
+        check_gl_context_destroy(ctx_3_1);
+    }
+
+    if (ctx_3_2) {
+        check_gl_context_destroy(ctx_3_2);
+    }
+
+    check_gl_cleanup();
+
+    return res;
+}
diff --git a/tizen/src/util/check_gl_glx.c b/tizen/src/util/check_gl_glx.c
new file mode 100644 (file)
index 0000000..8034c5c
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Stanislav Vorobiov <s.vorobiov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "check_gl.h"
+#include <GL/glx.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <assert.h>
+
+#ifndef GLX_VERSION_1_4
+#error GL/glx.h must be equal to or greater than GLX 1.4
+#endif
+
+#define GLX_GET_PROC(func, sym) \
+    do { \
+        *(void**)(&func) = (void*)get_proc_address((const GLubyte*)#sym); \
+        if (!func) { \
+            check_gl_log(gl_error, "%s", dlerror()); \
+            return 0; \
+        } \
+    } while (0)
+
+struct gl_context
+{
+    GLXContext base;
+    GLXPbuffer sfc;
+};
+
+typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display *dpy, GLXContext ctx);
+
+static void *handle;
+static Display *x_dpy;
+static GLXFBConfig x_config;
+static PFNGLXGETPROCADDRESSPROC get_proc_address;
+static PFNGLXCHOOSEFBCONFIGPROC choose_fb_config;
+static PFNGLXCREATEPBUFFERPROC create_pbuffer;
+static PFNGLXDESTROYPBUFFERPROC destroy_pbuffer;
+static PFNGLXCREATENEWCONTEXTPROC create_context;
+static PFNGLXDESTROYCONTEXTPROC destroy_context;
+static PFNGLXMAKECONTEXTCURRENTPROC make_current;
+
+/* GLX_ARB_create_context */
+static PFNGLXCREATECONTEXTATTRIBSARBPROC create_context_attribs;
+
+static int check_gl_error_handler(Display *dpy, XErrorEvent *e)
+{
+    return 0;
+}
+
+int check_gl_init(void)
+{
+    static const int config_attribs[] =
+    {
+        GLX_DOUBLEBUFFER, True,
+        GLX_RED_SIZE, 8,
+        GLX_GREEN_SIZE, 8,
+        GLX_BLUE_SIZE, 8,
+        GLX_ALPHA_SIZE, 8,
+        GLX_BUFFER_SIZE, 32,
+        GLX_DEPTH_SIZE, 24,
+        GLX_STENCIL_SIZE, 8,
+        GLX_RENDER_TYPE, GLX_RGBA_BIT,
+        GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
+        None
+    };
+    int n = 0;
+    GLXFBConfig *configs;
+
+    x_dpy = XOpenDisplay(NULL);
+
+    if (!x_dpy) {
+        check_gl_log(gl_error, "Unable to open X display");
+        return 0;
+    }
+
+    XSetErrorHandler(check_gl_error_handler);
+
+    handle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
+
+    if (!handle) {
+        check_gl_log(gl_error, "%s", dlerror());
+        goto fail;
+    }
+
+    get_proc_address = dlsym(handle, "glXGetProcAddress");
+
+    if (!get_proc_address) {
+        get_proc_address = dlsym(handle, "glXGetProcAddressARB");
+    }
+
+    if (!get_proc_address) {
+        check_gl_log(gl_error, "%s", dlerror());
+        goto fail;
+    }
+
+    GLX_GET_PROC(choose_fb_config, glXChooseFBConfig);
+    GLX_GET_PROC(create_pbuffer, glXCreatePbuffer);
+    GLX_GET_PROC(destroy_pbuffer, glXDestroyPbuffer);
+    GLX_GET_PROC(create_context, glXCreateNewContext);
+    GLX_GET_PROC(destroy_context, glXDestroyContext);
+    GLX_GET_PROC(make_current, glXMakeContextCurrent);
+    GLX_GET_PROC(create_context_attribs, glXCreateContextAttribsARB);
+
+    configs = choose_fb_config(x_dpy,
+                               DefaultScreen(x_dpy),
+                               config_attribs,
+                               &n);
+
+    if (!configs || (n <= 0)) {
+        check_gl_log(gl_error, "Unable to find suitable FB config");
+        goto fail;
+    }
+
+    x_config = configs[0];
+
+    XFree(configs);
+
+    return 1;
+
+fail:
+    XCloseDisplay(x_dpy);
+
+    return 0;
+}
+
+void check_gl_cleanup(void)
+{
+    XCloseDisplay(x_dpy);
+}
+
+struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
+                                           gl_version version)
+{
+    static const int ctx_attribs_3_1[] =
+    {
+        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+        GLX_CONTEXT_MINOR_VERSION_ARB, 1,
+        GLX_RENDER_TYPE, GLX_RGBA_TYPE,
+        GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
+        None
+    };
+    static const int ctx_attribs_3_2[] =
+    {
+        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+        GLX_CONTEXT_MINOR_VERSION_ARB, 2,
+        GLX_RENDER_TYPE, GLX_RGBA_TYPE,
+        GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
+        None
+    };
+    static const int surface_attribs[] =
+    {
+        GLX_PBUFFER_WIDTH, 1,
+        GLX_PBUFFER_HEIGHT, 1,
+        GLX_LARGEST_PBUFFER, False,
+        None
+    };
+    GLXContext base;
+    GLXPbuffer sfc;
+    struct gl_context *ctx;
+
+    switch (version) {
+    case gl_2:
+        base = create_context(x_dpy,
+                              x_config,
+                              GLX_RGBA_TYPE,
+                              (share_ctx ? share_ctx->base : NULL),
+                              True);
+        break;
+    case gl_3_1:
+        base = create_context_attribs(x_dpy,
+                                      x_config,
+                                      (share_ctx ? share_ctx->base : NULL),
+                                      True,
+                                      ctx_attribs_3_1);
+        break;
+    case gl_3_2:
+        base = create_context_attribs(x_dpy,
+                                      x_config,
+                                      (share_ctx ? share_ctx->base : NULL),
+                                      True,
+                                      ctx_attribs_3_2);
+        break;
+    default:
+        assert(0);
+        return NULL;
+    }
+
+    if (!base) {
+        return NULL;
+    }
+
+    sfc = create_pbuffer(x_dpy,
+                         x_config,
+                         surface_attribs);
+
+    if (!sfc) {
+        destroy_context(x_dpy, base);
+        return NULL;
+    }
+
+    ctx = malloc(sizeof(*ctx));
+
+    if (!ctx) {
+        destroy_pbuffer(x_dpy, sfc);
+        destroy_context(x_dpy, base);
+        return NULL;
+    }
+
+    ctx->base = base;
+    ctx->sfc = sfc;
+
+    return ctx;
+}
+
+int check_gl_make_current(struct gl_context *ctx)
+{
+    return make_current(x_dpy,
+                        (ctx ? ctx->sfc : None),
+                        (ctx ? ctx->sfc : None),
+                        (ctx ? ctx->base : NULL));
+}
+
+void check_gl_context_destroy(struct gl_context *ctx)
+{
+    destroy_pbuffer(x_dpy, ctx->sfc);
+    destroy_context(x_dpy, ctx->base);
+    free(ctx);
+}
+
+int check_gl_procaddr(void **func, const char *sym, int opt)
+{
+    *func = (void*)get_proc_address((const GLubyte*)sym);
+
+    if (!*func) {
+        *func = dlsym(handle, sym);
+    }
+
+    if (!*func && !opt) {
+        check_gl_log(gl_error, "Unable to find symbol \"%s\"", sym);
+        return 0;
+    }
+
+    return 1;
+}
diff --git a/tizen/src/util/check_gl_wgl.c b/tizen/src/util/check_gl_wgl.c
new file mode 100644 (file)
index 0000000..e0a5b50
--- /dev/null
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 2011 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Stanislav Vorobiov <s.vorobiov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "check_gl.h"
+#include <windows.h>
+#include <wingdi.h>
+#include <GL/gl.h>
+#include <GL/wglext.h>
+#include <assert.h>
+#include <stdlib.h>
+
+#define WGL_GET_PROC(func, sym) \
+    do { \
+        *(void**)(&func) = (void*)GetProcAddress(handle, #sym); \
+        if (!func) { \
+            check_gl_log(gl_error, "Unable to load %s symbol", #sym); \
+            goto fail; \
+        } \
+    } while (0)
+
+#define WGL_GET_EXT_PROC(func, ext, sym) \
+    do { \
+        if ((strstr(ext_str, #ext " ") == NULL)) { \
+            check_gl_log(gl_error, "Extension %s not supported", #ext); \
+            goto fail; \
+        } \
+        *(void**)(&func) = (void*)get_proc_address((LPCSTR)#sym); \
+        if (!func) { \
+            check_gl_log(gl_error, "Unable to load %s symbol", #sym); \
+            goto fail; \
+        } \
+    } while (0)
+
+struct gl_context
+{
+    HGLRC base;
+    HPBUFFERARB sfc;
+    HDC sfc_dc;
+};
+
+typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTPROC)(HDC hdl);
+typedef BOOL (WINAPI *PFNWGLDELETECONTEXTPROC)(HGLRC hdl);
+typedef PROC (WINAPI *PFNWGLGETPROCADDRESSPROC)(LPCSTR sym);
+typedef BOOL (WINAPI *PFNWGLMAKECURRENTPROC)(HDC dev_ctx, HGLRC rend_ctx);
+typedef BOOL (WINAPI *PFNWGLSHARELISTSPROC)(HGLRC ctx1, HGLRC ctx2);
+
+static HINSTANCE handle = NULL;
+static HWND init_win = NULL;
+static HDC init_dc = NULL;
+static HGLRC init_ctx = NULL;
+static HWND win = NULL;
+static HDC dc = NULL;
+static int config_id = 0;
+static struct gl_context *current = NULL;
+static PFNWGLCREATECONTEXTPROC create_context;
+static PFNWGLDELETECONTEXTPROC delete_context;
+static PFNWGLGETPROCADDRESSPROC get_proc_address;
+static PFNWGLMAKECURRENTPROC make_current;
+static PFNWGLSHARELISTSPROC share_lists;
+
+/* WGL extensions */
+static PFNWGLGETEXTENSIONSSTRINGEXTPROC get_extensions_string_ext;
+static PFNWGLGETEXTENSIONSSTRINGARBPROC get_extensions_string_arb;
+static PFNWGLCHOOSEPIXELFORMATARBPROC choose_pixel_format;
+static PFNWGLCREATEPBUFFERARBPROC create_pbuffer;
+static PFNWGLGETPBUFFERDCARBPROC get_pbuffer_dc;
+static PFNWGLRELEASEPBUFFERDCARBPROC release_pbuffer_dc;
+static PFNWGLDESTROYPBUFFERARBPROC destroy_pbuffer;
+
+/* WGL_ARB_create_context */
+static PFNWGLCREATECONTEXTATTRIBSARBPROC create_context_attribs;
+
+int check_gl_init(void)
+{
+    WNDCLASSEXA win_class;
+    PIXELFORMATDESCRIPTOR init_pixfmt =
+    {
+        .nSize = sizeof(PIXELFORMATDESCRIPTOR),
+        .nVersion = 1,
+        .dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
+        .iPixelType = PFD_TYPE_RGBA,
+        .cColorBits = 32,
+        .cDepthBits = 24,
+        .cStencilBits = 8,
+        .iLayerType = PFD_MAIN_PLANE,
+    };
+    int init_config_id = 0;
+    const char *ext_str = NULL;
+    const int config_attribs[] =
+    {
+        WGL_SUPPORT_OPENGL_ARB, TRUE,
+        WGL_DOUBLE_BUFFER_ARB, TRUE,
+        WGL_DRAW_TO_PBUFFER_ARB, TRUE,
+        WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
+        WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
+        WGL_RED_BITS_ARB, 8,
+        WGL_GREEN_BITS_ARB, 8,
+        WGL_BLUE_BITS_ARB, 8,
+        WGL_ALPHA_BITS_ARB, 8,
+        WGL_COLOR_BITS_ARB, 32,
+        WGL_DEPTH_BITS_ARB, 24,
+        WGL_STENCIL_BITS_ARB, 8,
+        0,
+    };
+    UINT n = 0;
+    PIXELFORMATDESCRIPTOR pixfmt;
+
+    win_class.cbSize = sizeof(WNDCLASSEXA);
+    win_class.style = 0;
+    win_class.lpfnWndProc = &DefWindowProcA;
+    win_class.cbClsExtra = 0;
+    win_class.cbWndExtra = 0;
+    win_class.hInstance = NULL;
+    win_class.hIcon = NULL;
+    win_class.hCursor = NULL;
+    win_class.hbrBackground = NULL;
+    win_class.lpszMenuName =  NULL;
+    win_class.lpszClassName = "CheckGLWinClass";
+    win_class.hIconSm = NULL;
+
+    if (!RegisterClassExA(&win_class)) {
+        check_gl_log(gl_error, "Unable to register window class");
+        return 0;
+    }
+
+    handle = LoadLibraryA("opengl32");
+
+    if (!handle) {
+        check_gl_log(gl_error, "Unable to load opengl32.dll");
+        goto fail;
+    }
+
+    WGL_GET_PROC(create_context, wglCreateContext);
+    WGL_GET_PROC(delete_context, wglDeleteContext);
+    WGL_GET_PROC(get_proc_address, wglGetProcAddress);
+    WGL_GET_PROC(make_current, wglMakeCurrent);
+    WGL_GET_PROC(share_lists, wglShareLists);
+
+    init_win = CreateWindow("CheckGLWinClass", "CheckGLWin",
+                            WS_DISABLED | WS_POPUP,
+                            0, 0, 1, 1, NULL, NULL, 0, 0);
+
+    if (!init_win) {
+        check_gl_log(gl_error, "Unable to create window");
+        goto fail;
+    }
+
+    init_dc = GetDC(init_win);
+
+    if (!init_dc) {
+        check_gl_log(gl_error, "Unable to get window DC");
+        goto fail;
+    }
+
+    init_config_id = ChoosePixelFormat(init_dc, &init_pixfmt);
+
+    if (!init_config_id) {
+        check_gl_log(gl_error, "ChoosePixelFormat failed");
+        goto fail;
+    }
+
+    if (!SetPixelFormat(init_dc, init_config_id, &init_pixfmt)) {
+        check_gl_log(gl_error, "SetPixelFormat failed");
+        goto fail;
+    }
+
+    init_ctx = create_context(init_dc);
+    if (!init_ctx) {
+        check_gl_log(gl_error, "wglCreateContext failed");
+        goto fail;
+    }
+
+    if (!make_current(init_dc, init_ctx)) {
+        check_gl_log(gl_error, "wglMakeCurrent failed");
+        goto fail;
+    }
+
+    /*
+     * WGL extensions couldn't be queried by glGetString(), we need to use
+     * wglGetExtensionsStringARB or wglGetExtensionsStringEXT for this, which
+     * themselves are extensions
+     */
+    get_extensions_string_arb = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
+        get_proc_address((LPCSTR)"wglGetExtensionsStringARB");
+    get_extensions_string_ext = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
+        get_proc_address((LPCSTR)"wglGetExtensionsStringEXT");
+
+    if (get_extensions_string_arb) {
+        ext_str = get_extensions_string_arb(init_dc);
+    } else if (get_extensions_string_ext) {
+        ext_str = get_extensions_string_ext();
+    }
+
+    if (!ext_str) {
+        check_gl_log(gl_error, "Unable to obtain WGL extension string");
+        goto fail;
+    }
+
+    WGL_GET_EXT_PROC(create_pbuffer, WGL_ARB_pbuffer, wglCreatePbufferARB);
+    WGL_GET_EXT_PROC(get_pbuffer_dc, WGL_ARB_pbuffer, wglGetPbufferDCARB);
+    WGL_GET_EXT_PROC(release_pbuffer_dc, WGL_ARB_pbuffer, wglReleasePbufferDCARB);
+    WGL_GET_EXT_PROC(destroy_pbuffer, WGL_ARB_pbuffer, wglDestroyPbufferARB);
+    WGL_GET_EXT_PROC(choose_pixel_format, WGL_ARB_pixel_format, wglChoosePixelFormatARB);
+    WGL_GET_EXT_PROC(create_context_attribs, WGL_ARB_create_context, wglCreateContextAttribsARB);
+
+    make_current(NULL, NULL);
+
+    win = CreateWindow("CheckGLWinClass", "CheckGLWin2",
+                       WS_DISABLED | WS_POPUP,
+                       0, 0, 1, 1, NULL, NULL, 0, 0);
+
+    if (!win) {
+        check_gl_log(gl_error, "Unable to create window");
+        goto fail;
+    }
+
+    dc = GetDC(win);
+
+    if (!dc) {
+        check_gl_log(gl_error, "Unable to get window DC");
+        goto fail;
+    }
+
+    if (!choose_pixel_format(dc,
+                             config_attribs,
+                             NULL,
+                             1,
+                             &config_id,
+                             &n) || (n == 0)) {
+        check_gl_log(gl_error, "wglChoosePixelFormat failed");
+        goto fail;
+    }
+
+    if (!DescribePixelFormat(dc,
+                             config_id,
+                             sizeof(PIXELFORMATDESCRIPTOR),
+                             &pixfmt)) {
+        check_gl_log(gl_error, "DescribePixelFormat failed");
+        goto fail;
+    }
+
+    if (!SetPixelFormat(dc,
+                        config_id,
+                        &pixfmt)) {
+        check_gl_log(gl_error, "SetPixelFormat failed");
+        goto fail;
+    }
+
+    return 1;
+
+fail:
+    if (dc) {
+        ReleaseDC(win, dc);
+    }
+    if (win) {
+        DestroyWindow(win);
+    }
+    if (init_ctx) {
+        make_current(NULL, NULL);
+        delete_context(init_ctx);
+    }
+    if (init_dc) {
+        ReleaseDC(init_win, init_dc);
+    }
+    if (init_win) {
+        DestroyWindow(init_win);
+    }
+    if (handle) {
+        FreeLibrary(handle);
+    }
+
+    UnregisterClassA((LPCTSTR)"CheckGLWinClass", NULL);
+
+    return 0;
+}
+
+void check_gl_cleanup(void)
+{
+    ReleaseDC(win, dc);
+    DestroyWindow(win);
+    delete_context(init_ctx);
+    ReleaseDC(init_win, init_dc);
+    DestroyWindow(init_win);
+
+    UnregisterClassA((LPCTSTR)"CheckGLWinClass", NULL);
+}
+
+struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
+                                           gl_version version)
+{
+    static const int ctx_attribs_3_1[] =
+    {
+        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
+        WGL_CONTEXT_MINOR_VERSION_ARB, 1,
+        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+        0
+    };
+    static const int ctx_attribs_3_2[] =
+    {
+        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
+        WGL_CONTEXT_MINOR_VERSION_ARB, 2,
+        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+        0
+    };
+    static const int surface_attribs[] =
+    {
+        WGL_PBUFFER_LARGEST_ARB, FALSE,
+        WGL_TEXTURE_TARGET_ARB, WGL_NO_TEXTURE_ARB,
+        WGL_TEXTURE_FORMAT_ARB, WGL_NO_TEXTURE_ARB,
+        0
+    };
+    HGLRC base;
+    HPBUFFERARB sfc;
+    HDC sfc_dc;
+    struct gl_context *ctx;
+
+    switch (version) {
+    case gl_2:
+        base = create_context(dc);
+        if (share_ctx && !share_lists(share_ctx->base, base)) {
+            delete_context(base);
+            base = NULL;
+        }
+        break;
+    case gl_3_1:
+        base = create_context_attribs(dc,
+                                      (share_ctx ? share_ctx->base : NULL),
+                                      ctx_attribs_3_1);
+        break;
+    case gl_3_2:
+        base = create_context_attribs(dc,
+                                      (share_ctx ? share_ctx->base : NULL),
+                                      ctx_attribs_3_2);
+        break;
+    default:
+        assert(0);
+        return NULL;
+    }
+
+    if (!base) {
+        return NULL;
+    }
+
+    sfc = create_pbuffer(dc,
+                         config_id, 1, 1,
+                         surface_attribs);
+
+    if (!sfc) {
+        delete_context(base);
+        return NULL;
+    }
+
+    sfc_dc = get_pbuffer_dc(sfc);
+
+    if (!sfc_dc) {
+        destroy_pbuffer(sfc);
+        delete_context(base);
+        return NULL;
+    }
+
+    ctx = malloc(sizeof(*ctx));
+
+    if (!ctx) {
+        release_pbuffer_dc(sfc, sfc_dc);
+        destroy_pbuffer(sfc);
+        delete_context(base);
+        return NULL;
+    }
+
+    ctx->base = base;
+    ctx->sfc = sfc;
+    ctx->sfc_dc = sfc_dc;
+
+    return ctx;
+}
+
+int check_gl_make_current(struct gl_context *ctx)
+{
+    current = ctx;
+    return make_current((ctx ? ctx->sfc_dc : NULL),
+                        (ctx ? ctx->base : NULL));
+}
+
+void check_gl_context_destroy(struct gl_context *ctx)
+{
+    release_pbuffer_dc(ctx->sfc, ctx->sfc_dc);
+    destroy_pbuffer(ctx->sfc);
+    delete_context(ctx->base);
+    free(ctx);
+}
+
+int check_gl_procaddr(void **func, const char *sym, int opt)
+{
+    if (!make_current(init_dc, init_ctx)) {
+        return 0;
+    }
+
+    *func = (void*)get_proc_address((LPCSTR)sym);
+
+    if (!*func) {
+        *func = GetProcAddress(handle, sym);
+    }
+
+    make_current((current ? current->sfc_dc : NULL),
+                 (current ? current->base : NULL));
+
+    if (!*func && !opt) {
+        check_gl_log(gl_error, "Unable to find symbol \"%s\"", sym);
+        return 0;
+    }
+
+    return 1;
+}
diff --git a/tizen/src/util/check_hax.c b/tizen/src/util/check_hax.c
new file mode 100644 (file)
index 0000000..7c072e3
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * check if hax is available. reference:target-i386/hax-all.c
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * Hyunjun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#ifdef _WIN32
+#include <stdint.h>
+#include <errno.h>
+#include <windows.h>
+#include <winioctl.h>
+#endif
+
+#ifdef __APPLE__
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#endif
+
+
+
+#define HAX_MAX_VCPU 0x10
+
+#define HAX_CAP_STATUS_NOTWORKING  0x0
+#define HAX_CAP_WORKSTATUS_MASK 0x1
+#define HAX_CAP_FAILREASON_VT   0x1
+#define HAX_CAP_FAILREASON_NX   0x2
+
+#define HAX_CAP_MEMQUOTA    0x2
+
+#ifdef __APPLE__
+#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
+typedef int hax_fd;
+#endif
+
+#ifdef _WIN32
+#define HAX_DEVICE_TYPE 0x4000
+#define HAX_IOCTL_CAPABILITY    CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
+typedef HANDLE hax_fd;
+#endif
+
+struct hax_vm {
+    hax_fd fd;
+    int id;
+    struct hax_vcpu_state *vcpus[HAX_MAX_VCPU];
+};
+
+struct hax_state {
+    hax_fd fd; /* the global hax device interface */
+    uint32_t version;
+    struct hax_vm *vm;
+    uint64_t mem_quota;
+};
+
+struct hax_capabilityinfo {
+    /* bit 0: 1 - working
+     *        0 - not working, possibly because NT/NX disabled
+     * bit 1: 1 - memory limitation working
+     *        0 - no memory limitation
+     */
+    uint16_t wstatus;
+    /* valid when not working
+     * bit 0: VT not enabeld
+     * bit 1: NX not enabled*/
+    uint16_t winfo;
+    uint32_t pad;
+    uint64_t mem_quota;
+};
+#ifdef _WIN32
+static inline int hax_invalid_fd( hax_fd fd ) {
+    return ( fd == INVALID_HANDLE_VALUE );
+}
+#endif
+#ifdef __APPLE__
+static inline int hax_invalid_fd(hax_fd fd)
+{
+    return fd <= 0;
+}
+#endif
+
+
+static hax_fd hax_mod_open( void );
+static int hax_open_device( hax_fd *fd );
+static int hax_get_capability( struct hax_state *hax );
+static int hax_capability( struct hax_state *hax, struct hax_capabilityinfo *cap );
+
+static int check_hax( void ) {
+
+    struct hax_state hax;
+    memset( &hax, 0, sizeof( struct hax_state ) );
+
+    hax.fd = hax_mod_open();
+
+    int ret_fd = hax_invalid_fd( hax.fd );
+    if ( ret_fd ) {
+        fprintf( stderr, "Invalid fd:%d\n", ret_fd );
+        return ret_fd;
+    }
+
+    int ret_cap = hax_get_capability( &hax );
+    if ( ret_cap ) {
+        fprintf( stderr, "Not capable:%d\n", ret_cap );
+        return ret_cap;
+    }
+
+    return 0;
+
+}
+#ifdef _WIN32
+static int hax_open_device( hax_fd *fd ) {
+    uint32_t errNum = 0;
+    HANDLE hDevice;
+
+    if ( !fd )
+        return -2;
+
+    hDevice = CreateFile( "\\\\.\\HAX", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
+        NULL );
+
+    if ( hDevice == INVALID_HANDLE_VALUE ) {
+        fprintf( stderr, "Failed to open the HAX device!\n" );
+        errNum = GetLastError();
+        if ( errNum == ERROR_FILE_NOT_FOUND )
+            return -1;
+        return -2;
+    }
+    *fd = hDevice;
+    fprintf( stdout, "device fd:%d\n", *fd );
+    return 0;
+}
+
+static hax_fd hax_mod_open( void ) {
+    int ret;
+    hax_fd fd;
+
+    ret = hax_open_device( &fd );
+    if ( ret != 0 ) {
+        fprintf( stderr, "Open HAX device failed\n" );
+    }
+
+    return fd;
+}
+#else
+static hax_fd hax_mod_open(void)
+{
+    int fd = open("/dev/HAX", O_RDWR);
+
+    if (fd == -1)
+    {
+        fprintf(stderr, "hahFailed to open the hax module\n");
+        //return -errno;
+    }
+
+    return fd;
+}
+
+#endif
+
+static int hax_get_capability( struct hax_state *hax ) {
+    int ret;
+    struct hax_capabilityinfo capinfo, *cap = &capinfo;
+
+    ret = hax_capability( hax, cap );
+    if ( ret )
+        return ret;
+
+    if ( ( ( cap->wstatus & HAX_CAP_WORKSTATUS_MASK ) == HAX_CAP_STATUS_NOTWORKING ) ) {
+        if ( cap->winfo & HAX_CAP_FAILREASON_VT )
+            fprintf( stderr, "VTX feature is not enabled. which will cause HAX driver not working.\n" );
+        else if ( cap->winfo & HAX_CAP_FAILREASON_NX )
+            fprintf( stderr, "NX feature is not enabled, which will cause HAX driver not working.\n" );
+        return -ENXIO;
+    }
+
+/*
+    if ( cap->wstatus & HAX_CAP_MEMQUOTA ) {
+        if ( cap->mem_quota < hax->mem_quota ) {
+            fprintf( stderr, "The memory needed by this VM exceeds the driver limit.\n" );
+            return -ENOSPC;
+        }
+    }
+*/
+    return 0;
+}
+#ifdef _WIN32
+static int hax_capability( struct hax_state *hax, struct hax_capabilityinfo *cap ) {
+    int ret;
+    HANDLE hDevice = hax->fd; //handle to hax module
+    DWORD dSize = 0;
+    DWORD err = 0;
+
+    if ( hax_invalid_fd( hDevice ) ) {
+        fprintf( stderr, "Invalid fd for hax device!\n" );
+        return -ENODEV;
+    }
+
+    ret = DeviceIoControl( hDevice, HAX_IOCTL_CAPABILITY, NULL, 0, cap, sizeof( *cap ), &dSize, ( LPOVERLAPPED ) NULL );
+
+    if ( !ret ) {
+        err = GetLastError();
+        if ( err == ERROR_INSUFFICIENT_BUFFER || err == ERROR_MORE_DATA )
+            fprintf( stderr, "hax capability is too long to hold.\n" );
+        fprintf( stderr, "Failed to get Hax capability:%d\n", err );
+        return -EFAULT;
+    } else
+        return 0;
+
+}
+#endif
+
+#ifdef __APPLE__
+int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
+{
+    int ret;
+
+    ret = ioctl(hax->fd, HAX_IOCTL_CAPABILITY, cap);
+    if (ret == -1)
+    {
+        fprintf(stderr, "Failed to get HAX capability\n");
+        return -errno;
+    }
+
+    return 0;
+}
+#endif
+
+int main(int argc, char* argv[]) {
+    return check_hax();
+}
diff --git a/tizen/src/util/osutil-darwin.c b/tizen/src/util/osutil-darwin.c
new file mode 100644 (file)
index 0000000..74a4182
--- /dev/null
@@ -0,0 +1,398 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+/**
+  @file     osutil-darwin.c
+  @brief    Collection of utilities for darwin
+ */
+
+#include "maru_common.h"
+#include "osutil.h"
+#include "emulator.h"
+#include "debug_ch.h"
+#include "maru_err_table.h"
+#include "sdb.h"
+
+#ifndef CONFIG_DARWIN
+#error
+#endif
+
+#include <string.h>
+#include <sys/shm.h>
+#include <sys/sysctl.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
+MULTI_DEBUG_CHANNEL(qemu, osutil);
+
+
+static qemu_timeval tv = { 0, 0 };
+static time_t ti;
+static char buf_time[64];
+static int g_shmid;
+static CFDictionaryRef proxySettings;
+
+extern char tizen_target_img_path[];
+
+static char *cfstring_to_cstring(CFStringRef str) {
+    if (str == NULL) {
+        return NULL;
+    }
+
+    CFIndex length = CFStringGetLength(str);
+    CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
+    char *buffer = (char *)malloc(maxSize);
+    if (CFStringGetCString(str, buffer, maxSize, kCFStringEncodingUTF8))
+        return buffer;
+    return NULL;
+}
+
+static int cfnumber_to_int(CFNumberRef num) {
+    if (!num)
+        return 0;
+
+    int value;
+    CFNumberGetValue(num, kCFNumberIntType, &value);
+    return value;
+}
+
+void check_vm_lock_os(void)
+{
+    /* TODO: */
+}
+
+void make_vm_lock_os(void)
+{
+    char *shared_memory;
+    int base_port;
+    base_port = get_emul_vm_base_port();
+    g_shmid = shmget((key_t)base_port, MAXLEN, 0666|IPC_CREAT);
+    if (g_shmid == -1) {
+        ERR("shmget failed\n");
+        perror("osutil-darwin: ");
+        return;
+    }
+
+    shared_memory = shmat(g_shmid, (char *)0x00, 0);
+    if (shared_memory == (void *)-1) {
+        ERR("shmat failed\n");
+        perror("osutil-darwin: ");
+        return;
+    }
+    g_sprintf(shared_memory, "%s", tizen_target_img_path);
+    INFO("shared memory key: %d, value: %s\n", base_port, (char *)shared_memory);
+
+    if (shmdt(shared_memory) == -1) {
+        ERR("shmdt failed\n");
+        perror("osutil-darwin: ");
+    }
+
+}
+
+void remove_vm_lock_os(void)
+{
+    if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
+        ERR("shmctl failed\n");
+        perror("osutil-linux: ");
+    }
+}
+
+void set_bin_path_os(gchar * exec_argv)
+{
+    gchar *file_name = NULL;
+
+    if (!exec_argv) {
+        return;
+    }
+
+    char *data = g_strdup(exec_argv);
+    if (!data) {
+        ERR("Fail to strdup for paring a binary directory.\n");
+        return;
+    }
+
+    file_name = g_strrstr(data, "/");
+    if (!file_name) {
+        free(data);
+        return;
+    }
+
+    g_strlcpy(bin_path, data, strlen(data) - strlen(file_name) + 1);
+
+    g_strlcat(bin_path, "/", PATH_MAX);
+    free(data);
+}
+
+int get_number_of_processors(void)
+{
+    int mib[2], sys_num = 0;
+    size_t len;
+
+    mib[0] = CTL_HW;
+    mib[1] = HW_AVAILCPU;
+
+    sysctl(mib, 2, &sys_num, &len, NULL, 0);
+    if (sys_num < 1) {
+        mib[1] = HW_NCPU;
+        sysctl(mib, 2, &sys_num, &len, NULL, 0);
+
+        if (sys_num < 1) {
+            sys_num = 1;
+        }
+    }
+    INFO("* Number of processors : %d\n", sys_num);
+
+    return sys_num;
+}
+
+void print_system_info_os(void)
+{
+    INFO("* Mac\n");
+
+    /* uname */
+    INFO("* Host machine uname :\n");
+    char uname_cmd[MAXLEN] = "uname -a";
+    if(system(uname_cmd) < 0) {
+        INFO("system function command '%s' \
+            returns error !", uname_cmd);
+    }
+
+    /* hw information */
+    int mib[2];
+    size_t len;
+    char *sys_info;
+    int sys_num = 0;
+
+    mib[0] = CTL_HW;
+    mib[1] = HW_MODEL;
+    sysctl(mib, 2, NULL, &len, NULL, 0);
+    sys_info = malloc(len * sizeof(char));
+    if (sysctl(mib, 2, sys_info, &len, NULL, 0) >= 0) {
+        INFO("* Machine model : %s\n", sys_info);
+    }
+    free(sys_info);
+
+    mib[0] = CTL_HW;
+    mib[1] = HW_MACHINE;
+    sysctl(mib, 2, NULL, &len, NULL, 0);
+    sys_info = malloc(len * sizeof(char));
+    if (sysctl(mib, 2, sys_info, &len, NULL, 0) >= 0) {
+        INFO("* Machine class : %s\n", sys_info);
+    }
+    free(sys_info);
+
+#if 0
+    mib[0] = CTL_HW;
+    mib[1] = HW_NCPU;
+    len = sizeof(sys_num);
+    if (sysctl(mib, 2, &sys_num, &len, NULL, 0) >= 0) {
+        INFO("* Number of processors : %d\n", sys_num);
+    }
+#endif
+    get_number_of_processors();
+
+    mib[0] = CTL_HW;
+    mib[1] = HW_PHYSMEM;
+    len = sizeof(sys_num);
+    if (sysctl(mib, 2, &sys_num, &len, NULL, 0) >= 0) {
+        INFO("* Total memory : %llu bytes\n", sys_num);
+    }
+
+    /* java version */
+    INFO("* Java version :\n");
+    char lspci_cmd[MAXLEN] = "java -version";
+
+    fflush(stdout);
+    if(system(lspci_cmd) < 0) {
+        INFO("system function command '%s' \
+            returns error !", lspci_cmd);
+    }
+}
+
+char *get_timeofday(void)
+{
+    qemu_gettimeofday(&tv);
+    ti = tv.tv_sec;
+
+    struct tm tm;
+    localtime_r(&ti, &tm);
+    strftime(buf_time, sizeof(buf_time),
+             "%H:%M:%S", &tm);
+
+    return buf_time;
+}
+
+static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    char type[MAXLEN];
+    char proxy[MAXLEN];
+    char line[MAXLEN];
+    FILE *fp_pacfile;
+    char *p = NULL;
+
+    CFStringRef pacURL = (CFStringRef)CFDictionaryGetValue(proxySettings,
+                    kSCPropNetProxiesProxyAutoConfigURLString);
+    if (pacURL) {
+        char url[MAXLEN] = {};
+        CFStringGetCString(pacURL, url, sizeof url, kCFStringEncodingASCII);
+                INFO("pac address: %s\n", (char*)url);
+        download_url(url);
+        }
+
+    fp_pacfile = fopen(pac_tempfile, "r");
+    if(fp_pacfile != NULL) {
+        while(fgets(line, MAXLEN, fp_pacfile) != NULL) {
+            if( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
+                INFO("line found %s", line);
+                sscanf(line, "%*[^\"]\"%s %s", type, proxy);
+            }
+        }
+
+        if(g_str_has_prefix(type, DIRECT)) {
+            INFO("auto proxy is set to direct mode\n");
+            fclose(fp_pacfile);
+        }
+        else if(g_str_has_prefix(type, PROXY)) {
+            INFO("auto proxy is set to proxy mode\n");
+            INFO("type: %s, proxy: %s\n", type, proxy);
+            p = strtok(proxy, "\";");
+            if(p != NULL) {
+                INFO("auto proxy to set: %s\n",p);
+                strcpy(http_proxy, p);
+                strcpy(https_proxy, p);
+                strcpy(ftp_proxy, p);
+                strcpy(socks_proxy, p);
+            }
+            fclose(fp_pacfile);
+        }
+        else
+        {
+            ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
+            fclose(fp_pacfile);
+        }
+    }
+    else {
+        ERR("fail to get pacfile fp\n");
+    return -1;
+    }
+
+    remove(pac_tempfile);
+    return 0;
+}
+
+static void get_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    char *hostname;
+    int port;
+    CFNumberRef isEnable;
+    CFStringRef proxyHostname;
+    CFNumberRef proxyPort;
+    CFDictionaryRef proxySettings;
+    proxySettings = SCDynamicStoreCopyProxies(NULL);
+
+    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPEnable);
+    if (cfnumber_to_int(isEnable)) {
+        // Get proxy hostname
+        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPProxy);
+        hostname = cfstring_to_cstring(proxyHostname);
+        // Get proxy port
+        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPPort);
+        port = cfnumber_to_int(proxyPort);
+        // Save hostname & port
+        snprintf(http_proxy, MAXLEN, "%s:%d", hostname, port);
+
+        free(hostname);
+    } else {
+        INFO("http proxy is null\n");
+    }
+
+    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSEnable);
+    if (cfnumber_to_int(isEnable)) {
+        // Get proxy hostname
+        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSProxy);
+        hostname = cfstring_to_cstring(proxyHostname);
+        // Get proxy port
+        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSPort);
+        port = cfnumber_to_int(proxyPort);
+        // Save hostname & port
+        snprintf(https_proxy, MAXLEN, "%s:%d", hostname, port);
+
+        free(hostname);
+    } else {
+        INFO("https proxy is null\n");
+    }
+
+    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPEnable);
+    if (cfnumber_to_int(isEnable)) {
+        // Get proxy hostname
+        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPProxy);
+        hostname = cfstring_to_cstring(proxyHostname);
+        // Get proxy port
+        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPPort);
+        port = cfnumber_to_int(proxyPort);
+        // Save hostname & port
+        snprintf(ftp_proxy, MAXLEN, "%s:%d", hostname, port);
+
+        free(hostname);
+    } else {
+        INFO("ftp proxy is null\n");
+    }
+
+    isEnable  = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSEnable);
+    if (cfnumber_to_int(isEnable)) {
+        // Get proxy hostname
+        proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSProxy);
+        hostname = cfstring_to_cstring(proxyHostname);
+        // Get proxy port
+        proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSPort);
+        port = cfnumber_to_int(proxyPort);
+        // Save hostname & port
+        snprintf(socks_proxy, MAXLEN, "%s:%d", hostname, port);
+
+        free(hostname);
+    } else {
+        INFO("socks proxy is null\n");
+    }
+    CFRelease(proxySettings);
+}
+
+void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    int ret;
+    proxySettings = SCDynamicStoreCopyProxies(NULL);
+    if(proxySettings) {
+        INFO("AUTO PROXY MODE\n");
+        ret = get_auto_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+        if(strlen(http_proxy) == 0 && ret < 0) {
+            INFO("MANUAL PROXY MODE\n");
+            get_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+        }
+    }
+}
diff --git a/tizen/src/util/osutil-linux.c b/tizen/src/util/osutil-linux.c
new file mode 100644 (file)
index 0000000..8ebbb89
--- /dev/null
@@ -0,0 +1,465 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2012 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+/**
+  @file     osutil-linux.c
+  @brief    Collection of utilities for linux
+ */
+
+#include <png.h>
+#include "maru_common.h"
+#include "osutil.h"
+#include "emulator.h"
+#include "debug_ch.h"
+#include "maru_err_table.h"
+#include "sdb.h"
+
+#ifndef CONFIG_LINUX
+#error
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+#include <linux/version.h>
+#include <sys/utsname.h>
+#include <sys/sysinfo.h>
+
+MULTI_DEBUG_CHANNEL(emulator, osutil);
+
+
+static qemu_timeval tv = { 0, 0 };
+static time_t ti;
+static char buf_time[64];
+
+static int g_shmid;
+static char *g_shared_memory;
+static int gproxytool = GSETTINGS;
+
+extern char tizen_target_img_path[];
+
+/* Getting proxy commands */
+static const char* gproxycmds[][2] = {
+    { "gconftool-2 -g /system/proxy/mode" , "gsettings get org.gnome.system.proxy mode" },
+    { "gconftool-2 -g /system/proxy/autoconfig_url", "gsettings get org.gnome.system.proxy autoconfig-url" },
+    { "gconftool-2 -g /system/http_proxy/host", "gsettings get org.gnome.system.proxy.http host" },
+    { "gconftool-2 -g /system/http_proxy/port", "gsettings get org.gnome.system.proxy.http port"},
+    { "gconftool-2 -g /system/proxy/secure_host", "gsettings get org.gnome.system.proxy.https host" },
+    { "gconftool-2 -g /system/proxy/secure_port", "gsettings get org.gnome.system.proxy.https port" },
+    { "gconftool-2 -g /system/proxy/ftp_host", "gsettings get org.gnome.system.proxy.ftp host" },
+    { "gconftool-2 -g /system/proxy/ftp_port", "gsettings get org.gnome.system.proxy.ftp port" },
+    { "gconftool-2 -g /system/proxy/socks_host", "gsettings get org.gnome.system.proxy.socks host" },
+    { "gconftool-2 -g /system/proxy/socks_port", "gsettings get org.gnome.system.proxy.socks port" },
+};
+
+void check_vm_lock_os(void)
+{
+    int shm_id;
+    void *shm_addr;
+    uint32_t port;
+    int val;
+    struct shmid_ds shm_info;
+
+    for (port = 26100; port < 26200; port += 10) {
+        shm_id = shmget((key_t)port, 0, 0);
+        if (shm_id != -1) {
+            shm_addr = shmat(shm_id, (void *)0, 0);
+            if ((void *)-1 == shm_addr) {
+                ERR("error occured at shmat()\n");
+                break;
+            }
+
+            val = shmctl(shm_id, IPC_STAT, &shm_info);
+            if (val != -1) {
+                INFO("count of process that use shared memory : %d\n",
+                    shm_info.shm_nattch);
+                if ((shm_info.shm_nattch > 0) &&
+                    g_strcmp0(tizen_target_img_path, (char *)shm_addr) == 0) {
+                    if (check_port_bind_listen(port + 1) > 0) {
+                        shmdt(shm_addr);
+                        continue;
+                    }
+                    shmdt(shm_addr);
+                    maru_register_exit_msg(MARU_EXIT_UNKNOWN,
+                                        "Can not execute this VM.\n"
+                                        "The same name is running now.");
+                    exit(0);
+                } else {
+                    shmdt(shm_addr);
+                }
+            }
+        }
+    }
+}
+
+void make_vm_lock_os(void)
+{
+    int base_port;
+
+    base_port = get_emul_vm_base_port();
+
+    g_shmid = shmget((key_t)base_port, MAXLEN, 0666|IPC_CREAT);
+    if (g_shmid == -1) {
+        ERR("shmget failed\n");
+        perror("osutil-linux: ");
+        return;
+    }
+
+    g_shared_memory = shmat(g_shmid, (char *)0x00, 0);
+    if (g_shared_memory == (void *)-1) {
+        ERR("shmat failed\n");
+        perror("osutil-linux: ");
+        return;
+    }
+
+    g_sprintf(g_shared_memory, "%s", tizen_target_img_path);
+    INFO("shared memory key: %d value: %s\n",
+        base_port, (char *)g_shared_memory);
+
+    if (shmdt(g_shared_memory) == -1) {
+        ERR("shmdt failed\n");
+        perror("osutil-linux: ");
+    }
+}
+
+void remove_vm_lock_os(void)
+{
+    if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
+        ERR("shmctl failed\n");
+        perror("osutil-linux: ");
+    }
+}
+
+
+void set_bin_path_os(gchar * exec_argv)
+{
+    gchar link_path[PATH_MAX] = { 0, };
+    char *file_name = NULL;
+
+    ssize_t len = readlink("/proc/self/exe", link_path, sizeof(link_path) - 1);
+
+    if (len < 0 || len > (sizeof(link_path) - 1)) {
+        perror("set_bin_path error : ");
+        return;
+    }
+
+    link_path[len] = '\0';
+
+    file_name = g_strrstr(link_path, "/");
+    g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
+
+    g_strlcat(bin_path, "/", PATH_MAX);
+}
+
+int get_number_of_processors(void)
+{
+    int num_processors = 0;
+
+    num_processors = sysconf(_SC_NPROCESSORS_ONLN);
+    if (num_processors < 1) {
+        num_processors = 1;
+    }
+    TRACE("Number of processors : %d\n", num_processors);
+
+    return num_processors;
+}
+
+void print_system_info_os(void)
+{
+    INFO("* Linux\n");
+
+    INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING);
+
+    /* depends on building */
+    INFO("* QEMU build machine linux kernel version : (%d, %d, %d)\n",
+        LINUX_VERSION_CODE >> 16,
+        (LINUX_VERSION_CODE >> 8) & 0xff,
+        LINUX_VERSION_CODE & 0xff);
+
+     /* depends on launching */
+    struct utsname host_uname_buf;
+    if (uname(&host_uname_buf) == 0) {
+        INFO("* Host machine uname : %s %s %s %s %s\n",
+            host_uname_buf.sysname, host_uname_buf.nodename,
+            host_uname_buf.release, host_uname_buf.version,
+            host_uname_buf.machine);
+    }
+
+    struct sysinfo sys_info;
+    if (sysinfo(&sys_info) == 0) {
+        INFO("* Total Ram : %llu kB, Free: %llu kB\n",
+            sys_info.totalram * (unsigned long long)sys_info.mem_unit / 1024,
+            sys_info.freeram * (unsigned long long)sys_info.mem_unit / 1024);
+    }
+
+    /* get linux distribution information */
+    INFO("* Linux distribution infomation :\n");
+    const gchar lsb_release_cmd[MAXLEN] = "lsb_release -d -r -c";
+    gchar *buffer = NULL;
+    gint buffer_size = strlen(lsb_release_cmd) + 1;
+
+    buffer = g_malloc(buffer_size);
+
+    g_snprintf(buffer, buffer_size, "%s", lsb_release_cmd);
+
+    if (system(buffer) < 0) {
+        INFO("system function command '%s' \
+                returns error !", buffer);
+    }
+    g_free(buffer);
+
+    /* pci device description */
+    INFO("* Host PCI devices :\n");
+    const gchar lspci_cmd[MAXLEN] = "lspci";
+    buffer_size = strlen(lspci_cmd) + 1;
+
+    buffer = g_malloc(buffer_size);
+
+    g_snprintf(buffer, buffer_size, "%s", lspci_cmd);
+
+    fflush(stdout);
+    if (system(buffer) < 0) {
+        INFO("system function command '%s' \
+                returns error !", buffer);
+    }
+    g_free(buffer);
+}
+
+char *get_timeofday(void)
+{
+    qemu_gettimeofday(&tv);
+    ti = tv.tv_sec;
+
+    struct tm tm;
+    localtime_r(&ti, &tm);
+    strftime(buf_time, sizeof(buf_time),
+             "%H:%M:%S", &tm);
+
+    return buf_time;
+}
+
+static void process_string(char *buf)
+{
+    char tmp_buf[MAXLEN];
+
+    /* remove single quotes of strings gotten by gsettings */
+    if (gproxytool == GSETTINGS) {
+        remove_string(buf, tmp_buf, "\'");
+        memset(buf, 0, MAXLEN);
+        strncpy(buf, tmp_buf, strlen(tmp_buf)-1);
+    }
+}
+
+static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    char type[MAXLEN];
+    char proxy[MAXLEN];
+    char line[MAXLEN];
+    FILE *fp_pacfile;
+    char *p = NULL;
+    FILE *output;
+    char buf[MAXLEN];
+
+    output = popen(gproxycmds[GNOME_PROXY_AUTOCONFIG_URL][gproxytool], "r");
+    if (fscanf(output, "%s", buf) > 0) {
+        process_string(buf);
+        INFO("pac address: %s\n", buf);
+        download_url(buf);
+    }
+
+    pclose(output);
+    fp_pacfile = fopen(pac_tempfile, "r");
+    if (fp_pacfile != NULL) {
+        while (fgets(line, MAXLEN, fp_pacfile) != NULL) {
+            if ((strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
+                INFO("line found %s", line);
+                sscanf(line, "%*[^\"]\"%s %s", type, proxy);
+            }
+        }
+
+        if (g_str_has_prefix(type, DIRECT)) {
+            INFO("auto proxy is set to direct mode\n");
+            fclose(fp_pacfile);
+        } else if (g_str_has_prefix(type, PROXY)) {
+            INFO("auto proxy is set to proxy mode\n");
+            INFO("type: %s, proxy: %s\n", type, proxy);
+
+            p = strtok(proxy, "\";");
+            if (p != NULL) {
+                INFO("auto proxy to set: %s\n",p);
+                strcpy(http_proxy, p);
+                strcpy(https_proxy, p);
+                strcpy(ftp_proxy, p);
+                strcpy(socks_proxy, p);
+            }
+            fclose(fp_pacfile);
+        } else {
+            ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
+            fclose(fp_pacfile);
+        }
+    } else {
+        ERR("fail to get pacfile fp\n");
+        return -1;
+    }
+
+    if (remove(pac_tempfile) < 0) {
+        WARN("fail to remove the temporary pacfile\n");
+    }
+
+    return 0;
+}
+
+static void get_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    char buf[MAXLEN] = {0,};
+    char buf_port[MAXPORTLEN] = {0,};
+    char buf_proxy[MAXLEN] = {0,};
+    char *buf_proxy_bak;
+    char *proxy;
+    FILE *output;
+    int MAXPROXYLEN = MAXLEN + MAXPORTLEN;
+
+    output = popen(gproxycmds[GNOME_PROXY_HTTP_HOST][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        process_string(buf);
+        snprintf(buf_proxy, MAXLEN, "%s", buf);
+    }
+    pclose(output);
+
+    output = popen(gproxycmds[GNOME_PROXY_HTTP_PORT][gproxytool], "r");
+    if(fscanf(output, "%s", buf_port) <= 0) {
+        //for abnormal case: if can't find the key of http port, get from environment value.
+        buf_proxy_bak = getenv("http_proxy");
+        INFO("http_proxy from env: %s\n", buf_proxy_bak);
+        if(buf_proxy_bak != NULL) {
+            proxy = malloc(MAXLEN);
+            remove_string(buf_proxy_bak, proxy, HTTP_PREFIX);
+            strncpy(http_proxy, proxy, strlen(proxy)-1);
+            INFO("final http_proxy value: %s\n", http_proxy);
+            free(proxy);
+        }
+        else {
+            INFO("http_proxy is not set on env.\n");
+            pclose(output);
+            return;
+        }
+
+    }
+    else {
+        snprintf(http_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf_port);
+        memset(buf_proxy, 0, MAXLEN);
+        INFO("http_proxy: %s\n", http_proxy);
+    }
+    pclose(output);
+
+    memset(buf, 0, MAXLEN);
+
+    output = popen(gproxycmds[GNOME_PROXY_HTTPS_HOST][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        process_string(buf);
+        snprintf(buf_proxy, MAXLEN, "%s", buf);
+    }
+    pclose(output);
+
+    output = popen(gproxycmds[GNOME_PROXY_HTTPS_PORT][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        snprintf(https_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
+    }
+    pclose(output);
+    memset(buf, 0, MAXLEN);
+    memset(buf_proxy, 0, MAXLEN);
+    INFO("https_proxy : %s\n", https_proxy);
+
+    output = popen(gproxycmds[GNOME_PROXY_FTP_HOST][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        process_string(buf);
+        snprintf(buf_proxy, MAXLEN, "%s", buf);
+    }
+    pclose(output);
+
+    output = popen(gproxycmds[GNOME_PROXY_FTP_PORT][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        snprintf(ftp_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
+    }
+    pclose(output);
+    memset(buf, 0, MAXLEN);
+    memset(buf_proxy, 0, MAXLEN);
+    INFO("ftp_proxy : %s\n", ftp_proxy);
+
+    output = popen(gproxycmds[GNOME_PROXY_SOCKS_HOST][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        process_string(buf);
+        snprintf(buf_proxy, MAXLEN, "%s", buf);
+    }
+    pclose(output);
+
+    output = popen(gproxycmds[GNOME_PROXY_SOCKS_PORT][gproxytool], "r");
+    if(fscanf(output, "%s", buf) > 0) {
+        snprintf(socks_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
+    }
+    pclose(output);
+    INFO("socks_proxy : %s\n", socks_proxy);
+}
+
+
+void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    char buf[MAXLEN];
+    FILE *output;
+    int ret;
+
+    output = popen(gproxycmds[GNOME_PROXY_MODE][gproxytool], "r");
+    ret = fscanf(output, "%s", buf);
+    if (ret <= 0) {
+        pclose(output);
+        INFO("Try to use gsettings to get proxy\n");
+        gproxytool = GSETTINGS;
+        output = popen(gproxycmds[GNOME_PROXY_MODE][gproxytool], "r");
+        ret = fscanf(output, "%s", buf);
+    }
+    if (ret > 0) {
+        process_string(buf);
+        //priority : auto > manual > none
+        if (strcmp(buf, "auto") == 0) {
+            INFO("AUTO PROXY MODE\n");
+            get_auto_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+        }
+        else if (strcmp(buf, "manual") == 0) {
+            INFO("MANUAL PROXY MODE\n");
+            get_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+        }
+        else if (strcmp(buf, "none") == 0) {
+            INFO("DIRECT PROXY MODE\n");
+        }
+    }
+    pclose(output);
+}
diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c
new file mode 100644 (file)
index 0000000..457279b
--- /dev/null
@@ -0,0 +1,411 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+/**
+  @file     osutil-win32.c
+  @brief    Collection of utilities for win32
+ */
+
+#include <png.h>
+#include "maru_common.h"
+#include "osutil.h"
+#include "emulator.h"
+#include "debug_ch.h"
+#include "maru_err_table.h"
+#include "sdb.h"
+
+#ifndef CONFIG_WIN32
+#error
+#endif
+
+#include <windows.h>
+
+MULTI_DEBUG_CHANNEL (emulator, osutil);
+
+
+static qemu_timeval tv = { 0, 0 };
+static time_t ti;
+static char buf_time[64];
+static HANDLE g_hMapFile;
+static char *g_pBuf;
+
+extern char tizen_target_img_path[];
+
+static const char *pactempfile = ".autoproxy";
+
+void check_vm_lock_os(void)
+{
+    uint32_t port;
+    char *base_port = NULL;
+    char *pBuf;
+    HANDLE hMapFile;
+
+    for (port = 26100; port < 26200; port += 10) {
+        base_port = g_strdup_printf("%d", port);
+        hMapFile = OpenFileMapping(FILE_MAP_READ, TRUE, base_port);
+        if (hMapFile == NULL) {
+            INFO("port %s is not used.\n", base_port);
+            continue;
+        } else {
+             pBuf = (char *)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 50);
+            if (pBuf == NULL) {
+                ERR("Could not map view of file (%d).\n", GetLastError());
+                CloseHandle(hMapFile);
+            }
+
+            if (strcmp(pBuf, tizen_target_img_path) == 0) {
+                maru_register_exit_msg(MARU_EXIT_UNKNOWN,
+                    "Can not execute this VM.\n"
+                    "The same name is running now.");
+                UnmapViewOfFile(pBuf);
+                CloseHandle(hMapFile);
+                free(base_port);
+                exit(0);
+            } else {
+                UnmapViewOfFile(pBuf);
+            }
+        }
+
+        CloseHandle(hMapFile);
+        free(base_port);
+    }
+}
+
+void make_vm_lock_os(void)
+{
+    char *port_in_use;
+    char *shared_memory;
+    int base_port;
+
+    base_port = get_emul_vm_base_port();
+    shared_memory = g_strdup_printf("%s", tizen_target_img_path);
+    port_in_use =  g_strdup_printf("%d", base_port);
+    g_hMapFile = CreateFileMapping(
+                 INVALID_HANDLE_VALUE, /* use paging file */
+                 NULL,                 /* default security */
+                 PAGE_READWRITE,       /* read/write access */
+                 0,                /* maximum object size (high-order DWORD) */
+                 50,               /* maximum object size (low-order DWORD) */
+                 port_in_use);         /* name of mapping object */
+    if (g_hMapFile == NULL) {
+        ERR("Could not create file mapping object (%d).\n", GetLastError());
+        return;
+    }
+
+    g_pBuf = MapViewOfFile(g_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 50);
+    if (g_pBuf == NULL) {
+        ERR("Could not map view of file (%d).\n", GetLastError());
+        CloseHandle(g_hMapFile);
+        return;
+    }
+
+    CopyMemory((PVOID)g_pBuf, shared_memory, strlen(shared_memory));
+    free(port_in_use);
+    free(shared_memory);
+}
+
+void remove_vm_lock_os(void)
+{
+    if (g_pBuf != NULL) {
+        UnmapViewOfFile(g_pBuf);
+    }
+    if (g_hMapFile != NULL) {
+        CloseHandle(g_hMapFile);
+    }
+}
+
+
+void set_bin_path_os(gchar * exec_argv)
+{
+    gchar link_path[PATH_MAX] = { 0, };
+    gchar *file_name = NULL;
+
+    if (!GetModuleFileName(NULL, link_path, PATH_MAX)) {
+        return;
+    }
+
+    file_name = g_strrstr(link_path, "\\");
+    g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
+
+    g_strlcat(bin_path, "\\", PATH_MAX);
+}
+
+int get_number_of_processors(void)
+{
+    SYSTEM_INFO sysi;
+    int num_processors = 0;
+
+    GetSystemInfo(&sysi);
+    TRACE("Processor type: %d, Core number: %d\n",
+        sysi.dwProcessorType, sysi.dwNumberOfProcessors);
+
+    num_processors = sysi.dwNumberOfProcessors;
+    if (num_processors < 1) {
+        num_processors = 1;
+    }
+
+    return num_processors;
+}
+
+void print_system_info_os(void)
+{
+    INFO("* Windows\n");
+
+    INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING);
+
+    /* Retrieves information about the current os */
+    OSVERSIONINFO osvi;
+    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+    if (GetVersionEx(&osvi)) {
+        INFO("* MajorVersion : %d, MinorVersion : %d, BuildNumber : %d, "
+            "PlatformId : %d, CSDVersion : %s\n", osvi.dwMajorVersion,
+            osvi.dwMinorVersion, osvi.dwBuildNumber,
+            osvi.dwPlatformId, osvi.szCSDVersion);
+    }
+
+    /* Retrieves information about the current system */
+    SYSTEM_INFO sysi;
+    ZeroMemory(&sysi, sizeof(SYSTEM_INFO));
+
+#if 0
+    GetSystemInfo(&sysi);
+    INFO("* Processor type : %d, Number of processors : %d\n",
+            sysi.dwProcessorType, sysi.dwNumberOfProcessors);
+#endif
+    get_number_of_processors();
+
+    MEMORYSTATUSEX memInfo;
+    memInfo.dwLength = sizeof(MEMORYSTATUSEX);
+    GlobalMemoryStatusEx(&memInfo);
+    INFO("* Total Ram : %llu kB, Free: %lld kB\n",
+            memInfo.ullTotalPhys / 1024, memInfo.ullAvailPhys / 1024);
+}
+
+char *get_timeofday(void)
+{
+    qemu_gettimeofday(&tv);
+    ti = tv.tv_sec;
+
+    struct tm *ptm = localtime(&ti);
+    strftime(buf_time, sizeof(buf_time),
+             "%H:%M:%S", ptm);
+
+    return buf_time;
+}
+
+static int get_auto_proxy(BYTE *url, char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    char type[MAXLEN];
+    char proxy[MAXLEN];
+    char line[MAXLEN];
+    FILE *fp_pacfile;
+    char *p = NULL;
+
+    INFO("pac address: %s\n", (char*)url);
+    download_url((char*)url);
+
+    fp_pacfile = fopen(pactempfile, "r");
+    if(fp_pacfile != NULL) {
+        while(fgets(line, MAXLEN, fp_pacfile) != NULL) {
+            if( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
+                INFO("line found %s", line);
+                sscanf(line, "%*[^\"]\"%s %s", type, proxy);
+            }
+        }
+
+        if(g_str_has_prefix(type, DIRECT)) {
+            INFO("auto proxy is set to direct mode\n");
+            fclose(fp_pacfile);
+        }
+        else if(g_str_has_prefix(type, PROXY)) {
+            INFO("auto proxy is set to proxy mode\n");
+            INFO("type: %s, proxy: %s\n", type, proxy);
+            p = strtok(proxy, "\";");
+            if(p != NULL) {
+                INFO("auto proxy to set: %s\n",p);
+                strcpy(http_proxy, p);
+                strcpy(https_proxy, p);
+                strcpy(ftp_proxy, p);
+                strcpy(socks_proxy, p);
+            }
+            fclose(fp_pacfile);
+        }
+        else
+        {
+            ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
+            fclose(fp_pacfile);
+        }
+    }
+    else {
+        ERR("fail to get pacfile fp\n");
+        return -1;
+    }
+
+    remove(pactempfile);
+
+    return 0;
+}
+
+void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
+{
+    HKEY hKey;
+    int nRet;
+    LONG lRet;
+    BYTE *proxyenable, *proxyserver;
+    char *p;
+    char *real_proxy;
+    BYTE *url;
+
+    DWORD dwLength = 0;
+    nRet = RegOpenKeyEx(HKEY_CURRENT_USER,
+            "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
+            0, KEY_QUERY_VALUE, &hKey);
+    if (nRet != ERROR_SUCCESS) {
+        ERR("Failed to open registry from %s\n",
+                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
+        return 0;
+    }
+    //check auto proxy key exists
+    lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, NULL, &dwLength);
+    if (lRet != ERROR_SUCCESS && dwLength == 0) {
+        ERR("Failed to query value from %s\n",
+                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\AutoConfigURL");
+    }
+    else {
+        //if exists
+        url = (char*)malloc(dwLength);
+        if (url == NULL) {
+            ERR( "Failed to allocate a buffer\n");
+        }
+        else {
+            memset(url, 0x00, dwLength);
+            lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, url, &dwLength);
+            if (lRet == ERROR_SUCCESS && dwLength != 0) {
+                get_auto_proxy(url, http_proxy, https_proxy, ftp_proxy, socks_proxy);
+                RegCloseKey(hKey);
+                return 0;
+            }
+        }
+    }
+    //check manual proxy key exists
+    lRet = RegQueryValueEx(hKey, "ProxyEnable", 0, NULL, NULL, &dwLength);
+    if (lRet != ERROR_SUCCESS && dwLength == 0) {
+        ERR(stderr, "Failed to query value from %s\n",
+                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable");
+        RegCloseKey(hKey);
+        return 0;
+    }
+    proxyenable = (BYTE*)malloc(dwLength);
+    if (proxyenable == NULL) {
+        ERR( "Failed to allocate a buffer\n");
+        RegCloseKey(hKey);
+        return 0;
+    }
+
+    lRet = RegQueryValueEx(hKey, "ProxyEnable", 0, NULL, proxyenable, &dwLength);
+    if (lRet != ERROR_SUCCESS) {
+        free(proxyenable);
+        ERR("Failed to query value from %s\n",
+                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable");
+        RegCloseKey(hKey);
+        return 0;
+    }
+    if (*(char*)proxyenable == 0) {
+        free(proxyenable);
+        RegCloseKey(hKey);
+        return 0;
+    }
+
+    dwLength = 0;
+    lRet = RegQueryValueEx(hKey, "ProxyServer", 0, NULL, NULL, &dwLength);
+    if (lRet != ERROR_SUCCESS && dwLength == 0) {
+        ERR("Failed to query value from from %s\n",
+                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
+        RegCloseKey(hKey);
+        return 0;
+    }
+
+    proxyserver = (BYTE*)malloc(dwLength);
+    if (proxyserver == NULL) {
+        ERR( "Failed to allocate a buffer\n");
+        RegCloseKey(hKey);
+        return 0;
+    }
+
+    memset(proxyserver, 0x00, dwLength);
+    lRet = RegQueryValueEx(hKey, "ProxyServer", 0, NULL, proxyserver, &dwLength);
+    if (lRet != ERROR_SUCCESS) {
+        free(proxyserver);
+        ERR( "Failed to query value from from %s\n",
+                "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
+        RegCloseKey(hKey);
+        return 0;
+    }
+
+    if((char*)proxyserver != NULL) {
+        INFO("proxy value: %s\n", (char*)proxyserver);
+        real_proxy = malloc(MAXLEN);
+
+        for(p = strtok((char*)proxyserver, ";"); p; p = strtok(NULL, ";")){
+            if(strstr(p, HTTP_PROTOCOL)) {
+                remove_string(p, real_proxy, HTTP_PROTOCOL);
+                strcpy(http_proxy, real_proxy);
+            }
+            else if(strstr(p, HTTPS_PROTOCOL)) {
+                remove_string(p, real_proxy, HTTPS_PROTOCOL);
+                strcpy(https_proxy, real_proxy);
+            }
+            else if(strstr(p, FTP_PROTOCOL)) {
+                remove_string(p, real_proxy, FTP_PROTOCOL);
+                strcpy(ftp_proxy, real_proxy);
+            }
+            else if(strstr(p, SOCKS_PROTOCOL)) {
+                remove_string(p, real_proxy, SOCKS_PROTOCOL);
+                strcpy(socks_proxy, real_proxy);
+            }
+            else {
+                INFO("all protocol uses the same proxy server: %s\n", p);
+                strcpy(http_proxy, p);
+                strcpy(https_proxy, p);
+                strcpy(ftp_proxy, p);
+                strcpy(socks_proxy, p);
+            }
+        }
+        free(real_proxy);
+    }
+    else {
+        INFO("proxy is null\n");
+        return 0;
+    }
+    RegCloseKey(hKey);
+}
diff --git a/tizen/src/util/osutil.c b/tizen/src/util/osutil.c
new file mode 100644 (file)
index 0000000..07fc65d
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+/**
+  @file     osutil.c
+  @brief    Common functions for osutil
+ */
+
+#include "osutil.h"
+#include "debug_ch.h"
+
+#include <curl/curl.h>
+#include <string.h>
+
+MULTI_DEBUG_CHANNEL(emulator, osutil);
+
+
+const char *pac_tempfile = ".autoproxy";
+
+inline size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+    size_t written;
+    written = fwrite(ptr, size, nmemb, stream);
+    return written;
+}
+
+inline void download_url(char *url)
+{
+    CURL *curl;
+    FILE *fp;
+    CURLcode res;
+
+    curl = curl_easy_init();
+    if (curl) {
+        fp = fopen(pac_tempfile, "wb");
+        if(fp == NULL) {
+            ERR("failed to fopen(): %s\n", pac_tempfile);
+            return;
+        }
+        curl_easy_setopt(curl, CURLOPT_URL, url);
+        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
+        /* just in case network does not work */
+        curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 3000);
+        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+
+        res = curl_easy_perform(curl);
+        if (res != 0) {
+            ERR("Fail to download pac file: %s\n", url);
+        }
+
+        curl_easy_cleanup(curl);
+        fclose(fp);
+    }
+
+    return;
+}
+
+inline void remove_string(char *src, char *dst, const char *toremove)
+{
+    int len = strlen(toremove);
+    int i, j;
+    int max_len = strlen(src);
+
+    for(i = len, j = 0; i < max_len; i++)
+    {
+        dst[j++] = src[i];
+    }
+
+    dst[j] = '\0';
+}
diff --git a/tizen/src/util/osutil.h b/tizen/src/util/osutil.h
new file mode 100644 (file)
index 0000000..338d1cb
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Emulator
+ *
+ * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef __OSUTIL_H__
+#define __OSUTIL_H__
+
+#include "qemu-common.h"
+#include "maru_common.h"
+#include "emul_state.h"
+
+#define HTTP_PROTOCOL "http="
+#define HTTP_PREFIX "http://"
+#define HTTPS_PROTOCOL "https="
+#define FTP_PROTOCOL "ftp="
+#define SOCKS_PROTOCOL "socks="
+#define DIRECT "DIRECT"
+#define PROXY "PROXY"
+#define MAXPORTLEN 6
+
+#define GNOME_PROXY_MODE 0
+#define GNOME_PROXY_AUTOCONFIG_URL 1
+#define GNOME_PROXY_HTTP_HOST 2
+#define GNOME_PROXY_HTTP_PORT 3
+#define GNOME_PROXY_HTTPS_HOST 4
+#define GNOME_PROXY_HTTPS_PORT 5
+#define GNOME_PROXY_FTP_HOST 6
+#define GNOME_PROXY_FTP_PORT 7
+#define GNOME_PROXY_SOCKS_HOST 8
+#define GNOME_PROXY_SOCKS_PORT 9
+#define GCONFTOOL 0
+#define GSETTINGS 1
+
+extern const char *pac_tempfile;
+
+void check_vm_lock_os(void);
+void make_vm_lock_os(void);
+void remove_vm_lock_os(void);
+
+void set_bin_path_os(gchar *);
+
+void print_system_info_os(void);
+
+void get_host_proxy_os(char *, char *, char *, char *);
+
+void download_url(char *);
+size_t write_data(void *, size_t, size_t, FILE *);
+void remove_string(char *, char *, const char *);
+char *get_timeofday(void);
+
+int get_number_of_processors(void);
+
+#endif // __OS_UTIL_H__
+
diff --git a/tizen/src/util/sdb.c b/tizen/src/util/sdb.c
new file mode 100644 (file)
index 0000000..c902a52
--- /dev/null
@@ -0,0 +1,225 @@
+/* Copyright (C) 2006-2010 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** 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.
+*/
+
+
+#include "net/slirp.h"
+#include "qemu/sockets.h"
+#include "sdb.h"
+#include "block/nbd.h"
+
+#include "emulator.h"
+#include "debug_ch.h"
+#include "emul_state.h"
+
+MULTI_DEBUG_CHANNEL(qemu, sdb);
+
+extern char tizen_target_path[];
+
+#ifdef _WIN32
+
+#include "qemu/main-loop.h"
+
+static void socket_close_handler( void*  _fd )
+{
+    int   fd = (int)_fd;
+    int   ret;
+    char  buff[64];
+
+    /* we want to drain the read side of the socket before closing it */
+    do {
+        ret = recv( fd, buff, sizeof(buff), 0 );
+    } while (ret < 0 && WSAGetLastError() == WSAEINTR);
+
+    if (ret < 0 && WSAGetLastError() == EWOULDBLOCK)
+        return;
+
+    qemu_set_fd_handler( fd, NULL, NULL, NULL );
+    closesocket( fd );
+}
+
+void socket_close( int  fd )
+{
+    int  old_errno = errno;
+
+    shutdown( fd, SD_BOTH );
+    /* we want to drain the socket before closing it */
+    qemu_set_fd_handler( fd, socket_close_handler, NULL, (void*)fd );
+
+    errno = old_errno;
+}
+
+#else /* !_WIN32 */
+
+#include <unistd.h>
+
+void socket_close( int  fd )
+{
+    int  old_errno = errno;
+
+    shutdown( fd, SHUT_RDWR );
+    close( fd );
+
+    errno = old_errno;
+}
+
+#endif /* !_WIN32 */
+
+int inet_strtoip(const char*  str, uint32_t  *ip)
+{
+    int  comp[4];
+
+    if (sscanf(str, "%d.%d.%d.%d", &comp[0], &comp[1], &comp[2], &comp[3]) != 4)
+        return -1;
+
+    if ((unsigned)comp[0] >= 256 ||
+            (unsigned)comp[1] >= 256 ||
+            (unsigned)comp[2] >= 256 ||
+            (unsigned)comp[3] >= 256)
+        return -1;
+
+    *ip = (uint32_t)((comp[0] << 24) | (comp[1] << 16) |
+            (comp[2] << 8)  |  comp[3]);
+    return 0;
+}
+
+int check_port_bind_listen(uint32_t port)
+{
+    struct sockaddr_in addr;
+    int s, opt = 1;
+    int ret = -1;
+    socklen_t addrlen = sizeof(addr);
+    memset(&addr, 0, addrlen);
+
+    addr.sin_family = AF_INET;
+    addr.sin_addr.s_addr = INADDR_ANY;
+    addr.sin_port = htons(port);
+
+    s = qemu_socket(AF_INET, SOCK_STREAM, 0);
+    if (s < 0) {
+        ERR("failed to create a socket\n", port);
+        return -1;
+    }
+
+#ifndef _WIN32
+    ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
+                    (char *)&opt, sizeof(int));
+    if (ret < 0) {
+        ERR("setsockopt failure\n");
+        close(s);
+        return -1;
+    }
+#endif
+
+    if ((bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) ||
+        (listen(s, 1) < 0)) {
+        /* failure */
+        ret = -1;
+        ERR("port(%d) listen failure\n", port);
+    } else {
+        /* success */
+        ret = 1;
+        INFO("port(%d) listen success\n", port);
+    }
+
+#ifdef _WIN32
+    closesocket(s);
+#else
+    close(s);
+#endif
+
+    return ret;
+}
+
+void set_base_port(void)
+{
+    int   tries     = 10;
+    int   success   = 0;
+    uint32_t port = 26100;
+    int base_port;
+
+    base_port = get_emul_vm_base_port();
+
+    if(base_port == 0){
+
+        for ( ; tries > 0; tries--, port += 10 ) {
+            if(check_port_bind_listen(port + 1) < 0 )
+                continue;
+
+            success = 1;
+            break;
+        }
+
+        if (!success) {
+            ERR( "it seems too many emulator instances are running on this machine. Aborting\n" );
+            exit(1);
+        }
+
+        base_port = port;
+        INFO( "sdb port is %d \n", base_port);
+    }
+
+    set_emul_vm_base_port(base_port);
+}
+
+void sdb_setup(void)
+{
+    int   tries     = 10;
+    int   success   = 0;
+    uint32_t  guest_ip;
+    char buf[64] = {0,};
+    int number;
+
+    number = get_device_serial_number();
+
+    inet_strtoip("10.0.2.16", &guest_ip);
+
+    for ( ; tries > 0; tries--, number += 10 ) {
+        // redir form [tcp:26101:10.0.2.16:26101]
+        sprintf(buf, "tcp:%d:10.0.2.16:26101", number);
+        if(net_slirp_redir((char*)buf) < 0)
+            continue;
+
+        INFO( "SDBD established on port %d\n", number);
+        success = 1;
+        break;
+    }
+
+    INFO("redirect [%s] success\n", buf);
+    if (!success) {
+        ERR( "it seems too many emulator instances are running on this machine. Aborting\n" );
+        exit(1);
+    }
+
+    INFO( "Port(%d/tcp) listen for SDB \n", number);
+}
+
+int sdb_loopback_client(int port, int type)
+{
+    struct sockaddr_in addr;
+    int s;
+
+    memset(&addr, 0, sizeof(addr));
+    addr.sin_family = AF_INET;
+    addr.sin_port = htons(port);
+    addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+    s = socket(AF_INET, type, 0);
+    if(s < 0) return -1;
+
+    if(connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+        close(s);
+        return -1;
+    }
+
+    return s;
+
+}
diff --git a/tizen/src/util/sdb.h b/tizen/src/util/sdb.h
new file mode 100644 (file)
index 0000000..2e1acfc
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (C) 2006-2010 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** 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.
+*/
+
+#include "maru_common.h"
+
+#include <errno.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else /* !_WIN32 */
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netdb.h>
+#endif /* !_WIN32 */
+
+
+#define SDB_HOST_PORT 26099
+
+#define SDB_TCP_EMULD_INDEX  2    /* emulator daemon port */
+#define SDB_TCP_OPENGL_INDEX  3   /* opengl server port */
+#define SDB_UDP_SENSOR_INDEX  2   /* sensor server port */
+
+void sdb_setup(void);
+void set_base_port(void);
+int inet_strtoip(const char*  str, uint32_t  *ip);
+int socket_send(int fd, const void*  buf, int  buflen);
+void socket_close(int fd);
+int check_port_bind_listen(uint32_t port);
+int sdb_loopback_client(int port, int type);
+
diff --git a/vl.c b/vl.c
index 9458e3ad7e5b8fc7c4fd59d87d76e6d1f77fa935..7c0d432da133878cd3bec3697d52ca96ac20db73 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -134,7 +134,7 @@ int qemu_main(int argc, char **argv, char **envp);
 #include "tizen/src/emulator.h"
 #include "tizen/src/maru_err_table.h"
 #include "tizen/src/emul_state.h"
-#include "tizen/src/maru_display.h"
+#include "tizen/src/display/maru_display.h"
 #include "tizen/src/skin/maruskin_operation.h"
 #include "tizen/src/ecs/ecs.h"
 #endif