Select display type with display options - DT_MARU_SDL, DT_MARU_SHM.
Clean-up definitions and display type names.
Change-Id: I67a551db1d39e39afa49b92d3ac65ac8b4946b40
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
DT_GTK,
DT_NOGRAPHIC,
#ifdef CONFIG_MARU
- DT_MARU,
+ DT_MARU_SDL,
+ DT_MARU_SHM,
#endif
DT_NONE,
} DisplayType;
obj-y += maru_display.o
-ifdef CONFIG_USE_SHM
-obj-y += maru_shm.o
-else
-ifdef CONFIG_SDL
-obj-y += maru_sdl.o maru_sdl_processing.o maru_finger.o
-endif
-endif
+
+obj-$(CONFIG_USE_SHM) += maru_shm.o
+
+obj-$(CONFIG_SDL) += 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)
#include "emulator.h"
-#include "emulator_common.h"
#include "maru_display.h"
#include "debug_ch.h"
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
-#include "maru_sdl.h"
-#endif
-#else
-#include "maru_shm.h"
-#endif
-
MULTI_DEBUG_CHANNEL(tizen, display);
MaruScreenShot* screenshot = NULL;
+static MaruDisplayChangeListener *mdcl;
+
static void maru_display_fini(void)
{
INFO("fini qemu display\n");
g_free(screenshot);
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
- maru_sdl_quit();
-#endif
-#else
- maru_shm_quit();
-#endif
+ if (mdcl->fini) {
+ mdcl->fini();
+ }
+
+ g_free(mdcl);
}
static void maru_display_notify_exit(Notifier *notifier, void *data) {
}
static Notifier maru_display_exit = { .notify = maru_display_notify_exit };
-//TODO: interface
-void maru_display_init(DisplayState *ds)
+void maru_display_init(DisplayState *ds, DisplayType display_type, int full_screen)
{
INFO("init qemu display\n");
-#ifndef CONFIG_USE_SHM
+ mdcl = g_malloc0(sizeof(MaruDisplayChangeListener));
+
+ switch (display_type) {
#ifdef CONFIG_SDL
- maru_sdl_pre_init();
+ case DT_MARU_SDL:
+ maru_sdl_pre_init(mdcl);
+ break;
#endif
-#else
- maru_shm_pre_init();
+#ifdef CONFIG_USE_SHM
+ case DT_MARU_SHM:
+ maru_shm_pre_init(mdcl);
+ break;
#endif
-
- /* graphics context information */
- DisplayChangeListener *dcl;
-
- dcl = g_malloc0(sizeof(DisplayChangeListener));
-#if defined(CONFIG_USE_SHM) || defined(CONFIG_SDL)
- //FIXME
- dcl->ops = &maru_dcl_ops;
-#endif
- register_displaychangelistener(dcl);
+ default:
+ ERR("can not enter here.\n");
+ // can not enter here...
+ break;
+ }
screenshot = g_malloc0(sizeof(MaruScreenShot));
screenshot->pixels = NULL;
void maru_display_resize(void)
{
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
- maru_sdl_resize();
-#endif
-#else
- maru_shm_resize();
-#endif
+ if (mdcl->resize) {
+ mdcl->resize();
+ }
}
void maru_display_update(void)
{
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
- maru_sdl_update();
-#endif
-#else
- maru_shm_update();
-#endif
+ if (mdcl->update) {
+ mdcl->update();
+ }
}
-void maru_display_invalidate(bool on)
+void maru_display_set_invalidate(bool on)
{
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
- maru_sdl_invalidate(on);
-#endif
-#else
- /* do nothing */
-#endif
+ if (mdcl->set_invalidate) {
+ mdcl->set_invalidate(on);
+ }
}
-void maru_display_interpolation(bool on)
+void maru_display_set_interpolation(bool on)
{
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
- maru_sdl_interpolation(on);
-#endif
-#else
- /* do nothing */
-#endif
+ if (mdcl->set_interpolation) {
+ mdcl->set_interpolation(on);
+ }
}
void maru_ds_surface_init(uint64 swt_handle,
unsigned int display_width, unsigned int display_height,
bool blank_guide)
{
-#ifndef CONFIG_USE_SHM
-#ifdef CONFIG_SDL
- maru_sdl_init(swt_handle,
- display_width, display_height, blank_guide);
-#endif
-#else
- maru_shm_init(swt_handle,
- display_width, display_height, blank_guide);
-#endif
+ if (mdcl->surface_init) {
+ mdcl->surface_init(swt_handle, display_width,
+ display_height, blank_guide);
+ }
}
MaruScreenShot *get_screenshot(void)
#ifndef __MARU_DISPLAY_H__
#define __MARU_DISPLAY_H__
+#include "sysemu/sysemu.h"
#include "ui/console.h"
+typedef struct {
+ void (*surface_init)(uint64 swt_handle,
+ unsigned int display_width, unsigned int display_height,
+ bool blank_guide);
+ void (*fini)(void);
+
+ void (*resize)(void);
+ void (*update)(void);
+ void (*set_invalidate)(bool);
+ void (*set_interpolation)(bool);
+} MaruDisplayChangeListener;
+
typedef struct MaruScreenShot {
unsigned char *pixels;
bool request;
bool ready;
} MaruScreenShot;
-void maru_display_init(DisplayState *ds);
+void maru_display_init(DisplayState *ds, DisplayType display_type, int full_screen);
void maru_display_resize(void);
void maru_display_update(void);
-void maru_display_invalidate(bool on);
-void maru_display_interpolation(bool on);
+void maru_display_set_invalidate(bool on);
+void maru_display_set_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);
+// maru_sdl
+void maru_sdl_pre_init(MaruDisplayChangeListener *mdcl);
+
+// maru_shm
+void maru_shm_pre_init(MaruDisplayChangeListener *mdcl);
+
#endif /* __MARU_DISPLAY_H__ */
#include "emulator.h"
#include "emul_state.h"
#include "maru_display.h"
-#include "maru_sdl.h"
#include "maru_sdl_processing.h"
#include "hw/pci/maru_brightness.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
+static DisplayChangeListener *dcl;
+
static QEMUBH *sdl_init_bh;
static QEMUBH *sdl_resize_bh;
static QEMUBH *sdl_update_bh;
#endif
}
-DisplayChangeListenerOps maru_dcl_ops = {
+static DisplayChangeListenerOps 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_GetWMInfo(&info);
#endif
+ sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL);
+ sdl_update_bh = qemu_bh_new(maru_sdl_update_bh, NULL);
qemu_bh_schedule(sdl_resize_bh);
#ifdef SDL_THREAD
#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)
+static void maru_sdl_quit(void)
{
INFO("maru sdl quit\n");
qemu_cond_destroy(&sdl_cond);
qemu_mutex_destroy(&sdl_mutex);
#endif
+
+ unregister_displaychangelistener(dcl);
+ g_free(dcl);
}
-void maru_sdl_resize(void)
+static void maru_sdl_resize(void)
{
INFO("maru sdl resize\n");
- qemu_bh_schedule(sdl_resize_bh);
+ if (sdl_resize_bh != NULL) {
+ qemu_bh_schedule(sdl_resize_bh);
+ }
}
-void maru_sdl_update(void)
+static void maru_sdl_update(void)
{
if (sdl_update_bh != NULL) {
qemu_bh_schedule(sdl_update_bh);
}
}
-void maru_sdl_invalidate(bool on)
+static void maru_sdl_set_invalidate(bool on)
{
sdl_invalidate = on;
}
+static void maru_sdl_set_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 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_set_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_pre_init(MaruDisplayChangeListener *mdcl)
+{
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
+ dcl->ops = &dcl_ops;
+
+ mdcl->surface_init = maru_sdl_init;
+ mdcl->fini = maru_sdl_quit;
+
+ mdcl->resize = maru_sdl_resize;
+ mdcl->update = maru_sdl_update;
+ mdcl->set_invalidate = maru_sdl_set_invalidate;
+ mdcl->set_interpolation = maru_sdl_set_interpolation;
+
+ sdl_init_bh = qemu_bh_new(maru_sdl_init_bh, NULL);
+
+#ifdef SDL_THREAD
+ qemu_mutex_init(&sdl_mutex);
+ qemu_cond_init(&sdl_cond);
+#endif
+
+ register_displaychangelistener(dcl);
+}
+
bool maru_extract_framebuffer(void *buffer)
{
uint32_t buffer_size = 0;
#define MARU_SDL_H_
#include "ui/console.h"
+#include "maru_display.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);
+void maru_sdl_pre_init(MaruDisplayChangeListener *mdcl);
#endif /* MARU_SDL_H_ */
#include <sys/shm.h>
#include "qemu/main-loop.h"
-#include "emul_state.h"
#include "maru_display.h"
-#include "maru_shm.h"
+#include "emul_state.h"
#include "hw/pci/maru_brightness.h"
#include "skin/maruskin_server.h"
#include "util/maru_err_table.h"
MULTI_DEBUG_CHANNEL(tizen, maru_shm);
-static QEMUBH *shm_update_bh;
+static DisplayChangeListener *dcl;
static DisplaySurface *dpy_surface;
static void *shared_memory = (void *) 0;
}
}
-static void maru_shm_update_bh(void *opaque)
-{
- graphic_hw_invalidate(NULL);
-}
-
-DisplayChangeListenerOps maru_dcl_ops = {
+static DisplayChangeListenerOps 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_pre_init(void)
+static 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 = 0;
+ }
+
+ 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 {
+ INFO("number of current attaches = %d\n",
+ (int)shm_info.shm_nattch);
+ }
+
+ unregister_displaychangelistener(dcl);
+ g_free(dcl);
+}
+
+static void maru_shm_resize(void)
{
- shm_update_bh = qemu_bh_new(maru_shm_update_bh, NULL);
+ shm_skip_update = 0;
}
-void maru_shm_init(uint64 swt_handle,
+static void maru_shm_init(uint64 swt_handle,
unsigned int display_width, unsigned int display_height,
bool blank_guide)
{
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 = 0;
- }
- if (shmdt(shared_memory) == -1) {
- ERR("shmdt failed\n");
- perror("maru_vga: ");
- return;
- }
- shared_memory = NULL;
+void maru_shm_pre_init(MaruDisplayChangeListener *mdcl)
+{
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
+ dcl->ops = &dcl_ops;
- 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 {
- INFO("number of current attaches = %d\n",
- (int)shm_info.shm_nattch);
- }
-}
+ mdcl->surface_init = maru_shm_init;
+ mdcl->fini = maru_shm_quit;
-void maru_shm_resize(void)
-{
- shm_skip_update = 0;
-}
+ mdcl->resize = maru_shm_resize;
-void maru_shm_update(void)
-{
- if (shm_update_bh != NULL) {
- qemu_bh_schedule(shm_update_bh);
- }
+ register_displaychangelistener(dcl);
}
bool maru_extract_framebuffer(void *buffer)
#define MARU_SHM_H_
#include "ui/console.h"
+#include "maru_display.h"
-extern DisplayChangeListenerOps maru_dcl_ops;
-
-void maru_shm_pre_init(void);
-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);
-void maru_shm_update(void);
+void maru_shm_pre_init(MaruDisplayChangeListener *mdcl);
#endif /* MARU_SHM_H_ */
/* display */
char buf_display_shm[8] = { 0, };
-#ifdef CONFIG_USE_SHM
- strcpy(buf_display_shm, OPT_BOOLEAN_TRUE); /* maru_shm */
-#else
- strcpy(buf_display_shm, OPT_BOOLEAN_FALSE); /* maru_sdl */
-#endif
+ switch (display_type) {
+ case DT_MARU_SDL:
+ strcpy(buf_display_shm, OPT_BOOLEAN_FALSE); /* maru_sdl */
+ break;
+ case DT_MARU_SHM:
+ strcpy(buf_display_shm, OPT_BOOLEAN_TRUE); /* maru_shm */
+ break;
+ default:
+ ERR("Can not enter here.\n");
+ break;
+ }
/* input */
char buf_input[12] = { 0, };
{
INFO("skin grabbing enable : %d\n", on);
- maru_display_invalidate(on);
+ maru_display_set_invalidate(on);
}
void do_mouse_event(int button_type, int event_type,
{
INFO("interpolation enable : %d\n", on);
- maru_display_interpolation(on);
+ maru_display_set_interpolation(on);
}
void do_ram_dump(void)
fprintf(stderr, "GTK support is disabled\n");
exit(1);
#endif
+#ifdef CONFIG_MARU
+# ifdef CONFIG_SDL
+ } else if (strstart(p, "maru_sdl", &opts)) {
+ display = DT_MARU_SDL;
+# endif
+# ifdef CONFIG_USE_SHM
+ } else if (strstart(p, "maru_shm", &opts)) {
+ display = DT_MARU_SHM;
+# endif
+#endif /* CONFIG_MARU */
} else if (strstart(p, "none", &opts)) {
display = DT_NONE;
} else {
}
#ifdef CONFIG_MARU
-int use_qemu_display = 0; //0:use tizen qemu sdl, 1:use original qemu sdl
-
// W/A for preserve larger continuous heap for RAM.
extern void *preallocated_ram_ptr;
extern int preallocated_ram_size;
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_MARU)
- display_type = DT_MARU;
+ // FIXME: for compatibility...
+ // If no display_type is specified,
+ // we use DT_MARU_SDL on Linux, Windows and
+ // use DT_MARU_SHM on MacOS.
+#if defined(CONFIG_SDL)
+ display_type = DT_MARU_SDL;
+#elif defined(CONFIG_USE_SHM)
+ display_type = DT_MARU_SHM;
+#endif
#elif defined(CONFIG_GTK)
display_type = DT_GTK;
#elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
curses_display_init(ds, full_screen);
break;
#endif
-#if defined(CONFIG_MARU)
-#if defined(CONFIG_SDL) || defined(CONFIG_USE_SHM)
- case DT_MARU:
- maru_display_init(ds);
- if (skin_disabled == 1) {
- /* do not start skin client process */
- set_emul_skin_enable(false);
- } else {
- set_emul_skin_enable(true);
- }
- start_skin();
- break;
-#endif
-#endif
#if defined(CONFIG_SDL)
case DT_SDL:
sdl_display_init(ds, full_screen, no_frame);
case DT_GTK:
gtk_display_init(ds, full_screen, grab_on_hover);
break;
+#endif
+#if defined(CONFIG_MARU)
+#if defined(CONFIG_SDL) || defined(CONFIG_USE_SHM)
+ case DT_MARU_SDL:
+ case DT_MARU_SHM:
+ maru_display_init(ds, display_type, full_screen);
+ if (skin_disabled == 1) {
+ /* do not start skin client process */
+ set_emul_skin_enable(false);
+ } else {
+ set_emul_skin_enable(true);
+ }
+ start_skin();
+ break;
+#endif
#endif
default:
break;