3055 lines
100 KiB
C
3055 lines
100 KiB
C
/*
|
|
Copyright (c), 2001-2022, Shenshu Tech. Co., Ltd.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/version.h>
|
|
#include <linux/module.h>
|
|
#include <linux/types.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/fcntl.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/miscdevice.h>
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/init.h>
|
|
#include <asm/uaccess.h>
|
|
#include <asm/io.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/string.h>
|
|
#include <linux/list.h>
|
|
#include <asm/delay.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/poll.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/sched.h>
|
|
#include <uapi/linux/sched/types.h>
|
|
|
|
#include <linux/i2c.h>
|
|
#include <linux/i2c-dev.h>
|
|
#include "tp2854_def.h"
|
|
#include "tp2854.h"
|
|
|
|
#include "securec.h"
|
|
|
|
#define DEBUG 0 // printk debug information on/off
|
|
|
|
enum{
|
|
TP2854 =0x5400,
|
|
TP2854B=0x5401,
|
|
};
|
|
|
|
static struct i2c_board_info tp2854_info =
|
|
{
|
|
I2C_BOARD_INFO("TP2854", 0x44),
|
|
};
|
|
|
|
static struct i2c_client* tp28xx_client0;
|
|
static struct i2c_client* tp28xx_client1;
|
|
|
|
#define I2C_INDEX_0 0 //TX2 I2C0 for camera
|
|
#define I2C_INDEX_1 1
|
|
|
|
MODULE_DESCRIPTION("TechPoint TP2854 Linux Module");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
#define DEBUG 0 //printk debug information on/off
|
|
#define CVBS_FRAME_OUTPUT 0 //1->output odd+even field to one frame
|
|
|
|
#define DEFAULT_FORMAT TP2802_1080P25
|
|
|
|
static int HDC_enable = 1;
|
|
static int tp_work_mode = DEFAULT_FORMAT;
|
|
static int chips = 4;
|
|
static int output = MIPI_1CH4LANE_297M;
|
|
|
|
static unsigned int id[MAX_CHIPS];
|
|
|
|
#define TP2854_I2C_A 0x44
|
|
#define TP2854_I2C_B 0x45
|
|
|
|
|
|
unsigned char tp2802_i2c_addr[] = { TP2854_I2C_A,
|
|
TP2854_I2C_B
|
|
};
|
|
|
|
|
|
#define TP2802_I2C_ADDR(chip_id) (tp2802_i2c_addr[chip_id])
|
|
|
|
#define TP2854B_I2C_A 0x88
|
|
#define TP2854B_I2C_B 0x8A
|
|
|
|
unsigned char tp2854b_i2c_addr[] = {
|
|
TP2854B_I2C_A,
|
|
TP2854B_I2C_B,
|
|
TP2854B_I2C_A,
|
|
TP2854B_I2C_B,
|
|
TP2854B_I2C_A,
|
|
TP2854B_I2C_B,
|
|
TP2854B_I2C_A,
|
|
TP2854B_I2C_B
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
unsigned int count[CHANNELS_PER_CHIP];
|
|
unsigned int mode[CHANNELS_PER_CHIP];
|
|
unsigned int scan[CHANNELS_PER_CHIP];
|
|
unsigned int gain[CHANNELS_PER_CHIP][4];
|
|
unsigned int std[CHANNELS_PER_CHIP];
|
|
unsigned int state[CHANNELS_PER_CHIP];
|
|
unsigned int force[CHANNELS_PER_CHIP];
|
|
unsigned char addr;
|
|
} tp2802wd_info;
|
|
|
|
static tp2802wd_info watchdog_info[MAX_CHIPS];
|
|
static volatile unsigned int watchdog_state = 0;
|
|
struct task_struct *task_watchdog_deamon = NULL;
|
|
|
|
struct semaphore watchdog_lock;
|
|
#define WATCHDOG_EXIT 0
|
|
#define WATCHDOG_RUNNING 1
|
|
#define WDT 0
|
|
|
|
int TP2802_watchdog_init(void);
|
|
void TP2802_watchdog_exit(void);
|
|
|
|
static void TP2854_RX_init(unsigned char chip, unsigned char mod);
|
|
static void TP2854_output(unsigned char chip);
|
|
static int tp2802_set_video_mode(unsigned char addr, unsigned char mode, unsigned char ch, unsigned char std);
|
|
static void tp2802_set_reg_page(unsigned char addr, unsigned char ch);
|
|
|
|
|
|
unsigned char ReverseByte(unsigned char dat)
|
|
{
|
|
|
|
static const unsigned char BitReverseTable256[] = {
|
|
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
|
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
|
|
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
|
|
0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
|
|
0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
|
|
0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
|
|
0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
|
|
0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
|
|
0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
|
|
0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
|
|
0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
|
|
0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
|
|
0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
|
|
0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
|
|
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
|
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
|
};
|
|
return BitReverseTable256[dat];
|
|
}
|
|
/////////////////////////////////////////////////////////////////////
|
|
unsigned char PELCO_Decode(unsigned char *buf)
|
|
{
|
|
unsigned char i, j;
|
|
unsigned char cnt_high = 0;
|
|
unsigned char cnt_low = 0;
|
|
unsigned char dat = 0;
|
|
|
|
for(j = 0; j < 6; j++ ) {
|
|
for(i = 0; i <8; i++ ) {
|
|
if(0x80&buf[j]) {
|
|
cnt_high++;
|
|
cnt_low = 0;
|
|
} else {
|
|
if(cnt_low == 0) {
|
|
dat <<= 1;
|
|
if(cnt_high > 2) dat |= 0x01;
|
|
cnt_high = 0;
|
|
}
|
|
cnt_low++;
|
|
}
|
|
buf[j] <<= 1;
|
|
}
|
|
}
|
|
if( 0 == cnt_low && cnt_high > 2 ) {
|
|
dat <<= 1;
|
|
dat |= 0x01;
|
|
}
|
|
return dat;
|
|
}
|
|
///////////////////////////////////////////////////////
|
|
unsigned int ConvertACPV1Data(unsigned char dat)
|
|
{
|
|
unsigned int i, tmp=0;
|
|
for(i = 0; i < 8; i++)
|
|
{
|
|
tmp <<= 3;
|
|
|
|
if(0x01 & dat) tmp |= 0x06;
|
|
else tmp |= 0x04;
|
|
|
|
dat >>= 1;
|
|
}
|
|
return tmp;
|
|
}
|
|
|
|
volatile unsigned int* gpio_reg;
|
|
volatile unsigned int* pinmux_reg;
|
|
volatile unsigned int* pinmux_ioctl_reg;
|
|
|
|
void tp28xx_byte_write(unsigned char chip, unsigned char reg_addr, unsigned char value)
|
|
{
|
|
unsigned char buf[2];
|
|
struct i2c_client* client = tp28xx_client0;
|
|
unsigned char chip_addr;
|
|
|
|
if (chip == 0) {
|
|
client = tp28xx_client0;
|
|
} else if (chip == 1) {
|
|
client = tp28xx_client0;
|
|
} else if (chip == 2) {
|
|
client = tp28xx_client1;
|
|
} else if (chip == 3) {
|
|
client = tp28xx_client1;
|
|
}
|
|
|
|
chip_addr = tp2854b_i2c_addr[chip];
|
|
|
|
client->addr = (chip_addr >> 1);
|
|
|
|
buf[0] = reg_addr;
|
|
buf[1] = value;
|
|
|
|
i2c_master_send(client, buf, 2);
|
|
udelay(300);
|
|
}
|
|
|
|
unsigned char tp28xx_byte_read(unsigned char chip, unsigned char reg_addr)
|
|
{
|
|
unsigned char ret_data = 0xFF;
|
|
int ret;
|
|
struct i2c_client *client = tp28xx_client0;
|
|
static struct i2c_msg msg[2];
|
|
unsigned char buffer[2];
|
|
unsigned int data_width = 1;
|
|
|
|
if (chip == 0) {
|
|
client = tp28xx_client0;
|
|
} else if (chip == 1) {
|
|
client = tp28xx_client0;
|
|
} else if (chip == 2) {
|
|
client = tp28xx_client1;
|
|
} else if (chip == 3) {
|
|
client = tp28xx_client1;
|
|
}
|
|
client->addr = (tp2854b_i2c_addr[chip] >> 1);
|
|
|
|
buffer[0] = reg_addr & 0xFF;
|
|
|
|
msg[0].addr = client->addr;
|
|
msg[0].flags = 0;
|
|
msg[0].len = 1;
|
|
msg[0].buf = buffer;
|
|
|
|
msg[1].addr = client->addr;
|
|
msg[1].flags = client->flags | I2C_M_RD;
|
|
msg[1].len = 1;
|
|
msg[1].buf = buffer;
|
|
|
|
ret = i2c_transfer(client->adapter, msg, 2);
|
|
if (ret != 2) {
|
|
printk("[%s %d] ot_i2c_transfer error, ret=%d.\n", __FUNCTION__, __LINE__, ret);
|
|
return 0xff;
|
|
}
|
|
|
|
if (memcpy_s(&ret_data, sizeof(ret_data), buffer, data_width) != EOK) {
|
|
printk("memcpy_s failed!\n");
|
|
return 0xff;
|
|
}
|
|
|
|
return ret_data;
|
|
}
|
|
|
|
static int i2c_client_init(void)
|
|
{
|
|
struct i2c_adapter* i2c_adap;
|
|
|
|
i2c_adap = i2c_get_adapter(I2C_INDEX_0);
|
|
tp28xx_client0 = i2c_new_device(i2c_adap, &tp2854_info);
|
|
i2c_put_adapter(i2c_adap);
|
|
|
|
i2c_adap = i2c_get_adapter(I2C_INDEX_1);
|
|
tp28xx_client1 = i2c_new_device(i2c_adap, &tp2854_info);
|
|
i2c_put_adapter(i2c_adap);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void i2c_client_exit(void)
|
|
{
|
|
i2c_unregister_device(tp28xx_client0);
|
|
|
|
i2c_unregister_device(tp28xx_client1);
|
|
}
|
|
|
|
static void tp2802_write_table(unsigned char chip,
|
|
unsigned char addr, unsigned char *tbl_ptr, unsigned char tbl_cnt)
|
|
{
|
|
unsigned char i;
|
|
for(i = 0; i < tbl_cnt; i ++) {
|
|
tp28xx_byte_write(chip, (addr + i), *(tbl_ptr + i));
|
|
}
|
|
}
|
|
|
|
void TP2854_StartTX(unsigned char chip, unsigned char ch)
|
|
{
|
|
unsigned char tmp;
|
|
int i;
|
|
tp28xx_byte_write(chip, 0xB6, (0x01<<(ch))); //clear flag
|
|
|
|
tmp = tp28xx_byte_read(chip, 0x6f);
|
|
tmp |= 0x01;
|
|
tp28xx_byte_write(chip, 0x6f, tmp); //TX enable
|
|
tmp &= 0xfe;
|
|
tp28xx_byte_write(chip, 0x6f, tmp); //TX disable
|
|
|
|
i = 100;
|
|
while (i--) {
|
|
if ((0x01 << (ch)) & tp28xx_byte_read(chip, 0xb6)) {
|
|
break;
|
|
}
|
|
msleep(2);
|
|
}
|
|
}
|
|
|
|
void HDA_SetACPV2Data(unsigned char chip, unsigned char reg, unsigned char dat)
|
|
{
|
|
unsigned int i;
|
|
unsigned int PTZ_pelco = 0;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
PTZ_pelco <<= 3;
|
|
|
|
if (0x80 & dat) {
|
|
PTZ_pelco |= 0x06;
|
|
} else {
|
|
PTZ_pelco |= 0x04;
|
|
}
|
|
|
|
dat <<= 1;
|
|
}
|
|
|
|
tp28xx_byte_write(chip, reg + 0, (PTZ_pelco >> 16) & 0xff);
|
|
tp28xx_byte_write(chip, reg + 1, (PTZ_pelco >> 8) & 0xff);
|
|
tp28xx_byte_write(chip, reg + 2, (PTZ_pelco) & 0xff);
|
|
}
|
|
void HDA_SetACPV1Data(unsigned char chip, unsigned char reg, unsigned char dat)
|
|
{
|
|
unsigned int i;
|
|
unsigned int PTZ_pelco = 0;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
PTZ_pelco <<= 3;
|
|
|
|
if (0x01 & dat) {
|
|
PTZ_pelco |= 0x06;
|
|
} else {
|
|
PTZ_pelco |= 0x04;
|
|
}
|
|
|
|
dat >>= 1;
|
|
}
|
|
|
|
tp28xx_byte_write(chip, reg + 0, (PTZ_pelco >> 16) & 0xff);
|
|
tp28xx_byte_write(chip, reg + 1, (PTZ_pelco >> 8) & 0xff);
|
|
tp28xx_byte_write(chip, reg + 2, (PTZ_pelco) & 0xff);
|
|
}
|
|
|
|
int tp2802_open(struct inode *inode, struct file *file)
|
|
{
|
|
(void)inode;
|
|
(void)file;
|
|
return SUCCESS;
|
|
}
|
|
|
|
int tp2802_close(struct inode *inode, struct file *file)
|
|
{
|
|
(void)inode;
|
|
(void)file;
|
|
return SUCCESS;
|
|
}
|
|
|
|
static void tp2802_set_work_mode_1080p25(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_1080p25_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_1080p30(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_1080p30_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_720p25(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_720p25_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_720p30(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_720p30_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_720p50(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_720p50_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_720p60(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_720p60_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_PAL(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_PAL_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_NTSC(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_NTSC_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_3M(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_3M_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_5M(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_5M_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_4M(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_4M_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_3M20(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_3M20_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_4M12(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_4M12_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_6M10(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_6M10_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_QHD15(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_QHD15_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_QHD30(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_QHD30_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_QHD25(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_QHD25_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_QXGA30(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_QXGA30_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_QXGA25(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_QXGA25_raster, 9);
|
|
}
|
|
|
|
static void tp2802_set_work_mode_5M20(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_5M20_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_8M15(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_8M15_raster, 9);
|
|
}
|
|
static void tp2802_set_work_mode_8M12(unsigned chip)
|
|
{
|
|
// Start address 0x15, Size = 9B
|
|
tp2802_write_table(chip, 0x15, tbl_tp2802_8M12_raster, 9);
|
|
}
|
|
|
|
long tp2802_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|
{
|
|
unsigned int __user *argp = (unsigned int __user *)arg;
|
|
unsigned int tmp;
|
|
unsigned char chip;
|
|
unsigned int ret = 0;
|
|
|
|
|
|
tp2802_video_mode video_mode;
|
|
|
|
if (argp == NULL) {
|
|
return FAILURE;
|
|
}
|
|
|
|
(void)file;
|
|
switch (_IOC_NR(cmd)) {
|
|
case _IOC_NR(TP2802_SET_VIDEO_MODE): {
|
|
if (copy_from_user(&video_mode, argp, sizeof(tp2802_video_mode))) {
|
|
return FAILURE;
|
|
}
|
|
|
|
if (video_mode.chip >= chips || video_mode.ch >= CHANNELS_PER_CHIP) {
|
|
return FAILURE;
|
|
}
|
|
output = video_mode.output;
|
|
down(&watchdog_lock);
|
|
|
|
ret = tp2802_set_video_mode(video_mode.chip, video_mode.mode, video_mode.ch, video_mode.std);
|
|
|
|
up(&watchdog_lock);
|
|
|
|
if (!(ret)) {
|
|
TP2854_output(video_mode.chip);
|
|
watchdog_info[video_mode.chip].mode[video_mode.ch] = video_mode.mode;
|
|
watchdog_info[video_mode.chip].std[video_mode.ch] = video_mode.std;
|
|
return SUCCESS;
|
|
} else {
|
|
printk("Invalid mode:%d\n", video_mode.mode);
|
|
return FAILURE;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case _IOC_NR(TP2802_GET_VIDEO_MODE): {
|
|
if (copy_from_user(&video_mode, argp, sizeof(tp2802_video_mode))) {
|
|
return FAILURE;
|
|
}
|
|
|
|
if (video_mode.chip >= chips || video_mode.ch >= CHANNELS_PER_CHIP) {
|
|
return FAILURE;
|
|
}
|
|
#if (WDT)
|
|
video_mode.mode = watchdog_info[video_mode.chip].mode[video_mode.ch];
|
|
video_mode.std = watchdog_info[video_mode.chip].std[video_mode.ch];
|
|
#else
|
|
down(&watchdog_lock);
|
|
|
|
chip = video_mode.chip;
|
|
|
|
tp2802_set_reg_page(chip, video_mode.ch);
|
|
|
|
tmp = tp28xx_byte_read(chip, 0x03);
|
|
tmp &= 0x7; /* [2:0] - CVSTD */
|
|
video_mode.mode = tmp;
|
|
|
|
up(&watchdog_lock);
|
|
#endif
|
|
if (copy_to_user(argp, &video_mode, sizeof(tp2802_video_mode))) {
|
|
return FAILURE;
|
|
}
|
|
break;
|
|
}
|
|
default: {
|
|
printk("Invalid tp2802 ioctl cmd!\n");
|
|
ret = -1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
static void TP2854_RX_init(unsigned char chip, unsigned char mod)
|
|
{
|
|
|
|
int i, index=0;
|
|
unsigned char regA7=0x00;
|
|
unsigned char regA8=0x00;
|
|
|
|
//regC9~D7
|
|
static const unsigned char PTZ_RX_dat[][15]=
|
|
{
|
|
{0x00,0x00,0x07,0x08,0x00,0x00,0x04,0x00,0x00,0x60,0x10,0x06,0xbe,0x39,0x27}, //TVI command
|
|
{0x00,0x00,0x07,0x08,0x09,0x0a,0x04,0x00,0x00,0x60,0x10,0x06,0xbe,0x39,0x27}, //TVI burst
|
|
{0x00,0x00,0x06,0x07,0x08,0x09,0x05,0xbf,0x11,0x60,0x0b,0x04,0xf0,0xd8,0x2f}, //ACP1 0.525
|
|
{0x00,0x00,0x06,0x07,0x08,0x09,0x02,0xdf,0x88,0x60,0x10,0x04,0xf0,0xd8,0x17}, //ACP2 0.6
|
|
{0x00,0x00,0x07,0x08,0x09,0x0a,0x09,0xd9,0xd3,0x60,0x08,0x04,0xf0,0xd8,0x2f}, //ACP3 0.35
|
|
{0x00,0x00,0x06,0x07,0x08,0x09,0x03,0x52,0x53,0x60,0x10,0x04,0xf0,0xd8,0x17} //ACP1 0.525
|
|
};
|
|
|
|
if(PTZ_RX_TVI_CMD == mod)
|
|
{
|
|
index = 0;
|
|
regA7 = 0x03;
|
|
regA8 = 0x00;
|
|
}
|
|
else if(PTZ_RX_TVI_BURST == mod)
|
|
{
|
|
index = 1;
|
|
regA7 = 0x03;
|
|
regA8 = 0x00;
|
|
}
|
|
else if(PTZ_RX_ACP1 == mod)
|
|
{
|
|
index = 2;
|
|
regA7 = 0x03;
|
|
regA8 = 0x00;
|
|
}
|
|
else if(PTZ_RX_ACP2 == mod)
|
|
{
|
|
index = 3;
|
|
regA7 = 0x27;
|
|
regA8 = 0x0f;
|
|
}
|
|
else if(PTZ_RX_ACP3 == mod)
|
|
{
|
|
index = 4;
|
|
regA7 = 0x03;
|
|
regA8 = 0x00;
|
|
}
|
|
else if(PTZ_RX_TEST == mod)
|
|
{
|
|
index = 5;
|
|
regA7 = 0x03;
|
|
regA8 = 0x00;
|
|
}
|
|
|
|
for(i = 0; i < 15; i++)
|
|
{
|
|
tp28xx_byte_write(chip, 0xc9+i, PTZ_RX_dat[index][i]);
|
|
tp28xx_byte_write(chip, 0xa8, regA8);
|
|
tp28xx_byte_write(chip, 0xa7, regA7);
|
|
}
|
|
|
|
}
|
|
|
|
static void TP2854_reset_default(unsigned char chip, unsigned char ch)
|
|
{
|
|
unsigned int tmp;
|
|
|
|
(void)ch;
|
|
tp28xx_byte_write(chip, 0x07, 0xC0);
|
|
tp28xx_byte_write(chip, 0x0B, 0xC0);
|
|
tmp = tp28xx_byte_read(chip, 0x26);
|
|
tmp &= 0xfe;
|
|
tp28xx_byte_write(chip, 0x26, tmp);
|
|
tmp = tp28xx_byte_read(chip, 0xa7);
|
|
tmp &= 0xfe;
|
|
tp28xx_byte_write(chip, 0xa7, tmp);
|
|
tmp = tp28xx_byte_read(chip, 0x06);
|
|
tmp &= 0xfb;
|
|
tp28xx_byte_write(chip, 0x06, tmp);
|
|
}
|
|
//////////////////////////////////////////////////////////////
|
|
static void TP2854_NTSC_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x13);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x40);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0x2d);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x70);
|
|
tp28xx_byte_write(chip, 0x2c, 0x2a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x68);
|
|
tp28xx_byte_write(chip, 0x2e, 0x57);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x62);
|
|
tp28xx_byte_write(chip, 0x31, 0xbb);
|
|
tp28xx_byte_write(chip, 0x32, 0x96);
|
|
tp28xx_byte_write(chip, 0x33, 0xc0);
|
|
tp28xx_byte_write(chip, 0x38, 0x00);
|
|
tp28xx_byte_write(chip, 0x39, 0x04);
|
|
tp28xx_byte_write(chip, 0x3a, 0x32);
|
|
tp28xx_byte_write(chip, 0x3B, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x18, 0x12);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
static void TP2854_PAL_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x13);
|
|
tp28xx_byte_write(chip, 0x0d, 0x51);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x48);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x37);
|
|
tp28xx_byte_write(chip, 0x23, 0x3f);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0x2d);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x70);
|
|
tp28xx_byte_write(chip, 0x2c, 0x2a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x64);
|
|
tp28xx_byte_write(chip, 0x2e, 0x56);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x7a);
|
|
tp28xx_byte_write(chip, 0x31, 0x4a);
|
|
tp28xx_byte_write(chip, 0x32, 0x4d);
|
|
tp28xx_byte_write(chip, 0x33, 0xf0);
|
|
tp28xx_byte_write(chip, 0x38, 0x00);
|
|
tp28xx_byte_write(chip, 0x39, 0x04);
|
|
tp28xx_byte_write(chip, 0x3a, 0x32);
|
|
tp28xx_byte_write(chip, 0x3B, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x18, 0x17);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
static void TP2854_V1_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x30);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0x2d);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x30);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0xbb);
|
|
tp28xx_byte_write(chip, 0x32, 0x2e);
|
|
tp28xx_byte_write(chip, 0x33, 0x90);
|
|
tp28xx_byte_write(chip, 0x38, 0x00);
|
|
tp28xx_byte_write(chip, 0x39, 0x1c);
|
|
tp28xx_byte_write(chip, 0x3a, 0x32);
|
|
tp28xx_byte_write(chip, 0x3B, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
static void TP2854_V2_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x13);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x30);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0x2d);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x30);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0xbb);
|
|
tp28xx_byte_write(chip, 0x32, 0x2e);
|
|
tp28xx_byte_write(chip, 0x33, 0x90);
|
|
tp28xx_byte_write(chip, 0x38, 0x00);
|
|
tp28xx_byte_write(chip, 0x39, 0x18);
|
|
tp28xx_byte_write(chip, 0x3a, 0x32);
|
|
tp28xx_byte_write(chip, 0x3B, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
|
|
/////HDA QHD30
|
|
static void TP2854_AQHDP30_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tp28xx_byte_write(chip, 0x15, 0x23);
|
|
tp28xx_byte_write(chip, 0x16, 0x16);
|
|
tp28xx_byte_write(chip, 0x18, 0x32);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x80);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2d, 0xa0);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x6a);
|
|
tp28xx_byte_write(chip, 0x32, 0xbe);
|
|
tp28xx_byte_write(chip, 0x33, 0x80);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
}
|
|
|
|
/////HDA QHD25
|
|
static void TP2854_AQHDP25_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tp28xx_byte_write(chip, 0x15, 0x23);
|
|
tp28xx_byte_write(chip, 0x16, 0x16);
|
|
tp28xx_byte_write(chip, 0x18, 0x32);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x80);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2d, 0xa0);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x6f);
|
|
tp28xx_byte_write(chip, 0x32, 0xb5);
|
|
tp28xx_byte_write(chip, 0x33, 0x80);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
}
|
|
|
|
/////HDA QXGA30
|
|
static void TP2854_AQXGAP30_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x90);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0xa0);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x68);
|
|
tp28xx_byte_write(chip, 0x32, 0xbe);
|
|
tp28xx_byte_write(chip, 0x33, 0x80);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
}
|
|
|
|
/////HDA QXGA25
|
|
static void TP2854_AQXGAP25_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x60;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x90);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0xa0);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x6c);
|
|
tp28xx_byte_write(chip, 0x32, 0xbe);
|
|
tp28xx_byte_write(chip, 0x33, 0x80);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
}
|
|
|
|
|
|
/////HDC QHD30
|
|
static void TP2854_CQHDP30_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0xfa);
|
|
tp28xx_byte_write(chip, 0x18, 0x38);
|
|
tp28xx_byte_write(chip, 0x1c, 0x0c);
|
|
tp28xx_byte_write(chip, 0x1d, 0x80);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x50);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x38);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xda);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x6c);
|
|
tp28xx_byte_write(chip, 0x2e, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x75);
|
|
tp28xx_byte_write(chip, 0x31, 0x39);
|
|
tp28xx_byte_write(chip, 0x32, 0xc0);
|
|
tp28xx_byte_write(chip, 0x33, 0x31);
|
|
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
}
|
|
|
|
/////HDC QHD25
|
|
static void TP2854_CQHDP25_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0xd8);
|
|
tp28xx_byte_write(chip, 0x18, 0x30);
|
|
tp28xx_byte_write(chip, 0x1c, 0x0c);
|
|
tp28xx_byte_write(chip, 0x1d, 0x80);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x50);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x38);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xda);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x6c);
|
|
tp28xx_byte_write(chip, 0x2e, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x75);
|
|
tp28xx_byte_write(chip, 0x31, 0x39);
|
|
tp28xx_byte_write(chip, 0x32, 0xc0);
|
|
tp28xx_byte_write(chip, 0x33, 0x3b);
|
|
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
}
|
|
|
|
///////HDA QHD15
|
|
static void TP2854_AQHDP15_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x38);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x44);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x29);
|
|
tp28xx_byte_write(chip, 0x31, 0x68);
|
|
tp28xx_byte_write(chip, 0x32, 0x78);
|
|
tp28xx_byte_write(chip, 0x33, 0x10);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
}
|
|
|
|
/////HDA QXGA18
|
|
static void TP2854_AQXGAP18_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x10);
|
|
tp28xx_byte_write(chip, 0x18, 0x68);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x48);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2d, 0x52);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x29);
|
|
tp28xx_byte_write(chip, 0x31, 0x65);
|
|
tp28xx_byte_write(chip, 0x32, 0x2b);
|
|
tp28xx_byte_write(chip, 0x33, 0xd0);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
}
|
|
|
|
/////TVI QHD30/QHD25
|
|
static void TP2854_QHDP30_25_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x15, 0x23);
|
|
tp28xx_byte_write(chip, 0x16, 0x1b);
|
|
tp28xx_byte_write(chip, 0x18, 0x38);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x50);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x58);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x74);
|
|
tp28xx_byte_write(chip, 0x31, 0x58);
|
|
tp28xx_byte_write(chip, 0x32, 0x9f);
|
|
tp28xx_byte_write(chip, 0x33, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
}
|
|
|
|
/////TVI 5M20
|
|
static void TP2854_5MP20_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x50);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x54);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x74);
|
|
tp28xx_byte_write(chip, 0x31, 0xa7);
|
|
tp28xx_byte_write(chip, 0x32, 0x18);
|
|
tp28xx_byte_write(chip, 0x33, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
|
|
/////HDA 5M20
|
|
static void TP2854_A5MP20_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
tp28xx_byte_write(chip, 0x20, 0x80);
|
|
tp28xx_byte_write(chip, 0x21, 0x86);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2d, 0xA0);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x77);
|
|
tp28xx_byte_write(chip, 0x32, 0x0e);
|
|
tp28xx_byte_write(chip, 0x33, 0xa0);
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
}
|
|
|
|
/////TVI 8M15
|
|
static void TP2854_8MP15_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x60);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x58);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x74);
|
|
tp28xx_byte_write(chip, 0x31, 0x59);
|
|
tp28xx_byte_write(chip, 0x32, 0xbd);
|
|
tp28xx_byte_write(chip, 0x33, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
///////HDA 5M12.5
|
|
static void TP2854_A5MP12_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x38);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x44);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x29);
|
|
tp28xx_byte_write(chip, 0x31, 0x68);
|
|
tp28xx_byte_write(chip, 0x32, 0x78);
|
|
tp28xx_byte_write(chip, 0x33, 0x10);
|
|
|
|
tp28xx_byte_write(chip, 0x18, 0x14);
|
|
tp28xx_byte_write(chip, 0x1d, 0xb8);
|
|
tp28xx_byte_write(chip, 0x36, 0xbc);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
}
|
|
///////////////////////////////////////////////////////////////////
|
|
static void TP2854_A720P30_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x02);
|
|
tmp |= 0x04;
|
|
tp28xx_byte_write(chip, 0x02, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x0d, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x40);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
|
|
tp28xx_byte_write(chip, 0x2c, 0x3a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x5a);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x9d);
|
|
tp28xx_byte_write(chip, 0x31, 0xca);
|
|
tp28xx_byte_write(chip, 0x32, 0x01);
|
|
tp28xx_byte_write(chip, 0x33, 0xd0);
|
|
}
|
|
static void TP2854_A720P25_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x02);
|
|
tmp |= 0x04;
|
|
tp28xx_byte_write(chip, 0x02, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x0d, 0x71);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x40);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
|
|
tp28xx_byte_write(chip, 0x2c, 0x3a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x5a);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x9e);
|
|
tp28xx_byte_write(chip, 0x31, 0x20);
|
|
tp28xx_byte_write(chip, 0x32, 0x10);
|
|
tp28xx_byte_write(chip, 0x33, 0x90);
|
|
}
|
|
static void TP2854_A1080P30_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x02);
|
|
tmp |= 0x04;
|
|
tp28xx_byte_write(chip, 0x02, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x16, 0xf0);
|
|
|
|
tp28xx_byte_write(chip, 0x0d, 0x72);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x38);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x0d);
|
|
|
|
tp28xx_byte_write(chip, 0x2c, 0x3a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x54);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0xa5);
|
|
tp28xx_byte_write(chip, 0x31, 0x95);
|
|
tp28xx_byte_write(chip, 0x32, 0xe0);
|
|
tp28xx_byte_write(chip, 0x33, 0x60);
|
|
}
|
|
static void TP2854_A1080P25_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x02);
|
|
tmp |= 0x04;
|
|
tp28xx_byte_write(chip, 0x02, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x16, 0xf0);
|
|
|
|
tp28xx_byte_write(chip, 0x0d, 0x73);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x3c);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x0d);
|
|
|
|
tp28xx_byte_write(chip, 0x2c, 0x3a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x54);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0xa5);
|
|
tp28xx_byte_write(chip, 0x31, 0x86);
|
|
tp28xx_byte_write(chip, 0x32, 0xfb);
|
|
tp28xx_byte_write(chip, 0x33, 0x60);
|
|
}
|
|
static void TP2854_1080P60_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
|
|
tp28xx_byte_write(chip, 0x0b, 0xc0);
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x15, 0x03);
|
|
tp28xx_byte_write(chip, 0x16, 0xf0);
|
|
tp28xx_byte_write(chip, 0x17, 0x80);
|
|
tp28xx_byte_write(chip, 0x18, 0x12);
|
|
tp28xx_byte_write(chip, 0x19, 0x38);
|
|
tp28xx_byte_write(chip, 0x1a, 0x47);
|
|
tp28xx_byte_write(chip, 0x1c, 0x08);
|
|
tp28xx_byte_write(chip, 0x1d, 0x96);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x50);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x23, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xad);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x40);
|
|
tp28xx_byte_write(chip, 0x2e, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x74);
|
|
tp28xx_byte_write(chip, 0x31, 0x9b);
|
|
tp28xx_byte_write(chip, 0x32, 0xa5);
|
|
tp28xx_byte_write(chip, 0x33, 0xe0);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x00);
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
}
|
|
/////HDC 8M12
|
|
static void TP2854_C8MP12_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tp28xx_byte_write(chip, 0x0c, 0x03);
|
|
tp28xx_byte_write(chip, 0x0d, 0x50);
|
|
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp &= 0x9f;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
tp28xx_byte_write(chip, 0x15, 0x23);
|
|
tp28xx_byte_write(chip, 0x16, 0xf8);
|
|
tp28xx_byte_write(chip, 0x18, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x68);
|
|
tp28xx_byte_write(chip, 0x21, 0x84);
|
|
tp28xx_byte_write(chip, 0x22, 0x36);
|
|
tp28xx_byte_write(chip, 0x22, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xff);
|
|
tp28xx_byte_write(chip, 0x26, 0x05);
|
|
tp28xx_byte_write(chip, 0x27, 0xda);
|
|
tp28xx_byte_write(chip, 0x28, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2c, 0x0a);
|
|
tp28xx_byte_write(chip, 0x2d, 0x84);
|
|
tp28xx_byte_write(chip, 0x2e, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x75);
|
|
tp28xx_byte_write(chip, 0x31, 0x39);
|
|
tp28xx_byte_write(chip, 0x32, 0xc0);
|
|
tp28xx_byte_write(chip, 0x33, 0x32);
|
|
|
|
tp28xx_byte_write(chip, 0x38, 0x40);
|
|
tp28xx_byte_write(chip, 0x39, 0x48);
|
|
tp28xx_byte_write(chip, 0x3a, 0x12);
|
|
tp28xx_byte_write(chip, 0x3b, 0x26);
|
|
}
|
|
/////HDA 8M15
|
|
static void TP2854_A8MP15_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x40;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x16, 0x70);
|
|
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x68);
|
|
tp28xx_byte_write(chip, 0x32, 0x43);
|
|
tp28xx_byte_write(chip, 0x33, 0x06);
|
|
tp28xx_byte_write(chip, 0x39, 0x40);
|
|
}
|
|
static void TP2854_A720P60_DataSet(unsigned char chip)
|
|
{
|
|
unsigned char tmp;
|
|
|
|
tmp = tp28xx_byte_read(chip, 0x14);
|
|
tmp |= 0x60;
|
|
tp28xx_byte_write(chip, 0x14, tmp);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x38);
|
|
tp28xx_byte_write(chip, 0x21, 0x46);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0xfe);
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x44);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x29);
|
|
tp28xx_byte_write(chip, 0x31, 0x62);
|
|
tp28xx_byte_write(chip, 0x32, 0x78);
|
|
tp28xx_byte_write(chip, 0x33, 0x10);
|
|
}
|
|
|
|
static void TP2854_C1080P30_DataSet(unsigned char chip);
|
|
static void TP2854_C1080P25_DataSet(unsigned char chip);
|
|
static void TP2854_C720P30_DataSet(unsigned char chip);
|
|
static void TP2854_C720P25_DataSet(unsigned char chip);
|
|
static void TP2854_C720P60_DataSet(unsigned char chip);
|
|
static void TP2854_C720P50_DataSet(unsigned char chip);
|
|
static void TP2854_SYSCLK_V1(unsigned char chip, unsigned char ch);
|
|
static void TP2854_SYSCLK_V2(unsigned char chip, unsigned char ch);
|
|
static void TP2854_SYSCLK_V3(unsigned char chip, unsigned char ch);
|
|
static void TP28xx_reset_default(int chip, unsigned char ch);
|
|
static int tp2802_set_video_mode(unsigned char chip, unsigned char mode, unsigned char ch, unsigned char std)
|
|
{
|
|
int err = 0;
|
|
unsigned int tmp;
|
|
|
|
if (std == STD_HDA_DEFAULT) {
|
|
std = STD_HDA;
|
|
}
|
|
|
|
#if (DEBUG)
|
|
printk("chip %d mode %d ch %d std %d\r\n", chip, mode, ch, std);
|
|
#endif
|
|
|
|
// Set Page Register to the appropriate Channel
|
|
tp2802_set_reg_page(chip, ch);
|
|
|
|
switch (mode) {
|
|
case TP2802_1080P25:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp2802_set_work_mode_1080p25(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
TP2854_A1080P25_DataSet(chip);
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
{
|
|
TP2854_C1080P25_DataSet(chip);
|
|
}
|
|
if (std == STD_HDC) { // HDC 1080p25 position adjust
|
|
{
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x60);
|
|
tp28xx_byte_write(chip, 0x17, 0x80);
|
|
tp28xx_byte_write(chip, 0x18, 0x29);
|
|
tp28xx_byte_write(chip, 0x19, 0x38);
|
|
tp28xx_byte_write(chip, 0x1A, 0x47);
|
|
tp28xx_byte_write(chip, 0x1C, 0x09);
|
|
tp28xx_byte_write(chip, 0x1D, 0x60);
|
|
}
|
|
}
|
|
}
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_1080P30:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp2802_set_work_mode_1080p30(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
{
|
|
TP2854_A1080P30_DataSet(chip);
|
|
}
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
{
|
|
TP2854_C1080P30_DataSet(chip);
|
|
}
|
|
if (std == STD_HDC) { // HDC 1080p30 position adjust
|
|
{
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x60);
|
|
tp28xx_byte_write(chip, 0x17, 0x80);
|
|
tp28xx_byte_write(chip, 0x18, 0x29);
|
|
tp28xx_byte_write(chip, 0x19, 0x38);
|
|
tp28xx_byte_write(chip, 0x1A, 0x47);
|
|
tp28xx_byte_write(chip, 0x1C, 0x09);
|
|
tp28xx_byte_write(chip, 0x1D, 0x60);
|
|
}
|
|
}
|
|
}
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_720P25:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp2802_set_work_mode_720p25(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc2);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_720P30:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp2802_set_work_mode_720p30(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc2);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_720P50:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp2802_set_work_mode_720p50(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc2);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
{
|
|
TP2854_C720P50_DataSet(chip);
|
|
}
|
|
if (std == STD_HDC) { // HDC 720p50 position adjust
|
|
{
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x0a);
|
|
tp28xx_byte_write(chip, 0x17, 0x00);
|
|
tp28xx_byte_write(chip, 0x18, 0x19);
|
|
tp28xx_byte_write(chip, 0x19, 0xd0);
|
|
tp28xx_byte_write(chip, 0x1A, 0x25);
|
|
tp28xx_byte_write(chip, 0x1C, 0x06);
|
|
tp28xx_byte_write(chip, 0x1D, 0x7a);
|
|
}
|
|
}
|
|
}
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_720P60:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp2802_set_work_mode_720p60(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc2);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
{
|
|
TP2854_A720P60_DataSet(chip);
|
|
}
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
{
|
|
TP2854_C720P60_DataSet(chip);
|
|
}
|
|
if (std == STD_HDC) { // HDC 720p60 position adjust
|
|
{
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x08);
|
|
tp28xx_byte_write(chip, 0x17, 0x00);
|
|
tp28xx_byte_write(chip, 0x18, 0x19);
|
|
tp28xx_byte_write(chip, 0x19, 0xd0);
|
|
tp28xx_byte_write(chip, 0x1A, 0x25);
|
|
tp28xx_byte_write(chip, 0x1C, 0x06);
|
|
tp28xx_byte_write(chip, 0x1D, 0x72);
|
|
}
|
|
}
|
|
}
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_720P30V2:
|
|
tp28xx_byte_write(chip, 0x35, 0x25);
|
|
tp2802_set_work_mode_720p60(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc2);
|
|
TP2854_V2_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
{
|
|
TP2854_A720P30_DataSet(chip);
|
|
}
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
{
|
|
TP2854_C720P30_DataSet(chip);
|
|
}
|
|
if (std == STD_HDC) { // HDC 720p30 position adjust
|
|
{
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x08);
|
|
tp28xx_byte_write(chip, 0x17, 0x00);
|
|
tp28xx_byte_write(chip, 0x18, 0x19);
|
|
tp28xx_byte_write(chip, 0x19, 0xd0);
|
|
tp28xx_byte_write(chip, 0x1A, 0x25);
|
|
tp28xx_byte_write(chip, 0x1C, 0x06);
|
|
tp28xx_byte_write(chip, 0x1D, 0x72);
|
|
}
|
|
}
|
|
}
|
|
|
|
TP2854_SYSCLK_V2(chip, ch);
|
|
break;
|
|
|
|
case TP2802_720P25V2:
|
|
tp28xx_byte_write(chip, 0x35, 0x25);
|
|
tp2802_set_work_mode_720p50(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc2);
|
|
TP2854_V2_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
{
|
|
TP2854_A720P25_DataSet(chip);
|
|
}
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
{
|
|
TP2854_C720P25_DataSet(chip);
|
|
}
|
|
if (std == STD_HDC) { // HDC 720p25 position adjust
|
|
{
|
|
tp28xx_byte_write(chip, 0x15, 0x13);
|
|
tp28xx_byte_write(chip, 0x16, 0x0a);
|
|
tp28xx_byte_write(chip, 0x17, 0x00);
|
|
tp28xx_byte_write(chip, 0x18, 0x19);
|
|
tp28xx_byte_write(chip, 0x19, 0xd0);
|
|
tp28xx_byte_write(chip, 0x1A, 0x25);
|
|
tp28xx_byte_write(chip, 0x1C, 0x06);
|
|
tp28xx_byte_write(chip, 0x1D, 0x7a);
|
|
}
|
|
}
|
|
}
|
|
|
|
TP2854_SYSCLK_V2(chip, ch);
|
|
break;
|
|
|
|
case TP2802_PAL:
|
|
if( TP2854B == id[chip]) {
|
|
tp28xx_byte_write(chip, 0x35, 0x65);
|
|
} else {
|
|
tp28xx_byte_write(chip, 0x35, 0x25);
|
|
}
|
|
tp2802_set_work_mode_PAL(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc7);
|
|
TP2854_PAL_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V2(chip, ch);
|
|
break;
|
|
|
|
case TP2802_NTSC:
|
|
if( TP2854B == id[chip]) {
|
|
tp28xx_byte_write(chip, 0x35, 0x65);
|
|
} else {
|
|
tp28xx_byte_write(chip, 0x35, 0x25);
|
|
}
|
|
tp2802_set_work_mode_NTSC(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc7);
|
|
TP2854_NTSC_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V2(chip, ch);
|
|
break;
|
|
|
|
case TP2802_3M18:
|
|
tp28xx_byte_write(chip, 0x35, 0x16);
|
|
tp28xx_byte_write(chip, 0x36, 0x30);
|
|
tp2802_set_work_mode_3M(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_5M12:
|
|
tp28xx_byte_write(chip, 0x35, 0x17);
|
|
tp28xx_byte_write(chip, 0x36, 0xD0);
|
|
tp2802_set_work_mode_5M(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
TP2854_A5MP12_DataSet(chip);
|
|
}
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_4M15:
|
|
tp28xx_byte_write(chip, 0x35, 0x16);
|
|
tp28xx_byte_write(chip, 0x36, 0x72);
|
|
tp2802_set_work_mode_4M(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_3M20:
|
|
tp28xx_byte_write(chip, 0x35, 0x16);
|
|
tp28xx_byte_write(chip, 0x36, 0x72);
|
|
tp2802_set_work_mode_3M20(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x26);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_4M12:
|
|
tp28xx_byte_write(chip, 0x35, 0x17);
|
|
tp28xx_byte_write(chip, 0x36, 0x08);
|
|
tp2802_set_work_mode_4M12(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_6M10:
|
|
tp28xx_byte_write(chip, 0x35, 0x17);
|
|
tp28xx_byte_write(chip, 0x36, 0xbc);
|
|
tp2802_set_work_mode_6M10(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_QHD30:
|
|
tp28xx_byte_write(chip, 0x35, 0x15);
|
|
tp28xx_byte_write(chip, 0x36, 0xdc);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
tp2802_set_work_mode_QHD30(chip);
|
|
TP2854_QHDP30_25_DataSet(chip);
|
|
|
|
if (std == STD_HDA) {
|
|
TP2854_AQHDP30_DataSet(chip);
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
TP2854_CQHDP30_DataSet(chip);
|
|
}
|
|
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
case TP2802_QHD25:
|
|
tp28xx_byte_write(chip, 0x35, 0x15);
|
|
tp28xx_byte_write(chip, 0x36, 0xdc);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
tp2802_set_work_mode_QHD25(chip);
|
|
TP2854_QHDP30_25_DataSet(chip);
|
|
if (std == STD_HDA) {
|
|
TP2854_AQHDP25_DataSet(chip);
|
|
} else if (std == STD_HDC || std == STD_HDC_DEFAULT) {
|
|
TP2854_CQHDP25_DataSet(chip);
|
|
}
|
|
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
case TP2802_QHD15:
|
|
tp28xx_byte_write(chip, 0x35, 0x15);
|
|
tp28xx_byte_write(chip, 0x36, 0xdc);
|
|
tp2802_set_work_mode_QHD15(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
if (std == STD_HDA) {
|
|
TP2854_AQHDP15_DataSet(chip);
|
|
}
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_QXGA18:
|
|
tp28xx_byte_write(chip, 0x35, 0x16);
|
|
tp28xx_byte_write(chip, 0x36, 0x72);
|
|
tp2802_set_work_mode_3M(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_V1_DataSet(chip);
|
|
if (std == STD_HDA) {
|
|
TP2854_AQXGAP18_DataSet(chip);
|
|
}
|
|
TP2854_SYSCLK_V1(chip, ch);
|
|
break;
|
|
|
|
case TP2802_QXGA25:
|
|
tp28xx_byte_write(chip, 0x35, 0x16);
|
|
tp28xx_byte_write(chip, 0x36, 0x72);
|
|
tp2802_set_work_mode_QXGA25(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_AQXGAP25_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
case TP2802_QXGA30:
|
|
tp28xx_byte_write(chip, 0x35, 0x16);
|
|
tp28xx_byte_write(chip, 0x36, 0x71);
|
|
tp2802_set_work_mode_QXGA30(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_AQXGAP30_DataSet(chip);
|
|
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
case TP2802_5M20:
|
|
tp28xx_byte_write(chip, 0x35, 0x17);
|
|
tp28xx_byte_write(chip, 0x36, 0xbc);
|
|
tp2802_set_work_mode_5M20(chip);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_5MP20_DataSet(chip);
|
|
if (std == STD_HDA) {
|
|
TP2854_A5MP20_DataSet(chip);
|
|
}
|
|
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
//soft reset
|
|
if(STD_TVI == std)
|
|
{
|
|
tmp = tp28xx_byte_read(chip, 0x06);
|
|
tmp |=0x80;
|
|
tp28xx_byte_write(chip, 0x06, tmp);
|
|
}
|
|
|
|
break;
|
|
|
|
case TP2802_8M15:
|
|
tp28xx_byte_write(chip, 0x35, 0x18);
|
|
tp28xx_byte_write(chip, 0x36, 0xca);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
tp2802_set_work_mode_8M15(chip);
|
|
TP2854_8MP15_DataSet(chip);
|
|
if (std == STD_HDA) {
|
|
TP2854_A8MP15_DataSet(chip);
|
|
} else if(STD_HDC == std || STD_HDC_DEFAULT == std) {
|
|
}
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
case TP2802_8M12:
|
|
tp28xx_byte_write(chip, 0x35, 0x18);
|
|
tp28xx_byte_write(chip, 0x36, 0xca);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
tp2802_set_work_mode_8M12(chip);
|
|
TP2854_8MP15_DataSet(chip);
|
|
if (std == STD_HDA) {
|
|
} else if (std == STD_HDC_DEFAULT) {
|
|
TP2854_C8MP12_DataSet(chip);
|
|
} else if (std == STD_HDC) {
|
|
TP2854_C8MP12_DataSet(chip);
|
|
tp28xx_byte_write(chip, 0x1c, 0x13);
|
|
tp28xx_byte_write(chip, 0x1d, 0x10);
|
|
}
|
|
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
case TP2802_1080P60:
|
|
tp28xx_byte_write(chip, 0x35, 0x05);
|
|
tp28xx_byte_write(chip, 0x02, 0xc0);
|
|
TP2854_1080P60_DataSet(chip);
|
|
TP2854_SYSCLK_V3(chip, ch);
|
|
break;
|
|
|
|
default:
|
|
err = -1;
|
|
break;
|
|
}
|
|
|
|
if( TP2854B == id[chip])
|
|
{
|
|
tmp = tp28xx_byte_read(chip, 0x02);
|
|
tmp &= 0x7f;
|
|
tp28xx_byte_write(chip, 0x02, tmp);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
static void tp2802_set_reg_page(unsigned char chip, unsigned char ch)
|
|
{
|
|
switch (ch) {
|
|
case CH_1:
|
|
tp28xx_byte_write(chip, 0x40, 0x00);
|
|
break;
|
|
case CH_2:
|
|
tp28xx_byte_write(chip, 0x40, 0x01);
|
|
break;
|
|
case CH_3:
|
|
tp28xx_byte_write(chip, 0x40, 0x02);
|
|
break;
|
|
case CH_4:
|
|
tp28xx_byte_write(chip, 0x40, 0x03);
|
|
break;
|
|
case CH_ALL:
|
|
tp28xx_byte_write(chip, 0x40, 0x04);
|
|
break;
|
|
case MIPI_PAGE:
|
|
tp28xx_byte_write(chip, 0x40, 0x08);
|
|
break;
|
|
}
|
|
}
|
|
const char SYSTEM_AND[5]={0xfe,0xfd,0xfb,0xf7,0xf0};
|
|
const char SYSTEM_AD_MODE[5]={0x01,0x02,0x04,0x08,0x0f};
|
|
static void TP2854_SYSCLK_V2(unsigned char chip, unsigned char ch)
|
|
{
|
|
unsigned char tmp;
|
|
|
|
if( TP2854 == id[chip]) {
|
|
tmp = tp28xx_byte_read(chip, 0x40);
|
|
tp28xx_byte_write(chip, 0x40, 0x08);
|
|
tp28xx_byte_write(chip, 0x23, 0x02);
|
|
tp28xx_byte_write(chip, 0x13, 0x24);
|
|
tp28xx_byte_write(chip, 0x14, 0x04);
|
|
tp28xx_byte_write(chip, 0x15, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0x08);
|
|
tp28xx_byte_write(chip, 0x26, 0x02);
|
|
tp28xx_byte_write(chip, 0x27, 0x0b);
|
|
|
|
tp28xx_byte_write(chip, 0x10, 0x88);
|
|
tp28xx_byte_write(chip, 0x10, 0x08);
|
|
tp28xx_byte_write(chip, 0x23, 0x00);
|
|
tp28xx_byte_write(chip, 0x40, tmp);
|
|
} else if( TP2854B == id[chip]) {
|
|
tp28xx_byte_write(chip, 0xf5, tp28xx_byte_read(chip, 0xf5) | SYSTEM_AD_MODE[ch]);
|
|
}
|
|
}
|
|
static void TP2854_SYSCLK_V1(unsigned char chip, unsigned char ch)
|
|
{
|
|
unsigned char tmp;
|
|
|
|
if( TP2854 == id[chip]) {
|
|
tmp = tp28xx_byte_read(chip, 0x40);
|
|
tp28xx_byte_write(chip, 0x40, 0x08);
|
|
tp28xx_byte_write(chip, 0x23, 0x02);
|
|
tp28xx_byte_write(chip, 0x13, 0x04);
|
|
tp28xx_byte_write(chip, 0x14, 0x04);
|
|
tp28xx_byte_write(chip, 0x15, 0x00);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0x10);
|
|
tp28xx_byte_write(chip, 0x26, 0x02);
|
|
tp28xx_byte_write(chip, 0x27, 0x16);
|
|
|
|
tp28xx_byte_write(chip, 0x10, 0x88);
|
|
tp28xx_byte_write(chip, 0x10, 0x08);
|
|
tp28xx_byte_write(chip, 0x23, 0x00);
|
|
tp28xx_byte_write(chip, 0x40, tmp);
|
|
} else if( TP2854B == id[chip]) {
|
|
tp28xx_byte_write(chip, 0xf5, tp28xx_byte_read(chip, 0xf5) & SYSTEM_AND[ch]);
|
|
if( output == MIPI_4CH4LANE_297M || output == MIPI_2CH2LANE_297M || output == MIPI_4CH2LANE_594M) {
|
|
tp28xx_byte_write(chip, 0x35, tp28xx_byte_read(chip, 0x35) | 0x40 );
|
|
}
|
|
}
|
|
}
|
|
static void TP2854_SYSCLK_V3(unsigned char chip, unsigned char ch)
|
|
{
|
|
unsigned char tmp;
|
|
|
|
if( TP2854 == id[chip]) {
|
|
tmp = tp28xx_byte_read(chip, 0x40);
|
|
tp28xx_byte_write(chip, 0x40, 0x08);
|
|
tp28xx_byte_write(chip, 0x23, 0x02);
|
|
tp28xx_byte_write(chip, 0x13, 0x04);
|
|
tp28xx_byte_write(chip, 0x14, 0x05);
|
|
tp28xx_byte_write(chip, 0x15, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x25, 0x10);
|
|
tp28xx_byte_write(chip, 0x26, 0x02);
|
|
tp28xx_byte_write(chip, 0x27, 0x18);
|
|
|
|
tp28xx_byte_write(chip, 0x10, 0x88);
|
|
tp28xx_byte_write(chip, 0x10, 0x08);
|
|
tp28xx_byte_write(chip, 0x23, 0x00);
|
|
tp28xx_byte_write(chip, 0x40, tmp);
|
|
} else if( TP2854B == id[chip]) {
|
|
tp28xx_byte_write(chip, 0xf5, tp28xx_byte_read(chip, 0xf5) & SYSTEM_AND[ch]);
|
|
|
|
if( output == MIPI_2CH4LANE_594M || output == MIPI_1CH4LANE_297M || output == MIPI_1CH2LANE_594M) {
|
|
} else {
|
|
tp28xx_byte_write(chip, 0x35, tp28xx_byte_read(chip, 0x35) | 0x40);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void TP28xx_reset_default(int chip, unsigned char ch)
|
|
{
|
|
TP2854_reset_default(chip, ch);
|
|
}
|
|
|
|
static void TP2854_C1080P25_DataSet(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x50);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0x5a);
|
|
tp28xx_byte_write(chip, 0x28, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x54);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x41);
|
|
tp28xx_byte_write(chip, 0x31, 0x82);
|
|
tp28xx_byte_write(chip, 0x32, 0x27);
|
|
tp28xx_byte_write(chip, 0x33, 0xa2);
|
|
}
|
|
static void TP2854_C720P25_DataSet(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x3a);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0x5a);
|
|
tp28xx_byte_write(chip, 0x28, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
tp28xx_byte_write(chip, 0x2d, 0x36);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x67);
|
|
tp28xx_byte_write(chip, 0x32, 0x6f);
|
|
tp28xx_byte_write(chip, 0x33, 0x33);
|
|
}
|
|
static void TP2854_C720P50_DataSet(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x3a);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0x5a);
|
|
tp28xx_byte_write(chip, 0x28, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x42);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x41);
|
|
tp28xx_byte_write(chip, 0x31, 0x82);
|
|
tp28xx_byte_write(chip, 0x32, 0x27);
|
|
tp28xx_byte_write(chip, 0x33, 0xa3);
|
|
}
|
|
static void TP2854_C1080P30_DataSet(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x3c);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0x5a);
|
|
tp28xx_byte_write(chip, 0x28, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x4c);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x41);
|
|
tp28xx_byte_write(chip, 0x31, 0x82);
|
|
tp28xx_byte_write(chip, 0x32, 0x27);
|
|
tp28xx_byte_write(chip, 0x33, 0xa4);
|
|
}
|
|
static void TP2854_C720P30_DataSet(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x30);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0x5a);
|
|
tp28xx_byte_write(chip, 0x28, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x37);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x48);
|
|
tp28xx_byte_write(chip, 0x31, 0x67);
|
|
tp28xx_byte_write(chip, 0x32, 0x6f);
|
|
tp28xx_byte_write(chip, 0x33, 0x30);
|
|
}
|
|
static void TP2854_C720P60_DataSet(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x13, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x20, 0x30);
|
|
|
|
tp28xx_byte_write(chip, 0x26, 0x01);
|
|
tp28xx_byte_write(chip, 0x27, 0x5a);
|
|
tp28xx_byte_write(chip, 0x28, 0x04);
|
|
|
|
tp28xx_byte_write(chip, 0x2b, 0x60);
|
|
|
|
tp28xx_byte_write(chip, 0x2d, 0x37);
|
|
tp28xx_byte_write(chip, 0x2e, 0x40);
|
|
|
|
tp28xx_byte_write(chip, 0x30, 0x41);
|
|
tp28xx_byte_write(chip, 0x31, 0x82);
|
|
tp28xx_byte_write(chip, 0x32, 0x27);
|
|
tp28xx_byte_write(chip, 0x33, 0xa0);
|
|
}
|
|
|
|
static void TP2854_output(unsigned char chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x40, 0x08);
|
|
tp28xx_byte_write(chip, 0x01, 0xf8);
|
|
tp28xx_byte_write(chip, 0x02, 0x01);
|
|
tp28xx_byte_write(chip, 0x08, 0x0f);
|
|
if (id[chip] == TP2854B) {
|
|
tp28xx_byte_write(chip, 0x0a, 0x80); //->add
|
|
tp28xx_byte_write(chip, 0x10, 0x20);
|
|
tp28xx_byte_write(chip, 0x11, 0x47);
|
|
tp28xx_byte_write(chip, 0x12, 0x54);
|
|
tp28xx_byte_write(chip, 0x13, 0xef);
|
|
#if (CVBS_FRAME_OUTPUT)
|
|
tp28xx_byte_write(chip, 0x21, 0x07);
|
|
#endif
|
|
if (output == MIPI_4CH4LANE_594M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x44);
|
|
tp28xx_byte_write(chip, 0x34, 0xe4);
|
|
tp28xx_byte_write(chip, 0x15, 0x00);
|
|
tp28xx_byte_write(chip, 0x25, 0x08);
|
|
tp28xx_byte_write(chip, 0x26, 0x06);
|
|
tp28xx_byte_write(chip, 0x27, 0x11);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x14, 0x86);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
} else if (output == MIPI_2CH4LANE_594M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x24);
|
|
tp28xx_byte_write(chip, 0x34, 0xe8); //output vin1&vin2
|
|
tp28xx_byte_write(chip, 0x15, 0x00);
|
|
tp28xx_byte_write(chip, 0x25, 0x08);
|
|
tp28xx_byte_write(chip, 0x26, 0x06);
|
|
tp28xx_byte_write(chip, 0x27, 0x11);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x14, 0x86);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
} else if (output == MIPI_4CH4LANE_297M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x44);
|
|
tp28xx_byte_write(chip, 0x34, 0xe4);
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x25, 0x04);
|
|
tp28xx_byte_write(chip, 0x26, 0x04);
|
|
tp28xx_byte_write(chip, 0x27, 0x09);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0x4f);
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
} else if (output == MIPI_2CH4LANE_297M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x24);
|
|
tp28xx_byte_write(chip, 0x34, 0xe8); //output vin1&vin2
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x25, 0x04);
|
|
tp28xx_byte_write(chip, 0x26, 0x04);
|
|
tp28xx_byte_write(chip, 0x27, 0x09);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0x4f);
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
} else if (output == MIPI_1CH4LANE_297M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x14);
|
|
tp28xx_byte_write(chip, 0x34, 0xe4);
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x25, 0x04);
|
|
tp28xx_byte_write(chip, 0x26, 0x04);
|
|
tp28xx_byte_write(chip, 0x27, 0x09);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0x4f);
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
} else if (output == MIPI_4CH2LANE_594M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x42);
|
|
tp28xx_byte_write(chip, 0x34, 0xe4);
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x25, 0x08);
|
|
tp28xx_byte_write(chip, 0x26, 0x06);
|
|
tp28xx_byte_write(chip, 0x27, 0x11);
|
|
tp28xx_byte_write(chip, 0x29, 0x0a);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x14, 0x86);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
} else if (output == MIPI_2CH2LANE_594M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x22);
|
|
tp28xx_byte_write(chip, 0x34, 0xe8); //output vin1&vin2
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x25, 0x08);
|
|
tp28xx_byte_write(chip, 0x26, 0x06);
|
|
tp28xx_byte_write(chip, 0x27, 0x11);
|
|
tp28xx_byte_write(chip, 0x29, 0x0a);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x14, 0x86);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
}else if (output == MIPI_1CH2LANE_594M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x12);
|
|
tp28xx_byte_write(chip, 0x34, 0xe4);
|
|
tp28xx_byte_write(chip, 0x15, 0x01);
|
|
tp28xx_byte_write(chip, 0x25, 0x08);
|
|
tp28xx_byte_write(chip, 0x26, 0x06);
|
|
tp28xx_byte_write(chip, 0x27, 0x11);
|
|
tp28xx_byte_write(chip, 0x29, 0x0a);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
tp28xx_byte_write(chip, 0x14, 0x86);
|
|
tp28xx_byte_write(chip, 0x14, 0x06);
|
|
}else if (output == MIPI_2CH2LANE_297M) {
|
|
tp28xx_byte_write(chip, 0x20, 0x22);
|
|
tp28xx_byte_write(chip, 0x34, 0xe8); //output vin1&vin2
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
tp28xx_byte_write(chip, 0x15, 0x02);
|
|
tp28xx_byte_write(chip, 0x25, 0x04);
|
|
tp28xx_byte_write(chip, 0x26, 0x03);
|
|
tp28xx_byte_write(chip, 0x27, 0x09);
|
|
tp28xx_byte_write(chip, 0x29, 0x02);
|
|
tp28xx_byte_write(chip, 0x33, 0x0f);
|
|
tp28xx_byte_write(chip, 0x33, 0x00);
|
|
tp28xx_byte_write(chip, 0x14, 0xc7);
|
|
tp28xx_byte_write(chip, 0x14, 0x47);
|
|
}
|
|
}
|
|
tp28xx_byte_write(chip, 0x40, 0x04);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
static void tp2802_comm_init( int chip)
|
|
{
|
|
tp2802_set_reg_page(chip, CH_ALL);
|
|
|
|
{
|
|
TP2854_reset_default(chip, CH_ALL);
|
|
|
|
tp2802_set_video_mode(chip, tp_work_mode, CH_ALL, STD_TVI);
|
|
|
|
#if(WDT)
|
|
tp28xx_byte_write(chip, 0x26, 0x04);
|
|
#endif
|
|
|
|
TP2854_RX_init(chip, PTZ_RX_ACP1);
|
|
}
|
|
|
|
}
|
|
|
|
static void tp2802_video_init(int chip)
|
|
{
|
|
tp28xx_byte_write(chip, 0x10, 0x70);
|
|
tp28xx_byte_write(chip, 0x11, 0x45);
|
|
tp28xx_byte_write(chip, 0x12, 0x50);
|
|
tp28xx_byte_write(chip, 0x13, 0xf5);
|
|
tp28xx_byte_write(chip, 0x14, 0x3f);
|
|
}
|
|
|
|
static struct file_operations tp2802_fops = {
|
|
.owner = THIS_MODULE,
|
|
.unlocked_ioctl = tp2802_ioctl,
|
|
.open = tp2802_open,
|
|
.release = tp2802_close
|
|
};
|
|
|
|
static struct miscdevice tp2802_dev = {
|
|
.minor = MISC_DYNAMIC_MINOR,
|
|
.name = "tp2802dev",
|
|
.fops = &tp2802_fops,
|
|
};
|
|
|
|
module_param(tp_work_mode, uint, S_IRUGO);
|
|
module_param(chips, uint, S_IRUGO);
|
|
module_param(output, uint, S_IRUGO);
|
|
|
|
static int __init tp2802_module_init(void)
|
|
{
|
|
int ret = 0, i = 0;
|
|
#if (DEBUG)
|
|
|
|
printk("TP2854 driver version %d.%d.%d loaded\n",
|
|
(TP2802_VERSION_CODE >> 16) & 0xff,
|
|
(TP2802_VERSION_CODE >> 8) & 0xff,
|
|
TP2802_VERSION_CODE & 0xff);
|
|
#endif
|
|
if (chips <= 0 || chips > MAX_CHIPS) {
|
|
printk("TP2854 module param 'chips' invalid value:%d\n", chips);
|
|
return FAILURE;
|
|
}
|
|
|
|
gpio_reg = (volatile unsigned int*)ioremap(0x1109F000, 0x420);
|
|
pinmux_reg = (volatile unsigned int*)ioremap(0x17C7011C, 0x10);
|
|
pinmux_ioctl_reg = (volatile unsigned int*)ioremap(0x17C5000C, 0x10);
|
|
*pinmux_reg = 0x430; //set GPIO15_1 pin mux: gpio
|
|
|
|
if (chips <= 0 || chips > MAX_CHIPS)
|
|
{
|
|
printk("TP2854 module param 'chips' invalid value:%d\n", chips);
|
|
return FAILURE;
|
|
}
|
|
|
|
/* register misc device*/
|
|
ret = misc_register(&tp2802_dev);
|
|
if (ret) {
|
|
printk("ERROR: could not register tp2854 device module\n");
|
|
goto umap_reg;
|
|
}
|
|
|
|
i2c_client_init();
|
|
|
|
sema_init(&watchdog_lock, 1);
|
|
|
|
|
|
/* initize each tp2802*/
|
|
for (i = 0; i < chips; i ++)
|
|
{
|
|
*pinmux_ioctl_reg = i;
|
|
//page reset
|
|
tp28xx_byte_write(i, 0x40, 0x00);
|
|
|
|
#if (DEBUG)
|
|
val = tp28xx_byte_read(i, 0xfe);
|
|
if(0x28 == val) {
|
|
printk("Detected TP28xx \n");
|
|
} else {
|
|
id[i] = 0xffff;
|
|
printk("Invalid chip %2x\n", val);
|
|
}
|
|
#endif
|
|
|
|
id[i] = tp28xx_byte_read(i, 0xff);
|
|
id[i] <<=8;
|
|
id[i] +=tp28xx_byte_read(i, 0xfd);
|
|
|
|
#if (DEBUG)
|
|
printk("Detected ID&revision %04x\n", id[i]);
|
|
#endif
|
|
|
|
tp2802_comm_init(i);
|
|
|
|
tp2802_video_init(i);
|
|
}
|
|
|
|
|
|
#if (WDT)
|
|
ret = TP2802_watchdog_init();
|
|
if (ret) {
|
|
printk("ERROR: could not create watchdog\n");
|
|
goto dev_deregist;
|
|
}
|
|
#endif
|
|
|
|
printk("TP2854b Driver Init Successful!\n");
|
|
|
|
return SUCCESS;
|
|
|
|
#if (WDT)
|
|
dev_deregist:
|
|
misc_deregister(&tp2802_dev);
|
|
#endif
|
|
umap_reg:
|
|
iounmap((void *)gpio_reg);
|
|
gpio_reg = NULL;
|
|
iounmap((void *)pinmux_reg);
|
|
pinmux_reg = NULL;
|
|
return FAILURE;
|
|
}
|
|
|
|
static void __exit tp2802_module_exit(void)
|
|
{
|
|
#if (WDT)
|
|
TP2802_watchdog_exit();
|
|
#endif
|
|
|
|
i2c_client_exit();
|
|
|
|
iounmap((void*)pinmux_ioctl_reg);
|
|
iounmap((void*)gpio_reg);
|
|
iounmap((void*)pinmux_reg);
|
|
|
|
|
|
misc_deregister(&tp2802_dev);
|
|
|
|
printk("TP2854b Driver Exit Successful!\n");
|
|
}
|
|
|
|
void tp283x_egain(unsigned int chip, unsigned int CGAIN_STD)
|
|
{
|
|
unsigned int tmp, cgain;
|
|
unsigned int retry = 30;
|
|
|
|
tp28xx_byte_write(chip, 0x2f, 0x06);
|
|
cgain = tp28xx_byte_read(chip, 0x04);
|
|
#if (DEBUG)
|
|
printk("Cgain=0x%02x \r\n", cgain );
|
|
#endif
|
|
|
|
if (cgain < CGAIN_STD) {
|
|
while (retry) {
|
|
retry--;
|
|
|
|
tmp = tp28xx_byte_read(chip, 0x07);
|
|
tmp &= 0x3f;
|
|
while (abs(CGAIN_STD - cgain)) {
|
|
if (tmp)
|
|
tmp--;
|
|
else
|
|
break;
|
|
cgain++;
|
|
}
|
|
|
|
tp28xx_byte_write(chip, 0x07, 0x80 | tmp);
|
|
if (tmp == 0)
|
|
break;
|
|
msleep(40);
|
|
tp28xx_byte_write(chip, 0x2f, 0x06);
|
|
cgain = tp28xx_byte_read(chip, 0x04);
|
|
#if (DEBUG)
|
|
printk("Cgain=0x%02x \r\n", cgain);
|
|
#endif
|
|
if (cgain > (CGAIN_STD + 1)) {
|
|
tmp = tp28xx_byte_read(chip, 0x07);
|
|
tmp &= 0x3f;
|
|
tmp += 0x02;
|
|
if (tmp > 0x3f)
|
|
tmp = 0x3f;
|
|
tp28xx_byte_write(chip, 0x07, 0x80 | tmp);
|
|
if (tmp == 0x3f)
|
|
break;
|
|
msleep(40);
|
|
cgain = tp28xx_byte_read(chip, 0x04);
|
|
#if (DEBUG)
|
|
printk("Cgain=0x%02x \r\n", cgain);
|
|
#endif
|
|
}
|
|
if (abs(cgain - CGAIN_STD) < 2)
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
unsigned char tp28xx_read_egain(unsigned char chip)
|
|
{
|
|
unsigned char gain;
|
|
|
|
tp28xx_byte_write(chip, 0x2f, 0x00);
|
|
gain = tp28xx_byte_read(chip, 0x04);
|
|
return gain;
|
|
}
|
|
|
|
static int TP2802_watchdog_deamon(void *data)
|
|
{
|
|
int iChip;
|
|
int i;
|
|
|
|
struct sched_param param = {
|
|
.sched_priority = 99
|
|
};
|
|
|
|
tp2802wd_info *wdi = NULL;
|
|
|
|
struct timeval start, end;
|
|
unsigned char status, cvstd, gain, tmp, flag_locked;
|
|
unsigned char rx1, rx2;
|
|
|
|
printk("TP2854_watchdog_deamon: start!\n");
|
|
|
|
sched_setscheduler(current, SCHED_FIFO, ¶m);
|
|
current->flags |= PF_NOFREEZE;
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
while (watchdog_state != WATCHDOG_EXIT) {
|
|
down(&watchdog_lock);
|
|
|
|
do_gettimeofday(&start);
|
|
|
|
for (iChip = 0; iChip < chips; iChip++) {
|
|
*pinmux_ioctl_reg = i;
|
|
|
|
wdi = &watchdog_info[iChip];
|
|
if (id[iChip] == 0xffff)
|
|
continue;
|
|
|
|
for (i = 0; i < CHANNELS_PER_CHIP; i++) { // scan four inputs:
|
|
if (wdi->scan[i] == SCAN_DISABLE)
|
|
continue;
|
|
|
|
tp2802_set_reg_page(iChip, i);
|
|
|
|
status = tp28xx_byte_read(iChip, 0x01);
|
|
// state machine for video checking
|
|
if (status & FLAG_LOSS) { // no video
|
|
if (wdi->state[i] != VIDEO_UNPLUG) { // switch to no video
|
|
wdi->state[i] = VIDEO_UNPLUG;
|
|
wdi->count[i] = 0;
|
|
if (wdi->scan[i] != SCAN_MANUAL)
|
|
wdi->mode[i] = INVALID_FORMAT;
|
|
#if (DEBUG)
|
|
printk("video loss ch%02x chip%2x\r\n", i, iChip );
|
|
#endif
|
|
}
|
|
|
|
if (wdi->count[i] == 0) { // first time into no video
|
|
TP28xx_reset_default(iChip, i);
|
|
wdi->count[i]++;
|
|
} else {
|
|
if (wdi->count[i] < MAX_COUNT)
|
|
wdi->count[i]++;
|
|
continue;
|
|
}
|
|
} else { // there is video
|
|
if (wdi->mode[i] == TP2802_PAL || wdi->mode[i] == TP2802_NTSC)
|
|
flag_locked = FLAG_HV_LOCKED;
|
|
else
|
|
flag_locked = FLAG_HV_LOCKED;
|
|
|
|
if (flag_locked == (status & flag_locked)) { // video locked
|
|
if (wdi->state[i] == VIDEO_LOCKED) {
|
|
if (wdi->count[i] < MAX_COUNT)
|
|
wdi->count[i]++;
|
|
} else if (wdi->state[i] == VIDEO_UNPLUG) {
|
|
wdi->state[i] = VIDEO_IN;
|
|
wdi->count[i] = 0;
|
|
#if (DEBUG)
|
|
printk("1video in ch%02x chip%2x\r\n", i, iChip);
|
|
#endif
|
|
} else if (wdi->mode[i] != INVALID_FORMAT) {
|
|
{
|
|
wdi->state[i] = VIDEO_LOCKED;
|
|
wdi->count[i] = 0;
|
|
#if (DEBUG)
|
|
printk("video locked %02x ch%02x chip%2x\r\n", status, i, iChip);
|
|
#endif
|
|
}
|
|
}
|
|
} else { // video in but unlocked
|
|
if (wdi->state[i] == VIDEO_UNPLUG) {
|
|
wdi->state[i] = VIDEO_IN;
|
|
wdi->count[i] = 0;
|
|
#if (DEBUG)
|
|
printk("2video in ch%02x chip%2x\r\n", i, iChip);
|
|
#endif
|
|
} else if (wdi->state[i] == VIDEO_LOCKED) {
|
|
wdi->state[i] = VIDEO_UNLOCK;
|
|
wdi->count[i] = 0;
|
|
#if (DEBUG)
|
|
printk("video unstable ch%02x chip%2x\r\n", i, iChip);
|
|
#endif
|
|
} else {
|
|
if (wdi->count[i] < MAX_COUNT)
|
|
wdi->count[i]++;
|
|
if (wdi->state[i] == VIDEO_UNLOCK && wdi->count[i] > 2) {
|
|
wdi->state[i] = VIDEO_IN;
|
|
wdi->count[i] = 0;
|
|
if (wdi->scan[i] != SCAN_MANUAL)
|
|
TP28xx_reset_default(iChip, i);
|
|
#if (DEBUG)
|
|
printk("video unlocked ch%02x chip%2x\r\n", i, iChip);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
if (wdi->force[i]) { // manual reset for V1/2 switching
|
|
wdi->state[i] = VIDEO_UNPLUG;
|
|
wdi->count[i] = 0;
|
|
wdi->mode[i] = INVALID_FORMAT;
|
|
wdi->force[i] = 0;
|
|
TP28xx_reset_default(iChip, i);
|
|
}
|
|
}
|
|
|
|
if (wdi->state[i] == VIDEO_IN) {
|
|
if (wdi->scan[i] != SCAN_MANUAL) {
|
|
cvstd = tp28xx_byte_read(iChip, 0x03);
|
|
cvstd &= 0x0f;
|
|
{
|
|
wdi->std[i] = STD_TVI;
|
|
|
|
if( TP2802_SD == (cvstd&0x07) ) {
|
|
if(wdi->count[i] & 0x01) {
|
|
wdi-> mode[i] = TP2802_PAL;
|
|
tp2802_set_video_mode(iChip, wdi-> mode[i], i, STD_TVI);
|
|
} else {
|
|
wdi-> mode[i] = TP2802_NTSC;
|
|
tp2802_set_video_mode(iChip, wdi-> mode[i], i, STD_TVI);
|
|
}
|
|
} else if((cvstd&0x07) < 6 ) {
|
|
if (wdi->scan[i] == SCAN_HDA || wdi->scan[i] == SCAN_HDC) {
|
|
if (wdi->scan[i] == SCAN_HDA)
|
|
wdi->std[i] = STD_HDA;
|
|
else if (wdi->scan[i] == SCAN_HDC)
|
|
wdi->std[i] = STD_HDC;
|
|
|
|
if ((cvstd & 0x07) == TP2802_720P25) {
|
|
wdi->mode[i] = TP2802_720P25V2;
|
|
} else if ((cvstd & 0x07) == TP2802_720P30) {
|
|
wdi->mode[i] = TP2802_720P30V2;
|
|
} else {
|
|
wdi->mode[i] = cvstd & 0x07;
|
|
}
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else { // TVI
|
|
if ((cvstd & 0x0f) == TP2802_720P25V2 || (cvstd & 0x0f) == TP2802_720P30V2) {
|
|
wdi->mode[i] = cvstd & 0x0f;
|
|
} else {
|
|
wdi->mode[i] = cvstd & 0x07;
|
|
}
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
} else { // format is 7
|
|
if (wdi->scan[i] == SCAN_HDA)
|
|
wdi->std[i] = STD_HDA;
|
|
if (wdi->scan[i] == SCAN_HDC)
|
|
wdi->std[i] = STD_HDC;
|
|
|
|
tp28xx_byte_write(iChip, 0x2f, 0x09);
|
|
tmp = tp28xx_byte_read(iChip, 0x04);
|
|
#if (DEBUG)
|
|
printk("detection %02x ch%02x chip%2x\r\n", tmp, i, iChip);
|
|
#endif
|
|
if (tmp == 0x4e) {
|
|
if (wdi->scan[i] == SCAN_HDA || wdi->scan[i] == SCAN_AUTO)
|
|
wdi->mode[i] = TP2802_QXGA18;
|
|
else
|
|
wdi->mode[i] = TP2802_3M18;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if (tmp == 0x5d) {
|
|
if (wdi->count[i] & 1) {
|
|
wdi->mode[i] = TP2802_5M12;
|
|
wdi->std[i] = STD_HDA;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else {
|
|
wdi->mode[i] = TP2802_4M15;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
} else if (tmp == 0x5c) {
|
|
wdi->mode[i] = TP2802_5M12;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if (tmp == 0x75) {
|
|
wdi->mode[i] = TP2802_6M10;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if (tmp == 0x38) {
|
|
wdi->mode[i] = TP2802_QXGA25; // current only HDA
|
|
wdi->std[i] = STD_HDA;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if (tmp == 0x2e) {
|
|
wdi->mode[i] = TP2802_QXGA30; // current only HDA
|
|
wdi->std[i] = STD_HDA;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if (tmp == 0x3a) { // invalid for TP2853C
|
|
if (wdi->mode[i] != TP2802_5M20) {
|
|
wdi->mode[i] = TP2802_5M20;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
} else if (tmp == 0x89) {
|
|
wdi->mode[i] = TP2802_1080P15;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if (tmp == 0x22) {
|
|
wdi->mode[i] = TP2802_1080P60;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if(0x93 == tmp) {
|
|
wdi-> mode[i] = TP2802_NTSC;
|
|
tp2802_set_video_mode(iChip, wdi-> mode[i], i, wdi-> std[i]);
|
|
} else if(0x94 == tmp) {
|
|
wdi-> mode[i] = TP2802_PAL;
|
|
tp2802_set_video_mode(iChip, wdi-> mode[i], i, wdi-> std[i]);
|
|
}
|
|
}
|
|
|
|
if ((wdi->count[i] & 1) && (wdi->mode[i] == TP2802_1080P25)) {
|
|
wdi->mode[i] = TP2802_8M12;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
if ((wdi->count[i] & 1) && (wdi->mode[i] == TP2802_1080P30)) {
|
|
wdi->mode[i] = TP2802_8M15;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
if ((wdi->count[i] & 1) && (wdi->mode[i] == TP2802_720P30)) {
|
|
wdi->mode[i] = TP2802_4M12;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
if ((wdi->count[i] & 1) && (wdi->mode[i] == TP2802_720P60)) {
|
|
wdi->mode[i] = TP2802_QHD30;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
if ((wdi->count[i] & 1) && (wdi->mode[i] == TP2802_720P50)) {
|
|
wdi->mode[i] = TP2802_QHD25;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
|
|
if ((wdi->count[i] & 1) && (wdi->mode[i] == TP2802_720P30V2)) {
|
|
wdi->mode[i] = TP2802_QHD15;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
|
|
if ((wdi->count[i] > 2) && (wdi->mode[i] == TP2802_QXGA18)) {
|
|
if (wdi->scan[i] == SCAN_AUTO) {
|
|
wdi->mode[i] = TP2802_3M18;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#define EQ_COUNT 10
|
|
if (wdi->state[i] == VIDEO_LOCKED) { // check signal lock
|
|
if (wdi->count[i] == 0) {
|
|
{
|
|
tmp = tp28xx_byte_read(iChip, 0x26);
|
|
tmp |= 0x01;
|
|
tp28xx_byte_write(iChip, 0x26, tmp);
|
|
}
|
|
|
|
if ((wdi->scan[i] == SCAN_AUTO || wdi->scan[i] == SCAN_TVI)) {
|
|
if ((wdi->mode[i] == TP2802_720P30V2) || (wdi->mode[i] == TP2802_720P25V2)) {
|
|
tmp = tp28xx_byte_read(iChip, 0x03);
|
|
#if (DEBUG)
|
|
printk("CVSTD%02x ch%02x chip%2x\r\n", tmp, i, iChip);
|
|
#endif
|
|
if (!(0x08 & tmp)) {
|
|
#if (DEBUG)
|
|
printk("720P V1 Detected ch%02x chip%2x\r\n", i, iChip);
|
|
#endif
|
|
wdi->mode[i] &= 0xf7;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, STD_TVI); // to speed the switching
|
|
}
|
|
} else if ((wdi->mode[i] == TP2802_720P30) || (wdi->mode[i] == TP2802_720P25)) {
|
|
tmp = tp28xx_byte_read(iChip, 0x03);
|
|
#if (DEBUG)
|
|
printk("CVSTD%02x ch%02x chip%2x\r\n", tmp, i, iChip);
|
|
#endif
|
|
if (0x08 & tmp) {
|
|
#if (DEBUG)
|
|
printk("720P V2 Detected ch%02x chip%2x\r\n", i, iChip);
|
|
#endif
|
|
wdi->mode[i] |= 0x08;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, STD_TVI); // to speed the switching
|
|
}
|
|
}
|
|
|
|
{
|
|
tmp = tp28xx_byte_read(iChip, 0xa7);
|
|
tmp &= 0xfe;
|
|
tp28xx_byte_write(iChip, 0xa7, tmp);
|
|
tp28xx_byte_write(iChip, 0x1f, 0x06);
|
|
tp28xx_byte_write(iChip, 0x1e, 0x60);
|
|
}
|
|
}
|
|
} else if (wdi->count[i] == 1) {
|
|
tmp = tp28xx_byte_read(iChip, 0xa7);
|
|
tmp |= 0x01;
|
|
tp28xx_byte_write(iChip, 0xa7, tmp);
|
|
|
|
#if (DEBUG)
|
|
tmp = tp28xx_byte_read(iChip, 0x01);
|
|
printk("status%02x ch%02x\r\n", tmp, i);
|
|
tmp = tp28xx_byte_read(iChip, 0x03);
|
|
printk("CVSTD%02x ch%02x\r\n", tmp, i);
|
|
#endif
|
|
} else if (wdi->count[i] < EQ_COUNT - 3) {
|
|
if (wdi->scan[i] == SCAN_AUTO) {
|
|
if (wdi->std[i] == STD_TVI) {
|
|
tmp = tp28xx_byte_read(iChip, 0x01);
|
|
|
|
if ((wdi->mode[i] == TP2802_PAL) || (wdi->mode[i] == TP2802_NTSC)) {
|
|
// nothing to do
|
|
} else if (wdi->mode[i] == TP2802_QXGA18) {
|
|
if ((tmp & 0x64) == 0x60) {
|
|
wdi->std[i] = STD_HDA; // no CVI QXGA18
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
} else if (wdi->mode[i] == TP2802_QHD15 || wdi->mode[i] == TP2802_5M20 ||
|
|
wdi->mode[i] == TP2802_5M12 || wdi->mode[i] == TP2802_8M15) {
|
|
if ((tmp & 0x64) == 0x60) {
|
|
wdi->std[i] = STD_HDA; // no CVI QHD15/5M20/5M12.5
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
}
|
|
} else if (wdi->mode[i] == TP2802_QHD25 || wdi->mode[i] == TP2802_QHD30) {
|
|
tp28xx_byte_write(iChip, 0x2f, 0x0f);
|
|
rx1 = tp28xx_byte_read(iChip, 0x04);
|
|
if (rx1 > 0x30)
|
|
wdi->std[i] = STD_HDA;
|
|
else if ((tmp & 0x64) == 0x60)
|
|
wdi->std[i] = STD_HDC;
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
} else if ((tmp & 0x64) == 0x60) {
|
|
rx2 = tp28xx_byte_read(iChip, 0x94); // capture line7 to match 3M/4M RT
|
|
|
|
if (HDC_enable) {
|
|
if (rx2 == 0xff)
|
|
wdi->std[i] = STD_HDC;
|
|
else if (rx2 == 0x00)
|
|
wdi->std[i] = STD_HDC_DEFAULT;
|
|
else
|
|
wdi->std[i] = STD_HDA;
|
|
} else {
|
|
wdi->std[i] = STD_HDA;
|
|
}
|
|
|
|
if (wdi->std[i] != STD_TVI) {
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
#if (DEBUG)
|
|
printk("RX=%02x standard to %02x ch%02x\r\n", rx2, wdi->std[i], i);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (wdi->count[i] < EQ_COUNT) { // skip
|
|
wdi->gain[i][3] = wdi->gain[i][2];
|
|
wdi->gain[i][2] = wdi->gain[i][1];
|
|
wdi->gain[i][1] = wdi->gain[i][0];
|
|
|
|
wdi->gain[i][0] = tp28xx_read_egain(iChip);
|
|
} else if (wdi->count[i] < EQ_COUNT + EQ_COUNT) { // add timeout handle
|
|
wdi->gain[i][3] = wdi->gain[i][2];
|
|
wdi->gain[i][2] = wdi->gain[i][1];
|
|
wdi->gain[i][1] = wdi->gain[i][0];
|
|
|
|
wdi->gain[i][0] = tp28xx_read_egain(iChip);
|
|
|
|
if (abs(wdi->gain[i][3] - wdi->gain[i][0]) < 0x02 &&
|
|
abs(wdi->gain[i][2] - wdi->gain[i][0]) < 0x02 &&
|
|
abs(wdi->gain[i][1] - wdi->gain[i][0]) < 0x02) {
|
|
wdi->count[i] = EQ_COUNT + EQ_COUNT - 1; // exit when EQ stable
|
|
}
|
|
} else if (wdi->count[i] == EQ_COUNT + EQ_COUNT) {
|
|
gain = tp28xx_read_egain(iChip);
|
|
|
|
if (wdi->std[i] != STD_TVI) {
|
|
tp28xx_byte_write(iChip, 0x07, 0x80 | (gain >> 2)); // manual mode
|
|
} else { // TVI
|
|
}
|
|
} else if (wdi->count[i] == EQ_COUNT + EQ_COUNT + 1) {
|
|
if (wdi->scan[i] == SCAN_AUTO) {
|
|
if (HDC_enable) {
|
|
if (wdi->std[i] == STD_HDC_DEFAULT) {
|
|
tp28xx_byte_write(iChip, 0x2f, 0x0c);
|
|
tmp = tp28xx_byte_read(iChip, 0x04);
|
|
status = tp28xx_byte_read(iChip, 0x01);
|
|
// if(0x10 == (0x11 & status) && (tmp < 0x18 || tmp > 0xf0))
|
|
if ((0x11 & status) == 0x10) {
|
|
// if((tmp < 0x18 || tmp > 0xf0))
|
|
wdi->std[i] = STD_HDC;
|
|
} else {
|
|
wdi->std[i] = STD_HDA;
|
|
}
|
|
tp2802_set_video_mode(iChip, wdi->mode[i], i, wdi->std[i]);
|
|
#if (DEBUG)
|
|
printk("reg01=%02x reg04@2f=0c %02x std%02x ch%02x\r\n", status, tmp, wdi->std[i],
|
|
i);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
if (wdi->std[i] != STD_TVI) {
|
|
tp283x_egain(iChip, 0x0c);
|
|
} else { // TVI
|
|
}
|
|
} else {
|
|
if (wdi->scan[i] == SCAN_AUTO) {
|
|
if ((wdi->mode[i] & (~FLAG_HALF_MODE)) < TP2802_3M18) {
|
|
tmp = tp28xx_byte_read(iChip, 0x03); //
|
|
tmp &= 0x07;
|
|
if (tmp != (wdi->mode[i] & 0x07) && tmp < TP2802_SD) {
|
|
#if (DEBUG)
|
|
printk("correct %02x from %02x ch%02x\r\n", tmp, wdi->mode[i], i);
|
|
#endif
|
|
|
|
wdi->force[i] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
do_gettimeofday(&end);
|
|
|
|
up(&watchdog_lock);
|
|
|
|
/* sleep 0.5 seconds */
|
|
schedule_timeout_interruptible(msecs_to_jiffies(500) + 1);
|
|
}
|
|
|
|
set_current_state(TASK_RUNNING);
|
|
|
|
printk("TP2854_watchdog_deamon: exit!\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
int __init TP2802_watchdog_init(void)
|
|
{
|
|
int ret;
|
|
struct task_struct *p_dog = NULL;
|
|
int i, j;
|
|
watchdog_state = WATCHDOG_RUNNING;
|
|
ret = memset_s(&watchdog_info, MAX_CHIPS * sizeof(tp2802wd_info), 0, MAX_CHIPS * sizeof(tp2802wd_info));
|
|
if (ret != EOK) {
|
|
printk("memset_s failed!\n");
|
|
return -1;
|
|
}
|
|
|
|
for (i = 0; i < MAX_CHIPS; i++) {
|
|
watchdog_info[i].addr = tp2854b_i2c_addr[i];
|
|
for (j = 0; j < CHANNELS_PER_CHIP; j++) {
|
|
watchdog_info[i].count[j] = 0;
|
|
watchdog_info[i].force[j] = 0;
|
|
watchdog_info[i].mode[j] = INVALID_FORMAT;
|
|
watchdog_info[i].scan[j] = SCAN_AUTO;
|
|
watchdog_info[i].state[j] = VIDEO_UNPLUG;
|
|
watchdog_info[i].std[j] = STD_TVI;
|
|
}
|
|
}
|
|
|
|
p_dog = kthread_create(TP2802_watchdog_deamon, NULL, "TP2854_WDT");
|
|
|
|
if (IS_ERR(p_dog)) {
|
|
printk("TP2854_watchdog_init: create watchdog_deamon failed!\n");
|
|
return -1;
|
|
}
|
|
|
|
wake_up_process(p_dog);
|
|
|
|
task_watchdog_deamon = p_dog;
|
|
|
|
printk("TP2854_watchdog_init: done!\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
void __exit TP2802_watchdog_exit(void)
|
|
{
|
|
struct task_struct *p_dog = task_watchdog_deamon;
|
|
watchdog_state = WATCHDOG_EXIT;
|
|
|
|
if (p_dog == NULL)
|
|
return;
|
|
|
|
wake_up_process(p_dog);
|
|
|
|
kthread_stop(p_dog);
|
|
|
|
yield();
|
|
|
|
task_watchdog_deamon = NULL;
|
|
|
|
printk("TP2854_watchdog_exit: done!\n");
|
|
}
|
|
|
|
module_init(tp2802_module_init);
|
|
module_exit(tp2802_module_exit);
|