📄 saa7113.c
字号:
/* extdrv/peripheral/vad/saa7113.c
*
*
* Copyright (c) 2006 Hisilicon Co., Ltd.
*
* 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 program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
*
*
* History:
* 17-Apr-2006 create this file
*
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <asm/hardware.h>
#include <asm/bitops.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include "hi_i2c.h"
#include "video_def.h"
#define I2C_SAA7113 0x48
static const unsigned char saa7113_data[] = {
0x01, 0x08,
0x02, 0xc0, //0xc0 : cvbs for AI11
0x03, 0x33,
0x04, 0x00,
0x05, 0x00,
0x06, 0xe9,
0x07, 0x00,
0x08, 0xb8,
0x09, 0x01,
0x0a, 0x80,
0x0b, 0x47,
0x0c, 0x40,
0x0d, 0x00,
0x0e, 0x01,
0x0f, 0x0f,
0x10, 0x00,
0x11, 0x0C,
0x12, 0x01,
0x13, 0x00,
0x15, 0x00,
0x16, 0x00,
0x17, 0x00,
0x40, 0x02,
0x58, 0x00,
0x59, 0x54,
0x5a, 0x07,
0x5b, 0x83,
0x5e, 0x00,
};
/***********************************************************************************/
static int write_regs(unsigned char *pu8data,unsigned int u32len)
{
int i = 0;
while (i < u32len)
{
hi_i2c_write(I2C_SAA7113, pu8data[i], pu8data[i+1]);
i += 2;
}
return 0;
}
/*
* saa7113 initialise routine.
* @param devccir: saa7113's working mode:0--VIDEO_MODE_CCIR656; 1--VIDEO_MODE_CCIR601
* @return value:0--success; 1--error.
*/
int init_saa7113(int slccir, int slnorm, int slmaster_mode)
{
if((slnorm >= VIDEO_NORM_SUPPORT)||\
(slccir > VIDEO_MODE_CCIR601)||\
(slmaster_mode > VIDEO_MODE_MASTER))
return -1;
if(write_regs((unsigned char *)saa7113_data, sizeof(saa7113_data)))
{
return -1;
}
return 0;
}
/*
* saa7113 open routine.
* do nothing.
*
*/
int saa7113_open(struct inode * inode, struct file * file)
{
return 0;
}
/*
* saa7113 close routine.
* do nothing.
*
*/
int saa7113_close(struct inode * inode, struct file * file)
{
return 0;
}
/*
* saa7113 ioctl routine.
*/
int saa7113_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
return 0;
}
/*
* The various file operations we support.
*/
static struct file_operations saa7113_fops = {
.owner = THIS_MODULE,
.ioctl = saa7113_ioctl,
.open = saa7113_open,
.release = saa7113_close
};
static struct miscdevice saa7113_dev = {
MISC_DYNAMIC_MINOR,
"saa7113",
&saa7113_fops,
};
static int saa7113_device_init(void)
{
if(init_saa7113(VIDEO_MODE_CCIR656,VIDEO_NORM_PAL,VIDEO_MODE_MASTER) == 0)
return 0;
else
return -1;
}
static int __init saa7113_init(void)
{
int ret = 0;
ret = misc_register(&saa7113_dev);
if(ret)
{
printk("could not register saa7113 devices. \n");
return ret;
}
if(saa7113_device_init()<0){
misc_deregister(&saa7113_dev);
printk("saa7113 driver init fail for device init error!\n");
return -1;
}
printk("saa7113 driver init successful!\n");
return ret;
}
static void __exit saa7113_exit(void)
{
misc_deregister(&saa7113_dev);
}
module_init(saa7113_init);
module_exit(saa7113_exit);
#ifdef MODULE
#include <linux/compile.h>
#endif
MODULE_INFO(build, UTS_VERSION);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("hisilicon");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -