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)
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;
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) {
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)