From 9435ef8c731065f81358d26eb926f32a0dbc0f12 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Tue, 14 Jan 2014 18:09:20 +0900 Subject: [PATCH] touchscreen: modified reset function clean up the queues when emulator restarting Change-Id: I28266a4ce863d160d793b45341ece4d8af42455c Signed-off-by: GiWoong Kim --- tizen/src/hw/maru_virtio_touchscreen.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tizen/src/hw/maru_virtio_touchscreen.c b/tizen/src/hw/maru_virtio_touchscreen.c index 32295dc..b68991f 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.c +++ b/tizen/src/hw/maru_virtio_touchscreen.c @@ -319,6 +319,7 @@ static int virtio_touchscreen_device_init(VirtIODevice *vdev) return NULL; }*/ + // TODO: reduce size ts->vq = virtio_add_queue(&ts->vdev, 64, maru_virtio_touchscreen_handle); ts->qdev = qdev; @@ -364,18 +365,32 @@ static Property virtio_touchscreen_properties[] = { static void virtio_touchscreen_device_reset(VirtIODevice *vdev) { + TouchEventEntry *event_entry = NULL; + ElementEntry *elem_entry = NULL; + INFO("reset the touchscreen device\n"); /* reset the counters */ - pthread_mutex_lock(&event_mutex); - event_queue_cnt = 0; - pthread_mutex_unlock(&event_mutex); - event_ringbuf_cnt = 0; elem_ringbuf_cnt = 0; + /* reset queue */ + pthread_mutex_lock(&event_mutex); + while (event_queue_cnt > 0) { + event_entry = QTAILQ_FIRST(&events_queue); + QTAILQ_REMOVE(&events_queue, event_entry, node); + + event_queue_cnt--; + } + pthread_mutex_unlock(&event_mutex); + pthread_mutex_lock(&elem_mutex); - elem_queue_cnt = 0; + while (elem_queue_cnt > 0) { + elem_entry = QTAILQ_FIRST(&elem_queue); + QTAILQ_REMOVE(&elem_queue, elem_entry, node); + + elem_queue_cnt--; + } ts->waitBuf = false; pthread_mutex_unlock(&elem_mutex); -- 2.7.4