Re: NVrec - V4L1 interface ( does mmap() work with bttv 0.8.16? )

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Eugene Kuznetsov wrote:
> Tested it with 0.8.16, still does not work :(( ...
> First, as I already mentioned, it does not compile with -Werror:
> 
> gcc -pthread -Wall -O2 -g -Werror -o QTrec NVrec.c -ldl -lpng -lglib RTjpeg.o quicktime/libquicktime.a
> cc1: warnings being treated as errors
> In file included from NVrec.c:31:
> /usr/include/linux/videodev.h:942: warning: `struct file' declared inside parameter list
> /usr/include/linux/videodev.h:942: warning: its scope is only this definition or declaration, which is probably not what you want.
> /usr/include/linux/videodev.h:942: warning: `struct inode' declared inside parameter list
> make: *** [QTrec] Error 1
> 
> This may be caused by me doing something wrong when patching the
> kernel.

That is strange.  I am pretty sure 'struct  file' and 'struct inode'
should never be visible to userland compiles. Gerd, could you please
have a look at this (please let me know if this is actually a fault on
my side)?

> Then, after I figured out correct sequence of actions for starting
> program ( that is: insert module as "modprobe bttv card=37
> sloppy=1 gbuffers=32 mmap=1"; start xawtv; close xawtv ), things
> started to become more complicated. I received an 'invalid argument'
> error for adding buffer to the queue. Debugging showed that the
> problem is actually in failing call to mmap() twenty lines higher,
> which was passed by error filter:
> 
> v4l1_core.c:216:
>         cct->mmbuf = (unsigned char *)mmap(NULL, vmb.size, PROT_READ, MAP_SHARED, cct->fd, 0);
>         if((int)(cct->bufs[0]) == -1) {
>             perror("v4l1 core init - mmap failed");
>             goto error2;;
>         }
> 
> ( note that return value of mmap() is assigned to different variable
> than the one which is checked for -1; obviously a bug ). mmap()
> returns -1 and sets errno to EINVAL.
> 
> Next question is, why mmap() is failing? I tried to add a couple
> of printk()'s to find out what happens, and this looks quite weird
> for me. One of the first sanity checks in bttv_mmap() ( sources of
> 0.8.16 ) fails. It is:
> 
>         if (!(vma->vm_flags & VM_SHARED))
>             return -EINVAL;
> 
> But, if I correctly understood what happens during the mmap() syscall
> ( /usr/src/linux/mm/mmap.c ), VM_SHARED flag is not set for mapping
> areas read-only! I tried to change protection in parameters to
> mmap(), but only to receive 'permission denied' instead of 'invalid
> argument', even as root.

Umm.. Try the attached patch - this may work...

-justin
--- v4l1_core.c.orig	Thu Jun  7 12:28:23 2001
+++ v4l1_core.c	Thu Jun  7 12:28:53 2001
@@ -213,8 +213,8 @@
 	
 	fprintf(stderr, "v4l1 core init - got %i buffers\n", cct->nbufs);
 
-	cct->mmbuf = (unsigned char *)mmap(NULL, vmb.size, PROT_READ, MAP_SHARED, cct->fd, 0);
-	if((int)(cct->bufs[0]) == -1) {
+	cct->mmbuf = (unsigned char *)mmap(NULL, vmb.size, PROT_READ|PROT_WRITE, MAP_SHARED, cct->fd, 0);
+	if((int)(cct->mmbuf) == -1) {
 		perror("v4l1 core init - mmap failed");
 		goto error2;;
 	}

[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux