Эх сурвалжийг харах

add tuning support for imp

Alfonso Gamboa 3 жил өмнө
parent
commit
3ab50eb989

+ 41 - 1
README.md

@@ -302,9 +302,49 @@ Live stream DIRECTLY from the camera's local RTSP server to: `youtube` / `twitch
 
 ---
 
-## Latest Updates
+IMP_CONTROL:  Tune various options presented by IMP.  Works for audio and video.  Only available when RTSP server is enabled
+
+`cmd imp_control <command> <value>`
+
+| function name  | Value | Description |
+| ------------- | ------------- | ----------- |
+| __AUDIO__|
+| agc_on  | <none>  | Enable Automatic Gain Control |
+| agc_off  | <none>  | Disable Automatic Gain Control |
+| hpf_on  | <none>  | Enable High Pass Filter |
+| hpf_off  | <none>  | Disable High Pass Filter |
+| ns_on | <none>  | Enable Noise Supression |
+| ns_off  | <none>  | Disable Noise Supression |
+| aec_on  | <none>  | Enable Automatic Echo Cancellation |
+| aec_off  | <none>  | Disable Automatic Echo Cancellation |
+| __VIDEO__|
+| flip_mirror  | <none>  | Mirror Image |
+| flip_vertical  | <none>  | Flip Vertical |
+| flip_horizontal  | <none>  | Flip Horizontal |
+| flip_normal  | <none>  | Normal Image |
+| tune_contrast  | -128 to 128  | Contrast Control |
+| tune_brightness  | -128 to 128 | Brightness Control |
+| tune_sharpness  | -128 to 128 | Sharpness Control |
+| tune_saturation  | -128 to 128 | Saturation Control |
+| tune_aecomp  | 0 to 255 | Auto Exposure Target |
+| tune_aeitmax  | 0 to 10000 | Auto Exposure Maxiumum |
+| tune_dpc_strength | -128 to 128 | DPC Strength |
+| tune_drc_strength | -128 to 128 | DRC Strength |
+| tune_hilightdepress | 0 to 10 | Glare Supression |
+| tune_temper | -128 to 128 | 3D Noise reduction strength |
+| tune_sinter | -128 to 128 | 2D Noise reduction strength |
+| tune_again | 0 to 99999 | Set sensor A-Gain maximum |
+| tune_dgain | see notes | Maximum D-Gain set by the ISP |
+| tune_backlightcomp | -1 to 3500 | Backlight Compensation? (undocumented) |
+
+
+tune_dgain: 0 means 1x, 32 means 2x, and so on 
+
+---
 
+## Latest Updates
 
+* 06-07-22:  Added support to tune IMP video and audio options in libcallback.
 * 06-04-22:  updated v2 kernel with fix for webcam mode on v2 camera's, working well now.  Updated RTMP streaming.
 * 05-31-22:  added kernel and initramfs configs to src dir, fixed old logs deleted on boot, save dmesg to log folder, upgrade script fixes, user selectable usb ethernet kernel modules in config.
 * 05-27-22:  update `rtmp-stream.sh`, update various system binaries.

BIN
SD_ROOT/wz_mini/lib/libcallback.so


+ 1 - 1
file.chk

@@ -79,7 +79,7 @@ ab04957b286c8c21f1532bf1947696bd  SD_ROOT/wz_mini/usr/bin/upgrade-run.sh
 4c780f0455481d106d47d89f0ae04ed5  SD_ROOT/wz_mini/lib/uClibc.tar
 9afeb088e4cbabbe0b04033b560204d0  SD_ROOT/wz_mini/lib/libimp.so
 4100755cb6cc6e3b76da20c7e3690e16  SD_ROOT/wz_mini/lib/libalog.so
-4d63637c5390a6c54e32cb5a9ad08848  SD_ROOT/wz_mini/lib/libcallback.so
+a0d2f47e09ae936c847115ad97c594e3  SD_ROOT/wz_mini/lib/libcallback.so
 3f7f24b71a73f9597b64cda42cd83221  SD_ROOT/wz_mini/lib/modules/3.10.14_v2/modules.order
 5ef8504ca3fa25445bfd8ae782b94e52  SD_ROOT/wz_mini/lib/modules/3.10.14_v2/kernel/crypto/md4.ko
 3d1f59ab6fa1987f58ed8b6bc0444582  SD_ROOT/wz_mini/lib/modules/3.10.14_v2/kernel/libcomposite.ko

