?? ch7024b.c
字號(hào):
//
//平臺(tái):LINUX
//名稱:CH7024驅(qū)動(dòng)程序
//作者:陳錫平
//日期:2006/08/22
//文件:ch7024.c
//
#include "mx1hw.h"
#include "khead.h"
#include "ch7024.h"
#include "i2c.h"
//
//240 x 320 PAL
//
#define init_len_ch7024_240x320_PAL (sizeof(init_reg_ch7024_240X320_PAL)/2)
static const unsigned char init_reg_ch7024_240X320_PAL[] = {
0x02, 0x00 ,
0x03, 0x03 ,
0x04, 0x0C , // 0x00
0x05, 0x40 ,
0x06, 0x40 ,
0x07, 0x40 ,
0x08, 0x80 ,
0x09, 0x04 ,
0x0A, 0x13 ,
0x0B, 0x03 ,//12MHZ
0x0C, 0x00 ,
0x0D, 0x00 ,//33
0x0E, 0x01 ,
0x0F, 0x00 ,
0x10, 0x01 ,
0x11, 0x08 ,
0x12, 0xF0 ,
0x13, 0x0E ,
0x14, 0x00 ,
0x15, 0x14 ,
0x16, 0x02 ,
0x17, 0x05 ,
0x18, 0x40 ,
0x19, 0xAC ,
0x1A, 0x04 ,
0x1B, 0x03 ,
0x1C, 0x80 ,
0x1D, 0x9E , // 0x9C
0x1E, 0x02 ,
0x1F, 0xEA ,
0x20, 0x02 ,
0x21, 0x8B ,
0x22, 0x00 ,
0x23, 0x80 ,
0x24, 0x00 ,
0x25, 0x00 ,
0x26, 0x00 ,
0x27, 0x00 ,
0x28, 0x0C ,
0x29, 0xEB ,
0x2A, 0x80 ,
0x2B, 0x10 ,
0x2C, 0x7A ,
0x2D, 0xC0 ,
0x2E, 0x36 ,
0x2F, 0x12 ,
0x30, 0x09 ,
0x31, 0x14 ,
0x32, 0x00 ,
0x33, 0x01 ,
0x34, 0x5E ,
0x35, 0x05 ,
0x36, 0x3B ,
0x37, 0xFF ,
0x62, 0x35 ,
0x63, 0xC2 , // 0xC0
0xFF
};
//
//320 x 240 PAL
//
#define init_len_ch7024_320x240_PAL (sizeof(init_reg_ch7024_320X240_PAL)/2)
static const unsigned char init_reg_ch7024_320X240_PAL[] = {
0x02, 0x00 ,
0x03, 0x03 ,
0x04, 0x0C , // 0x00
0x05, 0x40 ,
0x06, 0x40 ,
0x07, 0x40 ,
0x08, 0x80 ,
0x09, 0x04 ,
0x0A, 0x13 ,
0x0B, 0x04 ,
0x0C, 0x00 ,
0x0D, 0x33 ,
0x0E, 0x01 ,
0x0F, 0x00 ,
0x10, 0x01 ,
0x11, 0x09 ,
0x12, 0x40 ,
0x13, 0xAC ,
0x14, 0x00 ,
0x15, 0x63 , // 0x04
0x16, 0x02 ,
0x17, 0x04 ,
0x18, 0xF0 ,
0x19, 0x0E ,
0x1A, 0x04 ,
0x1B, 0x03 ,
0x1C, 0x80 ,
0x1D, 0x9E , // 0x9C
0x1E, 0x05 , //
0x1F, 0x1A ,
0x20, 0x00 ,
0x21, 0x83 , // 0x80
0x22, 0x00 ,
0x23, 0x7C , // 0x80
0x24, 0x00 ,
0x25, 0x00 ,
0x26, 0x00 ,
0x27, 0x00 ,
0x28, 0x0C ,
0x29, 0xEB ,
0x2A, 0x80 ,
0x2B, 0x10 ,
0x2C, 0x7A ,
0x2D, 0xC0 ,
0x2E, 0x36 ,
0x2F, 0x09 ,
0x30, 0x09 ,
0x31, 0x14 ,
0x32, 0x00 ,
0x33, 0x01 ,
0x34, 0x5E ,
0x35, 0x05 ,
0x36, 0x3B ,
0x37, 0xFF ,
0x62, 0x35 ,
0x63, 0xC2 , // 0xC0
0xFF
};
//
//640 x 480 PAL
//
#define init_len_ch7024_640x480_PAL (sizeof(init_reg_ch7024_640X480_PAL)/2)
static unsigned char init_reg_ch7024_640X480_PAL[] = {
};
static int gMajor = 0;
// functions and interface
static int ch7024_open(struct inode *inode, struct file *filp);
static int ch7024_release(struct inode *inode, struct file *filp);
static ssize_t ch7024_read(struct file *filp, char *buf, size_t size, loff_t * l);
static ssize_t ch7024_write(struct file *filp, const char *buf, size_t size, loff_t * l);
static int ch7024_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
struct file_operations ch7024_fops = {
// open:ch7024_open,
release:ch7024_release,
// read:ch7024_read,
// write:ch7024_write,
// ioctl:ch7024_ioctl,
};
int I2C_init()
{
return(I2C_write(0x02,0x00));
}
int ch7024_init()
{
unsigned char reg, data,* regs;
int rdata;
// regs=init_reg_ch7024_640X480_PAL;
// regs=init_reg_ch7024_320X240_PAL;
regs=init_reg_ch7024_240X320_PAL;
while (*regs!=0xff) {
reg =*(regs++);
data=*(regs++);
dprintch7024("write data %x to addr %x;\n",data,reg);
if (I2C_write(reg, data)!=0)
return -1;
}
if(I2C_read(0x00,&rdata)==0)
{
dprintch7024("Read The Chip Version Is %x\n",rdata);
}
else
{
return -1;
}
return 0;
}
static int ch7024_release(struct inode *inode, struct file *filp)
{
dprintch7024("*** close ***\n");
MOD_DEC_USE_COUNT;
return 0;
}
static devfs_handle_t devfs_handle;
int init_module()
{
int result;
printk("ch7024 driver " __DATE__ " / " __TIME__ "\n");
/* register our character device */
result = devfs_register_chrdev(0, "ch7024", &ch7024_fops);
if (result < 0) {
printk("ch7024 driver: Unable to register driver\n");
return -ENODEV;
}
devfs_handle = devfs_register(NULL, "ch7024", DEVFS_FL_DEFAULT,
result, 0, S_IFCHR | S_IRUSR | S_IWUSR, &ch7024_fops, NULL);
printk("make node for ch7024 with 'mknod ch7024 c %d 0'\n", result);
gMajor = result;
if(I2C_init()!=0)
{
printk("I2C write error!\n");
return (0);
}
if(ch7024_init()!=0)
dprintch7024("ch7024 init error!\n");
else
dprintch7024("ch7024 init ok!\n");
return 0;
}
void cleanup_module()
{
if (gMajor > 0) {
devfs_unregister_chrdev(gMajor, "ch7024");
devfs_unregister(devfs_handle);
}
// free_buffer();
printk("Say goodbye to ch7024\n");
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -