os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/cxdma.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/arch/cache.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 cxdma.c:

Go to the source code of this file.

Defines

#define MD1(x)
 ETRAX FS Cache bug workaround.
#define MD12(x)
#define MD13(x)
#define D(x)
#define D1(x)
#define MD2(x)   printk("%s:%d:",__FILE__,__LINE__);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)
 where jpeg_rp is modified?
#define EXT_DMA_0_START   *R_EXT_DMA_0_CMD = (extdma0_cmd_shadow |= IO_STATE( R_EXT_DMA_0_CMD, run, start ) )
#define EXT_DMA_0_STOP   *R_EXT_DMA_0_CMD = (extdma0_cmd_shadow &= ~IO_MASK( R_EXT_DMA_0_CMD, run ) )
#define TRAILER_SIZE   0x02
#define HEADER_YQTABLE   0x19
#define HEADER_CQTABLE   0x5e
#define HEADER_HEIGHT   0xa3
#define HEADER_WIDTH   0xa5
#define DMA_CHUNK   0x4000
#define CCAM_DESCR_DATA_NUM   (( CCAM_DMA_SIZE / DMA_CHUNK) +1 )
#define DCTSIZE2   64

Functions

void x313_dma_reset_jpeg (void)
int x313_dma_forget_jpeg (void)
int x313_dma_catchup_jpeg (void)
void update_JPEG_quality (int quality)
int x313_setDMABuffer (void)
unsigned long x313_DMA_size (void)
void x313_dma_update_jpeg_header (void)
void x313_JPEG_dump (void)
int X313_dma_update (int latest)
void x313_dma_reset_chain (void)
int x313_dma_save_jpeg (void)
 mooved to circbuf.h
int x313_dma_restore_jpeg (void)
int x313_JPEG_ctrl (int cmd)
int x313_get_JPEG_ctrl (void)
void prof_msg (const char *msg)
int x313_JPEG_cmd (int cmd)
int x313_dma_stop (void)
void x313_dma_start (void)
unsigned long x313_dma_init (void)
int cmoscam_open_dma (struct inode *inode, struct file *filp)
loff_t x313_dma_lseek (struct file *file, loff_t offset, int orig)
unsigned long cpu_to_le (unsigned long in)
void get_image_exp (unsigned long *e)
static unsigned char ext_mjpeg_header[PAGE_SIZE] __attribute__ ((aligned(PAGE_SIZE)))
unsigned long ext_make_jpeg_header (void)
void ext_fill_jpeg_mmap_desc (struct ext_jpeg_mmap_desc_t *mdesc)
void ext_fill_jpeg_mmap_desc_ (struct _ext_jpeg_mmap_desc_t *mdesc)
ssize_t x313_dma_read (struct file *file, char *buf, size_t count, loff_t *off)
ssize_t x313_dma_write (struct file *file, const char *buf, size_t count, loff_t *off)
void setJPEGHeader (int quality, int width, int height)
void jpeg_set_quality (int quality, int target, void *table)

Variables

frame_params_t frame_params
static etrax_dma_descr ccam_dma_descr_data [CCAM_DESCR_DATA_NUM]
static unsigned long extdma0_cmd_shadow = 0
static unsigned char jpeg_header_sbuffer [JPEG_HEADER_SIZE]
unsigned char * jpeg_header_sbuffer_ptr = NULL
static unsigned char trailer [TRAILER_SIZE] = {0xff,0xd9}
static unsigned long DMABufferLength
unsigned long ccam_dma_length = CCAM_DMA_SIZE << 2
static int use_header = 1
static int JPEG_ctrl = 0x2ff
int jpeg_quality = -1
int FPGA_quality = -1
 FPGA is last programmed with this compression quality.
int JPEG_header_quality = -1
 These parameters correspond to current JPEG header in memory.
int soft_rp
static int save_rp = -1
static int save_wp = -1
unsigned long t_sign = 0


Define Documentation

#define CCAM_DESCR_DATA_NUM   (( CCAM_DMA_SIZE / DMA_CHUNK) +1 )

Definition at line 268 of file cxdma.c.

Referenced by x313_JPEG_dump().

#define D ( x   ) 

Definition at line 167 of file cxdma.c.

#define D0 ( x   ) 

Definition at line 182 of file cxdma.c.

#define D1 ( x   ) 

Definition at line 168 of file cxdma.c.

#define DCTSIZE2   64

Definition at line 1239 of file cxdma.c.

Referenced by jpeg_set_quality().

#define DMA_CHUNK   0x4000

Definition at line 266 of file cxdma.c.

Referenced by x313_dma_start(), and x313_setDMABuffer().

#define EXT_DMA_0_START   *R_EXT_DMA_0_CMD = (extdma0_cmd_shadow |= IO_STATE( R_EXT_DMA_0_CMD, run, start ) )

Definition at line 206 of file cxdma.c.

Referenced by x313_dma_start().

#define EXT_DMA_0_STOP   *R_EXT_DMA_0_CMD = (extdma0_cmd_shadow &= ~IO_MASK( R_EXT_DMA_0_CMD, run ) )

Definition at line 208 of file cxdma.c.

Referenced by x313_dma_stop(), and x313_setDMABuffer().

#define HEADER_CQTABLE   0x5e

Definition at line 240 of file cxdma.c.

Referenced by jpeg_set_quality().

#define HEADER_HEIGHT   0xa3

Definition at line 242 of file cxdma.c.

Referenced by setJPEGHeader(), and x313_dma_update_jpeg_header().

#define HEADER_WIDTH   0xa5

Definition at line 243 of file cxdma.c.

Referenced by setJPEGHeader(), and x313_dma_update_jpeg_header().

#define HEADER_YQTABLE   0x19

Definition at line 239 of file cxdma.c.

Referenced by jpeg_set_quality().

#define MD1 ( x   ) 

ETRAX FS Cache bug workaround.

*************************************************************************** ! FILE NAME : cxdma353.c ! DESCRIPTION: TBD ! 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
cxdma353.c,v
! Revision 1.8 2008/04/20 06:49:40 elphel ! cleanup, bug fixes ! ! Revision 1.7 2008/04/16 20:33:23 elphel ! driver cleanup, removed some duplicate actions, working on better recovery after parameter modification ! ! Revision 1.6 2008/02/08 16:36:03 spectr_rain ! access to quantization tables from the streamer ! ! Revision 1.5 2007/12/09 05:59:13 elphel ! added cache_flush fix ! ! Revision 1.4 2007/12/03 08:28:46 elphel ! Multiple changes, mostly cleanup ! ! Revision 1.3 2007/11/04 05:39:11 elphel ! removed declaration of unused variable ! ! Revision 1.2 2007/10/11 06:40:33 elphel ! Added second RESET command with non-zero value to be compatible with lseek (,,SEEK_END) ! ! Revision 1.1.1.1 2007/10/02 19:36:10 elphel ! This is a fresh tree based on elphel353-2.10 ! ! Revision 1.17 2007/10/02 19:36:10 elphel ! removed unneeded debug output ! ! Revision 1.16 2007/09/30 07:07:27 elphel ! only disabled debug output ! ! Revision 1.15 2007/09/30 03:19:56 elphel ! Cleanup, fixed broken acquisition of individual JPEG images into circbuf (in mode 7) ! ! Revision 1.14 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 ! ! Revision 1.13 2007/09/23 06:45:10 elphel ! Restored ccam_dma.raw character device file - it was broken when EXIF headers were added, so I just returned it to the previous state (no Exif, but works) ! ! Revision 1.12 2007/09/05 10:32:40 spectr_rain ! reformatting and debug messages ! ! Revision 1.11 2007/08/31 21:47:01 spectr_rain ! *** empty log message *** ! ! Revision 1.10 2007/08/28 21:25:28 spectr_rain ! mmap for JPEG files ! ! Revision 1.9 2007/08/17 10:23:18 spectr_rain ! switch to GPL3 license ! ! Revision 1.8 2007/08/01 18:56:33 spectr_rain ! *** empty log message *** ! ! Revision 1.7 2007/08/01 15:12:45 spectr_rain ! *** empty log message *** ! ! Revision 1.6 2007/07/20 10:17:44 spectr_rain ! *** empty log message *** ! ! Revision 1.2 2007/03/29 23:38:15 spectr_rain ! fix mmap ! ! Revision 1.1.1.1 2007/02/23 10:11:48 elphel ! initial import into CVS ! ! Revision 1.5 2007/01/08 17:22:39 spectr_rain ! *** empty log message *** ! ! Revision 1.4 2006/12/28 15:12:15 spectr_rain ! *** empty log message *** ! ! Revision 1.3 2006/08/29 18:06:58 spectr_rain ! 6.5.2 ! ! Revision 1.1.1.1 2006/07/11 19:15:00 spectr_rain ! unwork with less than 5MPx Micron sensor, initial branch ! ! Revision 1.4 2006/04/16 00:18:09 elphel ! added timestamps to frame data in circbuf (streamers are not yet updated) ! ! Revision 1.3 2006/02/22 09:06:46 elphel ! Made ccam.cgi return last image from the buffer when streamer is running. Same as acquiring image, with "-" in the options, i.e. "admin-bin/ccam.cgi?opt=vhcxy-" (all parameters will be ignored) ! ! Revision 1.2 2005/05/10 21:08:49 elphel ! *** empty log message *** !

