From fb7b31b573353be750f216a538eadfba7899314c Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Mon, 20 May 2024 14:02:37 +0200 Subject: [PATCH] drivers: video: add a macro to generate an endpoint ID This allows referring to one particular interface more easily from the application or drivers definitions. The generated endpoint ID is extracted from the address: the reg property from the devicetree. Signed-off-by: Josuah Demangeon --- include/zephyr/drivers/video.h | 38 +--------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/include/zephyr/drivers/video.h b/include/zephyr/drivers/video.h index f9c1d92b8bf5b3b..d3cd7cfaf98b9bd 100644 --- a/include/zephyr/drivers/video.h +++ b/include/zephyr/drivers/video.h @@ -33,42 +33,6 @@ extern "C" { #endif -/** - * @brief Video Device Tree endpoint identifier - * - * Identify a particular port and particular endpoint of a video device, - * providing all the context necessary to act upon a video device, via one of - * its endpoint. - */ -struct video_dt_spec { - /** Device instance of the remote video device to communicate with. */ - const struct device *dev; - /** Devicetree address for this endpoint. */ - uint32_t endpoint; -}; - -/** - * @brief Get a device reference for an endpoint of a video controller. - * - * @code - * mipi0: mipi-controller@... { - * mipi0out: endpoint@0 { - * remote-endpoint = <&mjpeg0in>; - * }; - * }; - * @endcode - * - * Here, the devicetree spec for mipi0out can be obtaine with: - * - * @code - * struct video_dt_spec spec = VIDEO_DT_SPEC_GET(DT_NODELABEL(mipi0out)); - * @endcode - * - * @param node_id node identifier of an endpoint phandle property - */ -#define VIDEO_DT_SPEC_GET(node_id) \ - {.dev = DEVICE_DT_GET(DT_BUS(node_id)), .endpoint = VIDEO_ENDPOINT_ID(node_id)} - /** * Obtain the endpoint ID out of an devicetree endpoint node. * @@ -99,7 +63,7 @@ struct video_dt_spec { * @param node_id node identifier of an endpoint phandle property * @return an integer aggregating all the addresses */ -#define VIDEO_ENDPOINT_ID(node_id) \ +#define VIDEO_DT_ENDPOINT_ID(node_id) \ COND_CODE_0(DT_NUM_REGS(node_id) == 0, (Z_VIDEO_REG0(node_id)), \ (COND_CODE_1(DT_NUM_REGS(node_id) == 1, (Z_VIDEO_REG1(node_id)), \ (COND_CODE_1(DT_NUM_REGS(node_id) == 2, (Z_VIDEO_REG2(node_id)), \