Skip to content

Commit b80e09e

Browse files
author
Alain Volmat
committed
video: stm32: dcmi: perform config based on endpoint properties
Perform sensor interface properties parsing based on values retrieved via the endpoint rather than the root of the node. Use DT_PROP_OR to ensure proper configuration of optional settings. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
1 parent 212d827 commit b80e09e

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

drivers/video/video_stm32_dcmi.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,22 @@ static struct video_stm32_dcmi_data video_stm32_dcmi_data_0 = {
417417
.Instance = (DCMI_TypeDef *) DT_INST_REG_ADDR(0),
418418
.Init = {
419419
.SynchroMode = DCMI_SYNCHRO_HARDWARE,
420-
.PCKPolarity = (DT_INST_PROP(0, pixelclk_active) ?
421-
DCMI_PCKPOLARITY_RISING : DCMI_PCKPOLARITY_FALLING),
422-
.HSPolarity = (DT_INST_PROP(0, hsync_active) ?
423-
DCMI_HSPOLARITY_HIGH : DCMI_HSPOLARITY_LOW),
424-
.VSPolarity = (DT_INST_PROP(0, vsync_active) ?
425-
DCMI_VSPOLARITY_HIGH : DCMI_VSPOLARITY_LOW),
420+
.PCKPolarity = DT_PROP_OR(DT_INST_ENDPOINT_BY_ID(n, 0, 0),
421+
pclk_sample, 0) ?
422+
DCMI_PCKPOLARITY_RISING :
423+
DCMI_PCKPOLARITY_FALLING,
424+
.HSPolarity = DT_PROP_OR(DT_INST_ENDPOINT_BY_ID(n, 0, 0),
425+
hsync_active, 0) ?
426+
DCMI_HSPOLARITY_HIGH : DCMI_HSPOLARITY_LOW,
427+
.VSPolarity = DT_PROP_OR(DT_INST_ENDPOINT_BY_ID(n, 0, 0),
428+
vsync_active, 0) ?
429+
DCMI_VSPOLARITY_HIGH : DCMI_VSPOLARITY_LOW,
426430
.CaptureRate = STM32_DCMI_GET_CAPTURE_RATE(
427-
DT_INST_PROP(0, capture_rate)),
431+
DT_PROP_OR(DT_DRV_INST(inst), capture_rate,
432+
1)),
428433
.ExtendedDataMode = STM32_DCMI_GET_BUS_WIDTH(
429-
DT_INST_PROP(0, bus_width)),
434+
DT_PROP_OR(DT_INST_ENDPOINT_BY_ID(n, 0, 0),
435+
bus_width, 8)),
430436
.JPEGMode = DCMI_JPEG_DISABLE,
431437
.ByteSelectMode = DCMI_BSM_ALL,
432438
.ByteSelectStart = DCMI_OEBS_ODD,
@@ -436,7 +442,7 @@ static struct video_stm32_dcmi_data video_stm32_dcmi_data_0 = {
436442
},
437443
};
438444

439-
#define SOURCE_DEV(n) DEVICE_DT_GET(DT_INST_PHANDLE(n, sensor))
445+
#define SOURCE_DEV(n) DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 0, 0)))
440446

441447
static const struct video_stm32_dcmi_config video_stm32_dcmi_config_0 = {
442448
.pclken = {

0 commit comments

Comments
 (0)