Definition at line 160 of file cxdma.c.

#define MD10 ( x   ) 

Definition at line 189 of file cxdma.c.

#define MD11 ( x   ) 

where jpeg_rp is modified?

Definition at line 192 of file cxdma.c.

#define MD12 ( x   ) 

Definition at line 161 of file cxdma.c.

#define MD13 ( x   ) 

Definition at line 162 of file cxdma.c.

#define MD2 ( x   )     printk("%s:%d:",__FILE__,__LINE__);x

Definition at line 171 of file cxdma.c.

#define MD5 ( x   ) 

Definition at line 175 of file cxdma.c.

#define MD6 ( x   ) 

Definition at line 177 of file cxdma.c.

#define MD7 ( x   ) 

Definition at line 179 of file cxdma.c.

#define MD8 ( x   ) 

Definition at line 185 of file cxdma.c.

#define MD9 ( x   ) 

Definition at line 187 of file cxdma.c.

#define TRAILER_SIZE   0x02

Definition at line 238 of file cxdma.c.


Function Documentation

static unsigned char ext_mjpeg_header [PAGE_SIZE] __attribute__ ( (aligned(PAGE_SIZE))   )  [static]

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

Definition at line 816 of file cxdma.c.

Referenced by cmoscam_open().

unsigned long cpu_to_le ( unsigned long  in  ) 

Definition at line 877 of file cxdma.c.

Referenced by ext_make_jpeg_header().

void ext_fill_jpeg_mmap_desc ( struct ext_jpeg_mmap_desc_t mdesc  ) 

Definition at line 909 of file cxdma.c.

Referenced by ext353__ioctl().

void ext_fill_jpeg_mmap_desc_ ( struct _ext_jpeg_mmap_desc_t mdesc  ) 

Definition at line 924 of file cxdma.c.

Referenced by ext353__mmap().

unsigned long ext_make_jpeg_header ( void   ) 

Definition at line 933 of file cxdma.c.

References exif_desc_t::artist, cpu_to_le(), exif_desc_t::date_time, exif_desc_t::date_time_or, exif, EXIF_ARTIST, EXIF_ARTIST_LEN, EXIF_DATE_TIME, EXIF_DATE_TIME_LEN, EXIF_DATE_TIME_OR, EXIF_DATE_TIME_OR_LEN, exif_desc, EXIF_EXP, EXIF_EXP_LEN, EXIF_FIRMWARE, EXIF_FIRMWARE_LEN, exif_header, exif_header_length(), EXIF_OFFSET, EXIF_SUBSEC_OR, EXIF_SUBSEC_OR_LEN, exif_desc_t::exp, exif_desc_t::firmware, get_image_exp(), JPEG_HEADER_SIZE, memcpy(), and exif_desc_t::subsec.

Referenced by ext_fill_jpeg_mmap_desc().

void get_image_exp ( unsigned long *  e  ) 

Definition at line 885 of file cxdma.c.

References get_imageParamsR(), and P_EXPOS.

Referenced by ext_make_jpeg_header().

void jpeg_set_quality ( int  quality,
int  target,
void *  table 
)

==================================================== ! JPEG HEADER is recalculated together with the FPGA tables ! and due to limitations of the FPGA implementation (no divide) ! header table may slightly deviate from canonical one. ! JPEG quality is stored in the circular buffer, but not JPEG ! header table, so when Q changes, JPEG frame header may be ! out of sync. Possible solutions: ! 1 - always flush circular buffer whan Q is changed or ! 2 - rebuild JPEG header (if different) simulating FPGA ! writes. !====================================================

TODO: Temporary disabling IRQs here - later move FPGA table setup to IRQ-safe function

NOTE

NOTE

NOTE

Definition at line 1263 of file cxdma.c.

Referenced by dma2jpeg(), setJPEGHeader(), stream__ioctl(), and update_JPEG_quality().

void prof_msg ( const char *  msg  ) 

Definition at line 345 of file cxdma.c.

References printk.

Referenced by x313_JPEG_cmd().

void setJPEGHeader ( int  quality,
int  width,
int  height 
)

