mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-16 19:38:56 +00:00
V1.0.6
This commit is contained in:
@@ -2,10 +2,29 @@ config AIC_USING_CAMERA
|
||||
bool "Using camera device"
|
||||
default n
|
||||
|
||||
config AIC_USING_CAMERA_OV5640
|
||||
bool "Using camera OV5640"
|
||||
choice
|
||||
prompt "Select camera device"
|
||||
default AIC_USING_CAMERA_OV5640
|
||||
depends on AIC_USING_CAMERA && AIC_I2C_DRV
|
||||
default n
|
||||
|
||||
config AIC_USING_CAMERA_OV7670
|
||||
bool "Using camera OV7670"
|
||||
|
||||
config AIC_USING_CAMERA_OV5640
|
||||
bool "Using camera OV5640"
|
||||
|
||||
config AIC_USING_CAMERA_OV2659
|
||||
bool "Using camera OV2659"
|
||||
|
||||
config AIC_USING_CAMERA_OV2640
|
||||
bool "Using camera OV2640"
|
||||
|
||||
config AIC_USING_CAMERA_GM7150
|
||||
bool "Using camera GM7150"
|
||||
|
||||
config AIC_USING_CAMERA_TP2825
|
||||
bool "Using camera TP2825"
|
||||
endchoice
|
||||
|
||||
config AIC_CAMERA_I2C_CHAN
|
||||
int "The No. of I2C channel"
|
||||
|
||||
@@ -9,9 +9,24 @@ CPPPATH = []
|
||||
if GetDepend('AIC_USING_CAMERA'):
|
||||
CPPPATH.append(cwd)
|
||||
|
||||
if GetDepend('AIC_USING_CAMERA_OV7670'):
|
||||
src += Glob('ov7670/*.c')
|
||||
|
||||
if GetDepend('AIC_USING_CAMERA_OV5640'):
|
||||
src += Glob('ov5640/*.c')
|
||||
|
||||
if GetDepend('AIC_USING_CAMERA_OV2659'):
|
||||
src += Glob('ov2659/*.c')
|
||||
|
||||
if GetDepend('AIC_USING_CAMERA_OV2640'):
|
||||
src += Glob('ov2640/*.c')
|
||||
|
||||
if GetDepend('AIC_USING_CAMERA_GM7150'):
|
||||
src += Glob('gm7150/*.c')
|
||||
|
||||
if GetDepend('AIC_USING_CAMERA_TP2825'):
|
||||
src += Glob('tp2825b/tp2825bx.c')
|
||||
|
||||
LOCAL_CCFLAGS = ''
|
||||
# LOCAL_CCFLAGS += ' -O0'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
|
||||
#include "rtdef.h"
|
||||
|
||||
#define CAMERA_NAME_OV "ov-cam"
|
||||
#define CAMERA_DEV_NAME "camera"
|
||||
|
||||
#define CAMERA_CMD_START (RT_DEVICE_CTRL_BASE(CAMERA) + 0x01)
|
||||
#define CAMERA_CMD_STOP (RT_DEVICE_CTRL_BASE(CAMERA) + 0x02)
|
||||
|
||||
271
bsp/peripheral/camera/gm7150/drv_gm7150.c
Normal file
271
bsp/peripheral/camera/gm7150/drv_gm7150.c
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright (c) 2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: matteo <duanmt@artinchip.com>
|
||||
*/
|
||||
|
||||
#define LOG_TAG "gm7150"
|
||||
|
||||
#include <drivers/i2c.h>
|
||||
#include <drivers/pin.h>
|
||||
|
||||
#include "aic_core.h"
|
||||
#include "mpp_types.h"
|
||||
#include "mpp_img_size.h"
|
||||
#include "mpp_vin.h"
|
||||
|
||||
#include "drv_camera.h"
|
||||
|
||||
/* Default format configuration of GM7150 */
|
||||
#define GM7150_DFT_WIDTH PAL_WIDTH
|
||||
#define GM7150_DFT_HEIGHT PAL_HEIGHT
|
||||
#define GM7150_DFT_BUS_TYPE MEDIA_BUS_BT656
|
||||
#define GM7150_DFT_CODE MEDIA_BUS_FMT_UYVY8_2X8
|
||||
|
||||
#define GM7150_I2C_SLAVE_ID 0x5C // or 0x5D
|
||||
#define GM7150_CHIP_ID 0x7150
|
||||
|
||||
struct gm7150_dev {
|
||||
struct rt_device dev;
|
||||
struct rt_i2c_bus_device *i2c;
|
||||
u32 rst_pin;
|
||||
u32 pwdn_pin;
|
||||
|
||||
struct mpp_video_fmt fmt;
|
||||
|
||||
bool streaming;
|
||||
};
|
||||
|
||||
static struct gm7150_dev g_gm7150_dev = {0};
|
||||
|
||||
static int gm7150_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val)
|
||||
{
|
||||
u8 buf[2];
|
||||
struct rt_i2c_msg msgs;
|
||||
|
||||
buf[0] = reg;
|
||||
buf[1] = val;
|
||||
|
||||
msgs.addr = GM7150_I2C_SLAVE_ID;
|
||||
msgs.flags = RT_I2C_WR;
|
||||
msgs.buf = buf;
|
||||
msgs.len = 2;
|
||||
|
||||
if (rt_i2c_transfer(i2c, &msgs, 1) != 1) {
|
||||
LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gm7150_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val)
|
||||
{
|
||||
struct rt_i2c_msg msg[2];
|
||||
u8 buf = reg;
|
||||
|
||||
msg[0].addr = GM7150_I2C_SLAVE_ID;
|
||||
msg[0].flags = RT_I2C_WR;
|
||||
msg[0].buf = &buf;
|
||||
msg[0].len = 1;
|
||||
|
||||
msg[1].addr = GM7150_I2C_SLAVE_ID;
|
||||
msg[1].flags = RT_I2C_RD;
|
||||
msg[1].buf = val;
|
||||
msg[1].len = 1;
|
||||
|
||||
if (rt_i2c_transfer(i2c, msg, 2) != 2) {
|
||||
LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gm7150_select_ch(struct gm7150_dev *sensor, u32 ch)
|
||||
{
|
||||
if (ch)
|
||||
gm7150_write_reg(sensor->i2c, 0x00, 0x02);
|
||||
else
|
||||
gm7150_write_reg(sensor->i2c, 0x00, 0x00);
|
||||
}
|
||||
|
||||
static void gm7150_out_bt656(struct gm7150_dev *sensor)
|
||||
{
|
||||
gm7150_write_reg(sensor->i2c, 0x03, 0x0D);
|
||||
gm7150_write_reg(sensor->i2c, 0x11, 0x04);
|
||||
gm7150_write_reg(sensor->i2c, 0x12, 0x00);
|
||||
gm7150_write_reg(sensor->i2c, 0x13, 0x04);
|
||||
gm7150_write_reg(sensor->i2c, 0x14, 0x00);
|
||||
gm7150_write_reg(sensor->i2c, 0xA0, 0x55);
|
||||
gm7150_write_reg(sensor->i2c, 0xA1, 0xAA);
|
||||
gm7150_write_reg(sensor->i2c, 0x69, 0x40);
|
||||
gm7150_write_reg(sensor->i2c, 0x6D, 0x90);
|
||||
}
|
||||
|
||||
static void gm7150_cur_status(struct gm7150_dev *sensor)
|
||||
{
|
||||
u8 val = 0, fmt = 0;
|
||||
char *formats[] = {"Reserved", "NTSC BT.601", "Reserved", "PAL BT.601",
|
||||
"Reserved", "(M)PAL BT.601", "Reserved", "PAL-N BT.601",
|
||||
"Reserved", "NTSC 4.43 BT.601", "Reserved", "Reserved",
|
||||
"Reserved", "Reserved", "Reserved", "Reserved"};
|
||||
|
||||
gm7150_read_reg(sensor->i2c, 0x88, &val);
|
||||
LOG_I("Reg 0x%02x: 0x%02x. Input signal is %s\n", 0x88, val,
|
||||
(val & 0x6) == 0x6 ? "valid" : "invalid");
|
||||
|
||||
gm7150_read_reg(sensor->i2c, 0x8C, &val);
|
||||
fmt = val & 0xF;
|
||||
LOG_I("Reg 0x%02x: 0x%02x. Input format: %s\n", 0x8C, val,
|
||||
formats[fmt]);
|
||||
|
||||
if (fmt == 0x1 || fmt == 9)
|
||||
g_gm7150_dev.fmt.height = NTSC_HEIGHT;
|
||||
}
|
||||
|
||||
static int gm7150_probe(struct gm7150_dev *sensor)
|
||||
{
|
||||
u8 id_h = 0, id_l = 0;
|
||||
|
||||
aicos_msleep(30);
|
||||
rt_pin_write(sensor->pwdn_pin, 0); //SET PDN LOW BY GPIO OF MCU
|
||||
aicos_msleep(10);
|
||||
rt_pin_write(sensor->pwdn_pin, 1); //SET PDN HIGH BY GPIO OF MCU
|
||||
|
||||
aicos_msleep(30);
|
||||
|
||||
if (gm7150_read_reg(sensor->i2c, 0x80, &id_h) ||
|
||||
gm7150_read_reg(sensor->i2c, 0x81, &id_l))
|
||||
return -1;
|
||||
|
||||
if ((id_h << 8 | id_l) != GM7150_CHIP_ID) {
|
||||
LOG_E("Invalid chip ID: %02x %02x\n", id_h, id_l);
|
||||
return -1;
|
||||
}
|
||||
gm7150_select_ch(sensor, 0);
|
||||
gm7150_out_bt656(sensor);
|
||||
gm7150_cur_status(sensor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gm7150_i2c_init(struct gm7150_dev *sensor)
|
||||
{
|
||||
char name[8] = "";
|
||||
|
||||
snprintf(name, 8, "i2c%d", AIC_CAMERA_I2C_CHAN);
|
||||
sensor->i2c = rt_i2c_bus_device_find(name);
|
||||
if (sensor->i2c == RT_NULL) {
|
||||
LOG_E("Failed to open %s", name);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_err_t gm7150_init(rt_device_t dev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct gm7150_dev *sensor = &g_gm7150_dev;
|
||||
|
||||
ret = gm7150_i2c_init(sensor);
|
||||
if (ret != 0)
|
||||
return -RT_EINVAL;
|
||||
|
||||
sensor->fmt.code = GM7150_DFT_CODE;
|
||||
sensor->fmt.width = GM7150_DFT_WIDTH;
|
||||
sensor->fmt.height = GM7150_DFT_HEIGHT;
|
||||
sensor->fmt.bus_type = GM7150_DFT_BUS_TYPE;
|
||||
sensor->fmt.flags = MEDIA_SIGNAL_HSYNC_ACTIVE_HIGH |
|
||||
MEDIA_SIGNAL_VSYNC_ACTIVE_HIGH |
|
||||
MEDIA_SIGNAL_PCLK_SAMPLE_RISING |
|
||||
MEDIA_SIGNAL_INTERLACED_MODE;
|
||||
|
||||
sensor->pwdn_pin = rt_pin_get(AIC_CAMERA_PWDN_PIN);
|
||||
rt_pin_mode(sensor->pwdn_pin, PIN_MODE_OUTPUT);
|
||||
|
||||
ret = gm7150_probe(sensor);
|
||||
if (ret)
|
||||
return -RT_ERROR;
|
||||
|
||||
LOG_I("GM7150 inited");
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t gm7150_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t gm7150_close(rt_device_t dev)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int gm7150_get_fmt(rt_device_t dev, struct mpp_video_fmt *cfg)
|
||||
{
|
||||
struct gm7150_dev *sensor = (struct gm7150_dev *)dev;
|
||||
|
||||
cfg->code = sensor->fmt.code;
|
||||
cfg->width = sensor->fmt.width;
|
||||
cfg->height = sensor->fmt.height;
|
||||
cfg->flags = sensor->fmt.flags;
|
||||
cfg->bus_type = sensor->fmt.bus_type;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int gm7150_start(rt_device_t dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gm7150_stop(rt_device_t dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_err_t gm7150_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
switch (cmd) {
|
||||
case CAMERA_CMD_START:
|
||||
return gm7150_start(dev);
|
||||
case CAMERA_CMD_STOP:
|
||||
return gm7150_stop(dev);
|
||||
case CAMERA_CMD_GET_FMT:
|
||||
return gm7150_get_fmt(dev, (struct mpp_video_fmt *)args);
|
||||
default:
|
||||
LOG_I("Unsupported cmd: 0x%x", cmd);
|
||||
return -RT_EINVAL;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
static const struct rt_device_ops gm7150_ops =
|
||||
{
|
||||
.init = gm7150_init,
|
||||
.open = gm7150_open,
|
||||
.close = gm7150_close,
|
||||
.control = gm7150_control,
|
||||
};
|
||||
#endif
|
||||
|
||||
int rt_hw_gm7150_init(void)
|
||||
{
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
g_gm7150_dev.dev.ops = &gm7150_ops;
|
||||
#else
|
||||
g_gm7150_dev.dev.init = gm7150_init;
|
||||
g_gm7150_dev.dev.open = gm7150_open;
|
||||
g_gm7150_dev.dev.close = gm7150_close;
|
||||
g_gm7150_dev.dev.control = gm7150_control;
|
||||
#endif
|
||||
g_gm7150_dev.dev.type = RT_Device_Class_CAMERA;
|
||||
|
||||
rt_device_register(&g_gm7150_dev.dev, CAMERA_DEV_NAME, 0);
|
||||
return 0;
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_gm7150_init);
|
||||
1015
bsp/peripheral/camera/ov2640/drv_ov2640.c
Normal file
1015
bsp/peripheral/camera/ov2640/drv_ov2640.c
Normal file
File diff suppressed because it is too large
Load Diff
1199
bsp/peripheral/camera/ov2659/drv_ov2659.c
Normal file
1199
bsp/peripheral/camera/ov2659/drv_ov2659.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2196,25 +2196,6 @@ power_off:
|
||||
|
||||
static int ov5640_set_xclk(u32 freq)
|
||||
{
|
||||
s32 ret = 0;
|
||||
|
||||
if (freq < OV5640_XCLK_MIN || freq > OV5640_XCLK_MAX) {
|
||||
LOG_E("xclk freq out of range: %d Hz", freq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = hal_clk_set_freq(OV5640_CLK_SRC, freq);
|
||||
if (ret < 0) {
|
||||
LOG_E("Failed to set OV5640_CLK_SRC %d", freq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = hal_clk_enable(OV5640_CLK_SRC);
|
||||
if (ret < 0) {
|
||||
LOG_E("Failed to enable OV5640_CLK_SRC");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_ov5640_dev.xclk_freq = freq;
|
||||
return 0;
|
||||
}
|
||||
@@ -2236,9 +2217,9 @@ static rt_err_t ov5640_init(rt_device_t dev)
|
||||
sensor->fmt.width = sensor->current_mode->hact;
|
||||
sensor->fmt.height = sensor->current_mode->vact;
|
||||
sensor->fmt.bus_type = OV5640_BUS_TYPE;
|
||||
sensor->fmt.flags = MEDIA_SIGNAL_HSYNC_ACTIVE_LOW |
|
||||
MEDIA_SIGNAL_VSYNC_ACTIVE_HIGH |
|
||||
MEDIA_SIGNAL_PCLK_SAMPLE_RISING;
|
||||
sensor->fmt.flags = MEDIA_SIGNAL_FIELD_ACTIVE_LOW |
|
||||
MEDIA_SIGNAL_HSYNC_ACTIVE_LOW |
|
||||
MEDIA_SIGNAL_VSYNC_ACTIVE_LOW;
|
||||
sensor->current_fr = OV5640_FPS;
|
||||
sensor->ae_target = 52;
|
||||
|
||||
@@ -2333,7 +2314,7 @@ int rt_hw_ov5640_init(void)
|
||||
#endif
|
||||
g_ov5640_dev.dev.type = RT_Device_Class_CAMERA;
|
||||
|
||||
rt_device_register(&g_ov5640_dev.dev, CAMERA_NAME_OV, 0);
|
||||
rt_device_register(&g_ov5640_dev.dev, CAMERA_DEV_NAME, 0);
|
||||
return 0;
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_ov5640_init);
|
||||
|
||||
1012
bsp/peripheral/camera/ov7670/drv_ov7670.c
Normal file
1012
bsp/peripheral/camera/ov7670/drv_ov7670.c
Normal file
File diff suppressed because it is too large
Load Diff
196
bsp/peripheral/camera/tp2825b/tp2802_def.h
Normal file
196
bsp/peripheral/camera/tp2825b/tp2802_def.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (c) 2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* TP2802 Initialization I2C Tables
|
||||
*/
|
||||
|
||||
|
||||
// Video Format
|
||||
unsigned char tbl_tp2802_1080p25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x03, 0xD3, 0x80, 0x29, 0x38, 0x47, 0x00, 0x0A, 0x50
|
||||
//0x03, 0xD3, 0x80, 0x29, 0x38, 0x48, 0x00, 0x0A, 0x50
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_1080p30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x03, 0xD3, 0x80, 0x29, 0x38, 0x47, 0x00, 0x08, 0x98
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_720p25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x16, 0x00, 0x19, 0xD0, 0x25, 0x00, 0x0F, 0x78
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_720p30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x16, 0x00, 0x19, 0xD0, 0x25, 0x00, 0x0C, 0xE4
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_720p50_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x16, 0x00, 0x19, 0xD0, 0x25, 0x00, 0x07, 0xBC
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_720p60_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x16, 0x00, 0x19, 0xD0, 0x25, 0x00, 0x06, 0x72
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_PAL_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x5f, 0xbc, 0x17, 0x20, 0x17, 0x00, 0x09, 0x48
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_NTSC_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x4e, 0xbc, 0x15, 0xf0, 0x07, 0x00, 0x09, 0x38
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_3M_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x6C, 0x00, 0x2C, 0x00, 0x68, 0x00, 0x09, 0xC4 //3M18.75
|
||||
};
|
||||
|
||||
unsigned char tbl_tp2802_5M_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x1f, 0x20, 0x34, 0x98, 0x7A, 0x00, 0x0B, 0x9A //5M12.5
|
||||
};
|
||||
unsigned char tbl_tp2802_4M_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x1f, 0x80, 0x7d, 0xf0, 0x5A, 0x00, 0x0b, 0xb8 //4M15
|
||||
};
|
||||
unsigned char tbl_tp2802_3M20_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x03, 0xa0, 0x00, 0x6e, 0x00, 0x68, 0x00, 0x08, 0xca //3M20
|
||||
};
|
||||
unsigned char tbl_tp2802_4M12_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x4c, 0x80, 0x89, 0xf0, 0x5A, 0x00, 0x0c, 0xe4 //4M12.5
|
||||
};
|
||||
unsigned char tbl_tp2802_6M10_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0xec, 0x80, 0xb0, 0x08, 0x7c, 0x00, 0x0e, 0xa6 //6M10
|
||||
};
|
||||
unsigned char tbl_tp2802_QHDH30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x0f, 0x00, 0x32, 0xa0, 0x55, 0x00, 0x06, 0x72 //half QHD30
|
||||
};
|
||||
unsigned char tbl_tp2802_QHDH25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x20, 0x00, 0x20, 0xa0, 0x55, 0x00, 0x07, 0xbc //half QHD30
|
||||
};
|
||||
unsigned char tbl_tp2802_QHD15_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x0f, 0x00, 0x32, 0xa0, 0x5a, 0x00, 0x0c, 0xe4 //2560x1440p15
|
||||
};
|
||||
unsigned char tbl_tp2802_QXGAH30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x10, 0x00, 0x64, 0x00, 0x64, 0x00, 0x05, 0xdc //half QXGA30
|
||||
};
|
||||
unsigned char tbl_tp2802_QXGAH25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x0c, 0x00, 0x64, 0x00, 0x64, 0x00, 0x07, 0x08 //half QXGA25
|
||||
};
|
||||
unsigned char tbl_tp2802_QHD30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x1b, 0x00, 0x38, 0xa0, 0x5a, 0x00, 0x0c, 0xe2 //TVI/HDA/HDC QHD30
|
||||
};
|
||||
unsigned char tbl_tp2802_QHD25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x1b, 0x00, 0x38, 0xa0, 0x5a, 0x00, 0x0f, 0x76 //TVI/HDA/HDC QHD25
|
||||
};
|
||||
unsigned char tbl_tp2802_QXGA30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x16, 0x00, 0x68, 0x00, 0x68, 0x00, 0x0b, 0xb6 //HDA 3M30
|
||||
};
|
||||
unsigned char tbl_tp2802_QXGA25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x16, 0x00, 0x68, 0x00, 0x68, 0x00, 0x0e, 0x0e //HDA 3M25
|
||||
};
|
||||
/*
|
||||
unsigned char tbl_tp2802_4M30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x1f, 0x80, 0x7d, 0xf0, 0x5A, 0x00, 0x0b, 0xb6 //TVI 4M30
|
||||
};
|
||||
unsigned char tbl_tp2802_4M25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x34, 0x80, 0x8c, 0xf0, 0x5A, 0x00, 0x0c, 0xe2 //TVI 4M25
|
||||
};
|
||||
*/
|
||||
unsigned char tbl_tp2802_5M20_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x36, 0x20, 0x1a, 0x98, 0x7A, 0x00, 0x0e, 0xa4 //5M20
|
||||
};
|
||||
unsigned char tbl_tp2802_5MH20_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x20, 0x10, 0x1a, 0x98, 0x75, 0x00, 0x07, 0x53 // half 5M20
|
||||
};
|
||||
/*
|
||||
unsigned char tbl_tp2802_4MH30_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x1f, 0x40, 0x7d, 0xf0, 0x55, 0x00, 0x05, 0xdc //TVI half 4M30
|
||||
};
|
||||
unsigned char tbl_tp2802_4MH25_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x20, 0x40, 0x8c, 0xf0, 0x55, 0x00, 0x06, 0x72 //TVI half 4M25
|
||||
};
|
||||
*/
|
||||
unsigned char tbl_tp2802_8M15_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0xbd, 0x00, 0x50, 0x70, 0x8f, 0x00, 0x11, 0x2e //8M15
|
||||
};
|
||||
unsigned char tbl_tp2802_8MH15_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0xbd, 0x80, 0x50, 0x70, 0x87, 0x00, 0x08, 0x98 //8M15
|
||||
};
|
||||
unsigned char tbl_tp2802_8M12_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0xbd, 0x00, 0x50, 0x70, 0x8f, 0x00, 0x14, 0x9e //8M12
|
||||
};
|
||||
unsigned char tbl_tp2802_8MH12_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0xbd, 0x80, 0x50, 0x70, 0x87, 0x00, 0x0a, 0x50 //8M12
|
||||
};
|
||||
unsigned char tbl_tp2802_A5M12_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x13, 0x20, 0x80, 0x14, 0x98, 0x7A, 0x00, 0x0B, 0xb8 //HDA 5M12.5
|
||||
};
|
||||
unsigned char tbl_tp2802_720p30HDR_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x03, 0xb2, 0x00, 0x60, 0xD0, 0x25, 0x00, 0x05, 0xdc
|
||||
};
|
||||
unsigned char tbl_tp2802_6M20_raster[] = {
|
||||
// Start address 0x15, Size = 9B
|
||||
0x23, 0x26, 0x90, 0x44, 0x80, 0x7b, 0x00, 0x0e, 0x74 //6M20
|
||||
};
|
||||
// PLLs
|
||||
unsigned char tbl_tp2802_common_pll[] = {
|
||||
// Start address 0x42, Size = 4B
|
||||
0x00, 0x12, 0x07, 0x49
|
||||
};
|
||||
|
||||
// Output Enables
|
||||
unsigned char tbl_tp2802_common_oe[] = {
|
||||
// Start address 0x4B, Size = 11B
|
||||
0x10, 0x32, 0x0F, 0xFF, 0x0F, 0x00, 0x0A, 0x0B, 0x1F, 0xFA, 0x27
|
||||
};
|
||||
|
||||
// Rx Common
|
||||
unsigned char tbl_tp2802_common_rx[] = {
|
||||
// Start address 0x7E, Size = 13B
|
||||
0x2F, 0x00, 0x07, 0x08, 0x04, 0x00, 0x00, 0x60, 0x10,
|
||||
0x06, 0xBE, 0x39, 0xA7
|
||||
};
|
||||
|
||||
// IRQ Common
|
||||
unsigned char tbl_tp2802_common_irq[] = {
|
||||
// Start address 0xB3, Size = 6B
|
||||
0xFA, 0x1C, 0x0F, 0xFF, 0x00, 0x00
|
||||
};
|
||||
|
||||
242
bsp/peripheral/camera/tp2825b/tp2825b.h
Normal file
242
bsp/peripheral/camera/tp2825b/tp2825b.h
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (c) 2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __TP2825B_H__
|
||||
#define __TP2825B_H__
|
||||
|
||||
#include "aic_common.h"
|
||||
|
||||
#define TP2825_VERSION_CODE 0x000008
|
||||
|
||||
enum {
|
||||
TP2825B = 0x2825,
|
||||
TP2850 = 0x2850,
|
||||
TP2860 = 0x2860,
|
||||
};
|
||||
enum {
|
||||
TP2802_1080P25 = 0x03,
|
||||
TP2802_1080P30 = 0x02,
|
||||
TP2802_720P25 = 0x05,
|
||||
TP2802_720P30 = 0x04,
|
||||
TP2802_720P50 = 0x01,
|
||||
TP2802_720P60 = 0x00,
|
||||
TP2802_SD = 0x06,
|
||||
INVALID_FORMAT = 0x07,
|
||||
TP2802_720P25V2 = 0x0D,
|
||||
TP2802_720P30V2 = 0x0C,
|
||||
TP2802_PAL = 0x08,
|
||||
TP2802_NTSC = 0x09,
|
||||
TP2802_3M18 = 0x20, //2048x1536@18.75 for TVI
|
||||
TP2802_5M12 = 0x21, //2592x1944@12.5 for TVI
|
||||
TP2802_4M15 = 0x22, //2688x1520@15 for TVI
|
||||
TP2802_3M20 = 0x23, //2048x1536@20 for TVI
|
||||
TP2802_4M12 = 0x24, //2688x1520@12.5 for TVI
|
||||
TP2802_6M10 = 0x25, //3200x1800@10 for TVI
|
||||
TP2802_QHD30 = 0x26, //2560x1440@30 for TVI/HDA/HDC
|
||||
TP2802_QHD25 = 0x27, //2560x1440@25 for TVI/HDA/HDC
|
||||
TP2802_QHD15 = 0x28, //2560x1440@15 for HDA
|
||||
TP2802_QXGA18 = 0x29, //2048x1536@18 for HDA/TVI
|
||||
TP2802_QXGA30 = 0x2A, //2048x1536@30 for HDA
|
||||
TP2802_QXGA25 = 0x2B, //2048x1536@25 for HDA
|
||||
TP2802_4M30 = 0x2C, //2688x1520@30 for TVI(for future)
|
||||
TP2802_4M25 = 0x2D, //2688x1520@25 for TVI(for future)
|
||||
TP2802_5M20 = 0x2E, //2592x1944@20 for TVI/HDA
|
||||
TP2802_8M15 = 0x2f, //3840x2160@15 for TVI
|
||||
TP2802_8M12 = 0x30, //3840x2160@12.5 for TVI
|
||||
TP2802_1080P15 = 0x31, //1920x1080@15 for TVI
|
||||
TP2802_1080P60 = 0x32, //1920x1080@60 for TVI
|
||||
TP2802_960P30 = 0x33, //1280x960@30 for TVI
|
||||
TP2802_1080P20 = 0x34, //1920x1080@20 for TVI
|
||||
TP2802_1080P50 = 0x35, //1920x1080@50 for TVI
|
||||
TP2802_720P14 = 0x36, //1280x720@14 for TVI
|
||||
TP2802_720P30HDR = 0x37, //1280x720@30 for TVI
|
||||
TP2802_6M20 = 0x38, //2960x1920@20 for CVI
|
||||
TP2802_8M15V2 = 0x39, //3264x2448@15 for TVI
|
||||
TP2802_5M20V2 = 0x3a, //2960x1664@20 for TVI
|
||||
TP2802_8M7 = 0x3b, //3720x2160@7.5 for AHD
|
||||
TP2802_3M20V2 = 0x3c, //2304x1296@20 for TVI
|
||||
TP2802_1080P2750 = 0x3d, //1920x1080@27.5 for TVI
|
||||
TP2802_1080P2700 = 0x3e, //1920x1080@27.5 for TVI
|
||||
TP2802_1080P12 = 0x41, //1920x1080@12.5
|
||||
TP2802_5M12V2 = 0x42, //2960x1664@12.5 for TVI
|
||||
TP2802_960P25 = 0x43, //1280x960@25 for AHD
|
||||
};
|
||||
enum {
|
||||
VIDEO_UNPLUG,
|
||||
VIDEO_IN,
|
||||
VIDEO_LOCKED,
|
||||
VIDEO_UNLOCK
|
||||
};
|
||||
enum {
|
||||
MUX656_8BIT, //Y/C-mux 4:2:2 8-bit with embedded sync
|
||||
SEP656_8BIT, //Y/C-mux 4:2:2 8-bit with separate sync
|
||||
EMB422_16BIT, //only TP2825B YCbCr 4:2:2 16-bit with embedded sync
|
||||
SEP422_16BIT, //only TP2825B YCbCr 4:2:2 16-bit with separate sync
|
||||
MIPI_2LANES, //only TP2850/TP2860
|
||||
MIPI_1LANES, //only TP2860
|
||||
};
|
||||
enum {
|
||||
VIDEO_PAGE = 0, //
|
||||
MIPI_PAGE = 8
|
||||
};
|
||||
enum {
|
||||
SCAN_DISABLE = 0,
|
||||
SCAN_AUTO,
|
||||
SCAN_TVI,
|
||||
SCAN_HDA,
|
||||
SCAN_HDC,
|
||||
SCAN_MANUAL,
|
||||
SCAN_TEST
|
||||
};
|
||||
enum {
|
||||
STD_TVI,
|
||||
STD_HDA,
|
||||
STD_HDC,
|
||||
STD_HDA_DEFAULT,
|
||||
STD_HDC_DEFAULT
|
||||
};
|
||||
enum {
|
||||
PTZ_TVI = 0,
|
||||
PTZ_HDA_1080P = 1,
|
||||
PTZ_HDA_720P = 2,
|
||||
PTZ_HDA_CVBS = 3,
|
||||
PTZ_HDC = 4,
|
||||
PTZ_HDA_3M18 = 5, //HDA QXGA18
|
||||
PTZ_HDA_3M25 = 6, //HDA QXGA25,QXGA30
|
||||
PTZ_HDA_4M25 = 7, //HDA QHD25,QHD30,5M20
|
||||
PTZ_HDA_4M15 = 8, //HDA QHD15,5M12.5
|
||||
PTZ_HDC_QHD = 9, //HDC QHD25,QHD30
|
||||
PTZ_HDC_FIFO = 10, //HDC 1080p,720p FIFO
|
||||
PTZ_HDC_8M12 = 11, //HDC 8M12.5
|
||||
PTZ_HDC_8M15 = 12, //HDC 8M15
|
||||
PTZ_HDC_6M20 = 13 //HDC 6M20
|
||||
};
|
||||
enum {
|
||||
PTZ_RX_TVI_CMD,
|
||||
PTZ_RX_TVI_BURST,
|
||||
PTZ_RX_ACP1,
|
||||
PTZ_RX_ACP2,
|
||||
PTZ_RX_ACP3,
|
||||
PTZ_RX_TEST,
|
||||
PTZ_RX_HDC1,
|
||||
PTZ_RX_HDC2
|
||||
};
|
||||
enum {
|
||||
PTZ_PIN_TXD = 0, //only for TP2825B
|
||||
PTZ_PIN_PTZ1 = 1,
|
||||
PTZ_PIN_PTZ2 = 2,
|
||||
};
|
||||
enum {
|
||||
SINGLE_VIN1 = 0,
|
||||
SINGLE_VIN2 = 1,
|
||||
SINGLE_VIN3 = 2,
|
||||
SINGLE_VIN4 = 3,
|
||||
SINGLE_VIN5 = 4, //only for TP2825B
|
||||
DIFF_VIN12 = 6,
|
||||
DIFF_VIN34 = 7
|
||||
};
|
||||
|
||||
#define FLAG_LOSS 0x80
|
||||
#define FLAG_H_LOCKED 0x20
|
||||
#define FLAG_HV_LOCKED 0x60
|
||||
|
||||
#define FLAG_HDC_MODE 0x80
|
||||
#define FLAG_HALF_MODE 0x40
|
||||
#define FLAG_MEGA_MODE 0x20
|
||||
#define FLAG_HDA_MODE 0x10
|
||||
|
||||
#define CHANNELS_PER_CHIP 4
|
||||
#define MAX_CHIPS 2
|
||||
#define SUCCESS 0
|
||||
#define FAILURE -1
|
||||
|
||||
#define BRIGHTNESS 0x10
|
||||
#define CONTRAST 0x11
|
||||
#define SATURATION 0x12
|
||||
#define HUE 0x13
|
||||
#define SHARPNESS 0x14
|
||||
|
||||
#define MAX_COUNT 0xffff
|
||||
|
||||
typedef struct _tp2802_register
|
||||
{
|
||||
unsigned char chip;
|
||||
unsigned char ch;
|
||||
unsigned int reg_addr;
|
||||
unsigned int value;
|
||||
} tp2802_register;
|
||||
|
||||
typedef struct _tp2802_work_mode
|
||||
{
|
||||
unsigned char chip;
|
||||
unsigned char ch;
|
||||
unsigned char mode;
|
||||
} tp2802_work_mode;
|
||||
|
||||
typedef struct _tp2802_video_mode
|
||||
{
|
||||
unsigned char chip;
|
||||
unsigned char ch;
|
||||
unsigned char mode;
|
||||
unsigned char std;
|
||||
} tp2802_video_mode;
|
||||
|
||||
typedef struct _tp2802_video_loss
|
||||
{
|
||||
unsigned char chip;
|
||||
unsigned char ch;
|
||||
unsigned char is_lost;
|
||||
} tp2802_video_loss;
|
||||
|
||||
typedef struct _tp2802_image_adjust
|
||||
{
|
||||
unsigned char chip;
|
||||
unsigned char ch;
|
||||
unsigned int hue;
|
||||
unsigned int contrast;
|
||||
unsigned int brightness;
|
||||
unsigned int saturation;
|
||||
unsigned int sharpness;
|
||||
} tp2802_image_adjust;
|
||||
|
||||
typedef struct _tp2802_PTZ_data
|
||||
{
|
||||
unsigned char chip;
|
||||
unsigned char ch;
|
||||
unsigned char mode;
|
||||
unsigned char data[128];
|
||||
} tp2802_PTZ_data;
|
||||
|
||||
// IOCTL Definitions
|
||||
#define TP2802_IOC_MAGIC 'v'
|
||||
|
||||
#define TP2802_READ_REG _IOWR(TP2802_IOC_MAGIC, 1, tp2802_register)
|
||||
#define TP2802_WRITE_REG _IOW(TP2802_IOC_MAGIC, 2, tp2802_register)
|
||||
#define TP2802_SET_VIDEO_MODE _IOW(TP2802_IOC_MAGIC, 3, tp2802_video_mode)
|
||||
#define TP2802_GET_VIDEO_MODE _IOWR(TP2802_IOC_MAGIC, 4, tp2802_video_mode)
|
||||
#define TP2802_GET_VIDEO_LOSS _IOWR(TP2802_IOC_MAGIC, 5, tp2802_video_loss)
|
||||
#define TP2802_SET_IMAGE_ADJUST _IOW(TP2802_IOC_MAGIC, 6, tp2802_image_adjust)
|
||||
#define TP2802_GET_IMAGE_ADJUST _IOWR(TP2802_IOC_MAGIC, 7, tp2802_image_adjust)
|
||||
#define TP2802_SET_PTZ_DATA _IOW(TP2802_IOC_MAGIC, 8, tp2802_PTZ_data)
|
||||
#define TP2802_GET_PTZ_DATA _IOWR(TP2802_IOC_MAGIC, 9, tp2802_PTZ_data)
|
||||
#define TP2802_SET_SCAN_MODE _IOW(TP2802_IOC_MAGIC, 10, tp2802_work_mode)
|
||||
#define TP2802_DUMP_REG _IOW(TP2802_IOC_MAGIC, 11, tp2802_register)
|
||||
#define TP2802_FORCE_DETECT _IOW(TP2802_IOC_MAGIC, 12, tp2802_work_mode)
|
||||
#define TP2802_SET_SAMPLE_RATE _IOW(TP2802_IOC_MAGIC, 13, tp2802_audio_samplerate)
|
||||
#define TP2802_SET_AUDIO_PLAYBACK _IOW(TP2802_IOC_MAGIC, 14, tp2802_audio_playback)
|
||||
#define TP2802_SET_AUDIO_DA_VOLUME _IOW(TP2802_IOC_MAGIC, 15, tp2802_audio_da_volume)
|
||||
#define TP2802_SET_AUDIO_DA_MUTE _IOW(TP2802_IOC_MAGIC, 16, tp2802_audio_da_mute)
|
||||
#define TP2802_SET_BURST_DATA _IOW(TP2802_IOC_MAGIC, 17, tp2802_PTZ_data)
|
||||
#define TP2802_SET_VIDEO_INPUT _IOW(TP2802_IOC_MAGIC, 18, tp2802_register)
|
||||
#define TP2802_GET_VIDEO_INPUT _IOW(TP2802_IOC_MAGIC, 19, tp2802_register)
|
||||
#define TP2802_SET_PTZ_MODE _IOW(TP2802_IOC_MAGIC, 20, tp2802_PTZ_data)
|
||||
#define TP2802_SET_RX_MODE _IOW(TP2802_IOC_MAGIC, 21, tp2802_PTZ_data)
|
||||
|
||||
#define TP2802_SET_FIFO_DATA _IOW(TP2802_IOC_MAGIC, 25, tp2802_PTZ_data)
|
||||
#define TP2802_SET_FIFO_MODE _IOW(TP2802_IOC_MAGIC, 26, tp2802_PTZ_data)
|
||||
|
||||
#endif // end of __TP2825B_H__
|
||||
2568
bsp/peripheral/camera/tp2825b/tp2825b_tbl.c
Normal file
2568
bsp/peripheral/camera/tp2825b/tp2825b_tbl.c
Normal file
File diff suppressed because it is too large
Load Diff
2739
bsp/peripheral/camera/tp2825b/tp2825bx.c
Normal file
2739
bsp/peripheral/camera/tp2825b/tp2825bx.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user