+ 1 - 1
src/libcallback_wz_mod/Makefile

@@ -2,7 +2,7 @@
 
 CC = /openmiko/build/mips-gcc472-glibc216-64bit/bin/mips-linux-uclibc-gnu-gcc
 CFLAGS = -fPIC -std=gnu99 -shared -ldl -ltinyalsa -lm -pthread
-CC_SRCS = video_callback.c audio_callback.c jpeg.c setlinebuf.c mmc_format.c curl.c freopen.c opendir.c remove.c motor.c command.c gmtime_r.c wait_motion.c irled.c audio_play.c mp4write.c
+CC_SRCS = video_callback.c audio_callback.c jpeg.c setlinebuf.c mmc_format.c curl.c freopen.c opendir.c remove.c motor.c command.c gmtime_r.c wait_motion.c irled.c audio_play.c mp4write.c imp_control.c
 TARGET = libcallback.so
 
 all: ${TARGET}

+ 2 - 0
src/libcallback_wz_mod/command.c

@@ -22,6 +22,7 @@ extern char *WaitMotion(int fd, char *tokenPtr);
 extern char *IrLed(int fd, char *tokenPtr);
 extern char *AudioPlay(int fd, char *tokenPtr);
 extern char *mp4Write(int fd, char *tokenPtr);
