[Title] disintegration of maruskin_display_init()
authorgiwoong.kim <giwoong.kim@samsung.com>
Mon, 23 Jul 2012 11:03:05 +0000 (20:03 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Mon, 23 Jul 2012 11:04:45 +0000 (20:04 +0900)
[Type] feature
[Module] Emulator / skin
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/Makefile.tizen
tizen/src/maru_display.c [new file with mode: 0644]
tizen/src/maru_display.h [new file with mode: 0644]
tizen/src/maru_sdl.c
tizen/src/maru_sdl.h
tizen/src/maru_shm.c [new file with mode: 0644]
tizen/src/maru_shm.h [new file with mode: 0644]
vl.c

index 6e13e09..e66b6a4 100755 (executable)
@@ -62,7 +62,7 @@ endif #!CONFIG_DARWIN
 obj-y += emulator.o emul_state.o option.o maru_err_table.o
 
 # maru display
-obj-y += maru_sdl.o sdl_rotate.o maru_finger.o
+obj-y += maru_display.o maru_shm.o maru_sdl.o sdl_rotate.o maru_finger.o
 
 # sdb
 obj-y += sdb.o
diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c
new file mode 100644 (file)
index 0000000..e0fe41c
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * MARU display driver
+ *
+ * Copyright (C) 2011 - 2012 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 "maru_display.h"
+#include "debug_ch.h"
+#include "maru_sdl.h"
+#include "maru_shm.h"
+
+MULTI_DEBUG_CHANNEL(tizen, display);
+
+
+void maru_display_init(DisplayState *ds)
+{
+    INFO("init qemu display\n");
+
+    /*  graphics context information */
+    DisplayChangeListener *dcl;
+
+    dcl = g_malloc0(sizeof(DisplayChangeListener));
+#ifndef CONFIG_DARWING
+    /* sdl library */
+    dcl->dpy_update = qemu_ds_sdl_update;
+    dcl->dpy_resize = qemu_ds_sdl_resize;
+    dcl->dpy_refresh = qemu_ds_sdl_refresh;
+#else
+    /* shared memroy */
+    dcl->dpy_update = qemu_ds_shm_update;
+    dcl->dpy_resize = qemu_ds_shm_resize;
+    dcl->dpy_refresh = qemu_ds_shm_refresh;
+#endif
+
+    register_displaychangelistener(ds, dcl);
+}
+
+void maru_display_fini(void)
+{
+    INFO("fini qemu display\n");
+
+    //TODO:
+}
+
diff --git a/tizen/src/maru_display.h b/tizen/src/maru_display.h
new file mode 100644 (file)
index 0000000..6b0c2c1
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * MARU display driver
+ *
+ * Copyright (C) 2011 - 2012 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 "console.h"
+
+
+void maru_display_init(DisplayState *ds);
+void maru_display_fini(void);
+
+#endif /* MARU_DISPLAY_H_ */
index e5ff1a1..f7203d3 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * MARU SDL display driver
+ * SDL_WINDOWID hack
  *
  * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * HyunJun Son <hj79.son@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
@@ -68,6 +68,91 @@ static int sdl_thread_initialized = 0;
 #define SDL_FLAGS (SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME)
 #define SDL_BPP 32
 
+
+void qemu_ds_sdl_update(DisplayState *ds, int x, int y, int w, int h)
+{
+    /* call sdl update */
+#ifdef SDL_THREAD
+    pthread_mutex_lock(&sdl_mutex);
+
+    pthread_cond_signal(&sdl_cond);
+
+    pthread_mutex_unlock(&sdl_mutex);
+#else
+    qemu_update();
+#endif
+}
+
+void qemu_ds_sdl_resize(DisplayState *ds)
+{
+    TRACE("%d, %d\n", ds_get_width(ds), ds_get_height(ds));
+
+#ifdef SDL_THREAD
+    pthread_mutex_lock(&sdl_mutex);
+#endif
+
+    /* create surface_qemu */
+    surface_qemu = SDL_CreateRGBSurfaceFrom(ds_get_data(ds),
+            ds_get_width(ds),
+            ds_get_height(ds),
+            ds_get_bits_per_pixel(ds),
+            ds_get_linesize(ds),
+            ds->surface->pf.rmask,
+            ds->surface->pf.gmask,
+            ds->surface->pf.bmask,
+            ds->surface->pf.amask);
+
+#ifdef SDL_THREAD
+    pthread_mutex_unlock(&sdl_mutex);
+#endif
+
+    if (surface_qemu == NULL) {
+        ERR("Unable to set the RGBSurface: %s\n", SDL_GetError());
+        return;
+    }
+
+}
+
+static int maru_sdl_poll_event(SDL_Event *ev)
+{
+    int ret = 0;
+
+    if (sdl_initialized == 1) {
+        //pthread_mutex_lock(&sdl_mutex);
+        ret = SDL_PollEvent(ev);
+        //pthread_mutex_unlock(&sdl_mutex);
+    }
+
+    return ret;
+}
+void qemu_ds_sdl_refresh(DisplayState *ds)
+{
+    SDL_Event ev1, *ev = &ev1;
+
+    vga_hw_update();
+
+    // surface may be NULL in init func.
+    qemu_display_surface = ds->surface;
+
+    while (maru_sdl_poll_event(ev)) {
+        switch (ev->type) {
+            case SDL_VIDEORESIZE:
+            {
+                pthread_mutex_lock(&sdl_mutex);
+
+                SDL_Quit(); //The returned surface is freed by SDL_Quit and must not be freed by the caller
+                maruskin_sdl_init(0, get_emul_lcd_width(), get_emul_lcd_height(), true);
+
+                pthread_mutex_unlock(&sdl_mutex);
+                break;
+            }
+
+            default:
+                break;
+        }
+    }
+}
+
 extern int capability_check_gl;
 static void _sdl_init(void)
 {
@@ -318,147 +403,6 @@ static void* run_qemu_update(void* arg)
 }
 #endif
 
-static void qemu_ds_update(DisplayState *ds, int x, int y, int w, int h)
-{
-    /* call sdl update */
-#ifdef SDL_THREAD
-    pthread_mutex_lock(&sdl_mutex);
-
-    pthread_cond_signal(&sdl_cond);
-
-    pthread_mutex_unlock(&sdl_mutex);
-#else
-    qemu_update();
-#endif
-}
-
-static void qemu_ds_resize(DisplayState *ds)
-{
-    TRACE("%d, %d\n", ds_get_width(ds), ds_get_height(ds));
-
-#ifdef SDL_THREAD
-    pthread_mutex_lock(&sdl_mutex);
-#endif
-
-    /* create surface_qemu */
-    surface_qemu = SDL_CreateRGBSurfaceFrom(ds_get_data(ds),
-            ds_get_width(ds),
-            ds_get_height(ds),
-            ds_get_bits_per_pixel(ds),
-            ds_get_linesize(ds),
-            ds->surface->pf.rmask,
-            ds->surface->pf.gmask,
-            ds->surface->pf.bmask,
-            ds->surface->pf.amask);
-
-#ifdef SDL_THREAD
-    pthread_mutex_unlock(&sdl_mutex);
-#endif
-
-    if (surface_qemu == NULL) {
-        ERR("Unable to set the RGBSurface: %s\n", SDL_GetError());
-        return;
-    }
-
-}
-
-static int maru_sdl_poll_event(SDL_Event *ev)
-{
-    int ret = 0;
-
-    if (sdl_initialized == 1) {
-        //pthread_mutex_lock(&sdl_mutex);
-        ret = SDL_PollEvent(ev);
-        //pthread_mutex_unlock(&sdl_mutex);
-    }
-
-    return ret;
-}
-
-static void put_hardkey_code( SDL_UserEvent event )
-{
-    // use pointer as integer
-    int event_type = (int) event.data1;
-    int keycode = (int) event.data2;
-
-    if ( KEY_PRESSED == event_type ) {
-
-        if ( kbd_mouse_is_absolute() ) {
-            ps2kbd_put_keycode( keycode & 0x7f );
-        }
-
-    } else if ( KEY_RELEASED == event_type ) {
-
-        if ( kbd_mouse_is_absolute() ) {
-            ps2kbd_put_keycode( keycode | 0x80 );
-        }
-
-    } else {
-        ERR( "Unknown hardkey event type.[event_type:%d]\n", event_type );
-    }
-
-}
-
-static void handle_sdl_user_event ( SDL_UserEvent event )
-{
-    int code = event.code;
-
-    switch ( code ) {
-    case SDL_USER_EVENT_CODE_HARDKEY: {
-        put_hardkey_code( event );
-        break;
-    }
-    default: {
-        ERR( "Unknown sdl user event.[event code:%d]\n", code );
-        break;
-    }
-    }
-
-}
-
-static void qemu_ds_refresh(DisplayState *ds)
-{
-    SDL_Event ev1, *ev = &ev1;
-
-    vga_hw_update();
-
-    // surface may be NULL in init func.
-    qemu_display_surface = ds->surface;
-
-    while (maru_sdl_poll_event(ev)) {
-        switch (ev->type) {
-            case SDL_VIDEORESIZE:
-            {
-                pthread_mutex_lock(&sdl_mutex);
-
-                SDL_Quit(); //The returned surface is freed by SDL_Quit and must not be freed by the caller
-                maruskin_sdl_init(0, get_emul_lcd_width(), get_emul_lcd_height(), true);
-
-                pthread_mutex_unlock(&sdl_mutex);
-                break;
-            }
-
-            default:
-                break;
-        }
-    }
-}
-
-void maruskin_display_init(DisplayState *ds)
-{
-    INFO("qemu display initialization\n");
-
-    /*  graphics context information */
-    DisplayChangeListener *dcl;
-
-    dcl = g_malloc0(sizeof(DisplayChangeListener));
-    dcl->dpy_update = qemu_ds_update;
-    dcl->dpy_resize = qemu_ds_resize;
-    dcl->dpy_refresh = qemu_ds_refresh;
-
-    register_displaychangelistener(ds, dcl);
-}
-
 void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize)
 {
     gchar SDL_windowhack[32];
index f9d3ba7..d0e3a70 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * MARU SDL display driver
+ * SDL_WINDOWID hack
  *
  * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * HyunJun Son <hj79.son@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
 #define MARU_SDL_H_
 
 #include "console.h"
-
-#if 0
-#ifdef _WIN32
-#include <windows.h>
-#include <winbase.h>
-#endif
-#endif
-
 #include <SDL.h>
 #include <SDL_syswm.h>
 #include "qemu-common.h"
 
-#define SDL_USER_EVENT_CODE_HARDKEY 1
 
-void maruskin_display_init(DisplayState *ds);
+void qemu_ds_sdl_update(DisplayState *ds, int x, int y, int w, int h);
+void qemu_ds_sdl_resize(DisplayState *ds);
+void qemu_ds_sdl_refresh(DisplayState *ds);
+
 void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
 void maruskin_sdl_resize(void);
 void maruskin_sdl_quit(void);
diff --git a/tizen/src/maru_shm.c b/tizen/src/maru_shm.c
new file mode 100644 (file)
index 0000000..4210022
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Shared memory
+ *
+ * Copyright (C) 2011 - 2012 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 "maru_shm.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(tizen, maru_shm);
+
+
+void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h)
+{
+    //TODO:
+}
+
+void qemu_ds_shm_resize(DisplayState *ds)
+{
+    //TODO:
+}
+
+void qemu_ds_shm_refresh(DisplayState *ds)
+{
+    //TODO:
+}
+
diff --git a/tizen/src/maru_shm.h b/tizen/src/maru_shm.h
new file mode 100644 (file)
index 0000000..af06336
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Shared memory
+ *
+ * Copyright (C) 2011 - 2012 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 "console.h"
+
+
+void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h);
+void qemu_ds_shm_resize(DisplayState *ds);
+void qemu_ds_shm_refresh(DisplayState *ds);
+
+#endif /* MARU_SHM_H_ */
diff --git a/vl.c b/vl.c
index da0c518..0ceb970 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -179,7 +179,7 @@ int qemu_main(int argc, char **argv, char **envp);
 #include "ui/qemu-spice.h"
 
 #ifdef CONFIG_MARU
-#include "tizen/src/maru_sdl.h"
+#include "tizen/src/maru_display.h"
 #include "tizen/src/option.h"
 #include "tizen/src/emul_state.h"
 #include "tizen/src/skin/maruskin_operation.h"
@@ -3597,7 +3597,7 @@ int main(int argc, char **argv, char **envp)
 #endif
 #if defined(CONFIG_MARU)
     case DT_MARU:
-        maruskin_display_init(ds);
+        maru_display_init(ds);
         if (skin_disabled == 1) {
             set_emul_skin_enable(0);
         } else {