From 1ed949ea97c548731c11f2ebe1570b0e8fe52480 Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Mon, 20 Aug 2012 21:51:47 +0900 Subject: [PATCH] [Title] added virtqueue to virtio_touchscreen dev [Type] feature [Module] Emulator / touch [Priority] major [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- tizen/src/hw/maru_virtio_touchscreen.c | 21 +++++++++++++++++---- tizen/src/hw/maru_virtio_touchscreen.h | 2 +- tizen/src/skin/maruskin_operation.c | 8 ++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tizen/src/hw/maru_virtio_touchscreen.c b/tizen/src/hw/maru_virtio_touchscreen.c index cc8981fb84..c79034be79 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.c +++ b/tizen/src/hw/maru_virtio_touchscreen.c @@ -82,21 +82,25 @@ typedef struct VirtIOTouchscreen // lock for between communication thread and IO thread static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER; +VirtQueueElement elem; void maru_mouse_to_touchevent(int x, int y, int z, int buttons_state) { TouchEventEntry *te = NULL; pthread_mutex_lock(&event_mutex); +#if 0 if (queue_cnt >= MAX_TOUCH_EVENT_CNT) { pthread_mutex_unlock(&event_mutex); INFO("full touch event queue, lose event\n", queue_cnt); return; } +#endif te = &(_events_buf[ringbuf_cnt % MAX_TOUCH_EVENT_CNT]); ringbuf_cnt++; + /* mouse event is copied into the queue */ te->index = ++queue_cnt; // 1 ~ te->touch.x = x; @@ -104,20 +108,29 @@ void maru_mouse_to_touchevent(int x, int y, int z, int buttons_state) te->touch.z = z; te->touch.state = buttons_state; - QTAILQ_INSERT_TAIL(&events_queue, te, node); + //QTAILQ_INSERT_TAIL(&events_queue, te, node); pthread_mutex_unlock(&event_mutex); - TRACE("touch event (%d) : x=%d, y=%d, z=%d, state=%d\n", + INFO("touch event (%d) : x=%d, y=%d, z=%d, state=%d\n", te->index, te->touch.x, te->touch.y, te->touch.z, te->touch.state); // TODO: - + memcpy(elem.in_sg[0].iov_base, &(te->touch), sizeof(EmulTouchState)); + virtqueue_push(touchscreen_state.vq, &elem, 0); virtio_notify(touchscreen_state.vdev, touchscreen_state.vq); } static void maru_virtio_touchscreen_handle(VirtIODevice *vdev, VirtQueue *vq) { + EmulTouchState touch; + INFO("maru_virtio_touchscreen_handle\n"); + + virtqueue_pop(vq, &elem); + memcpy(&touch, elem.in_sg[0].iov_base, sizeof(EmulTouchState)); + + INFO("!!!! x=%d, y=%d, z=%d, state=%d\n", + touch.x, touch.y, touch.z, touch.state); } static uint32_t virtio_touchscreen_get_features(VirtIODevice *vdev, uint32_t request_features) @@ -140,7 +153,7 @@ VirtIODevice *maru_virtio_touchscreen_init(DeviceState *dev) } s->vdev.get_features = virtio_touchscreen_get_features; - s->vq = virtio_add_queue(&s->vdev, 128 /*check*/, maru_virtio_touchscreen_handle); + s->vq = virtio_add_queue(&s->vdev, 128, maru_virtio_touchscreen_handle); s->qdev = dev; diff --git a/tizen/src/hw/maru_virtio_touchscreen.h b/tizen/src/hw/maru_virtio_touchscreen.h index c5a42b5ad3..bc647be734 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.h +++ b/tizen/src/hw/maru_virtio_touchscreen.h @@ -25,7 +25,7 @@ * - S-Core Co., Ltd * */ - + #ifndef MARU_TOUCHSCREEN_H_ #define MARU_TOUCHSCREEN_H_ diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 786db82772..1f2fe353de 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -100,9 +100,17 @@ void do_mouse_event( int event_type, int origin_x, int origin_y, int x, int y, i /* single touch */ if (MOUSE_DOWN == event_type || MOUSE_DRAG == event_type) { +#if 1 kbd_mouse_event(x, y, z, 1); +#else + maru_mouse_to_touchevent(x, y, z, 1); +#endif } else if (MOUSE_UP == event_type) { +#if 1 kbd_mouse_event(x, y, z, 0); +#else + maru_mouse_to_touchevent(x, y, z, 0); +#endif } else { ERR("undefined mouse event type:%d\n", event_type); } -- 2.34.1