Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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