Skip to content

Commit

Permalink
update debugging logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gtxaspec committed Apr 24, 2024
1 parent 9fae89c commit cf065ef
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
17 changes: 14 additions & 3 deletions src/Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bool Encoder::init() {
LOG_ERROR("IMP_Encoder_CreateGroup() == " << ret);
return true;
}
LOG_DEBUG("Encoder Group created");

ret = system_init();
if (ret < 0) {
Expand All @@ -50,6 +51,7 @@ bool Encoder::init() {
LOG_ERROR("IMP_System_Bind(FS, ENC) == " << ret);
return true;
}
LOG_DEBUG("IMP_System_Bind(FS, ENC)");

} else {
// If OSD is enabled, initialize OSD and bind FrameSource to OSD, then OSD to Encoder
Expand All @@ -70,12 +72,15 @@ bool Encoder::init() {
LOG_ERROR("IMP_System_Bind(FS, OSD) == " << ret);
return true;
}
LOG_DEBUG("IMP_System_Bind(FS, OSD)");

// OSD -> Encoder
ret = IMP_System_Bind(&osd_cell, &enc);
if (ret < 0) {
LOG_ERROR("IMP_System_Bind(OSD, ENC) == " << ret);
return true;
}
LOG_DEBUG("IMP_System_Bind(OSD, ENC)");

}

Expand All @@ -84,15 +89,14 @@ bool Encoder::init() {
LOG_ERROR("IMP_FrameSource_EnableChn() == " << ret);
return true;
}
LOG_DEBUG("Frame Source Channel 0 enabled");

return false;
}

int Encoder::system_init() {
int ret = 0;

IMP_ISP_Tuning_SetAntiFlickerAttr(IMPISP_ANTIFLICKER_60HZ);

return ret;
}

Expand Down Expand Up @@ -210,6 +214,7 @@ int Encoder::encoder_init() {
if (ret < 0) {
LOG_ERROR("IMP_Encoder_SetbufshareChn() == " << ret);
}
LOG_ERROR("IMP_Encoder_SetbufshareChn(1, 0) enabled");
}
#endif

Expand All @@ -218,12 +223,14 @@ int Encoder::encoder_init() {
LOG_ERROR("IMP_Encoder_CreateChn() == " << ret);
return ret;
}
LOG_DEBUG("Encoder Channel 0 created");

ret = IMP_Encoder_RegisterChn(0, 0);
if (ret < 0) {
LOG_ERROR("IMP_Encoder_RegisterChn() == " << ret);
return ret;
}
LOG_DEBUG("Encoder Channel 0 registered");

