os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/circbuf.c File Reference

#include <linux/module.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/autoconf.h>
#include <linux/time.h>
#include <asm/system.h>
#include <asm/arch/memmap.h>
#include <asm/io.h>
#include <asm/arch/dma.h>
#include <asm/arch/hwregs/dma_defs.h>
#include <asm/arch/hwregs/dma.h>
#include <asm/arch/hwregs/reg_map.h>
#include <asm/arch/hwregs/bif_dma_defs.h>
#include <asm/irq.h>
#include <asm/atomic.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
#include <asm/elphel/driver_numbers.h>
#include <asm/elphel/c313a.h>
#include "fpgactrl.h"
#include "framepars.h"
#include "x3x3.h"
#include "cxdma.h"
#include "sensor_common.h"
#include "jpeghead.h"
#include "circbuf.h"
#include "exif.h"

Include dependency graph for circbuf.c:

Go to the source code of this file.

Data Structures

struct  circbuf_pd

Defines

#define MDF(x)
#define D19(x)
#define MDF19(x)
#define D20(x)
#define MDF20(x)
#define MD12(x)
#define D(x)
#define D1(x)
#define MD1(x)
#define MD2(x)
#define MD5(x)
#define MD6(x)
#define MD7(x)
#define D0(x)
#define MD8(x)
#define MD9(x)
#define MD10(x)
#define MD11(x)
#define JPEG_HEADER_MAX_SIZE   0x300
#define CIRCBUF_DRIVER_NAME   "Elphel (R) Model 353 video buffer device driver"

Functions

static unsigned long ccam_dma_buf[CCAM_DMA_SIZE+(PAGE_SIZE >>2)] __attribute__ ((aligned(PAGE_SIZE)))
void init_ccam_dma_buf_ptr (void)
 still used in autoexposure or something - why is in needed there?
int circbuf_all_open (struct inode *inode, struct file *filp)
int circbuf_all_release (struct inode *inode, struct file *filp)
loff_t circbuf_all_lseek (struct file *file, loff_t offset, int orig)
ssize_t circbuf_all_read (struct file *file, char *buf, size_t count, loff_t *off)
ssize_t circbuf_all_write (struct file *file, const char *buf, size_t count, loff_t *off)
int circbuf_all_mmap (struct file *file, struct vm_area_struct *vma)
unsigned int circbuf_all_poll (struct file *file, poll_table *wait)
int circbuf_all_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
 just to notify it is not implemented
int circbuf_open (struct inode *inode, struct file *filp)
int circbufValidPointer (int rp, struct interframe_params_t **fpp)
loff_t circbuf_lseek (struct file *file, loff_t offset, int orig)
ssize_t circbuf_write (struct file *file, const char *buf, size_t count, loff_t *off)
ssize_t circbuf_read (struct file *file, char *buf, size_t count, loff_t *off)
int circbuf_mmap (struct file *file, struct vm_area_struct *vma)
unsigned int circbuf_poll (struct file *file, poll_table *wait)
static int __init circbuf_all_init (void)
 module_init (circbuf_all_init)
 MODULE_LICENSE ("GPLv3.0")
 MODULE_AUTHOR ("Andrey Filippov <andrey@elphel.com>.")
 MODULE_DESCRIPTION (CIRCBUF_DRIVER_NAME)

Variables

unsigned long * ccam_dma_buf_ptr = NULL
 CIRCBUF macros.
unsigned long * ccam_dma = NULL
interframe_params_t frame_params
wait_queue_head_t circbuf_wait_queue
static struct file_operations circbuf_fops


Define Documentation

#define CIRCBUF_DRIVER_NAME   "Elphel (R) Model 353 video buffer device driver"

========================================================================================================= ! circbuf top level device drivers. Minors are the same as before ! CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_JPEAGHEAD - just a new major !========================================================================================================

Definition at line 256 of file circbuf.c.

Referenced by circbuf_all_init().

