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_VO_DEV_H__ 20 #define __MKP_VO_DEV_H__ 21 22 #include "mkp_ioctl.h" 23 #include "hi_common_adapt.h" 24 #include "hi_comm_video_adapt.h" 25 26 #ifdef __cplusplus 27 #if __cplusplus 28 extern "C" { 29 #endif 30 #endif /* end of #ifdef __cplusplus */ 31 32 #define GFX_MASK 0x80000000 33 34 typedef enum { 35 VO_LAYER_V0 = 0, 36 VO_LAYER_V1 = 1, 37 VO_LAYER_V2 = 2, 38 VO_LAYER_V3 = 3, 39 VO_LAYER_G0 = 4, 40 VO_LAYER_G1 = 5, 41 VO_LAYER_G2 = 6, 42 VO_LAYER_G3 = 7, 43 VO_LAYER_BUTT 44 } vo_layer_id; 45 46 #define vo_id_gfx_fd(gfx) (GFX_MASK | (((gfx)&0xf) << 28)) 47 48 /* for mkp */ 49 #define vo_get_dev(f) (((*((hi_u32 *)(f))) >> 16) & 0xff) 50 #define vo_get_gfx(f) ((((*((hi_u32 *)(f))) & (~(GFX_MASK))) >> 28) & 0xf) 51 52 #define vo_emerg_trace(fmt, ...) \ 53 HI_EMERG_TRACE(HI_ID_VO_DEV, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) 54 55 #define vo_err_trace(fmt, ...) \ 56 HI_ERR_TRACE(HI_ID_VO_DEV, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) 57 58 #define vo_warn_trace(fmt, ...) \ 59 HI_WARN_TRACE(HI_ID_VO_DEV, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) 60 61 #define vo_info_trace(fmt, ...) \ 62 HI_INFO_TRACE(HI_ID_VO_DEV, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) 63 64 #define vo_alert_trace(fmt, ...) \ 65 HI_ALERT_TRACE(HI_ID_VO_DEV, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) 66 67 #define vo_debug_trace(fmt, ...) \ 68 HI_DEBUG_TRACE(HI_ID_VO_DEV, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) 69 70 hi_s32 vo_def_check_dev_id(hi_vo_dev dev); 71 72 /* macro definition for check status */ 73 #define vo_check_null_ptr_return(ptr) \ 74 do { \ 75 if ((ptr) == HI_NULL) { \ 76 vo_warn_trace("null ptr!\n"); \ 77 return HI_ERR_VO_NULL_PTR; \ 78 } \ 79 } while (0) 80 81 /* vo device relative */ 82 #define vo_check_dev_id_return(dev) \ 83 do { \ 84 if (vo_def_check_dev_id(dev) != HI_SUCCESS) { \ 85 vo_err_trace("dev %d invalid!\n", dev); \ 86 return HI_ERR_VO_INVALID_DEVID; \ 87 } \ 88 } while (0) 89 90 typedef enum { 91 /* file operation */ 92 IOC_NR_VOU_SET_FD, 93 IOC_NR_VOU_CLOSE_FD, 94 95 /* device operation */ 96 IOC_NR_VOU_OPEN, 97 IOC_NR_VOU_CLOSE, 98 IOC_NR_VOU_PUB_ATTR_SET, 99 IOC_NR_VOU_PUB_ATTR_GET, 100 IOC_NR_VOU_FPS_SET, 101 IOC_NR_VOU_FPS_GET, 102 103 IOC_NR_VOU_VTTH_SET, 104 IOC_NR_VOU_VTTH_GET, 105 106 IOC_NR_VOU_USER_INTFSYNC_INFO_SET, 107 108 /* graphics bind operation */ 109 IOC_NR_VOU_GFX_LAYER_BIND, 110 IOC_NR_VOU_GFX_LAYER_UNBIND, 111 IOC_NR_VOU_GFX_CSC_SET, 112 IOC_NR_VOU_GFX_CSC_GET, 113 114 /* module param settings */ 115 IOC_NR_VO_MOD_PARAM_SET, 116 IOC_NR_VO_MOD_PARAM_GET, 117 118 IOC_NR_VOU_VTTH2_SET, 119 IOC_NR_VOU_VTTH2_GET, 120 121 IOC_NR_VOU_BUTT 122 } ioc_nr_vou; 123 124 #define VOU_OPEN_CTRL _IO(IOC_TYPE_VOU_DEV, IOC_NR_VOU_OPEN) 125 #define VOU_CLOSE_CTRL _IO(IOC_TYPE_VOU_DEV, IOC_NR_VOU_CLOSE) 126 #define VOU_PUB_ATTR_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_PUB_ATTR_SET, hi_vo_pub_attr) 127 #define VOU_PUB_ATTR_GET_CTRL _IOR(IOC_TYPE_VOU_DEV, IOC_NR_VOU_PUB_ATTR_GET, hi_vo_pub_attr) 128 129 #define VOU_DEV_FPS_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_FPS_SET, hi_u32) 130 #define VOU_DEV_FPS_GET_CTRL _IOR(IOC_TYPE_VOU_DEV, IOC_NR_VOU_FPS_GET, hi_u32) 131 132 #define VOU_DEV_VTTH_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_VTTH_SET, hi_u32) 133 #define VOU_DEV_VTTH_GET_CTRL _IOR(IOC_TYPE_VOU_DEV, IOC_NR_VOU_VTTH_GET, hi_u32) 134 #define VOU_DEV_VTTH2_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_VTTH2_SET, hi_u32) 135 #define VOU_DEV_VTTH2_GET_CTRL _IOR(IOC_TYPE_VOU_DEV, IOC_NR_VOU_VTTH2_GET, hi_u32) 136 137 #define VOU_USER_INTFSYNC_INFO_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_USER_INTFSYNC_INFO_SET, \ 138 hi_vo_user_intfsync_info) 139 140 /* the following IOCTL is used for vou fd operation */ 141 #define VOU_DEV_SET_FD _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_SET_FD, hi_s32) 142 #define VOU_DEV_CLOSE_FD _IO(IOC_TYPE_VOU_DEV, IOC_NR_VOU_CLOSE_FD) 143 144 /* graphics layer bind-relation */ 145 #define VOU_GFX_LAYER_BIND_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_GFX_LAYER_BIND, hi_s32) 146 #define VOU_GFX_LAYER_UNBIND_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_GFX_LAYER_UNBIND, hi_s32) 147 #define VOU_GFX_LAYER_CSC_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VOU_GFX_CSC_SET, hi_vo_csc) 148 #define VOU_GFX_LAYER_CSC_GET_CTRL _IOR(IOC_TYPE_VOU_DEV, IOC_NR_VOU_GFX_CSC_GET, hi_vo_csc) 149 150 /* module param settings */ 151 #define VO_MOD_PARAM_SET_CTRL _IOW(IOC_TYPE_VOU_DEV, IOC_NR_VO_MOD_PARAM_SET, hi_vo_mod_param) 152 #define VO_MOD_PARAM_GET_CTRL _IOR(IOC_TYPE_VOU_DEV, IOC_NR_VO_MOD_PARAM_GET, hi_vo_mod_param) 153 154 #ifdef __cplusplus 155 #if __cplusplus 156 } 157 #endif 158 #endif /* end of #ifdef __cplusplus */ 159 160 #endif /* end of #ifndef __MKP_VO_DEV_H__ */ 161