#if defined(PLATFORM_T10) || defined(PLATFORM_T20) || defined(PLATFORM_T21) || defined(PLATFORM_T23) || defined(PLATFORM_T30)
/*
Expand Down Expand Up @@ -335,11 +342,13 @@ void Encoder::jpeg_snap() {
if (ret < 0) {
LOG_ERROR("IMP_Encoder_CreateChn() == " << ret);
}
LOG_DEBUG("Encoder JPEG Channel 1 created");

ret = IMP_Encoder_RegisterChn(0, 1);
if (ret < 0) {
LOG_ERROR("IMP_Encoder_RegisterChn() == " << ret);
}
LOG_DEBUG("Encoder JPEG Channel 1 registered");

std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // Wait for ISP to init before saving initial image

Expand Down Expand Up @@ -399,7 +408,7 @@ void Encoder::jpeg_snap() {
}

void Encoder::run() {
LOG_DEBUG("Encoder Start.");
LOG_DEBUG("Encoder Start");

//The encoder thread is very important, but we
//want sink threads to have higher priority.
Expand All @@ -416,6 +425,8 @@ void Encoder::run() {
IMP_System_RebaseTimeStamp(0);
gettimeofday(&imp_time_base, NULL);
IMP_Encoder_StartRecvPic(0);
LOG_DEBUG("Encoder StartRecvPic success");

while (true) {
IMPEncoderStream stream;

Expand Down
48 changes: 39 additions & 9 deletions src/IMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "Config.hpp"
#include "Logger.hpp"

#define OSDPoolSize 131072

bool IMP::init() {
int ret;

Expand All @@ -19,7 +21,6 @@ bool IMP::init() {
return true;
}

IMP_ISP_Tuning_SetISPBypass(IMPISP_TUNING_OPS_MODE_ENABLE);
return false;
}

Expand Down Expand Up @@ -79,6 +80,7 @@ int IMP::framesource_init() {
LOG_DEBUG("IMP_FrameSource_SetChnRotate() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_FrameSource_SetChnRotate == " + std::to_string(rotation));
#endif
#endif

Expand All @@ -87,18 +89,39 @@ int IMP::framesource_init() {
LOG_DEBUG("IMP_FrameSource_CreateChn() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_FrameSource_CreateChn created");

ret = IMP_FrameSource_SetChnAttr(0, &fs_chn_attr);
if (ret < 0) {
LOG_DEBUG("IMP_FrameSource_CreateChn() == " + std::to_string(ret));
LOG_DEBUG("IMP_FrameSource_SetChnAttr() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_FrameSource_SetChnAttr set");

IMPFSChnFifoAttr fifo;
IMP_FrameSource_GetChnFifoAttr(0, &fifo);

ret = IMP_FrameSource_GetChnFifoAttr(0, &fifo);
if (ret < 0) {
LOG_DEBUG("IMP_FrameSource_GetChnFifoAttr() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_FrameSource_GetChnFifoAttr set");

fifo.maxdepth = 0;
IMP_FrameSource_SetChnFifoAttr(0, &fifo);
IMP_FrameSource_SetFrameDepth(0, 0);
ret = IMP_FrameSource_SetChnFifoAttr(0, &fifo);
if (ret < 0) {
LOG_DEBUG("IMP_FrameSource_SetChnFifoAttr() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_FrameSource_SetChnFifoAttr set");

ret = IMP_FrameSource_SetFrameDepth(0, 0);
if (ret < 0) {
LOG_DEBUG("IMP_FrameSource_SetFrameDepth() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_FrameSource_SetFrameDepth set");

return ret;
}

Expand All @@ -120,12 +143,12 @@ int IMP::system_init() {
const char* cpuInfo = IMP_System_GetCPUInfo();
LOG_INFO("CPU Information: " << cpuInfo);

ret = IMP_OSD_SetPoolSize(131072);
ret = IMP_OSD_SetPoolSize(OSDPoolSize);
if (ret < 0) {
LOG_DEBUG("Error: IMP_OSD_SetPoolSize() == " + std::to_string(ret));
LOG_DEBUG("Error: IMP_OSD_SetPoolSize == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("OSD Pool Size set");
LOG_DEBUG("IMP_OSD_SetPoolSize == " + std::to_string(OSDPoolSize));

ret = IMP_ISP_Open();
if (ret < 0) {
Expand Down Expand Up @@ -154,7 +177,7 @@ int IMP::system_init() {
LOG_DEBUG("Error: IMP_System_Init() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("System Initialized");
LOG_DEBUG("IMP System Initialized");

//Enable tuning.
//This is necessary to customize the sensor's image output.
Expand All @@ -164,25 +187,32 @@ int IMP::system_init() {
LOG_DEBUG("ERROR: IMP_ISP_EnableTuning() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_ISP_EnableTuning enabled");

/* Set tuning defaults; on some SoC platforms, if we don't do this, the stream will be dark until manually set */
IMP_ISP_Tuning_SetContrast(128);
IMP_ISP_Tuning_SetSharpness(128);
IMP_ISP_Tuning_SetSaturation(128);
IMP_ISP_Tuning_SetBrightness(128);
IMP_ISP_Tuning_SetISPBypass(IMPISP_TUNING_OPS_MODE_ENABLE);
IMP_ISP_Tuning_SetAntiFlickerAttr(IMPISP_ANTIFLICKER_60HZ);
LOG_DEBUG("ISP Tuning Defaults set");

ret = IMP_ISP_Tuning_SetSensorFPS(Config::singleton()->sensorFps, 1);
if (ret < 0) {
LOG_DEBUG("ERROR: IMP_ISP_Tuning_SetSensorFPS() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_ISP_Tuning_SetSensorFPS == " + std::to_string(Config::singleton()->sensorFps));

// Set the ISP to DAY on launch
ret = IMP_ISP_Tuning_SetISPRunningMode(IMPISP_RUNNING_MODE_DAY);
if (ret < 0) {
LOG_DEBUG("ERROR: IMP_ISP_Tuning_SetISPRunningMode() == " + std::to_string(ret));
return ret;
}
LOG_DEBUG("IMP_ISP_Tuning_SetISPRunningMode == " + std::to_string(IMPISP_RUNNING_MODE_DAY));


return ret;
}
4 changes: 3 additions & 1 deletion src/OSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ bool OSD::init() {
LOG_DEBUG("IMP_OSD_CreateGroup() == " + std::to_string(ret));
return true;
}
LOG_DEBUG("IMP_OSD_CreateGroup group 0 created");

memset(&timestamp.imp_rgn, 0, sizeof(timestamp.imp_rgn));
timestamp.imp_rgn = IMP_OSD_CreateRgn(NULL);
Expand Down Expand Up @@ -395,8 +396,9 @@ bool OSD::init() {
LOG_DEBUG("IMP_OSD_Start() == " + std::to_string(ret));
return true;
}
LOG_DEBUG("IMP_OSD_Start succeed");

LOG_DEBUG("OSD init done");
LOG_DEBUG("OSD init completed");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, const char *argv[]) {
}

if (Config::singleton()->stream1jpegEnable) {
LOG_DEBUG("JPEG Channel enabled");
LOG_DEBUG("JPEG support enabled");
std::thread jpegThread(&Encoder::jpeg_snap, &jpg);
jpegThread.detach();
}
Expand Down

0 comments on commit cf065ef

Please sign in to comment.