GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)

This commit is contained in:
lai
2026-09-06 03:52:57 +08:00
commit b1928b41c0
21813 changed files with 4413081 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
ifneq ($(MCU), )
include Makefile.riscv
else
include Makefile.linux
endif
+20
View File
@@ -0,0 +1,20 @@
ISP_DIR := $(shell cd ../.. && /bin/pwd)
SDK_DIR ?= $(shell cd $(ISP_DIR)/../../../.. && /bin/pwd)
include $(SDK_DIR)/build/base.mk
include $(ISP_DIR)/sensor/plat.mk
LIB_NAME := libsns_cv2005
SRCS := $(wildcard *.c)
SDK_USR_CFLAGS += -I$(GMP_DIR)/include
SDK_USR_CFLAGS += -I$(GMP_DIR)/usr/include
SDK_USR_CFLAGS += -I$(ISP_DIR)/include
SDK_USR_CFLAGS += -I$(ISP_DIR)/../include
SDK_USR_CFLAGS += -I.
AT := @
$(info SRCS=$(SRCS))
include $(SDK_DIR)/build/sdk_lib_rules.mk
+6
View File
@@ -0,0 +1,6 @@
SRCS-y += cv2005.c
SRCS-y += cv2005_ctrl.c
SRCS-y += cv2005_master.c
SRCS-y += cv2005_slave.c
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
#ifndef __CV2005_H__
#define __CV2005_H__
#include "sns_comm.h"
#ifdef __cplusplus
extern "C" {
#endif
// sensor fps mode
#define CV2005_FULL_LINES_MAX 0xFFFFF
#define CV2005_VMAX_1920X1080_LINEAR 0x49C
#define CV2005_EXP_OFFSET_LINEAR 6
#define CV2005_REG_ADDR_EXP_H 0x304A
#define CV2005_REG_ADDR_EXP_M 0x3049
#define CV2005_REG_ADDR_EXP_L 0x3048
#define CV2005_REG_ADDR_AGAIN 0x3118
#define CV2005_REG_ADDR_DGAIN_H 0x311D
#define CV2005_REG_ADDR_DGAIN_L 0x311C
#define CV2005_REG_ADDR_VMAX_H 0x301E
#define CV2005_REG_ADDR_VMAX_M 0x301D
#define CV2005_REG_ADDR_VMAX_L 0x301C
typedef enum {
CV2005_REG_EXP_H = 0,
CV2005_REG_EXP_M,
CV2005_REG_EXP_L,
CV2005_REG_AGAIN,
CV2005_REG_DGAIN_H,
CV2005_REG_DGAIN_L,
CV2005_REG_VMAX_H,
CV2005_REG_VMAX_M,
CV2005_REG_VMAX_L,
CV2005_REG_MAX_NUM
} cv2005_reg_info;
#ifdef __cplusplus
}
#endif
#endif // __CV2005_H__
+216
View File
@@ -0,0 +1,216 @@
#include <stdio.h>
#include <string.h>
#include "i2c_dev.h"
#include "cv2005.h"
#include "cv2005_ctrl.h"
static xmedia_s32 g_cv2005_i2c_addr[XMEDIA_SENSOR_DEV_MAX_NUM] =
{ [0 ...(XMEDIA_SENSOR_DEV_MAX_NUM - 1)] = SENSOR_I2C_INVALID };
static xmedia_s32 g_cv2005_i2c_fd[XMEDIA_SENSOR_DEV_MAX_NUM] =
{ [0 ...(XMEDIA_SENSOR_DEV_MAX_NUM - 1)] = SENSOR_I2C_INVALID };
#define CV2005_REG_ADDR_MIRROR_FLIP 0x3028
#define CV2005_REG_ADDR_X_START 0x3038
#define CV2005_REG_ADDR_Y_START 0x3034
#define CV2005_REG_VALUE_X_START 4
#define CV2005_REG_VALUE_Y_START 4
static xmedia_s32 cv2005_2lane_linear_1920x1080_init(xmedia_u32 dev)
{
xmedia_s32 ret = XMEDIA_SUCCESS;
ret |= cv2005_write_reg(dev, 0x301C, 0x9C);
ret |= cv2005_write_reg(dev, 0x301D, 0x04);
ret |= cv2005_write_reg(dev, 0x301E, 0x00);
ret |= cv2005_write_reg(dev, 0x3020, 0x4E);
ret |= cv2005_write_reg(dev, 0x3021, 0x04);
ret |= cv2005_write_reg(dev, 0x3808, 0x41);
ret |= cv2005_write_reg(dev, 0x3031, 0x00);
ret |= cv2005_write_reg(dev, 0x3204, 0x40);
ret |= cv2005_write_reg(dev, 0x359d, 0x00);
ret |= cv2005_write_reg(dev, 0x389D, 0x0A);
ret |= cv2005_write_reg(dev, 0x389C, 0x6A);
ret |= cv2005_write_reg(dev, 0x38A0, 0x2B);
ret |= cv2005_write_reg(dev, 0x3878, 0x01);
ret |= cv2005_write_reg(dev, 0x3879, 0x15);
ret |= cv2005_write_reg(dev, 0x356F, 0x0f);
ret |= cv2005_write_reg(dev, 0x3109, 0x01);
ret |= cv2005_write_reg(dev, 0x3420, 0x2f);
ret |= cv2005_write_reg(dev, 0x3422, 0x87);
ret |= cv2005_write_reg(dev, 0x3424, 0x3f);
ret |= cv2005_write_reg(dev, 0x3426, 0x57);
ret |= cv2005_write_reg(dev, 0x3428, 0x2f);
ret |= cv2005_write_reg(dev, 0x3000, 0x00); // Streaming
if (ret != XMEDIA_SUCCESS) {
SENSOR_TRACE(MODULE_DBG_ERR, "cv2005_write_reg failed\n");
return XMEDIA_FAILURE;
} else {
SENSOR_PRINT("=============================================================================================\n");
SENSOR_PRINT("======== cv2005_normal_mipi_24Minput_2lane_10bit_linear_1920x1080_30fps init success ========\n");
SENSOR_PRINT("=============================================================================================\n");
return XMEDIA_SUCCESS;
}
}
xmedia_s32 cv2005_init_image(xmedia_u32 dev, xmedia_u8 image_mode, xmedia_sensor_work_mode work_mode)
{
xmedia_s32 ret = XMEDIA_SUCCESS;
switch (image_mode) {
case CV2005_2LANE_1920X1080_LINEAR_MODE:
ret = cv2005_2lane_linear_1920x1080_init(dev);
break;
default:
SENSOR_TRACE(MODULE_DBG_ERR, "Not support, please check image param!\n");
return XMEDIA_ERRCODE_NOT_SUPPORT;
}
return ret;
}
SENSOR_PRIORITY_FUNC xmedia_s32 cv2005_set_slave_addr(xmedia_u32 dev, xmedia_u32 slave_addr)
{
xmedia_s32 ret;
if (g_cv2005_i2c_fd[dev] < 0) {
SENSOR_PRINT("Sensor dev [%d], i2c not open. please init i2c at first.\n", dev);
return XMEDIA_ERRCODE_NOT_INIT;
}
ret = i2c_set_slave_addr(g_cv2005_i2c_fd[dev], slave_addr);
if (ret < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "I2C_SLAVE_FORCE error!\n");
i2c_close(g_cv2005_i2c_fd[dev]);
g_cv2005_i2c_fd[dev] = SENSOR_I2C_INVALID;
return XMEDIA_FAILURE;
}
g_cv2005_i2c_addr[dev] = slave_addr;
SENSOR_PRINT("Sensor dev [%d] set slave addr 0x%x success.\n", dev, slave_addr);
return XMEDIA_SUCCESS;
}
SENSOR_PRIORITY_FUNC xmedia_s32 cv2005_i2c_init(xmedia_u32 dev, xmedia_s8 i2c_dev, xmedia_u32 i2c_addr)
{
xmedia_s32 ret;
if (g_cv2005_i2c_fd[dev] >= 0) {
SENSOR_PRINT("====== Sensor dev [%d], i2c already init !=======\n", dev);
return XMEDIA_SUCCESS;
}
if (i2c_dev == SENSOR_I2C_INVALID) {
SENSOR_TRACE(MODULE_DBG_ERR, "Sensor i2c dev invalid! Please set i2c dev at first!\n");
return XMEDIA_ERRCODE_NOT_CONFIG;
}
g_cv2005_i2c_fd[dev] = i2c_open(i2c_dev);
if (g_cv2005_i2c_fd[dev] < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "Open /dev/i2c_drv-%u error!\n", i2c_dev);
return XMEDIA_ERRCODE_OPEN_FAILED;
}
ret = cv2005_set_slave_addr(dev, i2c_addr);
SENSOR_CHECK_RET_RETURN(ret);
SENSOR_PRINT("====== i2c[%d] init success!=======\n", i2c_dev);
return XMEDIA_SUCCESS;
}
SENSOR_PRIORITY_FUNC xmedia_s32 cv2005_i2c_exit(xmedia_u32 dev)
{
xmedia_s32 ret;
ret = i2c_close(g_cv2005_i2c_fd[dev]);
if (ret < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "sensor dev[%d] close i2c failed!\n", dev);
return ret;
}
g_cv2005_i2c_fd[dev] = SENSOR_I2C_INVALID;
return XMEDIA_SUCCESS;
}
SENSOR_PRIORITY_FUNC xmedia_s32 cv2005_read_reg(xmedia_u32 dev, xmedia_u32 addr, xmedia_u32 *data)
{
xmedia_s32 ret;
xmedia_u8 buf[CV2005_DATA_BYTE];
if (g_cv2005_i2c_fd[dev] < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "sensor dev[%d]'s i2c is not init!\n", dev);
return XMEDIA_ERRCODE_NOT_INIT;
}
ret = i2c_read(g_cv2005_i2c_fd[dev], g_cv2005_i2c_addr[dev], addr, CV2005_ADDR_BYTE, buf, CV2005_DATA_BYTE);
if (ret < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "sensor dev[%d] read i2c addr [0x%X] failed!\n", dev, addr);
return ret;
}
*data = buf[0]; // CV2005_DATA_BYTE == 1
return XMEDIA_SUCCESS;
}
SENSOR_PRIORITY_FUNC xmedia_s32 cv2005_write_reg(xmedia_u32 dev, xmedia_u32 addr, xmedia_u32 data)
{
xmedia_u32 idx = 0;
xmedia_s32 ret;
xmedia_u8 buf[8];
if (g_cv2005_i2c_fd[dev] < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "sensor dev[%d]'s i2c is not init!\n", dev);
return XMEDIA_ERRCODE_NOT_INIT;
}
buf[idx] = (addr >> 8) & 0xff;
idx++;
buf[idx] = addr & 0xff;
idx++;
buf[idx] = data & 0xff;
ret = i2c_write(g_cv2005_i2c_fd[dev], g_cv2005_i2c_addr[dev], buf, CV2005_ADDR_BYTE + CV2005_DATA_BYTE);
if (ret < 0) {
SENSOR_TRACE(MODULE_DBG_ERR, "I2C_WRITE error!\n");
return XMEDIA_FAILURE;
}
return XMEDIA_SUCCESS;
}
xmedia_s32 cv2005_set_mirror_flip(xmedia_u32 dev, xmedia_bool mirror_en, xmedia_bool flip_en)
{
xmedia_s32 ret;
xmedia_u32 mirror_flip_type;
xmedia_u32 x, y;
cv2005_read_reg(dev, CV2005_REG_ADDR_MIRROR_FLIP, &mirror_flip_type);
if (mirror_en) {
mirror_flip_type |= 0x01;
x = CV2005_REG_VALUE_X_START + 1;
} else {
mirror_flip_type &= 0xfe;
x = CV2005_REG_VALUE_X_START;
}
if (flip_en) {
mirror_flip_type |= 0x02;
y = CV2005_REG_VALUE_Y_START + 1;
} else {
mirror_flip_type &= 0xfd;
y = CV2005_REG_VALUE_Y_START;
}
cv2005_write_reg(dev, CV2005_REG_ADDR_X_START, x);
cv2005_write_reg(dev, CV2005_REG_ADDR_Y_START, y);
ret = cv2005_write_reg(dev, CV2005_REG_ADDR_MIRROR_FLIP, mirror_flip_type);
if (ret != XMEDIA_SUCCESS) {
SENSOR_TRACE(MODULE_DBG_ERR, "cv2005_write_reg failed\n");
}
return XMEDIA_SUCCESS;
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef __CV2005_CTRL_H__
#define __CV2005_CTRL_H__
#include "sns_comm.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CV2005_I2C_ADDR 0x6a
#define CV2005_ADDR_BYTE 2
#define CV2005_DATA_BYTE 1
// cv2005 specs list
#define CV2005_2LANE_1920X1080_LINEAR_MODE 1
xmedia_s32 cv2005_i2c_init(xmedia_u32 dev, xmedia_s8 i2c_dev, xmedia_u32 i2c_addr);
xmedia_s32 cv2005_i2c_exit(xmedia_u32 dev);
xmedia_s32 cv2005_read_reg(xmedia_u32 dev, xmedia_u32 addr, xmedia_u32 *data);
xmedia_s32 cv2005_write_reg(xmedia_u32 dev, xmedia_u32 addr, xmedia_u32 data);
xmedia_s32 cv2005_set_mirror_flip(xmedia_u32 dev, xmedia_bool mirror_en, xmedia_bool flip_en);
xmedia_s32 cv2005_init_image(xmedia_u32 dev, xmedia_u8 img_mode, xmedia_sensor_work_mode work_mode);
xmedia_s32 cv2005_set_slave_addr(xmedia_u32 dev, xmedia_u32 slave_addr);
#ifdef __cplusplus
}
#endif
#endif //__CV2005_CTRL_H__
+102
View File
@@ -0,0 +1,102 @@
#ifndef __CV2005_EX_H__
#define __CV2005_EX_H__
#ifdef __cplusplus
extern "C" {
#endif
// Piris attr
static const xmedia_isp_piris_attr g_cv2005_piris_attr = {
0,
1,
94,
62,
// Step-F number mapping table. Must be from small to large. F1.0 is 1024 and F32.0 is 1
{30, 35, 40, 45, 50, 56, 61, 67, 73, 79, 85, 92, 98, 105, 112, 120, 127, 135, 143, 150, 158,
166, 174, 183, 191, 200, 208, 217, 225, 234, 243, 252, 261, 270, 279, 289, 298, 307, 316, 325, 335, 344,
353, 362, 372, 381, 390, 399, 408, 417, 426, 435, 444, 453, 462, 470, 478, 486, 493, 500, 506, 512},
XMEDIA_ISP_IRIS_F_NO_1_4,
XMEDIA_ISP_IRIS_F_NO_5_6
};
static const xmedia_isp_awb_ccm g_cv2005_awb_ccm = {
4,
{
{
6150,
{
0x018C, 0x805D, 0x802F,
0x803E, 0x0184, 0x8046,
0x8001, 0x80C5, 0x01C6
},
},
{
4850,
{
0x01FA, 0x80E0, 0x801A,
0x8063, 0x0177, 0x8014,
0x8013, 0x811F, 0x0232
},
},
{
3650,
{
0x01CB, 0x8030, 0x809B,
0x806B, 0x01BD, 0x8052,
0x800C, 0x80ED, 0x01F9
},
},
{
2650,
{
0x01B9, 0x80A5, 0x8014,
0x8090, 0x01A7, 0x8017,
0x801D, 0x8159, 0x0276
},
},
},
};
static const xmedia_isp_awb_agc_table g_cv2005_awb_agc_table = {
/* bvalid */
1,
/* saturation */
/* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */
{0x80, 0x78, 0x73, 0x6E, 0x69, 0x5F, 0x58, 0x50, 0x48, 0x40, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38}
};
static const xmedia_isp_blc_attr g_cv2005_blc_attr = {
.op_type = 0,
.manual_attr = {
.black_level = {512,512,512,512},
},
.auto_attr = {
.iso_num = 10,
.iso_level = {100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200, 1638400, 3276800},
.black_level = {
{ 256,256,256,256, },//0
{ 256,256,256,256, },//1
{ 256,256,256,256, },//2
{ 256,256,256,256, },//3
{ 256,256,256,256, },//4
{ 256,256,256,256, },//5
{ 256,256,256,256, },//6
{ 256,256,256,256, },//7
{ 256,256,256,256, },//8
{ 256,256,256,256, },//9
},
},
};
#ifdef __cplusplus
}
#endif
#endif // __CV2005_EX_H__