From 6f8abf166d01e5e5f486474fc8b1a3a81bcf7437 Mon Sep 17 00:00:00 2001 From: choisjin80 Date: Mon, 8 Apr 2013 15:37:07 +0900 Subject: [PATCH] Merge develop into ecp --- exec.c | 4 +- hw/virtio-pci.c | 45 +++ package/changelog | 24 ++ package/pkginfo.manifest | 2 +- tizen/src/Makefile | 15 +- tizen/src/Makefile.tizen | 1 + tizen/src/debug_ch.c | 2 +- tizen/src/ecs.c | 105 +++-- tizen/src/ecs.h | 7 +- tizen/src/emul_state.c | 42 +- tizen/src/emul_state.h | 9 +- tizen/src/emulator.c | 12 +- tizen/src/hw/gl_func_perso.h | 4 + tizen/src/hw/gloffscreen.h | 6 +- tizen/src/hw/gloffscreen_agl.c | 77 ++-- tizen/src/hw/gloffscreen_common.c | 4 + tizen/src/hw/gloffscreen_glx.c | 4 + tizen/src/hw/gloffscreen_test.c | 10 + tizen/src/hw/gloffscreen_wgl.c | 7 +- tizen/src/hw/gloffscreen_xcomposite.c | 8 +- tizen/src/hw/maru_device_ids.h | 3 + tizen/src/hw/maru_vga.c | 36 +- tizen/src/hw/maru_virtio_evdi.c | 196 ++++++++++ tizen/src/hw/maru_virtio_evdi.h | 26 ++ tizen/src/hw/maru_virtio_keyboard.c | 46 +-- tizen/src/hw/maru_virtio_keyboard.h | 2 +- tizen/src/hw/opengl_exec.c | 368 +++++++++++------- tizen/src/hw/opengl_func.h | 4 +- tizen/src/maru_err_table.c | 10 +- tizen/src/skin/client/native_src/share.c | 46 +-- .../client/skins/emul-320x480/default.dbi | 44 +-- .../client/skins/emul-480x800/default.dbi | 44 +-- .../client/skins/emul-600x1024/default.dbi | 44 +-- .../client/skins/emul-720x1280/default.dbi | 44 +-- .../tizen/emulator/skin/EmulatorShmSkin.java | 12 +- .../org/tizen/emulator/skin/EmulatorSkin.java | 19 +- .../tizen/emulator/skin/EmulatorSkinMain.java | 7 +- .../emulator/skin/EmulatorSkinState.java | 4 +- .../emulator/skin/config/EmulatorConfig.java | 8 +- .../layout/GeneralPurposeSkinComposer.java | 13 + .../skin/layout/PhoneShapeSkinComposer.java | 14 +- tizen/src/skin/maruskin_client.c | 17 +- tizen/src/skin/maruskin_operation.c | 60 +-- 43 files changed, 980 insertions(+), 475 deletions(-) mode change 100644 => 100755 hw/virtio-pci.c mode change 100644 => 100755 tizen/src/hw/maru_device_ids.h create mode 100755 tizen/src/hw/maru_virtio_evdi.c create mode 100755 tizen/src/hw/maru_virtio_evdi.h diff --git a/exec.c b/exec.c index a64e70bda0..8e6bf12671 100644 --- a/exec.c +++ b/exec.c @@ -1386,10 +1386,10 @@ void tb_link_page(TranslationBlock *tb, /* check whether the given addr is in TCG generated code buffer or not */ bool is_tcg_gen_code(uintptr_t tc_ptr) { - /* This can be called during code generation, code_gen_buffer_max_size + /* This can be called during code generation, code_gen_buffer_size is used instead of code_gen_ptr for upper boundary checking */ return (tc_ptr >= (uintptr_t)code_gen_buffer && - tc_ptr < (uintptr_t)(code_gen_buffer + code_gen_buffer_max_size)); + tc_ptr < (uintptr_t)(code_gen_buffer + code_gen_buffer_size)); } #endif diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c old mode 100644 new mode 100755 index eb6e23603a..f8ad8347c0 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -35,6 +35,7 @@ #include "range.h" #ifdef CONFIG_MARU #include "../tizen/src/hw/maru_device_ids.h" +#include "../tizen/src/hw/maru_virtio_evdi.h" #include "../tizen/src/mloop_event.h" #endif @@ -993,6 +994,28 @@ static void virtio_hwkey_exit_pci(PCIDevice *pci_dev) virtio_exit_pci(pci_dev); } +static int virtio_evdi_init_pci(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + VirtIODevice *vdev; + + vdev = virtio_evdi_init(&pci_dev->qdev); + if (!vdev) { + return -1; + } + virtio_init_pci(proxy, vdev); + return 0; +} + +static void virtio_evdi_exit_pci(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + + virtio_pci_stop_ioeventfd(proxy); + virtio_evdi_exit(proxy->vdev); + virtio_exit_pci(pci_dev); +} + #endif static Property virtio_blk_properties[] = { @@ -1290,6 +1313,27 @@ static TypeInfo virtio_hwkey_info = { .class_init = virtio_hwkey_class_init, }; +static void virtio_evdi_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->init = virtio_evdi_init_pci; + k->exit = virtio_evdi_exit_pci; + k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + k->device_id = PCI_DEVICE_ID_VIRTIO_EVDI; + k->revision = VIRTIO_PCI_ABI_VERSION; + k->class_id = PCI_CLASS_OTHERS; + dc->reset = virtio_pci_reset; +} + +static TypeInfo virtio_evdi_info = { + .name = "virtio-evdi-pci", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(VirtIOPCIProxy), + .class_init = virtio_evdi_class_init, +}; + + #endif /* CONFIG_MARU */ static void virtio_pci_register_types(void) @@ -1307,6 +1351,7 @@ static void virtio_pci_register_types(void) type_register_static(&virtio_keyboard_info); type_register_static(&virtio_esm_info); type_register_static(&virtio_hwkey_info); + type_register_static(&virtio_evdi_info); #endif } diff --git a/package/changelog b/package/changelog index 8ba16c7535..c2e2972dec 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,27 @@ +* 1.5.24 +- increased virtio keyboard queue and fixed overwrite bug +== SungMin Ha 2013-04-06 +* 1.5.23 +- no need to get the shmkey from another shm +== GiWoong Kim 2013-04-03 +* 1.5.18 +- modified skin's dbi file for key code of phone shape +== Sungmin Ha 2013-03-29 +* 1.5.17 +- modified elem index and mutex lock in virtio-kbd +== Sungmin Ha 2013-03-29 +* 1.5.16 +- modified Makefile to library load on mac from check-gl +== Sungmin Ha 2013-03-26 +* 1.5.15 +- Fix dibs build error. +== Sangjin Kim 2013-03-21 +* 1.5.14 +- Generate check-gl binary to use at an emulator-manager. +== Sangjin Kim 2013-03-21 +* 1.5.13 +- Enable pbuffer surface. +== Sangjin Kim 2013-03-20 * 1.5.12 - modified virtio hwkey device and improved hwkey mapping == Sungmin Ha 2013-03-20 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 59b53ad7a7..0aacd9e840 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version: 1.5.12 +Version: 1.5.24 Maintainer: Yeong-Kyoon Lee Source: emulator diff --git a/tizen/src/Makefile b/tizen/src/Makefile index 7a139d4d82..5f648f1502 100755 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -101,16 +101,16 @@ endif cp skin/client/emulator-skin.jar $(EMUL_DIR)/bin ifdef CONFIG_WIN32 - cp ../../i386-softmmu/check-gl.exe $(EMUL_DIR)/bin/ + cp ../../i386-softmmu/check-gl.exe $(EMUL_DIR)/bin cp check-hax.exe $(EMUL_DIR)/bin endif ifdef CONFIG_DARWIN - cp ../../i386-softmmu/check-gl $(EMUL_DIR)/bin/ + cp ../../i386-softmmu/check-gl $(EMUL_DIR)/bin cp check-hax $(EMUL_DIR)/bin cp sdbscript $(EMUL_DIR)/bin endif ifdef CONFIG_LINUX - cp ../../i386-softmmu/check-gl $(EMUL_DIR)/bin/ + cp ../../i386-softmmu/check-gl $(EMUL_DIR)/bin cp -pPr ../distrib/initscript/tizen-kvm $(EMUL_DIR)/etc cp -pPr ../distrib/initscript/45-tizen-kvm.rules $(EMUL_DIR)/etc endif @@ -135,6 +135,9 @@ ifdef CONFIG_DARWIN install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(EMUL_DIR)/bin/qemu-img install_name_tool -change /opt/local/lib/libz.1.dylib @loader_path/libz.1.dylib $(EMUL_DIR)/bin/qemu-img install_name_tool -change /opt/local/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(EMUL_DIR)/bin/qemu-img + install_name_tool -change /opt/local/lib/libglib-2.0.*.dylib @loader_path/libglib-2.0.0.dylib $(EMUL_DIR)/bin/check-gl + install_name_tool -change /opt/local/lib/libintl.8.dylib @loader_path/libintl.8.dylib $(EMUL_DIR)/bin/check-gl + install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(EMUL_DIR)/bin/check-gl @for target in $(TARGET_DIRS); do \ case "$$target" in \ @@ -204,14 +207,17 @@ endif cp skin/client/emulator-skin.jar $(DIBS_COMMON_DIR)/bin ifdef CONFIG_WIN32 + cp ../../i386-softmmu/check-gl.exe $(DIBS_COMMONL_DIR)/bin cp check-hax.exe $(DIBS_COMMON_DIR)/bin endif ifdef CONFIG_DARWIN + cp ../../i386-softmmu/check-gl $(DIBS_COMMON_DIR)/bin cp check-hax $(DIBS_COMMON_DIR)/bin cp sdbscript $(DIBS_COMMON_DIR)/bin endif ifdef CONFIG_LINUX + cp ../../i386-softmmu/check-gl $(DIBS_COMMON_DIR)/bin echo "Copying tizen-kvm to $(DIBS_X86_DIR)/etc" cp -pPr ../distrib/initscript/tizen-kvm $(DIBS_X86_DIR)/etc cp -pPr ../distrib/initscript/45-tizen-kvm.rules $(DIBS_X86_DIR)/etc @@ -235,6 +241,9 @@ ifdef CONFIG_DARWIN install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(DIBS_COMMON_DIR)/bin/qemu-img install_name_tool -change /opt/local/lib/libz.1.dylib @loader_path/libz.1.dylib $(DIBS_COMMON_DIR)/bin/qemu-img install_name_tool -change /opt/local/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(DIBS_COMMON_DIR)/bin/qemu-img + install_name_tool -change /opt/local/lib/libglib-2.0.*.dylib @loader_path/libglib-2.0.0.dylib $(DIBS_COMMON_DIR)/bin/check-gl + install_name_tool -change /opt/local/lib/libintl.8.dylib @loader_path/libintl.8.dylib $(DIBS_COMMON_DIR)/bin/check-gl + install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(DIBS_COMMON_DIR)/bin/check-gl @for target in $(TARGET_DIRS); do \ case "$$target" in \ diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index c8b354ed35..a7378fa12a 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -116,6 +116,7 @@ obj-y += maru_virtio_keyboard.o obj-y += maru_codec.o obj-y += maru_virtio_esm.o obj-y += maru_virtio_hwkey.o +obj-y += maru_virtio_evdi.o obj-$(CONFIG_PCI) += maru_camera_common_pci.o obj-$(CONFIG_LINUX) += maru_camera_linux_pci.o diff --git a/tizen/src/debug_ch.c b/tizen/src/debug_ch.c index 30088035f8..17954553f0 100644 --- a/tizen/src/debug_ch.c +++ b/tizen/src/debug_ch.c @@ -440,7 +440,7 @@ int dbg_log( enum _debug_class cls, struct _debug_channel *channel, ret += vsnprintf(buf + ret, sizeof(buf) - ret, format, valist ); va_end(valist); - open_flags = O_RDWR | O_APPEND | O_BINARY ; + open_flags = O_RDWR | O_APPEND | O_BINARY | O_CREAT ; fd = qemu_open(log_path, open_flags, 0666); if(fd < 0) { fprintf(stderr, "Can't open logfile: %s\n", log_path); diff --git a/tizen/src/ecs.c b/tizen/src/ecs.c index d38f63b6a4..0b2a0c0141 100644 --- a/tizen/src/ecs.c +++ b/tizen/src/ecs.c @@ -55,12 +55,14 @@ typedef struct ECS_State { struct epoll_event events[MAX_EVENTS]; int is_unix; int ecs_running; + QEMUTimer *alive_timer; Monitor *mon; } ECS_State; typedef struct ECS_Client { int client_fd; int client_id; + int keep_alive; const char* type; ECS_State *cs; JSONMessageParser parser; @@ -135,7 +137,7 @@ void send_to_client(int fd, const char *str) #define QMP_ACCEPT_UNKNOWNS 1 static void ecs_monitor_flush(ECS_Client *clii, Monitor *mon) { - if (clii && mon && mon->outbuf_index != 0) { + if (clii && 0 < clii->client_fd && mon && mon->outbuf_index != 0) { ecs_write(clii->client_fd, mon->outbuf, mon->outbuf_index); mon->outbuf_index = 0; } @@ -149,7 +151,6 @@ static void ecs_monitor_puts(ECS_Client *clii, Monitor *mon, const char *str) return; } - LOG("ecs_monitor_puts: %s", str); for(;;) { c = *str++; if (c == '\0') @@ -171,10 +172,8 @@ void ecs_vprintf(const char *type, const char *fmt, va_list ap) ECS_Client *clii; QTAILQ_FOREACH(clii, &clients, next) { - if (!strcmp(type, TYPE_ALL) || !strcmp(clii->type, type)) { - vsnprintf(buf, sizeof(buf), fmt, ap); - ecs_monitor_puts(clii, clii->cs->mon, buf); - } + vsnprintf(buf, sizeof(buf), fmt, ap); + ecs_monitor_puts(clii, clii->cs->mon, buf); } } @@ -200,10 +199,9 @@ static QDict *build_qmp_error_dict(const QError *err) return qobject_to_qdict(obj); } -static void ecs_json_emitter(ECS_Client *clii, const char* type, const QObject *data) +static void ecs_json_emitter(ECS_Client *clii, const QObject *data) { QString *json; - char type_full_string [OUT_BUF_SIZE]; json = qobject_to_json(data); @@ -244,7 +242,7 @@ static void ecs_protocol_emitter(ECS_Client *clii, const char* type, QObject *da clii->cs->mon->error = NULL; } - ecs_json_emitter(clii, type, QOBJECT(qmp)); + ecs_json_emitter(clii, QOBJECT(qmp)); QDECREF(qmp); } @@ -614,25 +612,6 @@ out: } -static void print_all_json(QObject *input_obj) -{ - const QDictEntry *ent; - QDict *input_dict; - - if (qobject_type(input_obj) != QTYPE_QDICT) { - qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object"); - return; - } - - input_dict = qobject_to_qdict(input_obj); - - for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){ - const char *arg_name = qdict_entry_key(ent); - const char *value_name = qdict_get_str(qobject_to_qdict(input_obj), arg_name); - LOG("received command: %s, value: %s", arg_name, value_name); - } -} - static int check_key(QObject *input_obj, const char *key) { const QDictEntry *ent; @@ -702,10 +681,6 @@ static void handle_ecs_command(JSONMessageParser *parser, QList *tokens, void *o return; } -#ifdef DEBUG - //print_all_json(obj); -#endif - def_target = check_key(obj, COMMANDS_TYPE); #ifdef DEBUG LOG("check_key(COMMAND_TYPE): %d", def_target); @@ -721,6 +696,14 @@ static void handle_ecs_command(JSONMessageParser *parser, QList *tokens, void *o return; } + type_name = qdict_get_str(qobject_to_qdict(obj), COMMANDS_TYPE); + + if (!strcmp(type_name, TYPE_DATA_SELF)) { + LOG("set client fd %d keep alive 0", clii->client_fd); + clii->keep_alive = 0; + return; + } + def_data = check_key(obj, COMMANDS_DATA); if (0 > def_data) { LOG("json format error: data."); @@ -730,8 +713,6 @@ static void handle_ecs_command(JSONMessageParser *parser, QList *tokens, void *o return; } - type_name = qdict_get_str(qobject_to_qdict(obj), COMMANDS_TYPE); - handle_qmp_command(clii, type_name, get_data_object(obj)); } @@ -739,10 +720,6 @@ static Monitor *monitor_create(void) { Monitor *mon; - // TODO: event related work - //key_timer = qemu_new_timer_ns(vm_clock, release_keys, NULL); - //monitor_protocol_event_init(); - mon = g_malloc0(sizeof(*mon)); if (NULL == mon) { LOG("monitor allocation failed."); @@ -764,6 +741,7 @@ static void ecs_client_close(ECS_Client* clii) if (0 <= clii->client_fd) { LOG("ecs client closed with fd: %d", clii->client_fd); closesocket(clii->client_fd); + clii->client_fd = -1; } QTAILQ_REMOVE(&clients, clii, next); if (NULL != clii) { @@ -784,6 +762,11 @@ static void ecs_close(ECS_State *cs) g_free(cs->mon); } + if (NULL != cs->alive_timer) { + qemu_del_timer(cs->alive_timer); + cs->alive_timer = NULL; + } + QTAILQ_FOREACH(clii, &clients, next) { ecs_client_close(clii); } @@ -798,6 +781,10 @@ static void ecs_close(ECS_State *cs) static int ecs_write(int fd, const uint8_t *buf, int len) { LOG("write buflen : %d, buf : %s", len, buf); + if (fd < 0) { + return -1; + } + return send_all(fd, buf, len); } @@ -835,21 +822,21 @@ static ssize_t ecs_recv(int fd, char *buf, size_t len) static void ecs_read (ECS_Client *clii) { - uint8_t buf[READ_BUF_LEN]; + uint8_t buf[READ_BUF_LEN]; int len, size; len = sizeof(buf); - if (!clii) { + if (!clii || 0 > clii->client_fd) { LOG ("read client info is NULL."); return; } - size = ecs_recv(clii->client_fd, (void *)buf, len); + size = ecs_recv(clii->client_fd, (char*)buf, len); if (0 == size) { ecs_client_close(clii); } else if (0 < size) { - LOG("read data: %s, size: %d", buf, size); - ecs_json_message_parser_feed(&clii->parser, (const char *) buf, size); + LOG("read data: %s, len: %d, size: %d", buf, len, size); + ecs_json_message_parser_feed(&clii->parser, (const char *) buf, size); } } @@ -960,6 +947,33 @@ static void epoll_init(ECS_State *cs) } } +static void alive_checker(void *opaque) +{ + ECS_State *cs = opaque; + ECS_Client *clii; + QObject *obj; + + obj = qobject_from_jsonf("{\"type\":\"self\"}"); + + if (NULL != current_ecs && !current_ecs->ecs_running) { + return; + } + + QTAILQ_FOREACH(clii, &clients, next) { + if (1 == clii->keep_alive) { + LOG("get client fd %d - keep alive fail", clii->client_fd); + ecs_client_close(clii); + continue; + } + LOG("set client fd %d - keep alive 1", clii->client_fd); + clii->keep_alive = 1; + ecs_json_emitter(clii, obj); + } + + qemu_mod_timer(cs->alive_timer, qemu_get_clock_ns(vm_clock) + + get_ticks_per_sec() * TIMER_ALIVE_S); +} + static int socket_initialize(ECS_State *cs, QemuOpts *opts) { int fd = -1; @@ -974,6 +988,11 @@ static int socket_initialize(ECS_State *cs, QemuOpts *opts) cs->listen_fd = fd; epoll_init(cs); + cs->alive_timer = qemu_new_timer_ns(vm_clock, alive_checker, cs); + + qemu_mod_timer(cs->alive_timer, qemu_get_clock_ns(vm_clock) + + get_ticks_per_sec() * TIMER_ALIVE_S); + return 0; } diff --git a/tizen/src/ecs.h b/tizen/src/ecs.h index 3b70a731a8..7fb1f30148 100644 --- a/tizen/src/ecs.h +++ b/tizen/src/ecs.h @@ -27,11 +27,8 @@ #define COMMANDS_TYPE "type" #define COMMANDS_DATA "data" -#define TYPE_ALL "all" -#define TYPE_ECP "ecp" -#define TYPE_SELF "self" -#define TYPE_QMP "qmp" -#define TYPE_VIRTUAL "virtual" +#define TIMER_ALIVE_S 60 +#define TYPE_DATA_SELF "self" int start_ecs(void); int stop_ecs(void); diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index b6d78ede81..ea7144454b 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -57,17 +57,6 @@ int get_emul_skin_enable(void) return _emul_info.skin_enable; } -/* current emulator condition */ -int get_emulator_condition(void) -{ - return _emul_state.emulator_condition; -} - -void set_emulator_condition(int state) -{ - _emul_state.emulator_condition = state; -} - /* lcd screen size */ void set_emul_lcd_size(int width, int height) { @@ -120,6 +109,28 @@ int get_emul_max_touch_point(void) return _emul_info.max_touch_point; } +/* base port for emualtor vm */ +void set_emul_vm_base_port(int port) +{ + _emul_info.vm_base_port = port; +} + +int get_emul_vm_base_port(void) +{ + return _emul_info.vm_base_port; +} + +/* current emulator condition */ +int get_emulator_condition(void) +{ + return _emul_state.emulator_condition; +} + +void set_emulator_condition(int state) +{ + _emul_state.emulator_condition = state; +} + /* emulator window scale */ void set_emul_win_scale(double scale_factor) { @@ -191,7 +202,7 @@ int get_host_lock_key_state(int key) return -1; } -/* manage CapsLock key state for usb keyboard input */ +/* manage CapsLock key state for host keyboard input */ void set_emul_caps_lock_state(int state) { _emul_state.qemu_caps_lock = state; @@ -199,10 +210,10 @@ void set_emul_caps_lock_state(int state) int get_emul_caps_lock_state(void) { - return _emul_state.qemu_caps_lock; + return _emul_state.qemu_caps_lock; } -/* manage NumLock key state for usb keyboard input */ +/* manage NumLock key state for host keyboard input */ void set_emul_num_lock_state(int state) { _emul_state.qemu_num_lock = state; @@ -210,5 +221,6 @@ void set_emul_num_lock_state(int state) int get_emul_num_lock_state(void) { - return _emul_state.qemu_num_lock; + return _emul_state.qemu_num_lock; } + diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 4a6baf9c7e..efb123230e 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -80,7 +80,8 @@ typedef struct EmulatorConfigInfo { int lcd_size_h; int sdl_bpp; int max_touch_point; - //TODO: + int vm_base_port; + /* add here */ } EmulatorConfigInfo; typedef struct EmulatorConfigState { @@ -90,7 +91,7 @@ typedef struct EmulatorConfigState { MultiTouchState qemu_mts; int qemu_caps_lock; int qemu_num_lock; - //TODO: + /* add here */ } EmulatorConfigState; @@ -100,6 +101,8 @@ void set_emul_lcd_size(int width, int height); void set_emul_win_scale(double scale); void set_emul_sdl_bpp(int bpp); void set_emul_max_touch_point(int cnt); +void set_emul_vm_base_port(int port); + void set_emulator_condition(int state); void set_emul_rotation(short rotation_type); void set_emul_caps_lock_state(int state); @@ -112,6 +115,8 @@ int get_emul_lcd_height(void); double get_emul_win_scale(void); int get_emul_sdl_bpp(void); int get_emul_max_touch_point(void); +int get_emul_vm_base_port(void); + int get_emulator_condition(void); short get_emul_rotation(void); MultiTouchState *get_emul_multi_touch_state(void); diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 32fe1af531..95a5688361 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -347,20 +347,20 @@ static void prepare_basic_features(void) tizen_base_port = get_sdb_base_port(); get_host_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); - // using "DNS" provided by default QEMU + /* using "DNS" provided by default QEMU */ g_strlcpy(dns, DEFAULT_QEMU_DNS_IP, strlen(DEFAULT_QEMU_DNS_IP) + 1); check_vm_lock(); socket_init(); make_vm_lock(); - sdb_setup(); + sdb_setup(); /* determine the base port for emulator */ + set_emul_vm_base_port(tizen_base_port); gchar * const tmp_str = g_strdup_printf(" sdb_port=%d," - " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s" - " dns1=%s", tizen_base_port, - http_proxy, https_proxy, ftp_proxy, socks_proxy, - dns); + " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s" + " dns1=%s", get_emul_vm_base_port(), + http_proxy, https_proxy, ftp_proxy, socks_proxy, dns); g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE); diff --git a/tizen/src/hw/gl_func_perso.h b/tizen/src/hw/gl_func_perso.h index 1488343e9c..4d7ad9eff3 100644 --- a/tizen/src/hw/gl_func_perso.h +++ b/tizen/src/hw/gl_func_perso.h @@ -60,6 +60,10 @@ MAGIC_MACRO(glXGetDriverConfig), MAGIC_MACRO(glXSwapIntervalSGI), MAGIC_MACRO(glXCreatePixmap), MAGIC_MACRO(glXDestroyPixmap), +MAGIC_MACRO(glXBindTexImageARB_fake), +MAGIC_MACRO(glXReleaseTexImageARB_fake), +MAGIC_MACRO(glXCreatePbuffer), +MAGIC_MACRO(glXDestroyPbuffer), MAGIC_MACRO(glGetString), diff --git a/tizen/src/hw/gloffscreen.h b/tizen/src/hw/gloffscreen.h index 806db14b68..11547c71be 100644 --- a/tizen/src/hw/gloffscreen.h +++ b/tizen/src/hw/gloffscreen.h @@ -83,8 +83,10 @@ extern void glo_context_destroy(GloContext *context); /* Update the context in surface and free previous light-weight context */ extern void glo_surface_update_context(GloSurface *surface, GloContext *context, int free_flags); -/* Link the pixmap associated with surface as texture */ -extern void glo_surface_as_texture(GloSurface *surface); +/* Link the pixmap/pbuffer associated with surface as texture. + * ctxt is the target context for the texture operation + */ +extern void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface); /* Create a surface with given width and height, */ extern GloSurface *glo_surface_create(int width, int height, GloContext *context); diff --git a/tizen/src/hw/gloffscreen_agl.c b/tizen/src/hw/gloffscreen_agl.c index 4a42907681..0d61423e69 100644 --- a/tizen/src/hw/gloffscreen_agl.c +++ b/tizen/src/hw/gloffscreen_agl.c @@ -188,51 +188,52 @@ GloContext *__glo_context_create(int formatFlags) GloContext *glo_context_create(int formatFlags, GloContext *shareLists) { - GloContext *context = __glo_context_create(formatFlags); - if(!context) - return NULL; + GloContext *context = __glo_context_create(formatFlags); + if(!context) + return NULL; - context->context = aglCreateContext(context->pixelFormat, shareLists ? shareLists->context : NULL); - if (context->context == NULL) - { - fprintf(stderr, "aglCreateContext failed: %s", aglErrorString(aglGetError())); - } - else - { - if(context->pixelFormat != NULL) - { - aglDestroyPixelFormat(context->pixelFormat); - context->pixelFormat = NULL; - } - } + context->context = aglCreateContext(context->pixelFormat, shareLists ? shareLists->context : NULL); + if (context->context == NULL) + { + fprintf(stderr, "aglCreateContext failed: %s", aglErrorString(aglGetError())); + } - TRACE("context=%p", context); - return context; -} + else + { + if(context->pixelFormat != NULL) + { + aglDestroyPixelFormat(context->pixelFormat); + context->pixelFormat = NULL; + } + } + TRACE("context=%p", context); + return context; +} + /* Destroy a previously created OpenGL context */ void glo_context_destroy(GloContext *context) { - TRACE("context=%p", context); - if (context) - { - aglDestroyContext(context->context); - if(context->pixelFormat != NULL) - { - aglDestroyPixelFormat(context->pixelFormat); - context->pixelFormat = NULL; - } - context->context = NULL; - g_free(context); - } - } + TRACE("context=%p", context); + if (context) + { + aglDestroyContext(context->context); + if(context->pixelFormat != NULL) + { + aglDestroyPixelFormat(context->pixelFormat); + context->pixelFormat = NULL; + } + context->context = NULL; + g_free(context); + } +} void glo_surface_update_context(GloSurface *surface, GloContext *context, int free_flags) { if ( surface->context ) { - if (free_flags) /* light-weight context */ - g_free(surface->context); + if ( free_flags) /* light-weight context */ + g_free(surface->context); } surface->context = context; } @@ -334,8 +335,9 @@ void glo_surface_get_size(GloSurface *surface, int *width, int *height) } /* Bind the surface as texture */ -void glo_surface_as_texture(GloSurface *surface) +void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface) { +#if 0 //Not QUit sure about this function; int glFormat, glType; glo_surface_updatecontents(surface); @@ -345,8 +347,11 @@ void glo_surface_as_texture(GloSurface *surface) /* glTexImage2D use different RGB order than the contexts in the pixmap surface */ /* glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->image->data);*/ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, glFormat, glType, surface->pbuffer); +#else + if (aglTexImagePBuffer(ctxt->context, surface->pbuffer, GL_BACK) == GL_FALSE) + fprintf(stderr, "aglTexImagePBuffer failed: %s", aglErrorString(aglGetError())); - +#endif } void glo_surface_release_texture(GloSurface *surface) diff --git a/tizen/src/hw/gloffscreen_common.c b/tizen/src/hw/gloffscreen_common.c index 433c78edad..bd1285421c 100644 --- a/tizen/src/hw/gloffscreen_common.c +++ b/tizen/src/hw/gloffscreen_common.c @@ -40,6 +40,10 @@ #include #include +#ifdef MANGLE_OPENGL_SYMBOLS +#include "gl_mangled.h" +#endif + void *g_malloc(size_t size); void *g_realloc(void *ptr, size_t size); void g_free(void *ptr); diff --git a/tizen/src/hw/gloffscreen_glx.c b/tizen/src/hw/gloffscreen_glx.c index 6580dea098..f649a0ff3e 100644 --- a/tizen/src/hw/gloffscreen_glx.c +++ b/tizen/src/hw/gloffscreen_glx.c @@ -39,6 +39,10 @@ #include #include +#ifdef MANGLE_OPENGL_SYMBOLS +#include "gl_mangled.h" +#endif + struct GloMain { Display *dpy; int use_ximage; diff --git a/tizen/src/hw/gloffscreen_test.c b/tizen/src/hw/gloffscreen_test.c index 67ce8f28f1..2799421938 100644 --- a/tizen/src/hw/gloffscreen_test.c +++ b/tizen/src/hw/gloffscreen_test.c @@ -42,6 +42,10 @@ #include #endif +#ifdef MANGLE_OPENGL_SYMBOLS +#include "gl_mangled.h" +#endif + // --------------------------------------------------- // Copied from glx.h as we need them in windows too /* @@ -90,6 +94,12 @@ int gl_acceleration_capability_check (void) { 0, }; +#ifdef MANGLE_OPENGL_SYMBOLS + if (mgl_load_symbols("libGL.so.1")) { + return CHECK_FAIL; + } +#endif + int bufferFlags = glo_flags_get_from_glx(bufferAttributes, 0); int bpp = glo_flags_get_bytes_per_pixel(bufferFlags); int glFormat, glType; diff --git a/tizen/src/hw/gloffscreen_wgl.c b/tizen/src/hw/gloffscreen_wgl.c index 0290d76474..15f22fe2da 100644 --- a/tizen/src/hw/gloffscreen_wgl.c +++ b/tizen/src/hw/gloffscreen_wgl.c @@ -659,6 +659,9 @@ static const char *STANDARD_GL_FUNCTIONS ={ "glXGetVisualFromFBConfig\0" "glXIsDirect\0" "glXCreatePixmap\0" +"glXDestroyPixmap\0" +"glXCreatePbuffer\n" +"glXDestroyPbuffer\n" "\0" }; @@ -879,7 +882,7 @@ void glo_surface_update_context(GloSurface *surface, GloContext *context, int fr if ( surface->context ) { - if ( free_flags) /* light-weight context */ + if ( free_flags ) /* light-weight context */ g_free(surface->context); } surface->context = context; @@ -964,7 +967,7 @@ void glo_surface_get_size(GloSurface *surface, int *width, int *height) { } /* Bind the surface as texture */ -void glo_surface_as_texture(GloSurface *surface) +void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface) { #if 0 int glFormat, glType; diff --git a/tizen/src/hw/gloffscreen_xcomposite.c b/tizen/src/hw/gloffscreen_xcomposite.c index 4389749f6f..6162d721c8 100644 --- a/tizen/src/hw/gloffscreen_xcomposite.c +++ b/tizen/src/hw/gloffscreen_xcomposite.c @@ -40,6 +40,10 @@ #include #include +#ifdef MANGLE_OPENGL_SYMBOLS +#include "gl_mangled.h" +#endif + void *g_malloc(size_t size); void *g_realloc(void *ptr, size_t size); void g_free(void *ptr); @@ -264,7 +268,7 @@ void glo_surface_update_context(GloSurface *surface, GloContext *context, int fr if ( surface->context ) { - if ( free_flags ) /* light-weight context */ + if (free_flags) /* light-weight context */ g_free(surface->context); } surface->context = context; @@ -475,7 +479,7 @@ void glo_surface_get_size(GloSurface *surface, int *width, int *height) { } /* Bind the surface as texture */ -void glo_surface_as_texture(GloSurface *surface) +void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface) { #if 0 void (*ptr_func_glXBindTexImageEXT) (Display *dpy, GLXDrawable draw, int buffer, int *attrib_list); diff --git a/tizen/src/hw/maru_device_ids.h b/tizen/src/hw/maru_device_ids.h old mode 100644 new mode 100755 index 8a2a0bd8e9..47a2fda274 --- a/tizen/src/hw/maru_device_ids.h +++ b/tizen/src/hw/maru_device_ids.h @@ -12,6 +12,7 @@ * SungMin Ha * JiHye Kim * GiWoong Kim + * DaiYoung Kim * YeongKyoon Lee * DongKyun Yun * DoHyung Hong @@ -52,6 +53,7 @@ #define PCI_DEVICE_ID_VIRTIO_KEYBOARD 0x1020 #define PCI_DEVICE_ID_VIRTIO_ESM 0x1024 #define PCI_DEVICE_ID_VIRTIO_HWKEY 0x1028 +#define PCI_DEVICE_ID_VIRTIO_EVDI 0x1028 /* Virtio */ /* @@ -84,5 +86,6 @@ #define VIRTIO_ID_KEYBOARD 12 #define VIRTIO_ID_ESM 13 #define VIRTIO_ID_HWKEY 14 +#define VIRTIO_ID_EVDI 15 #endif /* MARU_DEVICE_IDS_H_ */ diff --git a/tizen/src/hw/maru_vga.c b/tizen/src/hw/maru_vga.c index a6788be930..fbb7f81bf5 100644 --- a/tizen/src/hw/maru_vga.c +++ b/tizen/src/hw/maru_vga.c @@ -2,7 +2,7 @@ * Maru vga device * Based on qemu/hw/vga.c * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim @@ -56,12 +56,12 @@ #include #include #include "maru_err_table.h" +#include "emul_state.h" #endif #ifdef CONFIG_USE_SHM void *shared_memory = (void*) 0; int skin_shmid; -int port_shmid; #endif @@ -1873,34 +1873,19 @@ void maru_vga_common_init(VGACommonState *s) vga_dirty_log_start(s); #ifdef CONFIG_USE_SHM - int mykey; - void *temp; + /* base + 1 = sdb port */ + /* base + 2 = shared memory key */ + int mykey = get_emul_vm_base_port() + 2; - port_shmid = shmget((key_t)SHMKEY, (size_t)MAXLEN, 0666 | IPC_CREAT); - if (port_shmid == -1) { - ERR("shmget failed\n"); - perror("maru_vga: "); - exit(1); - } - - temp = shmat(port_shmid, (char*)0x0, 0); - if (temp == (void *)-1) { - ERR("shmat failed\n"); - perror("maru_vga: "); - exit(1); - } - - mykey = atoi(temp); - shmdt(temp); - INFO("shared memory key: %d, vga ram_size : %d\n", mykey, s->vram_size); skin_shmid = shmget((key_t)mykey, (size_t)s->vram_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" - "Shared memory is not enough."); + maru_register_exit_msg(MARU_EXIT_UNKNOWN, + (char*) "Cannot launch this VM.\n" + "Shared memory is not enough."); exit(0); } @@ -1929,11 +1914,6 @@ void maru_vga_common_fini(void) ERR("shmctl failed\n"); perror("maru_vga: "); } - - if (shmctl(port_shmid, IPC_RMID, 0) == -1) { - ERR("temp shmctl failed\n"); - perror("maru_vga: "); - } } #endif diff --git a/tizen/src/hw/maru_virtio_evdi.c b/tizen/src/hw/maru_virtio_evdi.c new file mode 100755 index 0000000000..01d54ebf51 --- /dev/null +++ b/tizen/src/hw/maru_virtio_evdi.c @@ -0,0 +1,196 @@ +/* + * Virtio EmulatorVirtualDeviceInterface Device + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: + * DaiYoung Kim + * YeongKyoon Lee + * + * 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_device_ids.h" +#include "maru_virtio_evdi.h" +#include "debug_ch.h" + +MULTI_DEBUG_CHANNEL(qemu, virtio-evdi); + +#define VIRTIO_EVDI_DEVICE_NAME "virtio-evdi" + +#define __MAX_BUF_SIZE 1024 + +enum { + IOTYPE_INPUT = 0, + IOTYPE_OUTPUT = 1 +}; + +struct msg_info { + char buf[__MAX_BUF_SIZE]; + uint32_t use; +}; + +typedef struct VirtIO_EVDI{ + VirtIODevice vdev; + VirtQueue *rvq; + VirtQueue *svq; + DeviceState *qdev; + + QEMUBH *bh; +} VirtIO_EVDI; + + +VirtIO_EVDI* vio_evdi; + +static int g_cnt = 0; + +static void virtio_evdi_recv(VirtIODevice *vdev, VirtQueue *vq) +{ + int index = 0; + + struct msg_info _msg; + + INFO(">> evdirecv : virtio_evdi_recv\n"); + + if (unlikely(virtio_queue_empty(vio_evdi->rvq))) { + INFO(">> evdirecv : virtqueue is empty\n"); + return; + } + + VirtQueueElement elem; + + while ((index = virtqueue_pop(vq, &elem))) { + + INFO(">> evdirecv : virtqueue_pop. index: %d\n", index); + INFO(">> evdirecv : element out_num : %d, in_num : %d\n", elem.out_num, elem.in_num); + + if (index == 0) { + INFO("evdirecv : virtqueue break\n"); + break; + } + + INFO(">> evdirecv : received use = %d, iov_len = %d\n", _msg.use, elem.in_sg[0].iov_len); + + memcpy(&_msg, elem.in_sg[0].iov_base, elem.in_sg[0].iov_len); + + + if (g_cnt < 10) + { + memset(&_msg, 0x00, sizeof(_msg)); + sprintf(_msg.buf, "test_%d\n", g_cnt++); + memcpy(elem.in_sg[0].iov_base, &_msg, sizeof(struct msg_info)); + + INFO(">> evdirecv : send to guest msg use = %d, msg = %s, iov_len = %d \n", + _msg.use, _msg.buf, elem.in_sg[0].iov_len); + + + virtqueue_push(vq, &elem, sizeof(VirtIO_EVDI)); + virtio_notify(&vio_evdi->vdev, vq); + } + } + + INFO("enf of virtio_evdi_recv\n"); +} + + +static void virtio_evdi_send(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIO_EVDI *vevdi = (VirtIO_EVDI *)vdev; + int index = 0; + struct msg_info _msg; + + INFO("<< evdisend : virtio_evdi_send \n"); + if (virtio_queue_empty(vevdi->svq)) { + INFO("<< evdisend : virtqueue is empty.\n"); + return; + } + + VirtQueueElement elem; + + while ((index = virtqueue_pop(vq, &elem))) { + + INFO("<< evdisend : virtqueue pop. index: %d\n", index); + INFO("<< evdisend : element out_num : %d, in_num : %d\n", elem.out_num, elem.in_num); + + if (index == 0) { + INFO("<< evdisend : virtqueue break\n"); + break; + } + + INFO("<< evdisend : use=%d, iov_len = %d\n", _msg.use, elem.out_sg[0].iov_len); + + memset(&_msg, 0x00, sizeof(_msg)); + memcpy(&_msg, elem.out_sg[0].iov_base, elem.out_sg[0].iov_len); + + INFO("<< evdisend : recv from guest len = %d, msg = %s \n", _msg.use, _msg.buf); + } + + virtqueue_push(vq, &elem, sizeof(VirtIO_EVDI)); + virtio_notify(&vio_evdi->vdev, vq); +} + +static void maru_virtio_evdi_notify(void) +{ + TRACE("nothing to do.\n"); +} + +static uint32_t virtio_evdi_get_features(VirtIODevice *vdev, + uint32_t request_feature) +{ + TRACE("virtio_evdi_get_features.\n"); + return 0; +} + +static void maru_evdi_bh(void *opaque) +{ + maru_virtio_evdi_notify(); +} + +VirtIODevice *virtio_evdi_init(DeviceState *dev) +{ + INFO("initialize evdi device\n"); + + vio_evdi = (VirtIO_EVDI *)virtio_common_init(VIRTIO_EVDI_DEVICE_NAME, + VIRTIO_ID_EVDI, 0, sizeof(VirtIO_EVDI)); + if (vio_evdi == NULL) { + ERR("failed to initialize evdi device\n"); + return NULL; + } + + vio_evdi->vdev.get_features = virtio_evdi_get_features; + vio_evdi->rvq = virtio_add_queue(&vio_evdi->vdev, 256, virtio_evdi_recv); + vio_evdi->svq = virtio_add_queue(&vio_evdi->vdev, 256, virtio_evdi_send); + vio_evdi->qdev = dev; + + vio_evdi->bh = qemu_bh_new(maru_evdi_bh, vio_evdi); + + return &vio_evdi->vdev; +} + +void virtio_evdi_exit(VirtIODevice *vdev) +{ + INFO("destroy evdi device\n"); + + if (vio_evdi->bh) { + qemu_bh_delete(vio_evdi->bh); + } + + virtio_cleanup(vdev); +} + diff --git a/tizen/src/hw/maru_virtio_evdi.h b/tizen/src/hw/maru_virtio_evdi.h new file mode 100755 index 0000000000..ad88b682d4 --- /dev/null +++ b/tizen/src/hw/maru_virtio_evdi.h @@ -0,0 +1,26 @@ +/* + * maru_virtio_evdi.h + * + * Created on: 2013. 3. 30. + * Author: dykim + */ + +#ifndef MARU_VIRTIO_EVDI_H_ +#define MARU_VIRTIO_EVDI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "hw/virtio.h" + +VirtIODevice *virtio_evdi_init(DeviceState *dev); + +void virtio_evdi_exit(VirtIODevice *vdev); + +#ifdef __cplusplus +} +#endif + + +#endif /* MARU_VIRTIO_EVDI_H_ */ diff --git a/tizen/src/hw/maru_virtio_keyboard.c b/tizen/src/hw/maru_virtio_keyboard.c index 00c4f3d6d8..6cae72f2e7 100644 --- a/tizen/src/hw/maru_virtio_keyboard.c +++ b/tizen/src/hw/maru_virtio_keyboard.c @@ -61,22 +61,13 @@ void virtio_keyboard_notify(void *opaque) EmulKbdEvent *kbdevt; int index = 0; int written_cnt = 0; - int *rptr = NULL; if (!vkbd) { ERR("VirtIOKeyboard is NULL.\n"); return; } - qemu_mutex_lock(&vkbd->event_mutex); - written_cnt = vkbd->kbdqueue.wptr; TRACE("[Enter] virtqueue notifier. %d\n", written_cnt); - qemu_mutex_unlock(&vkbd->event_mutex); - if (written_cnt < 0) { - TRACE("there is no input data to copy to guest.\n"); - return; - } - rptr = &vkbd->kbdqueue.rptr; if (!virtio_queue_ready(vkbd->vq)) { INFO("virtqueue is not ready.\n"); @@ -84,30 +75,41 @@ void virtio_keyboard_notify(void *opaque) } if (vkbd->kbdqueue.rptr == VIRTIO_KBD_QUEUE_SIZE) { - *rptr = 0; + vkbd->kbdqueue.rptr = 0; } + qemu_mutex_lock(&vkbd->event_mutex); + written_cnt = vkbd->kbdqueue.wptr; + while ((written_cnt--)) { - index = *rptr; - kbdevt = &vkbd->kbdqueue.kbdevent[index]; + kbdevt = &vkbd->kbdqueue.kbdevent[vkbd->kbdqueue.rptr]; + + while (((EmulKbdEvent*)(elem.in_sg[index].iov_base))->code != 0) { + if (++index == VIRTIO_KBD_QUEUE_SIZE) { + index--; + TRACE("virtio queue is full.\n"); + break; + } + } /* Copy keyboard data into guest side. */ - TRACE("copy: keycode %d, type %d, index %d\n", + TRACE("copy: keycode %d, type %d, elem_index %d\n", kbdevt->code, kbdevt->type, index); - memcpy(elem.in_sg[index].iov_base, kbdevt, sizeof(EmulKbdEvent)); + memcpy(elem.in_sg[index++].iov_base, kbdevt, sizeof(EmulKbdEvent)); memset(kbdevt, 0x00, sizeof(EmulKbdEvent)); - qemu_mutex_lock(&vkbd->event_mutex); if (vkbd->kbdqueue.wptr > 0) { vkbd->kbdqueue.wptr--; + TRACE("written_cnt: %d, wptr: %d, qemu_index: %d\n", written_cnt, vkbd->kbdqueue.wptr, vkbd->kbdqueue.rptr); } - qemu_mutex_unlock(&vkbd->event_mutex); - (*rptr)++; - if (*rptr == VIRTIO_KBD_QUEUE_SIZE) { - *rptr = 0; + vkbd->kbdqueue.rptr++; + if (vkbd->kbdqueue.rptr == VIRTIO_KBD_QUEUE_SIZE) { + vkbd->kbdqueue.rptr = 0; + TRACE("kbdqueue is full.\n"); } } + qemu_mutex_unlock(&vkbd->event_mutex); virtqueue_push(vkbd->vq, &elem, sizeof(EmulKbdEvent)); virtio_notify(&vkbd->vdev, vkbd->vq); @@ -199,11 +201,11 @@ static void virtio_keyboard_event(void *opaque, int keycode) vkbd->extension_key = 1; } + qemu_mutex_lock(&vkbd->event_mutex); memcpy(&vkbd->kbdqueue.kbdevent[(*index)++], &kbdevt, sizeof(kbdevt)); TRACE("event: keycode %d, type %d, index %d.\n", kbdevt.code, kbdevt.type, ((*index) - 1)); - qemu_mutex_lock(&vkbd->event_mutex); vkbd->kbdqueue.wptr++; qemu_mutex_unlock(&vkbd->event_mutex); @@ -242,7 +244,7 @@ VirtIODevice *virtio_keyboard_init(DeviceState *dev) vkbd->vdev.get_features = virtio_keyboard_get_features; - vkbd->vq = virtio_add_queue(&vkbd->vdev, 64, virtio_keyboard_handle); + vkbd->vq = virtio_add_queue(&vkbd->vdev, 128, virtio_keyboard_handle); vkbd->qdev = dev; /* bottom half */ @@ -250,7 +252,7 @@ VirtIODevice *virtio_keyboard_init(DeviceState *dev) /* register keyboard handler */ qemu_add_kbd_event_handler(virtio_keyboard_event, vkbd); - + return &vkbd->vdev; } diff --git a/tizen/src/hw/maru_virtio_keyboard.h b/tizen/src/hw/maru_virtio_keyboard.h index a744760cd8..4cd9b4ce7a 100644 --- a/tizen/src/hw/maru_virtio_keyboard.h +++ b/tizen/src/hw/maru_virtio_keyboard.h @@ -39,7 +39,7 @@ extern "C" { #include "hw/virtio.h" #define VIRTIO_KBD_DEVICE_NAME "virtio-keyboard" -#define VIRTIO_KBD_QUEUE_SIZE 10 +#define VIRTIO_KBD_QUEUE_SIZE 100 typedef struct EmulKbdEvent { uint16_t code; diff --git a/tizen/src/hw/opengl_exec.c b/tizen/src/hw/opengl_exec.c index 43c1f353dd..5085d4a293 100644 --- a/tizen/src/hw/opengl_exec.c +++ b/tizen/src/hw/opengl_exec.c @@ -209,8 +209,8 @@ enum { }; enum { - SURFACE_PENDING, /* Created with light-weight context */ - SURFACE_ACTIVE, /* Ready after MakeCurrent */ + SURFACE_PENDING, /* Created with light-weight context */ + SURFACE_ACTIVE, /* Ready after MakeCurrent */ }; typedef struct QGloSurface { @@ -219,7 +219,7 @@ typedef struct QGloSurface { ClientGLXDrawable *client_drawable; int type; /* window, pixmap or pbuffer */ int ready; - int status; + int status; int ref; QTAILQ_ENTRY(QGloSurface) next; } QGloSurface; @@ -628,17 +628,12 @@ static void unbind_qsurface(GLState *state, state->current_qsurface = NULL; } -/* Find the qsurface with required drawable in active & pending qsurfaces */ +/* Find the qsurface with required drawable in all pixmap/pbuffer surfaces */ QGloSurface* find_qsurface_from_client_drawable(ProcessState *process, ClientGLXDrawable client_drawable) { - /* search for surfaces in current conetxt */ int i; - QGloSurface *qsurface = get_qsurface_from_client_drawable(process->current_state, client_drawable); - - if (qsurface) - return qsurface; + QGloSurface *qsurface; - /* search the pending surfaces */ for ( i = 0; i < process->nb_qsurf; i++ ) { qsurface = process->pending_qsurfaces[i]; @@ -661,7 +656,7 @@ static int set_current_qsurface(GLState *state, QTAILQ_FOREACH(qsurface, &state->qsurfaces, next) { if(qsurface->client_drawable == client_drawable) { state->current_qsurface = qsurface; - qsurface->glstate = state; + qsurface->glstate = state; return 1; } } @@ -700,14 +695,13 @@ static int link_drawable(ProcessState *process, ClientGLXDrawable drawable) return 0; } -/* Need to create pixmap surface when guest do so, as guest may use it before - * MakeCurrent. As no context available at this point, we do the follwoing: +/* Need to create pixmap/pbuffer surface when guest do so, as guest may use it + * before MakeCurrent. As no context available at this point, do the following: * 1. Create one light-weight context just for surface creation. * 2. Store this qsurface, and link it with right context when MakeCurrent */ static void keep_qsurface(ProcessState *process, QGloSurface *qsurface) { - int i; process->pending_qsurfaces = g_realloc(process->pending_qsurfaces, (process->nb_qsurf + 1) * sizeof(QGloSurface*)); @@ -740,17 +734,17 @@ static int link_qsurface(ProcessState *process, GLState *glstate, ClientGLXDrawa #endif qsurface->ref = 1; - if(qsurface->status == SURFACE_PENDING) - { - glo_surface_update_context(qsurface->surface, glstate->context, 1); - qsurface->status = SURFACE_ACTIVE; - } - else - { - unbind_qsurface(qsurface->glstate, qsurface); - glo_surface_update_context(qsurface->surface, glstate->context, 0); + if(qsurface->status == SURFACE_PENDING) + { + glo_surface_update_context(qsurface->surface, glstate->context, 1); + qsurface->status = SURFACE_ACTIVE; + } + else + { + unbind_qsurface(qsurface->glstate, qsurface); + glo_surface_update_context(qsurface->surface, glstate->context, 0); - } + } bind_qsurface(glstate, qsurface); return 1; @@ -760,8 +754,9 @@ static int link_qsurface(ProcessState *process, GLState *glstate, ClientGLXDrawa return 0; } -/* Pixmap can be used as texture via glEGLImageTargetTexture2DOES, so need keep - * the mapping between them to add proper action when bind the texture again +/* Pixmap and Pbuffer can be used as texture via glEGLImageTargetTexture2DOES + * and glXBindTexImage, so need keep the mapping between them to add proper + * action when bind the texture again */ static void del_pixmap_texture_mapping(GLState *state, unsigned int texture) @@ -780,6 +775,23 @@ static void del_pixmap_texture_mapping(GLState *state, } } +static void remove_pixmap_texture_mapping(GLState *state, + ClientGLXDrawable drawable) +{ + int i; + for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ ) + { + if ( state->pixmapTextures[i].used && + state->pixmapTextures[i].drawable == drawable ) + { + state->pixmapTextures[i].used = 0; + state->pixmapTextures[i].texture = 0; + state->pixmapTextures[i].drawable = 0; + return; + } + } +} + static int add_pixmap_texture_mapping(GLState *state, unsigned int texture, ClientGLXDrawable drawable) { @@ -796,8 +808,7 @@ static int add_pixmap_texture_mapping(GLState *state, } } - if ( i >= MAX_PIXMAP_TEXTURE ) - return 0; + return 0; } static ClientGLXDrawable find_pixmap_texture(GLState *state, @@ -1400,21 +1411,21 @@ shadersrc_gles_to_gl(GLsizei count, const char** string, char **s, const GLint* */ static void mac_dump_texture() { - int w, h; - unsigned char *buf; + int w, h; + unsigned char *buf; - /* only handle target=GL_TEXTURE_2D, level=0, format=GL_RGBA, type=GL_UNSIGNED_BYTE */ - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); + /* only handle target=GL_TEXTURE_2D, level=0, format=GL_RGBA, type=GL_UNSIGNED_BYTE */ + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); - if ( w == 0 && h == 0 ) - return; + if ( w == 0 && h == 0 ) + return; - buf = g_malloc( (w*4) * h); /* XXX:need allignment? */ + buf = g_malloc( (w*4) * h); /* XXX:need allignment? */ - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); - g_free(buf); + g_free(buf); } #endif @@ -1759,7 +1770,7 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args ret.i = glo_surface_makecurrent(glstate->current_qsurface->surface); /* if (reset_texture)*/ -/* glo_surface_as_texture(old_glstate->current_qsurface->surface);*/ +/* glo_surface_as_texture(process->current_state->context, old_glstate->current_qsurface->surface);*/ } } break; @@ -2022,16 +2033,18 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args DEBUGF( "glXCreatePixmap: %dX%d.\n", width, height); qsurface->surface = glo_surface_create(width, height, context); qsurface->client_drawable = client_drawable; - qsurface->type = SURFACE_PIXMAP; - qsurface->status = SURFACE_PENDING; + qsurface->type = SURFACE_PIXMAP; + qsurface->status = SURFACE_PENDING; /* qsurface->ref = 1;*/ /* Keep this surface, will link it with context in MakeCurrent */ keep_qsurface(process, qsurface); /* If this pixmap is linked as texture previously */ - if (link_drawable(process, client_drawable)) - glo_surface_as_texture(qsurface->surface); + if (link_drawable(process, client_drawable)) + glo_surface_as_texture(process->current_state->context, + qsurface->surface); + ret.i = client_drawable; @@ -2040,6 +2053,17 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args } case glXDestroyPixmap_func: { + /* glXPixmap same as input Pixmap */ + ClientGLXDrawable client_drawable = to_drawable(args[1]); + QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable); + if ( qsurface && + qsurface != process->current_state->current_qsurface && + qsurface->glstate == NULL && + qsurface->type == SURFACE_PIXMAP ) + { + glo_surface_destroy(qsurface->surface); + g_free(qsurface); + } break; } case glEGLImageTargetTexture2DOES_fake_func: @@ -2063,10 +2087,93 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args } } else - glo_surface_as_texture(qsurface->surface); + glo_surface_as_texture(process->current_state->context, qsurface->surface); + + break; + } + case glXBindTexImageARB_fake_func: + { + ClientGLXDrawable client_drawable = to_drawable(args[1]); + QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable); + ret.i = 0; + + + if ( qsurface ) + { + add_pixmap_texture_mapping(process->current_state, + process->current_state->bindTexture2D, + client_drawable); + glo_surface_as_texture(process->current_state->context, qsurface->surface); + ret.i = 1; + } + else + DEBUGF( "Not found pbuffer surface for BindTexImage!\n"); + + break; + } + case glXReleaseTexImageARB_fake_func: + { + ClientGLXDrawable client_drawable = to_drawable(args[1]); + QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable); + + if ( qsurface ) + { + remove_pixmap_texture_mapping(process->current_state, + client_drawable); + glo_surface_release_texture(qsurface->surface); + } + + break; + } + case glXCreatePbuffer_func: + { + int client_fbconfig = args[1]; + + ret.i = 0; + const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig); + + if (fbconfig) { + + /* Create a light-weight context just for creating surface */ + GloContext *context = __glo_context_create(fbconfig->formatFlags); + + QGloSurface *qsurface = calloc(1, sizeof(QGloSurface)); + + /* get the width and height */ + int width, height; + glo_geometry_get_from_glx((int*)args[2], &width, &height); + + DEBUGF( "glXCreatePbuffer: %dX%d.\n", width, height); + qsurface->surface = glo_surface_create(width, height, context); + /* Use GloSurface handler as no input client_drawable, and + * keep only low 32bit of handler on x86_64 host. */ + qsurface->client_drawable = (int)qsurface->surface; + qsurface->type = SURFACE_PBUFFER; + qsurface->status = SURFACE_PENDING; + /* qsurface->ref = 1;*/ + + /* Keep this surface, will link it with context in MakeCurrent */ + keep_qsurface(process, qsurface); + + ret.i = qsurface->client_drawable; + } + break; + } + case glXDestroyPbuffer_func: + { + ClientGLXDrawable client_drawable = to_drawable(args[1]); + QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable); + if ( qsurface && + qsurface != process->current_state->current_qsurface && + qsurface->glstate == NULL && + qsurface->type == SURFACE_PBUFFER ) + { + glo_surface_destroy(qsurface->surface); + g_free(qsurface); + } break; - } + } /* Begin of texture stuff */ case glBindTexture_func: @@ -2102,7 +2209,7 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args if ( qsurface ) { - glo_surface_as_texture(qsurface->surface); + glo_surface_as_texture(process->current_state->context, qsurface->surface); fprintf(stderr, "edwin:bindtexture: drawable=0x%x,qsurface=%p.\n", drawable, qsurface); } } @@ -3052,15 +3159,14 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args glDrawArrays(mode, 0, count); #ifdef __APPLE__ //only for mac - { - int prev_fbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); - if ( prev_fbo != 0 ) - glFlush(); - } + { + int prev_fbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); + if ( prev_fbo != 0 ) + glFlush(); + } #endif - break; } @@ -3533,12 +3639,12 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args glDrawElements(args[0], args[1], args[2], (void *) args[3]); #ifdef __APPLE__ //only for mac - { - int prev_fbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); - if ( prev_fbo != 0 ) - glFlush(); - } + { + int prev_fbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); + if ( prev_fbo != 0 ) + glFlush(); + } #endif break; @@ -3556,37 +3662,37 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args GET_EXT_PTR(void, glMultiDrawElements, (int, int *, int, void **, int)); ptr_func_glMultiDrawElements(args[0], (int *) args[1], args[2], - (void **) args[3], args[4]); + (void **) args[3], args[4]); #ifdef __APPLE__ //only for mac - { - int prev_fbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); - if ( prev_fbo != 0 ) - glFlush(); - } + { + int prev_fbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); + if ( prev_fbo != 0 ) + glFlush(); + } #endif - break; - } + break; + } #ifdef __APPLE__ // only for mac - case glDrawArrays_func: - { - int prev_fbo; - glDrawArrays(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_INT(args[2])); - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); - if ( prev_fbo != 0 ) - glFlush(); - break; - } - case glDrawElements_func: - { - int prev_fbo; - glDrawElements(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_UNSIGNED_INT(args[2]), (const void*)(args[3])); - glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); - if ( prev_fbo != 0 ) - glFlush(); - break; - } + case glDrawArrays_func: + { + int prev_fbo; + glDrawArrays(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_INT(args[2])); + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); + if ( prev_fbo != 0 ) + glFlush(); + break; + } + case glDrawElements_func: + { + int prev_fbo; + glDrawElements(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_UNSIGNED_INT(args[2]), (const void*)(args[3])); + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo); + if ( prev_fbo != 0 ) + glFlush(); + break; + } #endif case _glGetError_fake_func: @@ -3759,61 +3865,61 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args #endif #ifdef _WIN32 - /* workaround for bug T_SDK-128. If GL_UNPACK_ROW_LENGTH==0, GL driver - * should calculate it for glTexSubImage2D according to width parameter and - * GL_UNPACK_ALIGNMENT. But on windows, some vender's driver like nvidia, - * don't follow it. So we need do it for the driver, and probably remove - * this hack in future if driver get fixed. - */ - case glTexSubImage2D_func: - { - int origin_row_length, alignment, width; + /* workaround for bug T_SDK-128. If GL_UNPACK_ROW_LENGTH==0, GL driver + * should calculate it for glTexSubImage2D according to width parameter and + * GL_UNPACK_ALIGNMENT. But on windows, some vender's driver like nvidia, + * don't follow it. So we need do it for the driver, and probably remove + * this hack in future if driver get fixed. + */ + case glTexSubImage2D_func: + { + int origin_row_length, alignment, width; - if (args[6] == GL_ALPHA) { - width = args[4]; - glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &origin_row_length); + if (args[6] == GL_ALPHA) { + width = args[4]; + glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + glGetIntegerv(GL_UNPACK_ROW_LENGTH, &origin_row_length); - if (width%alignment != 0) { - width = (width/alignment + 1) * alignment; - } + if (width%alignment != 0) { + width = (width/alignment + 1) * alignment; + } - glPixelStorei(GL_UNPACK_ROW_LENGTH, width); - } + glPixelStorei(GL_UNPACK_ROW_LENGTH, width); + } - glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), - ARG_TO_INT(args[2]), ARG_TO_INT(args[3]), - ARG_TO_INT(args[4]), ARG_TO_INT(args[5]), - ARG_TO_UNSIGNED_INT(args[6]), - ARG_TO_UNSIGNED_INT(args[7]), (const void*)(args[8])); + glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), + ARG_TO_INT(args[2]), ARG_TO_INT(args[3]), + ARG_TO_INT(args[4]), ARG_TO_INT(args[5]), + ARG_TO_UNSIGNED_INT(args[6]), + ARG_TO_UNSIGNED_INT(args[7]), (const void*)(args[8])); - if (args[6] == GL_ALPHA) - glPixelStorei(GL_UNPACK_ROW_LENGTH, origin_row_length); + if (args[6] == GL_ALPHA) + glPixelStorei(GL_UNPACK_ROW_LENGTH, origin_row_length); - break; - } + break; + } #endif #ifdef __APPLE__ - case glTexSubImage2D_func: - { + case glTexSubImage2D_func: + { - glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), - ARG_TO_INT(args[2]), ARG_TO_INT(args[3]), - ARG_TO_INT(args[4]), ARG_TO_INT(args[5]), - ARG_TO_UNSIGNED_INT(args[6]), ARG_TO_UNSIGNED_INT(args[7]), - (const void*)(args[8])); - - if ( ARG_TO_UNSIGNED_INT(args[0]) == GL_TEXTURE_2D && - ARG_TO_INT(args[1]) == 0 && - ARG_TO_UNSIGNED_INT(args[6]) == GL_RGBA && - ARG_TO_UNSIGNED_INT(args[7]) == GL_UNSIGNED_BYTE ) - mac_dump_texture(); - else - fprintf(stderr, "!!! Probable screen crash, no work around as glTexSubImage2d parameters do not match!\n"); - - break; - } + glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), + ARG_TO_INT(args[2]), ARG_TO_INT(args[3]), + ARG_TO_INT(args[4]), ARG_TO_INT(args[5]), + ARG_TO_UNSIGNED_INT(args[6]), ARG_TO_UNSIGNED_INT(args[7]), + (const void*)(args[8])); + + if ( ARG_TO_UNSIGNED_INT(args[0]) == GL_TEXTURE_2D && + ARG_TO_INT(args[1]) == 0 && + ARG_TO_UNSIGNED_INT(args[6]) == GL_RGBA && + ARG_TO_UNSIGNED_INT(args[7]) == GL_UNSIGNED_BYTE ) + mac_dump_texture(); + else + fprintf(stderr, "!!! Probable screen crash, no work around as glTexSubImage2d parameters do not match!\n"); + + break; + } #endif default: diff --git a/tizen/src/hw/opengl_func.h b/tizen/src/hw/opengl_func.h index 3b302175ab..e29f0d901f 100644 --- a/tizen/src/hw/opengl_func.h +++ b/tizen/src/hw/opengl_func.h @@ -428,9 +428,9 @@ static const int glXBindTexImageATI_signature[] = { TYPE_NONE, 0, 3, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT }; static const int glXReleaseTexImageATI_signature[] = { TYPE_NONE, 0, 3, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT }; -static const int glXBindTexImageARB_signature[] = +static const int glXBindTexImageARB_fake_signature[] = { TYPE_INT, 0, 3, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT }; -static const int glXReleaseTexImageARB_signature[] = +static const int glXReleaseTexImageARB_fake_signature[] = { TYPE_INT, 0, 3, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT }; static const int glEGLImageTargetTexture2DOES_fake_signature[] = diff --git a/tizen/src/maru_err_table.c b/tizen/src/maru_err_table.c index 6bb5cd027a..e1753ac002 100644 --- a/tizen/src/maru_err_table.c +++ b/tizen/src/maru_err_table.c @@ -51,7 +51,8 @@ Check if the file is corrupted or missing.\n\n", /* 3 */ "Failed to load a bios file the following path.\ Check if the file is corrupted or missing.\n\n", /* 4 */ "Skin process cannot be initialized. Skin server is not ready.", - /* 5 */ "Skin client could not connect to Skin server. The time of internal heartbeat has expired.", + /* 5 */ "Emulator has stopped working.\n\ +A problem caused the program to stop working correctly.", /* add here.. */ "" }; @@ -76,6 +77,11 @@ void maru_register_exit_msg(int maru_exit_index, char const *const additional_ms maru_exit_status = maru_exit_index; if (maru_exit_status != MARU_EXIT_UNKNOWN) { + if (maru_exit_status == MARU_EXIT_HB_TIME_EXPIRED) { + fprintf(stderr, "Skin client could not connect to Skin server.\ +The time of internal heartbeat has expired.\n"); + } + if (additional_msg != NULL) { len = strlen(_maru_string_table[maru_exit_status]) + strlen(additional_msg) + 1; @@ -94,7 +100,7 @@ void maru_register_exit_msg(int maru_exit_index, char const *const additional_ms snprintf(maru_exit_msg, len, "%s", _maru_string_table[maru_exit_status]); } - } else if (additional_msg != NULL) { + } else if (additional_msg != NULL) { /* MARU_EXIT_UNKNOWN */ len = strlen(additional_msg); if (len >= JAVA_MAX_COMMAND_LENGTH) { len = JAVA_MAX_COMMAND_LENGTH - 1; diff --git a/tizen/src/skin/client/native_src/share.c b/tizen/src/skin/client/native_src/share.c index 6a14d76837..a22fd035c4 100644 --- a/tizen/src/skin/client/native_src/share.c +++ b/tizen/src/skin/client/native_src/share.c @@ -1,7 +1,7 @@ /** + * Transmit the framebuffer from shared memory by JNI * - * - * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim @@ -36,42 +36,29 @@ #include "org_tizen_emulator_skin_EmulatorShmSkin.h" #define MAXLEN 512 -#define SHMKEY 26099 void *shared_memory = (void *)0; int shmid; JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_shmget - (JNIEnv *env, jobject obj, jint vga_ram_size) + (JNIEnv *env, jobject obj, jint shmkey, jint vga_ram_size) { - void *temp; - int keyval; - shmid = shmget((key_t)SHMKEY, (size_t)MAXLEN, 0666 | IPC_CREAT); - if (shmid == -1) { - fprintf(stderr, "share.c: shmget failed\n"); - exit(1); - } - - temp = shmat(shmid, (char*)0x0, 0); - if (temp == (void *)-1) { - fprintf(stderr, "share.c: shmat failed\n"); - exit(1); - } - keyval = atoi(temp); - fprintf(stdout, "share.c: shared memory key = %d\n", keyval); - shmdt(temp); + fprintf(stdout, "share.c: shared memory key = %d\n", shmkey); + fflush(stdout); - shmid = shmget((key_t)keyval, (size_t)vga_ram_size, 0666 | IPC_CREAT); + shmid = shmget((key_t)shmkey, (size_t)vga_ram_size, 0666 | IPC_CREAT); if (shmid == -1) { fprintf(stderr, "share.c: shmget failed\n"); + fflush(stderr); return 1; } - /* We now make the shared memory accessible to the program. */ + /* We now make the shared memory accessible to the program */ shared_memory = shmat(shmid, (void *)0, 0); if (shared_memory == (void *)-1) { fprintf(stderr, "share.c: shmat failed\n"); + fflush(stderr); return 2; } @@ -79,37 +66,42 @@ JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_shmget } JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_shmdt - (JNIEnv *env, jobject obj) + (JNIEnv *env, jobject obj) { /* Lastly, the shared memory is detached */ if (shmdt(shared_memory) == -1) { fprintf(stderr, "share.c: shmdt failed\n"); + fflush(stderr); perror("share.c: "); return 1; } -/* + + /* if (shmctl(shmid, IPC_RMID, 0) == -1) { fprintf(stderr, "share.c: shmctl failed\n"); + fflush(stderr); perror("share.c: "); } -*/ + */ + return 0; } JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_getPixels - (JNIEnv *env, jobject obj, jintArray array) + (JNIEnv *env, jobject obj, jintArray array) { int i = 0; int len = (*env)->GetArrayLength(env, array); if (len <= 0) { fprintf(stderr, "share.c: get length failed\n"); + fflush(stderr); return -1; } int *framebuffer = (int *)shared_memory; jint value = 0xFFFFFFFF; - for(i = 0; i < len; i++) { + for (i = 0; i < len; i++) { value = framebuffer[i]; (*env)->SetIntArrayRegion(env, array, i, 1, &value); } diff --git a/tizen/src/skin/client/skins/emul-320x480/default.dbi b/tizen/src/skin/client/skins/emul-320x480/default.dbi index b904f0865f..418f443691 100644 --- a/tizen/src/skin/client/skins/emul-320x480/default.dbi +++ b/tizen/src/skin/client/skins/emul-320x480/default.dbi @@ -14,16 +14,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -31,7 +31,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -39,7 +39,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -58,7 +58,7 @@ 139 - HOME + Home Home @@ -66,7 +66,7 @@ 116 - POWER + Power Power @@ -74,7 +74,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -82,7 +82,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -100,16 +100,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -117,7 +117,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -125,7 +125,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -143,16 +143,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -160,7 +160,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -168,7 +168,7 @@ 114 - VOLUME_DOWN + Volume - Volume - diff --git a/tizen/src/skin/client/skins/emul-480x800/default.dbi b/tizen/src/skin/client/skins/emul-480x800/default.dbi index 61bed8f7d1..34bd212222 100644 --- a/tizen/src/skin/client/skins/emul-480x800/default.dbi +++ b/tizen/src/skin/client/skins/emul-480x800/default.dbi @@ -15,7 +15,7 @@ 139 - HOME + Home Home @@ -23,7 +23,7 @@ 116 - POWER + Power Power @@ -31,7 +31,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -39,7 +39,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -57,16 +57,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -74,7 +74,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -82,7 +82,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -100,16 +100,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -117,7 +117,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -125,7 +125,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -143,16 +143,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -160,7 +160,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -168,7 +168,7 @@ 114 - VOLUME_DOWN + Volume - Volume - diff --git a/tizen/src/skin/client/skins/emul-600x1024/default.dbi b/tizen/src/skin/client/skins/emul-600x1024/default.dbi index dc9f9a69a1..c2b2b0dd09 100644 --- a/tizen/src/skin/client/skins/emul-600x1024/default.dbi +++ b/tizen/src/skin/client/skins/emul-600x1024/default.dbi @@ -15,7 +15,7 @@ 139 - HOME + Home Home @@ -23,7 +23,7 @@ 116 - POWER + Power Power @@ -31,7 +31,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -39,7 +39,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -57,16 +57,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -74,7 +74,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -82,7 +82,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -100,16 +100,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -117,7 +117,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -125,7 +125,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -143,16 +143,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -160,7 +160,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -168,7 +168,7 @@ 114 - VOLUME_DOWN + Volume - Volume - diff --git a/tizen/src/skin/client/skins/emul-720x1280/default.dbi b/tizen/src/skin/client/skins/emul-720x1280/default.dbi index 0a72633419..aa0c011a5c 100644 --- a/tizen/src/skin/client/skins/emul-720x1280/default.dbi +++ b/tizen/src/skin/client/skins/emul-720x1280/default.dbi @@ -15,7 +15,7 @@ 139 - HOME + Home Home @@ -23,7 +23,7 @@ 116 - POWER + Power Power @@ -31,7 +31,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -39,7 +39,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -57,16 +57,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -74,7 +74,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -82,7 +82,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -100,16 +100,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -117,7 +117,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -125,7 +125,7 @@ 114 - VOLUME_DOWN + Volume - Volume - @@ -143,16 +143,16 @@ - 101 - HOME + 139 + Home Home - 103 - POWER + 116 + Power Power @@ -160,7 +160,7 @@ 115 - VOLUME_UP + Volume + Volume + @@ -168,7 +168,7 @@ 114 - VOLUME_DOWN + Volume - Volume - diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index 1718babae2..6cd1bde18e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -1,7 +1,7 @@ /** * Emulator Skin Process * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim @@ -40,6 +40,7 @@ import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.widgets.Display; import org.tizen.emulator.skin.config.EmulatorConfig; +import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.exception.ScreenShotException; import org.tizen.emulator.skin.image.ImageRegistry.IconName; import org.tizen.emulator.skin.info.SkinInformation; @@ -57,7 +58,7 @@ public class EmulatorShmSkin extends EmulatorSkin { public static final int COLOR_DEPTH = 32; /* define JNI functions */ - public native int shmget(int size); + public native int shmget(int shmkey, int size); public native int shmdt(); public native int getPixels(int[] array); @@ -175,8 +176,13 @@ public class EmulatorShmSkin extends EmulatorSkin { public long initLayout() { super.initLayout(); + /* base + 1 = sdb port */ + /* base + 2 = shared memory key */ + int shmkey = config.getArgInt(ArgsConstants.NET_BASE_PORT) + 2; + logger.info("shmkey = " + shmkey); + /* initialize shared memory */ - int result = shmget( + int result = shmget(shmkey, currentState.getCurrentResolutionWidth() * currentState.getCurrentResolutionHeight()); logger.info("shmget native function returned " + result); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 2393efaceb..e5f7f903c7 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -181,7 +181,7 @@ public class EmulatorSkin { public CustomProgressBar bootingProgress; public ScreenShotDialog screenShotDialog; - protected SocketCommunicator communicator; + public SocketCommunicator communicator; private ShellListener shellListener; private MenuDetectListener shellMenuDetectListener; @@ -843,7 +843,7 @@ public class EmulatorSkin { if (SwtUtil.isWindowsPlatform() && disappearEvent) { disappearEvent = false; if (isMetaKey(e) && e.character != '\0') { - logger.info("send previous release : keycode=" + disappearKeycode + + logger.info("send disappear release : keycode=" + disappearKeycode + ", stateMask=" + disappearStateMask + ", keyLocation=" + disappearKeyLocation); @@ -901,6 +901,17 @@ public class EmulatorSkin { disappearStateMask = stateMask; disappearKeyLocation = e.keyLocation; } else { + /* three or more keys were pressed + at the same time */ + if (disappearEvent == true) { + logger.info("replace the disappearEvent : " + + disappearKeycode + "->" + keyCode); + + disappearKeycode = keyCode; + disappearStateMask = stateMask; + disappearKeyLocation = e.keyLocation; + } + int previousKeyCode = previous.keyCode; int previousStateMask = previous.stateMask; @@ -991,7 +1002,7 @@ public class EmulatorSkin { private synchronized boolean addPressedKey(KeyEventData pressData) { for (KeyEventData data : pressedKeyEventList) { if (data.keycode == pressData.keycode && - data.stateMask == pressData.stateMask && + //data.stateMask == pressData.stateMask && data.keyLocation == pressData.keyLocation) { return false; } @@ -1005,7 +1016,7 @@ public class EmulatorSkin { for (KeyEventData data : pressedKeyEventList) { if (data.keycode == releaseData.keycode && - data.stateMask == releaseData.stateMask && + //data.stateMask == releaseData.stateMask && data.keyLocation == releaseData.keyLocation) { pressedKeyEventList.remove(data); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java index d6f72d5af1..d93a1bda2e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java @@ -176,8 +176,11 @@ public class EmulatorSkinMain { } boolean skinPhoneShape = true; - String skinInfoResolutionW = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH); - String skinInfoResolutionH = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT); + String skinInfoResolutionW = + skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH); + String skinInfoResolutionH = + skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT); + if (skinInfoResolutionW.equalsIgnoreCase("all") || skinInfoResolutionH.equalsIgnoreCase("all")) { skinPhoneShape = false; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java index f9f94d11f9..4f55a8caf9 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java @@ -135,11 +135,11 @@ public class EmulatorSkinState { this.displayBounds = bounds; } - public synchronized boolean isUpdateDisplayBounds() { + public synchronized boolean isNeedToUpdateDisplay() { return updateDisplayBounds; } - public synchronized void setUpdateDisplayBounds(boolean needUpdate) { + public synchronized void setNeedToUpdateDisplay(boolean needUpdate) { this.updateDisplayBounds = needUpdate; } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java index 6dce373125..3048bd4299 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java @@ -103,14 +103,16 @@ public class EmulatorConfig { private Properties configProperties; private String skinPropertiesFilePath; - public EmulatorConfig( Map args, EmulatorUI dbiContents, Properties skinProperties, - String skinPropertiesFilePath, Properties configProperties ) { + public EmulatorConfig(Map args, + EmulatorUI dbiContents, Properties skinProperties, + String skinPropertiesFilePath, Properties configProperties) { this.args = args; this.dbiContents = dbiContents; this.skinProperties = skinProperties; this.skinPropertiesFilePath = skinPropertiesFilePath; this.configProperties = configProperties; - if ( null == configProperties ) { + + if (null == configProperties) { this.configProperties = new Properties(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index fe317dfb56..08e75c4611 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -48,6 +48,8 @@ import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.EmulatorSkinState; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; +import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; +import org.tizen.emulator.skin.comm.sock.data.DisplayStateData; import org.tizen.emulator.skin.config.EmulatorConfig; import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants; @@ -297,6 +299,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { /* custom window shape */ trimPatchedShell(shell, currentState.getCurrentImage()); + currentState.setNeedToUpdateDisplay(true); shell.redraw(); } @@ -363,6 +366,16 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { shellPaintListener = new PaintListener() { @Override public void paintControl(final PaintEvent e) { + if (currentState.isNeedToUpdateDisplay() == true) { + currentState.setNeedToUpdateDisplay(false); + + /* Let's do one more update for sdl display surface + while skipping of framebuffer drawing */ + DisplayStateData lcdStateData = new DisplayStateData( + currentState.getCurrentScale(), currentState.getCurrentRotationId()); + skin.communicator.sendToQEMU(SendCommand.CHANGE_LCD_STATE, lcdStateData); + } + /* general shell does not support native transparency, * so draw image with GC. */ if (currentState.getCurrentImage() != null) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java index 21eeeea071..349d35c2fb 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java @@ -52,6 +52,7 @@ import org.tizen.emulator.skin.EmulatorSkinState; import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType; import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; import org.tizen.emulator.skin.comm.sock.SocketCommunicator; +import org.tizen.emulator.skin.comm.sock.data.DisplayStateData; import org.tizen.emulator.skin.comm.sock.data.KeyEventData; import org.tizen.emulator.skin.config.EmulatorConfig; import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; @@ -183,8 +184,6 @@ public class PhoneShapeSkinComposer implements ISkinComposer { logger.info("lcd bounds : " + lcdBounds); currentState.setDisplayBounds(lcdBounds); - currentState.setUpdateDisplayBounds(true); - //lcdCanvas.setBounds(lcdBounds); /* arrange the skin image */ Image tempImage = null; @@ -232,6 +231,7 @@ public class PhoneShapeSkinComposer implements ISkinComposer { /* custom window shape */ SkinUtil.trimShell(shell, currentState.getCurrentImage()); + currentState.setNeedToUpdateDisplay(true); shell.redraw(); } @@ -271,9 +271,15 @@ public class PhoneShapeSkinComposer implements ISkinComposer { shellPaintListener = new PaintListener() { @Override public void paintControl(final PaintEvent e) { - if (currentState.isUpdateDisplayBounds() == true) { - currentState.setUpdateDisplayBounds(false); + if (currentState.isNeedToUpdateDisplay() == true) { + currentState.setNeedToUpdateDisplay(false); lcdCanvas.setBounds(currentState.getDisplayBounds()); + + /* Let's do one more update for sdl display surface + while skipping of framebuffer drawing */ + DisplayStateData lcdStateData = new DisplayStateData( + currentState.getCurrentScale(), currentState.getCurrentRotationId()); + skin.communicator.sendToQEMU(SendCommand.CHANGE_LCD_STATE, lcdStateData); } /* general shell does not support native transparency, diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index 24722f9e35..c79503385e 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -59,7 +59,6 @@ MULTI_DEBUG_CHANNEL(qemu, skin_client); #define OPT_MAX_TOUCHPOINT "max.touchpoint" extern char tizen_target_path[]; -extern int tizen_base_port; static int skin_argc; static char** skin_argv; @@ -94,7 +93,7 @@ static void* run_skin_client(void* arg) char buf_tizen_base_port[16]; sprintf(buf_skin_server_port, "%d", skin_server_port); sprintf(buf_uid, "%d", uid); - sprintf(buf_tizen_base_port, "%d", tizen_base_port); + sprintf(buf_tizen_base_port, "%d", get_emul_vm_base_port()); #ifdef CONFIG_WIN32 // find java path in 64bit windows @@ -118,11 +117,12 @@ static void* run_skin_client(void* arg) char* bin_dir = get_bin_path(); #endif INFO("bin directory : %s\n", bin_dir); + int maxtouchpoint = get_emul_max_touch_point(); int len_maxtouchpoint; - if(maxtouchpoint > 9) { + if (maxtouchpoint > 9) { len_maxtouchpoint = 2; - }else { + } else { len_maxtouchpoint = 1; } @@ -150,9 +150,9 @@ static void* run_skin_client(void* arg) OPT_SVR_PORT, skin_server_port, OPT_UID, uid, OPT_VM_PATH, vm_path, - OPT_NET_BASE_PORT, tizen_base_port, + OPT_NET_BASE_PORT, get_emul_vm_base_port(), OPT_MAX_TOUCHPOINT, maxtouchpoint, - argv ); + argv); INFO("command for swt : %s\n", cmd); @@ -261,10 +261,11 @@ int start_skin_client(int argc, char* argv[]) } else { count++; INFO("sleep for ready. count:%d\n", count); + #ifdef CONFIG_WIN32 - Sleep(SKIN_SERVER_SLEEP_TIME); + Sleep(SKIN_SERVER_SLEEP_TIME); #else - usleep(1000 * SKIN_SERVER_SLEEP_TIME); + usleep(1000 * SKIN_SERVER_SLEEP_TIME); #endif } diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index ffb1e2f8d5..b6ade33c46 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -58,7 +58,6 @@ #if defined(CONFIG_USE_SHM) && defined(TARGET_I386) #include int g_shmid; -extern int port_shmid; #endif MULTI_DEBUG_CHANNEL(qemu, skin_operation); @@ -80,11 +79,15 @@ extern pthread_mutex_t mutex_screenshot; extern pthread_cond_t cond_screenshot; extern int tizen_base_port; + static void* run_timed_shutdown_thread(void* args); -static void send_to_emuld(const char* request_type, int request_size, const char* send_buf, int buf_size); +static void send_to_emuld(const char* request_type, + int request_size, const char* send_buf, int buf_size); + void start_display(uint64 handle_id, - int lcd_size_width, int lcd_size_height, double scale_factor, short rotation_type) + int lcd_size_width, int lcd_size_height, + double scale_factor, short rotation_type) { INFO("start_display handle_id:%ld, lcd size:%dx%d, scale_factor:%f, rotation_type:%d\n", (long)handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation_type); @@ -358,7 +361,7 @@ QemuSurfaceInfo* get_screenshot_info(void) info->pixel_data = (unsigned char*) g_malloc0( length ); if ( !info->pixel_data ) { g_free( info ); - ERR( "Fail to malloc for pixel data.\n"); + ERR("Fail to malloc for pixel data.\n"); return NULL; } @@ -371,8 +374,8 @@ QemuSurfaceInfo* get_screenshot_info(void) pthread_mutex_lock(&mutex_screenshot); MaruScreenshot* maru_screenshot = get_maru_screenshot(); - if ( !maru_screenshot || maru_screenshot->isReady != 1) { - ERR( "maru screenshot is NULL or not ready.\n" ); + if (!maru_screenshot || maru_screenshot->isReady != 1) { + ERR("maru screenshot is NULL or not ready.\n"); memset(info->pixel_data, 0x00, length); } else { maru_screenshot->pixel_data = info->pixel_data; @@ -490,6 +493,7 @@ void free_detail_info(DetailInfo* detail_info) void do_open_shell(void) { INFO("open shell\n"); + /* do nothing */ } @@ -535,50 +539,49 @@ void request_close(void) } -void shutdown_qemu_gracefully( void ) { - +void shutdown_qemu_gracefully(void) +{ requested_shutdown_qemu_gracefully = 1; pthread_t thread_id; - if( 0 > pthread_create( &thread_id, NULL, run_timed_shutdown_thread, NULL ) ) { - ERR( "!!! Fail to create run_timed_shutdown_thread. shutdown qemu right now !!!\n" ); + if (0 > pthread_create( + &thread_id, NULL, run_timed_shutdown_thread, NULL)) { + + ERR("!!! Fail to create run_timed_shutdown_thread. shutdown qemu right now !!!\n"); qemu_system_shutdown_request(); } } -int is_requested_shutdown_qemu_gracefully( void ) { +int is_requested_shutdown_qemu_gracefully(void) +{ return requested_shutdown_qemu_gracefully; } -static void* run_timed_shutdown_thread( void* args ) { - - send_to_emuld( "system\n\n\n\n", 10, "shutdown", 8 ); +static void* run_timed_shutdown_thread(void* args) +{ + send_to_emuld("system\n\n\n\n", 10, "shutdown", 8); - int sleep_interval_time = 1000; // milli-seconds + int sleep_interval_time = 1000; /* milli-seconds */ int i; - for ( i = 0; i < TIMEOUT_FOR_SHUTDOWN; i++ ) { + for (i = 0; i < TIMEOUT_FOR_SHUTDOWN; i++) { #ifdef CONFIG_WIN32 - Sleep( sleep_interval_time ); + Sleep(sleep_interval_time); #else - usleep( sleep_interval_time * 1000 ); + usleep(sleep_interval_time * 1000); #endif - // do not use logger to help user see log in console - fprintf( stdout, "Wait for shutdown qemu...%d\n", ( i + 1 ) ); + /* do not use logger to help user see log in console */ + fprintf(stdout, "Wait for shutdown qemu...%d\n", (i + 1)); } - INFO( "Shutdown qemu !!!\n" ); + INFO("Shutdown qemu !!!\n"); + #if defined(CONFIG_USE_SHM) && defined(TARGET_I386) if (shmctl(g_shmid, IPC_RMID, 0) == -1) { ERR("shmctl failed\n"); perror("maruskin_operation.c:g_shmid: "); } - - if (shmctl(port_shmid, IPC_RMID, 0) == -1) { - ERR("shmctl failed\n"); - perror("maruskin_operation.c:port_shmid: "); - } #endif qemu_system_shutdown_request(); @@ -587,8 +590,9 @@ static void* run_timed_shutdown_thread( void* args ) { } -static void send_to_emuld( const char* request_type, int request_size, const char* send_buf, int buf_size ) { - +static void send_to_emuld(const char* request_type, + int request_size, const char* send_buf, int buf_size) +{ int s = tcp_socket_outgoing( "127.0.0.1", (uint16_t) ( tizen_base_port + SDB_TCP_EMULD_INDEX ) ); if ( s < 0 ) { -- 2.34.1