1 #ifndef _UAPI_MSM_VENC_H_ 2 #define _UAPI_MSM_VENC_H_ 3 4 #include <linux/types.h> 5 6 #define VENC_MAX_RECON_BUFFERS 2 7 8 #define VENC_FLAG_EOS 0x00000001 9 #define VENC_FLAG_END_OF_FRAME 0x00000010 10 #define VENC_FLAG_SYNC_FRAME 0x00000020 11 #define VENC_FLAG_EXTRA_DATA 0x00000040 12 #define VENC_FLAG_CODEC_CONFIG 0x00000080 13 14 enum venc_flush_type { 15 VENC_FLUSH_INPUT, 16 VENC_FLUSH_OUTPUT, 17 VENC_FLUSH_ALL 18 }; 19 20 enum venc_state_type { 21 VENC_STATE_PAUSE = 0x1, 22 VENC_STATE_START = 0x2, 23 VENC_STATE_STOP = 0x4 24 }; 25 26 enum venc_event_type_enum { 27 VENC_EVENT_START_STATUS, 28 VENC_EVENT_STOP_STATUS, 29 VENC_EVENT_SUSPEND_STATUS, 30 VENC_EVENT_RESUME_STATUS, 31 VENC_EVENT_FLUSH_STATUS, 32 VENC_EVENT_RELEASE_INPUT, 33 VENC_EVENT_DELIVER_OUTPUT, 34 VENC_EVENT_UNKNOWN_STATUS 35 }; 36 37 enum venc_status_code { 38 VENC_STATUS_SUCCESS, 39 VENC_STATUS_ERROR, 40 VENC_STATUS_INVALID_STATE, 41 VENC_STATUS_FLUSHING, 42 VENC_STATUS_INVALID_PARAM, 43 VENC_STATUS_CMD_QUEUE_FULL, 44 VENC_STATUS_CRITICAL, 45 VENC_STATUS_INSUFFICIENT_RESOURCES, 46 VENC_STATUS_TIMEOUT 47 }; 48 49 enum venc_msg_code { 50 VENC_MSG_INDICATION, 51 VENC_MSG_INPUT_BUFFER_DONE, 52 VENC_MSG_OUTPUT_BUFFER_DONE, 53 VENC_MSG_NEED_OUTPUT_BUFFER, 54 VENC_MSG_FLUSH, 55 VENC_MSG_START, 56 VENC_MSG_STOP, 57 VENC_MSG_PAUSE, 58 VENC_MSG_RESUME, 59 VENC_MSG_STOP_READING_MSG 60 }; 61 62 enum venc_error_code { 63 VENC_S_SUCCESS, 64 VENC_S_EFAIL, 65 VENC_S_EFATAL, 66 VENC_S_EBADPARAM, 67 VENC_S_EINVALSTATE, 68 VENC_S_ENOSWRES, 69 VENC_S_ENOHWRES, 70 VENC_S_EBUFFREQ, 71 VENC_S_EINVALCMD, 72 VENC_S_ETIMEOUT, 73 VENC_S_ENOREATMPT, 74 VENC_S_ENOPREREQ, 75 VENC_S_ECMDQFULL, 76 VENC_S_ENOTSUPP, 77 VENC_S_ENOTIMPL, 78 VENC_S_ENOTPMEM, 79 VENC_S_EFLUSHED, 80 VENC_S_EINSUFBUF, 81 VENC_S_ESAMESTATE, 82 VENC_S_EINVALTRANS 83 }; 84 85 enum venc_mem_region_enum { 86 VENC_PMEM_EBI1, 87 VENC_PMEM_SMI 88 }; 89 90 struct venc_buf_type { 91 u32 region; 92 u32 phys; 93 u32 size; 94 int offset; 95 }; 96 97 struct venc_qp_range { 98 u32 min_qp; 99 u32 max_qp; 100 }; 101 102 struct venc_frame_rate { 103 u32 frame_rate_num; 104 u32 frame_rate_den; 105 }; 106 107 struct venc_slice_info { 108 u32 slice_mode; 109 u32 units_per_slice; 110 }; 111 112 struct venc_extra_data { 113 u32 slice_extra_data_flag; 114 u32 slice_client_data1; 115 u32 slice_client_data2; 116 u32 slice_client_data3; 117 u32 none_extra_data_flag; 118 u32 none_client_data1; 119 u32 none_client_data2; 120 u32 none_client_data3; 121 }; 122 123 struct venc_common_config { 124 u32 standard; 125 u32 input_frame_height; 126 u32 input_frame_width; 127 u32 output_frame_height; 128 u32 output_frame_width; 129 u32 rotation_angle; 130 u32 intra_period; 131 u32 rate_control; 132 struct venc_frame_rate frame_rate; 133 u32 bitrate; 134 struct venc_qp_range qp_range; 135 u32 iframe_qp; 136 u32 pframe_qp; 137 struct venc_slice_info slice_config; 138 struct venc_extra_data extra_data; 139 }; 140 141 struct venc_nonio_buf_config { 142 struct venc_buf_type recon_buf1; 143 struct venc_buf_type recon_buf2; 144 struct venc_buf_type wb_buf; 145 struct venc_buf_type cmd_buf; 146 struct venc_buf_type vlc_buf; 147 }; 148 149 struct venc_mpeg4_config { 150 u32 profile; 151 u32 level; 152 u32 time_resolution; 153 u32 ac_prediction; 154 u32 hec_interval; 155 u32 data_partition; 156 u32 short_header; 157 u32 rvlc_enable; 158 }; 159 160 struct venc_h263_config { 161 u32 profile; 162 u32 level; 163 }; 164 165 struct venc_h264_config { 166 u32 profile; 167 u32 level; 168 u32 max_nal; 169 u32 idr_period; 170 }; 171 172 struct venc_pmem { 173 int src; 174 int fd; 175 u32 offset; 176 void *virt; 177 void *phys; 178 u32 size; 179 }; 180 181 struct venc_buffer { 182 unsigned char *ptr_buffer; 183 u32 size; 184 u32 len; 185 u32 offset; 186 long long time_stamp; 187 u32 flags; 188 u32 client_data; 189 190 }; 191 192 struct venc_buffers { 193 struct venc_pmem recon_buf[VENC_MAX_RECON_BUFFERS]; 194 struct venc_pmem wb_buf; 195 struct venc_pmem cmd_buf; 196 struct venc_pmem vlc_buf; 197 }; 198 199 struct venc_buffer_flush { 200 u32 flush_mode; 201 }; 202 203 union venc_msg_data { 204 struct venc_buffer buf; 205 struct venc_buffer_flush flush_ret; 206 207 }; 208 209 struct venc_msg { 210 u32 status_code; 211 u32 msg_code; 212 u32 msg_data_size; 213 union venc_msg_data msg_data; 214 }; 215 216 union venc_codec_config { 217 struct venc_mpeg4_config mpeg4_params; 218 struct venc_h263_config h263_params; 219 struct venc_h264_config h264_params; 220 }; 221 222 struct venc_q6_config { 223 struct venc_common_config config_params; 224 union venc_codec_config codec_params; 225 struct venc_nonio_buf_config buf_params; 226 void *callback_event; 227 }; 228 229 struct venc_hdr_config { 230 struct venc_common_config config_params; 231 union venc_codec_config codec_params; 232 }; 233 234 struct venc_init_config { 235 struct venc_q6_config q6_config; 236 struct venc_buffers q6_bufs; 237 }; 238 239 struct venc_seq_config { 240 int size; 241 struct venc_pmem buf; 242 struct venc_q6_config q6_config; 243 }; 244 245 struct venc_version { 246 u32 major; 247 u32 minor; 248 }; 249 250 #define VENC_IOCTL_MAGIC 'V' 251 252 #define VENC_IOCTL_CMD_READ_NEXT_MSG \ 253 _IOWR(VENC_IOCTL_MAGIC, 1, struct venc_msg) 254 255 #define VENC_IOCTL_CMD_STOP_READ_MSG _IO(VENC_IOCTL_MAGIC, 2) 256 257 #define VENC_IOCTL_SET_INPUT_BUFFER \ 258 _IOW(VENC_IOCTL_MAGIC, 3, struct venc_pmem) 259 260 #define VENC_IOCTL_SET_OUTPUT_BUFFER \ 261 _IOW(VENC_IOCTL_MAGIC, 4, struct venc_pmem) 262 263 #define VENC_IOCTL_CMD_START _IOW(VENC_IOCTL_MAGIC, 5, struct venc_init_config) 264 265 #define VENC_IOCTL_CMD_ENCODE_FRAME \ 266 _IOW(VENC_IOCTL_MAGIC, 6, struct venc_buffer) 267 268 #define VENC_IOCTL_CMD_FILL_OUTPUT_BUFFER \ 269 _IOW(VENC_IOCTL_MAGIC, 7, struct venc_buffer) 270 271 #define VENC_IOCTL_CMD_FLUSH \ 272 _IOW(VENC_IOCTL_MAGIC, 8, struct venc_buffer_flush) 273 274 #define VENC_IOCTL_CMD_PAUSE _IO(VENC_IOCTL_MAGIC, 9) 275 276 #define VENC_IOCTL_CMD_RESUME _IO(VENC_IOCTL_MAGIC, 10) 277 278 #define VENC_IOCTL_CMD_STOP _IO(VENC_IOCTL_MAGIC, 11) 279 280 #define VENC_IOCTL_SET_INTRA_PERIOD \ 281 _IOW(VENC_IOCTL_MAGIC, 12, int) 282 283 #define VENC_IOCTL_CMD_REQUEST_IFRAME _IO(VENC_IOCTL_MAGIC, 13) 284 285 #define VENC_IOCTL_GET_SEQUENCE_HDR \ 286 _IOWR(VENC_IOCTL_MAGIC, 14, struct venc_seq_config) 287 288 #define VENC_IOCTL_SET_INTRA_REFRESH \ 289 _IOW(VENC_IOCTL_MAGIC, 15, int) 290 291 #define VENC_IOCTL_SET_FRAME_RATE \ 292 _IOW(VENC_IOCTL_MAGIC, 16, struct venc_frame_rate) 293 294 #define VENC_IOCTL_SET_TARGET_BITRATE \ 295 _IOW(VENC_IOCTL_MAGIC, 17, int) 296 297 #define VENC_IOCTL_SET_QP_RANGE \ 298 _IOW(VENC_IOCTL_MAGIC, 18, struct venc_qp_range) 299 300 #define VENC_IOCTL_GET_VERSION \ 301 _IOR(VENC_IOCTL_MAGIC, 19, struct venc_version) 302 303 #endif 304