Sorry i messed it up, my apologies ! it sould be void *buf[NUM]; > void *buf[NUM*BUFF_SIZE]; > > buf [0] = mmap (fd, ...); > > for( i = 0; i < NUM; i++ ) { > buf [1] = buf [0] +i* BUFF_SIZE; /* GCC extension :) */ > > > read( iofd, buf, NUM*BUFF_SIZE ); > /* Initially u fill in all buffers with data. */ > > > configure_number_of_driver_buffers_and_kick_it_to_start_xfer_of_first_buffer > (); > /* This one kicks off the xfer of FIRST buffer */ > > no = 0; > > for( index = 0; !done(); index = (index+1)%NUM ) { > > /* WAIT till u get an intimation (irq_handler) */ > /* This could be done by sem, fasync+sleep, or poll, */ > /* I used fasync() here with sleep */ > > sleep(1); > /* The sleep time is depending on the design, > This fills up the buffer even if its not used up by driver > bcoz, here the data xfered is video data, delay > is more costly than data loss. So i can do with data loss > than delay ( NOTE: this is true for MY application ) > */ > Here the driver itself switches to next buffer xfer in irq_handler. > > read( iofd, buff[index], BUFF_SIZE ); > > } > > Well, the n buffers are required here bcoz of bandwidth and the > limitation > on size of DMA capable buffers available in linux kernel. > u get buffers through __get_dma_pages() which can give u > max 128k most of the times. > > Now considering the speed of CPU (mine is 233Mhz) and speed of DMA 100 > Mbps by the device ). > The device can finish xfering the 1st buffer before u fill in the second > one. > So till its finished, u need to block ( Which is not prefered ). > To give for this spead diffs u either need a very large buffer > or increase number of small buffers. > U can calculate the exact buff nos and size depending on calculations > done on disk_read_latency, driver-appl switching latency, > actual throughput of the device etc. > > -nagaraj. > \(*_*)/ > > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/