1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __MKP_SYS_H__ 20 #define __MKP_SYS_H__ 21 22 #include "mkp_ioctl.h" 23 #include "hi_common_adapt.h" 24 #include "hi_comm_sys_adapt.h" 25 #include "hi_comm_video_adapt.h" 26 #include "sys_ext.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif /* end of #ifdef __cplusplus */ 31 32 #define sys_check_null_ptr_return(ptr) \ 33 do { \ 34 if ((ptr) == HI_NULL) { \ 35 sys_err_trace("Null point \n"); \ 36 return HI_ERR_SYS_NULL_PTR; \ 37 } \ 38 } while (0) 39 40 typedef struct { 41 hi_mpp_chn src_chn; 42 hi_mpp_chn dest_chn; 43 } sys_bind_args; 44 45 typedef struct { 46 hi_mpp_chn src_chn; 47 hi_mpp_bind_dest dest_chns; 48 } sys_bind_src_args; 49 50 typedef struct { 51 hi_mpp_chn mpp_chn; 52 hi_char mmz_name[MAX_MMZ_NAME_LEN]; 53 } sys_mem_args; 54 55 typedef struct { 56 hi_s32 hr_timer; 57 hi_s32 rr_mode; 58 } kernel_config; 59 60 typedef struct { 61 hi_u32 size; 62 hi_u64 phy_addr; 63 hi_void ATTRIBUTE *vir_addr; 64 } sys_mem_cache_info; 65 66 typedef struct { 67 hi_vpss_venc_wrap_param wrap_param; 68 hi_u32 buf_line; 69 } vpss_venc_wrap_args; 70 71 typedef enum { 72 IOC_NR_SYS_INIT = 0, 73 IOC_NR_SYS_EXIT, 74 IOC_NR_SYS_SETCONFIG, 75 IOC_NR_SYS_GETCONFIG, 76 IOC_NR_SYS_INITPTSBASE, 77 IOC_NR_SYS_SYNCPTS, 78 IOC_NR_SYS_GETCURPTS, 79 80 IOC_NR_SYS_BIND, 81 IOC_NR_SYS_UNBIND, 82 IOC_NR_SYS_GETBINDBYDEST, 83 IOC_NR_SYS_GETBINDBYSRC, 84 85 IOC_NR_SYS_MEM_SET, 86 IOC_NR_SYS_MEM_GET, 87 88 IOC_NR_SYS_GET_CUST_CODE, 89 90 IOC_NR_SYS_GET_KERNELCONFIG, 91 92 IOC_NR_SYS_GET_CHIPID, 93 94 IOC_NR_SYS_GET_UNIQUE_ID, 95 96 IOC_NR_SYS_SET_VIVPSS_MODE, 97 IOC_NR_SYS_GET_VIVPSS_MODE, 98 99 IOC_NR_SYS_SET_TUNING_CONNECT, 100 IOC_NR_SYS_GET_TUNING_CONNECT, 101 102 IOC_NR_SYS_MFLUSH_CACHE, 103 104 IOC_NR_SYS_SET_SCALE_COEFF, 105 IOC_NR_SYS_GET_SCALE_COEFF, 106 107 IOC_NR_SYS_SET_TIME_ZONE, 108 IOC_NR_SYS_GET_TIME_ZONE, 109 110 IOC_NR_SYS_SET_GPS_INFO, 111 IOC_NR_SYS_GET_GPS_INFO, 112 113 IOC_NR_SYS_GET_VPSSVENC_WRAP_BUF_LINE, 114 115 IOC_NR_SYS_SET_RAW_FRAME_COMPRESS_RATE, 116 IOC_NR_SYS_GET_RAW_FRAME_COMPRESS_RATE, 117 118 IOC_NR_SYSCONFIG_SET_VI_VPSS_WORK_MODE, 119 120 #ifdef HI_DEBUG 121 IOC_NR_SYS_SET_COMPRESSV2_RATE, 122 IOC_NR_SYS_GET_COMPRESSV2_RATE, 123 #endif 124 } ioc_nr_sys; 125 126 #define SYS_INIT_CTRL _IO(IOC_TYPE_SYS, IOC_NR_SYS_INIT) 127 #define SYS_EXIT_CTRL _IO(IOC_TYPE_SYS, IOC_NR_SYS_EXIT) 128 #define SYS_SET_CONFIG_CTRL _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SETCONFIG, hi_mpp_sys_config) 129 #define SYS_GET_CONFIG_CTRL _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GETCONFIG, hi_mpp_sys_config) 130 #define SYS_INIT_PTSBASE _IOW(IOC_TYPE_SYS, IOC_NR_SYS_INITPTSBASE, hi_u64) 131 #define SYS_SYNC_PTS _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SYNCPTS, hi_u64) 132 #define SYS_GET_CURPTS _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GETCURPTS, hi_u64) 133 134 #define SYS_BIND_CTRL _IOW(IOC_TYPE_SYS, IOC_NR_SYS_BIND, sys_bind_args) 135 #define SYS_UNBIND_CTRL _IOW(IOC_TYPE_SYS, IOC_NR_SYS_UNBIND, sys_bind_args) 136 #define SYS_GETBINDBYDEST _IOWR(IOC_TYPE_SYS, IOC_NR_SYS_GETBINDBYDEST, sys_bind_args) 137 #define SYS_GETBINDBYSRC _IOWR(IOC_TYPE_SYS, IOC_NR_SYS_GETBINDBYSRC, sys_bind_src_args) 138 139 #define SYS_MEM_SET_CTRL _IOW(IOC_TYPE_SYS, IOC_NR_SYS_MEM_SET, sys_mem_args) 140 #define SYS_MEM_GET_CTRL _IOWR(IOC_TYPE_SYS, IOC_NR_SYS_MEM_GET, sys_mem_args) 141 142 #define SYS_GET_CUST_CODE _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_CUST_CODE, hi_u32) 143 144 #define SYS_GET_KERNELCONFIG _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_KERNELCONFIG, kernel_config) 145 146 #define SYS_GET_CHIPID _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_CHIPID, hi_u32) 147 148 #define SYS_GET_UNIQUE_ID _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_UNIQUE_ID, hi_unique_id) 149 150 #define SYS_SET_TUNING_CONNECT _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_TUNING_CONNECT, hi_s32) 151 #define SYS_GET_TUNING_CONNECT _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_TUNING_CONNECT, hi_s32) 152 153 #define SYS_MFLUSH_CACHE _IOW(IOC_TYPE_SYS, IOC_NR_SYS_MFLUSH_CACHE, sys_mem_cache_info) 154 155 #define SYS_SET_SCALE_COEFF _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_SCALE_COEFF, hi_scale_coeff_info) 156 #define SYS_GET_SCALE_COEFF _IOWR(IOC_TYPE_SYS, IOC_NR_SYS_GET_SCALE_COEFF, hi_scale_coeff_info) 157 158 #define SYS_SET_TIME_ZONE _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_TIME_ZONE, hi_s32) 159 #define SYS_GET_TIME_ZONE _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_TIME_ZONE, hi_s32) 160 161 #define SYS_SET_GPS_INFO _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_GPS_INFO, hi_gps_info) 162 #define SYS_GET_GPS_INFO _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_GPS_INFO, hi_gps_info) 163 164 #define SYS_SET_VIVPSS_MODE _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_VIVPSS_MODE, hi_vi_vpss_mode) 165 #define SYS_GET_VIVPSS_MODE _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_VIVPSS_MODE, hi_vi_vpss_mode) 166 #define SYSCONFIG_SET_VI_VPSS_WORK_MODE _IOW(IOC_TYPE_SYS, IOC_NR_SYSCONFIG_SET_VI_VPSS_WORK_MODE, hi_s32) 167 168 #define SYS_GET_VPSSVENC_WRAP_BUF_LINE _IOWR(IOC_TYPE_SYS, \ 169 IOC_NR_SYS_GET_VPSSVENC_WRAP_BUF_LINE, vpss_venc_wrap_args) 170 171 #define SYS_SET_RAW_FRAME_COMPRESS_RATE _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_RAW_FRAME_COMPRESS_RATE, \ 172 hi_raw_frame_compress_param) 173 #define SYS_GET_RAW_FRAME_COMPRESS_RATE _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_RAW_FRAME_COMPRESS_RATE, \ 174 hi_raw_frame_compress_param) 175 176 #ifdef HI_DEBUG 177 #define SYS_SET_COMPRESSV2_RATE _IOW(IOC_TYPE_SYS, IOC_NR_SYS_SET_COMPRESSV2_RATE, sys_compress_v2_param) 178 #define SYS_GET_COMPRESSV2_RATE _IOR(IOC_TYPE_SYS, IOC_NR_SYS_GET_COMPRESSV2_RATE, sys_compress_v2_param) 179 #endif 180 181 /* 182 * cur sender:VIU,VOU,VDEC,VPSS,AI 183 * cur receive:VOU,VPSS,GRP,AO 184 */ 185 #define bind_adjust_src_dev_id(mod_id, dev_id) \ 186 do { \ 187 if ((mod_id) == HI_ID_VDEC) { \ 188 (dev_id) = 0; \ 189 } \ 190 } while (0) 191 192 #define bind_adjust_src_chn_id(mod_id, chn_id) \ 193 do { \ 194 if ((mod_id) == HI_ID_VO) { \ 195 (chn_id) = 0; \ 196 } \ 197 } while (0) 198 199 #define bind_adjust_dest_chn_id(mod_id, chn_id) \ 200 do { \ 201 if ((mod_id) == HI_ID_VPSS) { \ 202 (chn_id) = 0; \ 203 } \ 204 } while (0) 205 206 #define sys_emerg_trace(fmt, ...) \ 207 do { \ 208 HI_EMERG_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 209 } while (0) 210 211 #define sys_alert_trace(fmt, ...) \ 212 do { \ 213 HI_ALERT_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 214 } while (0) 215 216 #define sys_crit_trace(fmt, ...) \ 217 do { \ 218 HI_CRIT_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 219 } while (0) 220 221 #define sys_err_trace(fmt, ...) \ 222 do { \ 223 HI_ERR_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 224 } while (0) 225 226 #define sys_warn_trace(fmt, ...) \ 227 do { \ 228 HI_WARN_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 229 } while (0) 230 231 #define sys_notice_trace(fmt, ...) \ 232 do { \ 233 HI_NOTICE_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 234 } while (0) 235 236 #define sys_info_trace(fmt, ...) \ 237 do { \ 238 HI_INFO_TRACE(HI_ID_SYS, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 239 } while (0) 240 241 #define sys_debug_trace(fmt, ...) \ 242 do { \ 243 HI_DEBUG_TRACE(HI_ID_GDC, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 244 } while (0) 245 246 hi_s32 sys_bind(hi_mpp_chn *bind_src, hi_mpp_chn *bind_dest); 247 hi_s32 sys_unbind(hi_mpp_chn *bind_src, hi_mpp_chn *bind_dest); 248 hi_s32 sys_get_bind_by_dest(hi_mpp_chn *dest_chn, hi_mpp_chn *src_chn, hi_bool inner_call); 249 250 hi_s32 sys_get_bind_num_by_src(hi_mpp_chn *src_chn, hi_u32 *bind_num); 251 252 hi_s32 sys_get_bind_by_dest_inner(hi_mpp_chn *dest_chn, hi_mpp_chn *src_chn); 253 hi_s32 sys_get_bind_by_src(hi_mpp_chn *src_chn, hi_mpp_bind_dest *bind_src); 254 255 hi_s32 sys_bind_register_sender(bind_sender_info *info); 256 hi_s32 sys_bind_unregister_sender(hi_mod_id mod_id); 257 hi_s32 sys_bind_send_data(hi_mod_id mod_id, hi_s32 dev_id, hi_s32 chn_id, hi_u32 flag, 258 mpp_data_type data_type, hi_void *v_data); 259 260 hi_s32 sys_bind_reset_data(hi_mod_id mod_id, hi_s32 dev_id, hi_s32 chn_id, hi_void *v_data); 261 262 hi_s32 sys_bind_register_receiver(bind_receiver_info *info); 263 hi_s32 sys_bind_unregister_receiver(hi_mod_id mod_id); 264 265 hi_s32 sys_bind_init(hi_void); 266 hi_void sys_bind_exit(hi_void); 267 268 hi_s32 sys_bind_mod_init(hi_void); 269 hi_void sys_bind_mod_exit(hi_void); 270 271 #ifdef __cplusplus 272 } 273 #endif /* __cplusplus */ 274 275 #endif /* __MKP_SYS_H__ */ 276