精华内容
下载资源
问答
  • usb 接口触摸屏驱动

    千次阅读 2013-11-19 19:10:38
    以前写的 USB 接口触摸屏驱动,那段时间简单的看了下 USB 协议的一些东西,主要是 HID 相关的,代码留着作为记录: /* Created by_fire 2012.2.13 */ #include #include #include #include #include #...

    以前写的 USB 接口的触摸屏驱动,那段时间简单的看了下 USB 协议的一些东西,主要是 HID 相关的,代码记录:

    /*
    	Created by_fire	2012.2.13
    */
    #include <linux/kernel.h>
    #include <linux/errno.h>
    #include <linux/init.h>
    #include <linux/slab.h>
    #include <linux/module.h>
    #include <linux/kref.h>
    #include <linux/uaccess.h>
    #include <linux/usb.h>
    #include <linux/mutex.h>
    #include <linux/input.h>
    #include <linux/usb/input.h>
    
    #define DEBUG 0
    
    #if DEBUG
    #define usb_ts_dbg(fmt, arg...) printk(fmt, ##arg)
    #else
    #define usb_ts_dbg(arg...) 
    #endif
    
    /* Define these values to match your devices */
    #define USB_SKEL_VENDOR_ID	0x0eef
    #define USB_SKEL_PRODUCT_ID	0x0001
    
    /* table of devices that work with this driver */
    static const struct usb_device_id usb_ts_table[] = {
    	{ USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
    	{ }					/* Terminating entry */
    };
    MODULE_DEVICE_TABLE(usb, usb_ts_table);
    
    static int swap_xy;
    module_param(swap_xy, bool, 0644);
    MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
    
    struct usb_ts;
    struct usb_ts_device_info {
    	int min_xc, max_xc;
    	int min_yc, max_yc;
    	int min_press, max_press;
    	int rept_size;
    
    	/*
    	 * Always service the USB devices irq not just when the input device is
    	 * open. This is useful when devices have a watchdog which prevents us
    	 * from periodically polling the device. Leave this unset unless your
    	 * touchscreen device requires it, as it does consume more of the USB
    	 * bandwidth.
    	 */
    	bool irq_always;
    
    	void (*process_pkt) (struct usb_ts *usbtouch, unsigned char *pkt, int len);
    
    	/*
    	 * used to get the packet len. possible return values:
    	 * > 0: packet len
    	 * = 0: skip one byte
    	 * < 0: -return value more bytes needed
    	 */
    	int  (*get_pkt_len) (unsigned char *pkt, int len);
    
    	int  (*read_data)   (struct usb_ts *usbtouch, unsigned char *pkt);
    	int  (*init)        (struct usb_ts *usbtouch);
    	void (*exit)	    (struct usb_ts *usbtouch);
    };
    
    /* a usbtouch device */
    struct usb_ts {
    	unsigned char *data;
    	dma_addr_t data_dma;
    	unsigned char *buffer;
    	int buf_len;
    	struct urb *int_urb;
    	struct usb_interface *interface;
    	struct input_dev *input;
    	struct usb_ts_device_info *dev_info;
    	char name[128];
    	char phys[64];
    	void *priv;
    
    	int x, y;
    	int touch, press;
    };
    
    static int usb_ts_read_data(struct usb_ts *dev, unsigned char *pkt)
    {
    	usb_ts_dbg("%s\n", __func__);
    
    	dev->x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F);
    	dev->y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F);
    	dev->touch = pkt[0] & 0x01;
    	dev->press = 0x01;
    
    	return 1;
    }
    
    static void usb_ts_process_pkt(struct usb_ts *usbtouch, unsigned char *pkt, int len)
    {
    	usb_ts_dbg("%s\n", __func__);
    	struct usb_ts_device_info *dev_info = usbtouch->dev_info;
    
    	int i;
    	
    	if(!(pkt[0] & 0x80)) return;
    	
    #if 0
    	for(i = 0; i < len; i++)
    		printk("pkt[%d] = %02x ", i, pkt[i]);
    
    	printk("\n");
    #endif
    
    	if (!dev_info->read_data(usbtouch, pkt))
    			return;
    
    	input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch);
    
    	if (swap_xy) {
    		input_report_abs(usbtouch->input, ABS_X, usbtouch->y);
    		input_report_abs(usbtouch->input, ABS_Y, usbtouch->x);
    	} else {
    		input_report_abs(usbtouch->input, ABS_X, usbtouch->x);
    		input_report_abs(usbtouch->input, ABS_Y, usbtouch->y);
    	}
    
    	usb_ts_dbg("x = %d, y = %d, p = %d\n", usbtouch->x, usbtouch->y, usbtouch->touch);
    	
    	if (dev_info->max_press)
    		input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press);
    	
    	input_sync(usbtouch->input);
    }
    
    static struct usb_ts_device_info usb_ts_dev_info[] = {
    	[0] = {
    		.min_xc		= 50,
    		.max_xc		= 1960,
    		.min_yc		= 140,
    		.max_yc		= 1900,
    		.min_press  = 0x0,
    		.max_press  = 0x1,
    		.rept_size	= 16,
    		.process_pkt	= usb_ts_process_pkt,
    		.read_data	= usb_ts_read_data,
    	},
    };
    
    static void usb_ts_irq(struct urb *urb)
    {
    	usb_ts_dbg("%s\n", __func__);
    	struct usb_ts *usbtouch = urb->context;
    	int retval;
    
    	switch (urb->status) {
    	case 0:
    		/* success */
    		break;
    	case -ETIME:
    		/* this urb is timing out */
    		usb_ts_dbg("%s - urb timed out - was the device unplugged?", __func__);
    		return;
    	case -ECONNRESET:
    	case -ENOENT:
    	case -ESHUTDOWN:
    	case -EPIPE:
    		/* this urb is terminated, clean up */
    		usb_ts_dbg("%s - urb shutting down with status: %d", __func__, urb->status);
    		return;
    	default:
    		usb_ts_dbg("%s - nonzero urb status received: %d", __func__, urb->status);
    		goto exit;
    	}
    
    	usbtouch->dev_info->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
    
    exit:
    	retval = usb_submit_urb(urb, GFP_ATOMIC);
    	if (retval)
     		err("%s - usb_submit_urb failed with result: %d", __func__, retval);
    }
    
    static int usb_ts_open(struct input_dev *input)
    {
    	usb_ts_dbg("%s\n", __func__);
    	struct usb_ts *usbtouch = input_get_drvdata(input);
    
    	usbtouch->int_urb->dev = interface_to_usbdev(usbtouch->interface);
    
    	if (!usbtouch->dev_info->irq_always) {
    		if (usb_submit_urb(usbtouch->int_urb, GFP_KERNEL))
    		  return -EIO;
    	}
    
    	return 0;
    }
    
    static void usb_ts_close(struct input_dev *input)
    {
    	usb_ts_dbg("%s\n", __func__);
    	struct usb_ts *usbtouch = input_get_drvdata(input);
    
    	if (!usbtouch->dev_info->irq_always)
    		usb_kill_urb(usbtouch->int_urb);
    }
    
    static void usb_ts_free_buffers(struct usb_device *udev, struct usb_ts *usbtouch)
    {
    	usb_ts_dbg("%s\n", __func__);
    	usb_free_coherent(udev, usbtouch->dev_info->rept_size, usbtouch->data, usbtouch->data_dma);
    	kfree(usbtouch->buffer);
    }
    
    static struct usb_endpoint_descriptor *usb_ts_get_input_endpoint(struct usb_host_interface *interface)
    {
    	usb_ts_dbg("%s\n", __func__);
    	int i;
    
    	for (i = 0; i < interface->desc.bNumEndpoints; i++)
    		if (usb_endpoint_dir_in(&interface->endpoint[i].desc))
    			return &interface->endpoint[i].desc;
    
    	return NULL;
    }
    
    static int usb_ts_probe(struct usb_interface *intf, const struct usb_device_id *id)
    {
    	struct usb_ts *usbtouch;
    	struct input_dev *input_dev;
    	struct usb_endpoint_descriptor *endpoint;
    	struct usb_device *udev = interface_to_usbdev(intf);
    	struct usb_ts_device_info *dev_info;
    	int err = -ENOMEM;
    	
    	usb_ts_dbg("%s 1\n", __func__);
    
    	endpoint = usb_ts_get_input_endpoint(intf->cur_altsetting);
    	if (!endpoint)
    		return -ENXIO;
    
    	usbtouch = kzalloc(sizeof(struct usb_ts), GFP_KERNEL);
    	input_dev = input_allocate_device();
    	if (!usbtouch || !input_dev)
    		goto out_free;
    
    	dev_info = &usb_ts_dev_info[0];
    	usbtouch->dev_info = dev_info;
    	if (!dev_info->process_pkt)
    		dev_info->process_pkt = usb_ts_process_pkt;
    
    	usbtouch->data = usb_alloc_coherent(udev, dev_info->rept_size, GFP_KERNEL, &usbtouch->data_dma);
    	if (!usbtouch->data)
    		goto out_free;
    
    	if (dev_info->get_pkt_len) {
    		usbtouch->buffer = kmalloc(dev_info->rept_size, GFP_KERNEL);
    		if (!usbtouch->buffer)
    			goto out_free_buffers;
    	}
    
    	usbtouch->int_urb = usb_alloc_urb(0, GFP_KERNEL);
    	if (!usbtouch->int_urb) {
    		usb_ts_dbg("%s - usb_alloc_urb failed: usbtouch->irq", __func__);
    		goto out_free_buffers;
    	}
    	
    	usb_ts_dbg("%s 2\n", __func__);
    
    	usbtouch->interface = intf;
    	usbtouch->input = input_dev;
    
    	if (udev->manufacturer)
    		strlcpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name));
    
    	if (udev->product) {
    		if (udev->manufacturer)
    			strlcat(usbtouch->name, " ", sizeof(usbtouch->name));
    		strlcat(usbtouch->name, udev->product, sizeof(usbtouch->name));
    	}
    
    	if (!strlen(usbtouch->name))
    		snprintf(usbtouch->name, sizeof(usbtouch->name),
    			"USB Touchscreen %04x:%04x",
    			 le16_to_cpu(udev->descriptor.idVendor),
    			 le16_to_cpu(udev->descriptor.idProduct));
    
    	usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys));
    	strlcat(usbtouch->phys, "/input0", sizeof(usbtouch->phys));
    
    	input_dev->name = usbtouch->name;
    	input_dev->phys = usbtouch->phys;
    	usb_to_input_id(udev, &input_dev->id);
    	input_dev->dev.parent = &intf->dev;
    
    	input_set_drvdata(input_dev, usbtouch);
    
    	input_dev->open = usb_ts_open;
    	input_dev->close = usb_ts_close;
    	
    	usb_ts_dbg("%s 3\n", __func__);
    
    	input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
    	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
    	input_set_abs_params(input_dev, ABS_X, dev_info->min_xc, dev_info->max_xc, 0, 0);
    	input_set_abs_params(input_dev, ABS_Y, dev_info->min_yc, dev_info->max_yc, 0, 0);
    	if (dev_info->max_press)
    		input_set_abs_params(input_dev, ABS_PRESSURE, dev_info->min_press, dev_info->max_press, 0, 0);
    
    	if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
    		usb_fill_int_urb(usbtouch->int_urb, udev,
    			 usb_rcvintpipe(udev, endpoint->bEndpointAddress),
    			 usbtouch->data, dev_info->rept_size,
    			 usb_ts_irq, usbtouch, endpoint->bInterval);
    	else
    		usb_fill_bulk_urb(usbtouch->int_urb, udev,
    			 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
    			 usbtouch->data, dev_info->rept_size,
    			 usb_ts_irq, usbtouch);
    
    	usbtouch->int_urb->dev = udev;
    	usbtouch->int_urb->transfer_dma = usbtouch->data_dma;
    	usbtouch->int_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
    
    	/* device specific init */
    	if (dev_info->init) {
    		err = dev_info->init(usbtouch);
    		if (err) {
    			usb_ts_dbg("%s - type->init() failed, err: %d", __func__, err);
    			goto out_free_urb;
    		}
    	}
    
    	err = input_register_device(usbtouch->input);
    	if (err) {
    		usb_ts_dbg("%s - input_register_device failed, err: %d", __func__, err);
    		goto out_do_exit;
    	}
    
    	usb_set_intfdata(intf, usbtouch);
    
    	if (usbtouch->dev_info->irq_always) {
    		err = usb_submit_urb(usbtouch->int_urb, GFP_KERNEL);
    		if (err) {
    			err("%s - usb_submit_urb failed with result: %d",
    			    __func__, err);
    			goto out_unregister_input;
    		}
    	}
    	
    	usb_ts_dbg("%s 4\n", __func__);
    
    	return 0;
    
    out_unregister_input:
    	input_unregister_device(input_dev);
    	input_dev = NULL;
    out_do_exit:
    	if (dev_info->exit)
    		dev_info->exit(usbtouch);
    out_free_urb:
    	usb_free_urb(usbtouch->int_urb);
    out_free_buffers:
    	usb_ts_free_buffers(udev, usbtouch);
    out_free:
    	input_free_device(input_dev);
    	kfree(usbtouch);
    	return err;
    }
    
    static void usb_ts_disconnect(struct usb_interface *intf)
    {
    	struct usb_ts *usbtouch = usb_get_intfdata(intf);
    
    	usb_ts_dbg("%s - called", __func__);
    
    	if (!usbtouch)
    		return;
    
    	usb_ts_dbg("%s - usbtouch is initialized, cleaning up", __func__);
    	usb_set_intfdata(intf, NULL);
    	/* this will stop IO via close */
    	input_unregister_device(usbtouch->input);
    	usb_free_urb(usbtouch->int_urb);
    	if (usbtouch->dev_info->exit)
    		usbtouch->dev_info->exit(usbtouch);
    	usb_ts_free_buffers(interface_to_usbdev(intf), usbtouch);
    	kfree(usbtouch);
    }
    
    static struct usb_driver usb_ts_driver = {
    	.name		= "usb_ts",
    	.probe		= usb_ts_probe,
    	.disconnect	= usb_ts_disconnect,
    	.id_table	= usb_ts_table,
    };
    
    static int __init usb_ts_init(void)
    {
    	int result;
    
    	/* register this driver with the USB subsystem */
    	result = usb_register(&usb_ts_driver);
    	if (result)
    		err("usb_register failed. Error number %d", result);
    
    	return result;
    }
    
    static void __exit usb_ts_exit(void)
    {
    	/* deregister this driver with the USB subsystem */
    	usb_deregister(&usb_ts_driver);
    }
    
    module_init(usb_ts_init);
    module_exit(usb_ts_exit);
    
    MODULE_AUTHOR("fire <fire@gochen.com.cn>");
    MODULE_DESCRIPTION("Gochen USB Touchscreen driver");
    MODULE_LICENSE("GPL");
    展开全文
  • [Fondar]手机屏幕驱动板HDMI接口USB触摸使用步骤 触摸显示 注意 1 . USB触摸有些支持效果好,有些支持效果一般,有些没有触摸. USB触摸是可选项. 注意2.有些HDMI主机还需要重启驱动板才能显示内容. 1.准备...

    使用步骤

    [Fondar]手机屏幕驱动板HDMI接口USB触摸使用步骤

    触摸显示

     

    注意 1 . USB触摸有些支持效果好,有些支持效果一般,有些没有触摸.

    USB触摸是可选项.

    注意 2 . 有些HDMI主机还需要重启驱动板才能显示内容.

     

    1.准备手机驱动板套件

    2.准备红米note4x手机一体屏幕

    3.驱动板接上10P触摸延长线

    4.驱动板接上屏幕转接板

    5.手机屏幕接上10P触摸延长线

    6.手机屏幕接上屏幕转接板

    7.接上电脑HDMI信号线

    8.接上USB触摸电源

     

    9.红米note3 note4x手机屏幕

       驱动板显示效果

    10.按键背光调整,触摸说明

    红米note7 6.3寸手机屏幕

    驱动板显示效果 分辨率1080x2340

    红米 2A  4.7寸手机屏幕

    驱动板显示效果 分辨率720x1280

    华为M2 M5平板 10.1寸屏幕

    驱动板显示效果 分辨率1200x1920

    展开全文
  • 公司自主研发的,安卓主板外接 红外触摸框,触摸接口是通过usb hid串口方式连接与 发送数据的,请教下应用程序如何在触摸时能够获取触摸框的原始数据,而不是经过底层 处理后的MotionEvent中的触摸数据。之前尝试...
  • usb4-配置usb触摸

    2019-09-20 21:46:30
    淘了一个触摸屏,usb接口,四线电阻,usb芯片是cy7c63723c。 此芯片一端接触摸屏的四根线,对触摸动作采样然后ad转换,一端通过usb接mini2440,即将ad转换后的数据通过usb接口发给mini2440. linux2.6.32已经集成usb ...
    淘了一个触摸屏,usb接口,四线电阻,usb芯片是cy7c63723c。
    此芯片一端接触摸屏的四根线,对触摸动作采样然后ad转换,一端通过usb接mini2440,即将ad转换后的数据通过usb接口发给mini2440.
    linux2.6.32已经集成usb 触摸屏驱动,mini2440默认是不配置的。可以配置一下
    make menuconfig 之后选择
     Device Drivers  --->        Input device support  --->    [*]   Touchscreens  ---> <*>   USB Touchscreen Driver
    即如图

    分析一下这一项的帮助信息,如下,可知其对应的编译符号是 TOUCHSCREEN_USB_COMPOSITE


    先说一下,depends on
    从此项可知这个符号需要根据这些编译符号的配置来显示,!S390 [=S390] && INPUT [=y] && INPUT_TOUCHSCREEN [=y] && USB_ARCH_HAS_HCD [=y]
    比如符号 INPUT_TOUCHSCREEN 要配置成y,而符号 INPUT_TOUCHSCREEN 就是 Touchscreens 这一项,如下

    看他的帮助信息,这一项Touchscreens  就是代表符号INPUT_TOUCHSCREEN

    其余类似

    再看一下,Defined at drivers/input/touchscreen/Kconfig:415 这句话有何用
    他可以帮助我们找到此项的源代码,如下,可以知道本项对应的源代码是usbtouchscreen.c


    直接从该项help里的最上面的提示也可以找到,即CONFIG_TOUCHSCREEN_USB_COMPOSITE,然后去Makefile查找这个东东即可。



    //Kconfig中符号TOUCHSCREEN_USB_COMPOSITE具体信息
    config TOUCHSCREEN_USB_COMPOSITE
    	tristate "USB Touchscreen Driver"
    	depends on USB_ARCH_HAS_HCD//只有这个符号有选,符号TOUCHSCREEN_USB_COMPOSITE才会出现在menu中,跟上面第2个图显示的deponds on外形有些不同,但一样的
    	select USB
    	help
    	  USB Touchscreen driver for:
    	  - eGalax Touchkit USB (also includes eTurboTouch CT-410/510/700)
    	  - PanJit TouchSet USB
    	  - 3M MicroTouch USB (EX II series)
    	  - ITM
    	  - some other eTurboTouch
    	  - Gunze AHL61
    	  - DMC TSC-10/25
    	  - IRTOUCHSYSTEMS/UNITOP
    	  - IdealTEK URTC1000
    	  - GoTop Super_Q2/GogoPen/PenPower tablets
    	  - JASTEC USB Touch Controller/DigiTech DTR-02U
    
    	  Have a look at <http://linux.chapter7.ch/touchkit/> for
    	  a usage description and the required user-space stuff.
    
    	  To compile this driver as a module, choose M here: the
    	  module will be called usbtouchscreen.
    

    /******************************************************************************
     * usbtouchscreen.c
     * Driver for USB Touchscreens, supporting those devices:
     *  - eGalax Touchkit
     *    includes eTurboTouch CT-410/510/700
     *  - 3M/Microtouch  EX II series
     *  - ITM
     *  - PanJit TouchSet
     *  - eTurboTouch
     *  - Gunze AHL61
     *  - DMC TSC-10/25
     *  - IRTOUCHSYSTEMS/UNITOP
     *  - IdealTEK URTC1000
     *  - General Touch
     *  - GoTop Super_Q2/GogoPen/PenPower tablets
     *  - JASTEC USB touch controller/DigiTech DTR-02U
     *
     * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
     * Copyright (C) by Todd E. Johnson (mtouchusb.c)
     *
     * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
     *
     * Driver is based on touchkitusb.c
     * - ITM parts are from itmtouch.c
     * - 3M parts are from mtouchusb.c
     * - PanJit parts are from an unmerged driver by Lanslott Gish
     * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
     *   driver from Marius Vollmer
     *
     *****************************************************************************/
    
    //#define DEBUG
    
    #include <linux/kernel.h>
    #include <linux/slab.h>
    #include <linux/input.h>
    #include <linux/module.h>
    #include <linux/init.h>
    #include <linux/usb.h>
    #include <linux/usb/input.h>
    #include <linux/hid.h>
    
    
    #define DRIVER_VERSION		"v0.6"
    #define DRIVER_AUTHOR		"Daniel Ritz <daniel.ritz@gmx.ch>"
    #define DRIVER_DESC		"USB Touchscreen Driver"
    
    static int swap_xy;
    module_param(swap_xy, bool, 0644);
    MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
    
    static int hwcalib_xy;
    module_param(hwcalib_xy, bool, 0644);
    MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");
    
    /* device specifc data/functions */
    struct usbtouch_usb;
    struct usbtouch_device_info {
    	int min_xc, max_xc;
    	int min_yc, max_yc;
    	int min_press, max_press;
    	int rept_size;
    
    	void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
    
    	/*
    	 * used to get the packet len. possible return values:
    	 * > 0: packet len
    	 * = 0: skip one byte
    	 * < 0: -return value more bytes needed
    	 */
    	int  (*get_pkt_len) (unsigned char *pkt, int len);
    
    	int  (*read_data)   (struct usbtouch_usb *usbtouch, unsigned char *pkt);
    	int  (*init)        (struct usbtouch_usb *usbtouch);
    };
    
    /* a usbtouch device */
    struct usbtouch_usb {
    	unsigned char *data;
    	dma_addr_t data_dma;
    	unsigned char *buffer;
    	int buf_len;
    	struct urb *irq;
    	struct usb_device *udev;
    	struct input_dev *input;
    	struct usbtouch_device_info *type;
    	char name[128];
    	char phys[64];
    
    	int x, y;
    	int touch, press;
    };
    
    
    /* device types */
    enum {
    	DEVTYPE_IGNORE = -1,
    	DEVTYPE_EGALAX,
    	DEVTYPE_PANJIT,
    	DEVTYPE_3M,
    	DEVTYPE_ITM,
    	DEVTYPE_ETURBO,
    	DEVTYPE_GUNZE,
    	DEVTYPE_DMC_TSC10,
    	DEVTYPE_IRTOUCH,
    	DEVTYPE_IDEALTEK,
    	DEVTYPE_GENERAL_TOUCH,
    	DEVTYPE_GOTOP,
    	DEVTYPE_JASTEC,
    	DEVTYPE_E2I,
    };
    
    #define USB_DEVICE_HID_CLASS(vend, prod) \
    	.match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
    		| USB_DEVICE_ID_MATCH_INT_PROTOCOL \
    		| USB_DEVICE_ID_MATCH_DEVICE, \
    	.idVendor = (vend), \
    	.idProduct = (prod), \
    	.bInterfaceClass = USB_INTERFACE_CLASS_HID, \
    	.bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
    
    static struct usb_device_id usbtouch_devices[] = {
    #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
    	/* ignore the HID capable devices, handled by usbhid */
    	{USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE},
    	{USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info = DEVTYPE_IGNORE},
    
    	/* normal device IDs */
    	{USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
    	{USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
    	{USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
    	{USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX},
    	{USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX},
    	{USB_DEVICE(0x1234, 0x0001), .driver_info = DEVTYPE_EGALAX},
    	{USB_DEVICE(0x1234, 0x0002), .driver_info = DEVTYPE_EGALAX},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
    	{USB_DEVICE(0x134c, 0x0001), .driver_info = DEVTYPE_PANJIT},
    	{USB_DEVICE(0x134c, 0x0002), .driver_info = DEVTYPE_PANJIT},
    	{USB_DEVICE(0x134c, 0x0003), .driver_info = DEVTYPE_PANJIT},
    	{USB_DEVICE(0x134c, 0x0004), .driver_info = DEVTYPE_PANJIT},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_3M
    	{USB_DEVICE(0x0596, 0x0001), .driver_info = DEVTYPE_3M},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_ITM
    	{USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
    	{USB_DEVICE(0x1234, 0x5678), .driver_info = DEVTYPE_ETURBO},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
    	{USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
    	{USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
    	{USB_DEVICE(0x595a, 0x0001), .driver_info = DEVTYPE_IRTOUCH},
    	{USB_DEVICE(0x6615, 0x0001), .driver_info = DEVTYPE_IRTOUCH},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
    	{USB_DEVICE(0x1391, 0x1000), .driver_info = DEVTYPE_IDEALTEK},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
    	{USB_DEVICE(0x0dfc, 0x0001), .driver_info = DEVTYPE_GENERAL_TOUCH},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
    	{USB_DEVICE(0x08f2, 0x007f), .driver_info = DEVTYPE_GOTOP},
    	{USB_DEVICE(0x08f2, 0x00ce), .driver_info = DEVTYPE_GOTOP},
    	{USB_DEVICE(0x08f2, 0x00f4), .driver_info = DEVTYPE_GOTOP},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
    	{USB_DEVICE(0x0f92, 0x0001), .driver_info = DEVTYPE_JASTEC},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_E2I
    	{USB_DEVICE(0x1ac7, 0x0001), .driver_info = DEVTYPE_E2I},
    #endif
    	{}
    };
    
    
    /*****************************************************************************
     * e2i Part
     */
    
    #ifdef CONFIG_TOUCHSCREEN_USB_E2I
    static int e2i_init(struct usbtouch_usb *usbtouch)
    {
    	int ret;
    
    	ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
    	                      0x01, 0x02, 0x0000, 0x0081,
    	                      NULL, 0, USB_CTRL_SET_TIMEOUT);
    
    	dbg("%s - usb_control_msg - E2I_RESET - bytes|err: %d",
    	    __func__, ret);
    	return ret;
    }
    
    static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	int tmp = (pkt[0] << 8) | pkt[1];
    	dev->x  = (pkt[2] << 8) | pkt[3];
    	dev->y  = (pkt[4] << 8) | pkt[5];
    
    	tmp = tmp - 0xA000;
    	dev->touch = (tmp > 0);
    	dev->press = (tmp > 0 ? tmp : 0);
    
    	return 1;
    }
    #endif
    
    
    /*****************************************************************************
     * eGalax part
     */
    
    #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
    
    #ifndef MULTI_PACKET
    #define MULTI_PACKET
    #endif
    
    #define EGALAX_PKT_TYPE_MASK		0xFE
    #define EGALAX_PKT_TYPE_REPT		0x80
    #define EGALAX_PKT_TYPE_DIAG		0x0A
    
    static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
    		return 0;
    
    	dev->x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F);
    	dev->y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F);
    	dev->touch = pkt[0] & 0x01;
    
    	return 1;
    }
    
    static int egalax_get_pkt_len(unsigned char *buf, int len)
    {
    	switch (buf[0] & EGALAX_PKT_TYPE_MASK) {
    	case EGALAX_PKT_TYPE_REPT:
    		return 5;
    
    	case EGALAX_PKT_TYPE_DIAG:
    		if (len < 2)
    			return -1;
    
    		return buf[1] + 2;
    	}
    
    	return 0;
    }
    #endif
    
    
    /*****************************************************************************
     * PanJit Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
    static int panjit_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
    	dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
    	dev->touch = pkt[0] & 0x01;
    
    	return 1;
    }
    #endif
    
    
    /*****************************************************************************
     * 3M/Microtouch Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_3M
    
    #define MTOUCHUSB_ASYNC_REPORT          1
    #define MTOUCHUSB_RESET                 7
    #define MTOUCHUSB_REQ_CTRLLR_ID         10
    
    static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	if (hwcalib_xy) {
    		dev->x = (pkt[4] << 8) | pkt[3];
    		dev->y = 0xffff - ((pkt[6] << 8) | pkt[5]);
    	} else {
    		dev->x = (pkt[8] << 8) | pkt[7];
    		dev->y = (pkt[10] << 8) | pkt[9];
    	}
    	dev->touch = (pkt[2] & 0x40) ? 1 : 0;
    
    	return 1;
    }
    
    static int mtouch_init(struct usbtouch_usb *usbtouch)
    {
    	int ret, i;
    
    	ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
    	                      MTOUCHUSB_RESET,
    	                      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
    	                      1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
    	dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
    	    __func__, ret);
    	if (ret < 0)
    		return ret;
    	msleep(150);
    
    	for (i = 0; i < 3; i++) {
    		ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
    				      MTOUCHUSB_ASYNC_REPORT,
    				      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
    				      1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
    		dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
    		    __func__, ret);
    		if (ret >= 0)
    			break;
    		if (ret != -EPIPE)
    			return ret;
    	}
    
    	/* Default min/max xy are the raw values, override if using hw-calib */
    	if (hwcalib_xy) {
    		input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);
    		input_set_abs_params(usbtouch->input, ABS_Y, 0, 0xffff, 0, 0);
    	}
    
    	return 0;
    }
    #endif
    
    
    /*****************************************************************************
     * ITM Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_ITM
    static int itm_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	int touch;
    	/*
    	 * ITM devices report invalid x/y data if not touched.
    	 * if the screen was touched before but is not touched any more
    	 * report touch as 0 with the last valid x/y data once. then stop
    	 * reporting data until touched again.
    	 */
    	dev->press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
    
    	touch = ~pkt[7] & 0x20;
    	if (!touch) {
    		if (dev->touch) {
    			dev->touch = 0;
    			return 1;
    		}
    
    		return 0;
    	}
    
    	dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
    	dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
    	dev->touch = touch;
    
    	return 1;
    }
    #endif
    
    
    /*****************************************************************************
     * eTurboTouch part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
    #ifndef MULTI_PACKET
    #define MULTI_PACKET
    #endif
    static int eturbo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	unsigned int shift;
    
    	/* packets should start with sync */
    	if (!(pkt[0] & 0x80))
    		return 0;
    
    	shift = (6 - (pkt[0] & 0x03));
    	dev->x = ((pkt[3] << 7) | pkt[4]) >> shift;
    	dev->y = ((pkt[1] << 7) | pkt[2]) >> shift;
    	dev->touch = (pkt[0] & 0x10) ? 1 : 0;
    
    	return 1;
    }
    
    static int eturbo_get_pkt_len(unsigned char *buf, int len)
    {
    	if (buf[0] & 0x80)
    		return 5;
    	if (buf[0] == 0x01)
    		return 3;
    	return 0;
    }
    #endif
    
    
    /*****************************************************************************
     * Gunze part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
    static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	if (!(pkt[0] & 0x80) || ((pkt[1] | pkt[2] | pkt[3]) & 0x80))
    		return 0;
    
    	dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[2] & 0x7F);
    	dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[3] & 0x7F);
    	dev->touch = pkt[0] & 0x20;
    
    	return 1;
    }
    #endif
    
    /*****************************************************************************
     * DMC TSC-10/25 Part
     *
     * Documentation about the controller and it's protocol can be found at
     *   http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
     *   http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
    
    /* supported data rates. currently using 130 */
    #define TSC10_RATE_POINT	0x50
    #define TSC10_RATE_30		0x40
    #define TSC10_RATE_50		0x41
    #define TSC10_RATE_80		0x42
    #define TSC10_RATE_100		0x43
    #define TSC10_RATE_130		0x44
    #define TSC10_RATE_150		0x45
    
    /* commands */
    #define TSC10_CMD_RESET		0x55
    #define TSC10_CMD_RATE		0x05
    #define TSC10_CMD_DATA1		0x01
    
    static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
    {
    	struct usb_device *dev = usbtouch->udev;
    	int ret = -ENOMEM;
    	unsigned char *buf;
    
    	buf = kmalloc(2, GFP_KERNEL);
    	if (!buf)
    		goto err_nobuf;
    	/* reset */
    	buf[0] = buf[1] = 0xFF;
    	ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
    	                      TSC10_CMD_RESET,
    	                      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
    	                      0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
    	if (ret < 0)
    		goto err_out;
    	if (buf[0] != 0x06) {
    		ret = -ENODEV;
    		goto err_out;
    	}
    
    	/* set coordinate output rate */
    	buf[0] = buf[1] = 0xFF;
    	ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
    	                      TSC10_CMD_RATE,
    	                      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
    	                      TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
    	if (ret < 0)
    		goto err_out;
    	if ((buf[0] != 0x06) && (buf[0] != 0x15 || buf[1] != 0x01)) {
    		ret = -ENODEV;
    		goto err_out;
    	}
    
    	/* start sending data */
    	ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
    	                      TSC10_CMD_DATA1,
    	                      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
    	                      0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
    err_out:
    	kfree(buf);
    err_nobuf:
    	return ret;
    }
    
    
    static int dmc_tsc10_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	dev->x = ((pkt[2] & 0x03) << 8) | pkt[1];
    	dev->y = ((pkt[4] & 0x03) << 8) | pkt[3];
    	dev->touch = pkt[0] & 0x01;
    
    	return 1;
    }
    #endif
    
    
    /*****************************************************************************
     * IRTOUCH Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
    static int irtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	dev->x = (pkt[3] << 8) | pkt[2];
    	dev->y = (pkt[5] << 8) | pkt[4];
    	dev->touch = (pkt[1] & 0x03) ? 1 : 0;
    
    	return 1;
    }
    #endif
    
    
    /*****************************************************************************
     * IdealTEK URTC1000 Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
    #ifndef MULTI_PACKET
    #define MULTI_PACKET
    #endif
    static int idealtek_get_pkt_len(unsigned char *buf, int len)
    {
    	if (buf[0] & 0x80)
    		return 5;
    	if (buf[0] == 0x01)
    		return len;
    	return 0;
    }
    
    static int idealtek_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	switch (pkt[0] & 0x98) {
    	case 0x88:
    		/* touch data in IdealTEK mode */
    		dev->x = (pkt[1] << 5) | (pkt[2] >> 2);
    		dev->y = (pkt[3] << 5) | (pkt[4] >> 2);
    		dev->touch = (pkt[0] & 0x40) ? 1 : 0;
    		return 1;
    
    	case 0x98:
    		/* touch data in MT emulation mode */
    		dev->x = (pkt[2] << 5) | (pkt[1] >> 2);
    		dev->y = (pkt[4] << 5) | (pkt[3] >> 2);
    		dev->touch = (pkt[0] & 0x40) ? 1 : 0;
    		return 1;
    
    	default:
    		return 0;
    	}
    }
    #endif
    
    /*****************************************************************************
     * General Touch Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
    static int general_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1] ;
    	dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3] ;
    	dev->press = pkt[5] & 0xff;
    	dev->touch = pkt[0] & 0x01;
    
    	return 1;
    }
    #endif
    
    /*****************************************************************************
     * GoTop Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
    static int gotop_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	dev->x = ((pkt[1] & 0x38) << 4) | pkt[2];
    	dev->y = ((pkt[1] & 0x07) << 7) | pkt[3];
    	dev->touch = pkt[0] & 0x01;
    
    	return 1;
    }
    #endif
    
    /*****************************************************************************
     * JASTEC Part
     */
    #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
    static int jastec_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
    {
    	dev->x = ((pkt[0] & 0x3f) << 6) | (pkt[2] & 0x3f);
    	dev->y = ((pkt[1] & 0x3f) << 6) | (pkt[3] & 0x3f);
    	dev->touch = (pkt[0] & 0x40) >> 6;
    
    	return 1;
    }
    #endif
    
    
    /*****************************************************************************
     * the different device descriptors
     */
    #ifdef MULTI_PACKET
    static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
    				   unsigned char *pkt, int len);
    #endif
    
    static struct usbtouch_device_info usbtouch_dev_info[] = {
    #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
    	[DEVTYPE_EGALAX] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x07ff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x07ff,
    		.rept_size	= 16,
    		.process_pkt	= usbtouch_process_multi,
    		.get_pkt_len	= egalax_get_pkt_len,
    		.read_data	= egalax_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
    	[DEVTYPE_PANJIT] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0fff,
    		.rept_size	= 8,
    		.read_data	= panjit_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_3M
    	[DEVTYPE_3M] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x4000,
    		.min_yc		= 0x0,
    		.max_yc		= 0x4000,
    		.rept_size	= 11,
    		.read_data	= mtouch_read_data,
    		.init		= mtouch_init,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_ITM
    	[DEVTYPE_ITM] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0fff,
    		.max_press	= 0xff,
    		.rept_size	= 8,
    		.read_data	= itm_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
    	[DEVTYPE_ETURBO] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x07ff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x07ff,
    		.rept_size	= 8,
    		.process_pkt	= usbtouch_process_multi,
    		.get_pkt_len	= eturbo_get_pkt_len,
    		.read_data	= eturbo_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
    	[DEVTYPE_GUNZE] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0fff,
    		.rept_size	= 4,
    		.read_data	= gunze_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
    	[DEVTYPE_DMC_TSC10] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x03ff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x03ff,
    		.rept_size	= 5,
    		.init		= dmc_tsc10_init,
    		.read_data	= dmc_tsc10_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
    	[DEVTYPE_IRTOUCH] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0fff,
    		.rept_size	= 8,
    		.read_data	= irtouch_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
    	[DEVTYPE_IDEALTEK] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0fff,
    		.rept_size	= 8,
    		.process_pkt	= usbtouch_process_multi,
    		.get_pkt_len	= idealtek_get_pkt_len,
    		.read_data	= idealtek_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
    	[DEVTYPE_GENERAL_TOUCH] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0500,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0500,
    		.rept_size	= 7,
    		.read_data	= general_touch_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
    	[DEVTYPE_GOTOP] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x03ff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x03ff,
    		.rept_size	= 4,
    		.read_data	= gotop_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
    	[DEVTYPE_JASTEC] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x0fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x0fff,
    		.rept_size	= 4,
    		.read_data	= jastec_read_data,
    	},
    #endif
    
    #ifdef CONFIG_TOUCHSCREEN_USB_E2I
    	[DEVTYPE_E2I] = {
    		.min_xc		= 0x0,
    		.max_xc		= 0x7fff,
    		.min_yc		= 0x0,
    		.max_yc		= 0x7fff,
    		.rept_size	= 6,
    		.init		= e2i_init,
    		.read_data	= e2i_read_data,
    	},
    #endif
    };
    
    
    /*****************************************************************************
     * Generic Part
     */
    static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
                                     unsigned char *pkt, int len)
    {
    	struct usbtouch_device_info *type = usbtouch->type;
    
    	if (!type->read_data(usbtouch, pkt))
    			return;
    
    	input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch);
    
    	if (swap_xy) {
    		input_report_abs(usbtouch->input, ABS_X, usbtouch->y);
    		input_report_abs(usbtouch->input, ABS_Y, usbtouch->x);
    	} else {
    		input_report_abs(usbtouch->input, ABS_X, usbtouch->x);
    		input_report_abs(usbtouch->input, ABS_Y, usbtouch->y);
    	}
    	if (type->max_press)
    		input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press);
    	input_sync(usbtouch->input);
    }
    
    
    #ifdef MULTI_PACKET
    static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
                                       unsigned char *pkt, int len)
    {
    	unsigned char *buffer;
    	int pkt_len, pos, buf_len, tmp;
    
    	/* process buffer */
    	if (unlikely(usbtouch->buf_len)) {
    		/* try to get size */
    		pkt_len = usbtouch->type->get_pkt_len(
    				usbtouch->buffer, usbtouch->buf_len);
    
    		/* drop? */
    		if (unlikely(!pkt_len))
    			goto out_flush_buf;
    
    		/* need to append -pkt_len bytes before able to get size */
    		if (unlikely(pkt_len < 0)) {
    			int append = -pkt_len;
    			if (unlikely(append > len))
    			       append = len;
    			if (usbtouch->buf_len + append >= usbtouch->type->rept_size)
    				goto out_flush_buf;
    			memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, append);
    			usbtouch->buf_len += append;
    
    			pkt_len = usbtouch->type->get_pkt_len(
    					usbtouch->buffer, usbtouch->buf_len);
    			if (pkt_len < 0)
    				return;
    		}
    
    		/* append */
    		tmp = pkt_len - usbtouch->buf_len;
    		if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
    			goto out_flush_buf;
    		memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
    		usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len);
    
    		buffer = pkt + tmp;
    		buf_len = len - tmp;
    	} else {
    		buffer = pkt;
    		buf_len = len;
    	}
    
    	/* loop over the received packet, process */
    	pos = 0;
    	while (pos < buf_len) {
    		/* get packet len */
    		pkt_len = usbtouch->type->get_pkt_len(buffer + pos,
    							buf_len - pos);
    
    		/* unknown packet: skip one byte */
    		if (unlikely(!pkt_len)) {
    			pos++;
    			continue;
    		}
    
    		/* full packet: process */
    		if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
    			usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len);
    		} else {
    			/* incomplete packet: save in buffer */
    			memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
    			usbtouch->buf_len = buf_len - pos;
    			return;
    		}
    		pos += pkt_len;
    	}
    
    out_flush_buf:
    	usbtouch->buf_len = 0;
    	return;
    }
    #endif
    
    
    static void usbtouch_irq(struct urb *urb)
    {
    	struct usbtouch_usb *usbtouch = urb->context;
    	int retval;
    
    	switch (urb->status) {
    	case 0:
    		/* success */
    		break;
    	case -ETIME:
    		/* this urb is timing out */
    		dbg("%s - urb timed out - was the device unplugged?",
    		    __func__);
    		return;
    	case -ECONNRESET:
    	case -ENOENT:
    	case -ESHUTDOWN:
    		/* this urb is terminated, clean up */
    		dbg("%s - urb shutting down with status: %d",
    		    __func__, urb->status);
    		return;
    	default:
    		dbg("%s - nonzero urb status received: %d",
    		    __func__, urb->status);
    		goto exit;
    	}
    
    	usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
    
    exit:
    	retval = usb_submit_urb(urb, GFP_ATOMIC);
    	if (retval)
    		err("%s - usb_submit_urb failed with result: %d",
    		    __func__, retval);
    }
    
    static int usbtouch_open(struct input_dev *input)
    {
    	struct usbtouch_usb *usbtouch = input_get_drvdata(input);
    
    	usbtouch->irq->dev = usbtouch->udev;
    
    	if (usb_submit_urb(usbtouch->irq, GFP_KERNEL))
    		return -EIO;
    
    	return 0;
    }
    
    static void usbtouch_close(struct input_dev *input)
    {
    	struct usbtouch_usb *usbtouch = input_get_drvdata(input);
    
    	usb_kill_urb(usbtouch->irq);
    }
    
    
    static void usbtouch_free_buffers(struct usb_device *udev,
    				  struct usbtouch_usb *usbtouch)
    {
    	usb_buffer_free(udev, usbtouch->type->rept_size,
    	                usbtouch->data, usbtouch->data_dma);
    	kfree(usbtouch->buffer);
    }
    
    
    static int usbtouch_probe(struct usb_interface *intf,
    			  const struct usb_device_id *id)
    {
    	struct usbtouch_usb *usbtouch;
    	struct input_dev *input_dev;
    	struct usb_host_interface *interface;
    	struct usb_endpoint_descriptor *endpoint;
    	struct usb_device *udev = interface_to_usbdev(intf);
    	struct usbtouch_device_info *type;
    	int err = -ENOMEM;
    
    	/* some devices are ignored */
    	if (id->driver_info == DEVTYPE_IGNORE)
    		return -ENODEV;
    
    	interface = intf->cur_altsetting;
    	endpoint = &interface->endpoint[0].desc;
    
    	usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
    	input_dev = input_allocate_device();
    	if (!usbtouch || !input_dev)
    		goto out_free;
    
    	type = &usbtouch_dev_info[id->driver_info];
    	usbtouch->type = type;
    	if (!type->process_pkt)
    		type->process_pkt = usbtouch_process_pkt;
    
    	usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
    	                                  GFP_KERNEL, &usbtouch->data_dma);
    	if (!usbtouch->data)
    		goto out_free;
    
    	if (type->get_pkt_len) {
    		usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL);
    		if (!usbtouch->buffer)
    			goto out_free_buffers;
    	}
    
    	usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
    	if (!usbtouch->irq) {
    		dbg("%s - usb_alloc_urb failed: usbtouch->irq", __func__);
    		goto out_free_buffers;
    	}
    
    	usbtouch->udev = udev;
    	usbtouch->input = input_dev;
    
    	if (udev->manufacturer)
    		strlcpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name));
    
    	if (udev->product) {
    		if (udev->manufacturer)
    			strlcat(usbtouch->name, " ", sizeof(usbtouch->name));
    		strlcat(usbtouch->name, udev->product, sizeof(usbtouch->name));
    	}
    
    	if (!strlen(usbtouch->name))
    		snprintf(usbtouch->name, sizeof(usbtouch->name),
    			"USB Touchscreen %04x:%04x",
    			 le16_to_cpu(udev->descriptor.idVendor),
    			 le16_to_cpu(udev->descriptor.idProduct));
    
    	usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys));
    	strlcat(usbtouch->phys, "/input0", sizeof(usbtouch->phys));
    
    	input_dev->name = usbtouch->name;
    	input_dev->phys = usbtouch->phys;
    	usb_to_input_id(udev, &input_dev->id);
    	input_dev->dev.parent = &intf->dev;
    
    	input_set_drvdata(input_dev, usbtouch);
    
    	input_dev->open = usbtouch_open;
    	input_dev->close = usbtouch_close;
    
    	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
    	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
    	input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0);
    	input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0);
    	if (type->max_press)
    		input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press,
    		                     type->max_press, 0, 0);
    
    	usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
    			 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress),
    			 usbtouch->data, type->rept_size,
    			 usbtouch_irq, usbtouch, endpoint->bInterval);
    
    	usbtouch->irq->dev = usbtouch->udev;
    	usbtouch->irq->transfer_dma = usbtouch->data_dma;
    	usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
    
    	/* device specific init */
    	if (type->init) {
    		err = type->init(usbtouch);
    		if (err) {
    			dbg("%s - type->init() failed, err: %d", __func__, err);
    			goto out_free_buffers;
    		}
    	}
    
    	err = input_register_device(usbtouch->input);
    	if (err) {
    		dbg("%s - input_register_device failed, err: %d", __func__, err);
    		goto out_free_buffers;
    	}
    
    	usb_set_intfdata(intf, usbtouch);
    
    	return 0;
    
    out_free_buffers:
    	usbtouch_free_buffers(udev, usbtouch);
    out_free:
    	input_free_device(input_dev);
    	kfree(usbtouch);
    	return err;
    }
    
    static void usbtouch_disconnect(struct usb_interface *intf)
    {
    	struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
    
    	dbg("%s - called", __func__);
    
    	if (!usbtouch)
    		return;
    
    	dbg("%s - usbtouch is initialized, cleaning up", __func__);
    	usb_set_intfdata(intf, NULL);
    	usb_kill_urb(usbtouch->irq);
    	input_unregister_device(usbtouch->input);
    	usb_free_urb(usbtouch->irq);
    	usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
    	kfree(usbtouch);
    }
    
    MODULE_DEVICE_TABLE(usb, usbtouch_devices);
    
    static struct usb_driver usbtouch_driver = {
    	.name		= "usbtouchscreen",
    	.probe		= usbtouch_probe,
    	.disconnect	= usbtouch_disconnect,
    	.id_table	= usbtouch_devices,
    };
    
    static int __init usbtouch_init(void)
    {
    	return usb_register(&usbtouch_driver);
    }
    
    static void __exit usbtouch_cleanup(void)
    {
    	usb_deregister(&usbtouch_driver);
    }
    
    module_init(usbtouch_init);
    module_exit(usbtouch_cleanup);
    
    MODULE_AUTHOR(DRIVER_AUTHOR);
    MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");
    
    MODULE_ALIAS("touchkitusb");
    MODULE_ALIAS("itmtouch");
    MODULE_ALIAS("mtouchusb");


    转载于:https://www.cnblogs.com/-song/archive/2011/10/31/3331937.html

    展开全文
  • 均安装了win 7 (嵌入式版)操作系统,使用触摸屏,触摸屏通过USB线接在主机的USB口中, 在控制面板中的电源计划中的USB选择性暂停设置已经禁止掉。 在现场中,发现一个怪异现象。在通电启动进入系统后,发现触摸屏...
  • 使用tslib来校准usb接口触摸

    千次阅读 2015-05-22 14:11:51
    现在使用eGalax的usb触摸屏设备。然后使用LinuxInput的Qt库,之前使用的是Qt里面的校准程序。但是发现,程序里面能够分辨的,设备的右下角坐标,总是等于内核的分辨率,也就是800*600。在开发板的环境变量里面有个,...

    现在使用eGalax的usb触摸屏设备。然后使用LinuxInput的Qt库,之前使用的是Qt里面的校准程序。但是发现,程序里面能够分辨的,设备的右下角坐标,总是等于内核的分辨率,也就是800*600。在开发板的环境变量里面有个,QWS_SIZE这个东西,我设置了也没见什么效果,删除了也没什么问题。所以校准出来的结果是,触摸屏左上四分之一,就已经能够表达显示器的全屏了,即800*600。
    但是,这没法用。所以最后又把目光投向tslib,之前就想过自己修改tslib,这回也许是瞎猫和耗子的关系,竟然真的实现了。
    在之前使用tslib时,打开usb设备,会经过fd_check()这个函数。它会对当前设备进行判断,看看是不是触屏设备(当然是了)。但是不知道是什么原因,usb的触屏就是不认,EV_VERSION这个东西我也修改了,发现不行,因为还有其他的很多判断条件。索性我直接在input-raw.c里面的,mod_init()这个函数里面把i->sane_fd = 0;这个修改成1。即
    TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
    {
    struct tslib_input *i;

    i = malloc(sizeof(struct tslib_input));
    if (i == NULL)
        return NULL;
    
    i->module.ops = &__ts_input_ops;
    i->current_x = 0;
    i->current_y = 0;
    i->current_p = 0;
    i->sane_fd = 1;
    i->using_syn = 0;
    return &(i->module);
    

    }这样就直接屏蔽了fd_check()这个过程。继续测试,发现还是不行,打开debug发现其实x、y坐标已经有了,但是就因为没有pressure的值,所以在tests\Testutils.c文件中有个while循环过不去。见getxy()函数中,
    do {
    if (ts_read_raw(ts, &samp[0], 1) < 0) {
    perror(“ts_read”);
    close_framebuffer ();
    exit(1);
    }

    } while (samp[0].pressure == 0);
    所以我在ts_input_read()函数中
    #ifdef DEBUG
                fprintf(stderr, "RAW---------------------------> %d %d %d\n",
                    samp->x, samp->y, samp->pressure);
    #endif   /*DEBUG*/
    

    这个地方加了一句,samp->pressure = 1;
    编译测试。成功了!!!当然方法比较傻,暂时能够实现。因为不太会linux下面的编程,特别是关于驱动的。如果会的话,我觉得应该可以参考tslib,自己写一个校准软件出来。

    展开全文
  • 设备同时有两个lcd,主屏是mipi接口,带有触摸屏,触摸屏是usb接口,副屏是hdmi接口,没有触摸屏,正常情况下,两个lcd显示相同内容,触摸屏一切正常;当打开双屏异显的app时,触摸屏就失效,触摸没反应,插上usb...
  • 请问WINCE 6.0是否支持USB接口电容触摸屏?只要单点就行,不用多点操作。我的电容屏连接到Windows 7上是可以识别使用的。在WinCE 6.0平台上是否支持通过USB将电容屏作为一个HID设备来使用?就像鼠标那样。还是说一定...
  • usb触摸屏驱动移植

    千次阅读 2012-08-19 11:26:16
    最近公司产品在原有基础上增加一个触摸功能,因电路已经定型,只有usb接口引出来,所以只能选用市面上usb接口触摸屏,联系了多家触摸屏代理商,移植时都存在问题。  公司产品用的平台是: PXA270 + linux2.6.27 +...
  • USB接口定义

    千次阅读 2019-01-23 12:42:45
    USB接口标准 USB是电脑的常见接口,有4根线,两根电源线和两个信号线,电源线正负极供电,接烦可能导致USB设备或电脑的南桥芯片烧坏。 type A 即我们常见的标准USB大口,主流的可以分为USB2.0速度(几十M/S)和...
  • 禾瑞亚USB接口电阻触摸屏控制卡QNX 6.5 RTOS操作系统x86架构驱动安装与配置方法 前提条件:安装QNX 6.5 RTOS操作系统的主板的USB接口必须能够被操作系统识别,否则连接不到触摸屏的控制卡并且无法使用U盘往其中复制...
  • Android系统USB触摸屏配置方法

    万次阅读 2015-11-10 11:05:46
    一般的USB 接口免驱触摸屏均能免驱支持windows XP, windows 7, windows 8 等windows 家族的操作系统,所以在使用触摸屏搭建最终使用环境乊前可以使用windows家族系统测试触摸屏,确保触摸屏能够正常的工作(相当于...
  • 本文转载自:... 最近需要往TV上装一个触摸屏设备,现在比较常见的就是使用usb接口触摸框,适用于各种平台,这里大体记录一下在android上kernel中的usbtouchscreen驱动. ...
  • 最近需要往TV上装一个触摸屏设备,现在比较常见的就是使用usb接口触摸框,适用于各种平台,这里大体记录一下在android上kernel中的usbtouchscreen驱动. 目前的kernel中都是自带了usbtouchscreen驱动的,我的...
  • 现象:USB 接口触摸屏插到板子上,触摸屏无法使用,有可能出现更奇葩的,同一套代码,有的板子可以用,有的板子不能用。 1、打开串口调试,插上触摸屏,读取触摸屏的 PID(idVendor) 和 VID(idProduct)。 ...
  • 系统版本:RK3288 android 6.0设备同时有两个lcd,主屏是lvds接口,带有触摸屏,触摸屏是usb接口,副屏是hdmi接口,没有触摸屏,正常情况下,两个lcd显示相同内容,触摸屏一切正常;测试过hdmi作为主屏,lvds作为副...
  • win7 注入 usb3.0接口

    2016-04-19 09:41:00
    看到很多人给2013款的苹果笔记本安装双系统,特别是WIN7,到安装界面那里,触摸板和鼠标用不了,其实就是WIN7没有原生集成USB 3.0驱动造成的,下面简单介绍一下如何制作集成了USB 3.0驱动的WIN7安装U盘 在D盘下建立...
  •  触摸屏在内核下找到usb 触摸屏驱动,内核启动后这个usb转的触摸屏也正常找到,注册为event接口事件event0, cat /dev/event0,触摸屏幕有乱码输出,说明usb触摸屏驱动产生中断并且将采集数据上报input子系统了。...
  • 关于tslib移植usb触摸屏的一个笔记

    千次阅读 2013-11-25 15:44:24
    usb触摸屏是32寸,显示用的hdmi接口,板子用的A8(友善之臂的),图形界面用的是qt。 1:tslib编译网上比较多,这里我就不去说了。 2:原理问题: kernl--》tslib---》qt tslib分为:tslib.o  
  • 凡是配置触摸屏显示器的笔记本电脑、平板电脑、电子书、移动网络装置(MID)、信息站、自动柜员机,以及其它的销售时点(POS)设备,新推出的CP2501 USB触摸屏桥接器都能提供可编程且易于使用的USB接口。 CP2501为业界...
  • 该设计结合了USB和无线设备的优点,将手持端的鼠标触摸板控制信息通过无线发送到接收端并通过USB接口与主机PC实现交互通信。整个系统主要由PIC16FB77A单片机,PDIUSBDl2芯片,CC2420无线模块,PS/2鼠标触摸板实现。
  • ThinkPad X1 Tablet键盘改USB接口

    万次阅读 2019-06-15 13:37:53
    ThinkPad X1 Tablet键盘改USB接口记 起因 用USB独立键盘,打字的同时又要去用鼠标的感觉实在糟糕,就算是有一个好的机械键盘也是如此。能不能有一个像笔记本那样既有按键又有触摸板在下方的键盘呢?最好再加个小红点...
  • CypressTrueTouchTM电容触摸屏方案可以在多个领域获得广泛应用:单点触摸,...TrueTouchTM芯片与主机通过TX/I2C/SPI/USB接口通讯,PSoCDesigner5.0提供了相应的各种通讯用户模块,这将大大简化用户的编程和调试工作。
  • 主要面向消费类电子、工控、车载导航、人机界面、行业PDA等电子产品的开发而设计,主要供广大企业用户进行产品前期软硬件性能评估验证、设计参考用,其强大的功能、丰富的外设接口、人性化外观设计也是高校、培训...

空空如也

空空如也

1 2 3 4 5 ... 16
收藏数 306
精华内容 122
关键字:

usb触摸接口