• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __RK_MPI_CMD_H__
17 #define __RK_MPI_CMD_H__
18 
19 
20 #include "rk_venc_cfg.h"
21 #include "rk_venc_ref.h"
22 
23 /*
24  * Command id bit usage is defined as follows:
25  * bit 20 - 23  - module id
26  * bit 16 - 19  - contex id
27  * bit  0 - 15  - command id
28  */
29 #define CMD_MODULE_ID_MASK              (0x00F00000)
30 #define CMD_MODULE_OSAL                 (0x00100000)
31 #define CMD_MODULE_MPP                  (0x00200000)
32 #define CMD_MODULE_CODEC                (0x00300000)
33 #define CMD_MODULE_HAL                  (0x00400000)
34 
35 #define CMD_CTX_ID_MASK                 (0x000F0000)
36 #define CMD_CTX_ID_DEC                  (0x00010000)
37 #define CMD_CTX_ID_ENC                  (0x00020000)
38 #define CMD_CTX_ID_ISP                  (0x00030000)
39 
40 /* separate encoder / decoder control command to different segment */
41 #define CMD_CFG_ID_MASK                 (0x0000FF00)
42 
43 /* decoder control command */
44 #define CMD_DEC_CFG_ALL                 (0x00000000)
45 #define CMD_DEC_QUERY                   (0x00000100)
46 #define CMD_DEC_CFG                     (0x00000200)
47 
48 /* encoder control command */
49 #define CMD_ENC_CFG_ALL                 (0x00000000)
50 #define CMD_ENC_CFG_RC_API              (0x00000100)
51 
52 #define CMD_ENC_CFG_MISC                (0x00008000)
53 #define CMD_ENC_CFG_SPLIT               (0x00008100)
54 #define CMD_ENC_CFG_REF                 (0x00008200)
55 #define CMD_ENC_CFG_ROI                 (0x00008300)
56 #define CMD_ENC_CFG_OSD                 (0x00008400)
57 
58 typedef enum {
59     MPP_OSAL_CMD_BASE                   = CMD_MODULE_OSAL,
60     MPP_OSAL_CMD_END,
61 
62     MPP_CMD_BASE                        = CMD_MODULE_MPP,
63     MPP_ENABLE_DEINTERLACE,
64     MPP_SET_INPUT_BLOCK,                /* deprecated */
65     MPP_SET_INTPUT_BLOCK_TIMEOUT,       /* deprecated */
66     MPP_SET_OUTPUT_BLOCK,               /* deprecated */
67     MPP_SET_OUTPUT_BLOCK_TIMEOUT,       /* deprecated */
68     /*
69      * timeout setup, refer to  MPP_TIMEOUT_XXX
70      * zero     - non block
71      * negative - block with no timeout
72      * positive - timeout in milisecond
73      */
74     MPP_SET_INPUT_TIMEOUT,              /* parameter type RK_S64 */
75     MPP_SET_OUTPUT_TIMEOUT,             /* parameter type RK_S64 */
76     MPP_CMD_END,
77 
78     MPP_CODEC_CMD_BASE                  = CMD_MODULE_CODEC,
79     MPP_CODEC_GET_FRAME_INFO,
80     MPP_CODEC_CMD_END,
81 
82     MPP_DEC_CMD_BASE                    = CMD_MODULE_CODEC | CMD_CTX_ID_DEC,
83     MPP_DEC_SET_FRAME_INFO,             /* vpu api legacy control for buffer slot dimension init */
84     MPP_DEC_SET_EXT_BUF_GROUP,          /* IMPORTANT: set external buffer group to mpp decoder */
85     MPP_DEC_SET_INFO_CHANGE_READY,
86     MPP_DEC_SET_PRESENT_TIME_ORDER,     /* use input time order for output */
87     MPP_DEC_SET_PARSER_SPLIT_MODE,      /* Need to setup before init */
88     MPP_DEC_SET_PARSER_FAST_MODE,       /* Need to setup before init */
89     MPP_DEC_GET_STREAM_COUNT,
90     MPP_DEC_GET_VPUMEM_USED_COUNT,
91     MPP_DEC_SET_VC1_EXTRA_DATA,
92     MPP_DEC_SET_OUTPUT_FORMAT,
93     MPP_DEC_SET_DISABLE_ERROR,          /* When set it will disable sw/hw error (H.264 / H.265) */
94     MPP_DEC_SET_IMMEDIATE_OUT,
95     MPP_DEC_SET_ENABLE_DEINTERLACE,     /* MPP enable deinterlace by default. Vpuapi can disable it */
96 
97     MPP_DEC_CMD_QUERY                   = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_QUERY,
98     /* query decoder runtime information for decode stage */
99     MPP_DEC_QUERY,                      /* set and get MppDecQueryCfg structure */
100 
101     CMD_DEC_CMD_CFG                     = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_CFG,
102     MPP_DEC_SET_CFG,                    /* set MppDecCfg structure */
103     MPP_DEC_GET_CFG,                    /* get MppDecCfg structure */
104 
105     MPP_DEC_CMD_END,
106 
107     MPP_ENC_CMD_BASE                    = CMD_MODULE_CODEC | CMD_CTX_ID_ENC,
108     /* basic encoder setup control */
109     MPP_ENC_SET_CFG,                    /* set MppEncCfg structure */
110     MPP_ENC_GET_CFG,                    /* get MppEncCfg structure */
111     MPP_ENC_SET_PREP_CFG,               /* deprecated set MppEncPrepCfg structure, use MPP_ENC_SET_CFG instead */
112     MPP_ENC_GET_PREP_CFG,               /* deprecated get MppEncPrepCfg structure, use MPP_ENC_GET_CFG instead */
113     MPP_ENC_SET_RC_CFG,                 /* deprecated set MppEncRcCfg structure, use MPP_ENC_SET_CFG instead */
114     MPP_ENC_GET_RC_CFG,                 /* deprecated get MppEncRcCfg structure, use MPP_ENC_GET_CFG instead */
115     MPP_ENC_SET_CODEC_CFG,              /* deprecated set MppEncCodecCfg structure, use MPP_ENC_SET_CFG instead */
116     MPP_ENC_GET_CODEC_CFG,              /* deprecated get MppEncCodecCfg structure, use MPP_ENC_GET_CFG instead */
117     /* runtime encoder setup control */
118     MPP_ENC_SET_IDR_FRAME,              /* next frame will be encoded as intra frame */
119     MPP_ENC_SET_OSD_LEGACY_0,           /* deprecated */
120     MPP_ENC_SET_OSD_LEGACY_1,           /* deprecated */
121     MPP_ENC_SET_OSD_LEGACY_2,           /* deprecated */
122     MPP_ENC_GET_HDR_SYNC,               /* get vps / sps / pps which has better sync behavior parameter is MppPacket */
123     MPP_ENC_GET_EXTRA_INFO,             /* deprecated */
124     MPP_ENC_SET_SEI_CFG,                /* SEI: Supplement Enhancemant Information, parameter is MppSeiMode */
125     MPP_ENC_GET_SEI_DATA,               /* SEI: Supplement Enhancemant Information, parameter is MppPacket */
126     MPP_ENC_PRE_ALLOC_BUFF,             /* deprecated */
127     MPP_ENC_SET_QP_RANGE,               /* used for adjusting qp range, the parameter can be 1 or 2 */
128     MPP_ENC_SET_ROI_CFG,                /* set MppEncROICfg structure */
129     MPP_ENC_SET_CTU_QP,                 /* for H265 Encoder,set CTU's size and QP */
130 
131     /* User define rate control stategy API control */
132     MPP_ENC_CFG_RC_API                  = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_RC_API,
133     /*
134      * Get RcApiQueryAll structure
135      * Get all available rate control stategy string and count
136      */
137     MPP_ENC_GET_RC_API_ALL              = MPP_ENC_CFG_RC_API + 1,
138     /*
139      * Get RcApiQueryType structure
140      * Get available rate control stategy string with certain type
141      */
142     MPP_ENC_GET_RC_API_BY_TYPE          = MPP_ENC_CFG_RC_API + 2,
143     /*
144      * Set RcImplApi structure
145      * Add new or update rate control stategy function pointers
146      */
147     MPP_ENC_SET_RC_API_CFG              = MPP_ENC_CFG_RC_API + 3,
148     /*
149      * Get RcApiBrief structure
150      * Get current used rate control stategy brief information (type and name)
151      */
152     MPP_ENC_GET_RC_API_CURRENT          = MPP_ENC_CFG_RC_API + 4,
153     /*
154      * Set RcApiBrief structure
155      * Set current used rate control stategy brief information (type and name)
156      */
157     MPP_ENC_SET_RC_API_CURRENT          = MPP_ENC_CFG_RC_API + 5,
158 
159     MPP_ENC_CFG_MISC                    = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_MISC,
160     /* set MppEncHeaderMode */
161     MPP_ENC_SET_HEADER_MODE,
162     /* get MppEncHeaderMode */
163     MPP_ENC_GET_HEADER_MODE,
164 
165     MPP_ENC_CFG_SPLIT = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_SPLIT,
166     /* set MppEncSliceSplit structure */
167     MPP_ENC_SET_SPLIT,
168     /* get MppEncSliceSplit structure */
169     MPP_ENC_GET_SPLIT,
170 
171     MPP_ENC_CFG_REF = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_REF,
172     /* set MppEncRefCfg structure */
173     MPP_ENC_SET_REF_CFG,
174 
175     MPP_ENC_CFG_OSD = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_OSD,
176     /* set OSD palette, parameter should be pointer to MppEncOSDPltCfg */
177     MPP_ENC_SET_OSD_PLT_CFG,
178     /* get OSD palette, parameter should be pointer to MppEncOSDPltCfg */
179     MPP_ENC_GET_OSD_PLT_CFG,
180     /* set OSD data with at most 8 regions, parameter should be pointer to MppEncOSDData */
181     MPP_ENC_SET_OSD_DATA_CFG,
182 
183     MPP_ENC_CMD_END,
184 
185     MPP_ISP_CMD_BASE                    = CMD_MODULE_CODEC | CMD_CTX_ID_ISP,
186     MPP_ISP_CMD_END,
187 
188     MPP_HAL_CMD_BASE                    = CMD_MODULE_HAL,
189     MPP_HAL_CMD_END,
190 
191     MPI_CMD_BUTT,
192 } MpiCmd;
193 
194 #endif /* __RK_MPI_CMD_H__ */
195