updated on Fri Jan 6 08:01:17 UTC 2012
[aur-mirror.git] / avld / bad.patch
bloba806ba8f05fab0e5a8ca6e85d06c40b04d1e29b2
1 --- video_device.c.original 2009-02-02 16:34:08.000000000 +0800
2 +++ video_device.c 2009-02-02 16:32:10.000000000 +0800
3 @@ -26,7 +26,7 @@
4 #include <media/v4l2-ioctl.h>
5 #endif
7 -/*#define DEBUG*/
8 +//#define DEBUG
10 #define KERNEL_PREFIX "AVLD device: " /* Prefix of each kernel message */
11 #define VID_DUMMY_DEVICE 0 /* The type of device we create */
12 @@ -456,14 +456,51 @@
13 printk(KERNEL_PREFIX "entering v4l_read()\n");
14 #endif
16 + int waiting_time;
17 + struct timeval current_time;
19 // if input size superior to the buffered image size
20 if (count > BUFFER_SIZE) {
21 printk(KERNEL_PREFIX "ERROR : you are attempting to read too much data : %d/%lu\n",count,BUFFER_SIZE);
22 return -EINVAL;
24 - memcpy(buf,image,count*sizeof(char));
26 + copy_to_user(buf,image,count*sizeof(char));
28 + // Wait to simulate FPS if necessary
29 + #ifdef DEBUG
30 + printk(KERNEL_PREFIX "waiting v4l_read() : %d - %ld\n",count,BUFFER_SIZE);
31 + #endif
32 + if ( fps > 0 ) {
33 + do_gettimeofday(&current_time);
34 + //printk(KERNEL_PREFIX "t2=%d.%d - t1=%d.%d\n",current_time.tv_sec,current_time.tv_usec,timer.tv_sec,timer.tv_usec);
36 + // Compute waiting_time
37 + waiting_time = HZ/fps - HZ*( (current_time.tv_sec-timer.tv_sec)*USEC_PER_SEC + (current_time.tv_usec-timer.tv_usec) )/USEC_PER_SEC;
38 + //waiting_time = MSEC_PER_SEC/fps - ( (current_time.tv_sec-timer.tv_sec)*MSEC_PER_SEC + (current_time.tv_usec-timer.tv_usec)/USEC_PER_MSEC );
40 + // waits
41 + if (waiting_time > 0) {
42 + // solution 1
43 + interruptible_sleep_on_timeout (&wait,waiting_time);
45 + // solution 2
46 + //set_current_state(TASK_INTERRUPTIBLE);
47 + //schedule_timeout(waiting_time);
49 + // solution 3
50 + //msleep_interruptible(waiting_time);
51 + }
53 + do_gettimeofday(&timer);
54 + }
55 + // Wait reader before continue
56 + else if ( fps < 0 ) {
57 + #ifdef DEBUG
58 + printk (KERN_INFO "fps value : %d\n",fps);
59 + #endif
60 + mutex_lock_interruptible(&lock);
61 + }
63 #ifdef DEBUG
64 printk(KERNEL_PREFIX "leaving v4l_read() : %d - %ld\n",count,BUFFER_SIZE);
65 #endif