From ef654b444890f859461b23a797ae9d66458d3072 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Thu, 8 May 2014 11:49:12 +0900 Subject: [PATCH] display: source clean-up convert pthread to qemu_thread modified function name & etc Change-Id: I022a36e51186367b87283fc07754847a98413f4e Signed-off-by: GiWoong Kim --- tizen/src/maru_display.c | 32 ++++++++++----- tizen/src/maru_display.h | 3 +- tizen/src/maru_sdl.c | 77 ++++++++++++++++++++----------------- tizen/src/maru_sdl.h | 13 ++++--- tizen/src/maru_shm.c | 6 +-- tizen/src/maru_shm.h | 6 +-- tizen/src/skin/maruskin_operation.c | 2 +- tizen/src/skin/maruskin_server.c | 32 +++------------ ui/console.c | 11 +++--- 9 files changed, 92 insertions(+), 90 deletions(-) diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c index e528673..9b89ece 100644 --- a/tizen/src/maru_display.c +++ b/tizen/src/maru_display.c @@ -38,7 +38,6 @@ #include "maru_shm.h" #endif - MULTI_DEBUG_CHANNEL(tizen, display); MaruScreenshot* maru_screenshot = NULL; @@ -48,6 +47,12 @@ 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; @@ -68,16 +73,25 @@ void maru_display_fini(void) g_free(maru_screenshot); #ifndef CONFIG_USE_SHM - maruskin_sdl_quit(); + maru_sdl_quit(); +#else + maru_shm_quit(); +#endif +} + +void maru_display_resize(void) +{ +#ifndef CONFIG_USE_SHM + maru_sdl_resize(); #else - maruskin_shm_quit(); + maru_shm_resize(); #endif } void maru_display_update(void) { #ifndef CONFIG_USE_SHM - maruskin_sdl_update(); + maru_sdl_update(); #else /* do nothing */ #endif @@ -86,7 +100,7 @@ void maru_display_update(void) void maru_display_invalidate(bool on) { #ifndef CONFIG_USE_SHM - maruskin_sdl_invalidate(on); + maru_sdl_invalidate(on); #else /* do nothing */ #endif @@ -95,21 +109,21 @@ void maru_display_invalidate(bool on) void maru_display_interpolation(bool on) { #ifndef CONFIG_USE_SHM - maruskin_sdl_interpolation(on); + maru_sdl_interpolation(on); #else /* do nothing */ #endif } -void maruskin_init(uint64 swt_handle, +void maru_ds_surface_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide) { #ifndef CONFIG_USE_SHM - maruskin_sdl_init(swt_handle, + maru_sdl_init(swt_handle, display_width, display_height, blank_guide); #else - maruskin_shm_init(swt_handle, + maru_shm_init(swt_handle, display_width, display_height, blank_guide); #endif } diff --git a/tizen/src/maru_display.h b/tizen/src/maru_display.h index e85cc3e..ec0b901 100644 --- a/tizen/src/maru_display.h +++ b/tizen/src/maru_display.h @@ -41,10 +41,11 @@ typedef struct MaruScreenshot { void maru_display_init(DisplayState *ds); void maru_display_fini(void); +void maru_display_resize(void); void maru_display_update(void); void maru_display_invalidate(bool on); void maru_display_interpolation(bool on); -void maruskin_init(uint64 swt_handle, +void maru_ds_surface_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index cc11898..1dd6571 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -29,7 +29,6 @@ */ -#include #include #include "qemu/main-loop.h" #include "emulator.h" @@ -70,24 +69,27 @@ static unsigned int blank_cnt; #define BLANK_GUIDE_IMAGE_NAME "blank-guide.png" #ifdef SDL_THREAD -pthread_mutex_t sdl_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t sdl_cond = PTHREAD_COND_INITIALIZER; +QemuMutex sdl_mutex; +QemuCond sdl_cond; static int sdl_thread_initialized; #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 - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); - pthread_cond_signal(&sdl_cond); + qemu_cond_signal(&sdl_cond); - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); #else qemu_update(); #endif @@ -251,7 +253,7 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) #ifdef TARGET_ARM #ifdef SDL_THREAD - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); #endif /* @@ -262,7 +264,7 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) SDL_UpdateRect(surface_screen, 0, 0, 0, 0); #ifdef SDL_THREAD - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); #endif #endif } @@ -274,7 +276,7 @@ DisplayChangeListenerOps maru_dcl_ops = { .dpy_refresh = qemu_ds_sdl_refresh, }; -void maruskin_sdl_interpolation(bool on) +void maru_sdl_interpolation(bool on) { if (on == true) { INFO("set PIXMAN_FILTER_BEST filter for image processing\n"); @@ -358,13 +360,13 @@ static void qemu_update(void) static void *run_qemu_update(void *arg) { while(1) { - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); - pthread_cond_wait(&sdl_cond, &sdl_mutex); + qemu_cond_wait(&sdl_cond, &sdl_mutex); qemu_update(); - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); } return NULL; @@ -389,7 +391,7 @@ static void maru_sdl_resize_bh(void *opaque) sdl_skip_update = 0; #ifdef SDL_THREAD - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); #endif /* get current setting information and calculate screen size */ @@ -429,7 +431,7 @@ static void maru_sdl_resize_bh(void *opaque) get_emul_sdl_bpp(), SDL_GetError()); #ifdef SDL_THREAD - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); #endif return; @@ -464,7 +466,7 @@ static void maru_sdl_resize_bh(void *opaque) } #ifdef SDL_THREAD - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); #endif graphic_hw_invalidate(NULL); @@ -493,16 +495,25 @@ static void maru_sdl_init_bh(void *opaque) INFO("sdl update thread create\n"); - pthread_t thread_id; - if (pthread_create(&thread_id, NULL, run_qemu_update, NULL) != 0) { - ERR("pthread_create fail\n"); - return; - } + QemuThread sdl_thread; + qemu_thread_create(&sdl_thread, run_qemu_update, + NULL, QEMU_THREAD_JOINABLE); } #endif } -void maruskin_sdl_init(uint64 swt_handle, +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) { @@ -512,10 +523,6 @@ void maruskin_sdl_init(uint64 swt_handle, INFO("maru sdl init\n"); - 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); - sprintf(SDL_windowhack, "%ld", window_id); g_setenv("SDL_WINDOWID", SDL_windowhack, 1); @@ -524,7 +531,7 @@ void maruskin_sdl_init(uint64 swt_handle, set_emul_resolution(display_width, display_height); set_emul_sdl_bpp(SDL_BPP); - maruskin_sdl_interpolation(false); + maru_sdl_interpolation(false); init_multi_touch_state(); if (blank_guide_enable == true) { @@ -534,7 +541,7 @@ void maruskin_sdl_init(uint64 swt_handle, qemu_bh_schedule(sdl_init_bh); } -void maruskin_sdl_quit(void) +void maru_sdl_quit(void) { INFO("maru sdl quit\n"); @@ -556,32 +563,32 @@ void maruskin_sdl_quit(void) sdl_alteration = -1; #ifdef SDL_THREAD - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); #endif SDL_Quit(); #ifdef SDL_THREAD - pthread_mutex_unlock(&sdl_mutex); - pthread_cond_destroy(&sdl_cond); -#endif + qemu_mutex_unlock(&sdl_mutex); + qemu_cond_destroy(&sdl_cond); - pthread_mutex_destroy(&sdl_mutex); + qemu_mutex_destroy(&sdl_mutex); +#endif } -void maruskin_sdl_resize(void) +void maru_sdl_resize(void) { INFO("maru sdl resize\n"); qemu_bh_schedule(sdl_resize_bh); } -void maruskin_sdl_update(void) +void maru_sdl_update(void) { qemu_bh_schedule(sdl_update_bh); } -void maruskin_sdl_invalidate(bool on) +void maru_sdl_invalidate(bool on) { sdl_invalidate = on; } diff --git a/tizen/src/maru_sdl.h b/tizen/src/maru_sdl.h index e093627..342f4d2 100644 --- a/tizen/src/maru_sdl.h +++ b/tizen/src/maru_sdl.h @@ -38,13 +38,14 @@ extern DisplayChangeListenerOps maru_dcl_ops; -void maruskin_sdl_init(uint64 swt_handle, +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 maruskin_sdl_resize(void); -void maruskin_sdl_update(void); -void maruskin_sdl_invalidate(bool on); -void maruskin_sdl_interpolation(bool on); -void maruskin_sdl_quit(void); +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_shm.c b/tizen/src/maru_shm.c index 5efb83c..86ad700 100644 --- a/tizen/src/maru_shm.c +++ b/tizen/src/maru_shm.c @@ -213,7 +213,7 @@ DisplayChangeListenerOps maru_dcl_ops = { .dpy_gfx_switch = qemu_ds_shm_switch, }; -void maruskin_shm_init(uint64 swt_handle, +void maru_shm_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide) { @@ -266,7 +266,7 @@ void maruskin_shm_init(uint64 swt_handle, INFO("Memory attached at 0x%X\n", (int)shared_memory); } -void maruskin_shm_quit(void) +void maru_shm_quit(void) { struct shmid_ds shm_info; @@ -298,7 +298,7 @@ void maruskin_shm_quit(void) } } -void maruskin_shm_resize(void) +void maru_shm_resize(void) { shm_skip_update = 0; } diff --git a/tizen/src/maru_shm.h b/tizen/src/maru_shm.h index ed28988..d24b1b6 100644 --- a/tizen/src/maru_shm.h +++ b/tizen/src/maru_shm.h @@ -35,10 +35,10 @@ extern DisplayChangeListenerOps maru_dcl_ops; -void maruskin_shm_init(uint64 swt_handle, +void maru_shm_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); -void maruskin_shm_resize(void); -void maruskin_shm_quit(void); +void maru_shm_resize(void); +void maru_shm_quit(void); #endif /* MARU_SHM_H_ */ diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 6c6b150..630b383 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -89,7 +89,7 @@ void start_display(uint64 handle_id, scale_factor, rotation_type, blank_guide); set_emul_win_scale(scale_factor); - maruskin_init(handle_id, + maru_ds_surface_init(handle_id, display_width, display_height, blank_guide); } diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index ce2273d..9e49375 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -28,30 +28,14 @@ */ -#include "maru_common.h" - -#include -#include -#include -#include -#include -#include #include +#include "maru_common.h" #include "maruskin_server.h" #include "maruskin_operation.h" -#include "qemu/thread.h" -#include "emul_state.h" -#include "maruskin_client.h" -#include "emulator.h" +#include "maru_display.h" #include "maru_err_table.h" #include "ecs/ecs.h" -#ifndef CONFIG_USE_SHM -#include "maru_sdl.h" -#else -#include "maru_shm.h" -#endif - #ifdef CONFIG_WIN32 #include #include @@ -59,7 +43,7 @@ #define SLEEP(x) Sleep(x) #define SOCKET_CLOSE(sock) closesocket(sock) -#define SOCKET_ERROR() WSAGetLastError() +#define SOCKET_ERR() WSAGetLastError() #else #include #include @@ -67,7 +51,7 @@ #define SLEEP(x) usleep(x * 1000) #define SOCKET_CLOSE(sock) close(sock) -#define SOCKET_ERROR() errno +#define SOCKET_ERR() errno #endif #include "debug_ch.h" @@ -752,7 +736,7 @@ static void* run_skin_server(void* args) is_force_close_client = 0; } else { ERR("skin_server read error (%d): %d\n", - SOCKET_ERROR(), read_cnt); + SOCKET_ERR(), read_cnt); perror("skin_server read error : "); } @@ -1028,11 +1012,7 @@ static void* run_skin_server(void* args) is_rotate = true; } -#ifndef CONFIG_USE_SHM - maruskin_sdl_resize(); -#else - maruskin_shm_resize(); -#endif + maru_display_resize(); /* after display resizing */ if (is_rotate == true && is_sensord_initialized == 1) { diff --git a/ui/console.c b/ui/console.c index e4205cd..18325d0 100644 --- a/ui/console.c +++ b/ui/console.c @@ -29,8 +29,7 @@ #include "sysemu/char.h" #ifdef SDL_THREAD -#include -extern pthread_mutex_t sdl_mutex; +extern QemuMutex sdl_mutex; #endif //#define DEBUG_CONSOLE @@ -1321,7 +1320,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl) } if (dcl->ops->dpy_gfx_switch) { #ifdef SDL_THREAD - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); #endif if (con) { @@ -1334,7 +1333,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl) } #ifdef SDL_THREAD - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); #endif } } @@ -1396,7 +1395,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, DisplayChangeListener *dcl; #ifdef SDL_THREAD - pthread_mutex_lock(&sdl_mutex); + qemu_mutex_lock(&sdl_mutex); #endif con->surface = surface; @@ -1410,7 +1409,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, } #ifdef SDL_THREAD - pthread_mutex_unlock(&sdl_mutex); + qemu_mutex_unlock(&sdl_mutex); #endif qemu_free_displaysurface(old_surface); -- 2.7.4