From owner-freebsd-hackers Tue Jan 23 14:00:04 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id OAA21582 for hackers-outgoing; Tue, 23 Jan 1996 14:00:04 -0800 (PST) Received: from miller.cs.uwm.edu (miller.cs.uwm.edu [129.89.9.13]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id NAA21519 for ; Tue, 23 Jan 1996 13:59:43 -0800 (PST) Received: (from james@localhost) by miller.cs.uwm.edu (8.7.3/8.7.3) id PAA21997; Tue, 23 Jan 1996 15:59:42 -0600 Date: Tue, 23 Jan 1996 15:59:42 -0600 From: Jim Lowe Message-Id: <199601232159.PAA21997@miller.cs.uwm.edu> To: marino.ladavac@aut.alcatel.at Subject: Re: Amancio's tv program with capture! Cc: hackers@freebsd.org Sender: owner-hackers@freebsd.org Precedence: bulk > 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