Skip to content

Commit fbdfef0

Browse files
committed
drivers: video: Use endpoint DT helpers
Drop the driver-defined macros. Use the endpoint DT helpers of the video framework instead. Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
1 parent de10d70 commit fbdfef0

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

drivers/video/video_mcux_csi.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
#include <fsl_cache.h>
1919
#endif
2020

21-
#if defined(CONFIG_VIDEO_MCUX_MIPI_CSI2RX)
22-
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
23-
DEVICE_DT_GET(DT_PARENT(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
24-
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label)))))
25-
#else
26-
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
27-
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
28-
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label))))
29-
#endif
30-
3121
struct video_mcux_csi_config {
3222
CSI_Type *base;
3323
const struct device *source_dev;
@@ -502,7 +492,7 @@ PINCTRL_DT_INST_DEFINE(0);
502492

503493
static const struct video_mcux_csi_config video_mcux_csi_config_0 = {
504494
.base = (CSI_Type *)DT_INST_REG_ADDR(0),
505-
.source_dev = DEVICE_DT_INST_GET_SOURCE_DEV(0),
495+
.source_dev = DEVICE_DT_GET_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(0, 0, 0)),
506496
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
507497
};
508498

drivers/video/video_mcux_mipi_csi2rx.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ LOG_MODULE_REGISTER(video_mipi_csi2rx, CONFIG_VIDEO_LOG_LEVEL);
2121

2222
#define ABS(a, b) (a > b ? a - b : b - a)
2323

24-
#define DEVICE_DT_INST_GET_SENSOR_DEV(n) \
25-
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL( \
26-
DT_STRING_TOKEN(DT_CHILD(DT_CHILD(DT_INST_CHILD(n, ports), port_1), endpoint), \
27-
remote_endpoint_label))))
28-
2924
struct mipi_csi2rx_config {
3025
const MIPI_CSI2RX_Type *base;
3126
const struct device *sensor_dev;
@@ -349,9 +344,7 @@ static int mipi_csi2rx_init(const struct device *dev)
349344

350345
#define MIPI_CSI2RX_INIT(n) \
351346
static struct mipi_csi2rx_data mipi_csi2rx_data_##n = { \
352-
.csi2rxConfig.laneNum = \
353-
DT_PROP_LEN(DT_CHILD(DT_CHILD(DT_INST_CHILD(n, ports), port_1), endpoint), \
354-
data_lanes), \
347+
.csi2rxConfig.laneNum = DT_PROP_LEN(DT_INST_ENDPOINT_BY_ID(n, 1, 0), data_lanes), \
355348
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
356349
.clock_root = (clock_control_subsys_t)DT_INST_CLOCKS_CELL_BY_IDX(n, 0, name), \
357350
.clock_ui = (clock_control_subsys_t)DT_INST_CLOCKS_CELL_BY_IDX(n, 1, name), \
@@ -360,7 +353,7 @@ static int mipi_csi2rx_init(const struct device *dev)
360353
\
361354
static const struct mipi_csi2rx_config mipi_csi2rx_config_##n = { \
362355
.base = (MIPI_CSI2RX_Type *)DT_INST_REG_ADDR(n), \
363-
.sensor_dev = DEVICE_DT_INST_GET_SENSOR_DEV(n), \
356+
.sensor_dev = DEVICE_DT_GET_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 1, 0)), \
364357
}; \
365358
\
366359
DEVICE_DT_INST_DEFINE(n, &mipi_csi2rx_init, NULL, &mipi_csi2rx_data_##n, \

0 commit comments

Comments
 (0)