#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 CAPTURE_SIZE 8192 |
#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/>. ! -----------------------------------------------------------------------------** !
#define D12 | ( | x | ) |
#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 | ) |
#define MDF13 | ( | x | ) |
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_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 | |||
) |
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().
char capture_buf[CAPTURE_SIZE] [static] |
int capture_length [static] |
int capture_pointer [static] |
unsigned long fpga_tables_buffer[CX313_FPGA_TABLES_SIZE] |