os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/fpga_io.c File Reference

#include <linux/module.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 <asm/system.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
#include <asm/elphel/fpgaconfa.h>
#include <asm/elphel/c313a.h>
#include "framepars.h"
#include <asm/arch/hwregs/reg_map.h>
#include <asm/arch/hwregs/bif_core_defs.h>
#include "x3x3.h"
#include "fpgactrl.h"
#include "fpga_io.h"

Include dependency graph for fpga_io.c:

Go to the source code of this file.

Defines

#define D(x)
#define D12(x)
#define MDF12(x)
#define MDF13(x)
#define CAPTURE_SIZE   8192
#define FPGA_TABLE_CHUNK   64

Functions

int fpga_io_open (void)
int fpga_io_close (void)
int canon_lens_io (int d)
int capture_pins (int n, int m)
int capture_read (void)
int fpga_io_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
loff_t fpga_io_lseek (struct file *file, loff_t offset, int orig)
ssize_t fpga_io_read (struct file *file, char *buf, size_t count, loff_t *off)
 Maybe make an "atomic" read/write FPGA sequence that is executed with IRQ down? How?
ssize_t fpga_io_write (struct file *file, const char *buf, size_t count, loff_t *off)
void fpga_table_write_nice (int addr, int len, unsigned long *data)
void fpga_hist_read_nice (int addr, int len, unsigned long *data)
ssize_t fpga_io_table_write (struct file *file, const char *buf, size_t count, loff_t *off)
loff_t fpga_io_table_lseek (struct file *file, loff_t offset, int orig)

Variables

unsigned long fpga_tables_buffer [CX313_FPGA_TABLES_SIZE]
static char capture_buf [CAPTURE_SIZE]
static int capture_length
static int capture_pointer


Define Documentation

#define CAPTURE_SIZE   8192

Definition at line 147 of file fpga_io.c.

Referenced by capture_pins().

#define D ( x   ) 

*************************************************************************** ! FILE NAME : fpga_io.c ! DESCRIPTION: TBD ! Copyright (C) 2002-2006 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
fpga_io.c,v
! Revision 1.1.1.1 2008/11/27 20:04:00 elphel ! ! ! Revision 1.10 2008/10/29 04:18:28 elphel ! v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue) ! ! Revision 1.9 2008/10/25 20:01:00 elphel ! bug fixed: removed reference to file->f_pos in write() and replaced with *ofs ! ! Revision 1.8 2008/10/23 08:02:23 elphel ! fpga_read_hist_nice() bug fix ! ! Revision 1.7 2008/10/04 16:10:12 elphel ! snapshot ! ! Revision 1.6 2008/09/16 00:49:30 elphel ! snapshot ! ! Revision 1.5 2008/09/12 00:23:59 elphel ! removed cc353.c, cc353.h ! ! Revision 1.4 2008/08/25 19:07:23 elphel ! just a snapshot ! ! Revision 1.3 2008/07/27 23:25:07 elphel ! next snapshot ! ! Revision 1.2 2008/07/27 04:27:49 elphel ! next snapshot ! ! Revision 1.1.1.1 2008/05/12 01:00:59 elphel ! ! ! Revision 1.6 2008/04/29 05:49:27 elphel ! typo ! ! Revision 1.5 2008/04/14 17:15:52 spectr_rain ! 200 gamma tables, correct 257 values tables ! ! Revision 1.4 2008/04/11 23:16:51 elphel ! removed unneeded local_irq_disable() after local_irq_save_flags() ! ! Revision 1.3 2008/04/09 21:01:25 elphel ! added access to individual wait state registers ! ! Revision 1.2 2007/10/23 16:58:51 elphel ! Improved r/w access to FPGA registers (available from PHP) ! ! Revision 1.1.1.1 2007/08/17 10:23:18 elphel ! This is a fresh tree based on elphel353-2.10 ! ! Revision 1.7 2007/08/17 10:23:18 spectr_rain ! switch to GPL3 license ! ! Revision 1.6 2007/07/20 10:17:46 spectr_rain ! *** empty log message *** ! ! Revision 1.2 2007/05/21 17:45:10 elphel ! boundary scan support, added 359/347 detection ! ! Revision 1.1.1.1 2007/02/23 10:11:48 elphel ! initial import into CVS ! ! Revision 1.3 2006/04/06 07:46:33 elphel ! control for canon lenses !

Definition at line 122 of file fpga_io.c.

#define D12 ( x   ) 

use static buffer, so will not work with simultaneous accesses (naturally fpga also has just one set of tables) only applies to file R/W, but most tables will be written from the kernel space

Definition at line 140 of file fpga_io.c.

#define FPGA_TABLE_CHUNK   64

IRQ-safe "nice" FPGA table write and histogram read functions - they split the data in chunks of fixed size, disable IRQ, transfer a chunk, then reenable interrupt before proceedg to the next chunk

Definition at line 437 of file fpga_io.c.

Referenced by fpga_hist_read_nice(), and fpga_table_write_nice().

#define MDF12 ( x   ) 

Definition at line 141 of file fpga_io.c.

Referenced by fpga_table_write_nice().

#define MDF13 ( x   ) 

Definition at line 142 of file fpga_io.c.

Referenced by fpga_hist_read_nice().


Function Documentation

int canon_lens_io ( int  d  ) 

Definition at line 159 of file fpga_io.c.

References flags, local_irq_restore, local_irq_save, port_csp0_addr, and udelay.