#define D ( x   ) 

Definition at line 197 of file circbuf.c.

#define D0 ( x   ) 

Definition at line 212 of file circbuf.c.

#define D1 ( x   ) 

Definition at line 198 of file circbuf.c.

#define D19 ( x   ) 

Definition at line 189 of file circbuf.c.

#define D20 ( x   ) 

Definition at line 191 of file circbuf.c.

#define JPEG_HEADER_MAX_SIZE   0x300

Definition at line 225 of file circbuf.c.

#define MD1 ( x   ) 

Definition at line 200 of file circbuf.c.

Referenced by fpga_open(), and init_FPGA().

#define MD10 ( x   ) 

Definition at line 219 of file circbuf.c.

Referenced by circbuf_all_lseek(), circbuf_all_mmap(), circbuf_all_open(), circbuf_all_poll(), circbuf_all_read(), circbuf_all_release(), circbuf_all_write(), circbuf_open(), circbuf_poll(), and circbufValidPointer().

#define MD11 ( x   ) 

Definition at line 221 of file circbuf.c.

Referenced by circbuf_lseek(), and circbufValidPointer().

#define MD12 ( x   ) 

Definition at line 196 of file circbuf.c.

Referenced by circbuf_lseek(), pgm_sensorphase(), x313_dma_start(), and x313_dma_stop().

#define MD2 ( x   ) 

Definition at line 202 of file circbuf.c.

Referenced by fpga_initSDRAM(), and fpga_resetSDRAM().

#define MD5 ( x   ) 

Definition at line 205 of file circbuf.c.

#define MD6 ( x   ) 

Definition at line 207 of file circbuf.c.

#define MD7 ( x   ) 

Definition at line 209 of file circbuf.c.

Referenced by circbuf_mmap(), and x313_dma_init().

#define MD8 ( x   ) 

Definition at line 215 of file circbuf.c.

Referenced by x313_setDMABuffer().

#define MD9 ( x   ) 

Definition at line 217 of file circbuf.c.

#define MDF ( x   ) 

*************************************************************************** ! FILE NAME : circbuf.c ! DESCRIPTION: drivers to manipulate large circular buffer thet holds compressed ! images/video. Buffer frame data is filled in by the FPGA, frame pointers and ! essential frames metadata filled during servicing of the interruptsl ! This code is based on the code from cxdma.c ! TODO: Add buffer reset, JPEG header generation here ! ! Copyright (C) 2002-2007 Elphel, Inc ! -----------------------------------------------------------------------------** ! ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! -----------------------------------------------------------------------------** !

Log
circbuf.c,v
! Revision 1.1.1.1 2008/11/27 20:04:00 elphel ! ! ! Revision 1.20 2008/11/20 07:06:24 elphel ! started more poll options ! ! Revision 1.19 2008/11/03 20:51:49 elphel ! minor bug fix ! ! Revision 1.18 2008/10/29 04:18:28 elphel ! v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue) ! ! Revision 1.17 2008/10/25 19:59:48 elphel ! added lseek() calls to enable/disable daemons at events (compressed frame available, any frame available, histogram-Y and histograms-C available) ! ! Revision 1.16 2008/10/23 08:01:30 elphel ! comments ! ! Revision 1.15 2008/10/19 06:50:03 elphel ! removed couple # if 0 ! ! Revision 1.14 2008/10/13 16:55:53 elphel ! removed (some) obsolete P_* parameters, renamed CIRCLSEEK to LSEEK_CIRC constants (same as other similar) ! ! Revision 1.13 2008/10/12 16:46:22 elphel ! snapshot ! ! Revision 1.12 2008/10/06 08:31:08 elphel ! snapshot, first images ! ! Revision 1.11 2008/09/22 22:55:47 elphel ! snapshot ! ! Revision 1.10 2008/09/20 00:29:49 elphel ! moved driver major/minor numbers to a single file - include/asm-cris/elphel/driver_numbers.h ! ! Revision 1.9 2008/09/12 20:40:11 elphel ! snapshot ! ! Revision 1.8 2008/09/12 00:23:58 elphel ! removed cc353.c, cc353.h ! ! Revision 1.7 2008/09/11 01:05:29 elphel ! snapshot ! ! Revision 1.6 2008/09/07 19:48:08 elphel ! snapshot ! ! Revision 1.5 2008/09/05 23:20:26 elphel ! just a snapshot ! ! Revision 1.4 2008/05/26 23:32:59 elphel ! Added driver to handle multi-frame parameters ! ! Revision 1.3 2008/05/24 05:31:02 elphel ! removed seek to current hardware write pointer after opening file, so now ftp-ing circbuf file works correctly ! ! Revision 1.2 2008/05/16 06:06:27 elphel ! adjusting drivers to the fpga code (03533020) ! ! Revision 1.10 2008/04/11 23:16:51 elphel ! removed unneeded local_irq_disable() after local_irq_save_flags() ! ! Revision 1.8 2007/12/03 08:28:46 elphel ! Multiple changes, mostly cleanup ! ! Revision 1.7 2007/11/16 08:56:19 elphel ! Added support for 2 additional commands to check circbuf usage ! ! Revision 1.6 2007/11/05 06:08:25 elphel ! fixed "first/second" bug introduced while fixing the previous one ! ! Revision 1.5 2007/11/05 01:40:51 elphel ! fixed wrong count of frames available, "second" frame ! ! Revision 1.4 2007/11/04 05:46:06 elphel ! removed debug, rearranged code to avoid a warning ! ! Revision 1.3 2007/11/01 18:59:37 elphel ! debugging mmap/caching problems ! ! Revision 1.2 2007/10/27 00:55:32 elphel ! untested revision - need to go ! ! Revision 1.1.1.1 2007/10/02 23:54:58 elphel ! This is a fresh tree based on elphel353-2.10 ! ! Revision 1.6 2007/10/02 23:54:58 elphel ! LSEEK_CIRC_LAST will now return just write pointer, not an error if there are no frames yet available. Moving to previous will still generate error. ! ! Revision 1.5 2007/10/02 22:29:38 elphel ! made that only 0,SEEK_END can move beyond circbuf, fro SEEK_CUR and SEET_SET it will roll over to 0 ! ! Revision 1.4 2007/10/02 19:35:15 elphel ! minor circbuf interface changes, bug fixes ! ! Revision 1.3 2007/09/30 07:07:08 elphel ! minor bug fix, disabled debug output ! ! Revision 1.2 2007/09/30 03:19:56 elphel ! Cleanup, fixed broken acquisition of individual JPEG images into circbuf (in mode 7) ! ! Revision 1.1 2007/09/29 18:33:29 elphel ! Split cxdma.c - /dev/circbuf is now in a separate circbuf.c file. New device driver does not support ioctl, so some curernt applications are updated to use other drivers to control the camera !

Definition at line 187 of file circbuf.c.

Referenced by init_qtable_head_cache(), initGlobalPars(), updateFramePars(), x353raw_fpn_lseek(), x353raw_fpn_open(), x353raw_fpn_read(), x353raw_fpn_release(), x353raw_frame_read(), x353raw_frame_release(), x353raw_frame_write(), and x353raw_frame_writeline().

#define MDF19 ( x   ) 

Definition at line 190 of file circbuf.c.

Referenced by circbuf_all_init().

#define MDF20 ( x   ) 

Definition at line 192 of file circbuf.c.


Function Documentation

static unsigned long ccam_dma_buf [CCAM_DMA_SIZE + (PAGE_SIZE>>2)] __attribute__ ( (aligned(PAGE_SIZE))   )  [static]

static int __init circbuf_all_init ( void   )  [static]

Definition at line 698 of file circbuf.c.

