#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 cxdma353.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 CCAM_DESCR_DATA_NUM (( CCAM_DMA_SIZE / DMA_CHUNK) +1 ) |
Definition at line 268 of file cxdma353.c.
#define D | ( | x | ) |
Definition at line 167 of file cxdma353.c.
#define D0 | ( | x | ) |
Definition at line 182 of file cxdma353.c.
#define D1 | ( | x | ) |
Definition at line 168 of file cxdma353.c.
#define DCTSIZE2 64 |
Definition at line 1239 of file cxdma353.c.
#define DMA_CHUNK 0x4000 |
Definition at line 266 of file cxdma353.c.
#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 cxdma353.c.
#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 cxdma353.c.
#define HEADER_CQTABLE 0x5e |
Definition at line 240 of file cxdma353.c.
#define HEADER_HEIGHT 0xa3 |
Definition at line 242 of file cxdma353.c.
#define HEADER_WIDTH 0xa5 |
Definition at line 243 of file cxdma353.c.
#define HEADER_YQTABLE 0x19 |
Definition at line 239 of file cxdma353.c.
#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/>. ! -----------------------------------------------------------------------------** !
Definition at line 160 of file cxdma353.c.
#define MD10 | ( | x | ) |
Definition at line 189 of file cxdma353.c.
#define MD11 | ( | x | ) |
#define MD12 | ( | x | ) |
Definition at line 161 of file cxdma353.c.
#define MD13 | ( | x | ) |
Definition at line 162 of file cxdma353.c.
Definition at line 171 of file cxdma353.c.
#define MD5 | ( | x | ) |
Definition at line 175 of file cxdma353.c.
#define MD6 | ( | x | ) |
Definition at line 177 of file cxdma353.c.
#define MD7 | ( | x | ) |
Definition at line 179 of file cxdma353.c.
#define MD8 | ( | x | ) |
Definition at line 185 of file cxdma353.c.
#define MD9 | ( | x | ) |
Definition at line 187 of file cxdma353.c.
#define TRAILER_SIZE 0x02 |
Definition at line 238 of file cxdma353.c.
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 cxdma353.c.
References exif_header_length(), EXIF_OFFSET, JPEG_HEADER_SIZE, TRAILER_SIZE, and x313_DMA_size().
unsigned long cpu_to_le | ( | unsigned long | in | ) |
Definition at line 877 of file cxdma353.c.
void ext_fill_jpeg_mmap_desc | ( | struct ext_jpeg_mmap_desc_t * | mdesc | ) |
Definition at line 909 of file cxdma353.c.
References CCAM_DMA_SIZE, ext_jpeg_mmap_desc_t::exif_length, ext_make_jpeg_header(), ext_jpeg_mmap_desc_t::jpeg_addr, ext_jpeg_mmap_desc_t::jpeg_length, ext_jpeg_mmap_desc_t::mmap_exif_length, ext_jpeg_mmap_desc_t::mmap_jpeg_length, ext_jpeg_mmap_desc_t::mmap_start, X313_BUFFADD, and x313_DMA_size().
void ext_fill_jpeg_mmap_desc_ | ( | struct _ext_jpeg_mmap_desc_t * | mdesc | ) |
Definition at line 924 of file cxdma353.c.
References ccam_dma_buf_ptr, CCAM_DMA_SIZE, _ext_jpeg_mmap_desc_t::exif_length, _ext_jpeg_mmap_desc_t::exif_start, _ext_jpeg_mmap_desc_t::jpeg_length, and _ext_jpeg_mmap_desc_t::jpeg_start.
unsigned long ext_make_jpeg_header | ( | void | ) |
void get_image_exp | ( | unsigned long * | e | ) |
==================================================== ! 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 cxdma353.c.
References DCTSIZE2, HEADER_CQTABLE, HEADER_YQTABLE, local_irq_restore, local_irq_save, MD13, port_csp0_addr, printk, QTABLES_EXIF, QTABLES_FPGA, QTABLES_TABLE, X313_WA_COMP_TA, and X313_WA_COMP_TD.
void prof_msg | ( | const char * | msg | ) |
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 cxdma353.c.
References HEADER_HEIGHT, HEADER_WIDTH, jpeg_set_quality(), MD9, printk, and QTABLES_EXIF.
void update_JPEG_quality | ( | int | quality | ) |
int x313_dma_catchup_jpeg | ( | void | ) |
int x313_dma_forget_jpeg | ( | void | ) |
unsigned long x313_dma_init | ( | void | ) |
Definition at line 656 of file cxdma353.c.
References ccam_dma_buf_ptr, D0, MD7, printk, udelay, x313_dma_reset_jpeg(), and x313_setDMABuffer().
loff_t x313_dma_lseek | ( | struct file * | file, | |
loff_t | offset, | |||
int | orig | |||
) |
Definition at line 833 of file cxdma353.c.
References exif_header_length(), EXIF_OFFSET, JPEG_HEADER_SIZE, printk, TRAILER_SIZE, and x313_DMA_size().
ssize_t x313_dma_read | ( | struct file * | file, | |
char * | buf, | |||
size_t | count, | |||
loff_t * | off | |||
) |
Definition at line 1087 of file cxdma353.c.
References CCAM_DMA_SIZE, JPEG_HEADER_SIZE, MD9, printk, TRAILER_SIZE, X313_BUFFADD, and x313_DMA_size().
void x313_dma_reset_chain | ( | void | ) |
============================================= ! Puts 0xffff, 0xffffffff "before" first frame !=============================================
void x313_dma_reset_jpeg | ( | void | ) |
============================================= ! cc3x3.c - resets different things !=============================================
int x313_dma_restore_jpeg | ( | void | ) |
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 !=============================================
unsigned long x313_DMA_size | ( | void | ) |
void x313_dma_start | ( | void | ) |
Definition at line 617 of file cxdma353.c.
References ccam_dma_buf_ptr, CCAM_DMA_SIZE, DMA_CHUNK, EXT_DMA_0_START, MD12, port_csp0_addr, printk, and X313_WA_DMACR.
int x313_dma_stop | ( | void | ) |
Definition at line 607 of file cxdma353.c.
References EXT_DMA_0_STOP, MD12, port_csp0_addr, printk, udelay, and X313_WA_DMACR.
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
void x313_dma_update_jpeg_header | ( | void | ) |
ssize_t x313_dma_write | ( | struct file * | file, | |
const char * | buf, | |||
size_t | count, | |||
loff_t * | off | |||
) |
int x313_get_JPEG_ctrl | ( | void | ) |
Definition at line 341 of file cxdma353.c.
Definition at line 351 of file cxdma353.c.
References camSeqGetJPEG_rp(), camSeqGetJPEG_wp(), camSeqStartClip(), camSeqStop(), JPEG_CMD_ACQUIRE, JPEG_CMD_CATCHUP, JPEG_CMD_DUMP, JPEG_CMD_FORGET, JPEG_CMD_FRAMES, JPEG_CMD_GET, JPEG_CMD_JUST_STOP, JPEG_CMD_RESET, JPEG_CMD_RESET0, JPEG_CMD_RESTORE_RP, JPEG_CMD_SAVE_RP, JPEG_CMD_START, JPEG_CMD_STOP, MD11, MD5, MD6, MD8, printk, prof_msg(), x313_dma_catchup_jpeg(), x313_dma_forget_jpeg(), x313_dma_reset_jpeg(), x313_dma_restore_jpeg(), x313_dma_save_jpeg(), X313_dma_update(), x313_dma_update_jpeg_header(), x313_JPEG_dump(), and x313_setDMABuffer().
Definition at line 335 of file cxdma353.c.
void x313_JPEG_dump | ( | void | ) |
int x313_setDMABuffer | ( | void | ) |
etrax_dma_descr ccam_dma_descr_data[CCAM_DESCR_DATA_NUM] [static] |
Definition at line 269 of file cxdma353.c.
unsigned long ccam_dma_length = CCAM_DMA_SIZE << 2 |
Definition at line 279 of file cxdma353.c.
unsigned long DMABufferLength [static] |
Definition at line 276 of file cxdma353.c.
unsigned long extdma0_cmd_shadow = 0 [static] |
Definition at line 270 of file cxdma353.c.
int FPGA_quality = -1 |
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 284 of file cxdma353.c.
int JPEG_header_quality = -1 |
These parameters correspond to current JPEG header in memory.
Definition at line 291 of file cxdma353.c.
unsigned char jpeg_header_sbuffer[JPEG_HEADER_SIZE] [static] |
Definition at line 273 of file cxdma353.c.
unsigned char* jpeg_header_sbuffer_ptr = NULL |
Definition at line 274 of file cxdma353.c.
int jpeg_quality = -1 |
Definition at line 286 of file cxdma353.c.
Definition at line 297 of file cxdma353.c.
Definition at line 298 of file cxdma353.c.
Definition at line 296 of file cxdma353.c.
unsigned long t_sign = 0 |
Definition at line 589 of file cxdma353.c.
unsigned char trailer[TRAILER_SIZE] = {0xff,0xd9} [static] |
Definition at line 275 of file cxdma353.c.
int use_header = 1 [static] |
Definition at line 283 of file cxdma353.c.