From: GiWoong Kim Date: Tue, 9 Jul 2013 12:54:45 +0000 (+0900) Subject: touchscreen: added virtio_touchscreen_class_init X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~900^2~32^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5be6a1cf8e93a8a90e5fb0aac4214189df07af48;p=sdk%2Femulator%2Fqemu.git touchscreen: added virtio_touchscreen_class_init Change-Id: I9d22018adf7649d7db05ccc191fec903a6c5dabc Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/hw/maru_virtio_touchscreen.c b/tizen/src/hw/maru_virtio_touchscreen.c index c72ab248a8..9f7d74cfe9 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.c +++ b/tizen/src/hw/maru_virtio_touchscreen.c @@ -117,7 +117,8 @@ void virtio_touchscreen_event(void *opaque, int x, int y, int z, int buttons_sta qemu_bh_schedule(ts->bh); TRACE("touch event (%d) : x=%d, y=%d, z=%d, state=%d\n", - entry->index, entry->touch.x, entry->touch.y, entry->touch.z, entry->touch.state); + entry->index, entry->touch.x, entry->touch.y, + entry->touch.z, entry->touch.state); } static void maru_virtio_touchscreen_handle(VirtIODevice *vdev, VirtQueue *vq) @@ -300,25 +301,21 @@ static void maru_touchscreen_bh(void *opaque) maru_virtio_touchscreen_notify(); } -VirtIODevice *maru_virtio_touchscreen_init(DeviceState *dev) +static int virtio_touchscreen_device_init(VirtIODevice *vdev) { - INFO("initialize the touchscreen device\n"); + DeviceState *qdev = DEVICE(vdev); + ts = VIRTIO_TOUCHSCREEN(vdev); - ts = (VirtIOTouchscreen *)virtio_common_init(DEVICE_NAME, - VIRTIO_ID_TOUCHSCREEN, 4, sizeof(VirtIOTouchscreen)); + INFO("initialize the touchscreen device\n"); - if (ts == NULL) { + virtio_init(vdev, DEVICE_NAME, VIRTIO_ID_TOUCHSCREEN, 4); + /*if (ts == NULL) { ERR("failed to initialize the touchscreen device\n"); return NULL; - } - - //TODO: - //ts->vdev.get_config = virtio_touchscreen_get_config; - //ts->vdev.set_config = virtio_touchscreen_set_config; - //ts->vdev.get_features = virtio_touchscreen_get_features; + }*/ ts->vq = virtio_add_queue(&ts->vdev, 64, maru_virtio_touchscreen_handle); - ts->qdev = dev; + ts->qdev = qdev; /* reset the counters */ event_queue_cnt = event_ringbuf_cnt = 0; @@ -337,11 +334,13 @@ VirtIODevice *maru_virtio_touchscreen_init(DeviceState *dev) INFO("virtio touchscreen is added to qemu mouse event handler\n"); #endif - return &(ts->vdev); + return 0; } -void maru_virtio_touchscreen_exit(VirtIODevice *vdev) +static int virtio_touchscreen_device_exit(DeviceState *qdev) { + VirtIODevice *vdev = VIRTIO_DEVICE(qdev); + INFO("exit the touchscreen device\n"); if (ts->eh_entry) { @@ -356,5 +355,36 @@ void maru_virtio_touchscreen_exit(VirtIODevice *vdev) pthread_mutex_destroy(&event_mutex); pthread_mutex_destroy(&elem_mutex); + + return 0; +} + +static Property virtio_touchscreen_properties[] = { + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_touchscreen_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + dc->exit = virtio_touchscreen_device_exit; + dc->props = virtio_touchscreen_properties; + vdc->init = virtio_touchscreen_device_init; + vdc->get_config = virtio_touchscreen_get_config; + vdc->set_config = virtio_touchscreen_set_config; + vdc->get_features = virtio_touchscreen_get_features; +} + +static const TypeInfo virtio_touchscreen_info = { + .name = TYPE_VIRTIO_TOUCHSCREEN, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VirtIOTouchscreen), + .class_init = virtio_touchscreen_class_init, +}; + +static void virtio_register_types(void) +{ + type_register_static(&virtio_touchscreen_info); } +type_init(virtio_register_types)