#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 CCAM_DESCR_DATA_NUM (( CCAM_DMA_SIZE / DMA_CHUNK) +1 ) |
#define DCTSIZE2 64 |
#define DMA_CHUNK 0x4000 |
#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 HEADER_CQTABLE 0x5e |
#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 |
#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/>. ! -----------------------------------------------------------------------------** !
static unsigned char ext_mjpeg_header [PAGE_SIZE] __attribute__ | ( | (aligned(PAGE_SIZE)) | ) | [static] |
int cmoscam_open_dma | ( | struct inode * | inode, | |
struct file * | filp | |||
) |
unsigned long cpu_to_le | ( | unsigned long | in | ) |
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 | ) |
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().
==================================================== ! 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 | ) |
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 | ) |
loff_t x313_dma_lseek | ( | struct file * | file, | |
loff_t | offset, | |||
int | orig | |||
) |
ssize_t x313_dma_read | ( | struct file * | file, | |
char * | buf, | |||
size_t | count, | |||
loff_t * | off | |||
) |
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 | ) |
int x313_dma_stop | ( | void | ) |
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 | |||
) |
int x313_get_JPEG_ctrl | ( | void | ) |
Definition at line 341 of file cxdma.c.
Referenced by compressorRun(), compressorSingle(), programSensor(), and x313_program_focus().
Definition at line 351 of file cxdma.c.
Referenced by ccam_DMA_ioctl(), and x313_JPEG_cmd_wrapper().
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().
etrax_dma_descr ccam_dma_descr_data[CCAM_DESCR_DATA_NUM] [static] |
unsigned long ccam_dma_length = CCAM_DMA_SIZE << 2 |
unsigned long DMABufferLength [static] |
unsigned long extdma0_cmd_shadow = 0 [static] |
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; }
int JPEG_header_quality = -1 |
unsigned char jpeg_header_sbuffer[JPEG_HEADER_SIZE] [static] |
unsigned char* jpeg_header_sbuffer_ptr = NULL |
int jpeg_quality = -1 |
unsigned long t_sign = 0 |
int use_header = 1 [static] |