this function to be called when JPEG header is needed to be sent to user. FPGA is not modified here

Definition at line 1209 of file cxdma.c.

Referenced by jpeghead_lseek().

void update_JPEG_quality ( int  quality  ) 

Definition at line 1240 of file cxdma.c.

References frame_params, get_imageParamsR(), jpeg_set_quality(), P_QUALITY, QTABLES_EXIF, QTABLES_FPGA, frame_params_t::quality, and set_imageParamsR().

Referenced by x313_dma_update_jpeg_header().

int x313_dma_catchup_jpeg ( void   ) 

Definition at line 498 of file cxdma.c.

References X313_dma_update().

Referenced by x313_JPEG_cmd().

int x313_dma_forget_jpeg ( void   ) 

Definition at line 481 of file cxdma.c.

References camSeqSetJPEG_rp(), ccam_dma_buf_ptr, CCAM_DMA_SIZE, rp, X313_BUFFADD, X313_CHAIN_SIGNATURE, X313_CHAIN_SIGNATURE4, X313_dma_update(), and X313_PADDED_FRAME.

Referenced by x313_JPEG_cmd().

unsigned long x313_dma_init ( void   ) 

Definition at line 656 of file cxdma.c.

Referenced by cmoscam_init().

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

Definition at line 833 of file cxdma.c.

Referenced by cmoscam_lseek().

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

Definition at line 1087 of file cxdma.c.

Referenced by cmoscam_read().

void x313_dma_reset_chain ( void   ) 

============================================= ! Puts 0xffff, 0xffffffff "before" first frame !=============================================

Definition at line 462 of file cxdma.c.

References ccam_dma_buf_ptr, CCAM_DMA_SIZE, X313_CHAIN_SIGNATURE, and X313_CHAIN_SIGNATURE4.

Referenced by camSeqStartClip(), and x313_dma_reset_jpeg().

void x313_dma_reset_jpeg ( void   ) 

============================================= ! cc3x3.c - resets different things !=============================================

Definition at line 475 of file cxdma.c.

References camSeqStop(), and x313_dma_reset_chain().

Referenced by x313_dma_init(), and x313_JPEG_cmd().

int x313_dma_restore_jpeg ( void   ) 

Definition at line 451 of file cxdma.c.

References camSeqGetJPEG_wp(), camSeqSetJPEG_rp(), and X313_BUFFSUB.

Referenced by x313_JPEG_cmd().

int x313_dma_save_jpeg ( void   ) 

mooved to circbuf.h

============================================== ! It makes sense to get rid of the global read ! pointer and store it individually in file private ! area !=============================================

Definition at line 445 of file cxdma.c.

References camSeqGetJPEG_rp(), and camSeqGetJPEG_wp().

Referenced by x313_JPEG_cmd().

unsigned long x313_DMA_size ( void   ) 

Definition at line 592 of file cxdma.c.

References camSeqGetJPEG_rp(), camSeqGetJPEG_wp(), ccam_dma_buf_ptr, X313_CHAIN_SIGNATURE, X313_CHAIN_SIGNATURE4, and X313_dma_update().

Referenced by cmoscam_open_dma(), ext_fill_jpeg_mmap_desc(), x313_dma_lseek(), and x313_dma_read().

void x313_dma_start ( void   ) 

Definition at line 617 of file cxdma.c.

Referenced by camSeqStartClip(), and ccam_DMA_ioctl().

int x313_dma_stop ( void   ) 

Definition at line 607 of file cxdma.c.

Referenced by camSeqStop(), and ccam_DMA_ioctl().

int X313_dma_update ( int  latest  ) 

NOTE: Modifies global RP - may interfere with other applications Is it still needed (but ccam.cgi?)

read pointer not initialized - first call

it is initialized

in sync

no data available (will never happen with rp==-1)

Look for an oldest frame, starting from the current write pointer backwards

set rp equal to wp

length of the previous frame

first pass, points to write pointer, no IRQ-provided data yet

could be length (but not 100% positive)

No frames available yet, RP already set

that definitely means that current frame was completely acquired

asked for a latest aquired frame in chain - got it !

traversed chain to the original rp (this will never happen now - would exit at once)

could be length (but not 100% positive) -looking at the previous frame

Current frame did not survive, was overwritten

Definition at line 522 of file cxdma.c.

References camSeqGetJPEG_rp(), camSeqGetJPEG_wp(), camSeqSetJPEG_rp(), ccam_dma_buf_ptr, MD1, MD2, printk, rp, X313_BUFFSUB, X313_CHAIN_SIGNATURE, X313_CHAIN_SIGNATURE4, X313_LENGTH_MASK, and X313_PADDED_FRAME.

