Skip to content

Commit 2397fed

Browse files
committed
Fixed wrong sized LVDS struct that rendered the MIPI configuration command inoperable
1 parent 4e99dc2 commit 2397fed

File tree

4 files changed

+45
-46
lines changed

4 files changed

+45
-46
lines changed

src/hal/hisi/v4_config.h

+16-13
Original file line numberDiff line numberDiff line change
@@ -402,24 +402,27 @@ static enum ConfigError v4_parse_sensor_config(char *path, v4_config_impl *confi
402402
config->input_mode = V4_SNR_INPUT_MIPI;
403403
}
404404

405-
if (config->input_mode == V4_VI_INTF_MIPI) {
405+
if (config->input_mode == V4_SNR_INPUT_MIPI) {
406406
// [mipi]
407407
{
408-
const char *possible_values[] = {
409-
"RAW_DATA_8BIT", "RAW_DATA_10BIT", "RAW_DATA_12BIT",
410-
"RAW_DATA_14BIT", "RAW_DATA_16BIT", "RAW_DATA_YUV420_8BIT_NORMAL",
411-
"RAW_DATA_YUV420_8BIT_LEGACY", "RAW_DATA_YUV422_8BIT"};
412-
const int count = sizeof(possible_values) / sizeof(const char *);
413-
err = parse_enum(
414-
&ini, "mode", "raw_bitness", (void*)&config->mipi.prec,
415-
possible_values, count, 0);
416-
if (err != CONFIG_OK)
417-
goto RET_ERR;
408+
int rawBitness;
409+
parse_int(&ini, "mode", "raw_bitness", 0, INT_MAX, &rawBitness);
410+
switch (rawBitness) {
411+
case 8: config->mipi.prec = V4_PREC_8BPP; break;
412+
case 10: config->mipi.prec = V4_PREC_10BPP; break;
413+
case 12: config->mipi.prec = V4_PREC_12BPP; break;
414+
case 14: config->mipi.prec = V4_PREC_14BPP; break;
415+
case 16: config->mipi.prec = V4_PREC_16BPP; break;
416+
default: config->mipi.prec = V4_PREC_10BPP; break;
417+
}
418418
}
419-
err = parse_array(&ini, "mipi", "lane_id", (int*)&config->mipi.laneId, 8);
419+
int laneId[4];
420+
err = parse_array(&ini, "mipi", "lane_id", (int*)&laneId, 4);
420421
if (err != CONFIG_OK)
421422
goto RET_ERR;
422-
} else if (config->input_mode == V4_VI_INTF_LVDS) {
423+
else for (char i = 0; i < 4; i++)
424+
config->mipi.laneId[i] = laneId[i];
425+
} else if (config->input_mode == V4_SNR_INPUT_LVDS) {
423426
// [lvds]
424427
err = v4_parse_config_lvds(&ini, "lvds", &config->lvds);
425428
if (err != CONFIG_OK)

src/hal/hisi/v4_hal.c

+15-23
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ void v4_pipeline_destroy(void)
215215
v4_vpss.fnStopGroup(grp);
216216
v4_vpss.fnDestroyGroup(grp);
217217
}
218-
219-
v4_vi.fnDisableChannel(_v4_vi_chn);
220-
v4_vi.fnDisableDevice(_v4_vi_dev);
221-
222-
v4_isp.fnExit(_v4_isp_dev);
223218
}
224219

225220
int v4_region_create(char handle, hal_rect rect)
@@ -295,7 +290,6 @@ int v4_sensor_config(void) {
295290
config.input = v4_config.input_mode;
296291
config.rect.width = v4_config.isp.capt.width;
297292
config.rect.height = v4_config.isp.capt.height;
298-
299293
if (config.input == V4_SNR_INPUT_MIPI)
300294
memcpy(&config.mipi, &v4_config.mipi, sizeof(v4_snr_mipi));
301295
else if (config.input == V4_SNR_INPUT_LVDS)
@@ -306,24 +300,21 @@ int v4_sensor_config(void) {
306300
V4_ERROR("Opening imaging device has failed!\n");
307301

308302
int laneMode = 0;
309-
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CONF_HSMODE, int), &laneMode))
310-
V4_ERROR("Configuring imaging device lane-splitting mode has failed!\n");
311-
312-
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CLKON_MIPI, unsigned int), &config.device))
313-
V4_ERROR("Enabling imaging device clocking has failed!\n");
303+
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CONF_HSMODE, int), &laneMode);
314304

315-
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_MIPI, unsigned int), &config.device))
316-
V4_ERROR("Resetting imaging device has failed!\n");
305+
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CLKON_MIPI, unsigned int), &config.device);
317306

318-
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CLKON_SENS, unsigned int), &config.device))
319-
V4_ERROR("Enabling imaging sensor clocking has failed!\n");
307+
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_MIPI, unsigned int), &config.device);
320308

321-
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_SENS, unsigned int), &config.device))
322-
V4_ERROR("Resetting imaging sensor has failed!\n");
309+
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CLKON_SENS, unsigned int), &config.device);
323310

324-
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CONF_DEV, v4_snr_dev), &config) && close(fd))
311+
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_RST_SENS, unsigned int), &config.device);
312+
313+
if (ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_CONF_DEV, v4_snr_dev), &config))
325314
V4_ERROR("Configuring imaging device has failed!\n");
326315

316+
usleep(10000);
317+
327318
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_MIPI, unsigned int), &config.device);
328319

