-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback.c
64 lines (55 loc) · 1.62 KB
/
callback.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*************************************************************************
* Source: le pilote uvcvideo (voir le répertoire /home/ELE784/uvc
* pour les fichiers sources)
************************************************************************/
static void complete_callback(struct urb *urb){
int ret;
int i;
unsigned char * data;
unsigned int len;
unsigned int maxlen;
unsigned int nbytes;
void * mem;
if(urb->status == 0){
for (i = 0; i < urb->number_of_packets; ++i) {
if(myStatus == 1){
continue;
}
if (urb->iso_frame_desc[i].status < 0) {
continue;
}
data = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
if(data[1] & (1 << 6)){
continue;
}
len = urb->iso_frame_desc[i].actual_length;
if (len < 2 || data[0] < 2 || data[0] > len){
continue;
}
len -= data[0];
maxlen = myLength - myLengthUsed ;
mem = myData + myLengthUsed;
nbytes = min(len, maxlen);
memcpy(mem, data + data[0], nbytes);
myLengthUsed += nbytes;
if (len > maxlen) {
myStatus = 1; // DONE
}
/* Mark the buffer as done if the EOF marker is set. */
if ((data[1] & (1 << 1)) && (myLengthUsed != 0)) {
myStatus = 1; // DONE
}
}
if (!(myStatus == 1)){
if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
//printk(KERN_WARNING "");
}
}else{
///////////////////////////////////////////////////////////////////////
// Synchronisation
///////////////////////////////////////////////////////////////////////
}
}else{
//printk(KERN_WARNING "");
}
}