Referenced by x313_dma_catchup_jpeg(), x313_dma_forget_jpeg(), x313_DMA_size(), and x313_JPEG_cmd().

void x313_dma_update_jpeg_header ( void   ) 

Definition at line 1219 of file cxdma.c.

References get_imageParamsR(), get_imageParamsW(), HEADER_HEIGHT, HEADER_WIDTH, MD13, MD6, MD8, P_QUALITY, port_csp0_addr, printk, update_JPEG_quality(), x, X313_WA_SDCH2_CTL1, and X313_WA_SDCH2_CTL2.

Referenced by ccam_DMA_ioctl(), and x313_JPEG_cmd().

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

Definition at line 1181 of file cxdma.c.

Referenced by cmoscam_write().

int x313_get_JPEG_ctrl ( void   ) 

Definition at line 341 of file cxdma.c.

Referenced by compressorRun(), compressorSingle(), programSensor(), and x313_program_focus().

int x313_JPEG_cmd ( int  cmd  ) 

Definition at line 351 of file cxdma.c.

Referenced by ccam_DMA_ioctl(), and x313_JPEG_cmd_wrapper().

int x313_JPEG_ctrl ( int  cmd  ) 

Definition at line 335 of file cxdma.c.

Referenced by ccam_DMA_ioctl(), programSensor(), and x313_program_focus().

void x313_JPEG_dump ( void   ) 

Definition at line 770 of file cxdma.c.

References buf, CCAM_DESCR_DATA_NUM, ccam_dma_buf_ptr, eol, port_csp0_addr, printk, and X313__RA__STATUS.

Referenced by x313_JPEG_cmd().

int x313_setDMABuffer ( void   ) 

Definition at line 736 of file cxdma.c.

References buf, ccam_dma_buf_ptr, CCAM_DMA_SIZE, DMA_CHUNK, EXT_DMA_0_STOP, MD8, P_CIRCBUFSIZE, printk, and set_imageParamsR().

Referenced by x313_dma_init(), and x313_JPEG_cmd().


Variable Documentation

etrax_dma_descr ccam_dma_descr_data[CCAM_DESCR_DATA_NUM] [static]

Definition at line 269 of file cxdma.c.

unsigned long ccam_dma_length = CCAM_DMA_SIZE << 2

Definition at line 279 of file cxdma.c.

unsigned long DMABufferLength [static]

Definition at line 276 of file cxdma.c.

unsigned long extdma0_cmd_shadow = 0 [static]

Definition at line 270 of file cxdma.c.

int FPGA_quality = -1

FPGA is last programmed with this compression quality.

Definition at line 289 of file cxdma.c.

struct frame_params_t frame_params

// moved to circbuf.c, so now ccam_dma_buf_ptr will be available (external) instead static unsigned long ccam_dma_buf[CCAM_DMA_SIZE + PAGE_SIZE] __attribute__ ((aligned (PAGE_SIZE))); unsigned long *ccam_dma_buf_ptr = NULL; void init_ccam_dma_buf_ptr(void) { ccam_dma_buf_ptr = ccam_dma_buf; }

Definition at line 716 of file cc353.c.

int JPEG_ctrl = 0x2ff [static]

Definition at line 284 of file cxdma.c.

int JPEG_header_quality = -1

These parameters correspond to current JPEG header in memory.

Definition at line 291 of file cxdma.c.

unsigned char jpeg_header_sbuffer[JPEG_HEADER_SIZE] [static]

Definition at line 273 of file cxdma.c.

unsigned char* jpeg_header_sbuffer_ptr = NULL

Definition at line 274 of file cxdma.c.

Referenced by jpeghead_read(), and jpeghead_write().

int jpeg_quality = -1

Definition at line 286 of file cxdma.c.

int save_rp = -1 [static]

Definition at line 297 of file cxdma.c.

int save_wp = -1 [static]

Definition at line 298 of file cxdma.c.

int soft_rp

Definition at line 296 of file cxdma.c.

unsigned long t_sign = 0

Definition at line 589 of file cxdma.c.

Referenced by get_image_time().

unsigned char trailer[TRAILER_SIZE] = {0xff,0xd9} [static]

Definition at line 275 of file cxdma.c.

int use_header = 1 [static]

Definition at line 283 of file cxdma.c.


Generated on Thu Aug 7 16:20:11 2008 for elphel by  doxygen 1.5.1