⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xllp_camera.h

📁 xScale PXA270的串口程序
💻 H
字号:
/****************************************************************************** 
** INTEL CONFIDENTIAL
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors.  Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.

** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
********************************************************************************/
#ifndef _XLLP_CAMERA_H_
#define _XLLP_CAMERA_H_

#include "xllp_defs.h"
#include "xllp_dmac.h"

//////////////////////////////////////////////////////////////////////////////////////
//
//          Macros
//
//////////////////////////////////////////////////////////////////////////////////////
//
//  Sensor type
//
#define XLLP_CAMERA_TYPE_ADCM_2650               01
#define XLLP_CAMERA_TYPE_ADCM_2670               02
#define XLLP_CAMERA_TYPE_ADCM_2700               03
#define XLLP_CAMERA_TYPE_OMNIVISION_9640         04
#define XLLP_CAMERA_TYPE_MAX                     XLLP_CAMERA_TYPE_OMNIVISION_9640

//
//  Image format definition
//
#define XLLP_CAMERA_IMAGE_FORMAT_RAW8                0
#define XLLP_CAMERA_IMAGE_FORMAT_RAW9                1
#define XLLP_CAMERA_IMAGE_FORMAT_RAW10               2
                                                     
#define XLLP_CAMERA_IMAGE_FORMAT_RGB444              3
#define XLLP_CAMERA_IMAGE_FORMAT_RGB555              4
#define XLLP_CAMERA_IMAGE_FORMAT_RGB565              5
#define XLLP_CAMERA_IMAGE_FORMAT_RGB666_PACKED       6
#define XLLP_CAMERA_IMAGE_FORMAT_RGB666_PLANAR       7
#define XLLP_CAMERA_IMAGE_FORMAT_RGB888_PACKED		 8
#define XLLP_CAMERA_IMAGE_FORMAT_RGB888_PLANAR       9
#define XLLP_CAMERA_IMAGE_FORMAT_RGBT555_0          10  //RGB+Transparent bit 0
#define XLLP_CAMERA_IMAGE_FORMAT_RGBT888_0          11
#define XLLP_CAMERA_IMAGE_FORMAT_RGBT555_1          12  //RGB+Transparent bit 1  
#define XLLP_CAMERA_IMAGE_FORMAT_RGBT888_1          13

#define XLLP_CAMERA_IMAGE_FORMAT_YCBCR400           14
#define XLLP_CAMERA_IMAGE_FORMAT_YCBCR422_PACKED    15
#define XLLP_CAMERA_IMAGE_FORMAT_YCBCR422_PLANAR    16
#define XLLP_CAMERA_IMAGE_FORMAT_YCBCR444_PACKED    17
#define XLLP_CAMERA_IMAGE_FORMAT_YCBCR444_PLANAR    18
#define XLLP_CAMERA_IMAGE_FORMAT_MAX                XLLP_CAMERA_IMAGE_FORMAT_YCBCR444_PLANAR

//
//  Image Size definition
//
#define XLLP_CAMERA_IMAGE_SIZE_QQVGA				0x01
#define XLLP_CAMERA_IMAGE_SIZE_QVGA					0x02
#define XLLP_CAMERA_IMAGE_SIZE_VGA					0x04
#define XLLP_CAMERA_IMAGE_SIZE_SXGA					0x08
#define XLLP_CAMERA_IMAGE_SIZE_QQCIF				0x10
#define XLLP_CAMERA_IMAGE_SIZE_QCIF					0x20
#define XLLP_CAMERA_IMAGE_SIZE_CIF					0x40
#define XLLP_CAMERA_IMAGE_SIZE_INVALID				0x80


// Interrupt mask
#define XLLP_CAMERA_INTMASK_FIFO_OVERRUN            0x0001
#define XLLP_CAMERA_INTMASK_END_OF_FRAME            0x0002  
#define XLLP_CAMERA_INTMASK_START_OF_FRAME          0x0004
#define XLLP_CAMERA_INTMASK_CI_DISABLE_DONE         0x0008
#define XLLP_CAMERA_INTMASK_CI_QUICK_DISABLE        0x0010
#define XLLP_CAMERA_INTMASK_PARITY_ERROR            0x0020
#define XLLP_CAMERA_INTMASK_END_OF_LINE             0x0040
#define XLLP_CAMERA_INTMASK_FIFO_EMPTY              0x0080
#define XLLP_CAMERA_INTMASK_RCV_DATA_AVALIBLE       0x0100
#define XLLP_CAMERA_INTMASK_TIME_OUT                0x0200
#define XLLP_CAMERA_INTMASK_END_OF_DMA              0x0400

// Interrupt status
#define XLLP_CAMERA_INTSTATUS_FIFO_OVERRUN_0        0x00000001
#define XLLP_CAMERA_INTSTATUS_FIFO_OVERRUN_1        0x00000002
#define XLLP_CAMERA_INTSTATUS_FIFO_OVERRUN_2        0x00000004
#define XLLP_CAMERA_INTSTATUS_END_OF_FRAME          0x00000008  
#define XLLP_CAMERA_INTSTATUS_START_OF_FRAME        0x00000010
#define XLLP_CAMERA_INTSTATUS_CI_DISABLE_DONE       0x00000020
#define XLLP_CAMERA_INTSTATUS_CI_QUICK_DISABLE      0x00000040
#define XLLP_CAMERA_INTSTATUS_PARITY_ERROR          0x00000080
#define XLLP_CAMERA_INTSTATUS_END_OF_LINE           0x00000100
#define XLLP_CAMERA_INTSTATUS_FIFO_EMPTY_0          0x00000200
#define XLLP_CAMERA_INTSTATUS_FIFO_EMPTY_1          0x00000400
#define XLLP_CAMERA_INTSTATUS_FIFO_EMPTY_2          0x00000800
#define XLLP_CAMERA_INTSTATUS_RCV_DATA_AVALIBLE_0   0x00001000
#define XLLP_CAMERA_INTSTATUS_RCV_DATA_AVALIBLE_1   0x00002000
#define XLLP_CAMERA_INTSTATUS_RCV_DATA_AVALIBLE_2   0x00004000
#define XLLP_CAMERA_INTSTATUS_TIME_OUT              0x00008000
#define XLLP_CAMERA_INTSTATUS_END_OF_DMA            0x00010000

