AM62Px MCU+ SDK  09.02.01
fvid2_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2023
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  */
32 
161 #ifndef FVID2_API_H_
162 #define FVID2_API_H_
163 
164 /* ========================================================================== */
165 /* Include Files */
166 /* ========================================================================== */
167 
169 #include <drivers/fvid2/v0/fvid2_trace.h>
170 #include <drivers/fvid2/v0/fvid2_utils.h>
171 
172 #ifdef __cplusplus
173 extern "C" {
174 #endif
175 
176 /* ========================================================================== */
177 /* Macros & Typedefs */
178 /* ========================================================================== */
179 
191 #define FVID2_VERSION_STRING "FVID_02_02_00_00"
192 
194 #define FVID2_VERSION_NUMBER (0x02020000U)
195 
197 typedef void *Fvid2_Handle;
198 
239 typedef int32_t (*Fvid2_CbFxn)(Fvid2_Handle handle, void *appData);
240 
273 typedef int32_t (*Fvid2_ErrCbFxn)(Fvid2_Handle handle,
274  void *appData,
275  void *errList);
276 
292 typedef int32_t (*Fvid2_SubFrameCbFxn)(Fvid2_Handle handle,
293  Fvid2_Frame *subFrame);
294 
302 typedef uint64_t (*Fvid2_TimeStampFxn)(void *args);
303 
311 typedef void (*Fvid2_PrintFxn)(const char *format, ...);
312 
319 #define FVID2_STREAM_ID_ANY (0xFFFFFFFFU)
320 
323 /*
324  * =========== Command codes for Submit call =============
325  */
327 #define FVID2_CTRL_BASE (0x00000000U)
328 
329 #define FVID2_USER_BASE (0x10000000U)
330 
346 #define FVID2_SET_FORMAT ((uint32_t) FVID2_CTRL_BASE + 3U)
347 
356 #define FVID2_GET_FORMAT ((uint32_t) FVID2_CTRL_BASE + 4U)
357 
366 #define FVID2_START ((uint32_t) FVID2_CTRL_BASE + 5U)
367 
376 #define FVID2_STOP ((uint32_t) FVID2_CTRL_BASE + 6U)
377 
390 #define FVID2_REGISTER_TIMESTAMP_FXN ((uint32_t) FVID2_CTRL_BASE + 7U)
391 
394 /*
395  * Driver ID Base.
396  */
398 #define FVID2_DSS_DRV_BASE (0x00001000U)
399 
400 #define FVID2_CAL_DRV_BASE (0x00002000U)
401 
402 #define FVID2_CSIRX_DRV_BASE (0x00003000U)
403 
404 #define FVID2_CSITX_DRV_BASE (0x00004000U)
405 
406 #define FVID2_VHWA_DRV_BASE (0x00005000U)
407 
408 /*
409  * IOCTLs Base.
410  */
412 #define FVID2_DSS_DRV_IOCTL_BASE (FVID2_USER_BASE + FVID2_DSS_DRV_BASE)
413 
414 #define FVID2_CAL_DRV_IOCTL_BASE (FVID2_USER_BASE + FVID2_CAL_DRV_BASE)
415 
416 #define FVID2_CSIRX_DRV_IOCTL_BASE (FVID2_USER_BASE + FVID2_CSIRX_DRV_BASE)
417 
418 #define FVID2_CSITX_DRV_IOCTL_BASE (FVID2_USER_BASE + FVID2_CSITX_DRV_BASE)
419 
420 #define FVID2_VHWA_DRV_IOCTL_BASE (FVID2_USER_BASE + FVID2_VHWA_DRV_BASE)
421 
422 /* ========================================================================== */
423 /* Structure Declarations */
424 /* ========================================================================== */
425 
435 typedef struct
436 {
449  void *errList;
462  void *appData;
466 
470 typedef struct
471 {
486  uint32_t reserved;
489 
493 typedef struct
494 {
499 
500 /* ========================================================================== */
501 /* Function Declarations */
502 /* ========================================================================== */
503 
517 int32_t Fvid2_init(const Fvid2_InitPrms *initPrms);
518 
529 int32_t Fvid2_deInit(void *args);
530 
539 const char *Fvid2_getVersionString(void);
540 
549 uint32_t Fvid2_getVersionNumber(void);
550 
581 Fvid2_Handle Fvid2_create(uint32_t drvId,
582  uint32_t instanceId,
583  void *createArgs,
584  void *createStatusArgs,
585  const Fvid2_CbParams *cbParams);
586 
601 int32_t Fvid2_delete(Fvid2_Handle handle, void *deleteArgs);
602 
627  uint32_t cmd,
628  void *cmdArgs,
629  void *cmdStatusArgs);
630 
652 int32_t Fvid2_queue(Fvid2_Handle handle,
653  Fvid2_FrameList *frameList,
654  uint32_t streamId);
655 
683  Fvid2_FrameList *frameList,
684  uint32_t streamId,
685  uint32_t timeout);
686 
714  Fvid2_FrameList *inFrameList,
715  Fvid2_FrameList *outFrameList,
716  uint32_t timeout);
717 
745  Fvid2_FrameList *inFrameList,
746  Fvid2_FrameList *outFrameList,
747  uint32_t timeout);
762 static inline int32_t Fvid2_start(Fvid2_Handle handle, void *cmdArgs);
763 
778 static inline int32_t Fvid2_stop(Fvid2_Handle handle, void *cmdArgs);
779 
791 static inline int32_t Fvid2_setFormat(Fvid2_Handle handle, Fvid2_Format *fmt);
792 
804 static inline int32_t Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt);
805 
806 /*
807  * Structure Init functions
808  */
815 static inline void Fvid2InitPrms_init(Fvid2_InitPrms *initPrms);
816 
823 static inline void Fvid2CbParams_init(Fvid2_CbParams *cbPrms);
824 
825 /* ========================================================================== */
826 /* Static Function Definitions */
827 /* ========================================================================== */
828 
829 static inline int32_t Fvid2_start(Fvid2_Handle handle, void *cmdArgs)
830 {
831  return Fvid2_control(handle, FVID2_START, cmdArgs, NULL);
832 }
833 
834 static inline int32_t Fvid2_stop(Fvid2_Handle handle, void *cmdArgs)
835 {
836  return Fvid2_control(handle, FVID2_STOP, cmdArgs, NULL);
837 }
838 
839 static inline int32_t Fvid2_setFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
840 {
841  return Fvid2_control(handle, FVID2_SET_FORMAT, fmt, NULL);
842 }
843 
844 static inline int32_t Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
845 {
846  return Fvid2_control(handle, FVID2_GET_FORMAT, fmt, NULL);
847 }
848 
849 static inline void Fvid2InitPrms_init(Fvid2_InitPrms *initPrms)
850 {
851  if (NULL != initPrms)
852  {
853  initPrms->printFxn = NULL;
854  }
855 
856  return;
857 }
858 
859 static inline void Fvid2CbParams_init(Fvid2_CbParams *cbPrms)
860 {
861  if (NULL != cbPrms)
862  {
863  cbPrms->cbFxn = NULL;
864  cbPrms->errCbFxn = NULL;
865  cbPrms->errList = NULL;
866  cbPrms->appData = NULL;
867  }
868 
869  return;
870 }
871 
872 #ifdef __cplusplus
873 }
874 #endif
875 
876 #endif /* #ifndef FVID2_API_H_ */
877 
Fvid2_deInit
int32_t Fvid2_deInit(void *args)
FVID2 deinit function.
Fvid2_ErrCbFxn
int32_t(* Fvid2_ErrCbFxn)(Fvid2_Handle handle, void *appData, void *errList)
FVID2 error callback function prototype.
Definition: fvid2_api.h:273
FVID2_SET_FORMAT
#define FVID2_SET_FORMAT
Control command used by Fvid2_setFormat()
Definition: fvid2_api.h:346
Fvid2InitPrms_init
static void Fvid2InitPrms_init(Fvid2_InitPrms *initPrms)
Fvid2_InitPrms structure init function.
Definition: fvid2_api.h:849
Fvid2_getProcessedRequest
int32_t Fvid2_getProcessedRequest(Fvid2_Handle handle, Fvid2_FrameList *inFrameList, Fvid2_FrameList *outFrameList, uint32_t timeout)
An application calls Fvid2_getProcessedRequest to get the processed request back from the driver and ...
fvid2_dataTypes.h
FVID2 Datatypes.
Fvid2_control
int32_t Fvid2_control(Fvid2_Handle handle, uint32_t cmd, void *cmdArgs, void *cmdStatusArgs)
Send control commands (IOCTLs) to the driver.
Fvid2_processRequest
int32_t Fvid2_processRequest(Fvid2_Handle handle, Fvid2_FrameList *inFrameList, Fvid2_FrameList *outFrameList, uint32_t timeout)
An application calls Fvid2_processRequest to submit a video buffer to the video device driver.
Fvid2_TimeStampParams
Structure used to configure time stamping of frames.
Definition: fvid2_api.h:471
Fvid2_CbParams::cbFxn
Fvid2_CbFxn cbFxn
Definition: fvid2_api.h:437
Fvid2_create
Fvid2_Handle Fvid2_create(uint32_t drvId, uint32_t instanceId, void *createArgs, void *createStatusArgs, const Fvid2_CbParams *cbParams)
Creates the driver identified by the driver ID.
NULL
#define NULL
Define NULL if not defined.
Definition: csl_types.h:100
Fvid2_CbParams::appData
void * appData
Definition: fvid2_api.h:462
Fvid2CbParams_init
static void Fvid2CbParams_init(Fvid2_CbParams *cbPrms)
Fvid2_CbParams structure init function.
Definition: fvid2_api.h:859
Fvid2_CbParams
FVID2 callback parameters that are setup during Fvid2_create().
Definition: fvid2_api.h:436
Fvid2_dequeue
int32_t Fvid2_dequeue(Fvid2_Handle handle, Fvid2_FrameList *frameList, uint32_t streamId, uint32_t timeout)
An application calls Fvid2_dequeue to request the video device driver to give ownership of a video bu...
Fvid2_TimeStampParams::reserved
uint32_t reserved
Definition: fvid2_api.h:486
Fvid2_TimeStampFxn
uint64_t(* Fvid2_TimeStampFxn)(void *args)
Function prototype, to determine the time stamp.
Definition: fvid2_api.h:302
Fvid2_Handle
void * Fvid2_Handle
FVID2 Driver handle.
Definition: fvid2_api.h:197
Fvid2_delete
int32_t Fvid2_delete(Fvid2_Handle handle, void *deleteArgs)
Deletes a previously created FVID2 driver handle.
Fvid2_setFormat
static int32_t Fvid2_setFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
An application calls Fvid2_setFormat to request the video device driver to set the format for a given...
Definition: fvid2_api.h:839
Fvid2_FrameList
FVID2 frame buffer list used to exchange multiple FVID2 frames in a single driver call.
Definition: fvid2_dataTypes.h:1276
Fvid2_Format
FVID2 video buffer format specification.
Definition: fvid2_dataTypes.h:1104
Fvid2_stop
static int32_t Fvid2_stop(Fvid2_Handle handle, void *cmdArgs)
An application calls Fvid2_stop to request the video device driver to stop the video display or captu...
Definition: fvid2_api.h:834
Fvid2_start
static int32_t Fvid2_start(Fvid2_Handle handle, void *cmdArgs)
An application calls Fvid2_start to request the video device driver to start the video display or cap...
Definition: fvid2_api.h:829
Fvid2_PrintFxn
void(* Fvid2_PrintFxn)(const char *format,...)
FVID2 info/debug print function prototype.
Definition: fvid2_api.h:311
Fvid2_CbFxn
int32_t(* Fvid2_CbFxn)(Fvid2_Handle handle, void *appData)
FVID2 driver callback function prototype.
Definition: fvid2_api.h:239
Fvid2_getVersionNumber
uint32_t Fvid2_getVersionNumber(void)
Same as Fvid2_getVersionString() except it returns the version in uint32_t form.
Fvid2_Frame
FVID2 frame buffer structure.
Definition: fvid2_dataTypes.h:1173
Fvid2_CbParams::errCbFxn
Fvid2_ErrCbFxn errCbFxn
Definition: fvid2_api.h:443
Fvid2_CbParams::errList
void * errList
Definition: fvid2_api.h:449
Fvid2_SubFrameCbFxn
int32_t(* Fvid2_SubFrameCbFxn)(Fvid2_Handle handle, Fvid2_Frame *subFrame)
FVID2 callback that is called by subframe mode Capture driver.
Definition: fvid2_api.h:292
Fvid2_queue
int32_t Fvid2_queue(Fvid2_Handle handle, Fvid2_FrameList *frameList, uint32_t streamId)
An application calls Fvid2_queue to submit a video buffer to the video device driver.
Fvid2_InitPrms::printFxn
Fvid2_PrintFxn printFxn
Definition: fvid2_api.h:495
Fvid2_TimeStampParams::timeStampFxn
Fvid2_TimeStampFxn timeStampFxn
Definition: fvid2_api.h:472
Fvid2_InitPrms
FVID2 initialization parameters.
Definition: fvid2_api.h:494
FVID2_START
#define FVID2_START
Control command used by Fvid2_start()
Definition: fvid2_api.h:366
Fvid2_getFormat
static int32_t Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
An application calls Fvid2_getFormat to request the video device driver to get the current format for...
Definition: fvid2_api.h:844
FVID2_GET_FORMAT
#define FVID2_GET_FORMAT
Control command used by Fvid2_getFormat()
Definition: fvid2_api.h:356
Fvid2_getVersionString
const char * Fvid2_getVersionString(void)
Get the version string for FVID2 interface.
FVID2_STOP
#define FVID2_STOP
Control command used by Fvid2_stop()
Definition: fvid2_api.h:376
Fvid2_init
int32_t Fvid2_init(const Fvid2_InitPrms *initPrms)
FVID2 init function.