• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __HI_COMM_GDC_H__
16 #define __HI_COMM_GDC_H__
17 
18 #include "hi_type.h"
19 #include "hi_common.h"
20 #include "hi_errno.h"
21 #include "hi_comm_video.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif /* __cplusplus */
28 
29 /* failure caused by malloc buffer */
30 #define HI_ERR_GDC_NOBUF         HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
31 #define HI_ERR_GDC_BUF_EMPTY     HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
32 #define HI_ERR_GDC_NULL_PTR      HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
33 #define HI_ERR_GDC_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
34 #define HI_ERR_GDC_BUF_FULL      HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL)
35 #define HI_ERR_GDC_SYS_NOTREADY  HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
36 #define HI_ERR_GDC_NOT_SUPPORT   HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
37 #define HI_ERR_GDC_NOT_PERMITTED HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
38 #define HI_ERR_GDC_BUSY          HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
39 #define HI_ERR_GDC_INVALID_CHNID HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
40 #define HI_ERR_GDC_CHN_UNEXIST   HI_DEF_ERR(HI_ID_GDC, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
41 
42 #define HI_GDC_PRIVATE_DATA_NUM  4
43 #define FISHEYE_MAX_REGION_NUM   4
44 #define FISHEYE_LMFCOEF_NUM      128
45 #define GDC_PMFCOEF_NUM          9
46 
47 typedef HI_S32 GDC_HANDLE;
48 
49 typedef struct hiGDC_TASK_ATTR_S {
50     VIDEO_FRAME_INFO_S stImgIn;                      /* Input picture */
51     VIDEO_FRAME_INFO_S stImgOut;                     /* Output picture */
52     HI_U64 au64privateData[HI_GDC_PRIVATE_DATA_NUM]; /* RW; Private data of task */
53     HI_U64 reserved;                                 /* RW; Debug information,state of current picture */
54 } GDC_TASK_ATTR_S;
55 
56 /* Mount mode of device */
57 typedef enum hiFISHEYE_MOUNT_MODE_E {
58     FISHEYE_DESKTOP_MOUNT = 0, /* Desktop mount mode */
59     FISHEYE_CEILING_MOUNT = 1, /* Ceiling mount mode */
60     FISHEYE_WALL_MOUNT = 2,    /* wall mount mode */
61 
62     FISHEYE_MOUNT_MODE_BUTT
63 } FISHEYE_MOUNT_MODE_E;
64 
65 /* View mode of client */
66 typedef enum hiFISHEYE_VIEW_MODE_E {
67     FISHEYE_VIEW_360_PANORAMA = 0, /* 360 panorama mode of gdc correction */
68     FISHEYE_VIEW_180_PANORAMA = 1, /* 180 panorama mode of gdc correction */
69     FISHEYE_VIEW_NORMAL = 2,       /* normal mode of gdc correction */
70     FISHEYE_NO_TRANSFORMATION = 3, /* no gdc correction */
71 
72     FISHEYE_VIEW_MODE_BUTT
73 } FISHEYE_VIEW_MODE_E;
74 
75 /* Fisheye region correction attribute */
76 typedef struct hiFISHEYE_REGION_ATTR_S {
77     FISHEYE_VIEW_MODE_E enViewMode; /* RW; Range: [0, 3];gdc view mode */
78     HI_U32 u32InRadius; /* RW; inner radius of gdc correction region */
79     HI_U32 u32OutRadius; /* RW; out radius of gdc correction region */
80     HI_U32 u32Pan; /* RW; Range: [0, 360] */
81     HI_U32 u32Tilt; /* RW; Range: [0, 360] */
82     HI_U32 u32HorZoom; /* RW; Range: [1, 4095] */
83     HI_U32 u32VerZoom; /* RW; Range: [1, 4095] */
84     RECT_S stOutRect; /* RW; out Imge rectangle attribute */
85 } FISHEYE_REGION_ATTR_S;
86 
87 typedef struct hiFISHEYE_REGION_ATTR_EX_S {
88     FISHEYE_VIEW_MODE_E enViewMode; /* RW; Range: [0, 3];gdc view mode */
89     HI_U32 u32InRadius; /* RW; inner radius of gdc correction region */
90     HI_U32 u32OutRadius; /* RW; out radius of gdc correction region */
91     HI_U32 u32X; /* RW; Range: [0, 4608] */
92     HI_U32 u32Y; /* RW; Range: [0, 3456] */
93     HI_U32 u32HorZoom; /* RW; Range: [1, 4095] */
94     HI_U32 u32VerZoom; /* RW; Range: [1, 4095] */
95     RECT_S stOutRect; /* RW; out Imge rectangle attribute */
96 } FISHEYE_REGION_ATTR_EX_S;
97 
98 /* Fisheye all regions correction attribute */
99 typedef struct hiFISHEYE_ATTR_S {
100     HI_BOOL bEnable; /* RW; Range: [0, 1];whether enable fisheye correction or not */
101     /* RW; Range: [0, 1];whether gdc len's LMF coefficient is from user config or from default linear config */
102     HI_BOOL bLMF;
103     HI_BOOL bBgColor; /* RW; Range: [0, 1];whether use background color or not */
104     HI_U32 u32BgColor; /* RW; Range: [0,0xffffff];the background color RGB888 */
105 
106     /* RW; Range: [-511, 511];the horizontal offset between image center and physical center of len */
107     HI_S32 s32HorOffset;
108     /* RW; Range: [-511, 511]; the vertical offset between image center and physical center of len */
109     HI_S32 s32VerOffset;
110 
111     HI_U32 u32TrapezoidCoef; /* RW; Range: [0, 32];strength coefficient of trapezoid correction */
112     HI_S32 s32FanStrength; /* RW; Range: [-760, 760];strength coefficient of fan correction */
113 
114     FISHEYE_MOUNT_MODE_E enMountMode; /* RW; Range: [0, 2];gdc mount mode */
115 
116     HI_U32 u32RegionNum; /* RW; Range: [1, 4]; gdc correction region number */
117     FISHEYE_REGION_ATTR_S astFishEyeRegionAttr[FISHEYE_MAX_REGION_NUM]; /* RW; attribution of gdc correction region */
118 } FISHEYE_ATTR_S;
119 
120 typedef struct hiFISHEYE_ATTR_EX_S {
121     HI_BOOL bEnable; /* RW; Range: [0, 1];whether enable fisheye correction or not */
122     /* RW; Range: [0, 1];whether gdc len's LMF coefficient is from user config or from default linear config */
123     HI_BOOL bLMF;
124     HI_BOOL bBgColor; /* RW; Range: [0, 1];whether use background color or not */
125     HI_U32 u32BgColor; /* RW; Range: [0,0xffffff];the background color RGB888 */
126 
127     /* RW; Range: [-511, 511];the horizontal offset between image center and physical center of len */
128     HI_S32 s32HorOffset;
129     /* RW; Range: [-511, 511]; the vertical offset between image center and physical center of len */
130     HI_S32 s32VerOffset;
131 
132     HI_U32 u32TrapezoidCoef; /* RW; Range: [0, 32];strength coefficient of trapezoid correction */
133     HI_S32 s32FanStrength; /* RW; Range: [-760, 760];strength coefficient of fan correction */
134 
135     FISHEYE_MOUNT_MODE_E enMountMode; /* RW; Range: [0, 2];gdc mount mode */
136 
137     HI_U32 u32RegionNum; /* RW; Range: [1, 4]; gdc correction region number */
138     /* RW; attribution of gdc correction region */
139     FISHEYE_REGION_ATTR_EX_S astFishEyeRegionAttr[FISHEYE_MAX_REGION_NUM];
140 } FISHEYE_ATTR_EX_S;
141 
142 /* Spread correction attribute */
143 typedef struct hiSPREAD_ATTR_S {
144     /* RW; Range: [0, 1];whether enable spread or not, When spread on,ldc DistortionRatio range should be [0, 500] */
145     HI_BOOL bEnable;
146     HI_U32 u32SpreadCoef; /* RW; Range: [0, 18];strength coefficient of spread correction */
147     SIZE_S stDestSize; /* RW; dest size of spread */
148 } SPREAD_ATTR_S;
149 
150 /* Fisheye Job Config */
151 typedef struct hiFISHEYE_JOB_CONFIG_S {
152     HI_U64 u64LenMapPhyAddr; /* LMF coefficient Physic Addr */
153 } FISHEYE_JOB_CONFIG_S;
154 
155 /* Fisheye Config */
156 typedef struct hiFISHEYE_CONFIG_S {
157     HI_U16 au16LMFCoef[FISHEYE_LMFCOEF_NUM]; /* RW;  LMF coefficient of gdc len */
158 } FISHEYE_CONFIG_S;
159 
160 /* Gdc PMF Attr */
161 typedef struct hiGDC_PMF_ATTR_S {
162     HI_S64 as64PMFCoef[GDC_PMFCOEF_NUM]; /* W;  PMF coefficient of gdc */
163 } GDC_PMF_ATTR_S;
164 
165 /* Gdc FISHEYE POINT QUERY Attr */
166 typedef struct hiGDC_FISHEYE_POINT_QUERY_ATTR_S {
167     HI_U32 u32RegionIndex;
168     FISHEYE_ATTR_S *pstFishEyeAttr;
169     HI_U16 au16LMF[FISHEYE_LMFCOEF_NUM];
170 } GDC_FISHEYE_POINT_QUERY_ATTR_S;
171 
172 #ifdef __cplusplus
173 #if __cplusplus
174 }
175 #endif
176 #endif /* __cplusplus */
177 
178 #endif /* __HI_COMM_GDC_H__ */
179