Iso dma to user space available for ohci module
Brought to you by:
aeb,
bencollins
From: Sebastien R. <Seb...@sy...> - 2000-04-20 11:24:14
|
I am please to announce the availibility of direct iso dma to user space for the ohci module. The driver supports multi-buffering and user configurable frame sizes. It is now included in the sourceforge CVS repository. To achieve that, I have temporarily created a /dev/ohci1394 entry. If you want to test this feature, you have to add it manually: 'mknod /dev/ohci1394 c 172 0' and set the permission accordingly. If the MAJOR number is already taken on your system, change it in ohci1394.h I have also added a file called video1394.h that has to be included in the source code of the user application. Note that the API is just temporary, I have to see with Andreas what would be the best way to include that in the subsystem. If you want to enable the direct DMA to user space feature, you will have to set it at the beginning of ohci1394.h. Please be aware that this feature has not been tested extensively (it works from me on linux-2.2.14)... USE AT YOUR OWN RISK ! The user app works like this. It is loosely based on the video4linux API: main() { int fd; struct video1394_mmap v; struct video1394_wait w; char *map; v.channel = 4; /* the iso channel you want to listen to */ v.sync_tag = 1; /* the tag in the iso packet for frame sync */ v.nb_buffers = 2; /* the number of buffers you want */ v.buf_size = 320*240*2; /* the size in bytes of one frame */ /* open the driver */ fd = open("/dev/ohci1394",O_RDWR); /* launch the iso context that will do the dma transfer */ /* !!! NOTE: the field v.buf_size is modified by this call !!! */ if (ioctl(fd, VIDEO1394_LISTEN_CHANNEL, &v)<0) { perror("VIDEO1394_LISTEN_CHANNEL"); } /* map the dma buffer into user space */ if ((map = (char *) mmap(0,v.nb_buffers*v.buf_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd,0)) == (char *)-1) { perror("mmap"); return -1; } /* here you do the camera initialization, start iso transmission */ ........ /* */ w.channel = 4; /* the channel you are listening */ w.buffer = 0; /* the buffer number that has been loaded */ while(cond) { /* wait for the next frame */ ioctl(fd, VIDEO1394_WAIT_CHANNEL, &w); /* the image buffer starts at map+w.buffer*v.buf_size, * and has for length the frame size specified at the * beginning of the program. */ } /* here you do the camera stop, stop iso transmission */ ........ /* */ /* unmap the memory */ if (map!=(char*)-1) munmap(map,v.nb_buffers*v.buf_size); /* deallocate the iso context */ if (ioctl(fd, VIDEO1394_UNLISTEN_CHANNEL, &v.channel)<0) { perror("VIDEO1394_UNLISTEN_CHANNEL"); } /* close the device */ close(fd); } Enjoy ! -- Sebastien Rougeaux RSISE, The Australian National University |