1 /* 2 * include/linux/amlogic/media/utils/amstream.h 3 * 4 * Copyright (C) 2016 Amlogic, Inc. All rights reserved. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 * more details. 15 * 16 */ 17 18 #ifndef AMSTREAM_H 19 #define AMSTREAM_H 20 21 /* #include <linux/interrupt.h> */ 22 #include <linux/amlogic/media/utils/vformat.h> 23 #include <linux/amlogic/media/utils/aformat.h> 24 25 #ifdef __KERNEL__ 26 #define PORT_FLAG_IN_USE 0x0001 27 #define PORT_FLAG_VFORMAT 0x0002 28 #define PORT_FLAG_AFORMAT 0x0004 29 #define PORT_FLAG_FORMAT (PORT_FLAG_VFORMAT | PORT_FLAG_AFORMAT) 30 #define PORT_FLAG_VID 0x0008 31 #define PORT_FLAG_AID 0x0010 32 #define PORT_FLAG_SID 0x0020 33 #define PORT_FLAG_UD 0x0040 34 #define PORT_FLAG_DRM 0x0080 35 #define PORT_FLAG_ID (PORT_FLAG_VID | \ 36 PORT_FLAG_AID | PORT_FLAG_SID | PORT_FLAG_UD) 37 #define PORT_FLAG_INITED 0x100 38 39 #define PORT_TYPE_VIDEO 0x01 40 #define PORT_TYPE_AUDIO 0x02 41 #define PORT_TYPE_MPTS 0x04 42 #define PORT_TYPE_MPPS 0x08 43 #define PORT_TYPE_ES 0x10 44 #define PORT_TYPE_RM 0x20 45 #define PORT_TYPE_SUB 0x40 46 #define PORT_TYPE_SUB_RD 0x80 47 #define PORT_TYPE_HEVC 0x100 48 #define PORT_TYPE_USERDATA 0x200 49 #define PORT_TYPE_FRAME 0x400 50 #define PORT_TYPE_DECODER_SCHED 0x800 51 #define PORT_TYPE_DUALDEC 0x1000 52 #endif 53 54 #define _A_M 'S' 55 #define AMSTREAM_IOC_VB_START _IOW((_A_M), 0x00, int) 56 #define AMSTREAM_IOC_VB_SIZE _IOW((_A_M), 0x01, int) 57 #define AMSTREAM_IOC_AB_START _IOW((_A_M), 0x02, int) 58 #define AMSTREAM_IOC_AB_SIZE _IOW((_A_M), 0x03, int) 59 #define AMSTREAM_IOC_VFORMAT _IOW((_A_M), 0x04, int) 60 #define AMSTREAM_IOC_AFORMAT _IOW((_A_M), 0x05, int) 61 #define AMSTREAM_IOC_VID _IOW((_A_M), 0x06, int) 62 #define AMSTREAM_IOC_AID _IOW((_A_M), 0x07, int) 63 #define AMSTREAM_IOC_VB_STATUS _IOR((_A_M), 0x08, int) 64 #define AMSTREAM_IOC_AB_STATUS _IOR((_A_M), 0x09, int) 65 #define AMSTREAM_IOC_SYSINFO _IOW((_A_M), 0x0a, int) 66 #define AMSTREAM_IOC_ACHANNEL _IOW((_A_M), 0x0b, int) 67 #define AMSTREAM_IOC_SAMPLERATE _IOW((_A_M), 0x0c, int) 68 #define AMSTREAM_IOC_DATAWIDTH _IOW((_A_M), 0x0d, int) 69 #define AMSTREAM_IOC_TSTAMP _IOW((_A_M), 0x0e, int) 70 #define AMSTREAM_IOC_VDECSTAT _IOR((_A_M), 0x0f, int) 71 #define AMSTREAM_IOC_ADECSTAT _IOR((_A_M), 0x10, int) 72 73 #define AMSTREAM_IOC_PORT_INIT _IO((_A_M), 0x11) 74 #define AMSTREAM_IOC_TRICKMODE _IOW((_A_M), 0x12, int) 75 76 #define AMSTREAM_IOC_AUDIO_INFO _IOW((_A_M), 0x13, int) 77 #define AMSTREAM_IOC_TRICK_STAT _IOR((_A_M), 0x14, int) 78 #define AMSTREAM_IOC_AUDIO_RESET _IO((_A_M), 0x15) 79 #define AMSTREAM_IOC_SID _IOW((_A_M), 0x16, int) 80 #define AMSTREAM_IOC_VPAUSE _IOW((_A_M), 0x17, int) 81 #define AMSTREAM_IOC_AVTHRESH _IOW((_A_M), 0x18, int) 82 #define AMSTREAM_IOC_SYNCTHRESH _IOW((_A_M), 0x19, int) 83 #define AMSTREAM_IOC_SUB_RESET _IOW((_A_M), 0x1a, int) 84 #define AMSTREAM_IOC_SUB_LENGTH _IOR((_A_M), 0x1b, int) 85 #define AMSTREAM_IOC_SET_DEC_RESET _IOW((_A_M), 0x1c, int) 86 #define AMSTREAM_IOC_TS_SKIPBYTE _IOW((_A_M), 0x1d, int) 87 #define AMSTREAM_IOC_SUB_TYPE _IOW((_A_M), 0x1e, int) 88 #define AMSTREAM_IOC_CLEAR_VIDEO _IOW((_A_M), 0x1f, int) 89 #define AMSTREAM_IOC_VDECINFO _IOR((_A_M), 0x20, int) 90 #define AMSTREAM_IOC_GLOBAL_GET_VIDEO_OUTPUT _IOR((_A_M), 0x21, int) 91 #define AMSTREAM_IOC_GLOBAL_SET_VIDEO_OUTPUT _IOW((_A_M), 0x22, int) 92 #define AMSTREAM_IOC_GET_VIDEO_LAYER1_ON _IOR((_A_M), 0x23, int) 93 /*video pip IOCTL command list*/ 94 #define AMSTREAM_IOC_CLEAR_VIDEOPIP _IOW((_A_M), 0x24, int) 95 #define AMSTREAM_IOC_CLEAR_PIP_VBUF _IO((_A_M), 0x25) 96 97 #define AMSTREAM_IOC_GET_DISPLAYPATH _IOW((_A_M), 0x26, int) 98 #define AMSTREAM_IOC_SET_DISPLAYPATH _IOW((_A_M), 0x27, int) 99 100 #define AMSTREAM_IOC_GET_PIP_DISPLAYPATH _IOW((_A_M), 0x28, int) 101 #define AMSTREAM_IOC_SET_PIP_DISPLAYPATH _IOW((_A_M), 0x29, int) 102 103 #define AMSTREAM_IOC_GLOBAL_GET_VIDEOPIP_OUTPUT _IOR((_A_M), 0x2b, int) 104 #define AMSTREAM_IOC_GLOBAL_SET_VIDEOPIP_OUTPUT _IOW((_A_M), 0x2c, int) 105 #define AMSTREAM_IOC_GET_VIDEOPIP_DISABLE _IOR((_A_M), 0x2d, int) 106 #define AMSTREAM_IOC_SET_VIDEOPIP_DISABLE _IOW((_A_M), 0x2e, int) 107 #define AMSTREAM_IOC_GET_VIDEOPIP_AXIS _IOR((_A_M), 0x2f, int) 108 #define AMSTREAM_IOC_SET_VIDEOPIP_AXIS _IOW((_A_M), 0x30, int) 109 #define AMSTREAM_IOC_GET_VIDEOPIP_CROP _IOR((_A_M), 0x31, int) 110 #define AMSTREAM_IOC_SET_VIDEOPIP_CROP _IOW((_A_M), 0x32, int) 111 #define AMSTREAM_IOC_GET_PIP_SCREEN_MODE _IOR((_A_M), 0x33, int) 112 #define AMSTREAM_IOC_SET_PIP_SCREEN_MODE _IOW((_A_M), 0x34, int) 113 #define AMSTREAM_IOC_GET_PIP_ZORDER _IOW((_A_M), 0x35, unsigned int) 114 #define AMSTREAM_IOC_SET_PIP_ZORDER _IOW((_A_M), 0x36, unsigned int) 115 116 #define AMSTREAM_IOC_GET_ZORDER _IOW((_A_M), 0x37, unsigned int) 117 #define AMSTREAM_IOC_SET_ZORDER _IOW((_A_M), 0x38, unsigned int) 118 119 #define AMSTREAM_IOC_QUERY_LAYER _IOW((_A_M), 0x39, unsigned int) 120 #define AMSTREAM_IOC_ALLOC_LAYER _IOW((_A_M), 0x3a, unsigned int) 121 #define AMSTREAM_IOC_FREE_LAYER _IOW((_A_M), 0x3b, unsigned int) 122 123 /* VPP.3D IOCTL command list^M */ 124 #define AMSTREAM_IOC_SET_3D_TYPE _IOW((_A_M), 0x3c, unsigned int) 125 #define AMSTREAM_IOC_GET_3D_TYPE _IOW((_A_M), 0x3d, unsigned int) 126 #define AMSTREAM_IOC_GET_SOURCE_VIDEO_3D_TYPE _IOW((_A_M), 0x3e, unsigned int) 127 128 #define AMSTREAM_IOC_APTS _IOR((_A_M), 0x40, int) 129 #define AMSTREAM_IOC_VPTS _IOR((_A_M), 0x41, int) 130 #define AMSTREAM_IOC_PCRSCR _IOR((_A_M), 0x42, int) 131 #define AMSTREAM_IOC_SYNCENABLE _IOW((_A_M), 0x43, int) 132 #define AMSTREAM_IOC_GET_SYNC_ADISCON _IOR((_A_M), 0x44, int) 133 #define AMSTREAM_IOC_SET_SYNC_ADISCON _IOW((_A_M), 0x45, int) 134 #define AMSTREAM_IOC_GET_SYNC_VDISCON _IOR((_A_M), 0x46, int) 135 #define AMSTREAM_IOC_SET_SYNC_VDISCON _IOW((_A_M), 0x47, int) 136 #define AMSTREAM_IOC_GET_VIDEO_DISABLE _IOR((_A_M), 0x48, int) 137 #define AMSTREAM_IOC_SET_VIDEO_DISABLE _IOW((_A_M), 0x49, int) 138 #define AMSTREAM_IOC_SET_PCRSCR _IOW((_A_M), 0x4a, int) 139 #define AMSTREAM_IOC_GET_VIDEO_AXIS _IOR((_A_M), 0x4b, int) 140 #define AMSTREAM_IOC_SET_VIDEO_AXIS _IOW((_A_M), 0x4c, int) 141 #define AMSTREAM_IOC_GET_VIDEO_CROP _IOR((_A_M), 0x4d, int) 142 #define AMSTREAM_IOC_SET_VIDEO_CROP _IOW((_A_M), 0x4e, int) 143 #define AMSTREAM_IOC_PCRID _IOW((_A_M), 0x4f, int) 144 145 #define AMSTREAM_IOC_SUB_NUM _IOR((_A_M), 0x50, int) 146 #define AMSTREAM_IOC_SUB_INFO _IOR((_A_M), 0x51, int) 147 #define AMSTREAM_IOC_GET_BLACKOUT_POLICY _IOR((_A_M), 0x52, int) 148 #define AMSTREAM_IOC_SET_BLACKOUT_POLICY _IOW((_A_M), 0x53, int) 149 #define AMSTREAM_IOC_UD_LENGTH _IOR((_A_M), 0x54, int) 150 #define AMSTREAM_IOC_UD_POC _IOR((_A_M), 0x55, int) 151 #define AMSTREAM_IOC_UD_FLUSH_USERDATA _IOR((_A_M), 0x56, int) 152 153 #define AMSTREAM_IOC_UD_BUF_READ _IOR((_A_M), 0x57, int) 154 155 #define AMSTREAM_IOC_GET_SCREEN_MODE _IOR((_A_M), 0x58, int) 156 #define AMSTREAM_IOC_SET_SCREEN_MODE _IOW((_A_M), 0x59, int) 157 #define AMSTREAM_IOC_GET_VIDEO_DISCONTINUE_REPORT _IOR((_A_M), 0x5a, int) 158 #define AMSTREAM_IOC_SET_VIDEO_DISCONTINUE_REPORT _IOW((_A_M), 0x5b, int) 159 160 #define AMSTREAM_IOC_UD_AVAILABLE_VDEC _IOR((_A_M), 0x5c, unsigned int) 161 #define AMSTREAM_IOC_GET_VDEC_ID _IOR((_A_M), 0x5d, int) 162 163 /* 164 * #define AMSTREAM_IOC_UD_BUF_STATUS _IOR((_A_M), 165 * 0x5c, struct userdata_buf_state_t) 166 */ 167 168 #define AMSTREAM_IOC_VF_STATUS _IOR((_A_M), 0x60, int) 169 170 #define AMSTREAM_IOC_GET_BLACKOUT_PIP_POLICY _IOR((_A_M), 0x62, int) 171 #define AMSTREAM_IOC_SET_BLACKOUT_PIP_POLICY _IOW((_A_M), 0x63, int) 172 173 #define AMSTREAM_IOC_CLEAR_VBUF _IO((_A_M), 0x80) 174 175 #define AMSTREAM_IOC_APTS_LOOKUP _IOR((_A_M), 0x81, int) 176 #define GET_FIRST_APTS_FLAG _IOR((_A_M), 0x82, int) 177 #define AMSTREAM_IOC_GET_SYNC_ADISCON_DIFF _IOR((_A_M), 0x83, int) 178 #define AMSTREAM_IOC_GET_SYNC_VDISCON_DIFF _IOR((_A_M), 0x84, int) 179 #define AMSTREAM_IOC_SET_SYNC_ADISCON_DIFF _IOW((_A_M), 0x85, int) 180 #define AMSTREAM_IOC_SET_SYNC_VDISCON_DIFF _IOW((_A_M), 0x86, int) 181 #define AMSTREAM_IOC_GET_FREERUN_MODE _IOR((_A_M), 0x87, int) 182 #define AMSTREAM_IOC_SET_FREERUN_MODE _IOW((_A_M), 0x88, int) 183 #define AMSTREAM_IOC_SET_VSYNC_UPINT _IOW((_A_M), 0x89, int) 184 #define AMSTREAM_IOC_GET_VSYNC_SLOW_FACTOR _IOW((_A_M), 0x8a, int) 185 #define AMSTREAM_IOC_SET_VSYNC_SLOW_FACTOR _IOW((_A_M), 0x8b, int) 186 #define AMSTREAM_IOC_GET_FIRST_FRAME_LATENCY _IOR((_A_M), 0x8c, int) 187 #define AMSTREAM_IOC_CLEAR_FIRST_FRAME_LATENCY _IOR((_A_M), 0x8d, int) 188 #define AMSTREAM_IOC_SET_DEMUX _IOW((_A_M), 0x90, int) 189 #define AMSTREAM_IOC_SET_DRMMODE _IOW((_A_M), 0x91, int) 190 #define AMSTREAM_IOC_TSTAMP_uS64 _IOW((_A_M), 0x95, int) 191 192 #define AMSTREAM_IOC_SET_VIDEO_DELAY_LIMIT_MS _IOW((_A_M), 0xa0, int) 193 #define AMSTREAM_IOC_GET_VIDEO_DELAY_LIMIT_MS _IOR((_A_M), 0xa1, int) 194 #define AMSTREAM_IOC_SET_AUDIO_DELAY_LIMIT_MS _IOW((_A_M), 0xa2, int) 195 #define AMSTREAM_IOC_GET_AUDIO_DELAY_LIMIT_MS _IOR((_A_M), 0xa3, int) 196 #define AMSTREAM_IOC_GET_AUDIO_CUR_DELAY_MS _IOR((_A_M), 0xa4, int) 197 #define AMSTREAM_IOC_GET_VIDEO_CUR_DELAY_MS _IOR((_A_M), 0xa5, int) 198 #define AMSTREAM_IOC_GET_AUDIO_AVG_BITRATE_BPS _IOR((_A_M), 0xa6, int) 199 #define AMSTREAM_IOC_GET_VIDEO_AVG_BITRATE_BPS _IOR((_A_M), 0xa7, int) 200 #define AMSTREAM_IOC_SET_APTS _IOW((_A_M), 0xa8, int) 201 #define AMSTREAM_IOC_GET_LAST_CHECKIN_APTS _IOR((_A_M), 0xa9, int) 202 #define AMSTREAM_IOC_GET_LAST_CHECKIN_VPTS _IOR((_A_M), 0xaa, int) 203 #define AMSTREAM_IOC_GET_LAST_CHECKOUT_APTS _IOR((_A_M), 0xab, int) 204 #define AMSTREAM_IOC_GET_LAST_CHECKOUT_VPTS _IOR((_A_M), 0xac, int) 205 206 /* subtitle.c get/set subtitle info */ 207 #define AMSTREAM_IOC_GET_SUBTITLE_INFO _IOR((_A_M), 0xad, int) 208 #define AMSTREAM_IOC_SET_SUBTITLE_INFO _IOW((_A_M), 0xae, int) 209 #define AMSTREAM_IOC_SET_OMX_VPTS _IOW((_A_M), 0xaf, int) 210 #define AMSTREAM_IOC_GET_OMX_VPTS _IOW((_A_M), 0xb0, int) 211 #define AMSTREAM_IOC_GET_OMX_VERSION _IOW((_A_M), 0xb1, int) 212 #define AMSTREAM_IOC_GET_OMX_INFO _IOR((_A_M), 0xb2, unsigned int) 213 #define AMSTREAM_IOC_SET_HDR_INFO _IOW((_A_M), 0xb3, int) 214 #define AMSTREAM_IOC_SET_TUNNEL_MODE _IOR(_A_M, 0xbd, unsigned int) 215 #define AMSTREAM_IOC_GET_FIRST_FRAME_TOGGLED _IOR(_A_M, 0xbe, unsigned int) 216 #define AMSTREAM_IOC_SET_VIDEOPEEK _IOW(_A_M, 0xbf, unsigned int) 217 218 #define AMSTREAM_IOC_GET_TRICK_VPTS _IOR((_A_M), 0xf0, int) 219 #define AMSTREAM_IOC_DISABLE_SLOW_SYNC _IOW((_A_M), 0xf1, int) 220 221 #define AMSTREAM_IOC_GET_AUDIO_CHECKIN_BITRATE_BPS _IOR((_A_M), 0xf2, int) 222 #define AMSTREAM_IOC_GET_VIDEO_CHECKIN_BITRATE_BPS _IOR((_A_M), 0xf3, int) 223 #define AMSTREAM_IOC_VDEC_RESET _IO((_A_M), 0xf4) 224 #define AMSTREAM_IOC_GET_VERSION _IOR((_A_M), 0xc0, int) 225 #define AMSTREAM_IOC_GET _IOWR((_A_M), 0xc1, struct am_ioctl_parm) 226 #define AMSTREAM_IOC_SET _IOW((_A_M), 0xc2, struct am_ioctl_parm) 227 #define AMSTREAM_IOC_GET_EX _IOWR((_A_M), 0xc3, struct am_ioctl_parm_ex) 228 #define AMSTREAM_IOC_SET_EX _IOW((_A_M), 0xc4, struct am_ioctl_parm_ex) 229 #define AMSTREAM_IOC_GET_PTR _IOWR((_A_M), 0xc5, struct am_ioctl_parm_ptr) 230 #define AMSTREAM_IOC_SET_PTR _IOW((_A_M), 0xc6, struct am_ioctl_parm_ptr) 231 #define AMSTREAM_IOC_GET_AVINFO _IOR((_A_M), 0xc7, struct av_param_info_t) 232 #define AMSTREAM_IOC_GET_QOSINFO _IOR((_A_M), 0xc8, struct av_param_qosinfo_t) 233 #define AMSTREAM_IOC_SET_CRC _IOW((_A_M), 0xc9, struct usr_crc_info_t) 234 #define AMSTREAM_IOC_GET_CRC_CMP_RESULT _IOWR((_A_M), 0xca, int) 235 #define AMSTREAM_IOC_GET_MVDECINFO _IOR((_A_M), 0xcb, int) 236 237 238 #define TRICKMODE_NONE 0x00 239 #define TRICKMODE_I 0x01 240 #define TRICKMODE_I_HEVC 0x07 241 #define TRICKMODE_FFFB 0x02 242 243 #define TRICK_STAT_DONE 0x01 244 #define TRICK_STAT_WAIT 0x00 245 246 #define AUDIO_EXTRA_DATA_SIZE (4096) 247 #define MAX_SUB_NUM 32 248 249 enum VIDEO_DEC_TYPE { 250 VIDEO_DEC_FORMAT_UNKNOWN, 251 VIDEO_DEC_FORMAT_MPEG4_3, 252 253 VIDEO_DEC_FORMAT_MPEG4_4, 254 VIDEO_DEC_FORMAT_MPEG4_5, 255 256 VIDEO_DEC_FORMAT_H264, 257 258 VIDEO_DEC_FORMAT_MJPEG, 259 VIDEO_DEC_FORMAT_MP4, 260 VIDEO_DEC_FORMAT_H263, 261 262 VIDEO_DEC_FORMAT_REAL_8, 263 VIDEO_DEC_FORMAT_REAL_9, 264 265 VIDEO_DEC_FORMAT_WMV3, 266 267 VIDEO_DEC_FORMAT_WVC1, 268 VIDEO_DEC_FORMAT_SW, 269 VIDEO_DEC_FORMAT_MAX 270 }; 271 272 enum FRAME_BASE_VIDEO_PATH { 273 FRAME_BASE_PATH_IONVIDEO = 0, 274 FRAME_BASE_PATH_AMLVIDEO_AMVIDEO, 275 FRAME_BASE_PATH_AMLVIDEO1_AMVIDEO2, 276 FRAME_BASE_PATH_DI_AMVIDEO, 277 FRAME_BASE_PATH_AMVIDEO, 278 FRAME_BASE_PATH_AMVIDEO2, 279 FRAME_BASE_PATH_V4L_VIDEO, 280 FRAME_BASE_PATH_TUNNEL_MODE, 281 FRAME_BASE_PATH_V4L_OSD, 282 FRAME_BASE_PATH_DI_V4LVIDEO, 283 FRAME_BASE_PATH_PIP_TUNNEL_MODE, 284 FRAME_BASE_PATH_MAX 285 }; 286 287 struct buf_status { 288 289 int size; 290 291 int data_len; 292 293 int free_len; 294 295 unsigned int read_pointer; 296 297 unsigned int write_pointer; 298 }; 299 300 /*struct vdec_status.status*/ 301 #define STAT_TIMER_INIT 0x01 302 #define STAT_MC_LOAD 0x02 303 #define STAT_ISR_REG 0x04 304 #define STAT_VF_HOOK 0x08 305 #define STAT_TIMER_ARM 0x10 306 #define STAT_VDEC_RUN 0x20 307 308 /*struct vdec_status.status on error*/ 309 310 #define PARSER_FATAL_ERROR (0x10<<16) 311 #define DECODER_ERROR_VLC_DECODE_TBL (0x20<<16) 312 #define PARSER_ERROR_WRONG_HEAD_VER (0x40<<16) 313 #define PARSER_ERROR_WRONG_PACKAGE_SIZE (0x80<<16) 314 #define DECODER_FATAL_ERROR_SIZE_OVERFLOW (0x100<<16) 315 #define DECODER_FATAL_ERROR_UNKNOWN (0x200<<16) 316 #define DECODER_FATAL_ERROR_NO_MEM (0x400<<16) 317 318 #define DECODER_ERROR_MASK (0xffff<<16) 319 /* The total slot number for fifo_buf */ 320 #define NUM_FRAME_VDEC 128 //This must be 2^n 321 #define QOS_FRAME_NUM 8 322 323 324 enum E_ASPECT_RATIO { 325 ASPECT_RATIO_4_3, 326 ASPECT_RATIO_16_9, 327 ASPECT_UNDEFINED = 255 328 }; 329 330 struct vdec_status { 331 unsigned int width; 332 unsigned int height; 333 unsigned int fps; 334 unsigned int error_count; 335 unsigned int status; 336 enum E_ASPECT_RATIO euAspectRatio; 337 }; 338 339 struct vdec_info { 340 char vdec_name[16]; 341 u32 ver; 342 u32 frame_width; 343 u32 frame_height; 344 u32 frame_rate; 345 union { 346 u32 bit_rate; 347 /* Effective in h265,vp9,avs2 multi-instance */ 348 u32 bit_depth_luma; 349 }; 350 u32 frame_dur; 351 union { 352 u32 frame_data; 353 /* Effective in h265,vp9,avs2 multi-instance */ 354 u32 bit_depth_chroma; 355 }; 356 u32 error_count; 357 u32 status; 358 u32 frame_count; 359 u32 error_frame_count; 360 u32 drop_frame_count; 361 u64 total_data; 362 union { 363 u32 samp_cnt; 364 /* Effective in h265,vp9,avs2 multi-instance */ 365 u32 double_write_mode; 366 }; 367 u32 offset; 368 u32 ratio_control; 369 char reserved[32]; 370 }; 371 372 struct adec_status { 373 unsigned int channels; 374 unsigned int sample_rate; 375 unsigned int resolution; 376 unsigned int error_count; 377 unsigned int status; 378 }; 379 380 struct am_io_param { 381 union { 382 int data; 383 int id; /* get bufstatus? or others */ 384 }; 385 int len; /* buffer size; */ 386 387 union { 388 389 char buf[1]; 390 391 struct buf_status status; 392 393 struct vdec_status vstatus; 394 struct adec_status astatus; 395 }; 396 }; 397 398 struct am_io_info { 399 union { 400 int data; 401 int id; 402 }; 403 int len; 404 union { 405 char buf[1]; 406 struct vdec_info vinfo; 407 }; 408 }; 409 410 struct audio_info { 411 412 int valid; 413 414 int sample_rate; 415 416 int channels; 417 418 int bitrate; 419 420 int codec_id; 421 422 int block_align; 423 424 int extradata_size; 425 426 char extradata[AUDIO_EXTRA_DATA_SIZE]; 427 }; 428 429 struct dec_sysinfo { 430 431 unsigned int format; 432 433 unsigned int width; 434 435 unsigned int height; 436 437 unsigned int rate; 438 439 unsigned int extra; 440 441 unsigned int status; 442 443 unsigned int ratio; 444 445 void *param; 446 447 unsigned long long ratio64; 448 }; 449 450 struct subtitle_info { 451 452 unsigned char id; 453 454 unsigned char width; 455 456 unsigned char height; 457 458 unsigned char type; 459 }; 460 461 struct codec_profile_t { 462 463 char *name; /* video codec short name */ 464 char *profile; /* Attributes,separated by commas */ 465 }; 466 467 struct userdata_poc_info_t { 468 469 unsigned int poc_info; 470 unsigned int poc_number; 471 /* 472 * bit 0: 473 * 1, group start 474 * 0, not group start 475 * bit 1-2: 476 * 0, extension_and_user_data( 0 ) 477 * 1, extension_and_user_data( 1 ) 478 * 2, extension_and_user_data( 2 ) 479 */ 480 unsigned int flags; 481 unsigned int vpts; 482 unsigned int vpts_valid; 483 unsigned int duration; 484 }; 485 486 struct userdata_meta_info_t { 487 uint32_t poc_number; 488 /************ flags bit defination ***********/ 489 /* 490 * bit 0: //used for mpeg2 491 * 1, group start 492 * 0, not group start 493 * bit 1-2: //used for mpeg2 494 * 0, extension_and_user_data( 0 ) 495 * 1, extension_and_user_data( 1 ) 496 * 2, extension_and_user_data( 2 ) 497 * bit 3-6: //video format 498 * 0, VFORMAT_MPEG12 499 * 1, VFORMAT_MPEG4 500 * 2, VFORMAT_H264 501 * 3, VFORMAT_MJPEG 502 * 4, VFORMAT_REAL 503 * 5, VFORMAT_JPEG 504 * 6, VFORMAT_VC1 505 * 7, VFORMAT_AVS 506 * 8, VFORMAT_SW 507 * 9, VFORMAT_H264MVC 508 * 10, VFORMAT_H264_4K2K 509 * 11, VFORMAT_HEVC 510 * 12, VFORMAT_H264_ENC 511 * 13, VFORMAT_JPEG_ENC 512 * 14, VFORMAT_VP9 513 * bit 7-9: //frame type 514 * 0, Unknown Frame Type 515 * 1, I Frame 516 * 2, B Frame 517 * 3, P Frame 518 * 4, D_Type_MPEG2 519 * bit 10: //top_field_first_flag valid 520 * 0: top_field_first_flag is not valid 521 * 1: top_field_first_flag is valid 522 * bit 11: //top_field_first bit val 523 */ 524 uint32_t flags; 525 uint32_t vpts; /*video frame pts*/ 526 /* 527 * 0: pts is invalid, please use duration to calcuate 528 * 1: pts is valid 529 */ 530 uint32_t vpts_valid; 531 /*duration for frame*/ 532 uint32_t duration; 533 /* how many records left in queue waiting to be read*/ 534 uint32_t records_in_que; 535 unsigned long long priv_data; 536 uint32_t padding_data[4]; 537 }; 538 539 struct userdata_param_t { 540 uint32_t version; 541 uint32_t instance_id; /*input, 0~9*/ 542 uint32_t buf_len; /*input*/ 543 uint32_t data_size; /*output*/ 544 void *pbuf_addr; /*input*/ 545 struct userdata_meta_info_t meta_info; /*output*/ 546 }; 547 548 struct usr_crc_info_t { 549 u32 id; 550 u32 pic_num; 551 u32 y_crc; 552 u32 uv_crc; 553 }; 554 555 /******************************************************************* 556 * 0x100~~0x1FF : set cmd 557 * 0x200~~0x2FF : set ex cmd 558 * 0x300~~0x3FF : set ptr cmd 559 * 0x400~~0x7FF : set reserved cmd 560 * 0x800~~0x8FF : get cmd 561 * 0x900~~0x9FF : get ex cmd 562 * 0xA00~~0xAFF : get ptr cmd 563 * 0xBFF~~0xFFF : get reserved cmd 564 * 0xX00~~0xX5F : amstream cmd(X: cmd type) 565 * 0xX60~~0xXAF : video cmd(X: cmd type) 566 * 0xXAF~~0xXFF : reserved cmd(X: cmd type) 567 ****************************************************************** 568 */ 569 570 /* amstream set cmd */ 571 #define AMSTREAM_SET_VB_START 0x101 572 #define AMSTREAM_SET_VB_SIZE 0x102 573 #define AMSTREAM_SET_AB_START 0x103 574 #define AMSTREAM_SET_AB_SIZE 0x104 575 #define AMSTREAM_SET_VFORMAT 0x105 576 #define AMSTREAM_SET_AFORMAT 0x106 577 #define AMSTREAM_SET_VID 0x107 578 #define AMSTREAM_SET_AID 0x108 579 #define AMSTREAM_SET_SID 0x109 580 #define AMSTREAM_SET_PCRID 0x10A 581 #define AMSTREAM_SET_ACHANNEL 0x10B 582 #define AMSTREAM_SET_SAMPLERATE 0x10C 583 #define AMSTREAM_SET_DATAWIDTH 0x10D 584 #define AMSTREAM_SET_TSTAMP 0x10E 585 #define AMSTREAM_SET_TSTAMP_US64 0x10F 586 #define AMSTREAM_SET_APTS 0x110 587 #define AMSTREAM_PORT_INIT 0x111 588 #define AMSTREAM_SET_TRICKMODE 0x112 /* amstream,video */ 589 #define AMSTREAM_AUDIO_RESET 0x013 590 #define AMSTREAM_SUB_RESET 0x114 591 #define AMSTREAM_DEC_RESET 0x115 592 #define AMSTREAM_SET_TS_SKIPBYTE 0x116 593 #define AMSTREAM_SET_SUB_TYPE 0x117 594 #define AMSTREAM_SET_PCRSCR 0x118 595 #define AMSTREAM_SET_DEMUX 0x119 596 #define AMSTREAM_SET_VIDEO_DELAY_LIMIT_MS 0x11A 597 #define AMSTREAM_SET_AUDIO_DELAY_LIMIT_MS 0x11B 598 #define AMSTREAM_SET_DRMMODE 0x11C 599 600 /* video set cmd */ 601 #define AMSTREAM_SET_OMX_VPTS 0x160 602 #define AMSTREAM_SET_VPAUSE 0x161 603 #define AMSTREAM_SET_AVTHRESH 0x162 604 #define AMSTREAM_SET_SYNCTHRESH 0x163 605 #define AMSTREAM_SET_SYNCENABLE 0x164 606 #define AMSTREAM_SET_SYNC_ADISCON 0x165 607 #define AMSTREAM_SET_SYNC_VDISCON 0x166 608 #define AMSTREAM_SET_SYNC_ADISCON_DIFF 0x167 609 #define AMSTREAM_SET_SYNC_VDISCON_DIFF 0x168 610 #define AMSTREAM_SET_VIDEO_DISABLE 0x169 611 #define AMSTREAM_SET_VIDEO_DISCONTINUE_REPORT 0x16A 612 #define AMSTREAM_SET_SCREEN_MODE 0x16B 613 #define AMSTREAM_SET_BLACKOUT_POLICY 0x16C 614 #define AMSTREAM_CLEAR_VBUF 0x16D 615 #define AMSTREAM_SET_CLEAR_VIDEO 0x16E 616 #define AMSTREAM_SET_FREERUN_MODE 0x16F 617 #define AMSTREAM_SET_DISABLE_SLOW_SYNC 0x170 618 #define AMSTREAM_SET_3D_TYPE 0x171 619 #define AMSTREAM_SET_VSYNC_UPINT 0x172 620 #define AMSTREAM_SET_VSYNC_SLOW_FACTOR 0x173 621 #define AMSTREAM_SET_FRAME_BASE_PATH 0x174 622 #define AMSTREAM_SET_EOS 0x175 623 #define AMSTREAM_SET_RECEIVE_ID 0x176 624 #define AMSTREAM_SET_IS_RESET 0x177 625 #define AMSTREAM_SET_NO_POWERDOWN 0x178 626 #define AMSTREAM_SET_DV_META_WITH_EL 0x179 627 628 629 /* video set ex cmd */ 630 #define AMSTREAM_SET_EX_VIDEO_AXIS 0x260 631 #define AMSTREAM_SET_EX_VIDEO_CROP 0x261 632 633 /* amstream set ptr cmd */ 634 #define AMSTREAM_SET_PTR_AUDIO_INFO 0x300 635 #define AMSTREAM_SET_PTR_CONFIGS 0x301 636 637 /* amstream get cmd */ 638 #define AMSTREAM_GET_SUB_LENGTH 0x800 639 #define AMSTREAM_GET_UD_LENGTH 0x801 640 #define AMSTREAM_GET_APTS_LOOKUP 0x802 641 #define AMSTREAM_GET_FIRST_APTS_FLAG 0x803 642 #define AMSTREAM_GET_APTS 0x804 643 #define AMSTREAM_GET_VPTS 0x805 644 #define AMSTREAM_GET_PCRSCR 0x806 645 #define AMSTREAM_GET_LAST_CHECKIN_APTS 0x807 646 #define AMSTREAM_GET_LAST_CHECKIN_VPTS 0x808 647 #define AMSTREAM_GET_LAST_CHECKOUT_APTS 0x809 648 #define AMSTREAM_GET_LAST_CHECKOUT_VPTS 0x80A 649 #define AMSTREAM_GET_SUB_NUM 0x80B 650 #define AMSTREAM_GET_VIDEO_DELAY_LIMIT_MS 0x80C 651 #define AMSTREAM_GET_AUDIO_DELAY_LIMIT_MS 0x80D 652 #define AMSTREAM_GET_AUDIO_CUR_DELAY_MS 0x80E 653 #define AMSTREAM_GET_VIDEO_CUR_DELAY_MS 0x80F 654 #define AMSTREAM_GET_AUDIO_AVG_BITRATE_BPS 0x810 655 #define AMSTREAM_GET_VIDEO_AVG_BITRATE_BPS 0x811 656 #define AMSTREAM_GET_ION_ID 0x812 657 #define AMSTREAM_GET_NEED_MORE_DATA 0x813 658 #define AMSTREAM_GET_FREED_HANDLE 0x814 659 #define AMSTREAM_GET_VPTS_U64 0x815 660 #define AMSTREAM_GET_APTS_U64 0x816 661 /* video get cmd */ 662 #define AMSTREAM_GET_OMX_VPTS 0x860 663 #define AMSTREAM_GET_TRICK_STAT 0x861 664 #define AMSTREAM_GET_TRICK_VPTS 0x862 665 #define AMSTREAM_GET_SYNC_ADISCON 0x863 666 #define AMSTREAM_GET_SYNC_VDISCON 0x864 667 #define AMSTREAM_GET_SYNC_ADISCON_DIFF 0x865 668 #define AMSTREAM_GET_SYNC_VDISCON_DIFF 0x866 669 #define AMSTREAM_GET_VIDEO_DISABLE 0x867 670 #define AMSTREAM_GET_VIDEO_DISCONTINUE_REPORT 0x868 671 #define AMSTREAM_GET_SCREEN_MODE 0x869 672 #define AMSTREAM_GET_BLACKOUT_POLICY 0x86A 673 #define AMSTREAM_GET_FREERUN_MODE 0x86B 674 #define AMSTREAM_GET_3D_TYPE 0x86C 675 #define AMSTREAM_GET_VSYNC_SLOW_FACTOR 0x86D 676 677 /* amstream get ex cmd */ 678 #define AMSTREAM_GET_EX_VB_STATUS 0x900 679 #define AMSTREAM_GET_EX_AB_STATUS 0x901 680 #define AMSTREAM_GET_EX_VDECSTAT 0x902 681 #define AMSTREAM_GET_EX_ADECSTAT 0x903 682 #define AMSTREAM_GET_EX_UD_POC 0x904 683 684 /* video get ex cmd */ 685 #define AMSTREAM_GET_EX_VF_STATUS 0x960 686 #define AMSTREAM_GET_EX_VIDEO_AXIS 0x961 687 #define AMSTREAM_GET_EX_VIDEO_CROP 0x962 688 689 /* amstream get ptr cmd */ 690 #define AMSTREAM_GET_PTR_SUB_INFO 0xA00 691 692 #define AMSTREAM_IOC_VERSION_FIRST 2 693 #define AMSTREAM_IOC_VERSION_SECOND 0 694 695 struct am_ioctl_parm { 696 union { 697 u32 data_32; 698 u64 data_64; 699 enum vformat_e data_vformat; 700 enum aformat_e data_aformat; 701 enum FRAME_BASE_VIDEO_PATH frame_base_video_path; 702 char data[8]; 703 }; 704 u32 cmd; 705 char reserved[4]; 706 }; 707 708 struct am_ioctl_parm_ex { 709 union { 710 struct buf_status status; 711 struct vdec_status vstatus; 712 struct adec_status astatus; 713 714 struct userdata_poc_info_t data_userdata_info; 715 char data[24]; 716 717 }; 718 u32 cmd; 719 char reserved[4]; 720 }; 721 722 struct am_ioctl_parm_ptr { 723 union { 724 struct audio_info *pdata_audio_info; 725 struct subtitle_info *pdata_sub_info; 726 void *pointer; 727 char data[8]; 728 }; 729 u32 cmd; 730 u32 len; /*char reserved[4]; */ 731 }; 732 733 struct vframe_qos_s { 734 u32 num; 735 u32 type; 736 u32 size; 737 u32 pts; 738 int max_qp; 739 int avg_qp; 740 int min_qp; 741 int max_skip; 742 int avg_skip; 743 int min_skip; 744 int max_mv; 745 int min_mv; 746 int avg_mv; 747 int decode_buffer;//For padding currently 748 } /*vframe_qos */; 749 750 751 struct vframe_comm_s { 752 int vdec_id; 753 char vdec_name[16]; 754 u32 vdec_type; 755 }; 756 757 758 struct vframe_counter_s { 759 struct vframe_qos_s qos; 760 u32 decode_time_cost;/*us*/ 761 u32 frame_width; 762 u32 frame_height; 763 u32 frame_rate; 764 union { 765 u32 bit_rate; 766 /* Effective in h265,vp9,avs2 multi-instance */ 767 u32 bit_depth_luma; 768 }; 769 u32 frame_dur; 770 union { 771 u32 frame_data; 772 /* Effective in h265,vp9,avs2 multi-instance */ 773 u32 bit_depth_chroma; 774 }; 775 u32 error_count; 776 u32 status; 777 u32 frame_count; 778 u32 error_frame_count; 779 u32 drop_frame_count; 780 u64 total_data;//this member must be 8 bytes alignment 781 union { 782 u32 samp_cnt; 783 /* Effective in h265,vp9,avs2 multi-instance */ 784 u32 double_write_mode; 785 }; 786 u32 offset; 787 u32 ratio_control; 788 u32 vf_type; 789 u32 signal_type; 790 u32 pts; 791 u64 pts_us64; 792 }; 793 794 struct vdec_frames_s { 795 u64 hw_decode_start; 796 u64 hw_decode_time; 797 u32 frame_size; 798 u32 rd; 799 u32 wr; 800 struct vframe_comm_s comm; 801 struct vframe_counter_s fifo_buf[NUM_FRAME_VDEC]; 802 }; 803 804 enum FRAME_FORMAT { 805 FRAME_FORMAT_UNKNOWN, 806 FRAME_FORMAT_PROGRESS, 807 FRAME_FORMAT_INTERLACE, 808 }; 809 810 811 struct av_info_t { 812 /*auido info*/ 813 int sample_rate; 814 int channels; 815 int aformat_type; 816 unsigned int apts; 817 unsigned int apts_err; 818 /*video info*/ 819 unsigned int width; 820 unsigned int height; 821 unsigned int dec_error_count; 822 unsigned int first_pic_coming; 823 unsigned int fps; 824 unsigned int current_fps; 825 unsigned int vpts; 826 unsigned int vpts_err; 827 unsigned int ts_error; 828 unsigned int first_vpts; 829 int vformat_type; 830 enum FRAME_FORMAT frame_format; 831 unsigned int toggle_frame_count;/*toggle frame count*/ 832 unsigned int dec_err_frame_count;/*vdec error frame count*/ 833 unsigned int dec_frame_count;/*vdec frame count*/ 834 unsigned int dec_drop_frame_count;/*drop frame num*/ 835 int tsync_mode; 836 unsigned int dec_video_bps;/*video bitrate*/ 837 }; 838 839 struct av_param_info_t { 840 struct av_info_t av_info; 841 }; 842 struct av_param_qosinfo_t { 843 struct vframe_qos_s vframe_qos[QOS_FRAME_NUM]; 844 }; 845 846 /*This is a versioning structure, the key member is the struct_size. 847 *In the 1st version it is not used,but will have its role in fureture. 848 *https://bytes.com/topic/c/answers/811125-struct-versioning 849 */ 850 struct av_param_mvdec_t { 851 int vdec_id; 852 853 /*This member is used for versioning this structure. 854 *When passed from userspace, its value must be 855 *sizeof(struct av_param_mvdec_t) 856 */ 857 int struct_size; 858 859 int slots; 860 861 struct vframe_comm_s comm; 862 struct vframe_counter_s minfo[QOS_FRAME_NUM]; 863 }; 864 865 #define SUPPORT_VDEC_NUM (64) 866 int vcodec_profile_register(const struct codec_profile_t *vdec_profile); 867 ssize_t vcodec_profile_read(char *buf); 868 bool is_support_profile(char *name); 869 #ifdef __KERNEL__ 870 #include <linux/interrupt.h> 871 872 /*TS demux operation interface*/ 873 struct tsdemux_ops { 874 875 int (*reset)(void); 876 877 int (*set_reset_flag)(void); 878 879 int (*request_irq)(irq_handler_t handler, void *data); 880 881 int (*free_irq)(void); 882 883 int (*set_vid)(int vpid); 884 885 int (*set_aid)(int apid); 886 887 int (*set_sid)(int spid); 888 889 int (*set_pcrid)(int pcrpid); 890 891 int (*set_skipbyte)(int skipbyte); 892 893 int (*set_demux)(int dev); 894 }; 895 896 void tsdemux_set_ops(struct tsdemux_ops *ops); 897 int tsdemux_set_reset_flag(void); 898 int amports_switch_gate(const char *name, int enable); 899 900 void set_adec_func(int (*adec_func)(struct adec_status *)); 901 void wakeup_sub_poll(void); 902 void init_userdata_fifo(void); 903 void reset_userdata_fifo(int bInit); 904 int wakeup_userdata_poll(struct userdata_poc_info_t poc, 905 int wp, unsigned long start_phyaddr, 906 int buf_size, int data_length); 907 int get_sub_type(void); 908 909 #endif /**/ 910 911 struct tcon_gamma_table_s { 912 913 u16 data[256]; 914 } /*tcon_gamma_table_t */; 915 916 struct tcon_rgb_ogo_s { 917 918 unsigned int en; 919 920 int r_pre_offset; /* s11.0, range -1024~+1023, default is 0 */ 921 int g_pre_offset; /* s11.0, range -1024~+1023, default is 0 */ 922 int b_pre_offset; /* s11.0, range -1024~+1023, default is 0 */ 923 unsigned int r_gain; /* u1.10, range 0~2047, default is 1024 (1.0x) */ 924 unsigned int g_gain; /* u1.10, range 0~2047, default is 1024 (1.0x) */ 925 unsigned int b_gain; /* u1.10, range 0~2047, default is 1024 (1.0x) */ 926 int r_post_offset; /* s11.0, range -1024~+1023, default is 0 */ 927 int g_post_offset; /* s11.0, range -1024~+1023, default is 0 */ 928 int b_post_offset; /* s11.0, range -1024~+1023, default is 0 */ 929 } /*tcon_rgb_ogo_t */; 930 931 #endif /* AMSTREAM_H */ 932