omap3530上移植AMT 6000 系列USB型触摸屏+tslib(九)

2014-11-24 08:39:42 来源: 作者: 浏览: 9
_xc = 0x0fff,
.min_yc = 0x0,
.max_yc = 0x0fff,
.rept_size = 5,
.read_data = tc5uh_read_data,
},
#endif


/***************************************************************
*add by willow 2011.4.13
*AMT 6000 PART
*/
#ifdef CONFIG_TOUCHSCREEN_USB_AMT_6000
[DEVTYPE_AMT_6000] = {
.min_xc = 0x0,
//.max_xc = 0x0fff,
.max_xc = 0x0400,
.min_yc = 0x0,
//.max_yc = 0x0fff,
.max_yc = 0x0300,
.rept_size = 5,
.read_data = amt_6000_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))) {

-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: