13d0407baSopenharmony_ci/* 23d0407baSopenharmony_ci * Copyright (c) 2021 Rockchip Electronics Co., Ltd. 33d0407baSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43d0407baSopenharmony_ci * you may not use this file except in compliance with the License. 53d0407baSopenharmony_ci * You may obtain a copy of the License at 63d0407baSopenharmony_ci * 73d0407baSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83d0407baSopenharmony_ci * 93d0407baSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103d0407baSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113d0407baSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123d0407baSopenharmony_ci * See the License for the specific language governing permissions and 133d0407baSopenharmony_ci * limitations under the License. 143d0407baSopenharmony_ci */ 153d0407baSopenharmony_ci 163d0407baSopenharmony_ci#ifndef H__RK_MPI_CMD_H__ 173d0407baSopenharmony_ci#define H__RK_MPI_CMD_H__ 183d0407baSopenharmony_ci 193d0407baSopenharmony_ci#include "rk_vdec_cmd.h" 203d0407baSopenharmony_ci#include "rk_vdec_cfg.h" 213d0407baSopenharmony_ci#include "rk_venc_cmd.h" 223d0407baSopenharmony_ci#include "rk_venc_cfg.h" 233d0407baSopenharmony_ci#include "rk_venc_ref.h" 243d0407baSopenharmony_ci/* 253d0407baSopenharmony_ci * Command id bit usage is defined as follows: 263d0407baSopenharmony_ci * bit 20 - 23 - module id 273d0407baSopenharmony_ci * bit 16 - 19 - contex id 283d0407baSopenharmony_ci * bit 0 - 15 - command id 293d0407baSopenharmony_ci */ 303d0407baSopenharmony_ci#define CMD_MODULE_ID_MASK (0x00F00000) 313d0407baSopenharmony_ci#define CMD_MODULE_OSAL (0x00100000) 323d0407baSopenharmony_ci#define CMD_MODULE_MPP (0x00200000) 333d0407baSopenharmony_ci#define CMD_MODULE_CODEC (0x00300000) 343d0407baSopenharmony_ci#define CMD_MODULE_HAL (0x00400000) 353d0407baSopenharmony_ci 363d0407baSopenharmony_ci#define CMD_CTX_ID_MASK (0x000F0000) 373d0407baSopenharmony_ci#define CMD_CTX_ID_DEC (0x00010000) 383d0407baSopenharmony_ci#define CMD_CTX_ID_ENC (0x00020000) 393d0407baSopenharmony_ci#define CMD_CTX_ID_ISP (0x00030000) 403d0407baSopenharmony_ci 413d0407baSopenharmony_ci/* separate encoder / decoder control command to different segment */ 423d0407baSopenharmony_ci#define CMD_CFG_ID_MASK (0x0000FF00) 433d0407baSopenharmony_ci 443d0407baSopenharmony_ci/* decoder control command */ 453d0407baSopenharmony_ci#define CMD_DEC_CFG_ALL (0x00000000) 463d0407baSopenharmony_ci#define CMD_DEC_QUERY (0x00000100) 473d0407baSopenharmony_ci#define CMD_DEC_CFG (0x00000200) 483d0407baSopenharmony_ci 493d0407baSopenharmony_ci/* encoder control command */ 503d0407baSopenharmony_ci#define CMD_ENC_CFG_ALL (0x00000000) 513d0407baSopenharmony_ci#define CMD_ENC_CFG_RC_API (0x00000100) 523d0407baSopenharmony_ci 533d0407baSopenharmony_ci#define CMD_ENC_CFG_MISC (0x00008000) 543d0407baSopenharmony_ci#define CMD_ENC_CFG_SPLIT (0x00008100) 553d0407baSopenharmony_ci#define CMD_ENC_CFG_REF (0x00008200) 563d0407baSopenharmony_ci#define CMD_ENC_CFG_ROI (0x00008300) 573d0407baSopenharmony_ci#define CMD_ENC_CFG_OSD (0x00008400) 583d0407baSopenharmony_ci 593d0407baSopenharmony_citypedef enum { 603d0407baSopenharmony_ci MPP_OSAL_CMD_BASE = CMD_MODULE_OSAL, 613d0407baSopenharmony_ci MPP_OSAL_CMD_END, 623d0407baSopenharmony_ci 633d0407baSopenharmony_ci MPP_CMD_BASE = CMD_MODULE_MPP, 643d0407baSopenharmony_ci MPP_ENABLE_DEINTERLACE, 653d0407baSopenharmony_ci MPP_SET_INPUT_BLOCK, /* deprecated */ 663d0407baSopenharmony_ci MPP_SET_INTPUT_BLOCK_TIMEOUT, /* deprecated */ 673d0407baSopenharmony_ci MPP_SET_OUTPUT_BLOCK, /* deprecated */ 683d0407baSopenharmony_ci MPP_SET_OUTPUT_BLOCK_TIMEOUT, /* deprecated */ 693d0407baSopenharmony_ci /* 703d0407baSopenharmony_ci * timeout setup, refer to MPP_TIMEOUT_XXX 713d0407baSopenharmony_ci * zero - non block 723d0407baSopenharmony_ci * negative - block with no timeout 733d0407baSopenharmony_ci * positive - timeout in milisecond 743d0407baSopenharmony_ci */ 753d0407baSopenharmony_ci MPP_SET_INPUT_TIMEOUT, /* parameter type RK_S64 */ 763d0407baSopenharmony_ci MPP_SET_OUTPUT_TIMEOUT, /* parameter type RK_S64 */ 773d0407baSopenharmony_ci MPP_CMD_END, 783d0407baSopenharmony_ci 793d0407baSopenharmony_ci MPP_CODEC_CMD_BASE = CMD_MODULE_CODEC, 803d0407baSopenharmony_ci MPP_CODEC_GET_FRAME_INFO, 813d0407baSopenharmony_ci MPP_CODEC_CMD_END, 823d0407baSopenharmony_ci 833d0407baSopenharmony_ci MPP_DEC_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_DEC, 843d0407baSopenharmony_ci MPP_DEC_SET_FRAME_INFO, /* vpu api legacy control for buffer slot dimension init */ 853d0407baSopenharmony_ci MPP_DEC_SET_EXT_BUF_GROUP, /* IMPORTANT: set external buffer group to mpp decoder */ 863d0407baSopenharmony_ci MPP_DEC_SET_INFO_CHANGE_READY, 873d0407baSopenharmony_ci MPP_DEC_SET_PRESENT_TIME_ORDER, /* use input time order for output */ 883d0407baSopenharmony_ci MPP_DEC_SET_PARSER_SPLIT_MODE, /* Need to setup before init */ 893d0407baSopenharmony_ci MPP_DEC_SET_PARSER_FAST_MODE, /* Need to setup before init */ 903d0407baSopenharmony_ci MPP_DEC_GET_STREAM_COUNT, 913d0407baSopenharmony_ci MPP_DEC_GET_VPUMEM_USED_COUNT, 923d0407baSopenharmony_ci MPP_DEC_SET_VC1_EXTRA_DATA, 933d0407baSopenharmony_ci MPP_DEC_SET_OUTPUT_FORMAT, 943d0407baSopenharmony_ci MPP_DEC_SET_DISABLE_ERROR, /* When set it will disable sw/hw error (H.264 / H.265) */ 953d0407baSopenharmony_ci MPP_DEC_SET_IMMEDIATE_OUT, 963d0407baSopenharmony_ci MPP_DEC_SET_ENABLE_DEINTERLACE, /* MPP enable deinterlace by default. Vpuapi can disable it */ 973d0407baSopenharmony_ci 983d0407baSopenharmony_ci MPP_DEC_CMD_QUERY = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_QUERY, 993d0407baSopenharmony_ci /* query decoder runtime information for decode stage */ 1003d0407baSopenharmony_ci MPP_DEC_QUERY, /* set and get MppDecQueryCfg structure */ 1013d0407baSopenharmony_ci 1023d0407baSopenharmony_ci CMD_DEC_CMD_CFG = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_CFG, 1033d0407baSopenharmony_ci MPP_DEC_SET_CFG, /* set MppDecCfg structure */ 1043d0407baSopenharmony_ci MPP_DEC_GET_CFG, /* get MppDecCfg structure */ 1053d0407baSopenharmony_ci 1063d0407baSopenharmony_ci MPP_DEC_CMD_END, 1073d0407baSopenharmony_ci 1083d0407baSopenharmony_ci MPP_ENC_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_ENC, 1093d0407baSopenharmony_ci /* basic encoder setup control */ 1103d0407baSopenharmony_ci MPP_ENC_SET_CFG, /* set MppEncCfg structure */ 1113d0407baSopenharmony_ci MPP_ENC_GET_CFG, /* get MppEncCfg structure */ 1123d0407baSopenharmony_ci MPP_ENC_SET_PREP_CFG, /* deprecated set MppEncPrepCfg structure, use MPP_ENC_SET_CFG instead */ 1133d0407baSopenharmony_ci MPP_ENC_GET_PREP_CFG, /* deprecated get MppEncPrepCfg structure, use MPP_ENC_GET_CFG instead */ 1143d0407baSopenharmony_ci MPP_ENC_SET_RC_CFG, /* deprecated set MppEncRcCfg structure, use MPP_ENC_SET_CFG instead */ 1153d0407baSopenharmony_ci MPP_ENC_GET_RC_CFG, /* deprecated get MppEncRcCfg structure, use MPP_ENC_GET_CFG instead */ 1163d0407baSopenharmony_ci MPP_ENC_SET_CODEC_CFG, /* deprecated set MppEncCodecCfg structure, use MPP_ENC_SET_CFG instead */ 1173d0407baSopenharmony_ci MPP_ENC_GET_CODEC_CFG, /* deprecated get MppEncCodecCfg structure, use MPP_ENC_GET_CFG instead */ 1183d0407baSopenharmony_ci /* runtime encoder setup control */ 1193d0407baSopenharmony_ci MPP_ENC_SET_IDR_FRAME, /* next frame will be encoded as intra frame */ 1203d0407baSopenharmony_ci MPP_ENC_SET_OSD_LEGACY_0, /* deprecated */ 1213d0407baSopenharmony_ci MPP_ENC_SET_OSD_LEGACY_1, /* deprecated */ 1223d0407baSopenharmony_ci MPP_ENC_SET_OSD_LEGACY_2, /* deprecated */ 1233d0407baSopenharmony_ci MPP_ENC_GET_HDR_SYNC, /* get vps / sps / pps which has better sync behavior parameter is MppPacket */ 1243d0407baSopenharmony_ci MPP_ENC_GET_EXTRA_INFO, /* deprecated */ 1253d0407baSopenharmony_ci MPP_ENC_SET_SEI_CFG, /* SEI: Supplement Enhancemant Information, parameter is MppSeiMode */ 1263d0407baSopenharmony_ci MPP_ENC_GET_SEI_DATA, /* SEI: Supplement Enhancemant Information, parameter is MppPacket */ 1273d0407baSopenharmony_ci MPP_ENC_PRE_ALLOC_BUFF, /* deprecated */ 1283d0407baSopenharmony_ci MPP_ENC_SET_QP_RANGE, /* used for adjusting qp range, the parameter can be 1 or 2 */ 1293d0407baSopenharmony_ci MPP_ENC_SET_ROI_CFG, /* set MppEncROICfg structure */ 1303d0407baSopenharmony_ci MPP_ENC_SET_CTU_QP, /* for H265 Encoder,set CTU's size and QP */ 1313d0407baSopenharmony_ci 1323d0407baSopenharmony_ci /* User define rate control stategy API control */ 1333d0407baSopenharmony_ci MPP_ENC_CFG_RC_API = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_RC_API, 1343d0407baSopenharmony_ci /* 1353d0407baSopenharmony_ci * Get RcApiQueryAll structure 1363d0407baSopenharmony_ci * Get all available rate control stategy string and count 1373d0407baSopenharmony_ci */ 1383d0407baSopenharmony_ci MPP_ENC_GET_RC_API_ALL = MPP_ENC_CFG_RC_API + 1, 1393d0407baSopenharmony_ci /* 1403d0407baSopenharmony_ci * Get RcApiQueryType structure 1413d0407baSopenharmony_ci * Get available rate control stategy string with certain type 1423d0407baSopenharmony_ci */ 1433d0407baSopenharmony_ci MPP_ENC_GET_RC_API_BY_TYPE = MPP_ENC_CFG_RC_API + 2, 1443d0407baSopenharmony_ci /* 1453d0407baSopenharmony_ci * Set RcImplApi structure 1463d0407baSopenharmony_ci * Add new or update rate control stategy function pointers 1473d0407baSopenharmony_ci */ 1483d0407baSopenharmony_ci MPP_ENC_SET_RC_API_CFG = MPP_ENC_CFG_RC_API + 3, 1493d0407baSopenharmony_ci /* 1503d0407baSopenharmony_ci * Get RcApiBrief structure 1513d0407baSopenharmony_ci * Get current used rate control stategy brief information (type and name) 1523d0407baSopenharmony_ci */ 1533d0407baSopenharmony_ci MPP_ENC_GET_RC_API_CURRENT = MPP_ENC_CFG_RC_API + 4, 1543d0407baSopenharmony_ci /* 1553d0407baSopenharmony_ci * Set RcApiBrief structure 1563d0407baSopenharmony_ci * Set current used rate control stategy brief information (type and name) 1573d0407baSopenharmony_ci */ 1583d0407baSopenharmony_ci MPP_ENC_SET_RC_API_CURRENT = MPP_ENC_CFG_RC_API + 5, 1593d0407baSopenharmony_ci 1603d0407baSopenharmony_ci MPP_ENC_CFG_MISC = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_MISC, 1613d0407baSopenharmony_ci /* set MppEncHeaderMode */ 1623d0407baSopenharmony_ci MPP_ENC_SET_HEADER_MODE, 1633d0407baSopenharmony_ci /* get MppEncHeaderMode */ 1643d0407baSopenharmony_ci MPP_ENC_GET_HEADER_MODE, 1653d0407baSopenharmony_ci 1663d0407baSopenharmony_ci MPP_ENC_CFG_SPLIT = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_SPLIT, 1673d0407baSopenharmony_ci /* set MppEncSliceSplit structure */ 1683d0407baSopenharmony_ci MPP_ENC_SET_SPLIT, 1693d0407baSopenharmony_ci /* get MppEncSliceSplit structure */ 1703d0407baSopenharmony_ci MPP_ENC_GET_SPLIT, 1713d0407baSopenharmony_ci 1723d0407baSopenharmony_ci MPP_ENC_CFG_REF = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_REF, 1733d0407baSopenharmony_ci /* set MppEncRefCfg structure */ 1743d0407baSopenharmony_ci MPP_ENC_SET_REF_CFG, 1753d0407baSopenharmony_ci 1763d0407baSopenharmony_ci MPP_ENC_CFG_OSD = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_OSD, 1773d0407baSopenharmony_ci /* set OSD palette, parameter should be pointer to MppEncOSDPltCfg */ 1783d0407baSopenharmony_ci MPP_ENC_SET_OSD_PLT_CFG, 1793d0407baSopenharmony_ci /* get OSD palette, parameter should be pointer to MppEncOSDPltCfg */ 1803d0407baSopenharmony_ci MPP_ENC_GET_OSD_PLT_CFG, 1813d0407baSopenharmony_ci /* set OSD data with at most 8 regions, parameter should be pointer to MppEncOSDData */ 1823d0407baSopenharmony_ci MPP_ENC_SET_OSD_DATA_CFG, 1833d0407baSopenharmony_ci 1843d0407baSopenharmony_ci MPP_ENC_CMD_END, 1853d0407baSopenharmony_ci 1863d0407baSopenharmony_ci MPP_ISP_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_ISP, 1873d0407baSopenharmony_ci MPP_ISP_CMD_END, 1883d0407baSopenharmony_ci 1893d0407baSopenharmony_ci MPP_HAL_CMD_BASE = CMD_MODULE_HAL, 1903d0407baSopenharmony_ci MPP_HAL_CMD_END, 1913d0407baSopenharmony_ci 1923d0407baSopenharmony_ci MPI_CMD_BUTT, 1933d0407baSopenharmony_ci} MpiCmd; 1943d0407baSopenharmony_ci 1953d0407baSopenharmony_ci#endif /* __RK_MPI_CMD_H__ */ 196