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

📄 pxaovcamera.h

📁 ov2640驱动开发
💻 H
字号:
/* ovpxacamera - header file for pxa OV camera driver 
 *	
 * Copyrith (c) 2006, OmniVision
 * 	
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
 *
 * OmniVision is a trademark of OmniVision Technologies, Inc. 
 */

#ifndef _OVPXACAMERA_H_
#define _OVPXACAMERA_H_
#include <linux/pxa_ov_camera.h>
#include <linux/videodev.h>
#define WCAM_VIDIOCSCAMREG  	_IOW('v', 211, int)
#define WCAM_VIDIOCGCAMREG   	_IOR('v', 212, int)
#define WCAM_VIDIOCSCIREG    	_IOW('v', 213, int)
#define WCAM_VIDIOCGCIREG    	_IOR('v', 214, int)
#define WCAM_VIDIOCSINFOR	_IOW('v', 215, int)
#define WCAM_VIDIOCGINFOR	_IOR('v', 216, int)
#define WCAM_VIDIOCSSTILL		217
#define WCAM_VIDIOCCAMERACHIP   _IOW('v', 218, int) 

//For GUI control command
#define WCAM_VIDIOCSWHITEBALANCE 250
#define WCAM_VIDIOCGWHITEBALANCE 251
#define WCAM_VIDIOCSEXPCOMPEN	 252
#define WCAM_VIDIOCGEXPCOMPEN	 253
#define WCAM_VIDIOCSROTATEMODE	 254
#define WCAM_VIDIOCGROTATEMODE	 255
#define WCAM_VIDIOCSPHOTOEFFECT	256
#define WCAM_VIDIOCGPHOTOEFFECT	257
#define WCAM_VIDIOCSFOCUS	 258
#define WCAM_VIDIOCGFOCUS	 259
#define WCAM_VIDIOCSLCDMODE 260
#define WCAM_VIDIOCGLASTFRAME 261
#define WCAM_VIDIOCGRAWFRAME 262
#define WCAM_VIDIOCSNIGHTMODE 263

/*videodev.h*/
#define VID_HARDWARE_OVCAMERA 60

/*
Bpp definition
*/

#define YUV422_BPP				16
#define RGB565_BPP				16
#define RGB666_UNPACKED_BPP       32
#define RGB666_PACKED_BPP         24

//#define CI_INT_MAX 10

//#define VID_HARDWARE_PXA_CAMERA 	50 /* subject to change */

#define STATUS_FAILURE	(0)
#define STATUS_SUCCESS	(1)
#define STATUS_WRONG_PARAMETER  -1

#ifdef CONFIG_CAMERA_OV9640
#define CIBR0_PHY       (0x50000000 + 0x28)
#define CIBR1_PHY       (0x50000000 + 0x30)
#define CIBR2_PHY       (0x50000000 + 0x38)
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*Macros*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*GPIO and CIF pin definitions*/
#define CIF_PD       50
#define CIF_RST      19
#define CIF_MCLK     23
#define CIF_PCLK     54
#define CIF_LV       85
#define CIF_FV       84
#define CIF_DD0      27
#define CIF_DD1      114
#define CIF_DD2      51
#define CIF_DD3      115 
#define CIF_DD4      95
#define CIF_DD5      94 
#define CIF_DD6      17
#define CIF_DD7      108

#define CIF_PD_MD      (CIF_PD   | GPIO_OUT)
#define CIF_RST_MD     (CIF_RST  | GPIO_OUT) 
#define CIF_MCLK_MD    (CIF_MCLK | GPIO_ALT_FN_1_OUT)
#define CIF_PCLK_MD    (CIF_PCLK | GPIO_ALT_FN_3_IN)
#define CIF_LV_MD      (CIF_LV   | GPIO_ALT_FN_3_IN)
#define CIF_FV_MD      (CIF_FV   | GPIO_ALT_FN_3_IN)
#define CIF_DD0_MD     (CIF_DD0  | GPIO_ALT_FN_3_IN)
#define CIF_DD1_MD     (CIF_DD1  | GPIO_ALT_FN_1_IN)
#define CIF_DD2_MD     (CIF_DD2  | GPIO_ALT_FN_1_IN)
#define CIF_DD3_MD     (CIF_DD3  | GPIO_ALT_FN_2_IN)
#define CIF_DD4_MD     (CIF_DD4  | GPIO_ALT_FN_2_IN)
#define CIF_DD5_MD     (CIF_DD5  | GPIO_ALT_FN_2_IN)
#define CIF_DD6_MD     (CIF_DD6  | GPIO_ALT_FN_2_IN)
#define CIF_DD7_MD     (CIF_DD7  | GPIO_ALT_FN_1_IN)


//Image format definition

#define CAMERA_IMAGE_FORMAT_MAX                CAMERA_IMAGE_FORMAT_JPEG

// Interrupt mask
#define CAMERA_INTMASK_FIFO_OVERRUN            0x0001
#define CAMERA_INTMASK_END_OF_FRAME            0x0002  
#define CAMERA_INTMASK_START_OF_FRAME          0x0004
#define CAMERA_INTMASK_CI_DISABLE_DONE         0x0008
#define CAMERA_INTMASK_CI_QUICK_DISABLE        0x0010
#define CAMERA_INTMASK_PARITY_ERROR            0x0020
#define CAMERA_INTMASK_END_OF_LINE             0x0040
#define CAMERA_INTMASK_FIFO_EMPTY              0x0080
#define CAMERA_INTMASK_RCV_DATA_AVALIBLE       0x0100
#define CAMERA_INTMASK_TIME_OUT                0x0200
#define CAMERA_INTMASK_END_OF_DMA              0x0400

