📄 pxa_camera.h
字号:
CI_INT_CQD = 0x00000010, CI_INT_PAR_ERR = 0x00000020, CI_INT_EOL = 0x00000040, CI_INT_FEMPTY = 0x00000080, CI_INT_RDAV = 0x00000100, CI_INT_FTO = 0x00000200, CI_INT_ALL = 0x000003FF} CI_INTERRUPT_MASK;#define CI_INT_MAX 10typedef enum CI_MODE { CI_MODE_MP, // Master-Parallel CI_MODE_SP, // Slave-Parallel CI_MODE_MS, // Master-Serial CI_MODE_EP, // Embedded-Parallel CI_MODE_ES // Embedded-Serial} CI_MODE;typedef enum { CI_FR_ALL = 0, // Capture all incoming frames CI_FR_1_2, // Capture 1 out of every 2 frames CI_FR_1_3, // Capture 1 out of every 3 frames CI_FR_1_4, CI_FR_1_5, CI_FR_1_6, CI_FR_1_7, CI_FR_1_8} CI_FRAME_CAPTURE_RATE;typedef enum { CI_FIFO_THL_32 = 0, CI_FIFO_THL_64, CI_FIFO_THL_96} CI_FIFO_THRESHOLD;typedef struct { unsigned int BFW; unsigned int BLW;} CI_MP_TIMING, CI_MS_TIMING;typedef struct { unsigned int BLW; unsigned int ELW; unsigned int HSW; unsigned int BFPW; unsigned int FSW; unsigned int BFW; unsigned int EFW; unsigned int VSW; } CI_SP_TIMING;typedef enum { CI_DATA_WIDTH4 = 0x0, CI_DATA_WIDTH5 = 0x1, CI_DATA_WIDTH8 = 0x2, CI_DATA_WIDTH9 = 0x3, CI_DATA_WIDTH10= 0x4 } CI_DATA_WIDTH;/* * Structures */typedef struct camera_context_s camera_context_t, *p_camera_context_t;typedef struct { int (*init)(p_camera_context_t context); int (*deinit)(p_camera_context_t); int (*set_capture_format)(p_camera_context_t); int (*start_capture)(p_camera_context_t, unsigned int frames); int (*stop_capture)(p_camera_context_t);} camera_function_t, *p_camera_function_t;// context struct camera_context_s { // syncronization stuff atomic_t refcount; /* * DRIVER FILLED PARAMTER */ // sensor info unsigned int sensor_type; // capture image info unsigned int capture_width; unsigned int capture_height; unsigned int capture_input_format; unsigned int capture_output_format; // frame rate control unsigned int frame_rate; // ring buffers // note: must pass in 8 bytes aligned address void *buffer_virtual; void *buffer_physical; unsigned int buf_size; // memory for dma descriptors, layout: // dma descriptor chain 0, // dma descriptor chain 1, // ... void *dma_descriptors_virtual; void *dma_descriptors_physical; unsigned int dma_descriptors_size; // os mapped register address unsigned int clk_reg_base; unsigned int ost_reg_base; unsigned int gpio_reg_base; unsigned int ci_reg_base; unsigned int board_reg_base; // function dispatch table p_camera_function_t camera_functions; /* * FILLED PARAMTER */ int dma_channels[3]; unsigned int capture_status; /* * INTERNALLY USED: DON'T TOUCH! */ unsigned int block_number, block_size; unsigned int block_header, block_tail; unsigned int fifo0_descriptors_virtual, fifo0_descriptors_physical; unsigned int fifo1_descriptors_virtual, fifo1_descriptors_physical; unsigned int fifo2_descriptors_virtual, fifo2_descriptors_physical; unsigned int fifo0_num_descriptors; unsigned int fifo1_num_descriptors; unsigned int fifo2_num_descriptors; unsigned int fifo0_transfer_size; unsigned int fifo1_transfer_size; unsigned int fifo2_transfer_size; struct page **page_array; unsigned int pages_allocated; unsigned int page_aligned_block_size; unsigned int pages_per_block; unsigned int pages_per_fifo0; unsigned int pages_per_fifo1; unsigned int pages_per_fifo2;#ifdef CONFIG_PM struct pm_dev *pmdev;#endif#ifdef CONFIG_DPM int dma_started;#endif};/* * Camera capture info structure is used by the application to determine * the current state of capturing ring-buffer */typedef struct camera_capture_info_s { int first_frame_id; /* first captured frame available in the ring buffer */ int last_frame_id; /* last captured frame available in the ring buffer */ int frames; /* total amount of frames in the ring buffer */} camera_capture_info_t;/* * Prototypes *//*********************************************************************** * * Init/Deinit APIs * ***********************************************************************/// Setup the sensor type, configure image capture format (RGB, yuv 444, yuv 422, yuv 420, packed | planar, MJPEG) regardless// of current operating mode (i.e. sets mode for both still capture and video capture)int camera_init( p_camera_context_t camera_context );// Power off sensorint camera_deinit( p_camera_context_t camera_context );/*********************************************************************** * * Capture APIs * ***********************************************************************/// Set the image formatint camera_set_capture_format( p_camera_context_t camera_context );// take a picture and copy it into the ring bufferint camera_capture_still_image( p_camera_context_t camera_context, unsigned int block_id );// capture motion video and copy it the ring bufferint camera_start_video_capture( p_camera_context_t camera_context, unsigned int block_id );// disable motion video image capturevoid camera_stop_video_capture( p_camera_context_t camera_context );/*********************************************************************** * * Flow Control APIs * ***********************************************************************/// continue capture image to next available buffer// Returns the continued buffer id, -1 means buffer full and no transfer startedvoid camera_continue_transfer( p_camera_context_t camera_context ); // Return 1: there is available buffer, 0: buffer is fullint camera_next_buffer_available( p_camera_context_t camera_context );// Application supplies the FrameBufferID to the driver to tell it that the application has completed processing of the given frame buffer, and that buffer is now available for re-use.void camera_release_frame_buffer( p_camera_context_t camera_context, unsigned int frame_buffer_id ); // Returns the FrameBufferID for the first filled frame// Note: -1 represents buffer emptyint camera_get_first_frame_buffer_id( p_camera_context_t camera_context ); /*Returns the FrameBufferID for the last filled frame, this would be used if we were polling for image completion data, or we wanted to make sure there were no frames waiting for us to process.Note: -1 represents buffer empty*/int camera_get_last_frame_buffer_id( p_camera_context_t camera_context ); /*********************************************************************** * * Buffer Info APIs * ***********************************************************************/// Return: the number of frame buffers allocated for use.unsigned int camera_get_num_frame_buffers( p_camera_context_t camera_context );/* FrameBufferID is a number between 0 and N-1, where N is the total number of frame buffers in use. Returns the address of the given frame buffer. The application will call this once for each frame buffer at application initialization only.*/void* camera_get_frame_buffer_addr( p_camera_context_t camera_context, unsigned int frame_buffer_id );// Return the block idint camera_get_frame_buffer_id( p_camera_context_t camera_context, void* address );/*********************************************************************** * * Frame rate APIs * ***********************************************************************/// Set desired frame ratevoid camera_set_capture_frame_rate( p_camera_context_t camera_context ); // return current settingvoid camera_get_capture_frame_rate( p_camera_context_t camera_context ); /*********************************************************************** * * Interrupt APIs * ***********************************************************************/// set interrupt mask void camera_set_int_mask( p_camera_context_t camera_context, unsigned int mask ); // get interrupt mask unsigned int camera_get_int_mask( p_camera_context_t camera_context ); // clear interrupt statusvoid camera_clear_int_status( p_camera_context_t camera_context, unsigned int status );// gpio initvoid camera_gpio_init(void);//-------------------------------------------------------------------------------------------------------// Configuration APIs//-------------------------------------------------------------------------------------------------------void ci_set_frame_rate(CI_FRAME_CAPTURE_RATE frate);CI_FRAME_CAPTURE_RATE ci_get_frame_rate(void);void ci_set_image_format(CI_IMAGE_FORMAT input_format, CI_IMAGE_FORMAT output_format); void ci_set_mode(CI_MODE mode, CI_DATA_WIDTH data_width);void ci_configure_mp(unsigned int PPL, unsigned int LPF, CI_MP_TIMING* timing);void ci_configure_sp(unsigned int PPL, unsigned int LPF, CI_SP_TIMING* timing);void ci_configure_ms(unsigned int PPL, unsigned int LPF, CI_MS_TIMING* timing);void ci_configure_ep(int parity_check);void ci_configure_es(int parity_check);void ci_set_clock(unsigned int clk_regs_base, int pclk_enable, int mclk_enable, unsigned int mclk_khz);void ci_set_polarity(int pclk_sample_falling, int hsync_active_low, int vsync_active_low);void ci_set_fifo( unsigned int timeout, CI_FIFO_THRESHOLD threshold, int fifo1_enable, int fifo2_enable);void ci_set_int_mask( unsigned int mask);void ci_clear_int_status( unsigned int status);void ci_set_reg_value( unsigned int reg_offset, unsigned int value);int ci_get_reg_value(unsigned int reg_offset);void ci_reset_fifo(void);unsigned int ci_get_int_mask(void);unsigned int ci_get_int_status(void);void ci_slave_capture_enable(void);void ci_slave_capture_disable(void);//-------------------------------------------------------------------------------------------------------// Control APIs//-------------------------------------------------------------------------------------------------------int ci_init(void);void ci_deinit(void);void ci_enable( int dma_en);int ci_disable(int quick);// IRQvoid pxa_camera_irq(int irq, void *dev_id, struct pt_regs *regs);#endif /* __PXA_CAMERA_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -