@@ -196,8 +196,8 @@ void HAL_DCMIPP_PIPE_FrameEventCallback(DCMIPP_HandleTypeDef *hdcmipp, uint32_t
196
196
struct stm32_dcmipp_data * dcmipp =
197
197
CONTAINER_OF (hdcmipp , struct stm32_dcmipp_data , hdcmipp );
198
198
struct stm32_dcmipp_pipe_data * pipe = dcmipp -> pipe [Pipe ];
199
+ HAL_StatusTypeDef ret ;
199
200
uint32_t bytesused ;
200
- int ret ;
201
201
202
202
__ASSERT (pipe -> active , "Unexpected behavior, active_buf must not be NULL" );
203
203
@@ -324,7 +324,7 @@ static int stm32_dcmipp_conf_parallel(const struct device *dev,
324
324
struct stm32_dcmipp_data * dcmipp = dev -> data ;
325
325
const struct stm32_dcmipp_config * config = dev -> config ;
326
326
DCMIPP_ParallelConfTypeDef parallel_cfg = { 0 };
327
- int ret ;
327
+ HAL_StatusTypeDef ret ;
328
328
329
329
parallel_cfg .Format = input_fmt -> dcmipp_format ;
330
330
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
381
381
const struct stm32_dcmipp_config * config = dev -> config ;
382
382
struct stm32_dcmipp_data * dcmipp = dev -> data ;
383
383
DCMIPP_CSI_ConfTypeDef csiconf = { 0 };
384
+ HAL_StatusTypeDef hal_ret ;
384
385
int64_t phy_bitrate ;
385
386
int err , i ;
386
387
@@ -411,17 +412,17 @@ static int stm32_dcmipp_conf_csi(const struct device *dev, uint32_t dcmipp_csi_b
411
412
}
412
413
csiconf .PHYBitrate = stm32_dcmipp_bitrate [i ].PHYBitrate ;
413
414
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 ) {
416
417
LOG_ERR ("Failed to configure DCMIPP CSI" );
417
418
return - EIO ;
418
419
}
419
420
420
421
/* Set Virtual Channel config */
421
422
/* 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 ) {
425
426
LOG_ERR ("Failed to set CSI configuration" );
426
427
return - EIO ;
427
428
}
@@ -691,7 +692,7 @@ static int stm32_dcmipp_set_crop(struct stm32_dcmipp_pipe_data *pipe)
691
692
DCMIPP_CropConfTypeDef crop_cfg ;
692
693
uint32_t frame_width = dcmipp -> source_fmt .width ;
693
694
uint32_t frame_height = dcmipp -> source_fmt .height ;
694
- int ret ;
695
+ HAL_StatusTypeDef ret ;
695
696
696
697
#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
697
698
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)
760
761
DCMIPP_DownsizeTypeDef downsize_cfg ;
761
762
struct video_rect * compose = & pipe -> compose ;
762
763
uint32_t hdec = 1 , vdec = 1 ;
763
- int ret ;
764
+ HAL_StatusTypeDef ret ;
764
765
765
766
if (compose -> width == pipe -> crop .width && compose -> height == pipe -> crop .height ) {
766
767
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,
871
872
{
872
873
struct stm32_dcmipp_data * dcmipp = pipe -> dcmipp ;
873
874
const DCMIPP_ColorConversionConfTypeDef * cfg = NULL ;
874
- int ret ;
875
+ HAL_StatusTypeDef ret ;
875
876
876
877
/* No YUV conversion on pipe 2 */
877
878
if (pipe -> id == DCMIPP_PIPE2 ) {
@@ -922,7 +923,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
922
923
#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
923
924
struct video_format * fmt = & pipe -> fmt ;
924
925
#endif
925
- int ret ;
926
+ HAL_StatusTypeDef ret ;
926
927
927
928
#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
928
929
if (VIDEO_FMT_IS_PLANAR (fmt )) {
@@ -948,7 +949,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
948
949
#endif
949
950
else {
950
951
LOG_ERR ("Invalid bus_type" );
951
- ret = - EINVAL ;
952
+ ret = HAL_ERROR ;
952
953
}
953
954
} else if (VIDEO_FMT_IS_SEMI_PLANAR (fmt )) {
954
955
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,
972
973
#endif
973
974
else {
974
975
LOG_ERR ("Invalid bus_type" );
975
- ret = - EINVAL ;
976
+ ret = HAL_ERROR ;
976
977
}
977
978
} else {
978
979
#endif
@@ -991,7 +992,7 @@ static int stm32_dcmipp_start_pipeline(const struct device *dev,
991
992
#endif
992
993
else {
993
994
LOG_ERR ("Invalid bus_type" );
994
- ret = - EINVAL ;
995
+ ret = HAL_ERROR ;
995
996
}
996
997
#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES )
997
998
}
@@ -1015,6 +1016,7 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
1015
1016
DCMIPP_CSI_PIPE_ConfTypeDef csi_pipe_cfg = { 0 };
1016
1017
#endif
1017
1018
DCMIPP_PipeConfTypeDef pipe_cfg = { 0 };
1019
+ HAL_StatusTypeDef hal_ret ;
1018
1020
int ret ;
1019
1021
1020
1022
k_mutex_lock (& pipe -> lock , K_FOREVER );
@@ -1069,10 +1071,10 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
1069
1071
/* Configure the Pipe input */
1070
1072
csi_pipe_cfg .DataTypeMode = DCMIPP_DTMODE_DTIDA ;
1071
1073
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 ) {
1076
1078
LOG_ERR ("Failed to configure pipe #%d input" , pipe -> id );
1077
1079
ret = - EIO ;
1078
1080
goto out ;
@@ -1094,8 +1096,8 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
1094
1096
pipe_cfg .PixelPackerFormat = mapping -> pixels .dcmipp_format ;
1095
1097
}
1096
1098
#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 ) {
1099
1101
LOG_ERR ("Failed to configure pipe #%d" , pipe -> id );
1100
1102
ret = - EIO ;
1101
1103
goto out ;
@@ -1110,9 +1112,9 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
1110
1112
1111
1113
/* Only the PIPE0 has a limiter */
1112
1114
/* 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 ) {
1116
1118
LOG_ERR ("Failed to set limiter" );
1117
1119
ret = - EIO ;
1118
1120
goto out ;
@@ -1125,15 +1127,15 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
1125
1127
1126
1128
/* Enable / disable SWAPRB if necessary */
1127
1129
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 ) {
1130
1132
LOG_ERR ("Failed to enable Red-Blue swap" );
1131
1133
ret = - EIO ;
1132
1134
goto out ;
1133
1135
}
1134
1136
} 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 ) {
1137
1139
LOG_ERR ("Failed to disable Red-Blue swap" );
1138
1140
ret = - EIO ;
1139
1141
goto out ;
@@ -1142,17 +1144,18 @@ static int stm32_dcmipp_stream_enable(const struct device *dev)
1142
1144
1143
1145
if (source_colorspace == VIDEO_COLORSPACE_RAW ) {
1144
1146
/* 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 ) {
1147
1150
LOG_ERR ("Failed to enable demosaicing" );
1148
1151
ret = - EIO ;
1149
1152
goto out ;
1150
1153
}
1151
1154
} else {
1152
1155
/* Disable demosaicing */
1153
- ret = HAL_DCMIPP_PIPE_DisableISPRawBayer2RGB (& dcmipp -> hdcmipp ,
1154
- DCMIPP_PIPE1 );
1155
- if (ret != HAL_OK ) {
1156
+ hal_ret = HAL_DCMIPP_PIPE_DisableISPRawBayer2RGB (& dcmipp -> hdcmipp ,
1157
+ DCMIPP_PIPE1 );
1158
+ if (hal_ret != HAL_OK ) {
1156
1159
LOG_ERR ("Failed to disable demosaicing" );
1157
1160
ret = - EIO ;
1158
1161
goto out ;
@@ -1255,22 +1258,27 @@ static int stm32_dcmipp_stream_disable(const struct device *dev)
1255
1258
#endif
1256
1259
1257
1260
/* Disable the DCMIPP Pipeline */
1261
+ ret = 0 ;
1258
1262
if (config -> bus_type == VIDEO_BUS_TYPE_PARALLEL ) {
1259
- ret = HAL_DCMIPP_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id );
1263
+ if (HAL_DCMIPP_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ) != HAL_OK ) {
1264
+ ret = - EIO ;
1265
+ }
1260
1266
}
1261
1267
#if defined(STM32_DCMIPP_HAS_CSI )
1262
1268
else if (config -> bus_type == VIDEO_BUS_TYPE_CSI2_DPHY ) {
1263
- ret = HAL_DCMIPP_CSI_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id , DCMIPP_VIRTUAL_CHANNEL0 );
1269
+ if (HAL_DCMIPP_CSI_PIPE_Stop (& dcmipp -> hdcmipp , pipe -> id ,
1270
+ DCMIPP_VIRTUAL_CHANNEL0 ) != HAL_OK ) {
1271
+ ret = - EIO ;
1272
+ }
1264
1273
}
1265
1274
#endif
1266
1275
else {
1267
1276
LOG_ERR ("Invalid bus_type" );
1268
1277
ret = - EIO ;
1269
1278
goto out ;
1270
1279
}
1271
- if (ret != HAL_OK ) {
1280
+ if (ret < 0 ) {
1272
1281
LOG_ERR ("Failed to stop the pipeline" );
1273
- ret = - EIO ;
1274
1282
goto out ;
1275
1283
}
1276
1284
0 commit comments