Skip to content

Conversation

ABESTM
Copy link
Contributor

@ABESTM ABESTM commented Sep 30, 2025

This fixes bug where stm32_dcmipp_isp_init is called multiple times.

@erwango
Copy link
Member

erwango commented Oct 2, 2025

@ABESTM CI failed due to a SonarCloud issue, nothing related to your PR, but I'm not able to launch it again. Would you mind rebasing your PR to hopefully get it right next time ?

@HaeberleAtBosch
Copy link

I have tested the patch with a modified video capture example (can not attach here) - which does change the zoom level every second - and it does work well.

@ABESTM ABESTM force-pushed the stm32_dcmipp_initonce branch from 62636ce to 777cf30 Compare October 2, 2025 15:03
* initiialized
*/
if (atomic_cas(&isp_init_once, 0, 1) &&
if (atomic_cas(&pipe->isp_init_once, 0, 1) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean caller for this function may return with success while another thread has still not yet completed the pipe initialization through stm32_dcmipp_stream_enable()? Maybe a mutex would be preferable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, this could be a problem, and I will rewrite this.
There is already a mutex on the pipe I can probably reuse. Thank you.

Copy link

@avolmat-st avolmat-st Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ABESTM for this fix.
This isp initialization has to be done only once for the whole device instead of once per pipe, so I think it should be held within the struct stm32_dcmipp_data instead of within the pipe structure in order to avoid having it initialized everytime a pipe is used (in a multi-pipe use case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the mutex part.
I noticed that in stm32_dcmipp_get_fmt the stm32_dcmipp_isp_init is called only for DCMIPP_PIPE1 and DCMIPP_PIPE2, but in stm32_dcmipp_stream_enable it is called always.
Maybe in the stm32_dcmipp_stream_enable it should be also called only for DCMIPP_PIPE1 and DCMIPP_PIPE2?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, it might better be part of the previous if statement right after the set_yuv_conversion.
However in fact, considering that the isp_init is done within the get_fmt function, I am no more sure it is really necessary within the stream_enable function. In most / all (current) cases, it will never do anything in fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the optimal solution would be to call it inside stm32_dcmipp_init, but this would require that the camera sensor (config->source_dev) is initialized before. This way we could get rid of the mutex.
This would probably require defining additional priority level in Kconfig.

@ABESTM ABESTM force-pushed the stm32_dcmipp_initonce branch from 777cf30 to ca7d9e1 Compare October 3, 2025 08:20
@ABESTM ABESTM force-pushed the stm32_dcmipp_initonce branch from ca7d9e1 to 80a1426 Compare October 13, 2025 09:14
@ABESTM
Copy link
Contributor Author

ABESTM commented Oct 13, 2025

I reworked the PR, to initialized ISP during dcmipp initialization. This is similar approach to what is done in video_mcux_mipi_csi2rx.c driver. I added new initialization priority (VIDEO_ISP_INIT_PRIORITY) to global config.
@ngphibang Maybe this could replace the VIDEO_MCUX_MIPI_CSI2RX_INIT_PRIORITY priority in NXP driver?

This fixes bug where stm32_dcmipp_isp_init is called multiple times.

Signed-off-by: Adam BERLINGER <[email protected]>
@ABESTM ABESTM force-pushed the stm32_dcmipp_initonce branch from 80a1426 to 09be14d Compare October 13, 2025 10:45
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Video Video subsystem platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants