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 #ifndef __MOD_EXT_H__ 19 #define __MOD_EXT_H__ 20 21 #include "hi_osal.h" 22 #include "hi_type.h" 23 #include "hi_common_adapt.h" 24 25 #define MAX_MPP_MODULES HI_ID_BUTT 26 27 #define VERSION_MAGIC 20191120 28 29 #define MAX_MOD_NAME 16 30 31 typedef enum { 32 MOD_NOTICE_STOP = 0x11, 33 } mod_notice_id; 34 35 typedef enum { 36 MOD_STATE_FREE = 0x11, 37 MOD_STATE_BUSY = 0X22, 38 MOD_STATE_BYPASS = 0x33, 39 } mod_state; 40 41 typedef hi_s32 fn_mod_init(hi_void *); 42 typedef hi_void fn_mod_exit(hi_void); 43 typedef hi_void fn_mod_notify(mod_notice_id notice_id); 44 typedef hi_void fn_mod_query_state(mod_state *state); 45 typedef hi_u32 fn_mod_ver_checker(hi_void); 46 47 typedef struct { 48 struct osal_list_head list; 49 50 hi_char mod_name[MAX_MOD_NAME]; 51 hi_mod_id mod_id; 52 53 fn_mod_init *pfn_init; 54 fn_mod_exit *pfn_exit; 55 fn_mod_query_state *pfn_query_state; 56 fn_mod_notify *pfn_notify; 57 fn_mod_ver_checker *pfn_ver_checker; 58 59 hi_bool inited; 60 61 hi_void *export_funcs; 62 hi_void *data; 63 64 hi_char *version; 65 } umap_module; 66 67 extern hi_char *cmpi_get_module_name(hi_mod_id mod_id); 68 extern umap_module *cmpi_get_module_by_id(hi_mod_id mod_id); 69 extern hi_void *cmpi_get_module_func_by_id(hi_mod_id mod_id); 70 71 extern hi_void cmpi_stop_modules(hi_void); 72 extern hi_s32 cmpi_query_modules(hi_void); 73 extern hi_s32 cmpi_init_modules(hi_void); 74 extern hi_void cmpi_exit_modules(hi_void); 75 extern hi_s32 cmpi_register_module(umap_module *modules); 76 extern hi_void cmpi_unregister_module(hi_mod_id mod_id); 77 78 #define func_entry(type, id) ((type *)cmpi_get_module_func_by_id(id)) 79 #define check_func_entry(id) (cmpi_get_module_func_by_id(id) != NULL) 80 #define func_entry_null(id) (!check_func_entry(id)) 81 82 #endif /* __MOD_EXT_H__ */ 83 84