1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 2 /* 3 * V4L2 fwnode binding parsing library 3 * V4L2 fwnode binding parsing library 4 * 4 * 5 * Copyright (c) 2016 Intel Corporation. 5 * Copyright (c) 2016 Intel Corporation. 6 * Author: Sakari Ailus <sakari.ailus@linux.in 6 * Author: Sakari Ailus <sakari.ailus@linux.intel.com> 7 * 7 * 8 * Copyright (C) 2012 - 2013 Samsung Electroni 8 * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. 9 * Author: Sylwester Nawrocki <s.nawrocki@sams 9 * Author: Sylwester Nawrocki <s.nawrocki@samsung.com> 10 * 10 * 11 * Copyright (C) 2012 Renesas Electronics Corp 11 * Copyright (C) 2012 Renesas Electronics Corp. 12 * Author: Guennadi Liakhovetski <g.liakhovets 12 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de> 13 */ 13 */ 14 #ifndef _V4L2_FWNODE_H 14 #ifndef _V4L2_FWNODE_H 15 #define _V4L2_FWNODE_H 15 #define _V4L2_FWNODE_H 16 16 17 #include <linux/errno.h> 17 #include <linux/errno.h> 18 #include <linux/fwnode.h> 18 #include <linux/fwnode.h> 19 #include <linux/list.h> 19 #include <linux/list.h> 20 #include <linux/types.h> 20 #include <linux/types.h> 21 21 22 #include <media/v4l2-mediabus.h> 22 #include <media/v4l2-mediabus.h> 23 23 >> 24 struct fwnode_handle; >> 25 struct v4l2_async_notifier; >> 26 struct v4l2_async_subdev; >> 27 >> 28 #define V4L2_FWNODE_CSI2_MAX_DATA_LANES 4 >> 29 >> 30 /** >> 31 * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure >> 32 * @flags: media bus (V4L2_MBUS_*) flags >> 33 * @data_lanes: an array of physical data lane indexes >> 34 * @clock_lane: physical lane index of the clock lane >> 35 * @num_data_lanes: number of data lanes >> 36 * @lane_polarities: polarity of the lanes. The order is the same of >> 37 * the physical lanes. >> 38 */ >> 39 struct v4l2_fwnode_bus_mipi_csi2 { >> 40 unsigned int flags; >> 41 unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES]; >> 42 unsigned char clock_lane; >> 43 unsigned char num_data_lanes; >> 44 bool lane_polarities[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES]; >> 45 }; >> 46 >> 47 /** >> 48 * struct v4l2_fwnode_bus_parallel - parallel data bus data structure >> 49 * @flags: media bus (V4L2_MBUS_*) flags >> 50 * @bus_width: bus width in bits >> 51 * @data_shift: data shift in bits >> 52 */ >> 53 struct v4l2_fwnode_bus_parallel { >> 54 unsigned int flags; >> 55 unsigned char bus_width; >> 56 unsigned char data_shift; >> 57 }; >> 58 >> 59 /** >> 60 * struct v4l2_fwnode_bus_mipi_csi1 - CSI-1/CCP2 data bus structure >> 61 * @clock_inv: polarity of clock/strobe signal >> 62 * false - not inverted, true - inverted >> 63 * @strobe: false - data/clock, true - data/strobe >> 64 * @lane_polarity: the polarities of the clock (index 0) and data lanes >> 65 * index (1) >> 66 * @data_lane: the number of the data lane >> 67 * @clock_lane: the number of the clock lane >> 68 */ >> 69 struct v4l2_fwnode_bus_mipi_csi1 { >> 70 unsigned char clock_inv:1; >> 71 unsigned char strobe:1; >> 72 bool lane_polarity[2]; >> 73 unsigned char data_lane; >> 74 unsigned char clock_lane; >> 75 }; >> 76 24 /** 77 /** 25 * struct v4l2_fwnode_endpoint - the endpoint 78 * struct v4l2_fwnode_endpoint - the endpoint data structure 26 * @base: fwnode endpoint of the v4l2_fwnode 79 * @base: fwnode endpoint of the v4l2_fwnode 27 * @bus_type: bus type 80 * @bus_type: bus type 28 * @bus: bus configuration data structure 81 * @bus: bus configuration data structure 29 * @bus.parallel: embedded &struct v4l2_mbus_c !! 82 * @bus.parallel: embedded &struct v4l2_fwnode_bus_parallel. 30 * Used if the bus is parallel. 83 * Used if the bus is parallel. 31 * @bus.mipi_csi1: embedded &struct v4l2_mbus_ !! 84 * @bus.mipi_csi1: embedded &struct v4l2_fwnode_bus_mipi_csi1. 32 * Used if the bus is MIPI All 85 * Used if the bus is MIPI Alliance's Camera Serial 33 * Interface version 1 (MIPI C 86 * Interface version 1 (MIPI CSI1) or Standard 34 * Mobile Imaging Architecture 87 * Mobile Imaging Architecture's Compact Camera Port 2 35 * (SMIA CCP2). 88 * (SMIA CCP2). 36 * @bus.mipi_csi2: embedded &struct v4l2_mbus_ !! 89 * @bus.mipi_csi2: embedded &struct v4l2_fwnode_bus_mipi_csi2. 37 * Used if the bus is MIPI All 90 * Used if the bus is MIPI Alliance's Camera Serial 38 * Interface version 2 (MIPI C 91 * Interface version 2 (MIPI CSI2). 39 * @link_frequencies: array of supported link 92 * @link_frequencies: array of supported link frequencies 40 * @nr_of_link_frequencies: number of elements 93 * @nr_of_link_frequencies: number of elements in link_frequenccies array 41 */ 94 */ 42 struct v4l2_fwnode_endpoint { 95 struct v4l2_fwnode_endpoint { 43 struct fwnode_endpoint base; 96 struct fwnode_endpoint base; >> 97 /* >> 98 * Fields below this line will be zeroed by >> 99 * v4l2_fwnode_endpoint_parse() >> 100 */ 44 enum v4l2_mbus_type bus_type; 101 enum v4l2_mbus_type bus_type; 45 struct { 102 struct { 46 struct v4l2_mbus_config_parall !! 103 struct v4l2_fwnode_bus_parallel parallel; 47 struct v4l2_mbus_config_mipi_c !! 104 struct v4l2_fwnode_bus_mipi_csi1 mipi_csi1; 48 struct v4l2_mbus_config_mipi_c !! 105 struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2; 49 } bus; 106 } bus; 50 u64 *link_frequencies; 107 u64 *link_frequencies; 51 unsigned int nr_of_link_frequencies; 108 unsigned int nr_of_link_frequencies; 52 }; 109 }; 53 110 54 /** 111 /** 55 * V4L2_FWNODE_PROPERTY_UNSET - identify a non 112 * V4L2_FWNODE_PROPERTY_UNSET - identify a non initialized property 56 * 113 * 57 * All properties in &struct v4l2_fwnode_devic 114 * All properties in &struct v4l2_fwnode_device_properties are initialized 58 * to this value. 115 * to this value. 59 */ 116 */ 60 #define V4L2_FWNODE_PROPERTY_UNSET (-1U) 117 #define V4L2_FWNODE_PROPERTY_UNSET (-1U) 61 118 62 /** 119 /** 63 * enum v4l2_fwnode_orientation - possible dev 120 * enum v4l2_fwnode_orientation - possible device orientation 64 * @V4L2_FWNODE_ORIENTATION_FRONT: device inst 121 * @V4L2_FWNODE_ORIENTATION_FRONT: device installed on the front side 65 * @V4L2_FWNODE_ORIENTATION_BACK: device insta 122 * @V4L2_FWNODE_ORIENTATION_BACK: device installed on the back side 66 * @V4L2_FWNODE_ORIENTATION_EXTERNAL: device e 123 * @V4L2_FWNODE_ORIENTATION_EXTERNAL: device externally located 67 */ 124 */ 68 enum v4l2_fwnode_orientation { 125 enum v4l2_fwnode_orientation { 69 V4L2_FWNODE_ORIENTATION_FRONT, 126 V4L2_FWNODE_ORIENTATION_FRONT, 70 V4L2_FWNODE_ORIENTATION_BACK, 127 V4L2_FWNODE_ORIENTATION_BACK, 71 V4L2_FWNODE_ORIENTATION_EXTERNAL 128 V4L2_FWNODE_ORIENTATION_EXTERNAL 72 }; 129 }; 73 130 74 /** 131 /** 75 * struct v4l2_fwnode_device_properties - fwno 132 * struct v4l2_fwnode_device_properties - fwnode device properties 76 * @orientation: device orientation. See &enum 133 * @orientation: device orientation. See &enum v4l2_fwnode_orientation 77 * @rotation: device rotation 134 * @rotation: device rotation 78 */ 135 */ 79 struct v4l2_fwnode_device_properties { 136 struct v4l2_fwnode_device_properties { 80 enum v4l2_fwnode_orientation orientati 137 enum v4l2_fwnode_orientation orientation; 81 unsigned int rotation; 138 unsigned int rotation; 82 }; 139 }; 83 140 84 /** 141 /** 85 * struct v4l2_fwnode_link - a link between tw 142 * struct v4l2_fwnode_link - a link between two endpoints 86 * @local_node: pointer to device_node of this 143 * @local_node: pointer to device_node of this endpoint 87 * @local_port: identifier of the port this en 144 * @local_port: identifier of the port this endpoint belongs to 88 * @local_id: identifier of the id this endpoi 145 * @local_id: identifier of the id this endpoint belongs to 89 * @remote_node: pointer to device_node of the 146 * @remote_node: pointer to device_node of the remote endpoint 90 * @remote_port: identifier of the port the re 147 * @remote_port: identifier of the port the remote endpoint belongs to 91 * @remote_id: identifier of the id the remote 148 * @remote_id: identifier of the id the remote endpoint belongs to 92 */ 149 */ 93 struct v4l2_fwnode_link { 150 struct v4l2_fwnode_link { 94 struct fwnode_handle *local_node; 151 struct fwnode_handle *local_node; 95 unsigned int local_port; 152 unsigned int local_port; 96 unsigned int local_id; 153 unsigned int local_id; 97 struct fwnode_handle *remote_node; 154 struct fwnode_handle *remote_node; 98 unsigned int remote_port; 155 unsigned int remote_port; 99 unsigned int remote_id; 156 unsigned int remote_id; 100 }; 157 }; 101 158 102 /** 159 /** 103 * enum v4l2_connector_type - connector type 160 * enum v4l2_connector_type - connector type 104 * @V4L2_CONN_UNKNOWN: unknown connector typ 161 * @V4L2_CONN_UNKNOWN: unknown connector type, no V4L2 connector configuration 105 * @V4L2_CONN_COMPOSITE: analog composite conn 162 * @V4L2_CONN_COMPOSITE: analog composite connector 106 * @V4L2_CONN_SVIDEO: analog svideo connect 163 * @V4L2_CONN_SVIDEO: analog svideo connector 107 */ 164 */ 108 enum v4l2_connector_type { 165 enum v4l2_connector_type { 109 V4L2_CONN_UNKNOWN, 166 V4L2_CONN_UNKNOWN, 110 V4L2_CONN_COMPOSITE, 167 V4L2_CONN_COMPOSITE, 111 V4L2_CONN_SVIDEO, 168 V4L2_CONN_SVIDEO, 112 }; 169 }; 113 170 114 /** 171 /** 115 * struct v4l2_connector_link - connector link 172 * struct v4l2_connector_link - connector link data structure 116 * @head: structure to be used to add the link 173 * @head: structure to be used to add the link to the 117 * &struct v4l2_fwnode_connector 174 * &struct v4l2_fwnode_connector 118 * @fwnode_link: &struct v4l2_fwnode_link link 175 * @fwnode_link: &struct v4l2_fwnode_link link between the connector and the 119 * device the connector belongs 176 * device the connector belongs to. 120 */ 177 */ 121 struct v4l2_connector_link { 178 struct v4l2_connector_link { 122 struct list_head head; 179 struct list_head head; 123 struct v4l2_fwnode_link fwnode_link; 180 struct v4l2_fwnode_link fwnode_link; 124 }; 181 }; 125 182 126 /** 183 /** 127 * struct v4l2_fwnode_connector_analog - analo 184 * struct v4l2_fwnode_connector_analog - analog connector data structure 128 * @sdtv_stds: sdtv standards this connector s 185 * @sdtv_stds: sdtv standards this connector supports, set to V4L2_STD_ALL 129 * if no restrictions are specifie 186 * if no restrictions are specified. 130 */ 187 */ 131 struct v4l2_fwnode_connector_analog { 188 struct v4l2_fwnode_connector_analog { 132 v4l2_std_id sdtv_stds; 189 v4l2_std_id sdtv_stds; 133 }; 190 }; 134 191 135 /** 192 /** 136 * struct v4l2_fwnode_connector - the connecto 193 * struct v4l2_fwnode_connector - the connector data structure 137 * @name: the connector device name 194 * @name: the connector device name 138 * @label: optional connector label 195 * @label: optional connector label 139 * @type: connector type 196 * @type: connector type 140 * @links: list of all connector &struct v4l2_ 197 * @links: list of all connector &struct v4l2_connector_link links 141 * @nr_of_links: total number of links 198 * @nr_of_links: total number of links 142 * @connector: connector configuration 199 * @connector: connector configuration 143 * @connector.analog: analog connector configu 200 * @connector.analog: analog connector configuration 144 * &struct v4l2_fwnode_conn 201 * &struct v4l2_fwnode_connector_analog 145 */ 202 */ 146 struct v4l2_fwnode_connector { 203 struct v4l2_fwnode_connector { 147 const char *name; 204 const char *name; 148 const char *label; 205 const char *label; 149 enum v4l2_connector_type type; 206 enum v4l2_connector_type type; 150 struct list_head links; 207 struct list_head links; 151 unsigned int nr_of_links; 208 unsigned int nr_of_links; 152 209 153 union { 210 union { 154 struct v4l2_fwnode_connector_a 211 struct v4l2_fwnode_connector_analog analog; 155 /* future connectors */ 212 /* future connectors */ 156 } connector; 213 } connector; 157 }; 214 }; 158 215 159 /** 216 /** 160 * enum v4l2_fwnode_bus_type - Video bus types << 161 * @V4L2_FWNODE_BUS_TYPE_GUESS: Default value << 162 * @V4L2_FWNODE_BUS_TYPE_CSI2_CPHY: MIPI CSI-2 << 163 * @V4L2_FWNODE_BUS_TYPE_CSI1: MIPI CSI-1 bus << 164 * @V4L2_FWNODE_BUS_TYPE_CCP2: SMIA Compact Ca << 165 * @V4L2_FWNODE_BUS_TYPE_CSI2_DPHY: MIPI CSI-2 << 166 * @V4L2_FWNODE_BUS_TYPE_PARALLEL: Camera Para << 167 * @V4L2_FWNODE_BUS_TYPE_BT656: BT.656 video f << 168 * @V4L2_FWNODE_BUS_TYPE_DPI: Video Parallel I << 169 * @NR_OF_V4L2_FWNODE_BUS_TYPE: Number of bus- << 170 */ << 171 enum v4l2_fwnode_bus_type { << 172 V4L2_FWNODE_BUS_TYPE_GUESS = 0, << 173 V4L2_FWNODE_BUS_TYPE_CSI2_CPHY, << 174 V4L2_FWNODE_BUS_TYPE_CSI1, << 175 V4L2_FWNODE_BUS_TYPE_CCP2, << 176 V4L2_FWNODE_BUS_TYPE_CSI2_DPHY, << 177 V4L2_FWNODE_BUS_TYPE_PARALLEL, << 178 V4L2_FWNODE_BUS_TYPE_BT656, << 179 V4L2_FWNODE_BUS_TYPE_DPI, << 180 NR_OF_V4L2_FWNODE_BUS_TYPE << 181 }; << 182 << 183 /** << 184 * v4l2_fwnode_endpoint_parse() - parse all fw 217 * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties 185 * @fwnode: pointer to the endpoint's fwnode h 218 * @fwnode: pointer to the endpoint's fwnode handle 186 * @vep: pointer to the V4L2 fwnode data struc 219 * @vep: pointer to the V4L2 fwnode data structure 187 * 220 * 188 * This function parses the V4L2 fwnode endpoi 221 * This function parses the V4L2 fwnode endpoint specific parameters from the 189 * firmware. There are two ways to use this fu !! 222 * firmware. The caller is responsible for assigning @vep.bus_type to a valid 190 * obtain the type of the bus (by setting the !! 223 * media bus type. The caller may also set the default configuration for the 191 * V4L2_MBUS_UNKNOWN) or specifying the bus ty !! 224 * endpoint --- a configuration that shall be in line with the DT binding 192 * v4l2_mbus_type types. !! 225 * documentation. Should a device support multiple bus types, the caller may 193 * !! 226 * call this function once the correct type is found --- with a default 194 * When @vep.bus_type is V4L2_MBUS_UNKNOWN, th !! 227 * configuration valid for that type. 195 * property to determine the type when it is a !! 228 * 196 * responsible for validating the contents of !! 229 * It is also allowed to set @vep.bus_type to V4L2_MBUS_UNKNOWN. USING THIS 197 * returns. !! 230 * FEATURE REQUIRES "bus-type" PROPERTY IN DT BINDINGS. For old drivers, 198 * !! 231 * guessing @vep.bus_type between CSI-2 D-PHY, parallel and BT.656 busses is 199 * As a deprecated functionality to support ol !! 232 * supported. NEVER RELY ON GUESSING @vep.bus_type IN NEW DRIVERS! 200 * property for devices that support multiple << 201 * does not exist, the function will attempt t << 202 * endpoint properties available. NEVER RELY O << 203 * DRIVERS OR BINDINGS. << 204 * << 205 * It is also possible to set @vep.bus_type co << 206 * this case the function will only attempt to << 207 * bus, and it will return an error if the val << 208 * corresponds to a different bus. << 209 * 233 * 210 * The caller is required to initialise all fi 234 * The caller is required to initialise all fields of @vep, either with 211 * explicitly values, or by zeroing them. 235 * explicitly values, or by zeroing them. 212 * 236 * 213 * The function does not change the V4L2 fwnod 237 * The function does not change the V4L2 fwnode endpoint state if it fails. 214 * 238 * 215 * NOTE: This function does not parse "link-fr !! 239 * NOTE: This function does not parse properties the size of which is variable 216 * not known in advance. Please use v4l2_fwnod !! 240 * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in 217 * need properties of variable size. !! 241 * new drivers instead. 218 * 242 * 219 * Return: %0 on success or a negative error c 243 * Return: %0 on success or a negative error code on failure: 220 * %-ENOMEM on memory allocation failu 244 * %-ENOMEM on memory allocation failure 221 * %-EINVAL on parsing failure 245 * %-EINVAL on parsing failure 222 * %-ENXIO on mismatching bus types 246 * %-ENXIO on mismatching bus types 223 */ 247 */ 224 int v4l2_fwnode_endpoint_parse(struct fwnode_h 248 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, 225 struct v4l2_fwn 249 struct v4l2_fwnode_endpoint *vep); 226 250 227 /** 251 /** 228 * v4l2_fwnode_endpoint_free() - free the V4L2 252 * v4l2_fwnode_endpoint_free() - free the V4L2 fwnode acquired by 229 * v4l2_fwnode_endpoint_alloc_parse() 253 * v4l2_fwnode_endpoint_alloc_parse() 230 * @vep: the V4L2 fwnode the resources of whic 254 * @vep: the V4L2 fwnode the resources of which are to be released 231 * 255 * 232 * It is safe to call this function with NULL 256 * It is safe to call this function with NULL argument or on a V4L2 fwnode the 233 * parsing of which failed. 257 * parsing of which failed. 234 */ 258 */ 235 void v4l2_fwnode_endpoint_free(struct v4l2_fwn 259 void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); 236 260 237 /** 261 /** 238 * v4l2_fwnode_endpoint_alloc_parse() - parse 262 * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties 239 * @fwnode: pointer to the endpoint's fwnode h 263 * @fwnode: pointer to the endpoint's fwnode handle 240 * @vep: pointer to the V4L2 fwnode data struc 264 * @vep: pointer to the V4L2 fwnode data structure 241 * 265 * 242 * This function parses the V4L2 fwnode endpoi 266 * This function parses the V4L2 fwnode endpoint specific parameters from the 243 * firmware. There are two ways to use this fu !! 267 * firmware. The caller is responsible for assigning @vep.bus_type to a valid 244 * obtain the type of the bus (by setting the !! 268 * media bus type. The caller may also set the default configuration for the 245 * V4L2_MBUS_UNKNOWN) or specifying the bus ty !! 269 * endpoint --- a configuration that shall be in line with the DT binding 246 * v4l2_mbus_type types. !! 270 * documentation. Should a device support multiple bus types, the caller may 247 * !! 271 * call this function once the correct type is found --- with a default 248 * When @vep.bus_type is V4L2_MBUS_UNKNOWN, th !! 272 * configuration valid for that type. 249 * property to determine the type when it is a !! 273 * 250 * responsible for validating the contents of !! 274 * It is also allowed to set @vep.bus_type to V4L2_MBUS_UNKNOWN. USING THIS 251 * returns. !! 275 * FEATURE REQUIRES "bus-type" PROPERTY IN DT BINDINGS. For old drivers, 252 * !! 276 * guessing @vep.bus_type between CSI-2 D-PHY, parallel and BT.656 busses is 253 * As a deprecated functionality to support ol !! 277 * supported. NEVER RELY ON GUESSING @vep.bus_type IN NEW DRIVERS! 254 * property for devices that support multiple << 255 * does not exist, the function will attempt t << 256 * endpoint properties available. NEVER RELY O << 257 * DRIVERS OR BINDINGS. << 258 * << 259 * It is also possible to set @vep.bus_type co << 260 * this case the function will only attempt to << 261 * bus, and it will return an error if the val << 262 * corresponds to a different bus. << 263 * 278 * 264 * The caller is required to initialise all fi 279 * The caller is required to initialise all fields of @vep, either with 265 * explicitly values, or by zeroing them. 280 * explicitly values, or by zeroing them. 266 * 281 * 267 * The function does not change the V4L2 fwnod 282 * The function does not change the V4L2 fwnode endpoint state if it fails. 268 * 283 * 269 * v4l2_fwnode_endpoint_alloc_parse() has two 284 * v4l2_fwnode_endpoint_alloc_parse() has two important differences to 270 * v4l2_fwnode_endpoint_parse(): 285 * v4l2_fwnode_endpoint_parse(): 271 * 286 * 272 * 1. It also parses variable size data. 287 * 1. It also parses variable size data. 273 * 288 * 274 * 2. The memory it has allocated to store the 289 * 2. The memory it has allocated to store the variable size data must be freed 275 * using v4l2_fwnode_endpoint_free() when n 290 * using v4l2_fwnode_endpoint_free() when no longer needed. 276 * 291 * 277 * Return: %0 on success or a negative error c 292 * Return: %0 on success or a negative error code on failure: 278 * %-ENOMEM on memory allocation failu 293 * %-ENOMEM on memory allocation failure 279 * %-EINVAL on parsing failure 294 * %-EINVAL on parsing failure 280 * %-ENXIO on mismatching bus types 295 * %-ENXIO on mismatching bus types 281 */ 296 */ 282 int v4l2_fwnode_endpoint_alloc_parse(struct fw 297 int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode, 283 struct v4 298 struct v4l2_fwnode_endpoint *vep); 284 299 285 /** 300 /** 286 * v4l2_fwnode_parse_link() - parse a link bet 301 * v4l2_fwnode_parse_link() - parse a link between two endpoints 287 * @fwnode: pointer to the endpoint's fwnode a 302 * @fwnode: pointer to the endpoint's fwnode at the local end of the link 288 * @link: pointer to the V4L2 fwnode link data 303 * @link: pointer to the V4L2 fwnode link data structure 289 * 304 * 290 * Fill the link structure with the local and 305 * Fill the link structure with the local and remote nodes and port numbers. 291 * The local_node and remote_node fields are s 306 * The local_node and remote_node fields are set to point to the local and 292 * remote port's parent nodes respectively (th 307 * remote port's parent nodes respectively (the port parent node being the 293 * parent node of the port node if that node i 308 * parent node of the port node if that node isn't a 'ports' node, or the 294 * grand-parent node of the port node otherwis 309 * grand-parent node of the port node otherwise). 295 * 310 * 296 * A reference is taken to both the local and 311 * A reference is taken to both the local and remote nodes, the caller must use 297 * v4l2_fwnode_put_link() to drop the referenc 312 * v4l2_fwnode_put_link() to drop the references when done with the 298 * link. 313 * link. 299 * 314 * 300 * Return: 0 on success, or -ENOLINK if the re 315 * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode can't be 301 * found. 316 * found. 302 */ 317 */ 303 int v4l2_fwnode_parse_link(struct fwnode_handl 318 int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, 304 struct v4l2_fwnode_ 319 struct v4l2_fwnode_link *link); 305 320 306 /** 321 /** 307 * v4l2_fwnode_put_link() - drop references to 322 * v4l2_fwnode_put_link() - drop references to nodes in a link 308 * @link: pointer to the V4L2 fwnode link data 323 * @link: pointer to the V4L2 fwnode link data structure 309 * 324 * 310 * Drop references to the local and remote nod 325 * Drop references to the local and remote nodes in the link. This function 311 * must be called on every link parsed with v4 326 * must be called on every link parsed with v4l2_fwnode_parse_link(). 312 */ 327 */ 313 void v4l2_fwnode_put_link(struct v4l2_fwnode_l 328 void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); 314 329 315 /** 330 /** 316 * v4l2_fwnode_connector_free() - free the V4L 331 * v4l2_fwnode_connector_free() - free the V4L2 connector acquired memory 317 * @connector: the V4L2 connector resources of 332 * @connector: the V4L2 connector resources of which are to be released 318 * 333 * 319 * Free all allocated memory and put all links 334 * Free all allocated memory and put all links acquired by 320 * v4l2_fwnode_connector_parse() and v4l2_fwno 335 * v4l2_fwnode_connector_parse() and v4l2_fwnode_connector_add_link(). 321 * 336 * 322 * It is safe to call this function with NULL 337 * It is safe to call this function with NULL argument or on a V4L2 connector 323 * the parsing of which failed. 338 * the parsing of which failed. 324 */ 339 */ 325 void v4l2_fwnode_connector_free(struct v4l2_fw 340 void v4l2_fwnode_connector_free(struct v4l2_fwnode_connector *connector); 326 341 327 /** 342 /** 328 * v4l2_fwnode_connector_parse() - initialize 343 * v4l2_fwnode_connector_parse() - initialize the 'struct v4l2_fwnode_connector' 329 * @fwnode: pointer to the subdev endpoint's f 344 * @fwnode: pointer to the subdev endpoint's fwnode handle where the connector 330 * is connected to or to the connecto 345 * is connected to or to the connector endpoint fwnode handle. 331 * @connector: pointer to the V4L2 fwnode conn 346 * @connector: pointer to the V4L2 fwnode connector data structure 332 * 347 * 333 * Fill the &struct v4l2_fwnode_connector with 348 * Fill the &struct v4l2_fwnode_connector with the connector type, label and 334 * all &enum v4l2_connector_type specific conn 349 * all &enum v4l2_connector_type specific connector data. The label is optional 335 * so it is set to %NULL if no one was found. 350 * so it is set to %NULL if no one was found. The function initialize the links 336 * to zero. Adding links to the connector is d 351 * to zero. Adding links to the connector is done by calling 337 * v4l2_fwnode_connector_add_link(). 352 * v4l2_fwnode_connector_add_link(). 338 * 353 * 339 * The memory allocated for the label must be 354 * The memory allocated for the label must be freed when no longer needed. 340 * Freeing the memory is done by v4l2_fwnode_c 355 * Freeing the memory is done by v4l2_fwnode_connector_free(). 341 * 356 * 342 * Return: 357 * Return: 343 * * %0 on success or a negative error code on 358 * * %0 on success or a negative error code on failure: 344 * * %-EINVAL if @fwnode is invalid 359 * * %-EINVAL if @fwnode is invalid 345 * * %-ENOTCONN if connector type is unknown o 360 * * %-ENOTCONN if connector type is unknown or connector device can't be found 346 */ 361 */ 347 int v4l2_fwnode_connector_parse(struct fwnode_ 362 int v4l2_fwnode_connector_parse(struct fwnode_handle *fwnode, 348 struct v4l2_fw 363 struct v4l2_fwnode_connector *connector); 349 364 350 /** 365 /** 351 * v4l2_fwnode_connector_add_link - add a link 366 * v4l2_fwnode_connector_add_link - add a link between a connector node and 352 * a v4l2-sub 367 * a v4l2-subdev node. 353 * @fwnode: pointer to the subdev endpoint's f 368 * @fwnode: pointer to the subdev endpoint's fwnode handle where the connector 354 * is connected to 369 * is connected to 355 * @connector: pointer to the V4L2 fwnode conn 370 * @connector: pointer to the V4L2 fwnode connector data structure 356 * 371 * 357 * Add a new &struct v4l2_connector_link link 372 * Add a new &struct v4l2_connector_link link to the 358 * &struct v4l2_fwnode_connector connector lin 373 * &struct v4l2_fwnode_connector connector links list. The link local_node 359 * points to the connector node, the remote_no 374 * points to the connector node, the remote_node to the host v4l2 (sub)dev. 360 * 375 * 361 * The taken references to remote_node and loc 376 * The taken references to remote_node and local_node must be dropped and the 362 * allocated memory must be freed when no long 377 * allocated memory must be freed when no longer needed. Both is done by calling 363 * v4l2_fwnode_connector_free(). 378 * v4l2_fwnode_connector_free(). 364 * 379 * 365 * Return: 380 * Return: 366 * * %0 on success or a negative error code on 381 * * %0 on success or a negative error code on failure: 367 * * %-EINVAL if @fwnode or @connector is inva 382 * * %-EINVAL if @fwnode or @connector is invalid or @connector type is unknown 368 * * %-ENOMEM on link memory allocation failur 383 * * %-ENOMEM on link memory allocation failure 369 * * %-ENOTCONN if remote connector device can 384 * * %-ENOTCONN if remote connector device can't be found 370 * * %-ENOLINK if link parsing between v4l2 (s 385 * * %-ENOLINK if link parsing between v4l2 (sub)dev and connector fails 371 */ 386 */ 372 int v4l2_fwnode_connector_add_link(struct fwno 387 int v4l2_fwnode_connector_add_link(struct fwnode_handle *fwnode, 373 struct v4l2 388 struct v4l2_fwnode_connector *connector); 374 389 375 /** 390 /** 376 * v4l2_fwnode_device_parse() - parse fwnode d 391 * v4l2_fwnode_device_parse() - parse fwnode device properties 377 * @dev: pointer to &struct device 392 * @dev: pointer to &struct device 378 * @props: pointer to &struct v4l2_fwnode_devi 393 * @props: pointer to &struct v4l2_fwnode_device_properties where to store the 379 * parsed properties values 394 * parsed properties values 380 * 395 * 381 * This function parses and validates the V4L2 396 * This function parses and validates the V4L2 fwnode device properties from the 382 * firmware interface, and fills the @struct v 397 * firmware interface, and fills the @struct v4l2_fwnode_device_properties 383 * provided by the caller. 398 * provided by the caller. 384 * 399 * 385 * Return: 400 * Return: 386 * % 0 on success 401 * % 0 on success 387 * %-EINVAL if a parsed property value is 402 * %-EINVAL if a parsed property value is not valid 388 */ 403 */ 389 int v4l2_fwnode_device_parse(struct device *de 404 int v4l2_fwnode_device_parse(struct device *dev, 390 struct v4l2_fwnod 405 struct v4l2_fwnode_device_properties *props); >> 406 >> 407 /** >> 408 * typedef parse_endpoint_func - Driver's callback function to be called on >> 409 * each V4L2 fwnode endpoint. >> 410 * >> 411 * @dev: pointer to &struct device >> 412 * @vep: pointer to &struct v4l2_fwnode_endpoint >> 413 * @asd: pointer to &struct v4l2_async_subdev >> 414 * >> 415 * Return: >> 416 * * %0 on success >> 417 * * %-ENOTCONN if the endpoint is to be skipped but this >> 418 * should not be considered as an error >> 419 * * %-EINVAL if the endpoint configuration is invalid >> 420 */ >> 421 typedef int (*parse_endpoint_func)(struct device *dev, >> 422 struct v4l2_fwnode_endpoint *vep, >> 423 struct v4l2_async_subdev *asd); >> 424 >> 425 /** >> 426 * v4l2_async_notifier_parse_fwnode_endpoints - Parse V4L2 fwnode endpoints in a >> 427 * device node >> 428 * @dev: the device the endpoints of which are to be parsed >> 429 * @notifier: notifier for @dev >> 430 * @asd_struct_size: size of the driver's async sub-device struct, including >> 431 * sizeof(struct v4l2_async_subdev). The &struct >> 432 * v4l2_async_subdev shall be the first member of >> 433 * the driver's async sub-device struct, i.e. both >> 434 * begin at the same memory address. >> 435 * @parse_endpoint: Driver's callback function called on each V4L2 fwnode >> 436 * endpoint. Optional. >> 437 * >> 438 * Parse the fwnode endpoints of the @dev device and populate the async sub- >> 439 * devices list in the notifier. The @parse_endpoint callback function is >> 440 * called for each endpoint with the corresponding async sub-device pointer to >> 441 * let the caller initialize the driver-specific part of the async sub-device >> 442 * structure. >> 443 * >> 444 * The notifier memory shall be zeroed before this function is called on the >> 445 * notifier. >> 446 * >> 447 * This function may not be called on a registered notifier and may be called on >> 448 * a notifier only once. >> 449 * >> 450 * The &struct v4l2_fwnode_endpoint passed to the callback function >> 451 * @parse_endpoint is released once the function is finished. If there is a need >> 452 * to retain that configuration, the user needs to allocate memory for it. >> 453 * >> 454 * Any notifier populated using this function must be released with a call to >> 455 * v4l2_async_notifier_cleanup() after it has been unregistered and the async >> 456 * sub-devices are no longer in use, even if the function returned an error. >> 457 * >> 458 * Return: %0 on success, including when no async sub-devices are found >> 459 * %-ENOMEM if memory allocation failed >> 460 * %-EINVAL if graph or endpoint parsing failed >> 461 * Other error codes as returned by @parse_endpoint >> 462 */ >> 463 int >> 464 v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev, >> 465 struct v4l2_async_notifier *notifier, >> 466 size_t asd_struct_size, >> 467 parse_endpoint_func parse_endpoint); >> 468 >> 469 /** >> 470 * v4l2_async_notifier_parse_fwnode_endpoints_by_port - Parse V4L2 fwnode >> 471 * endpoints of a port in a >> 472 * device node >> 473 * @dev: the device the endpoints of which are to be parsed >> 474 * @notifier: notifier for @dev >> 475 * @asd_struct_size: size of the driver's async sub-device struct, including >> 476 * sizeof(struct v4l2_async_subdev). The &struct >> 477 * v4l2_async_subdev shall be the first member of >> 478 * the driver's async sub-device struct, i.e. both >> 479 * begin at the same memory address. >> 480 * @port: port number where endpoints are to be parsed >> 481 * @parse_endpoint: Driver's callback function called on each V4L2 fwnode >> 482 * endpoint. Optional. >> 483 * >> 484 * This function is just like v4l2_async_notifier_parse_fwnode_endpoints() with >> 485 * the exception that it only parses endpoints in a given port. This is useful >> 486 * on devices that have both sinks and sources: the async sub-devices connected >> 487 * to sources have already been configured by another driver (on capture >> 488 * devices). In this case the driver must know which ports to parse. >> 489 * >> 490 * Parse the fwnode endpoints of the @dev device on a given @port and populate >> 491 * the async sub-devices list of the notifier. The @parse_endpoint callback >> 492 * function is called for each endpoint with the corresponding async sub-device >> 493 * pointer to let the caller initialize the driver-specific part of the async >> 494 * sub-device structure. >> 495 * >> 496 * The notifier memory shall be zeroed before this function is called on the >> 497 * notifier the first time. >> 498 * >> 499 * This function may not be called on a registered notifier and may be called on >> 500 * a notifier only once per port. >> 501 * >> 502 * The &struct v4l2_fwnode_endpoint passed to the callback function >> 503 * @parse_endpoint is released once the function is finished. If there is a need >> 504 * to retain that configuration, the user needs to allocate memory for it. >> 505 * >> 506 * Any notifier populated using this function must be released with a call to >> 507 * v4l2_async_notifier_cleanup() after it has been unregistered and the async >> 508 * sub-devices are no longer in use, even if the function returned an error. >> 509 * >> 510 * Return: %0 on success, including when no async sub-devices are found >> 511 * %-ENOMEM if memory allocation failed >> 512 * %-EINVAL if graph or endpoint parsing failed >> 513 * Other error codes as returned by @parse_endpoint >> 514 */ >> 515 int >> 516 v4l2_async_notifier_parse_fwnode_endpoints_by_port(struct device *dev, >> 517 struct v4l2_async_notifier *notifier, >> 518 size_t asd_struct_size, >> 519 unsigned int port, >> 520 parse_endpoint_func parse_endpoint); >> 521 >> 522 /** >> 523 * v4l2_fwnode_reference_parse_sensor_common - parse common references on >> 524 * sensors for async sub-devices >> 525 * @dev: the device node the properties of which are parsed for references >> 526 * @notifier: the async notifier where the async subdevs will be added >> 527 * >> 528 * Parse common sensor properties for remote devices related to the >> 529 * sensor and set up async sub-devices for them. >> 530 * >> 531 * Any notifier populated using this function must be released with a call to >> 532 * v4l2_async_notifier_release() after it has been unregistered and the async >> 533 * sub-devices are no longer in use, even in the case the function returned an >> 534 * error. >> 535 * >> 536 * Return: 0 on success >> 537 * -ENOMEM if memory allocation failed >> 538 * -EINVAL if property parsing failed >> 539 */ >> 540 int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, >> 541 struct v4l2_async_notifier *notifier); 391 542 392 /* Helper macros to access the connector links 543 /* Helper macros to access the connector links. */ 393 544 394 /** v4l2_connector_last_link - Helper macro to 545 /** v4l2_connector_last_link - Helper macro to get the first 395 * &struct v4l2_fw 546 * &struct v4l2_fwnode_connector link 396 * @v4l2c: &struct v4l2_fwnode_connector ownin 547 * @v4l2c: &struct v4l2_fwnode_connector owning the connector links 397 * 548 * 398 * This marco returns the first added &struct 549 * This marco returns the first added &struct v4l2_connector_link connector 399 * link or @NULL if the connector has no links 550 * link or @NULL if the connector has no links. 400 */ 551 */ 401 #define v4l2_connector_first_link(v4l2c) 552 #define v4l2_connector_first_link(v4l2c) \ 402 list_first_entry_or_null(&(v4l2c)->lin 553 list_first_entry_or_null(&(v4l2c)->links, \ 403 struct v4l2_c 554 struct v4l2_connector_link, head) 404 555 405 /** v4l2_connector_last_link - Helper macro to 556 /** v4l2_connector_last_link - Helper macro to get the last 406 * &struct v4l2_fw 557 * &struct v4l2_fwnode_connector link 407 * @v4l2c: &struct v4l2_fwnode_connector ownin 558 * @v4l2c: &struct v4l2_fwnode_connector owning the connector links 408 * 559 * 409 * This marco returns the last &struct v4l2_co 560 * This marco returns the last &struct v4l2_connector_link added connector link. 410 */ 561 */ 411 #define v4l2_connector_last_link(v4l2c) 562 #define v4l2_connector_last_link(v4l2c) \ 412 list_last_entry(&(v4l2c)->links, struc 563 list_last_entry(&(v4l2c)->links, struct v4l2_connector_link, head) 413 564 414 #endif /* _V4L2_FWNODE_H */ 565 #endif /* _V4L2_FWNODE_H */ 415 566
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.