Referenced by fpga_io_ioctl().

int capture_pins ( int  n,
int  m 
)

Definition at line 200 of file fpga_io.c.

References capture_buf, capture_length, capture_pointer, CAPTURE_SIZE, flags, local_irq_restore, local_irq_save, port_csp0_addr, and udelay.

Referenced by fpga_io_ioctl().

int capture_read ( void   ) 

Definition at line 226 of file fpga_io.c.

References capture_buf, capture_length, and capture_pointer.

Referenced by fpga_io_ioctl().

void fpga_hist_read_nice ( int  addr,
int  len,
unsigned long *  data 
)

reading histograms really does not need disabling IRQs - they only could interfere with other process, reading histograms

Write start address, read first word from the memory to the output buffer (will be read out during next read)

needed before reading from FPGA after writing to it (for the writes that influence reads only)

will autoincrement FPGA table address)

Definition at line 457 of file fpga_io.c.

References flags, FPGA_TABLE_CHUNK, local_irq_restore, local_irq_save, MDF13, port_csp0_addr, port_csp4_addr, printk, X313_RA_HIST_DATA, X313_WA_HIST_ADDR, and X3X3_AFTERWRITE.

Referenced by set_histograms().

int fpga_io_close ( void   ) 

Definition at line 154 of file fpga_io.c.

int fpga_io_ioctl ( struct inode *  inode,
struct file *  file,
unsigned int  cmd,
unsigned long  arg 
)

Definition at line 258 of file fpga_io.c.

References canon_lens_io(), capture_pins(), capture_read(), d, D, FPGACONF_CANON_IOBYTE, FPGACONF_RD_WAITSTATES, FPGACONF_READ_CAPTURE, FPGACONF_READREG, FPGACONF_READREG4, FPGACONF_READREG_H, FPGACONF_READREG_H4, FPGACONF_READREG_L, FPGACONF_READREG_L4, FPGACONF_START_CAPTURE, FPGACONF_WR_WAITSTATES, FPGACONF_WRITEREG, FPGACONF_WRITEREG4, int, port_csp0_addr, port_csp4_addr, and printk.

Referenced by fpga_ioctl().

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

Definition at line 359 of file fpga_io.c.

References D, printk, SEEK_CUR, SEEK_END, SEEK_SET, and size.

Referenced by fpga_lseek().

int fpga_io_open ( void   ) 

Definition at line 151 of file fpga_io.c.

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

Maybe make an "atomic" read/write FPGA sequence that is executed with IRQ down? How?

it is not safe to read data table if interrupts are - autoexposure may try to read FPGA tables and that will change the pointers. So these functions are provided for testing only, there will be special functions for reading/writing FPGA tables TODO: Make sure that these FPGA accesses do not disturb autoexposure (it should read histogram only while IRQ is off)

off is considered to be a register address, not a byte pointer

now read to the buffer

copy data to user space

dont modify *off, return number of bytes read

Definition at line 396 of file fpga_io.c.

References D, port_csp0_addr, port_csp4_addr, and printk.

Referenced by fpga_read().

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

Definition at line 499 of file fpga_io.c.

References CX313_FPGA_TABLES_SIZE.

Referenced by fpga_lseek().

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

Definition at line 477 of file fpga_io.c.

References CX313_FPGA_TABLES_SIZE, D, fpga_table_write_nice(), fpga_tables_buffer, printk, and sa.

Referenced by fpga_write().

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

Changing again: 1. Lseek selects a 32-bit register, Bit 13 selects between CSP0 and CSP4 (needed for buffer reads that increment buffer address - i.e. histogram) 2. Writes and Reads always start from register LSB (i.e. multiple one byte reads will each return LSB of the same register), addresses are not autoincremented 3. Writes with less than muptiple of 4 bytes will fill higher bytes with zeros, register addresses are not auto incremented

off is considered to be a register address, not a byte pointer

get data from user space

zero unused bytes in last partial word

now write to FPGA

dont modify *off, return number of bytes written

Definition at line 414 of file fpga_io.c.

References D, n, port_csp0_addr, port_csp4_addr, printk, and wbuf.

Referenced by fpga_write().

void fpga_table_write_nice ( int  addr,
int  len,
unsigned long *  data 
)

extern void fpga_table_write(unsigned long fpga_addr, unsigned long *data, int length); - was only in hist353.c write FPGA tables/read histograms

will autoincrement FPGA table address

Definition at line 438 of file fpga_io.c.

References flags, FPGA_TABLE_CHUNK, local_irq_restore, local_irq_save, MDF12, port_csp0_addr, printk, X313_WA_COMP_TA, and X313_WA_COMP_TD.

Referenced by fpga_io_table_write(), jpeg_htable_fpga_pgm(), pgm_focusmode(), pgm_gammaload(), and set_qtable_fpga().


Variable Documentation

char capture_buf[CAPTURE_SIZE] [static]

Definition at line 148 of file fpga_io.c.

Referenced by capture_pins(), and capture_read().

int capture_length [static]

Definition at line 149 of file fpga_io.c.

Referenced by capture_pins(), and capture_read().

int capture_pointer [static]

Definition at line 150 of file fpga_io.c.

Referenced by capture_pins(), and capture_read().

unsigned long fpga_tables_buffer[CX313_FPGA_TABLES_SIZE]

Definition at line 145 of file fpga_io.c.

Referenced by fpga_io_table_write().


Generated on Fri Nov 28 00:07:48 2008 for elphel by  doxygen 1.5.1