deba224c1b7f86b1fd8fd0337bb97e9a797a46b9
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 #define FVID2_GRAPH_DEF_ALIGN ((uint32_t) 16U)
57 #define FVID2_GRAPH_INVALID_NODE_ID ((uint32_t) 0U)
58 #define FVID2_GRAPH_MAX_NODES ((uint32_t) 80U)
59 #define FVID2_GRAPH_MAX_NUM_PATHS ((uint32_t) 20U)
61 typedef enum
62 {
63 FVID2_GRAPH_NM_DISABLE,
64 FVID2_GRAPH_NM_ENABLE,
65 FVID2_GRAPH_NM_CHECK
66 } Fvid2_GraphNodeMode;
68 typedef enum
69 {
70 FVID2_GRAPH_NT_DUMMY,
71 FVID2_GRAPH_NT_DSS, /* DSS */
72 FVID2_GRAPH_NT_MAX_NODETYPE
73 } Fvid2_GraphNodeTypes;
75 typedef enum
76 {
77 FVID2_GRAPH_NT_IN_SINGLE,
78 FVID2_GRAPH_NT_IN_MULTI,
79 FVID2_GRAPH_NT_IN_EMPTY
80 } Fvid2_GraphNodeInputType;
82 typedef enum
83 {
84 FVID2_GRAPH_NT_OUT_SINGLE,
85 FVID2_GRAPH_NT_OUT_MULTI,
86 FVID2_GRAPH_NT_OUT_EMPTY
87 } Fvid2_GraphNodeOutputType;
89 /* ========================================================================== */
90 /* Structure Declarations */
91 /* ========================================================================== */
93 typedef struct Fvid2_GraphNodeInfo_t Fvid2_GraphNodeInfo;
95 typedef struct Fvid2_GraphNodeSet_t
96 {
97 uint32_t numNodes;
98 /**< Number of input/output nodes */
99 Fvid2_GraphNodeInfo *node[FVID2_GRAPH_MAX_NUM_PATHS];
100 /**< Pointer to the input/output node */
101 uint32_t isEnabled[FVID2_GRAPH_MAX_NUM_PATHS];
102 /**< Flag to indicate whether input/output is enabled or not. */
103 } Fvid2_GraphNodeSet;
105 struct Fvid2_GraphNodeInfo_t
106 {
107 /*Used to select config structure from the CreateParams */
108 uint32_t nodeNum;
110 /* Tree-connections */
111 Fvid2_GraphNodeInputType inType;
112 Fvid2_GraphNodeOutputType outType;
114 /* SI/SO/MI/MO */
115 uint32_t nodeType;
117 void *corePtr;
118 uint32_t isDummy;
119 uint32_t inUse;
120 Fvid2_GraphNodeSet input;
121 Fvid2_GraphNodeSet output;
122 };
124 typedef struct
125 {
126 uint32_t numNodes;
127 Fvid2_GraphNodeInfo *list;
128 } Fvid2_GraphNodeInfoList;
130 /**
131 * \brief Structure containing edge information. Edge is a connection
132 * between two nodes i.e. two modules. Video Hardware can be represented
133 * by a graph, where each module is node and edge is present between two
134 * nodes if they are connected.
135 */
136 typedef struct
137 {
138 uint32_t startNode;
139 /**< Starting node of the edge */
140 uint32_t endNode;
141 /**< End node of the edge */
142 } Fvid2_GraphEdgeInfo;
144 typedef struct
145 {
146 uint32_t numEdges;
147 /**< Number of the edge */
148 Fvid2_GraphEdgeInfo *list;
149 /**< Edge list */
150 } Fvid2_GraphEdgeInfoList;
152 typedef struct
153 {
154 Fvid2_GraphNodeInfoList *nodeList;
155 Fvid2_GraphEdgeInfoList *edgeList;
156 } Fvid2_GraphInfo;
158 /* ========================================================================== */
159 /* Function Declarations */
160 /* ========================================================================== */
162 Fvid2_GraphInfo *Fvid2_graphInit(const Fvid2_GraphNodeInfoList *inNodeList,
163 const Fvid2_GraphEdgeInfoList *inEdgeList,
164 Fvid2_GraphInfo *graphHandle);
166 int32_t Fvid2_graphDeInit(Fvid2_GraphInfo *graphHandle);
168 Fvid2_GraphNodeInfo *Fvid2_graphGetNodeInfo(
169 const Fvid2_GraphNodeInfoList *nodeList,
170 uint32_t cnt);
172 int32_t Fvid2_graphAllocNodes(const Fvid2_GraphNodeInfoList *nodeList,
173 const Fvid2_GraphEdgeInfoList *edgeList,
174 Fvid2_GraphNodeMode mode);
176 int32_t Fvid2_graphGetPath(const Fvid2_GraphNodeInfoList *inNodeList,
177 const Fvid2_GraphEdgeInfoList *inEdgeList,
178 Fvid2_GraphNodeInfoList *outNodeList,
179 Fvid2_GraphEdgeInfoList *outEdgeList,
180 uint32_t maxOutNodeCnt,
181 uint32_t maxOutEdgeCnt);
183 int32_t Fvid2_graphFreePath(Fvid2_GraphNodeInfoList *nodeList,
184 Fvid2_GraphEdgeInfoList *edgeList);
186 int32_t Fvid2_graphStackIsLastNode(const Fvid2_GraphNodeInfo *currNode,
187 uint32_t isForward);
189 void Fvid2_graphStackInitTraverser(Fvid2_GraphNodeInfo *node);
191 Fvid2_GraphNodeInfo *Fvid2_graphGetNextNodeToTraverse(uint32_t isForward);
193 uint32_t Fvid2_graphIsNodeInputAvailable(
194 const Fvid2_GraphNodeInfoList *nodeList,
195 uint32_t nodeNum);
197 uint32_t Fvid2_graphIsNodeOutputAvailable(
198 const Fvid2_GraphNodeInfoList *nodeList,
199 uint32_t nodeNum);
201 void Fvid2_graphInitTraverser(Fvid2_GraphNodeInfo *node);
203 Fvid2_GraphNodeInfo *Fvid2_graphGetNextChildNode(
204 const Fvid2_GraphNodeInfo *currNode,
205 uint32_t isForward);
207 Fvid2_GraphNodeInfo *Fvid2_graphStackPeak(uint32_t *stNum);
209 int32_t Fvid2_graphGetEnabledIndex(const uint32_t *array, uint32_t size);
211 void Fvid2_graphAddEdge(Fvid2_GraphEdgeInfo *edge,
212 uint32_t startNode,
213 uint32_t endNode);
215 #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
216 }
217 #endif
219 #endif /* FVID2_GRAPH_H_ */