#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/c313a.h>
#include "fpgactrl.h"
#include "x3x3.h"
#include "cc3x3.h"
#include "cxdma.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 | 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_SIZE 0x26f |
#define | CIRCBUF_MAJOR 135 |
#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 frame_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) |
int | jpeghead_open (struct inode *inode, struct file *filp) |
loff_t | jpeghead_lseek (struct file *file, loff_t offset, int orig) |
ssize_t | jpeghead_read (struct file *file, char *buf, size_t count, loff_t *off) |
ssize_t | jpeghead_write (struct file *file, const char *buf, size_t count, loff_t *off) |
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 |
Without "static" system hangs after "Uncompressing Linux... | |
unsigned long * | ccam_dma = NULL |
frame_params_t | frame_params |
wait_queue_head_t | circbuf_wait_queue |
static struct file_operations | circbuf_fops |
#define CIRCBUF_MAJOR 135 |
========================================================================================================= ! circbuf top level device drivers. Minors are the same as before ! CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_JPEAGHEAD - just a new major ! ! ! ! ! ! !========================================================================================================
Definition at line 178 of file circbuf.c.
Referenced by circbuf_all_init().
#define MD12 | ( | 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 ! ! 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/>. ! -----------------------------------------------------------------------------** !
#define MD5 | ( | 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 735 of file circbuf.c.
References CIRCBUF_DRIVER_NAME, CIRCBUF_MAJOR, init_waitqueue_head, KERN_ERR, 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 295 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 241 of file circbuf.c.
References circbuf_lseek(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_JPEAGHEAD, jpeghead_lseek(), MD10, circbuf_pd::minor, and printk.
int circbuf_all_mmap | ( | struct file * | file, | |
struct vm_area_struct * | vma | |||
) |
Definition at line 274 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 202 of file circbuf.c.
References circbuf_open(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_JPEAGHEAD, GFP_KERNEL, jpeghead_open(), kfree, kmalloc, MD10, circbuf_pd::minor, and printk.
unsigned int circbuf_all_poll | ( | struct file * | file, | |
poll_table * | wait | |||
) |
Definition at line 284 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 252 of file circbuf.c.
References circbuf_read(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_JPEAGHEAD, jpeghead_read(), MD10, circbuf_pd::minor, and printk.
int circbuf_all_release | ( | struct inode * | inode, | |
struct file * | filp | |||
) |
Definition at line 223 of file circbuf.c.
References CMOSCAM_MINOR_CIRCBUF, 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 262 of file circbuf.c.
References circbuf_write(), CMOSCAM_MINOR_CIRCBUF, CMOSCAM_MINOR_JPEAGHEAD, jpeghead_write(), MD10, circbuf_pd::minor, and printk.
loff_t circbuf_lseek | ( | struct file * | file, | |
loff_t | offset, | |||
int | orig | |||
) |
Definition at line 386 of file circbuf.c.
References camSeqGetJPEG_rp(), camSeqGetJPEG_wp(), camSeqSetJPEG_rp(), ccam_dma_buf, CCAM_DMA_SIZE, circbufValidPointer(), CIRCLSEEK_FIRST, CIRCLSEEK_FREE, CIRCLSEEK_LAST, CIRCLSEEK_NEXT, CIRCLSEEK_PREV, CIRCLSEEK_READY, CIRCLSEEK_SCND, CIRCLSEEK_SETP, CIRCLSEEK_TORP, CIRCLSEEK_TOWP, CIRCLSEEK_USED, CIRCLSEEK_VALID, CIRCLSEEK_WAIT, MD11, MD12, printk, rp, frame_params_t::timestamp_sec, X313_BUFFADD, X313_BUFFSUB, X313_LENGTH_MASK, and X313_PADDED_FRAME.
Referenced by circbuf_all_lseek(), and circbuf_open().
int circbuf_mmap | ( | struct file * | file, | |
struct vm_area_struct * | vma | |||
) |
Definition at line 573 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 305 of file circbuf.c.
References CCAM_DMA_SIZE, circbuf_lseek(), CIRCLSEEK_LAST, MD10, 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 602 of file circbuf.c.
References camSeqGetJPEG_wp(), circbufValidPointer(), 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 556 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 536 of file circbuf.c.
References ccam_dma_buf, CCAM_DMA_SIZE, D, and printk.
Referenced by circbuf_all_write().
int circbufValidPointer | ( | int | rp, | |
struct frame_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 360 of file circbuf.c.
References camSeqGetJPEG_wp(), ccam_dma_buf, dumpFrameParams(), 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 159 of file circbuf.c.
References ccam_dma_buf.
Referenced by cmoscam_init().
loff_t jpeghead_lseek | ( | struct file * | file, | |
loff_t | offset, | |||
int | orig | |||
) |
================================================================= ! Overloading lseek with additional functionality (to avoid ioctls) ! with orig==SEEK_END lseek will treat (offset>0) as a byte pointer ! in (char *)ccam_dma_buf of a frame pointer and use quality, ! width and height to regenerate header. ! frame pointers are 32-bytes aligned, so adding 1 to offest ! will make sure it is always >0 (as offset=0, orig=SEEK_END ! will just move pointer to the end and return file length. ! ! When called with orig==SEEK_END, offset>0 lseek will position ! file at the very beginning and return 0 if OK, -EINVAL if ! frame header is not found for the specified offset !================================================================
New functionality
32 bytes before the frame pointer, may roll-over to the end of ccam_dma_buf
signature is overwritten
acquisition of this frame is not done yet - length word high byte is non-zero
it is 0
Definition at line 650 of file circbuf.c.
References ccam_dma_buf, frame_params_t::height, JPEG_HEADER_SIZE, frame_params_t::quality, rp, setJPEGHeader(), frame_params_t::signffff, frame_params_t::timestamp_sec, frame_params_t::width, X313_BUFFSUB, and X313_LENGTH_MASK.
Referenced by circbuf_all_lseek().
int jpeghead_open | ( | struct inode * | inode, | |
struct file * | filp | |||
) |
make it blocking to use shared resource - jpeg header that may need re-calculation for different requests? or use individual header arrays?
Definition at line 629 of file circbuf.c.
References JPEG_HEADER_SIZE.
Referenced by circbuf_all_open().
ssize_t jpeghead_read | ( | struct file * | file, | |
char * | buf, | |||
size_t | count, | |||
loff_t * | off | |||
) |
Definition at line 697 of file circbuf.c.
References D, jpeg_header_sbuffer_ptr, JPEG_HEADER_SIZE, and printk.
Referenced by circbuf_all_read().
ssize_t jpeghead_write | ( | struct file * | file, | |
const char * | buf, | |||
size_t | count, | |||
loff_t * | off | |||
) |
Definition at line 717 of file circbuf.c.
References D, jpeg_header_sbuffer_ptr, JPEG_HEADER_SIZE, and printk.
Referenced by circbuf_all_write().
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 |
Without "static" system hangs after "Uncompressing Linux...
Definition at line 157 of file circbuf.c.
Referenced by add_frame_params(), ext_fill_jpeg_mmap_desc_(), flush_par_cache(), x313_dma_forget_jpeg(), x313_dma_init(), x313_dma_reset_chain(), x313_DMA_size(), x313_dma_start(), X313_dma_update(), x313_JPEG_dump(), 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 167 of file circbuf.c.
Referenced by add_frame_params().
struct frame_params_t frame_params |