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

Go to the documentation of this file.
00001 /*!********************************************************************************
00002 *! FILE NAME  : sensor_common.c
00003 *! DESCRIPTION: Sensor discovery, initialization, programming - common
00004 *! for all sensors
00005 *! Now most is moved to other files, here will be
00006 *! - system initialization
00007 *! - compressor write (and global read) pointers
00008 *! - populating 32-byte interframe data
00009 *! - something for Exif?
00010 *! - where are histograms? ->histograms.c
00011 *! - interrupt loop
00012 *! - tasklets
00013 *! - device driver that includes waiting for the next frame regardless of compression
00014 *! - anything else?
00015 *!
00016 *! 
00017 *! Copyright (C) 2008 Elphel, Inc.
00018 *! -----------------------------------------------------------------------------**
00019 *!
00020 *!  This program is free software: you can redistribute it and/or modify
00021 *!  it under the terms of the GNU General Public License as published by
00022 *!  the Free Software Foundation, either version 3 of the License, or
00023 *!  (at your option) any later version.
00024 *!
00025 *!  This program is distributed in the hope that it will be useful,
00026 *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
00027 *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00028 *!  GNU General Public License for more details.
00029 *!
00030 *!  You should have received a copy of the GNU General Public License
00031 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00032 *! -----------------------------------------------------------------------------**
00033 *!  $Log: sensor_common.c,v $
00034 *!  Revision 1.1.1.1  2008/11/27 20:04:00  elphel
00035 *!
00036 *!
00037 *!  Revision 1.33  2008/11/20 07:04:47  elphel
00038 *!  made silent when debug is 0
00039 *!
00040 *!  Revision 1.32  2008/11/14 07:06:54  elphel
00041 *!  fixed wrong timing for servicing histogram requests
00042 *!
00043 *!  Revision 1.31  2008/11/13 05:40:45  elphel
00044 *!  8.0.alpha16 - modified histogram storage, profiling
00045 *!
00046 *!  Revision 1.30  2008/11/10 19:47:46  elphel
00047 *!  added TODO abut reducing CPU load by decimating histogram calculations (not each frame)
00048 *!
00049 *!  Revision 1.29  2008/10/29 04:18:28  elphel
00050 *!  v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue)
00051 *!
00052 *!  Revision 1.28  2008/10/26 05:54:45  elphel
00053 *!  changed value of frame counters for histograms to compensate for 1 frame latency of histograms
00054 *!
00055 *!  Revision 1.27  2008/10/25 19:55:00  elphel
00056 *!  made the histograms calculations relate to previous, not this frame.
00057 *!
00058 *!  Revision 1.26  2008/10/23 08:09:02  elphel
00059 *!  support for histogram wait queues
00060 *!
00061 *!  Revision 1.25  2008/10/19 06:56:05  elphel
00062 *!  elphel_wait_frame() now works only for compressed frames, new elphel_skip_frames() and elphel_wait_frame_abs() wait sequencer frames (all sensor frames, even those that are not compressed)
00063 *!
00064 *!  Revision 1.24  2008/10/15 22:28:56  elphel
00065 *!  snapshot 8.0.alpha2
00066 *!
00067 *!  Revision 1.23  2008/10/13 16:55:53  elphel
00068 *!  removed (some) obsolete P_* parameters, renamed CIRCLSEEK to LSEEK_CIRC constants (same as other similar)
00069 *!
00070 *!  Revision 1.22  2008/10/12 16:46:22  elphel
00071 *!  snapshot
00072 *!
00073 *!  Revision 1.21  2008/10/11 18:46:07  elphel
00074 *!  snapshot
00075 *!
00076 *!  Revision 1.20  2008/10/10 17:06:59  elphel
00077 *!  just a snapshot
00078 *!
00079 *!  Revision 1.19  2008/10/08 21:26:25  elphel
00080 *!  snapsot 7.2.0.pre4 - first images (actually - second)
00081 *!
00082 *!  Revision 1.18  2008/10/05 05:13:33  elphel
00083 *!  snapshot003
00084 *!
00085 *!  Revision 1.17  2008/10/04 16:10:12  elphel
00086 *!  snapshot
00087 *!
00088 *!  Revision 1.16  2008/09/28 00:31:57  elphel
00089 *!  snapshot
00090 *!
00091 *!  Revision 1.15  2008/09/25 00:58:12  elphel
00092 *!  snapshot
00093 *!
00094 *!  Revision 1.14  2008/09/22 22:55:49  elphel
00095 *!  snapshot
00096 *!
00097 *!  Revision 1.13  2008/09/20 00:29:50  elphel
00098 *!  moved driver major/minor numbers to a single file - include/asm-cris/elphel/driver_numbers.h
00099 *!
00100 *!  Revision 1.12  2008/09/19 04:37:26  elphel
00101 *!  snapshot
00102 *!
00103 *!  Revision 1.11  2008/09/16 00:49:32  elphel
00104 *!  snapshot
00105 *!
00106 *!  Revision 1.10  2008/09/12 00:24:00  elphel
00107 *!  removed cc353.c, cc353.h
00108 *!
00109 *!  Revision 1.9  2008/09/07 19:48:09  elphel
00110 *!  snapshot
00111 *!
00112 *!  Revision 1.8  2008/09/05 23:20:26  elphel
00113 *!  just a snapshot
00114 *!
00115 *!  Revision 1.7  2008/09/02 21:01:07  elphel
00116 *!  just next...
00117 *!
00118 *!  Revision 1.6  2008/07/29 01:15:07  elphel
00119 *!  another snapshot
00120 *!
00121 *!  Revision 1.5  2008/07/27 23:25:07  elphel
00122 *!  next snapshot
00123 *!
00124 *!  Revision 1.4  2008/07/27 04:27:49  elphel
00125 *!  next snapshot
00126 *!
00127 *!  Revision 1.3  2008/06/24 00:43:44  elphel
00128 *!  just a snapshot
00129 *!
00130 *!  Revision 1.2  2008/06/20 03:54:21  elphel
00131 *!  another snapshot
00132 *!
00133 *!  Revision 1.1  2008/06/16 06:51:21  elphel
00134 *!  work in progress, intermediate commit
00135 *!
00136 *!
00137 */
00138 
00139 //copied from cxi2c.c - TODO:remove unneeded
00140 
00141 #include <linux/module.h>
00142 #include <linux/sched.h>
00143 #include <linux/slab.h>
00144 #include <linux/errno.h>
00145 #include <linux/kernel.h>
00146 #include <linux/fs.h>
00147 #include <linux/string.h>
00148 #include <linux/init.h>
00149 #include <linux/autoconf.h>
00150 #include <linux/interrupt.h>
00151 #include <linux/time.h>
00152 #include <linux/vmalloc.h>
00153 
00154 #include <asm/system.h>
00155 #include <asm/byteorder.h> // endians
00156 #include <asm/io.h>
00157 
00158 #include <asm/arch/hwregs/intr_vect_defs.h> 
00159 
00160 #include <asm/irq.h>
00161 
00162 #include <asm/delay.h>
00163 #include <asm/uaccess.h>
00164 #include <asm/elphel/driver_numbers.h>
00165 #include <asm/elphel/c313a.h>
00166 #include <asm/elphel/fpgaconfa.h>
00167 #include <asm/elphel/exifa.h>
00168 #include "fpgactrl.h"  // defines port_csp0_addr, port_csp4_addr 
00169 #include "fpga_sdram.h" // use a single fpga_initSDRAM(void)
00170 
00171 #include "x3x3.h"
00172 //#include "cc3x3.h"
00173 #include "cxdma.h"
00174 
00175 #include "framepars.h"
00176 #include "sensor_common.h"
00177 #include "pgm_functions.h"
00178 #include "circbuf.h"
00179 #include "exif353.h"
00180 #include "histograms.h"
00181 #include "gamma_tables.h"
00182 #include "quantization_tables.h"
00183 
00184 #if ELPHEL_DEBUG
00185  #define ELPHEL_DEBUG_THIS 0
00186 #else
00187  #define ELPHEL_DEBUG_THIS 0
00188 #endif
00189 #if ELPHEL_DEBUG_THIS
00190   #define MDF2(x) printk("%s:%d:%s ",__FILE__,__LINE__,__FUNCTION__); x
00191   #define MDD1(x) printk("%s:%d:",__FILE__,__LINE__); x ; udelay (ELPHEL_DEBUG_DELAY)
00192   #define MD1(x) printk("%s:%d:",__FILE__,__LINE__);x
00193   //#define MD1(x)
00194   #define MD12(x) printk("%s:%d:",__FILE__,__LINE__);x
00195   //#define MD12(x)
00196   #define MD13(x) printk("%s:%d:",__FILE__,__LINE__);x
00197   //#define MD13(x)
00198 #else
00199   #define MDF2(x)
00200   #define MD1(x)
00201   #define MDD1(x)
00202   #define MD12(x)
00203   #define MD13(x)
00204 #endif
00205 
00206 
00207 
00208 #define X3X3_ELPHEL_DRIVER_NAME "Elphel (R) Model 353 Camera Driver"
00209 static const char elphel_cam_name[] = "elphelcam353";
00210 
00211 static volatile int JPEG_wp;
00212 static volatile int JPEG_rp;
00213 static int fpga_counter_prev=0; 
00214   static struct meta_offsets_t { // works like a cache to time save on looking for tags in the directory (forced to recalcualte if does not match)
00215     int Image_DateTime;          // will have offset of the Exif_Image_DateTime data in meta page (Exif_Photo_SubSecTime should go immediately after in meta page)
00216     int Photo_DateTimeOriginal;
00217     int Photo_ExposureTime;
00218     int Image_FrameNumber;
00219   } meta_offsets;
00220 
00221 
00222 
00223 
00224 
00226 // #define EN_INTERRUPT(x)  port_csp0_addr[X313_WA_IRQ_ENA]= (1<< x )
00227 // #define DIS_INTERRUPT(x) {port_csp0_addr[X313_WA_IRQ_DIS]= (1<< x ); port_csp0_addr[X313_WA_IRQ_RST]= (1<< x );}
00228 // #define DIS_INTERRUPTS   {port_csp0_addr[X313_WA_IRQ_DIS]= 0xffff; port_csp0_addr[X313_WA_IRQ_RST]= 0xffff;}
00229 
00230 
00231 
00232 int  camSeqGetJPEG_wp(void) {return JPEG_wp;}
00233 int  camSeqGetJPEG_rp(void) {return JPEG_rp;}
00234 void camSeqSetJPEG_rp(int p) {
00235                               JPEG_rp=p;
00236                               set_globalParam(G_CIRCBUFRP,  p<< 2);
00237                               set_globalParam(G_FREECIRCBUF,
00238                                     (((get_globalParam(G_CIRCBUFRP) <= get_globalParam(G_CIRCBUFWP))?
00239                                        get_globalParam(G_CIRCBUFSIZE):0)+ get_globalParam(G_CIRCBUFRP))
00240                                        - get_globalParam(G_CIRCBUFWP));
00241                                }
00242 
00251 #define X3X3_IMAGEACQ_DRIVER_NAME "Elphel (R) Model 353 Image Acquisition device driver"
00252 static struct sensorproc_t s_sensorproc; // sensor parameters and functions to call
00253 struct sensorproc_t * sensorproc = NULL;
00254 //wait_queue_head_t image_acq_wait_queue;  /// queue for the sensor frame interrupts
00255 
00256 struct image_acq_pd {
00257     int                minor;
00258 //    struct wait_queue *image_acq_wait_queue;
00259 // something else to be added here?
00260 };
00261 
00262 void tasklet_fpga_function(unsigned long arg);
00263 
00264 
00266 //int init_sensor(void);
00268 
00273 int init_FPGA(void) { //will check FPGA version, init SDRAM (if needed) and sensor
00274   int i;
00275 //  int f1,f2;
00276    // Should be initial
00277   if ((fpga_state & FPGA_STATE_LOADED) ==  0) return -1; 
00278 
00279   if ((i=port_csp0_addr[X313__RA__MODEL]) < X313_MINMODREV) {
00280    printk ("too old fpga rev - found %x, software wants >= %x\n",i,X313_MINMODREV);
00281    return -1;   // too old FPGA
00282   } 
00283   if (i > X313_MAXMODREV) {
00284      printk ("too new fpga rev - found %x, software wants <= %x\n",i,X313_MAXMODREV);
00285      return -1;    // too new FPGA
00286   }
00287   fpga_state |= FPGA_STATE_INITIALIZED; 
00288   
00289   if (!X313_IS_SDRAM_ON)  fpga_initSDRAM();
00290 // Was sensor initialized? (What if SDRAM was initialized by some application?)
00291   MD1(printk("init_FPGA, fpga_state=0x%x\n",fpga_state));
00292   if (X313_CHN0_USED!=0) return 0;
00293   return 1;
00294 }
00295 
00307 int init_acq_sensor(void);
00308 
00309 static int __init image_acq_init(void);
00310 
00311 DECLARE_TASKLET(tasklet_fpga, tasklet_fpga_function, 0); 
00312 
00313 
00314 
00320 inline int updateIRQJPEG_wp(void) {
00321      int xferred;                                           
00322      int fpga_cntr=            X313_XFERCNTR;               
00323      xferred=                  fpga_cntr-fpga_counter_prev; 
00324 #if ELPHEL_DEBUG_THIS
00325      set_globalParam          (0x300,get_globalParam (0x300)+1);
00326      set_globalParam          (0x302,fpga_cntr);
00327      if (xferred==0)           set_globalParam          (0x305,get_globalParam (0x305)+1);
00328 #endif
00329      if (xferred==0)           return 0;                    
00330      fpga_counter_prev=        fpga_cntr;
00331      if (xferred <0) xferred+= (1 <<24) ;                   
00332      JPEG_wp+= (xferred << 3); 
00333      int circbuf_size=get_globalParam (G_CIRCBUFSIZE)>>2; //G_CIRCBUFSIZE G_CIRCBUFRP
00334      if (JPEG_wp > circbuf_size) JPEG_wp-=circbuf_size;
00335 #if ELPHEL_DEBUG_THIS
00336      set_globalParam          (0x301,get_globalParam (0x301)+1);
00337      set_globalParam          (0x303,xferred);
00338      set_globalParam          (0x304,JPEG_wp);
00339 #endif
00340      return 1;
00341 }
00345 inline void updateIRQCircbuf(void) {
00346      set_globalParam (G_CIRCBUFWP, JPEG_wp<<2);
00347      set_globalParam (G_FREECIRCBUF, (((get_globalParam (G_CIRCBUFRP) <= get_globalParam (G_CIRCBUFWP))? get_globalParam (G_CIRCBUFSIZE):0)+ 
00348                                      get_globalParam (G_CIRCBUFRP)) -    get_globalParam (G_CIRCBUFWP));
00349 }
00350 
00355 inline void updateIRQFocus(void) {
00356     set_globalParam     (G_GFOCUS_VALUE, X313_HIGHFREQ);
00357     set_imageParamsThis (P_FOCUS_VALUE, X313_HIGHFREQ);
00358 }
00359 
00360 
00361 
00366 inline struct interframe_params_t* updateIRQ_interframe(void) {
00367    int circbuf_size=get_globalParam (G_CIRCBUFSIZE)>>2;
00368    int alen = JPEG_wp-9; if (alen<0) alen+=circbuf_size;
00369    int jpeg_len=ccam_dma_buf_ptr[alen] & 0xffffff;
00370    int aframe_params=(alen & 0xfffffff8)-
00371                      (((jpeg_len + CCAM_MMAP_META + 3) & 0xffffffe0)>>2) 
00372                      -8; 
00373    if(aframe_params < 0) aframe_params += circbuf_size;
00374    struct interframe_params_t* interframe= (struct interframe_params_t*) &ccam_dma_buf_ptr[aframe_params];
00376    interframe->frame_length=jpeg_len;
00377    interframe->signffff=0xffff;
00378 #if ELPHEL_DEBUG_THIS
00379     set_globalParam          (0x306,get_globalParam (0x306)+1);
00380 #endif
00381 
00382    return interframe;
00383 }
00384 
00389 inline void updateIRQ_Exif(struct interframe_params_t* interframe) {
00390    int  index_time = JPEG_wp-11; if (index_time<0) index_time+=get_globalParam (G_CIRCBUFSIZE)>>2;
00392    char * exif_meta_time_string=encode_time(ccam_dma_buf_ptr[index_time], ccam_dma_buf_ptr[index_time+1]);
00394    write_meta_irq(exif_meta_time_string, &meta_offsets.Photo_DateTimeOriginal,  Exif_Photo_DateTimeOriginal, 27);
00395    write_meta_irq(exif_meta_time_string, &meta_offsets.Image_DateTime,  Exif_Image_DateTime, 20); // may use 27 if room is provided
00396    putlong_meta_irq(get_imageParamsThis(P_EXPOS), &meta_offsets.Photo_ExposureTime,  Exif_Photo_ExposureTime);
00397    putlong_meta_irq(get_imageParamsThis(P_FRAME), &meta_offsets.Image_FrameNumber,   Exif_Image_FrameNumber);
00398    interframe->meta_index=store_meta();
00399 }
00400 
00408 static irqreturn_t elphel_FPGA_interrupt(int irq, void *dev_id) {
00409    unsigned long irq_state;
00410 
00411    irq_state = X313_IRQSTATE; 
00412    DIS_INTERRUPTS;
00413    PROFILE_NEXT(0);
00416    if (updateIRQJPEG_wp()) { 
00417       updateIRQCircbuf();
00418       updateIRQFocus(); 
00419       struct interframe_params_t* interframe= updateIRQ_interframe(); 
00420 
00421 //      interframe->frame_length=jpeg_len;
00422 //      interframe->signffff=0xffff;
00423       updateIRQ_Exif(interframe);
00424       updateFramePars(X3X3_I2C_FRAME, interframe);
00425       wake_up_interruptible(&circbuf_wait_queue); 
00426    } else {
00427       updateFramePars(X3X3_I2C_FRAME, NULL); 
00428    }
00429    PROFILE_NOW(1);
00430    wake_up_interruptible(&framepars_wait_queue); 
00431    tasklet_schedule(&tasklet_fpga); 
00432 
00433    EN_INTERRUPT(SMART);
00434 
00435    return IRQ_HANDLED;
00436 }
00437 
00460 
00461 
00462 //#define HISTOGRAMS_WAKEUP_ALWAYS 0
00463 void tasklet_fpga_function(unsigned long arg) {
00464   int hist_en;
00465   int tasklet_disable=get_globalParam(G_TASKLET_CTL);
00466   unsigned long thisFrameNumber=getThisFrameNumber();
00467   unsigned long prevFrameNumber=thisFrameNumber-1;
00468   unsigned long * hash32p=&(framepars[(thisFrameNumber-1) & PARS_FRAMES_MASK].pars[P_GTAB_R]);
00470   if ((getThisFrameNumber() ^ X3X3_I2C_FRAME)  & PARS_FRAMES_MASK) return; 
00471 
00472 
00473   PROFILE_NOW(2);
00474   switch ((tasklet_disable >> TASKLET_CTL_HISTY_BIT) & 7) {
00475      case TASKLET_HIST_NEVER:   
00476       hist_en=0;
00477       break;
00478      case TASKLET_HIST_HALF:    
00479       hist_en= ((thisFrameNumber & 1) ==0) || (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_Y));
00480       break;
00481      case TASKLET_HIST_QUATER:  
00482       hist_en= ((thisFrameNumber & 3) ==0) || (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_Y));
00483       break;
00484      case TASKLET_HIST_ONCE:    
00485       hist_en= ((thisFrameNumber & 7) ==0) || (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_Y));
00486       break;
00487      case TASKLET_HIST_RQONLY:  
00488       hist_en= (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_Y));
00489       break;
00490      case TASKLET_HIST_ALL:     
00491      default:                   
00492        hist_en=1;
00493   }
00494   if (hist_en) {
00496     set_histograms (prevFrameNumber, (1 << COLOR_Y_NUMBER), hash32p); 
00497     GLOBALPARS(G_HIST_Y_FRAME)=prevFrameNumber;           
00498     PROFILE_NOW(3);
00500     if ((getThisFrameNumber() ^ X3X3_I2C_FRAME)  & PARS_FRAMES_MASK) return; 
00501 #if HISTOGRAMS_WAKEUP_ALWAYS
00502   }
00503   wake_up_interruptible(&hist_y_wait_queue);    
00504 #else
00505     wake_up_interruptible(&hist_y_wait_queue);    
00506   }
00507 #endif
00509   if ((tasklet_disable & (1 << TASKLET_CTL_PGM))   == 0) {
00510       processPars (sensorproc, getThisFrameNumber(), get_globalParam(G_MAXAHEAD)); 
00511       PROFILE_NOW(4);
00512   }
00514   if ((getThisFrameNumber() ^ X3X3_I2C_FRAME)  & PARS_FRAMES_MASK) return; 
00515 
00516   switch ((tasklet_disable >> TASKLET_CTL_HISTC_BIT) & 7) {
00517      case TASKLET_HIST_NEVER:   
00518        hist_en=0;
00519       break;
00520      case TASKLET_HIST_HALF:    
00521       hist_en= ((thisFrameNumber & 1) ==0) || (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_C));
00522       break;
00523      case TASKLET_HIST_QUATER:  
00524       hist_en= ((thisFrameNumber & 3) ==0) || (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_C));
00525       break;
00526      case TASKLET_HIST_ONCE:    
00527       hist_en= ((thisFrameNumber & 7) ==0) || (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_C));
00528       break;
00529      case TASKLET_HIST_RQONLY:  
00530       hist_en= (get_imageParamsPrev(P_HISTRQ) & (1<<HISTRQ_BIT_C));
00531       break;
00532      case TASKLET_HIST_ALL:     
00533      default:                   
00534        hist_en=1;
00535   }
00536 /*
00537 GLOBALPARS(0x1040)=((thisFrameNumber & 1) ==0);
00538 GLOBALPARS(0x1041)=((thisFrameNumber & 3) ==0);
00539 GLOBALPARS(0x1042)=((thisFrameNumber & 7) ==0);
00540 GLOBALPARS(0x1043)=hist_en;
00541 GLOBALPARS(0x1044)=thisFrameNumber;
00542 */
00543   if (hist_en) {
00545     set_histograms (prevFrameNumber, 0xf, hash32p); 
00546     GLOBALPARS(G_HIST_C_FRAME)=prevFrameNumber;           
00547     PROFILE_NOW(5);
00549     if ((getThisFrameNumber() ^ X3X3_I2C_FRAME)  & PARS_FRAMES_MASK) return; 
00550 #if HISTOGRAMS_WAKEUP_ALWAYS
00551   }
00552   wake_up_interruptible(&hist_c_wait_queue);     
00553 #else
00554     wake_up_interruptible(&hist_c_wait_queue);   
00555   }
00556 #endif
00557 }
00558 
00562 void reset_compressor(void) {
00563   unsigned long flags;
00564   local_irq_save(flags);
00565   port_csp0_addr[X313_WA_COMP_CMD]= COMPCMD_RESET; 
00566   if (framepars) set_imageParamsR_all( P_COMPRESSOR_RUN, COMPRESSOR_RUN_STOP );
00567   else printk ("framepars is not initialized\n");
00569   JPEG_wp=0;
00570   JPEG_rp=0;
00571   updateIRQCircbuf(); 
00572   fpga_counter_prev=0;
00573   local_irq_restore(flags);
00574 }
00575 
00580 void camera_interrupts (int on) {
00581   MDF2(printk ("camera_interrupts(%d)\n",on));
00582   if (on) {
00583     EN_INTERRUPT(SMART);
00584   }  else {
00585     DIS_INTERRUPTS;
00586   }
00588   port_csp0_addr[X313_WA_SMART_IRQ]=0x8000;
00589 
00590   reg_intr_vect_rw_mask intr_mask;
00591   intr_mask = REG_RD(intr_vect, regi_irq, rw_mask);
00592   intr_mask.ext = on ? 1 : 0;
00593   REG_WR(intr_vect, regi_irq, rw_mask, intr_mask); 
00594 }
00595 
00596 
00597 int image_acq_open(struct inode *inode, struct file *filp) ;
00598 int image_acq_release(struct inode *inode, struct file *filp) ;
00599 loff_t image_acq_fops_lseek (struct file * file, loff_t offset, int orig) ;
00600 ssize_t image_acq_fops_write(struct file * file, const char * buf, size_t count, loff_t *off) ;
00601 int image_acq_mmap (struct file *file, struct vm_area_struct *vma) ;
00602 
00603 static struct file_operations image_acq_fops = {
00604    owner:    THIS_MODULE,
00605    llseek:   image_acq_fops_lseek,
00606 //   read:     image_acq_fops_read,
00607    write:    image_acq_fops_write,
00608 //   ioctl:    image_acq_ioctl,
00609    open:     image_acq_open,
00610    mmap:     image_acq_mmap,
00611    release:  image_acq_release
00612 };
00613 static int __init image_acq_init(void) {
00614    int res;
00615    sensorproc= &s_sensorproc;
00616    MDD1(printk("sensorproc=0x%x\n",(int) sensorproc));
00617    init_ccam_dma_buf_ptr();  
00618 
00619    res = register_chrdev(ELPHEL_MAJOR, elphel_cam_name, &image_acq_fops);
00620    if(res < 0) {
00621      printk(KERN_ERR "image_acq_init: couldn't get a major number %d.\n",ELPHEL_MAJOR);
00622      return res;
00623    }
00624    if(request_irq(EXT_INTR_VECT,
00625                   elphel_FPGA_interrupt,
00626                   SA_INTERRUPT, // SA_SHIRQ | SA_INTERRUPT if it is a shared one.
00627                   "Elphel FPGA interrupts",
00628                   NULL)) {
00629                printk(KERN_ERR "Can't allocate Elphel FPGA interrupts");
00630                return -EBUSY;
00631     }
00632     printk("Elphel FPGA interrupts initialized\n");
00633 //    init_waitqueue_head(&image_acq_wait_queue);
00634 //    DMA_buf_start=x313_dma_init();
00635   MDD1(printk("reset_compressor()\n"));
00636     reset_compressor(); 
00637   MDD1(printk("x313_dma_init()\n"));
00638     x313_dma_init();    
00639   MDD1(printk("init_pgm_proc ()\n"));
00640     init_pgm_proc ();   
00641   MDD1(printk("reset_qtables()\n"));
00642     reset_qtables(); 
00643     printk(X3X3_ELPHEL_DRIVER_NAME" - %d\n",ELPHEL_MAJOR);
00644     return 0;
00645 }
00646 
00647 
00648 int image_acq_open(struct inode *inode, struct file *filp) {
00649   return 0;
00650 }
00651 int image_acq_release(struct inode *inode, struct file *filp) {
00652   return 0;
00653 }
00654 loff_t image_acq_fops_lseek (struct file * file, loff_t offset, int orig) {
00655   return 0;
00656 }
00657 ssize_t image_acq_fops_write(struct file * file, const char * buf, size_t count, loff_t *off) {
00658   return 0;
00659 }
00660 int image_acq_mmap (struct file *file, struct vm_area_struct *vma) {
00661   return 0;
00662 }
00663 
00664 module_init(image_acq_init);
00665 MODULE_LICENSE("GPLv3.0");
00666 MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>.");
00667 MODULE_DESCRIPTION(X3X3_IMAGEACQ_DRIVER_NAME);

Generated on Fri Nov 28 00:06:23 2008 for elphel by  doxygen 1.5.1