Skip to content

Commit

Permalink
Unresetting the MIPI interface on hisi-v4 fails for now, must investi…
Browse files Browse the repository at this point in the history
…gate further
  • Loading branch information
wberube committed May 22, 2024
1 parent 8778a0c commit edee9e3
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/hal/hisi/v4_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
36 changes: 22 additions & 14 deletions src/hal/hisi/v4_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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
}
Expand All @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion src/hal/hisi/v4_snr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions src/hal/hisi/v4_vb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/hal/sstar/i6_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion src/hal/sstar/i6c_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion src/hal/sstar/i6f_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit edee9e3

Please sign in to comment.