Skip to content

Commit

Permalink
drivers: video: Use endpoint DT helpers
Browse files Browse the repository at this point in the history
Drop the driver-defined macros. Use the endpoint DT helpers of the video
framework instead.

Signed-off-by: Phi Bang Nguyen <[email protected]>
  • Loading branch information
ngphibang committed Dec 5, 2024
1 parent 8e49898 commit b37117f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
12 changes: 1 addition & 11 deletions drivers/video/video_mcux_csi.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
#include <fsl_cache.h>
#endif

#if defined(CONFIG_VIDEO_MCUX_MIPI_CSI2RX)
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
DEVICE_DT_GET(DT_PARENT(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label)))))
#else
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label))))
#endif

struct video_mcux_csi_config {
CSI_Type *base;
const struct device *source_dev;
Expand Down Expand Up @@ -502,7 +492,7 @@ PINCTRL_DT_INST_DEFINE(0);

static const struct video_mcux_csi_config video_mcux_csi_config_0 = {
.base = (CSI_Type *)DT_INST_REG_ADDR(0),
.source_dev = DEVICE_DT_INST_GET_SOURCE_DEV(0),
.source_dev = DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(0, 0, 0))),
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
};

Expand Down
12 changes: 3 additions & 9 deletions drivers/video/video_mcux_mipi_csi2rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ LOG_MODULE_REGISTER(video_mipi_csi2rx, CONFIG_VIDEO_LOG_LEVEL);

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

#define DEVICE_DT_INST_GET_SENSOR_DEV(n) \
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL( \
DT_STRING_TOKEN(DT_CHILD(DT_CHILD(DT_INST_CHILD(n, ports), port_1), endpoint), \
remote_endpoint_label))))

struct mipi_csi2rx_config {
const MIPI_CSI2RX_Type *base;
const struct device *sensor_dev;
Expand Down Expand Up @@ -349,9 +344,7 @@ static int mipi_csi2rx_init(const struct device *dev)

#define MIPI_CSI2RX_INIT(n) \
static struct mipi_csi2rx_data mipi_csi2rx_data_##n = { \
.csi2rxConfig.laneNum = \
DT_PROP_LEN(DT_CHILD(DT_CHILD(DT_INST_CHILD(n, ports), port_1), endpoint), \
data_lanes), \
.csi2rxConfig.laneNum = DT_PROP_LEN(DT_INST_ENDPOINT_BY_ID(n, 1, 0), data_lanes), \
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
.clock_root = (clock_control_subsys_t)DT_INST_CLOCKS_CELL_BY_IDX(n, 0, name), \
.clock_ui = (clock_control_subsys_t)DT_INST_CLOCKS_CELL_BY_IDX(n, 1, name), \
Expand All @@ -360,7 +353,8 @@ static int mipi_csi2rx_init(const struct device *dev)
\
static const struct mipi_csi2rx_config mipi_csi2rx_config_##n = { \
.base = (MIPI_CSI2RX_Type *)DT_INST_REG_ADDR(n), \
.sensor_dev = DEVICE_DT_INST_GET_SENSOR_DEV(n), \
.sensor_dev = \
DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 1, 0))), \
}; \
\
DEVICE_DT_INST_DEFINE(n, &mipi_csi2rx_init, NULL, &mipi_csi2rx_data_##n, \
Expand Down

0 comments on commit b37117f

Please sign in to comment.