// Capture status
#define XLLP_CAMERA_STATUS_VIDEO_CAPTURE_IN_PROCESS 0x0001
#define XLLP_CAMERA_STATUS_RING_BUFFER_FULL         0x0002

//////////////////////////////////////////////////////////////////////////////////////
//
//          Structures
//
//////////////////////////////////////////////////////////////////////////////////////

typedef struct XLLP_Camera_Context_S XLLP_Camera_Context_T, *P_XLLP_Camera_Context_T;

typedef struct {
    XLLP_STATUS_T (*init)(P_XLLP_Camera_Context_T context);
    XLLP_STATUS_T (*deinit)(P_XLLP_Camera_Context_T);   
    XLLP_STATUS_T (*set_capture_format)(P_XLLP_Camera_Context_T);
    XLLP_STATUS_T (*start_capture)(P_XLLP_Camera_Context_T, unsigned int frames);
    XLLP_STATUS_T (*stop_capture)(P_XLLP_Camera_Context_T);
} XLLP_Camera_Function_T, *P_XLLP_Camera_Function_T;

// context 
typedef struct XLLP_Camera_Context_S {

    //
    // 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_XLLP_Camera_Function_T camera_functions;

    //
    // XLLP FILLED PARAMTER
    //
    XLLP_DMAC_CHANNEL_T dma_channels[3];
    unsigned int capture_status;
    
    //
    // XLLP 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;
} XLLP_Camera_Context_T, *P_XLLP_Camera_Context_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)
XLLP_STATUS_T XllpCameraInit( P_XLLP_Camera_Context_T camera_context );

// Power off sensor
XLLP_STATUS_T XllpCameraDeInit( P_XLLP_Camera_Context_T camera_context );


/***********************************************************************
 *
 * Capture APIs
 *
 ***********************************************************************/
// Set the image format
XLLP_STATUS_T XllpCameraSetCaptureFormat( P_XLLP_Camera_Context_T camera_context );

// take a picture and copy it into the ring buffer
XLLP_STATUS_T XllpCameraCaptureStillImage( P_XLLP_Camera_Context_T camera_context, unsigned int block_id );

// capture motion video and copy it the ring buffer
XLLP_STATUS_T XllpCameraStartVideoCapture( P_XLLP_Camera_Context_T camera_context, unsigned int block_id );

// disable motion video image capture
void XllpCameraStopVideoCapture( P_XLLP_Camera_Context_T camera_context );


/***********************************************************************
 *
 * Flow Control APIs
 *
 ***********************************************************************/
// Stop DMA transfer
void XllpCameraStopTransfer( P_XLLP_Camera_Context_T camera_context );

// Repeat transfer to current frame buffer
void XllpCameraRepeatTransfer( P_XLLP_Camera_Context_T camera_context );

// continue capture image to next available buffer
// Returns the continued buffer id, -1 means buffer full and no transfer started
void XllpCameraContinueTransfer( P_XLLP_Camera_Context_T camera_context ); 

// Return 1: there is available buffer, 0: buffer is full
int XllpCameraNextBufferAvailable( P_XLLP_Camera_Context_T camera_context );

// Check whether if there is enough buffer to resume transfer
int XllpCameraResumeBufferAvailable( P_XLLP_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 XllpCameraReleaseFrameBuffer( P_XLLP_Camera_Context_T camera_context, unsigned int frame_buffer_id ); 

// Returns the FrameBufferID for the first filled frame
// Note: -1 represents buffer empty
int XllpCameraGetFirstFrameBufferID( P_XLLP_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 XllpCameraGetLastFrameBufferID( P_XLLP_Camera_Context_T camera_context ); 


/***********************************************************************
 *
 * Buffer Info APIs
 *
 ***********************************************************************/
// Return: the number of frame buffers allocated for use.
unsigned int XllpCameraGetNumFrameBuffers( P_XLLP_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* XllpCameraGetFrameBufferAddress( P_XLLP_Camera_Context_T camera_context, unsigned int frame_buffer_id );

// Return the block id
int XllpCameraGetFrameBufferID( P_XLLP_Camera_Context_T camera_context, void* address );

/***********************************************************************
 *
 * Frame rate APIs
 *
 ***********************************************************************/
// Set desired frame rate
void XllpCameraSetCaptureFrameRate( P_XLLP_Camera_Context_T camera_context ); 

// return current setting
void XllpCameraGetCaptureFrameRate( P_XLLP_Camera_Context_T camera_context ); 


/***********************************************************************
 *
 * Interrupt APIs
 *
 ***********************************************************************/
// set interrupt mask 
void XllpCameraSetInterruptMask( P_XLLP_Camera_Context_T camera_context, unsigned int mask ); 

// get interrupt mask 
unsigned int XllpCameraGetInterruptMask( P_XLLP_Camera_Context_T camera_context ); 

// clear interrupt status
void XllpCameraClearInterruptStatus( P_XLLP_Camera_Context_T camera_context, unsigned int status );

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -