From: giwoong.kim Date: Fri, 10 Aug 2012 12:05:36 +0000 (+0900) Subject: [Title] added virtio touchscreen skeleton driver X-Git-Tag: 2.2.1_release^2~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e65a90c514d2580e426561b382ee664b8dd09ef5;p=sdk%2Femulator%2Femulator-kernel.git [Title] added virtio touchscreen skeleton driver [Type] feature [Module] Emulator / touch [Priority] marjo [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/drivers/maru/maru_virtio_touchscreen.c b/drivers/maru/maru_virtio_touchscreen.c new file mode 100644 index 000000000000..822e2b0d0d34 --- /dev/null +++ b/drivers/maru/maru_virtio_touchscreen.c @@ -0,0 +1,167 @@ +/* + * Maru Virtual Virtio Touchscreen device driver + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SeokYeon Hwang + * 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 +#include +#include +#include +#include +#include +//#include +#include +#include +#include + + +#define DEVICE_NAME "virtio-touchscreen" + +/* This structure must match the qemu definitions */ +typedef struct EmulTouchState { + uint16_t x, y, z; + uint8_t state; +} EmulTouchState; + + +static struct virtqueue *vq = NULL; + +static struct virtio_device_id id_table[] = { + { VIRTIO_ID_TOUCHSCREEN, VIRTIO_DEV_ANY_ID }, + { 0 }, +}; + +static void vq_touchscreen_callback(struct virtqueue *vq) +{ + printk(KERN_INFO "vq touchscreen callback\n"); +} + +static int virtio_touchscreen_open(struct inode *inode, struct file *file) +{ + printk(KERN_INFO "virtio touchscreen device is opened\n"); + return 0; +} + +static int virtio_touchscreen_release(struct inode *inode, struct file *file) +{ + printk(KERN_INFO "virtio touchscreen device is closed\n"); + return 0; +} + +struct file_operations virtio_touchscreen_fops = { + .owner = THIS_MODULE, + .write = NULL, + .mmap = NULL, + .open = virtio_touchscreen_open, + .release = virtio_touchscreen_release, +}; + +static struct miscdevice virtio_touchscreen_dev = { + .minor = MISC_DYNAMIC_MINOR, + .name = DEVICE_NAME, + .fops = &virtio_touchscreen_fops, +}; + +static int virtio_touchscreen_probe(struct virtio_device *vdev) +{ + int ret = 0; + + printk(KERN_INFO "virtio touchscreen driver is probed.\n"); + + vq = virtio_find_single_vq(vdev, NULL, "virtio-touchscreen-vq"); + if (IS_ERR(vq)) { + return PTR_ERR(vq); + } + + ret = misc_register(&virtio_touchscreen_dev); + if (ret) { + printk(KERN_ERR "virtio touchscreen cannot register device as misc\n"); + return -ENODEV; + } + + + // temp + vq->callback = vq_touchscreen_callback; + + /* Transfer data */ +#if 0 + if (virtqueue_add_buf(vq, sg_list, out_page, in_page, (void*)1, GFP_ATOMIC) >= 0) { + while (!virtqueue_get_buf(vq, &count)) { + cpu_relax(); + } + } +#endif + + return 0; +} + +static void __devexit virtio_touchscreen_remove(struct virtio_device *vdev) +{ + printk(KERN_INFO "virtio touchscreen driver is removed.\n"); + + vdev->config->reset(vdev); // reset device + misc_deregister(&virtio_touchscreen_dev); + vdev->config->del_vqs(vdev); // clean up the queues +} + +static struct virtio_driver virtio_touchscreen_driver = { + //.feature_table = features, + //.feature_table_size = ARRAY_SIZE(features), + .driver.name = KBUILD_MODNAME, + .driver.owner = THIS_MODULE, + .id_table = id_table, + .probe = virtio_touchscreen_probe, + .remove = virtio_touchscreen_remove, +#if 0 + .config_changed = virtballoon_changed, +#ifdef CONFIG_PM + .freeze = + .restore = +#endif +#endif +}; + +static int __init virtio_touchscreen_init(void) +{ + printk(KERN_INFO "virtio touchscreen device is initialized.\n"); + return register_virtio_driver(&virtio_touchscreen_driver); +} + +static void __exit virtio_touchscreen_exit(void) +{ + printk(KERN_INFO "virtio touchscreen device is destroyed.\n"); + unregister_virtio_driver(&virtio_touchscreen_driver); +} + +module_init(virtio_touchscreen_init); +module_exit(virtio_touchscreen_exit); + +MODULE_DEVICE_TABLE(virtio, id_table); +MODULE_AUTHOR("GiWoong Kim "); +MODULE_DESCRIPTION("Emulator Virtio Touchscreen driver"); +MODULE_LICENSE("GPL2"); diff --git a/include/linux/virtio_ids.h b/include/linux/virtio_ids.h index a2d629476dfc..76c8f87c77db 100644 --- a/include/linux/virtio_ids.h +++ b/include/linux/virtio_ids.h @@ -39,4 +39,7 @@ #define VIRTIO_ID_SCSI 8 /* virtio scsi */ #define VIRTIO_ID_9P 9 /* 9p virtio console */ +/* Maru devices */ +#define VIRTIO_ID_TOUCHSCREEN 10 /* virtio touchscreen */ + #endif /* _LINUX_VIRTIO_IDS_H */