diff --git a/src/hal/hisi/v4_common.h b/src/hal/hisi/v4_common.h index cc63133..b34785a 100644 --- a/src/hal/hisi/v4_common.h +++ b/src/hal/hisi/v4_common.h @@ -10,7 +10,9 @@ #define V4_ERROR(x, ...) \ do { \ - fprintf(stderr, "%s \033[31m%s\033[0m\n", "[v4_hal]", (x), ##__VA_ARGS__); \ + fprintf(stderr, "[v4_hal] \033[31m"); \ + fprintf(stderr, (x), ##__VA_ARGS__); \ + fprintf(stderr, "\033[0m"); \ return EXIT_FAILURE; \ } while (0) diff --git a/src/hal/hisi/v4_hal.c b/src/hal/hisi/v4_hal.c index 98354d8..36f644f 100644 --- a/src/hal/hisi/v4_hal.c +++ b/src/hal/hisi/v4_hal.c @@ -300,26 +300,35 @@ int v4_region_setbitmap(int handle, hal_bitmap *bitmap) int v4_sensor_config(void) { v4_snr_dev config; config.device = 0; - config.dataRate2X = 0; config.input = v4_config.input_mode; + config.dataRate2X = 0; config.rect = v4_config.vichn.capt; - memcpy(&config.lvds, &v4_config.lvds, sizeof(v4_snr_lvds)); - memcpy(&config.mipi, &v4_config.mipi, sizeof(v4_snr_mipi)); + + if (config.input == V4_SNR_INPUT_MIPI) + memcpy(&config.mipi, &v4_config.mipi, sizeof(v4_snr_mipi)); + else if (config.input == V4_SNR_INPUT_LVDS) + memcpy(&config.lvds, &v4_config.lvds, sizeof(v4_snr_lvds)); int fd = open(V4_SNR_ENDPOINT, O_RDWR); if (fd < 0) V4_ERROR("Opening imaging device has failed!\n"); - ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_INTF, unsigned int), &config.device); - ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_SENS, unsigned int), &config.device); + if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_INTF, unsigned int), &config.device)) + V4_ERROR("Resetting imaging device has failed!\n"); + + if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_SENS, unsigned int), &config.device)) + V4_ERROR("Resetting imaging sensor has failed!\n"); if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CONF_DEV, v4_snr_dev), &config) && close(fd)) V4_ERROR("Configuring imaging device has failed!\n"); usleep(10000); - ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_INTF, unsigned int), &config.device); - ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_INTF, unsigned int), &config.device); + if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_INTF, unsigned int), &config.device)) + V4_ERROR("Unresetting imaging device has failed!\n"); + + if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_SENS, unsigned int), &config.device)) + V4_ERROR("Unresetting imaging sensor has failed!\n"); close(fd); @@ -776,7 +785,8 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt, if (v4_parse_sensor_config(snrConfig, &v4_config) != CONFIG_OK) V4_ERROR("Can't load sensor config\n"); - v4_sensor_init(v4_config.dll_file, v4_config.sensor_type); + if (ret = v4_sensor_init(v4_config.dll_file, v4_config.sensor_type)) + return ret; v4_sys.fnExit(); v4_vb.fnExit(); @@ -789,7 +799,7 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt, .blockSize = v4_system_calculate_block( v4_config.vichn.capt.width, v4_config.vichn.capt.height, - V4_PIXFMT_RGB_BAYER_8BPP, + v4_config.vichn.pixFmt, alignWidth), .blockCnt = blockCnt } @@ -799,17 +809,15 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt, return ret; } { - v4_vb_supl supl = V4_VB_USERINFO_MASK; + v4_vb_supl supl = V4_VB_JPEG_MASK; if (ret = v4_vb.fnConfigSupplement(&supl)) return ret; } if (ret = v4_vb.fnInit()) return ret; - { - if (ret = v4_sys.fnSetAlignment(&alignWidth)) - return ret; - } + if (ret = v4_sys.fnSetAlignment(&alignWidth)) + return ret; if (ret = v4_sys.fnInit()) return ret; diff --git a/src/hal/hisi/v4_snr.h b/src/hal/hisi/v4_snr.h index 3aee3e0..6d29b5e 100644 --- a/src/hal/hisi/v4_snr.h +++ b/src/hal/hisi/v4_snr.h @@ -97,7 +97,9 @@ typedef struct { v4_snr_mwdr mode; // Value -1 signifies a lane is disabled short laneId[4]; - short wdrVcType[2]; + union { + short wdrVcType[2]; + }; } v4_snr_mipi; typedef struct { diff --git a/src/hal/hisi/v4_vb.h b/src/hal/hisi/v4_vb.h index 48277d7..2050707 100644 --- a/src/hal/hisi/v4_vb.h +++ b/src/hal/hisi/v4_vb.h @@ -3,11 +3,10 @@ #include "v4_common.h" typedef enum { - V4_VB_JPEG_MASK, - V4_VB_USERINFO_MASK, - V4_VB_ISPINFO_MASK, - V4_VB_ISPSTAT_MASK, - V4_VB_DNG_MASK + V4_VB_JPEG_MASK = 0x1, + V4_VB_ISPINFO_MASK = 0x2, + V4_VB_MOTIONDATA_MASK = 0x4, + V4_VB_DNG_MASK = 0x8 } v4_vb_supl; typedef struct { diff --git a/src/hal/sstar/i6_common.h b/src/hal/sstar/i6_common.h index 4f13033..f0441cb 100644 --- a/src/hal/sstar/i6_common.h +++ b/src/hal/sstar/i6_common.h @@ -10,7 +10,9 @@ #define I6_ERROR(x, ...) \ do { \ - fprintf(stderr, "%s \033[31m%s\033[0m\n", "[i6_hal]", (x), ##__VA_ARGS__); \ + fprintf(stderr, "[i6_hal] \033[31m"); \ + fprintf(stderr, (x), ##__VA_ARGS__); \ + fprintf(stderr, "\033[0m"); \ return EXIT_FAILURE; \ } while (0) diff --git a/src/hal/sstar/i6c_common.h b/src/hal/sstar/i6c_common.h index afdef6a..a0b2c4c 100644 --- a/src/hal/sstar/i6c_common.h +++ b/src/hal/sstar/i6c_common.h @@ -10,7 +10,9 @@ #define I6C_ERROR(x, ...) \ do { \ - fprintf(stderr, "%s \033[31m%s\033[0m\n", "[i6c_hal]", (x), ##__VA_ARGS__); \ + fprintf(stderr, "[i6c_hal] \033[31m"); \ + fprintf(stderr, (x), ##__VA_ARGS__); \ + fprintf(stderr, "\033[0m"); \ return EXIT_FAILURE; \ } while (0) diff --git a/src/hal/sstar/i6f_common.h b/src/hal/sstar/i6f_common.h index 5f7acb6..dad1d26 100644 --- a/src/hal/sstar/i6f_common.h +++ b/src/hal/sstar/i6f_common.h @@ -10,7 +10,9 @@ #define I6F_ERROR(x, ...) \ do { \ - fprintf(stderr, "%s \033[31m%s\033[0m\n", "[i6f_hal]", (x), ##__VA_ARGS__); \ + fprintf(stderr, "[i6f_hal] \033[31m"); \ + fprintf(stderr, (x), ##__VA_ARGS__); \ + fprintf(stderr, "\033[0m"); \ return EXIT_FAILURE; \ } while (0)