329320
ioctl(fd, _IOW(V4_SNR_IOC_MAGIC, V4_SNR_CMD_UNRST_SENS, unsigned int), &config.device);
@@ -786,7 +777,7 @@ void v4_system_deinit(void)
786777
v4_vi.fnStopPipe(_v4_vi_pipe);
787778
v4_vi.fnDestroyPipe(_v4_vi_pipe);
788779

789-
v4_vi.fnDisableChannel(_v4_vi_chn);
780+
v4_vi.fnDisableChannel(_v4_vi_pipe, _v4_vi_chn);
790781

791782
v4_sensor_deconfig();
792783

@@ -892,8 +883,9 @@ int v4_system_init(char *snrConfig, char mirror, char flip)
892883

893884
{
894885
v4_vi_chn channel;
895-
channel.size = v4_config.isp.size;
896-
channel.pixFmt = V4_PIXFMT_RGB_BAYER_8BPP + v4_config.mipi.prec;
886+
channel.size.width = v4_config.isp.capt.width;
887+
channel.size.height = v4_config.isp.capt.height;
888+
channel.pixFmt = V4_PIXFMT_YVU420SP;
897889
channel.dynRange = V4_HDR_SDR8;
898890
channel.videoFmt = 0;
899891
channel.compress = V4_COMPR_NONE;
@@ -902,10 +894,10 @@ int v4_system_init(char *snrConfig, char mirror, char flip)
902894
channel.depth = 0;
903895
channel.srcFps = -1;
904896
channel.dstFps = -1;
905-
if (ret = v4_vi.fnSetChannelConfig(_v4_vi_chn, &channel))
897+
if (ret = v4_vi.fnSetChannelConfig(_v4_vi_pipe, _v4_vi_chn, &channel))
906898
return ret;
907899
}
908-
if (ret = v4_vi.fnEnableChannel(_v4_vi_chn))
900+
if (ret = v4_vi.fnEnableChannel(_v4_vi_pipe, _v4_vi_chn))
909901
return ret;
910902

911903
{

src/hal/hisi/v4_snr.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,23 @@ typedef enum {
7575
V4_SNR_MWDR_END
7676
} v4_snr_mwdr;
7777

78+
typedef struct {
79+
v4_snr_lfid type;
80+
unsigned char outputFil;
81+
} v4_snr_fid;
82+
7883
typedef struct {
7984
v4_snr_lvsynct type;
8085
unsigned short hBlank1;
8186
unsigned short hBlank2;
8287
} v4_snr_lvsync;
8388

84-
typedef struct
85-
{
89+
typedef struct {
8690
v4_common_prec prec;
8791
v4_snr_lwdr wdr;
8892
int syncSavOn;
89-
v4_snr_lvsynct vsync;
90-
v4_snr_lfid fid;
93+
v4_snr_lvsync vsync;
94+
v4_snr_fid fid;
9195
int dataBeOn;
9296
int syncBeOn;
9397
// Value -1 signifies a lane is disabled

src/hal/hisi/v4_vi.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ typedef struct {
141141
int (*fnEnableDevice)(int device);
142142
int (*fnSetDeviceConfig)(int device, v4_vi_dev *config);
143143

144-
int (*fnDisableChannel)(int channel);
145-
int (*fnEnableChannel)(int channel);
146-
int (*fnSetChannelConfig)(int channel, v4_vi_chn *config);
144+
int (*fnDisableChannel)(int pipe, int channel);
145+
int (*fnEnableChannel)(int pipe, int channel);
146+
int (*fnSetChannelConfig)(int pipe, int channel, v4_vi_chn *config);
147147

148148
int (*fnBindPipe)(int device, v4_vi_bind *config);
149149
int (*fnCreatePipe)(int pipe, v4_vi_pipe *config);
@@ -179,19 +179,19 @@ static int v4_vi_load(v4_vi_impl *vi_lib) {
179179
return EXIT_FAILURE;
180180
}
181181

182-
if (!(vi_lib->fnDisableChannel = (int(*)(int device))
182+
if (!(vi_lib->fnDisableChannel = (int(*)(int pipe, int device))
183183
dlsym(vi_lib->handle, "HI_MPI_VI_DisableChn"))) {
184184
fprintf(stderr, "[v4_vi] Failed to acquire symbol HI_MPI_VI_DisableChn!\n");
185185
return EXIT_FAILURE;
186186
}
187187

188-
if (!(vi_lib->fnEnableChannel = (int(*)(int device))
188+
if (!(vi_lib->fnEnableChannel = (int(*)(int pipe, int device))
189189
dlsym(vi_lib->handle, "HI_MPI_VI_EnableChn"))) {
190190
fprintf(stderr, "[v4_vi] Failed to acquire symbol HI_MPI_VI_EnableChn!\n");
191191
return EXIT_FAILURE;
192192
}
193193

194-
if (!(vi_lib->fnSetChannelConfig = (int(*)(int device, v4_vi_chn *config))
194+
if (!(vi_lib->fnSetChannelConfig = (int(*)(int pipe, int device, v4_vi_chn *config))
195195
dlsym(vi_lib->handle, "HI_MPI_VI_SetChnAttr"))) {
196196
fprintf(stderr, "[v4_vi] Failed to acquire symbol HI_MPI_VI_SetChnAttr!\n");
197197
return EXIT_FAILURE;

0 commit comments

Comments
 (0)