// Interrupt status
#define CAMERA_INTSTATUS_FIFO_OVERRUN_0        0x00000001
#define CAMERA_INTSTATUS_FIFO_OVERRUN_1        0x00000002
#define CAMERA_INTSTATUS_FIFO_OVERRUN_2        0x00000004
#define CAMERA_INTSTATUS_END_OF_FRAME          0x00000008  
#define CAMERA_INTSTATUS_START_OF_FRAME        0x00000010
#define CAMERA_INTSTATUS_CI_DISABLE_DONE       0x00000020
#define CAMERA_INTSTATUS_CI_QUICK_DISABLE      0x00000040
#define CAMERA_INTSTATUS_PARITY_ERROR          0x00000080
#define CAMERA_INTSTATUS_END_OF_LINE           0x00000100
#define CAMERA_INTSTATUS_FIFO_EMPTY_0          0x00000200
#define CAMERA_INTSTATUS_FIFO_EMPTY_1          0x00000400
#define CAMERA_INTSTATUS_FIFO_EMPTY_2          0x00000800
#define CAMERA_INTSTATUS_RCV_DATA_AVALIBLE_0   0x00001000
#define CAMERA_INTSTATUS_RCV_DATA_AVALIBLE_1   0x00002000
#define CAMERA_INTSTATUS_RCV_DATA_AVALIBLE_2   0x00004000
#define CAMERA_INTSTATUS_TIME_OUT              0x00008000
#define CAMERA_INTSTATUS_END_OF_DMA            0x00010000

// Capture status
#define CAMERA_STATUS_VIDEO_CAPTURE_IN_PROCESS 	0x0001
#define CAMERA_STATUS_RING_BUFFER_FULL         	     	0x0002
#define CAMERA_STATUS_STILLIMAGE_CAPTURE_IN_PROCESS	0x0004

//===============================================================================
//
//
//
//===============================================================================
typedef struct camerachip_protocol  *p_camerachip_protocol_t;

typedef struct ovcamera_context_s ovcamera_context_t, *p_ovcamera_context_t;

/*camera structures*/
typedef struct {
	int (*init) ( p_ovcamera_context_t );
	int (*deinit) ( p_ovcamera_context_t );
	int (*capture_set_format) ( p_ovcamera_context_t );
	int (*capture_start) ( p_ovcamera_context_t, unsigned int );
	int (*capture_stop) ( p_ovcamera_context_t );
	int (*command) ( p_ovcamera_context_t, unsigned int, void *param);
	int (*power_management) ( p_ovcamera_context_t, int );
} ovcamera_function_t, *p_ovcamera_function_t;

/*context*/
struct ovcamera_context_s {
	// syncronization stuff
	atomic_t	count;
	
	//sensor type
	unsigned int sensor_type;
		
	//
	struct video_capability 	vc;
	struct video_window 	vw;
	struct video_picture	vp;
	struct capture_format	cf;
	unsigned int capture_mode;
	unsigned int capture_height;
	unsigned int capture_width;
	int 	frame_rate;
	
	// ring buffers
    // note: must pass in 8 bytes aligned address
    void *buffer_virtual;
    void *buffer_physical;
    unsigned int buf_size;
    void *image_buffer_virtual;
    void *image_buffer_physical;
    struct list_head buf_head;
    unsigned int image_buf_size;
	 unsigned int block_header_t;
    unsigned int block_tail_t;
    
	//ring buffers
	//note: must pass in 8 bytes aligned address
	void	*p_buffer_virtual;
	void 	*p_buffer_physical;
	unsigned int 	ui_buffer_size;

	void	*dma_descriptors_virtual;
	void 	*dma_descriptors_physical;
	unsigned int 	dma_descriptors_size;
	//memory for DMA
	void	*p_dmadest_virtual;
	void 	*p_dmadest_physical;
	unsigned int 	ui_dmadest_size;
	
	//os mapped register address
	unsigned int 	ui_clk_reg_base;
	unsigned int 	ui_ost_reg_base;
	unsigned int 	ui_gpio_reg_base;
	unsigned int 	ui_ci_reg_base;
	unsigned int 	ui_board_reg_base;
	
	//function dispatch table
	p_ovcamera_function_t camera_functions;

	//
	int dma_channels[3];
	unsigned int ui_capture_status;
	 

	/*
	INTERNALLY USERD: 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	fifo0_num_descriptors,	fifo0_transfer_size;
	unsigned int	fifo1_descriptors_virtual,	fifo1_descriptors_physical;
	unsigned int	fifo1_num_descriptors,	fifo1_transfer_size;
	unsigned int	fifo2_descriptors_virtual,	fifo2_descriptors_physical;
	unsigned int	fifo2_num_descriptors,	fifo2_transfer_size;
	
	struct page	**buf_page_array;
	
	unsigned int	total_pages;
	unsigned int	page_aligned_block_size;
	unsigned int	pages_per_block;

	unsigned int	ci_disalbe_completed;
};



//=========================================================
//
//==========================================================
void ovcamerachip_gpio_init ( void );
void ovcamerachip_clock_set ( unsigned int clk_regs_base, int pclk_enable, int mclk_enable, unsigned int mclk_khz);

#endif


⌨️ 快捷键说明

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