#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 |
========================================================================================================= ! 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 MD1 | ( | x | ) |
#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 | ) |
#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 | ) |
#define MD7 | ( | x | ) |
#define MD8 | ( | x | ) |
#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/>. ! -----------------------------------------------------------------------------** !
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 | ) |
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" | ) |
unsigned long* ccam_dma = NULL |
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:
{ owner: THIS_MODULE, llseek: circbuf_all_lseek, read: circbuf_all_read, write: circbuf_all_write, ioctl: circbuf_all_ioctl, open: circbuf_all_open, mmap: circbuf_all_mmap, poll: circbuf_all_poll, release: circbuf_all_release }
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 |