5101d8506bdbfd5478c94d003a23037fb92e72a3
1 /*
2 * Copyright (c) Texas Instruments Incorporated 2018
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /**
34 * \file fvid2_graph.h
35 *
36 * \brief FVID2 Graph interface file.
37 */
39 #ifndef FVID2_GRAPH_H_
40 #define FVID2_GRAPH_H_
42 /* ========================================================================== */
43 /* Include Files */
44 /* ========================================================================== */
46 #include <ti/drv/fvid2/fvid2.h>
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 /* ========================================================================== */
53 /* Macros & Typedefs */
54 /* ========================================================================== */
56 /**
57 * \brief Graph Alignment
58 */
59 #define FVID2_GRAPH_DEF_ALIGN ((uint32_t) 16U)
61 /**
62 * \brief Invalid Node Id
63 */
64 #define FVID2_GRAPH_INVALID_NODE_ID ((uint32_t) 0x0U)
66 /**
67 * \brief Maximum number of nodes
68 */
69 #define FVID2_GRAPH_MAX_NODES ((uint32_t) 10U)
71 /**
72 * \brief Maximum number of paths
73 */
74 #define FVID2_GRAPH_MAX_NUM_PATHS ((uint32_t) 20U)
76 /**
77 * \anchor Fvid2_GraphNodeMode
78 * \name Mode of the node
79 *
80 * @{
81 */
82 /** \brief Disable mode */
83 #define FVID2_GRAPH_NODE_MODE_DISABLE ((uint32_t) 0x0U)
84 /** \brief Enable mode */
85 #define FVID2_GRAPH_NODE_MODE_ENABLE ((uint32_t) 0x1U)
86 /** \brief Check Mode */
87 #define FVID2_GRAPH_NODE_MODE_CHECK ((uint32_t) 0x2U)
88 /* @} */
90 /**
91 * \anchor Fvid2_GraphNodeType
92 * \name Node Type
93 *
94 * @{
95 */
96 /** \brief Node type is dummy */
97 #define FVID2_GRAPH_NODE_TYPE_DUMMY ((uint32_t) 0x0U)
98 /** \brief Node type is DSS Pipe */
99 #define FVID2_GRAPH_NODE_TYPE_DSS_PIPE ((uint32_t) 0x1U)
100 /** \brief Node type is DSS Overlay */
101 #define FVID2_GRAPH_NODE_TYPE_DSS_OVERLAY ((uint32_t) 0x2U)
102 /** \brief Node type is DSS Video Port */
103 #define FVID2_GRAPH_NODE_TYPE_DSS_VP ((uint32_t) 0x3U)
104 /** \brief Node type is DSS Output */
105 #define FVID2_GRAPH_NODE_TYPE_DSS_OUT ((uint32_t) 0x4U)
106 /** \brief Maximum Node types */
107 #define FVID2_GRAPH_NODE_TYPE_MAX ((uint32_t) 0x5U)
108 /* @} */
110 /**
111 * \anchor Fvid2_GraphNodeInputNum
112 * \name Number of inputs to a particular node
113 *
114 * @{
115 */
116 /** \brief No Input */
117 #define FVID2_GRAPH_NODE_IN_NONE ((uint32_t) 0x0U)
118 /** \brief Single Input */
119 #define FVID2_GRAPH_NODE_IN_SINGLE ((uint32_t) 0x1U)
120 /** \brief Multiple Inputs */
121 #define FVID2_GRAPH_NODE_IN_MULTI ((uint32_t) 0x2U)
122 /* @} */
124 /**
125 * \anchor Fvid2_GraphNodeOutputNum
126 * \name Number of outputs from a particular node
127 *
128 * @{
129 */
130 /** \brief No Output */
131 #define FVID2_GRAPH_NODE_OUT_NONE ((uint32_t) 0x0U)
132 /** \brief Single Output */
133 #define FVID2_GRAPH_NODE_OUT_SINGLE ((uint32_t) 0x1U)
134 /** \brief Multiple Outputs */
135 #define FVID2_GRAPH_NODE_OUT_MULTI ((uint32_t) 0x2U)
136 /* @} */
138 /* ========================================================================== */
139 /* Structure Declarations */
140 /* ========================================================================== */
142 /** \brief Forward declaration for Node Information. */
143 typedef struct Fvid2_GraphNodeInfo_t Fvid2_GraphNodeInfo;
145 /**
146 * \brief Structure containing Node Set Configuration.
147 */
148 typedef struct
149 {
150 uint32_t numNodes;
151 /**< Number of input/output nodes */
152 Fvid2_GraphNodeInfo *node[FVID2_GRAPH_MAX_NUM_PATHS];
153 /**< Pointer to the input/output node */
154 uint32_t isEnabled[FVID2_GRAPH_MAX_NUM_PATHS];
155 /**< Flag to indicate whether input/output is enabled or not. */
156 } Fvid2_GraphNodeSet;
158 /**
159 * \brief Structure containing Node Information.
160 */
161 struct Fvid2_GraphNodeInfo_t
162 {
163 uint32_t nodeId;
164 /**< Node Id */
165 uint32_t nodeInNum;
166 /**< Number of inputs to this particular node. Refer \ref
167 * Fvid2_GraphNodeInputNum for values */
168 uint32_t nodeOutNum;
169 /**< Number of outputs from this particular node. Refer \ref
170 * Fvid2_GraphNodeOutputNum for values */
171 uint32_t nodeType;
172 /**< Node type for the particular node. Refer \ref Fvid2_GraphNodeType
173 * for values */
174 uint32_t isDummy;
175 /**< Variable defining whether node type is dummy */
176 uint32_t inUse;
177 /**< Variable defining whether node is used in the present context */
178 Fvid2_GraphNodeSet inputNodeSet;
179 /**< Input Node Set */
180 Fvid2_GraphNodeSet outputNodeSet;
181 /**< Output Node Set */
182 };
184 /**
185 * \brief Structure containing Node List
186 */
187 typedef struct
188 {
189 uint32_t numNodes;
190 /**< Number of nodes */
191 Fvid2_GraphNodeInfo *list;
192 /**< Pointer to node list */
193 } Fvid2_GraphNodeList;
195 /**
196 * \brief Structure containing edge information. Edge is a connection
197 * between two nodes i.e. two modules. Video Hardware can be represented
198 * by a graph, where each module is node and edge is present between two
199 * nodes if they are connected.
200 */
201 typedef struct
202 {
203 uint32_t startNode;
204 /**< Starting node of the edge */
205 uint32_t endNode;
206 /**< End node of the edge */
207 } Fvid2_GraphEdgeInfo;
209 /**
210 * \brief Structure containing Edge List.
211 */
212 typedef struct
213 {
214 uint32_t numEdges;
215 /**< Number of the edge */
216 Fvid2_GraphEdgeInfo *list;
217 /**< Edge list */
218 } Fvid2_GraphEdgeList;
220 /**
221 * \brief Structure containing Graph information.
222 */
223 typedef struct
224 {
225 Fvid2_GraphNodeList *nodeList;
226 /**< Node list of the graph */
227 Fvid2_GraphEdgeList *edgeList;
228 /**< Edge list of the graph */
229 } Fvid2_GraphInfo;
231 /* ========================================================================== */
232 /* Function Declarations */
233 /* ========================================================================== */
235 Fvid2_GraphInfo *Fvid2_graphInit(const Fvid2_GraphNodeList *inNodeList,
236 const Fvid2_GraphEdgeList *inEdgeList,
237 Fvid2_GraphInfo *graphHandle);
239 int32_t Fvid2_graphDeInit(Fvid2_GraphInfo *graphHandle);
241 Fvid2_GraphNodeInfo *Fvid2_graphGetNodeInfo(
242 const Fvid2_GraphNodeList *nodeList,
243 uint32_t cnt);
245 int32_t Fvid2_graphAllocNodes(const Fvid2_GraphNodeList *nodeList,
246 const Fvid2_GraphEdgeList *edgeList,
247 uint32_t mode); /* Fvid2_GraphNodeMode */
249 int32_t Fvid2_graphGetPath(const Fvid2_GraphNodeList *inNodeList,
250 const Fvid2_GraphEdgeList *inEdgeList,
251 Fvid2_GraphNodeList *outNodeList,
252 Fvid2_GraphEdgeList *outEdgeList,
253 uint32_t maxOutNodeCnt,
254 uint32_t maxOutEdgeCnt);
256 int32_t Fvid2_graphFreePath(Fvid2_GraphNodeList *nodeList,
257 Fvid2_GraphEdgeList *edgeList);
259 int32_t Fvid2_graphStackIsLastNode(const Fvid2_GraphNodeInfo *currNode,
260 uint32_t isForward);
262 void Fvid2_graphStackInitTraverser(Fvid2_GraphNodeInfo *node);
264 Fvid2_GraphNodeInfo *Fvid2_graphGetNextNodeToTraverse(uint32_t isForward);
266 uint32_t Fvid2_graphIsNodeInputAvailable(
267 const Fvid2_GraphNodeList *nodeList,
268 uint32_t nodeId);
270 uint32_t Fvid2_graphIsNodeOutputAvailable(
271 const Fvid2_GraphNodeList *nodeList,
272 uint32_t nodeId);
274 void Fvid2_graphInitTraverser(Fvid2_GraphNodeInfo *node);
276 Fvid2_GraphNodeInfo *Fvid2_graphGetNextChildNode(
277 const Fvid2_GraphNodeInfo *currNode,
278 uint32_t isForward);
280 Fvid2_GraphNodeInfo *Fvid2_graphStackPeak(uint32_t *stNum);
282 int32_t Fvid2_graphGetEnabledIndex(const uint32_t *array, uint32_t size);
284 void Fvid2_graphAddEdge(Fvid2_GraphEdgeInfo *edge,
285 uint32_t startNode,
286 uint32_t endNode);
288 #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
289 }
290 #endif
292 #endif /* FVID2_GRAPH_H_ */