xref: /OK3568_Linux_fs/external/rockit/mpi/sdk/include/rk_comm_avs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* GPL-2.0 WITH Linux-syscall-note OR Apache 2.0 */
2 /* Copyright (c) 2023 Fuzhou Rockchip Electronics Co., Ltd */
3 
4 #ifndef INCLUDE_RT_MPI_RK_COMMON_AVS_H_
5 #define INCLUDE_RT_MPI_RK_COMMON_AVS_H_
6 
7 #include "rk_common.h"
8 #include "rk_errno.h"
9 #include "rk_comm_video.h"
10 
11 #ifdef __cplusplus
12 #if __cplusplus
13 extern "C" {
14 #endif
15 #endif /* End of #ifdef __cplusplus */
16 
17 #define AVS_SPLIT_NUM            2
18 #define AVS_SPLIT_PIPE_NUM       6
19 #define AVS_CUBE_MAP_SURFACE_NUM 6
20 
21 typedef enum rkAVS_LUT_ACCURACY_E {
22     AVS_LUT_ACCURACY_HIGH    = 0,    /* LUT high accuracy. */
23     AVS_LUT_ACCURACY_LOW     = 1,    /* LUT low accuracy. */
24 
25     AVS_LUT_ACCURACY_BUTT
26 } AVS_LUT_ACCURACY_E;
27 
28 typedef enum rkAVS_LUT_STEP_E {
29     AVS_LUT_STEP_HIGH    = 0,    /* LUT step size 16  pixel */
30     AVS_LUT_STEP_MEDIUM  = 1,    /* LUT step size 32 pixel */
31     AVS_LUT_STEP_LOW     = 2,    /* LUT step size 64 pixel */
32 
33     AVS_LUT_STEP_BUTT
34 } AVS_LUT_STEP_E;
35 
36 typedef enum rkAVS_FUSE_WIDTH_E {
37     AVS_FUSE_WIDTH_HIGH      = 0,    /* Fusion zone size 128 pixel */
38     AVS_FUSE_WIDTH_MEDIUM    = 1,    /* Fusion zone size 256 pixel */
39     AVS_FUSE_WIDTH_LOW       = 2,    /* Fusion zone size 512 pixel */
40 
41     AVS_FUSE_WIDTH_BUTT
42 } AVS_FUSE_WIDTH_E;
43 
44 typedef enum rkAVS_PROJECTION_MODE_E {
45     AVS_PROJECTION_EQUIRECTANGULAR       = 0,  /* Equirectangular mode. */
46     AVS_PROJECTION_RECTILINEAR           = 1,  /* Rectilinear mode. */
47     AVS_PROJECTION_CYLINDRICAL           = 2,  /* Cylindrical mode. */
48     AVS_PROJECTION_CUBE_MAP              = 3,  /* Cube map mode. */
49     AVS_PROJECTION_EQUIRECTANGULAR_TRANS = 4,  /* Transvers Equirectangular  mode. */
50 
51     AVS_PROJECTION_BUTT
52 } AVS_PROJECTION_MODE_E;
53 
54 typedef enum rkAVS_GAIN_MODE_E {
55     AVS_GAIN_MODE_MANUAL = 0,
56     AVS_GAIN_MODE_AUTO   = 1,
57 
58     AVS_GAIN_MODE_BUTT
59 } AVS_GAIN_MODE_E;
60 
61 typedef enum rkAVS_MODE_E {
62     AVS_MODE_BLEND        = 0, /* according to LUT stitching, blend at the splicing point */
63     AVS_MODE_NOBLEND_VER  = 1, /* place input images vertically together, no blend at the stitching point. */
64     AVS_MODE_NOBLEND_HOR  = 2, /* place input images horizontally together, no blend at the stitching point */
65 
66     /* Only 4 image stitching is supported,
67     *   two rows are placed, two rows are placed together,
68     *   no blend at the stitching point.
69     *  The input image arrangement position of each pipe
70     *   is as follows.
71     * +-----------+-----------+
72     * |   pipe0   |   pipe1   |
73     * +-----------+-----------+
74     * |   pipe2   |   pipe3   |
75     * +-----------+-----------+
76     * */
77     AVS_MODE_NOBLEND_QR   = 3,
78 
79     AVS_MODE_BUTT
80 } AVS_MODE_E;
81 
82 typedef enum rkAVS_PARAM_SOURCE_E {
83     AVS_PARAM_SOURCE_LUT   = 0,     /* Look up table*/
84     AVS_PARAM_SOURCE_CALIB = 1,     /* Calibration file */
85 
86     AVS_PARAM_SOURCE_MODE_BUT
87 } AVS_PARAM_SOURCE_E;
88 
89 typedef struct rkAVS_GAIN_ATTR_S {
90     AVS_GAIN_MODE_E enMode;
91     RK_S32          s32Coef[AVS_PIPE_NUM];
92 } AVS_GAIN_ATTR_S;
93 
94 typedef struct rkAVS_ROTATION_S {
95     RK_S32 s32Yaw;
96     RK_S32 s32Pitch;
97     RK_S32 s32Roll;
98 } AVS_ROTATION_S;
99 
100 typedef struct rkAVS_FOV_S {
101     RK_U32 u32FOVX;
102     RK_U32 u32FOVY;
103 } AVS_FOV_S;
104 
105 typedef struct rkAVS_LUT_STEP_S {
106     AVS_LUT_STEP_E    enStepX;
107     AVS_LUT_STEP_E    enStepY;
108 } AVS_STEP_ATTR_S;
109 
110 typedef struct rkAVS_SPLIT_ATTR_S {
111     RK_U32   u32PipeNum;
112     AVS_PIPE AVSPipe[AVS_SPLIT_PIPE_NUM];
113 } AVS_SPLIT_ATTR_S;
114 
115 typedef struct rkAVS_CUBE_MAP_ATTR_S {
116     RK_BOOL   bBgColor;
117     RK_U32    u32BgColor;
118     RK_U32    u32SurfaceLength;
119     POINT_S   stStartPoint[AVS_CUBE_MAP_SURFACE_NUM];  /* RW; Start point of each surface. */
120 } AVS_CUBE_MAP_ATTR_S;
121 
122 typedef struct rkAVS_LUT_S {
123     AVS_LUT_ACCURACY_E enAccuracy;
124     AVS_FUSE_WIDTH_E   enFuseWidth;
125     AVS_STEP_ATTR_S    stLutStep;
126     RK_VOID           *pVirAddr[AVS_PIPE_NUM];
127 } AVS_LUT_S;
128 
129 typedef struct rkAVS_CALIB_S {
130     const RK_CHAR *pCalibFilePath;
131     const RK_CHAR *pMeshAlphaPath;
132 } AVS_CALIB_S;
133 
134 typedef struct rkAVS_FINAL_LUT_S {
135     MB_BLK pMeshBlk[AVS_PIPE_NUM];
136     MB_BLK pAlphaBlk[AVS_PIPE_NUM];
137     MB_BLK pLdchBlk[AVS_PIPE_NUM];
138     MB_BLK pParamBlk[AVS_PIPE_NUM];
139 } AVS_FINAL_LUT_S;
140 
141 typedef struct rkAVS_INPUT_ATTR_S {
142     AVS_PARAM_SOURCE_E  enParamSource;         /* RW; Input param source. */
143     union {
144         AVS_LUT_S       stLUT;                 /* Look up table. */
145         AVS_CALIB_S     stCalib;               /* Calibration file. */
146     };
147     SIZE_S              stSize;                /* Source resolution */
148 } AVS_INPUT_ATTR_S;
149 
150 typedef struct rkAVS_OUTPUT_ATTR_S {
151     AVS_PROJECTION_MODE_E    enPrjMode;                  /* RW; Projection mode. */
152     POINT_S                  stCenter;                   /* Center point. */
153     AVS_FOV_S                stFOV;                      /* Output FOV. */
154     AVS_ROTATION_S           stORIRotation;              /* Output original rotation. */
155     AVS_ROTATION_S           stRotation;                 /* Output rotation. */
156     AVS_SPLIT_ATTR_S         stSplitAttr[AVS_SPLIT_NUM]; /* Split attribute for 7 or 8 inputs stitching. */
157     AVS_CUBE_MAP_ATTR_S      stCubeMapAttr;              /* Cube map attribute. */
158     SIZE_S                   stSize;                     /* Mesh resolution */
159     RK_FLOAT                 fDistance;                  /* Optimum stitch distance. */
160 } AVS_OUTPUT_ATTR_S;
161 
162 typedef struct rkAVS_GRP_ATTR_S {
163     AVS_MODE_E           enMode;                        /* Group work mode */
164     RK_U32               u32PipeNum;                    /* RW; Pipe number. */
165     RK_BOOL              bSyncPipe;                     /* RW; Whether sync pipe image. */
166     AVS_INPUT_ATTR_S     stInAttr;                      /* Input attribute */
167     AVS_GAIN_ATTR_S      stGainAttr;                    /* Gain attribute. */
168     RK_U64               u64BBoxPhyAddr[AVS_PIPE_NUM];  /* Physical address of bounding box data. */
169     AVS_OUTPUT_ATTR_S    stOutAttr;                     /* Output attribute. */
170     FRAME_RATE_CTRL_S    stFrameRate;                   /* Frame rate control info. */
171 } AVS_GRP_ATTR_S;
172 
173 typedef struct rkAVS_CHN_ATTR_S {
174     RK_U32              u32Width;           /* RW; Width of target image. */
175     RK_U32              u32Height;          /* RW; Height of target image. */
176     COMPRESS_MODE_E     enCompressMode;     /* RW; Compression mode of the output. */
177     DYNAMIC_RANGE_E     enDynamicRange;     /* RW; Dynamic range. */
178     RK_U32              u32Depth;           /* RW; Chn user list depth. */
179     FRAME_RATE_CTRL_S   stFrameRate;        /* Frame rate control info. */
180     RK_U32              u32FrameBufCnt;     /* RW; frame buffer cnt only used by MB_SOURCE_PRIVATE */
181 } AVS_CHN_ATTR_S;
182 
183 typedef struct rkAVS_MOD_PARAM_S {
184     RK_U32 u32WorkingSetSize;               /* RW; AVS work */
185     MB_SOURCE_E enMBSource;                 /* RW; AVS MB pool source type */
186 } AVS_MOD_PARAM_S;
187 
188 #define RK_AVS_OK                   RK_SUCCESS
189 #define RK_ERR_AVS_NULL_PTR         RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_NULL_PTR)
190 #define RK_ERR_AVS_NOTREADY         RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_NOTREADY)
191 #define RK_ERR_AVS_INVALID_DEVID    RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_DEVID)
192 #define RK_ERR_AVS_INVALID_CHNID    RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_CHNID)
193 #define RK_ERR_AVS_INVALID_PIPEID   RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_PIPEID)
194 #define RK_ERR_AVS_EXIST            RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_EXIST)
195 #define RK_ERR_AVS_UNEXIST          RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_UNEXIST)
196 #define RK_ERR_AVS_NOT_SUPPORT      RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_SUPPORT)
197 #define RK_ERR_AVS_NOT_PERM         RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_PERM)
198 #define RK_ERR_AVS_NOMEM            RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_NOMEM)
199 #define RK_ERR_AVS_NOBUF            RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_NOBUF)
200 #define RK_ERR_AVS_ILLEGAL_PARAM    RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_ILLEGAL_PARAM)
201 #define RK_ERR_AVS_BUF_EMPTY        RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_EMPTY)
202 #define RK_ERR_AVS_BUF_FULL         RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_FULL)
203 #define RK_ERR_AVS_BUSY             RK_DEF_ERR(RK_ID_AVS, RK_ERR_LEVEL_ERROR, RK_ERR_BUSY)
204 
205 #ifdef __cplusplus
206 #if __cplusplus
207 }
208 #endif
209 #endif /* End of #ifdef __cplusplus */
210 
211 #endif /* INCLUDE_RT_MPI_RK_COMMON_AVS_H_ */
212