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_drvMgr.h
35 *
36 * \brief FVID2 driver manager header file.
37 *
38 * This file exposes internal functions of driver management functionality.
39 * This is not used by application and is used by video drivers to register
40 * itself to the FVID2.
41 *
42 */
44 #ifndef FVID2_DRVMGR_H_
45 #define FVID2_DRVMGR_H_
47 /* ========================================================================== */
48 /* Include Files */
49 /* ========================================================================== */
51 #include <ti/drv/fvid2/include/fvid2_api.h>
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
57 /* ========================================================================== */
58 /* Macros & Typedefs */
59 /* ========================================================================== */
61 /** \brief Number of driver object to allocate in FVID2 library. */
62 #define FVID2_CFG_FDM_NUM_DRV_OBJS (40U)
64 /** \brief Number of channel object to allocate in FVID2 library. */
65 #define FVID2_CFG_FDM_NUM_CH_OBJS (80U)
67 /** \brief FVID2 driver handle returned by individual drivers. */
68 typedef void *Fdrv_Handle;
70 /** \brief Typedef for callback function parameters. */
71 typedef struct Fvid2_DrvCbParams_t Fvid2_DrvCbParams;
73 /**
74 * \brief Typedef for FVID2 driver callback function prototype. This will be
75 * called by the driver and then the FVID2 driver manager will route the
76 * callback to the application.
77 *
78 * fdmData: FVID2 driver manager internal data passed to driver during create
79 * call.
80 */
81 typedef int32_t (*Fdm_CbFxn)(void *fdmData);
83 /**
84 * \brief Typedef for FVID2 driver error callback function prototype.
85 * This will be called by the driver and then the FVID2 driver manager
86 * will route the error callback to the application.
87 *
88 * fdmData: FVID2 driver manager internal data passed to driver during create
89 * call.
90 *
91 * errList: Error data passed to the application.
92 *
93 */
94 typedef int32_t (*Fdm_ErrCbFxn)(void *fdmData, void *errList);
96 /** \brief Typedef for FVID2 create function pointer. */
97 typedef Fdrv_Handle (*Fvid2_DrvCreate)(uint32_t drvId,
98 uint32_t instanceId,
99 void *createArgs,
100 void *createStatusArgs,
101 const Fvid2_DrvCbParams *fdmCbParams);
103 /** \brief Typedef for FVID2 delete function pointer. */
104 typedef int32_t (*Fvid2_DrvDelete)(Fdrv_Handle handle, void *deleteArgs);
106 /** \brief Typedef for FVID2 control function pointer. */
107 typedef int32_t (*Fvid2_DrvControl)(Fdrv_Handle handle,
108 uint32_t cmd,
109 void *cmdArgs,
110 void *cmdStatusArgs);
112 /** \brief Typedef for FVID2 queue function pointer. */
113 typedef int32_t (*Fvid2_DrvQueue)(Fdrv_Handle handle,
114 Fvid2_FrameList *frameList,
115 uint32_t streamId);
117 /** \brief Typedef for FVID2 dequeue function pointer. */
118 typedef int32_t (*Fvid2_DrvDequeue)(Fdrv_Handle handle,
119 Fvid2_FrameList *frameList,
120 uint32_t streamId,
121 uint32_t timeout);
123 /** \brief Typedef for FVID2 process frames function pointer. */
124 typedef int32_t (*Fvid2_DrvProcessRequest)(Fdrv_Handle handle,
125 Fvid2_FrameList *inProcessList,
126 Fvid2_FrameList *outProcessList,
127 uint32_t timeout);
129 /** \brief Typedef for FVID2 get processed frames function pointer. */
130 typedef int32_t (*Fvid2_DrvGetProcessedRequest)(Fdrv_Handle handle,
131 Fvid2_FrameList *inProcessList,
132 Fvid2_FrameList *outProcessList,
133 uint32_t timeout);
136 /* ========================================================================== */
137 /* Structure Declarations */
138 /* ========================================================================== */
140 /**
141 * struct Fvid2_DrvCbParams_t
142 * \brief Structure for setting callback function parameters.
143 */
144 struct Fvid2_DrvCbParams_t
145 {
146 Fdm_CbFxn fdmCbFxn;
147 /**< FDM callback function used by the driver to initimate any
148 * operation has completed or not. */
149 Fdm_ErrCbFxn fdmErrCbFxn;
150 /**< FDM error callback function used by the driver to initimate
151 * any error occuring at the time of streaming. */
152 Fvid2_Handle handle;
153 /**< FDM layer FVID2 handle. This can be used by the actual driver to call
154 * application callback with proper FVID2 handle instead of routining
155 * the call through FDM layer. */
156 void *errList;
157 /**< Pointer to a valid framelist or processlist where the driver
158 * copies the aborted/error packet. */
159 void *fdmData;
160 /**< FDM specific data which is returned in the callback function
161 * as it is. */
162 };
164 /**
165 * struct Fvid2_DrvOps
166 * \brief Structure to store driver function pointers.
167 */
168 typedef struct
169 {
170 uint32_t drvId;
171 /**< Unique driver Id. */
172 Fvid2_DrvCreate createFxn;
173 /**< FVID2 create function pointer. */
174 Fvid2_DrvDelete deleteFxn;
175 /**< FVID2 delete function pointer. */
176 Fvid2_DrvControl controlFxn;
177 /**< FVID2 control function pointer. */
178 Fvid2_DrvQueue queueFxn;
179 /**< FVID2 queue function pointer. */
180 Fvid2_DrvDequeue dequeueFxn;
181 /**< FVID2 dequeue function pointer. */
182 Fvid2_DrvProcessRequest processRequestFxn;
183 /**< FVID2 process request function pointer. */
184 Fvid2_DrvGetProcessedRequest getProcessedRequestFxn;
185 /**< FVID2 get processed request function pointer. */
186 } Fvid2_DrvOps;
188 /* ========================================================================== */
189 /* Function Declarations */
190 /* ========================================================================== */
192 /**
193 * Fvid2_registerDriver
194 * \brief FVID2 register driver function.
195 *
196 * This function registers a driver with the FVID2 driver manager.
197 *
198 * \param drvOps Driver function table pointer containing driver
199 * function pointers and driver name. The driver name
200 * should be unique - two or more drivers can't have the
201 * same driver name.
202 *
203 * \return Returns 0 on success else returns error value.
204 */
205 int32_t Fvid2_registerDriver(const Fvid2_DrvOps *drvOps);
207 /**
208 * Fvid2_unRegisterDriver
209 * \brief FVID2 unregister driver function.
210 *
211 * This function unregisters a driver from the FVID2 driver manager.
212 *
213 * \param drvOps Driver function table pointer containing driver
214 * function pointers and driver name.
215 *
216 * \return Returns 0 on success else returns error value.
217 */
218 int32_t Fvid2_unRegisterDriver(const Fvid2_DrvOps *drvOps);
220 /**
221 * Fvid2_checkFrameList
222 * \brief Checks the FVID2 frame list for error and returns appropriate error.
223 *
224 * This is used by the drivers and not by the application.
225 *
226 * \param frameList Pointer to frame list to check for errors.
227 * \param maxFrames Max frames to be checked against numFrames member
228 * in frame list.
229 *
230 * \return Returns 0 on success else returns error value.
231 */
232 int32_t Fvid2_checkFrameList(const Fvid2_FrameList *frameList,
233 uint32_t maxFrames);
235 /**
236 * Fvid2_checkDqFrameList
237 * \brief Checks the FVID2 frame list of dequeue call for error and returns
238 * appropriate error. For dequeue operation, the frame pointers in the frames
239 * should not be checked as this will be filled by the driver.
240 *
241 * This is used by the drivers and not by the application.
242 *
243 * \param frameList Pointer to frame list to check for errors.
244 * \param maxFrames Max frames to be checked against numFrames member
245 * in frame list.
246 *
247 * \return Returns 0 on success else returns error value.
248 */
249 int32_t Fvid2_checkDqFrameList(const Fvid2_FrameList *frameList,
250 uint32_t maxFrames);
252 /**
253 * Fvid2_copyFrameList
254 * \brief Copies the source frame list to the destination frame list.
255 * This also resets the frame pointers from the source frame list.
256 *
257 * This is used by the drivers and not by the application.
258 *
259 * \param dest Pointer to destination frame list.
260 * \param src Pointer to source frame list.
261 *
262 * \return Returns 0 on success else returns error value.
263 */
264 void Fvid2_copyFrameList(Fvid2_FrameList *dest, Fvid2_FrameList *src);
266 /**
267 * Fvid2_duplicateFrameList
268 * \brief Duplicate the source frame list to the destination frame list.
269 * This does not reset the frame pointers from the source frame list.
270 *
271 * This is used by the drivers and not by the application.
272 *
273 * \param dest Pointer to destination frame list.
274 * \param src Pointer to source frame list.
275 *
276 * \return Returns 0 on success else returns error value.
277 */
278 void Fvid2_duplicateFrameList(Fvid2_FrameList *dest,
279 const Fvid2_FrameList *src);
281 /**
282 * \brief Fvid2_DrvOps structure init function.
283 *
284 * \param drvOps [IN] Pointer to #Fvid2_DrvOps structure.
285 *
286 */
287 static inline void Fvid2DrvOps_init(Fvid2_DrvOps *drvOps);
289 /* ========================================================================== */
290 /* Static Function Definitions */
291 /* ========================================================================== */
293 static inline void Fvid2DrvOps_init(Fvid2_DrvOps *drvOps)
294 {
295 if (NULL != drvOps)
296 {
297 drvOps->drvId = 0U;
298 drvOps->createFxn = NULL;
299 drvOps->deleteFxn = NULL;
300 drvOps->controlFxn = NULL;
301 drvOps->queueFxn = NULL;
302 drvOps->dequeueFxn = NULL;
303 drvOps->processRequestFxn = NULL;
304 drvOps->getProcessedRequestFxn = NULL;
305 }
307 return;
308 }
311 #ifdef __cplusplus
312 }
313 #endif
315 #endif /* #ifndef FVID2_DRVMGR_H_ */