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

Compile circbuf as external module

This involves some modifications to meta-elphel layer.
parent 52ee3704
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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  
+9 −4
Original line number Diff line number Diff line
@@ -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
+22 −5
Original line number Diff line number Diff line
@@ -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);
+3 −1
Original line number Diff line number Diff line
@@ -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 */
+5 −1
Original line number Diff line number Diff line
@@ -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);
Loading