@@ -196,8 +196,8 @@ void HAL_DCMIPP_PIPE_FrameEventCallback(DCMIPP_HandleTypeDef *hdcmipp, uint32_t
196196 struct stm32_dcmipp_data * dcmipp =
197197 CONTAINER_OF (hdcmipp , struct stm32_dcmipp_data , hdcmipp );
198198 struct stm32_dcmipp_pipe_data * pipe = dcmipp -> pipe [Pipe ];
199+ HAL_StatusTypeDef ret ;
199200 uint32_t bytesused ;
200- int ret ;
201201
202202 __ASSERT (pipe -> active , "Unexpected behavior, active_buf must not be NULL" );
203203
@@ -324,7 +324,7 @@ static int stm32_dcmipp_conf_parallel(const struct device *dev,
324324 struct stm32_dcmipp_data * dcmipp = dev -> data ;
325325 const struct stm32_dcmipp_config * config = dev -> config ;
326326 DCMIPP_ParallelConfTypeDef parallel_cfg = { 0 };
327- int ret ;
327+ HAL_StatusTypeDef ret ;
328328
329329 parallel_cfg .Format = input_fmt -> dcmipp_format ;
330330 parallel_cfg .SwapCycles = DCMIPP_SWAPCYCLES_DISABLE ;
@@ -381,6 +381,7 @@ static int stm32_dcmipp_conf_csi(const struct device *dev, uint32_t dcmipp_csi_b
381381 const struct stm32_dcmipp_config * config = dev -> config ;
382382 struct stm32_dcmipp_data * dcmipp = dev -> data ;
383383 DCMIPP_CSI_ConfTypeDef csiconf = { 0 };
384+ HAL_StatusTypeDef hal_ret ;
384385 int64_t phy_bitrate ;
385386 int err , i ;
386387
@@ -411,17 +412,17 @@ static int stm32_dcmipp_conf_csi(const struct device *dev, uint32_t dcmipp_csi_b
411412 }
412413 csiconf .PHYBitrate = stm32_dcmipp_bitrate [i ].PHYBitrate ;
413414
414- err = HAL_DCMIPP_CSI_SetConfig (& dcmipp -> hdcmipp , & csiconf );
415- if (err != HAL_OK ) {
415+ hal_ret = HAL_DCMIPP_CSI_SetConfig (& dcmipp -> hdcmipp , & csiconf );
416+ if (hal_ret != HAL_OK ) {
416417 LOG_ERR ("Failed to configure DCMIPP CSI" );
417418 return - EIO ;
418419 }
419420
420421 /* Set Virtual Channel config */
421422 /* TODO - need to be able to use an alternate VC, info coming from the source */
422- err = HAL_DCMIPP_CSI_SetVCConfig (& dcmipp -> hdcmipp , DCMIPP_VIRTUAL_CHANNEL0 ,
423- dcmipp_csi_bpp );
424- if (err != HAL_OK ) {
423+ hal_ret = HAL_DCMIPP_CSI_SetVCConfig (& dcmipp -> hdcmipp , DCMIPP_VIRTUAL_CHANNEL0 ,
424+ dcmipp_csi_bpp );
425+ if (hal_ret != HAL_OK ) {
425426 LOG_ERR ("Failed to set CSI configuration" );
426427 return - EIO ;
427428 }
@@ -691,7 +692,7 @@ static int stm32_dcmipp_set_crop(struct stm32_dcmipp_pipe_data *pipe)
691692 DCMIPP_CropConfTypeDef crop_cfg ;
692693 uint32_t frame_width = dcmipp -> source_fmt .width ;
693694 uint32_t frame_height = dcmipp -> source_fmt .height ;
694- int ret ;
695+ HAL_StatusTypeDef ret ;
695696
696697#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
697698 if (pipe -> id == DCMIPP_PIPE1 || pipe -> id == DCMIPP_PIPE2 ) {
@@ -760,7 +761,7 @@ static int stm32_dcmipp_set_downscale(struct stm32_dcmipp_pipe_data *pipe)
760761 DCMIPP_DownsizeTypeDef downsize_cfg ;
761762 struct video_rect * compose = & pipe -> compose ;
762763 uint32_t hdec = 1 , vdec = 1 ;
763- int ret ;
764+ HAL_StatusTypeDef ret ;
764765
765766 if (compose -> width == pipe -> crop .width && compose -> height == pipe -> crop .height ) {
766767 ret = HAL_DCMIPP_PIPE_DisableDecimation (& dcmipp -> hdcmipp , pipe -> id );
@@ -871,7 +872,7 @@ static int stm32_dcmipp_set_yuv_conversion(struct stm32_dcmipp_pipe_data *pipe,
871872{
872873 struct stm32_dcmipp_data * dcmipp = pipe -> dcmipp ;
873874 const DCMIPP_ColorConversionConfTypeDef * cfg = NULL ;
874- int ret ;
875+ HAL_StatusTypeDef ret ;
875876
876877 /* No YUV conversion on pipe 2 */
877878 if (pipe -> id == DCMIPP_PIPE2 ) {
@@ -922,7 +923,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
922923#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
923924 struct video_format * fmt = & pipe -> fmt ;
924925#endif
925- int ret ;
926+ HAL_StatusTypeDef ret ;
926927
927928#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
928929 if (VIDEO_FMT_IS_PLANAR (fmt )) {
@@ -948,7 +949,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
948949#endif
949950 else {
950951 LOG_ERR ("Invalid bus_type" );
951- ret = - EINVAL ;
952+ ret = HAL_ERROR ;
952953 }
953954 } else if (VIDEO_FMT_IS_SEMI_PLANAR (fmt )) {
954955 uint8_t * uv_addr = pipe -> next -> buffer + VIDEO_FMT_PLANAR_Y_PLANE_SIZE (fmt );
@@ -972,7 +973,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
972973#endif
973974 else {
974975 LOG_ERR ("Invalid bus_type" );
975- ret = - EINVAL ;
976+ ret = HAL_ERROR ;
976977 }
977978 } else {
978979#endif
@@ -991,7 +992,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
991992#endif
992993 else {
993994 LOG_ERR ("Invalid bus_type" );
994- ret = - EINVAL ;
995+ ret = HAL_ERROR ;
995996 }
996997#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
997998 }
@@ -1015,6 +1016,7 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
10151016 DCMIPP_CSI_PIPE_ConfTypeDef csi_pipe_cfg = { 0 };
10161017#endif
10171018 DCMIPP_PipeConfTypeDef pipe_cfg = { 0 };
1019+ HAL_StatusTypeDef hal_ret ;
10181020 int ret ;
10191021
10201022 k_mutex_lock (& pipe -> lock , K_FOREVER );
@@ -1069,10 +1071,10 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
10691071 /* Configure the Pipe input */
10701072 csi_pipe_cfg .DataTypeMode = DCMIPP_DTMODE_DTIDA ;
10711073 csi_pipe_cfg .DataTypeIDA = input_fmt -> dcmipp_csi_dt ;
1072- ret = HAL_DCMIPP_CSI_PIPE_SetConfig (& dcmipp -> hdcmipp ,
1073- pipe -> id == DCMIPP_PIPE2 ? DCMIPP_PIPE1 : pipe -> id ,
1074- & csi_pipe_cfg );
1075- if (ret != HAL_OK ) {
1074+ hal_ret = HAL_DCMIPP_CSI_PIPE_SetConfig (& dcmipp -> hdcmipp ,
1075+ pipe -> id == DCMIPP_PIPE2 ? DCMIPP_PIPE1 : pipe -> id ,
1076+ & csi_pipe_cfg );
1077+ if (hal_ret != HAL_OK ) {
10761078 LOG_ERR ("Failed to configure pipe #%d input" , pipe -> id );
10771079 ret = - EIO ;
10781080 goto out ;
@@ -1094,8 +1096,8 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
10941096 pipe_cfg .PixelPackerFormat = mapping -> pixels .dcmipp_format ;
10951097 }
10961098#endif
1097- ret = HAL_DCMIPP_PIPE_SetConfig (& dcmipp -> hdcmipp , pipe -> id , & pipe_cfg );
1098- if (ret != HAL_OK ) {
1099+ hal_ret = HAL_DCMIPP_PIPE_SetConfig (& dcmipp -> hdcmipp , pipe -> id , & pipe_cfg );
1100+ if (hal_ret != HAL_OK ) {
10991101 LOG_ERR ("Failed to configure pipe #%d" , pipe -> id );
11001102 ret = - EIO ;
11011103 goto out ;
@@ -1110,9 +1112,9 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
11101112
11111113 /* Only the PIPE0 has a limiter */
11121114 /* Set Limiter to avoid buffer overflow, in number of 32 bits words */
1113- ret = HAL_DCMIPP_PIPE_EnableLimitEvent (& dcmipp -> hdcmipp , DCMIPP_PIPE0 ,
1114- (fmt -> pitch * fmt -> height ) / 4 );
1115- if (ret != HAL_OK ) {
1115+ hal_ret = HAL_DCMIPP_PIPE_EnableLimitEvent (& dcmipp -> hdcmipp , DCMIPP_PIPE0 ,
1116+ (fmt -> pitch * fmt -> height ) / 4 );
1117+ if (hal_ret != HAL_OK ) {
11161118 LOG_ERR ("Failed to set limiter" );
11171119 ret = - EIO ;
11181120 goto out ;
@@ -1125,15 +1127,15 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
11251127
11261128 /* Enable / disable SWAPRB if necessary */
11271129 if (mapping -> pixels .swap_uv ) {
1128- ret = HAL_DCMIPP_PIPE_EnableRedBlueSwap (& dcmipp -> hdcmipp , pipe -> id );
1129- if (ret != HAL_OK ) {
1130+ hal_ret = HAL_DCMIPP_PIPE_EnableRedBlueSwap (& dcmipp -> hdcmipp , pipe -> id );
1131+ if (hal_ret != HAL_OK ) {
11301132 LOG_ERR ("Failed to enable Red-Blue swap" );
11311133 ret = - EIO ;
11321134 goto out ;
11331135 }
11341136 } else {
1135- ret = HAL_DCMIPP_PIPE_DisableRedBlueSwap (& dcmipp -> hdcmipp , pipe -> id );
1136- if (ret != HAL_OK ) {
1137+ hal_ret = HAL_DCMIPP_PIPE_DisableRedBlueSwap (& dcmipp -> hdcmipp , pipe -> id );
1138+ if (hal_ret != HAL_OK ) {
11371139 LOG_ERR ("Failed to disable Red-Blue swap" );
11381140 ret = - EIO ;
11391141 goto out ;
@@ -1142,17 +1144,18 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
11421144
11431145 if (source_colorspace == VIDEO_COLORSPACE_RAW ) {
11441146 /* Enable demosaicing if input format is Bayer */
1145- ret = HAL_DCMIPP_PIPE_EnableISPRawBayer2RGB (& dcmipp -> hdcmipp , DCMIPP_PIPE1 );
1146- if (ret != HAL_OK ) {
1147+ hal_ret = HAL_DCMIPP_PIPE_EnableISPRawBayer2RGB (& dcmipp -> hdcmipp ,
1148+ DCMIPP_PIPE1 );
1149+ if (hal_ret != HAL_OK ) {
11471150 LOG_ERR ("Failed to enable demosaicing" );
11481151 ret = - EIO ;
11491152 goto out ;
11501153 }
11511154 } else {
11521155 /* Disable demosaicing */
1153- ret = HAL_DCMIPP_PIPE_DisableISPRawBayer2RGB (& dcmipp -> hdcmipp ,
1154- DCMIPP_PIPE1 );
1155- if (ret != HAL_OK ) {
1156+ hal_et = HAL_DCMIPP_PIPE_DisableISPRawBayer2RGB (& dcmipp -> hdcmipp ,
1157+ DCMIPP_PIPE1 );
1158+ if (hal_ret != HAL_OK ) {
11561159 LOG_ERR ("Failed to disable demosaicing" );
11571160 ret = - EIO ;
11581161 goto out ;
@@ -1198,12 +1201,18 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
11981201 if (ret < 0 ) {
11991202 LOG_ERR ("Failed to start the source" );
12001203 if (config -> bus_type == VIDEO_BUS_TYPE_PARALLEL ) {
1201- HAL_DCMIPP_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id );
1204+ if (HAL_DCMIPP_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ) != HAL_OK ) {
1205+ ret = - EIO ;
1206+ goto out ;
1207+ }
12021208 }
12031209#if defined(STM32_DCMIPP_HAS_CSI )
12041210 else if (config -> bus_type == VIDEO_BUS_TYPE_CSI2_DPHY ) {
1205- HAL_DCMIPP_CSI_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ,
1206- DCMIPP_VIRTUAL_CHANNEL0 );
1211+ if (HAL_DCMIPP_CSI_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ,
1212+ DCMIPP_VIRTUAL_CHANNEL0 ) != HAL_OK ) {
1213+ ret = - EIO ;
1214+ goto out ;
1215+ }
12071216 }
12081217#endif
12091218 else {
@@ -1237,6 +1246,7 @@ static int stm32_dcmipp_stream_disable(const struct device *dev)
12371246 struct stm32_dcmipp_pipe_data * pipe = dev -> data ;
12381247 struct stm32_dcmipp_data * dcmipp = pipe -> dcmipp ;
12391248 const struct stm32_dcmipp_config * config = dev -> config ;
1249+ HAL_StatusTypeDef hal_ret ;
12401250 int ret ;
12411251
12421252 k_mutex_lock (& pipe -> lock , K_FOREVER );
@@ -1249,28 +1259,32 @@ static int stm32_dcmipp_stream_disable(const struct device *dev)
12491259#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
12501260 /* Stop the external ISP handling */
12511261 ret = stm32_dcmipp_isp_stop ();
1252- if (ret < 0 ) {
1262+ if (ret != 0 ) {
12531263 goto out ;
12541264 }
12551265#endif
12561266
12571267 /* Disable the DCMIPP Pipeline */
12581268 if (config -> bus_type == VIDEO_BUS_TYPE_PARALLEL ) {
1259- ret = HAL_DCMIPP_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id );
1269+ if (HAL_DCMIPP_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ) != HAL_OK ) {
1270+ ret = - EIO ;
1271+ }
12601272 }
12611273#if defined(STM32_DCMIPP_HAS_CSI )
12621274 else if (config -> bus_type == VIDEO_BUS_TYPE_CSI2_DPHY ) {
1263- ret = HAL_DCMIPP_CSI_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id , DCMIPP_VIRTUAL_CHANNEL0 );
1275+ if (HAL_DCMIPP_CSI_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ,
1276+ DCMIPP_VIRTUAL_CHANNEL0 ) != HAL_OK ) {
1277+ ret = - EIO ;
1278+ }
12641279 }
12651280#endif
12661281 else {
12671282 LOG_ERR ("Invalid bus_type" );
12681283 ret = - EIO ;
12691284 goto out ;
12701285 }
1271- if (ret != HAL_OK ) {
1286+ if (ret != 0 ) {
12721287 LOG_ERR ("Failed to stop the pipeline" );
1273- ret = - EIO ;
12741288 goto out ;
12751289 }
12761290
0 commit comments