Commit 6afee618 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Compile circbuf as external module

This involves some modifications to meta-elphel layer.
parent 52ee3704
......@@ -20,4 +20,10 @@ config ELPHEL393_INIT
default y
help
If unsure, say Y.
config ELPHEL393_EXTERNAL
tristate "Compile circbuf as external module"
default m
help
If unsure, say Y.
endmenu
......@@ -7,7 +7,12 @@ obj-$(CONFIG_ELPHEL393) += elphel393-mem.o
obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o
obj-$(CONFIG_ELPHEL393_INIT) += elphel393-init.o
obj-$(CONFIG_ELPHEL393) += framepars.o
obj-$(CONFIG_ELPHEL393) += sensor_common.o
obj-$(CONFIG_ELPHEL393) += quantization_tables.o
obj-$(CONFIG_ELPHEL393) += circbuf.o jpeghead.o
\ No newline at end of file
#obj-$(CONFIG_ELPHEL393) += framepars.o
#obj-$(CONFIG_ELPHEL393) += sensor_common.o
#obj-$(CONFIG_ELPHEL393) += quantization_tables.o
#obj-$(CONFIG_ELPHEL393) += circbuf.o jpeghead.o
obj-$(CONFIG_ELPHEL393_EXTERNAL) += framepars.o
obj-$(CONFIG_ELPHEL393_EXTERNAL) += sensor_common.o
obj-$(CONFIG_ELPHEL393_EXTERNAL) += quantization_tables.o
obj-$(CONFIG_ELPHEL393_EXTERNAL) += circbuf.o jpeghead.o
\ No newline at end of file
......@@ -150,6 +150,8 @@
#include <linux/init.h>
#include <linux/time.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
#include <linux/errno.h>
//#include <asm/system.h>
//#include <asm/arch/memmap.h>
......@@ -206,14 +208,23 @@
/* really huge static DMA buffer (1288+8)*1032/3=445824 long-s */
// DMA_SIZE - in 32-bit words, not bytes
static unsigned long ccam_dma_buf[CCAM_DMA_SIZE + (PAGE_SIZE>>2)] __attribute__ ((aligned (PAGE_SIZE)));
//static unsigned long ccam_dma_buf[CCAM_DMA_SIZE + (PAGE_SIZE>>2)] __attribute__ ((aligned (PAGE_SIZE)));
static unsigned long *ccam_dma_buf = NULL;
//!Without "static" system hangs after "Uncompressing Linux...
unsigned long * ccam_dma_buf_ptr = NULL;
unsigned long * ccam_dma = NULL; //! still used in autoexposure or something - why is in needed there?
void init_ccam_dma_buf_ptr(void) {
ccam_dma_buf_ptr = ccam_dma_buf;
ccam_dma = ccam_dma_buf; //&ccam_dma_buf[0]; Use in autoexposure
int init_ccam_dma_buf_ptr(void) {
dma_addr_t *dma_handle;
//ccam_dma_buf_ptr = ccam_dma_buf;
//ccam_dma = ccam_dma_buf; //&ccam_dma_buf[0]; Use in autoexposure
ccam_dma_buf_ptr = dma_alloc_coherent(NULL, (CCAM_DMA_SIZE + (PAGE_SIZE >> 2)), dma_handle, GFP_KERNEL);
if (!ccam_dma_buf_ptr) {
return -ENOMEM;
} else {
printk(KERN_DEBUG "%s: dma memory allocated at 0x%08x", __func__, dma_handle);
}
}
extern struct interframe_params_t frame_params; // cc353.c
/*!======================================================================================
......@@ -679,6 +690,12 @@ static int __init circbuf_all_init(void) {
return res;
}
res = init_ccam_dma_buf_ptr();
if (res < 0) {
printk(KERN_ERR "%s: ERROR allocating coherent DMA buffer\n", __func__);
return -ENOMEM;
}
MDF19(printk("init_waitqueue_head()\n"));
init_waitqueue_head(&circbuf_wait_queue);
MDF19(printk("jpeg_htable_init()\n"));
......@@ -689,7 +706,7 @@ static int __init circbuf_all_init(void) {
module_init(circbuf_all_init);
MODULE_LICENSE("GPLv3.0");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>.");
MODULE_DESCRIPTION(CIRCBUF_DRIVER_NAME);
......@@ -25,10 +25,12 @@ ssize_t circbuf_read (struct file * file, char * buf, size_t count, loff_t
int circbuf_mmap (struct file *file, struct vm_area_struct *vma);
unsigned int circbuf_poll (struct file *file, poll_table *wait);
void init_ccam_dma_buf_ptr(void);
int init_ccam_dma_buf_ptr(void);
/*!======================================================================================
*! Wait queue for the processes waiting for a new frame to appear in the circular buffer
*!======================================================================================*/
extern wait_queue_head_t circbuf_wait_queue;
unsigned long *ccam_dma_buf_ptr;
#endif /* _CIRCBUF_H */
......@@ -302,6 +302,7 @@ unsigned long *multiSensIndex= NULL; /// index for per-sensor alternat
unsigned long *multiSensRvrsIndex=NULL; /// reverse index (to parent) for the multiSensIndex
wait_queue_head_t framepars_wait_queue; /// used to wait for the frame to be acquired
extern struct sensorproc_t * sensorproc;
/**
* @brief file private data
......@@ -433,6 +434,7 @@ int initMultiPars(void) {
inline unsigned long get_imageParamsThis (int n) {
return framepars[thisFrameNumber & PARS_FRAMES_MASK].pars[n] ;
}
EXPORT_SYMBOL_GPL(get_imageParamsThis);
/**
* @brief reads parameters from the previous frame (matching hardware index) - used to determine if historam was needed
......@@ -462,6 +464,7 @@ inline void set_imageParamsThis (int n,unsigned long d) {
inline unsigned long get_globalParam (int n) {
return GLOBALPARS(n) ;
}
EXPORT_SYMBOL_GPL(get_globalParam);
/**
* @brief sets global (not related to particular frames) parameters
* @param n number of a parameter to set (numbers start from FRAMEPAR_GLOBALS)
......@@ -471,6 +474,7 @@ inline unsigned long get_globalParam (int n) {
inline void set_globalParam (int n, unsigned long d) {
GLOBALPARS(n)=d;
}
EXPORT_SYMBOL_GPL(set_globalParam);
/**
* @brief set same parameters in all frames
......@@ -1340,6 +1344,6 @@ static int __init framepars_init(void) {
module_init(framepars_init);
MODULE_LICENSE("GPLv3.0");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>.");
MODULE_DESCRIPTION(X3X3_FRAMEPARS_DRIVER_NAME);
......@@ -4,7 +4,7 @@
//extern struct framepars_t (*framepars)[PARS_FRAMES];
extern struct framepars_t *framepars;
extern struct framepars_past_t *pastpars;
extern unsigned long *globalPars;
unsigned long *globalPars;
extern unsigned long *multiSensIndex;
extern unsigned long *multiSensRvrsIndex;
......
......@@ -118,6 +118,8 @@
#define JPEG_HEADER_MAX_SIZE 0x300
static int huffman_fpga_programmed=0;
extern unsigned long *ccam_dma_buf_ptr;
/// All huffman tabels data to be read/written from the application
static struct huff_tables_t {
struct huffman_encoded_t header_huffman_tables[4];
......@@ -369,6 +371,7 @@ int jpeghead_open(struct inode *inode, struct file *filp) { // set filesize
inode->i_size=JPEG_HEADER_MAXSIZE; /// not the actual size
return 0;
}
EXPORT_SYMBOL_GPL(jpeghead_open);
/*!=================================================================
*! Overloading lseek with additional functionality (to avoid ioctls)
......@@ -439,6 +442,7 @@ loff_t jpeghead_lseek(struct file * file, loff_t offset, int orig){
}
return ( file->f_pos );
}
EXPORT_SYMBOL_GPL(jpeghead_lseek);
ssize_t jpeghead_read(struct file * file, char * buf, size_t count, loff_t *off) {
unsigned long p;
......@@ -457,6 +461,7 @@ ssize_t jpeghead_read(struct file * file, char * buf, size_t count, loff_t *off)
}
return count;
}
EXPORT_SYMBOL_GPL(jpeghead_read);
/**huffman_* file operations
......@@ -477,6 +482,7 @@ int huffman_open(struct inode *inode, struct file *filp) { // set filesize
return 0;
}
EXPORT_SYMBOL_GPL(huffman_open);
/*!=================================================================
*! Overloading lseek with additional functionality
......@@ -537,6 +543,7 @@ loff_t huffman_lseek(struct file * file, loff_t offset, int orig){
if (file->f_pos > sizeof(huff_tables)) file->f_pos = sizeof(huff_tables);
return ( file->f_pos );
}
EXPORT_SYMBOL_GPL(huffman_lseek);
ssize_t huffman_read(struct file * file, char * buf, size_t count, loff_t *off) {
......@@ -552,6 +559,7 @@ ssize_t huffman_read(struct file * file, char * buf, size_t count, loff_t *off)
}
return count;
}
EXPORT_SYMBOL_GPL(huffman_read);
ssize_t huffman_write(struct file * file, const char * buf, size_t count, loff_t *off) {
......@@ -567,6 +575,7 @@ ssize_t huffman_write(struct file * file, const char * buf, size_t count, loff_t
return count;
}
EXPORT_SYMBOL_GPL(huffman_write);
/**
* @brief Initialize Huffman tables with default data
......@@ -637,6 +646,7 @@ void jpeg_htable_init (void) {
MDF17(printk("jpeg_htable_fpga_encode ()\n"));
jpeg_htable_fpga_encode ();
}
EXPORT_SYMBOL_GPL(jpeg_htable_init);
/**
* @brief encode all 4 Huffman tables into FPGA format
......
......@@ -19,7 +19,7 @@ ssize_t huffman_write (struct file * file, const char * buf, size_t count, loff
extern unsigned long * ccam_dma_buf_ptr;
void init_ccam_dma_buf_ptr(void);
//void init_ccam_dma_buf_ptr(void);
#define JPEG_HEADER_MAXSIZE 0x300
struct jpeghead_pd {
int minor;/// should be the first, same as in circbuf_pd
......
......@@ -191,14 +191,14 @@ static unsigned long coring_tables[];
/**
* @brief force (re-)initilaization of quantization tables cache and FPGA qunatization table (in FPGA) when next used.
* @brief force (re-)initialization of quantization tables cache and FPGA quantization table (in FPGA) when next used.
*/
void reset_qtables(void) {
qtable_cache_initialized=0;
qtable_fpga_initialized=0;
}
EXPORT_SYMBOL_GPL(reset_qtables);
/**
......
......@@ -271,6 +271,9 @@ void camSeqSetJPEG_rp(int p) {
get_globalParam(G_CIRCBUFSIZE):0)+ get_globalParam(G_CIRCBUFRP))
- get_globalParam(G_CIRCBUFWP));
}
EXPORT_SYMBOL_GPL(camSeqGetJPEG_wp);
EXPORT_SYMBOL_GPL(camSeqGetJPEG_rp);
EXPORT_SYMBOL_GPL(camSeqSetJPEG_rp);
/*!
End of compressor-related code - TODO: move to a separate file?
......@@ -671,6 +674,7 @@ void reset_compressor(void) {
fpga_counter_prev=0;
local_irq_restore(flags);
}
EXPORT_SYMBOL_GPL(reset_compressor);
/**
* @brief Camera interrupts on/off (currently both in the FPGA and in the CPU)
......@@ -693,6 +697,7 @@ void camera_interrupts (int on) {
REG_WR(intr_vect, regi_irq, rw_mask, intr_mask);
#endif /* TEST_DISABLE_CODE */
}
EXPORT_SYMBOL_GPL(camera_interrupts);
int image_acq_open(struct inode *inode, struct file *filp) ;
......@@ -715,7 +720,7 @@ static int __init image_acq_init(void) {
int res;
sensorproc= &s_sensorproc;
MDD1(printk("sensorproc=0x%x\n",(int) sensorproc));
init_ccam_dma_buf_ptr(); /// should it be done here? Why not in circbuf.c?
//init_ccam_dma_buf_ptr(); /// should it be done here? Why not in circbuf.c?
/// init_histograms(); - other initializations?
res = register_chrdev(ELPHEL_MAJOR, elphel_cam_name, &image_acq_fops);
if(res < 0) {
......@@ -770,6 +775,6 @@ int image_acq_mmap (struct file *file, struct vm_area_struct *vma) {
module_init(image_acq_init);
MODULE_LICENSE("GPLv3.0");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>.");
MODULE_DESCRIPTION(X3X3_IMAGEACQ_DRIVER_NAME);
......@@ -2,7 +2,7 @@
#define _SENSOR_COMMON_H
//extern struct sensor_t sensor; // current sensor (will be copied to by sensor driver), made external for the cc353.c to read/write i2c
extern struct sensorproc_t * sensorproc;
struct sensorproc_t * sensorproc;
/// 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
#define FPGA_TABLE_CHUNK 64 // up to 64 words to send to the table/from histogram on a single IRQ-off transfer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment