@@ -300,26 +300,35 @@ int v4_region_setbitmap(int handle, hal_bitmap *bitmap)
300
300
int v4_sensor_config (void ) {
301
301
v4_snr_dev config ;
302
302
config .device = 0 ;
303
- config .dataRate2X = 0 ;
304
303
config .input = v4_config .input_mode ;
304
+ config .dataRate2X = 0 ;
305
305
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 ));
308
311
309
312
int fd = open (V4_SNR_ENDPOINT , O_RDWR );
310
313
if (fd < 0 )
311
314
V4_ERROR ("Opening imaging device has failed!\n" );
312
315
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" );
315
321
316
322
if (ioctl (fd , _IOW (V4_SNR_IOC_MAGIC , V4_SNR_CMD_CONF_DEV , v4_snr_dev ), & config ) && close (fd ))
317
323
V4_ERROR ("Configuring imaging device has failed!\n" );
318
324
319
325
usleep (10000 );
320
326
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" );
323
332
324
333
close (fd );
325
334
@@ -776,7 +785,8 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt,
776
785
if (v4_parse_sensor_config (snrConfig , & v4_config ) != CONFIG_OK )
777
786
V4_ERROR ("Can't load sensor config\n" );
778
787
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 ;
780
790
781
791
v4_sys .fnExit ();
782
792
v4_vb .fnExit ();
@@ -789,7 +799,7 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt,
789
799
.blockSize = v4_system_calculate_block (
790
800
v4_config .vichn .capt .width ,
791
801
v4_config .vichn .capt .height ,
792
- V4_PIXFMT_RGB_BAYER_8BPP ,
802
+ v4_config . vichn . pixFmt ,
793
803
alignWidth ),
794
804
.blockCnt = blockCnt
795
805
}
@@ -799,17 +809,15 @@ int v4_system_init(unsigned int alignWidth, unsigned int blockCnt,
799
809
return ret ;
800
810
}
801
811
{
802
- v4_vb_supl supl = V4_VB_USERINFO_MASK ;
812
+ v4_vb_supl supl = V4_VB_JPEG_MASK ;
803
813
if (ret = v4_vb .fnConfigSupplement (& supl ))
804
814
return ret ;
805
815
}
806
816
if (ret = v4_vb .fnInit ())
807
817
return ret ;
808
818
809
- {
810
- if (ret = v4_sys .fnSetAlignment (& alignWidth ))
811
- return ret ;
812
- }
819
+ if (ret = v4_sys .fnSetAlignment (& alignWidth ))
820
+ return ret ;
813
821
if (ret = v4_sys .fnInit ())
814
822
return ret ;
815
823
0 commit comments