Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jan 1996 15:59:42 -0600
From:      Jim Lowe <james@miller.cs.uwm.edu>
To:        marino.ladavac@aut.alcatel.at
Cc:        hackers@freebsd.org
Subject:   Re: Amancio's tv program with capture!
Message-ID:  <199601232159.PAA21997@miller.cs.uwm.edu>

next in thread | raw e-mail | index | archive | help
> Is it possible to mmap() something to the address returned by shmat()?
> 
> Something like:
> 
> 	shmaddr = shmat( shmid, NULL, 0 );
> 	mapaddr = mmap( shmaddr, ... );
> 
> I haven't got a slightest clue about this approach.
> 
> /Alby
> 
Yes, and no.  One should be able to do this, but the frame grabber
can't write into this shmaddr.  It has its own constraints to deal
with.

The driver writes to a contiguously, wired down region of memory
that is allocated at bootup time.  So we do something like:

	i = open("/dev/meteor0", O_RDONLY);
	total_size = ((geo.columns*geo.rows*geo.frames*depth+4095)/4096)*4096;
	data_addr=mmap((caddr_t)0, total_size + 4096, PROT_READ,
		MAP_SHARED, i, (off_t)0);

Now we want X to be able to access this so I tried something like:

	ximage = XShmCreateImage(display, fc_visual, depth,
		ZPixmap, NULL, $shminfo, vid_stream->mb_width,
		vid_stream->mb_height);
	shminfo.shmid = shmget (IPC_PRIVATE,
		 ximage->bytes_per_line * ximage->height,
		IPC_CREAT | 0777);
	shminfo.shmaddr = ximage->data = shmat(sminfo.shmid, data_addr, 0);
	xhminfo.readOnly = True;
	XShmAttach(display, &shminfo);
	XShmPutImage(display, ...);


If I do a
	ximage->data = shmat(sminfo.shmid, 0, 0)
 and then a
	bcopy(data_addr, image->data, size);
	XShmPutImage(display, ...);
It works just fine.

I am not sure how one is suppose to mark a previous defined
memory region as shared and get an id for it to pass along
to X.  The whole object is to avoid the ``bcopy'' because
we are talking anywhere from 5-35MBytes/second of data we
have to copy.  From the tests that I have done, I can only
get about 40Mbytes/second mem<->mem bandwidth (Triton chipset),
which doesn't leave much (if any) room for anything else.

	-Jim



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601232159.PAA21997>