Skip to content

Commit edee9e3

Browse files
committed
Unresetting the MIPI interface on hisi-v4 fails for now, must investigate further
1 parent 8778a0c commit edee9e3

File tree

7 files changed

+41
-24
lines changed

7 files changed

+41
-24
lines changed

src/hal/hisi/v4_common.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
#define V4_ERROR(x, ...) \
1212
do { \
13-
fprintf(stderr, "%s \033[31m%s\033[0m\n", "[v4_hal]", (x), ##__VA_ARGS__); \
13+
fprintf(stderr, "[v4_hal] \033[31m"); \
14+
fprintf(stderr, (x), ##__VA_ARGS__); \
15+
fprintf(stderr, "\033[0m"); \
1416
return EXIT_FAILURE; \
1517
} while (0)
1618

src/hal/hisi/v4_hal.c

+22-14
Original file line numberDiff line numberDiff line change
@@ -300,26 +300,35 @@ int v4_region_setbitmap(int handle, hal_bitmap *bitmap)
300300
int v4_sensor_config(void) {
301301
v4_snr_dev config;
302302
config.device = 0;
303-
config.dataRate2X = 0;
304303
config.input = v4_config.input_mode;
304+
config.dataRate2X = 0;
305305
config.rect = v4_config.vichn.capt;
306-
memcpy(&config.lvds, &v4_config.lvds, sizeof(v4_snr_lvds));
307-
memcpy(&config.mipi, &v4_config.mipi, sizeof(v4_snr_mipi));
306+
307+
if (config.input == V4_SNR_INPUT_MIPI)
308+
memcpy(&config.mipi, &v4_config.mipi, sizeof(v4_snr_mipi));
309+
else if (config.input == V4_SNR_INPUT_LVDS)
310+
memcpy(&config.lvds, &v4_config.lvds, sizeof(v4_snr_lvds));
308311

309312
int fd = open(V4_SNR_ENDPOINT, O_RDWR);
310313
if (fd < 0)
311314
V4_ERROR("Opening imaging device has failed!\n");
312315

313-
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_INTF, unsigned int), &config.device);
314-
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_SENS, unsigned int), &config.device);
316+
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_INTF, unsigned int), &config.device))
317+
V4_ERROR("Resetting imaging device has failed!\n");
318+
319+
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_SENS, unsigned int), &config.device))
320+
V4_ERROR("Resetting imaging sensor has failed!\n");
315321

316322
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CONF_DEV, v4_snr_dev), &config) && close(fd))
317323
V4_ERROR("Configuring imaging device has failed!\n");
318324

319325
usleep(10000);
320326

321-
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_INTF, unsigned int), &config.device);
322-
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_INTF, unsigned int), &config.device);
327+
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_INTF, unsigned int), &config.device))
328+
V4_ERROR("Unresetting imaging device has failed!\n");
329+
330+
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_SENS, unsigned int), &config.device))
331+
V4_ERROR("Unresetting imaging sensor has failed!\n");
323332

324333
close(fd);
325334

@@ -776,7 +785,8 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt,
776785
if (v4_parse_sensor_config(snrConfig, &v4_config) != CONFIG_OK)
777786
V4_ERROR("Can't load sensor config\n");
778787

779-
v4_sensor_init(v4_config.dll_file, v4_config.sensor_type);
788+
if (ret = v4_sensor_init(v4_config.dll_file, v4_config.sensor_type))
789+
return ret;
780790

781791
v4_sys.fnExit();
782792
v4_vb.fnExit();
@@ -789,7 +799,7 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt,
789799
.blockSize = v4_system_calculate_block(
790800
v4_config.vichn.capt.width,
791801
v4_config.vichn.capt.height,
792-
V4_PIXFMT_RGB_BAYER_8BPP,
802+
v4_config.vichn.pixFmt,
793803
alignWidth),
794804
.blockCnt = blockCnt
795805
}
@@ -799,17 +809,15 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt,
799809
return ret;
800810
}
801811
{
802-
v4_vb_supl supl = V4_VB_USERINFO_MASK;
812+
v4_vb_supl supl = V4_VB_JPEG_MASK;
803813
if (ret = v4_vb.fnConfigSupplement(&supl))
804814
return ret;
805815
}
806816
if (ret = v4_vb.fnInit())
807817
return ret;
808818

809-
{
810-
if (ret = v4_sys.fnSetAlignment(&alignWidth))
811-
return ret;
812-
}
819+
if (ret = v4_sys.fnSetAlignment(&alignWidth))
820+
return ret;
813821
if (ret = v4_sys.fnInit())
814822
return ret;
815823

src/hal/hisi/v4_snr.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ typedef struct {
9797
v4_snr_mwdr mode;
9898
// Value -1 signifies a lane is disabled
9999
short laneId[4];
100-
short wdrVcType[2];
100+
union {
101+
short wdrVcType[2];
102+
};
101103
} v4_snr_mipi;
102104

103105
typedef struct {

src/hal/hisi/v4_vb.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
#include "v4_common.h"
44

55
typedef enum {
6-
V4_VB_JPEG_MASK,
7-
V4_VB_USERINFO_MASK,
8-
V4_VB_ISPINFO_MASK,
9-
V4_VB_ISPSTAT_MASK,
10-
V4_VB_DNG_MASK
6+
V4_VB_JPEG_MASK = 0x1,
7+
V4_VB_ISPINFO_MASK = 0x2,
8+
V4_VB_MOTIONDATA_MASK = 0x4,
9+
V4_VB_DNG_MASK = 0x8
1110
} v4_vb_supl;
1211

1312
typedef struct {

src/hal/sstar/i6_common.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
#define I6_ERROR(x, ...) \
1212
do { \
13-
fprintf(stderr, "%s \033[31m%s\033[0m\n", "[i6_hal]", (x), ##__VA_ARGS__); \
13+
fprintf(stderr, "[i6_hal] \033[31m"); \
14+
fprintf(stderr, (x), ##__VA_ARGS__); \
15+
fprintf(stderr, "\033[0m"); \
1416
return EXIT_FAILURE; \
1517
} while (0)
1618

src/hal/sstar/i6c_common.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
#define I6C_ERROR(x, ...) \
1212
do { \
13-
fprintf(stderr, "%s \033[31m%s\033[0m\n", "[i6c_hal]", (x), ##__VA_ARGS__); \
13+
fprintf(stderr, "[i6c_hal] \033[31m"); \
14+
fprintf(stderr, (x), ##__VA_ARGS__); \
15+
fprintf(stderr, "\033[0m"); \
1416
return EXIT_FAILURE; \
1517
} while (0)
1618

src/hal/sstar/i6f_common.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
#define I6F_ERROR(x, ...) \
1212
do { \
13-
fprintf(stderr, "%s \033[31m%s\033[0m\n", "[i6f_hal]", (x), ##__VA_ARGS__); \
13+
fprintf(stderr, "[i6f_hal] \033[31m"); \
14+
fprintf(stderr, (x), ##__VA_ARGS__); \
15+
fprintf(stderr, "\033[0m"); \
1416
return EXIT_FAILURE; \
1517
} while (0)
1618

0 commit comments

Comments
 (0)