Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OV5647 sensor support #31

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CONFIG_STORAGE_TYPE_sd=y
CONFIG_MIPI_PANEL_ZCT2133V1=y
CONFIG_SENSOR_GCORE_GC4653=y
CONFIG_SENSOR_OV_OS04A10=y
CONFIG_SENSOR_OV_OS05647=y
CONFIG_SENSOR_LONTIUM_LT6911=y
CONFIG_SENSOR_SMS_SC035GS=y
CONFIG_UBOOT_2021_10=y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[source]

;type = SOURCE_USER_FE

dev_num = 1

; section for sensor

[sensor]

; sensor name
name = OV_OV5647_MIPI_2M_30FPS_10BIT

bus_id = 4

sns_i2c_addr = 36

mipi_dev = 0

lane_id = 0, 1, 2, 3, -1

pn_swap = 0, 0, 0, 0, 0

mclk_en = 1

mclk = 1

;port = 0

;pin = 2

;pol = 1

;fps = 30
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ static CVI_S32 sensor_set_init(VI_PIPE ViPipe, ISP_INIT_ATTR_S *pstInitAttr)
}
static CVI_S32 sensor_probe(VI_PIPE ViPipe)
{
printf("[sensor_prob = ov547_probe] \n");
return ov5647_probe(ViPipe);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ int ov5647_read_register(VI_PIPE ViPipe, int addr)
CVI_U8 buf[8];
CVI_U8 idx = 0;

printf("[ov5647_read_register] : addr = %x \n", addr);
if (g_fd[ViPipe] < 0)
return CVI_FAILURE;

Expand Down Expand Up @@ -113,6 +114,7 @@ int ov5647_write_register(VI_PIPE ViPipe, int addr, int data)
int ret;
CVI_U8 buf[8];

printf("[ov5647_write_register] : addr = %x. data = %x \n", addr, data);
if (g_fd[ViPipe] < 0)
return CVI_SUCCESS;

Expand Down Expand Up @@ -205,26 +207,61 @@ int ov5647_probe(VI_PIPE ViPipe)
{
int nVal, nVal2;

// PinMUX
printf("########### PinMux #######################################################################\n");
system("devmem 0x0300116C 32 0x3");
system("devmem 0x03001170 32 0x3");
system("devmem 0x03001174 32 0x3");
system("devmem 0x03001178 32 0x3");
system("devmem 0x0300117C 32 0x3");
system("devmem 0x03001180 32 0x3");
system("devmem 0x03001184 32 0x3");
system("devmem 0x03001188 32 0x3");
system("devmem 0x0300118C 32 0x3");
system("devmem 0x03001190 32 0x3");
printf("########### PinMux End #######################################################################\n")

usleep(1000);
printf("[ov5647_probe] -189 \n");
if (ov5647_i2c_init(ViPipe) != CVI_SUCCESS)
return CVI_FAILURE;

printf("[lt6911_probe] -195 \n");
nVal = ov5647_read_register(ViPipe, OV5647_CHIP_ID_ADDR_H);
nVal2 = ov5647_read_register(ViPipe, OV5647_CHIP_ID_ADDR_L);
if (nVal < 0 || nVal2 < 0) {
CVI_TRACE_SNS(CVI_DBG_ERR, "read sensor id error.\n");
printf("[ov5647_probe] jump return nVal -198 \n");
return nVal;
}

printf("[ov5647_probe] -201 \n");
printf("data:%02x %02x\n", nVal, nVal2);
if ((((nVal & 0xFF) << 8) | (nVal2 & 0xFF)) != OV5647_CHIP_ID) {
CVI_TRACE_SNS(CVI_DBG_ERR, "Sensor ID Mismatch! Use the wrong sensor??\n");
return CVI_FAILURE;
printf("[ov5647_probe] jump return CVI_FAILURE -206 \n");
}
printf("[ov5647_probe] -208 = exit success \n");
return CVI_SUCCESS;
}

void ov5647_init(VI_PIPE ViPipe)
{
// PinMUX
printf("########### PinMux #######################################################################\n");
system("devmem 0x0300116C 32 0x3");
system("devmem 0x03001170 32 0x3");
system("devmem 0x03001174 32 0x3");
system("devmem 0x03001178 32 0x3");
system("devmem 0x0300117C 32 0x3");
system("devmem 0x03001180 32 0x3");
system("devmem 0x03001184 32 0x3");
system("devmem 0x03001188 32 0x3");
system("devmem 0x0300118C 32 0x3");
system("devmem 0x03001190 32 0x3");
printf("########### PinMux End #######################################################################\n");

ov5647_i2c_init(ViPipe);

delay_ms(10);
Expand Down