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


#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;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwxzdz.html