Skip to content

Commit

Permalink
* support sms_sc035gs
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed Jul 23, 2024
1 parent 2fadf6f commit 5adac27
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
4 changes: 3 additions & 1 deletion components/maixcam_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if(CONFIG_MAIXCAM_LIB_COMPILE_FROM_SOURCE)

append_srcs_dir(middleware_src_dir ${middleware_src_path}/v2/sample/common
${middleware_src_path}/v2/component/isp/sensor/cv181x/gcore_gc4653
${middleware_src_path}/v2/component/isp/sensor/sg200x/sms_sc035gs
)
list(APPEND ADD_SRCS ${middleware_src_dir}
"${source_dir}/middleware/sophgo_middleware.cpp")
Expand Down Expand Up @@ -95,7 +96,8 @@ if(CONFIG_MAIXCAM_LIB_COMPILE_FROM_SOURCE)
-DSENSOR0_TYPE=SONY_IMX327_MIPI_2M_30FPS_12BIT
-DSENSOR1_TYPE=SONY_IMX327_MIPI_2M_30FPS_12BIT)


list(APPEND ADD_DEFINITIONS_PRIVATE -DSENSOR_SMS_SC035GS
-DSENSOR2_TYPE=SMS_SC035GS_MIPI_480P_120FPS_12BIT)
register_component(DYNAMIC)
else()
list(APPEND ADD_DYNAMIC_LIB "lib/libmaixcam_lib.so")
Expand Down
2 changes: 1 addition & 1 deletion components/maixcam_lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ config SOPHGO_MIDDLEWARE_VERSION_MINOR

config SOPHGO_MIDDLEWARE_VERSION_PATCH
int "sophgo middleware package patch version"
default 6
default 7
help
sophgo middleware package patch version
endmenu
2 changes: 2 additions & 0 deletions components/maixcam_lib/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def add_file_downloads(confs : dict) -> list:
sha256sum = "484dd9199f7d8d5d2af34bf76fd2b9e5feb3d47691308e491c68270844adffb9"
elif version == "0.0.6":
sha256sum = "e7a9f4fb6e3eeb791c8ebf0a19bbf660151deeffa977e99e1835fe1cbeb2aa0b"
elif version == "0.0.7":
sha256sum = "990401337cc0108046f89d873708c316f40b67704045695fc245404d377ab3fc"
else:
raise Exception(f"version {version} not support")
filename = f"sophgo-middleware-{version}.tar.xz"
Expand Down
34 changes: 31 additions & 3 deletions components/vision/port/maixcam/maix_camera_mmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "maix_log.hpp"
#include "maix_image.hpp"
#include "maix_time.hpp"
#include "maix_i2c.hpp"
#include "maix_camera_base.hpp"
#include "sophgo_middleware.hpp"
#include <signal.h>
Expand Down Expand Up @@ -63,6 +64,31 @@ static __attribute__((constructor)) void maix_vision_register_signal(void)
#define MAIX_SENSOR_FPS "MAIX_SENSOR_FPS"
namespace maix::camera
{
static void config_sensor(void)
{
#define MMF_SENSOR_NAME "MMF_SENSOR_NAME"
peripheral::i2c::I2C i2c_obj(4, peripheral::i2c::Mode::MASTER);
std::vector<int> addr_list = i2c_obj.scan();
for (size_t i = 0; i < addr_list.size(); i++) {
printf("i2c addr: 0x%02x\n", addr_list[i]);
switch (addr_list[i]) {
case 0x30:
printf("found sms_sc035gs, addr 0x30\n" );
setenv(MMF_SENSOR_NAME, "sms_sc035gs", 0);
return;
case 0x29: // fall through
default:
printf("found gcore_gc4653, addr 0x29\n" );
setenv(MMF_SENSOR_NAME, "gcore_gc4653", 0);
return;
}
}

printf("Found not sensor address, use gcore_gc4653\n" );
setenv(MMF_SENSOR_NAME, "gcore_gc4653", 0);
return;
}

class CameraCviMmf final : public CameraBase
{
public:
Expand All @@ -75,6 +101,8 @@ namespace maix::camera
this->buffer_num = buff_num;
this->ch = -1;

config_sensor();

mmf_sys_cfg_t sys_cfg = {0};
if (width <= 1280 && height <= 720 && fps > 30) {
sys_cfg.vb_pool[0].size = 1280 * 720 * 3 / 2;
Expand All @@ -83,16 +111,16 @@ namespace maix::camera
sys_cfg.max_pool_cnt = 1;

if (fps > 30 && fps <= 60) {
err::check_bool_raise(!setenv(MAIX_SENSOR_FPS, "60", 1), "setenv MAIX_SENSOR_FPS failed");
err::check_bool_raise(!setenv(MAIX_SENSOR_FPS, "60", 0), "setenv MAIX_SENSOR_FPS failed");
} else {
err::check_bool_raise(!setenv(MAIX_SENSOR_FPS, "80", 1), "setenv MAIX_SENSOR_FPS failed");
err::check_bool_raise(!setenv(MAIX_SENSOR_FPS, "80", 0), "setenv MAIX_SENSOR_FPS failed");
}
} else {
sys_cfg.vb_pool[0].size = 2560 * 1440 * 3 / 2;
sys_cfg.vb_pool[0].count = 2;
sys_cfg.vb_pool[0].map = 2;
sys_cfg.max_pool_cnt = 1;
err::check_bool_raise(!setenv(MAIX_SENSOR_FPS, "30", 1), "setenv MAIX_SENSOR_FPS failed");
err::check_bool_raise(!setenv(MAIX_SENSOR_FPS, "30", 0), "setenv MAIX_SENSOR_FPS failed");
}
mmf_pre_config_sys(&sys_cfg);

Expand Down

0 comments on commit 5adac27

Please sign in to comment.