References CIRCBUF_DRIVER_NAME, CIRCBUF_MAJOR, init_waitqueue_head, jpeg_htable_init(), KERN_ERR, MDF19, and printk.

int circbuf_all_ioctl ( struct inode *  inode,
struct file *  filp,
unsigned int  cmd,
unsigned long  arg 
)

just to notify it is not implemented

Definition at line 379 of file circbuf.c.

References circbuf_pd::minor, and printk.

loff_t circbuf_all_lseek ( struct file *  file,
loff_t  offset,
int  orig 
)

Definition at line 322 of file circbuf.c.

References circbuf_lseek(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_HUFFMAN, CMOSCAM_MINOR_JPEAGHEAD, huffman_lseek(), jpeghead_lseek(), MD10, circbuf_pd::minor, and printk.

int circbuf_all_mmap ( struct file *  file,
struct vm_area_struct *  vma 
)

Definition at line 358 of file circbuf.c.

References circbuf_mmap(), CMOSCAM_MINOR_CIRCBUF, MD10, circbuf_pd::minor, and printk.

int circbuf_all_open ( struct inode *  inode,
struct file *  filp 
)

Definition at line 282 of file circbuf.c.

References circbuf_open(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_HUFFMAN, CMOSCAM_MINOR_JPEAGHEAD, huffman_open(), jpeghead_open(), MD10, and printk.

unsigned int circbuf_all_poll ( struct file *  file,
poll_table *  wait 
)

Definition at line 368 of file circbuf.c.

References circbuf_poll(), CMOSCAM_MINOR_CIRCBUF, MD10, circbuf_pd::minor, and printk.

ssize_t circbuf_all_read ( struct file *  file,
char *  buf,
size_t  count,
loff_t *  off 
)

Definition at line 334 of file circbuf.c.

References circbuf_read(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_HUFFMAN, CMOSCAM_MINOR_JPEAGHEAD, huffman_read(), jpeghead_read(), MD10, circbuf_pd::minor, and printk.

int circbuf_all_release ( struct inode *  inode,
struct file *  filp 
)

Definition at line 301 of file circbuf.c.

References CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_HUFFMAN, CMOSCAM_MINOR_JPEAGHEAD, kfree, MD10, and printk.

ssize_t circbuf_all_write ( struct file *  file,
const char *  buf,
size_t  count,
loff_t *  off 
)

Definition at line 345 of file circbuf.c.

References circbuf_write(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_HUFFMAN, huffman_write(), MD10, circbuf_pd::minor, and printk.

loff_t circbuf_lseek ( struct file *  file,
loff_t  offset,
int  orig 
)

Definition at line 475 of file circbuf.c.

References camSeqGetJPEG_rp(), camSeqGetJPEG_wp(), camSeqSetJPEG_rp(), ccam_dma_buf, CCAM_DMA_SIZE, circbufValidPointer(), fp, get_imageParamsThis, LSEEK_CIRC_FIRST, LSEEK_CIRC_FREE, LSEEK_CIRC_LAST, LSEEK_CIRC_NEXT, LSEEK_CIRC_PREV, LSEEK_CIRC_READY, LSEEK_CIRC_SCND, LSEEK_CIRC_SETP, LSEEK_CIRC_TORP, LSEEK_CIRC_TOWP, LSEEK_CIRC_USED, LSEEK_CIRC_VALID, LSEEK_CIRC_WAIT, LSEEK_DAEMON_CIRCBUF, MD11, MD12, P_DAEMON_EN, printk, rp, SEEK_CUR, SEEK_END, SEEK_SET, X313_BUFFADD, X313_BUFFSUB, X313_LENGTH_MASK, and X313_PADDED_FRAME.

Referenced by circbuf_all_lseek().

int circbuf_mmap ( struct file *  file,
struct vm_area_struct *  vma 
)

Definition at line 647 of file circbuf.c.

References ccam_dma_buf, MD7, and printk.

Referenced by circbuf_all_mmap().

int circbuf_open ( struct inode *  inode,
struct file *  filp 
)

Definition at line 389 of file circbuf.c.

References CCAM_DMA_SIZE, GFP_KERNEL, kmalloc, MD10, circbuf_pd::minor, and printk.

Referenced by circbuf_all_open().

unsigned int circbuf_poll ( struct file *  file,
poll_table *  wait 
)

=========================================================================== ! If the current read pointer is invalid, circbuf_poll returns POLLHUP ! as no data will be ever available until file poinetr is reset. ! if it is valid, wait is setup and the blocking condition occurs ! ifthe current file pointer is equal to the FPGA write pointer !===========================================================================

result of testing read poinetr

not a valid read pointer, probable buffer overrun

there was frame already available

pointer valid, no frame yet

Frame might become available during call to poll_wait so nobody will wake us up. Let's see if there is stillno frame

we are lucky - got it

Definition at line 676 of file circbuf.c.

References camSeqGetJPEG_wp(), circbufValidPointer(), fp, MD10, and printk.

Referenced by circbuf_all_poll().

ssize_t circbuf_read ( struct file *  file,
char *  buf,
size_t  count,
loff_t *  off 
)

Definition at line 631 of file circbuf.c.

References ccam_dma_buf, CCAM_DMA_SIZE, D, and printk.

Referenced by circbuf_all_read().

ssize_t circbuf_write ( struct file *  file,
const char *  buf,
size_t  count,
loff_t *  off 
)

Definition at line 612 of file circbuf.c.

References ccam_dma_buf, CCAM_DMA_SIZE, D, and printk.

Referenced by circbuf_all_write().

int circbufValidPointer ( int  rp,
struct interframe_params_t **  fpp 
)

returns 0 if rp is a valid read ponter returns 1 if there is a frame at this address returns 0 if the pointer is for the frame yet to be acquired returns -1 if there is no frame at this index returns -2 if the rp is not 32-bytes aligned sets *fpp to the frame header, including signature and length

rp is not 32-bytes aligned

32 bytes before the frame pointer, may roll-over to the end of ccam_dma_buf

signature is overwritten

should not get here - should be caught by (p==wp)

Definition at line 449 of file circbuf.c.

References camSeqGetJPEG_wp(), ccam_dma_buf, fp, MD10, MD11, printk, wp, X313_BUFFSUB, and X313_LENGTH_MASK.

Referenced by circbuf_lseek(), and circbuf_poll().

void init_ccam_dma_buf_ptr ( void   ) 

still used in autoexposure or something - why is in needed there?

Definition at line 243 of file circbuf.c.

References ccam_dma_buf.

Referenced by image_acq_init().

MODULE_AUTHOR ( "Andrey Filippov <andrey@elphel.com>."   ) 

MODULE_DESCRIPTION ( CIRCBUF_DRIVER_NAME   ) 

module_init ( circbuf_all_init   ) 

MODULE_LICENSE ( "GPLv3.0"   ) 


Variable Documentation

unsigned long* ccam_dma = NULL

Definition at line 241 of file circbuf.c.

Referenced by get_image_time().

unsigned long* ccam_dma_buf_ptr = NULL

CIRCBUF macros.

Definition at line 240 of file circbuf.c.

Referenced by jpeghead_lseek(), updateIRQ_Exif(), updateIRQ_interframe(), x313_dma_init(), x313_dma_start(), and x313_setDMABuffer().

struct file_operations circbuf_fops [static]

Initial value:

Definition at line 257 of file circbuf.c.

wait_queue_head_t circbuf_wait_queue

====================================================================================== ! Wait queue for the processes waiting for a new frame to appear in the circular buffer !======================================================================================

Definition at line 251 of file circbuf.c.

Referenced by elphel_FPGA_interrupt().

struct interframe_params_t frame_params


Generated on Fri Nov 28 00:07:38 2008 for elphel by  doxygen 1.5.1