xref: /OK3568_Linux_fs/external/rockit/mpi/sdk/include/rk_comm_gdc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* GPL-2.0 WITH Linux-syscall-note OR Apache 2.0 */
2 /* Copyright (c) 2022 Fuzhou Rockchip Electronics Co., Ltd */
3 
4 #ifndef INCLUDE_RT_MPI_RK_COMM_GDC_H_
5 #define INCLUDE_RT_MPI_RK_COMM_GDC_H_
6 
7 #ifdef __cplusplus
8 #if __cplusplus
9 extern "C" {
10 #endif
11 #endif /* __cplusplus */
12 
13 #include "rk_type.h"
14 #include "rk_common.h"
15 #include "rk_errno.h"
16 #include "rk_comm_video.h"
17 
18 /* failure caused by malloc buffer */
19 #define RK_GDC_SUCCESS             RK_SUCCESS
20 #define RK_ERR_GDC_NOBUF           RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_NOBUF)
21 #define RK_ERR_GDC_BUF_EMPTY       RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_EMPTY)
22 #define RK_ERR_GDC_NULL_PTR        RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_NULL_PTR)
23 #define RK_ERR_GDC_ILLEGAL_PARAM   RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_ILLEGAL_PARAM)
24 #define RK_ERR_GDC_BUF_FULL        RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_FULL)
25 #define RK_ERR_GDC_SYS_NOTREADY    RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_NOTREADY)
26 #define RK_ERR_GDC_NOT_SUPPORT     RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_SUPPORT)
27 #define RK_ERR_GDC_NOT_PERMITTED   RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_PERM)
28 #define RK_ERR_GDC_BUSY            RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_BUSY)
29 #define RK_ERR_GDC_INVALID_CHNID   RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_CHNID)
30 #define RK_ERR_GDC_CHN_UNEXIST     RK_DEF_ERR(RK_ID_GDC, RK_ERR_LEVEL_ERROR, RK_ERR_UNEXIST)
31 
32 #define FISHEYE_MAX_REGION_NUM     9
33 #define FISHEYE_LMFCOEF_NUM        128
34 #define GDC_PMFCOEF_NUM            9
35 
36 typedef RK_S32      GDC_HANDLE;
37 
38 typedef struct rkGDC_TASK_ATTR_S {
39     VIDEO_FRAME_INFO_S      stImgIn;             /* Input picture */
40     VIDEO_FRAME_INFO_S      stImgOut;            /* Output picture */
41     /* RW; Private data of task ; au64privateData[0]: stepx au64privateData[1]: stepy;
42            advised to set this parameter to 0.*/
43     RK_U64                  au64privateData[4];
44     /* RW; Specify a task index, default 0 is not specify;[0,GDC_MAX_TASK_NUM);
45            advised to set this parameter to 0*/
46     RK_U64                  u64TaskId;
47 } GDC_TASK_ATTR_S;
48 
49 /* Mount mode of device*/
50 typedef enum rkFISHEYE_MOUNT_MODE_E {
51     FISHEYE_DESKTOP_MOUNT    = 0,        /* Desktop mount mode */
52     FISHEYE_CEILING_MOUNT    = 1,        /* Ceiling mount mode */
53     FISHEYE_WALL_MOUNT       = 2,        /* wall mount mode */
54 
55     FISHEYE_MOUNT_MODE_BUTT
56 } FISHEYE_MOUNT_MODE_E;
57 
58 /* View mode of client*/
59 typedef enum rkFISHEYE_VIEW_MODE_E {
60     FISHEYE_VIEW_360_PANORAMA   = 0,     /* 360 panorama mode of gdc correction */
61     FISHEYE_VIEW_180_PANORAMA   = 1,     /* 180 panorama mode of gdc correction */
62     FISHEYE_VIEW_NORMAL         = 2,     /* normal mode of gdc correction */
63     FISHEYE_NO_TRANSFORMATION   = 3,     /* no gdc correction */
64 
65     FISHEYE_VIEW_MODE_BUTT
66 } FISHEYE_VIEW_MODE_E;
67 
68 /*Fisheye region correction attribute */
69 typedef struct rkFISHEYE_REGION_ATTR_S {
70     FISHEYE_VIEW_MODE_E     enViewMode;     /* RW; Range: [0, 3];gdc view mode */
71     RK_U32                  u32InRadius;    /* RW; inner radius of gdc correction region*/
72     RK_U32                  u32OutRadius;   /* RW; out radius of gdc correction region*/
73     RK_U32                  u32Pan;         /* RW; Range: [0, 360] */
74     RK_U32                  u32Tilt;        /* RW; Range: [0, 360] */
75     RK_U32                  u32HorZoom;     /* RW; Range: [1, 4095] */
76     RK_U32                  u32VerZoom;     /* RW; Range: [1, 4095] */
77     RECT_S                  stOutRect;      /* RW; out Imge rectangle attribute */
78 } FISHEYE_REGION_ATTR_S;
79 
80 typedef struct rkFISHEYE_REGION_ATTR_EX_S {
81     FISHEYE_VIEW_MODE_E     enViewMode;     /* RW; Range: [0, 3];gdc view mode */
82     RK_U32                  u32InRadius;    /* RW; inner radius of gdc correction region*/
83     RK_U32                  u32OutRadius;   /* RW; out radius of gdc correction region*/
84     RK_U32                  u32X;           /* RW; Range: [0, 4608] */
85     RK_U32                  u32Y;           /* RW; Range: [0, 3456] */
86     RK_U32                  u32HorZoom;     /* RW; Range: [1, 4095] */
87     RK_U32                  u32VerZoom;     /* RW; Range: [1, 4095] */
88     RECT_S                  stOutRect;      /* RW; out Imge rectangle attribute */
89 } FISHEYE_REGION_ATTR_EX_S;
90 
91 /*Fisheye all regions correction attribute */
92 typedef struct rkFISHEYE_ATTR_S {
93     RK_BOOL                 bEnable;    /* RW; Range: [0, 1];whether enable fisheye correction or not */
94     /* RW; Range: [0, 1];whether gdc len's LMF coefficient is from user config or from default linear config */
95     RK_BOOL                 bLMF;
96     RK_BOOL                 bBgColor;   /* RW; Range: [0, 1];whether use background color or not */
97     RK_U32                  u32BgColor; /* RW; Range: [0,0xffffff];the background color RGB888*/
98     /* RW; Range: [-511, 511];the horizontal offset between image center and physical center of len*/
99     RK_S32                  s32HorOffset;
100     /* RW; Range: [-511, 511]; the vertical offset between image center and physical center of len*/
101     RK_S32                  s32VerOffset;
102     RK_U32                  u32TrapezoidCoef;  /* RW; Range: [0, 32];strength coefficient of trapezoid correction */
103     RK_S32                  s32FanStrength;    /* RW; Range: [-760, 760];strength coefficient of fan correction */
104     FISHEYE_MOUNT_MODE_E    enMountMode;       /* RW; Range: [0, 2];gdc mount mode */
105     RK_U32                  u32RegionNum;      /* RW; Range: [1, 9]; gdc correction region number */
106     /* RW; attribution of gdc correction region */
107     FISHEYE_REGION_ATTR_S   astFishEyeRegionAttr[FISHEYE_MAX_REGION_NUM];
108 } FISHEYE_ATTR_S;
109 
110 typedef struct rkFISHEYE_ATTR_EX_S {
111     RK_BOOL                    bEnable;      /* RW; Range: [0, 1];whether enable fisheye correction or not */
112     /* RW; Range: [0, 1];whether gdc len's LMF coefficient is from user config or from default linear config */
113     RK_BOOL                    bLMF;
114     RK_BOOL                    bBgColor;     /* RW; Range: [0, 1];whether use background color or not */
115     RK_U32                     u32BgColor;   /* RW; Range: [0,0xffffff];the background color RGB888*/
116     /* RW; Range: [-511, 511];the horizontal offset between image center and physical center of len*/
117     RK_S32                     s32HorOffset;
118     /* RW; Range: [-511, 511]; the vertical offset between image center and physical center of len*/
119     RK_S32                     s32VerOffset;
120     RK_U32                     u32TrapezoidCoef;  /* RW; Range: [0, 32];strength coefficient of trapezoid correction */
121     RK_S32                     s32FanStrength;    /* RW; Range: [-760, 760];strength coefficient of fan correction */
122     FISHEYE_MOUNT_MODE_E       enMountMode;       /* RW; Range: [0, 2];gdc mount mode */
123     RK_U32                     u32RegionNum;      /* RW; Range: [1, 4]; gdc correction region number */
124     /* RW; attribution of gdc correction region */
125     FISHEYE_REGION_ATTR_EX_S   astFishEyeRegionAttr[FISHEYE_MAX_REGION_NUM];
126 } FISHEYE_ATTR_EX_S;
127 
128 /*Spread correction attribute */
129 typedef struct rkSPREAD_ATTR_S {
130     /* RW; Range: [0, 1];whether enable spread or not, When spread on, ldc DistortionRatio range should be [0, 500] */
131     RK_BOOL                 bEnable;
132     RK_U32                  u32SpreadCoef;      /* RW; Range: [0, 18];strength coefficient of spread correction */
133     SIZE_S                  stDestSize;         /* RW; dest size of spread*/
134 } SPREAD_ATTR_S;
135 
136 /*Fisheye Job Config */
137 typedef struct rkFISHEYE_JOB_CONFIG_S {
138     RK_U64                  u64LenMapPhyAddr;   /* LMF coefficient Physic Addr*/
139 } FISHEYE_JOB_CONFIG_S;
140 
141 /*Fisheye Config */
142 typedef struct rkFISHEYE_CONFIG_S {
143     RK_U16                  au16LMFCoef[FISHEYE_LMFCOEF_NUM];     /*RW;  LMF coefficient of gdc len */
144 } FISHEYE_CONFIG_S;
145 
146 /*Gdc PMF Attr */
147 typedef struct rkGDC_PMF_ATTR_S {
148     RK_S64                  as64PMFCoef[GDC_PMFCOEF_NUM];         /*W;  PMF coefficient of gdc */
149 } GDC_PMF_ATTR_S;
150 
151 typedef struct rkGDC_FISHEYE_POINT_QUERY_ATTR_S {
152     RK_U32          u32RegionIndex;
153     FISHEYE_ATTR_S *pstFishEyeAttr;
154     RK_U16          au16LMF[FISHEYE_LMFCOEF_NUM];
155 } GDC_FISHEYE_POINT_QUERY_ATTR_S;
156 
157 #ifdef __cplusplus
158 #if __cplusplus
159 }
160 #endif
161 #endif /* __cplusplus */
162 
163 #endif /* __RK_COMM_GDC_H__ */
164