+extern char *imp_Control(int fd, char *tokenPtr);
 
 struct CommandTableSt {
   const char *cmd;
@@ -37,6 +38,7 @@ struct CommandTableSt CommandTable[] = {
   { "irled",      &IrLed },
   { "aplay",      &AudioPlay },
   { "mp4write",      &mp4Write },
+  { "imp_control",      &imp_Control },
 
 };
 

+ 204 - 0
src/libcallback_wz_mod/imp_control.c

@@ -0,0 +1,204 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern int IMP_AI_DisableHpf();
+extern int IMP_AI_DisableAgc();
+extern int IMP_AI_DisableNs();
+extern int IMP_AI_DisableAec();
+
+extern int IMP_AI_EnableHpf();
+extern int IMP_AI_EnableAgc();
+extern int IMP_AI_EnableNs();
+extern int IMP_AI_EnableAec();
+
+extern void set_video_max_fps();
+
+extern void set_fs_chn_config_fps();
+
+extern void local_sdk_video_init();
+extern void local_sdk_video_set_fps();
+extern void local_sdk_video_set_gop();
+
+extern void IMP_ISP_EnableTuning();
+
+extern void IMP_ISP_Tuning_SetSensorFPS();
+
+extern int IMP_ISP_Tuning_SetHVFLIP();
+extern int IMP_ISP_Tuning_SetContrast();
+extern int IMP_ISP_Tuning_SetBrightness();
+extern int IMP_ISP_Tuning_SetSaturation();
+extern int IMP_ISP_Tuning_SetSharpness();
+extern int IMP_ISP_Tuning_SetAeComp();
+extern int IMP_ISP_Tuning_SetAe_IT_MAX();
+extern int IMP_ISP_Tuning_SetDPC_Strength();
+extern int IMP_ISP_Tuning_SetDRC_Strength();
+extern int IMP_ISP_Tuning_SetHiLightDepress();
+extern int IMP_ISP_Tuning_SetTemperStrength();
+extern int IMP_ISP_Tuning_SetSinterStrength();
+extern int IMP_ISP_Tuning_SetMaxAgain();
+extern int IMP_ISP_Tuning_SetMaxDgain();
+extern int IMP_ISP_Tuning_SetBacklightComp();
+
+extern void CommandResponse(int fd, const char *res);
+
+
+
+char *imp_Control(int fd, char *tokenPtr) {
+
+int devID = 0;
+int chnID = 1;
+int fps_val;
+int con_val;
+int bright_val;
+int sharp_val;
+int satur_val;
+int aecomp_val;
+int aeitmax_val;
+int dpc_val;
+int drc_val;
+int depress_val;
+int temper_val;
+int sinter_val;
+int bcomp_val;
+int again_val;
+int dgain_val;
+
+int encChn = 0;
+int fps_den = 1;
+int frmRateNum = 30;
+int frmRateDen = 1;
+
+  char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+  if(!p) return "error";
+  if(!strcmp(p, "agc_off")) {
+   IMP_AI_DisableAgc();
+  } else if(!strcmp(p, "agc_on")) {
+   IMP_AI_EnableAgc();
+  } else if(!strcmp(p, "hpf_off")) {
+   IMP_AI_DisableHpf();
+  } else if(!strcmp(p, "hpf_on")) {
+   IMP_AI_EnableHpf();
+  } else if(!strcmp(p, "ns_off")) {
+   IMP_AI_DisableNs();
+  } else if(!strcmp(p, "ns_on")) {
+   IMP_AI_EnableNs();
+  } else if(!strcmp(p, "aec_off")) {
+   IMP_AI_DisableAec(devID, chnID);
+  } else if(!strcmp(p, "aec_on")) {
+   IMP_AI_EnableAec();
+  } else if(!strcmp(p, "flip_mirror")) {
+	IMP_ISP_Tuning_SetHVFLIP(0);
+  } else if(!strcmp(p, "flip_vertical")) {
+	IMP_ISP_Tuning_SetHVFLIP(1);
+  } else if(!strcmp(p, "flip_horizontal")) {
+	IMP_ISP_Tuning_SetHVFLIP(2);
+  } else if(!strcmp(p, "flip_normal")) {
+	IMP_ISP_Tuning_SetHVFLIP(3);
+  } else if(!strcmp(p, "fps_set")) {
+	//encoder framerate failed, broken
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+//	fps_val = 20;
+        if(p) fps_val = atoi(p);
+
+//	IMP_ISP_EnableTuning();
+//	IMP_ISP_Tuning_SetSensorFPS(fps_val, fps_den);
+
+//	set_fs_chn_config_fps(encChn, fps_val);
+
+	set_video_max_fps(fps_val);
+	local_sdk_video_set_fps(fps_val);
+	local_sdk_video_set_gop(encChn, fps_val);
+
+//	local_sdk_video_init(fps_val);
+
+  } else if(!strcmp(p, "tune_contrast")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) con_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetContrast(con_val);
+
+  } else if(!strcmp(p, "tune_brightness")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) bright_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetBrightness(bright_val);
+
+  } else if(!strcmp(p, "tune_sharpness")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) sharp_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetSharpness(sharp_val);
+
+  } else if(!strcmp(p, "tune_saturation")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) satur_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetSaturation(satur_val);
+
+  } else if(!strcmp(p, "tune_aecomp")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) aecomp_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetAeComp(aecomp_val);
+
+  } else if(!strcmp(p, "tune_aeitmax")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) aeitmax_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetAe_IT_MAX(aeitmax_val);
+
+  } else if(!strcmp(p, "tune_dpc_strength")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) dpc_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetDPC_Strength(dpc_val);
+
+  } else if(!strcmp(p, "tune_drc_strength")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) drc_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetDRC_Strength(drc_val);
+
+  } else if(!strcmp(p, "tune_hilightdepress")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) depress_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetHiLightDepress(depress_val);
+
+  } else if(!strcmp(p, "tune_temper")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) temper_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetTemperStrength(temper_val);
+
+  } else if(!strcmp(p, "tune_sinter")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) sinter_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetSinterStrength(sinter_val);
+
+  } else if(!strcmp(p, "tune_dgain")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) dgain_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetMaxDgain(dgain_val);
+
+  } else if(!strcmp(p, "tune_again")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) again_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetMaxAgain(again_val);
+
+  } else if(!strcmp(p, "tune_backlightcomp")) {
+        p = strtok_r(NULL, " \t\r\n", &tokenPtr);
+        if(p) bcomp_val = atoi(p);
+	IMP_ISP_EnableTuning();
+	IMP_ISP_Tuning_SetBacklightComp(bcomp_val);
+
+} else {
+    return "error";
+  }
+  return "ok";
+
+}

BIN
src/libcallback_wz_mod/libcallback.so