📄 cim.patch
字号:
diff -Nbur linux26-cvs/drivers/char/au1xxx_cim.c linux26-cvs.camera/drivers/char/au1xxx_cim.c--- linux26-cvs/drivers/char/au1xxx_cim.c 1969-12-31 18:00:00.000000000 -0600+++ linux26-cvs.camera/drivers/char/au1xxx_cim.c 2005-08-30 15:47:51.000000000 -0500@@ -0,0 +1,1208 @@++/*+* Alchemy Camera Interface (CIM) driver+*+* Copyright 2004 Advanced Micro Devices, Inc+*+* 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.+*+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN+* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+*+* You should have received a copy of the GNU General Public License along+* with this program; if not, write to the Free Software Foundation, Inc.,+* 675 Mass Ave, Cambridge, MA 02139, USA.+*/++#include <linux/module.h>+#include <linux/config.h>+#include <linux/types.h>+#include <linux/kernel.h>+#include <linux/miscdevice.h>+#include <linux/init.h>+#include <linux/mm.h>+#include <linux/highmem.h>+#include <linux/pagemap.h>+#include <asm/uaccess.h>+#include <asm/io.h>+#include <asm/mach-au1x00/au1000.h>+#include <asm/mach-au1x00/au1xxx_dbdma.h>+#include <asm/irq.h>+#include <asm/mach-au1x00/au1xxx_cim.h>+#include <asm/mach-au1x00/au1xxx_psc.h>+#include <asm/mman.h>+++#ifdef CONFIG_MIPS_PB1200+ #include <asm/mach-pb1x00/pb1200.h>+#endif++#ifdef CONFIG_MIPS_DB1200+ #include <asm/mach-db1x00/db1200.h>+#endif+++/*+Camera Interface Driver will always work in DBDMA Mode. +PIO Mode will result in OverFlow Error+*/++/*+* Global Variables+*/++#define CIM_NAME "au1xxx_cim"+#define CIM_MAJOR 238+#define VERSION "1.2"++#define MAX_DBDMA_CHANNEL 3 /* Number of DMA channel used by CIM interface*/+#define MAX_DEVICE_CMD 115 /*Max Command Send over SMbus to configure external camera*/+#define NUM_DBDMA_DESCRIPTORS 1 /* Number of descriptor used*/+#define MAX_FRAME_SIZE (1280*960) ++//#define DEBUG 1+#ifdef DEBUG +#define DPRINTK(fmt,args...) printk("%s: " fmt,__FUNCTION__, ## args) +#else+#define DPRINTK(fmt, args...)+#endif++uint32 volatile nInterruptDoneNumber = 0;+uint32 volatile ciminterruptcheck = 0;+int prev_mode = 0;+int check_mode=0;+uint32 DBDMA_SourceID[]={DSCR_CMD0_CIM_RXA,DSCR_CMD0_CIM_RXB,DSCR_CMD0_CIM_RXC}; +void *mem_buf; ++extern int pb1550_wm_codec_write(u8 , u8 , u8 );+++static AU1200_CIM * const au1200_cim = (AU1200_CIM*)CIM_BASE_ADDRESS;++typedef struct cim_cmos_camera_config+{+ uint32 frame_width; /* Frame Width (Pixel per Line)*/+ uint32 frame_height;/* Frame Height*/ + unsigned char camera_name[32];/* Camera Name (Display/Debug Purpose)*/+ unsigned char camera_mode[32]; /* Camera Mode(Display/Debug Purpose)*/ + uint32 cmos_output_format; /*CMOS Camera output (Bayer, CCIR656*/+ uint32 camera_resformat; /* Camera Mode(Display/Debug Purpose)*/+ uint32 au1200_dpsmode; /* Data Pattern Select ie: Mode on Camera Interface (BAYER, YUV, RAW)*/+ uint32 au1200_baymode; /* Mode within BAYER mode*/+ uint32 dbdma_channel;/* Number of DBDMA channels to be used */+ u8 device_addr; /*Camera Device address*/+ uint32 cmd_size; /*Number of device sub register to be configured over SMBus*/ + u8 config_cmd[MAX_DEVICE_CMD][2]; /*2x2 array for sub device address and values*/+}CAMERA;+++typedef struct cim_camera_runtime+{+ chan_tab_t **ChannelArray[MAX_DBDMA_CHANNEL]; /* Pointer to DBDMA structure*/ + void *memory[MAX_DBDMA_CHANNEL]; /*Number of DMA Channel*/+ uint32 nTransferSize[MAX_DBDMA_CHANNEL]; /*Transfer size for DMA descriptor*/+ CAMERA *cmos_camera; /*Pointer to Camera Structure*/++}CAMERA_RUNTIME;+++CAMERA_RUNTIME cam_base;+CAMERA_RUNTIME* pcam_base=&cam_base;++/* ***************************************************+Configurations for Different Mode of Different Cameras+****************************************************** */++CAMERA modes[]=+{+ { /* Omnivision OV9640 Camera 1280x960 Mode (SXGA) in "Pass Thru Mode"+ 1.3 MP at 15 Fps*/++ /* frame width=1280 */ 1280,+ /* frame heigth=960 */ 960,+ /* camera name */ "omnivision",+ /* camera mode */ "raw_SXGA",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ RAW_SXGA,+ /* DPS mode */ CIM_CONFIG_RAW,+ /* Bayer Mode*/ CIM_CONFIG_BGGR, + /* dbdma channel */ 1,+ /* Device Address*/ 0x30,+ /* No of Sub Register*/ 50,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x05},{0x11,0x80},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x2a},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ }+ + }, + { /* Omnivision OV9640 Camera 640x480 Mode (VGA) in "Pass Through Mode" */++ /* frame width=640 */ 640,+ /* frame heigth=480 */ 480,+ /* camera name */ "omnivision",+ /* camera mode */ "raw_VGA",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ RAW_VGA,+ /* DPS mode */ CIM_CONFIG_RAW,+ /* Bayer Mode */ CIM_CONFIG_BGGR,+ /* dbdma channel */ 1, + /* Device Address */ 0x30,+ /* No of Sub Register */ 54,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x45},{0x11,0x81},{0x0c, 0x04},{0x0d, 0x40},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},{0x73, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x2e},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ }++++ }, + { /* Omnivision OV9640 Camera 352x288 Mode CIF "Pass Through Mode"*/++ /* frame width=640 */ 352,+ /* frame heigth=480 */ 288,+ /* camera name */ "omnivision",+ /* camera mode */ "raw_CIF",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ RAW_CIF,+ /* DPS mode */ CIM_CONFIG_RAW,+ /* Bayer Mode */ CIM_CONFIG_BGGR, + /* dbdma channel */ 1,+ /* Device Address */ 0x30,+ /* No of Sub Register */ 54,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x25},{0x11,0x80},{0x0c, 0x04},{0x0d, 0x40},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},{0x73, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ }++ }, + { /* Omnivision OV9640 Camera 320x240 Mode (QVGA) in "Pass Through Mode"*/++ /* frame width=320 */ 320,+ /* frame heigth=240 */ 240,+ /* camera name */ "omnivision",+ /* camera mode */ "raw_QVGA",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ RAW_QVGA,+ /* DPS mode */ CIM_CONFIG_RAW,+ /* Bayer Mode */ CIM_CONFIG_BGGR, + /* dbdma channel */ 1,+ /* Device Address */ 0x30,+ /* No of Sub Register */ 54,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x15},{0x11,0x83},{0x0c, 0x04},{0x0d, 0xc0},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},{0x73, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ } ++ },+ { /* Omnivision OV9640 Camera 176x144 QCIF Mode "Pass Through Mode"*/++ /* frame width=320 */ 176,+ /* frame heigth=240 */ 144,+ /* camera name */ "omnivision",+ /* camera mode */ "raw_QCIF",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ RAW_QCIF,+ /* DPS mode */ CIM_CONFIG_RAW,+ /* Bayer Mode */ CIM_CONFIG_BGGR, + /* dbdma channel */ 1,+ /* Device Address */ 0x30,+ /* No of Sub Register */ 54,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x0D},{0x11,0x80},{0x0c, 0x04},{0x0d, 0xc0},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},{0x73, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x6f},{0x3c, 0x60},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ } ++ },+ + /* Omnivision OV9640 BAYER*/+ { /* Omnivision OV9640 Camera 1280x960 Mode (SXGA) in BAYER Mode (Planar)*/++ /* frame width=1280 */ 1280,+ /* frame heigth=960 */ 960,+ /* camera name */ "omnivision",+ /* camera mode */ "bayer_SXGA",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ BAYER_SXGA,+ /* DPS mode */ CIM_CONFIG_BAYER,+ /* Bayer Mode*/ CIM_CONFIG_BGGR, + /* dbdma channel */ 3,+ /* Device Address*/ 0x30,+ /* No of Sub Register*/ 50,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x05},{0x11,0x80},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x2a},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ }++ }, /* 1280x960*/ + + { /* Omnivision OV9640 Camera 640x480 Mode (VGA) in BAYER Mode (Planar)*/++ /* frame width=640 */ 640,+ /* frame heigth=480 */ 480,+ /* camera name */ "omnivision",+ /* camera mode */ "bayer_VGA",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ BAYER_VGA,+ /* DPS mode */ CIM_CONFIG_BAYER,+ /* Bayer Mode */ CIM_CONFIG_BGGR,+ /* dbdma channel */ 3,+ /* Device Address */ 0x30,+ /* No of Sub Register */ 54,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x45},{0x11,0x81},{0x0c, 0x04},{0x0d, 0x40},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},{0x73, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x2e},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ }++ }, + { /* Omnivision OV9640 Camera 352x288 CIF Mode in BAYER Mode (Planar)*/++ /* frame width=640 */ 352,+ /* frame heigth=480 */ 288,+ /* camera name */ "omnivision",+ /* camera mode */ "bayer_CIF",+ /* Cmos output format*/ CMOS_RAW,+ /* Resolution Format */ BAYER_CIF,+ /* DPS mode */ CIM_CONFIG_BAYER,+ /* Bayer Mode */ CIM_CONFIG_BGGR, + /* dbdma channel */ 3,+ /* Device Address */ 0x30,+ /* No of Sub Register */ 54,+ /* Array Initialization*/ {+ {0x12, 0x80},{0x12, 0x25},{0x11,0x80},{0x0c, 0x04},{0x0d, 0x40},{0x3b, 0x00},{0x33, 0x02},+ {0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},+ {0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},{0x73, 0x70},{0x74, 0x60},+ {0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},+ {0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},+ {0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},+ {0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},+ {0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca}, + {0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},+ {0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},++ }++ }, + { /* Omnivision OV9640 Camera 320x240 Mode (QVGA) in BAYER Mode (Planar)*/++ /* frame width=320 */ 320,+ /* frame heigth=240 */ 240,+ /* camera name */ "omnivision",+ /* camera mode */ "bayer_QVGA",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -