xref: /OK3568_Linux_fs/external/mpp/mpp/hal/inc/mpp_hal.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __MPP_HAL_H__
18 #define __MPP_HAL_H__
19 
20 #include "rk_mpi_cmd.h"
21 
22 #include "mpp_buf_slot.h"
23 #include "mpp_platform.h"
24 
25 #include "hal_dec_task.h"
26 #include "mpp_dec_cfg.h"
27 #include "mpp_device.h"
28 
29 typedef enum VpuHwMode_e {
30     MODE_NULL   = 0,
31     RKVDEC_MODE = 0x01,
32     VDPU1_MODE  = 0x02,
33     VDPU2_MODE  = 0x04,
34     RKVENC_MODE = 0x05,
35     MODE_BUTT,
36 } VpuHwMode;
37 
38 typedef struct MppHalCfg_t {
39     // input
40     MppCtxType          type;
41     MppCodingType       coding;
42     MppBufSlots         frame_slots;
43     MppBufSlots         packet_slots;
44     MppDecCfgSet        *cfg;
45     MppCbCtx            *dec_cb;
46 
47     // output from hardware module
48     const MppDecHwCap   *hw_info;
49     // codec dev
50     MppDev              dev;
51     RK_S32              support_fast_mode;
52 } MppHalCfg;
53 
54 typedef struct MppHalApi_t {
55     char            *name;
56     MppCtxType      type;
57     MppCodingType   coding;
58     RK_U32          ctx_size;
59     RK_U32          flag;
60 
61     MPP_RET (*init)(void *ctx, MppHalCfg *cfg);
62     MPP_RET (*deinit)(void *ctx);
63 
64     // task preprocess function
65     MPP_RET (*reg_gen)(void *ctx, HalTaskInfo *syn);
66 
67     // hw operation function
68     MPP_RET (*start)(void *ctx, HalTaskInfo *task);
69     MPP_RET (*wait)(void *ctx, HalTaskInfo *task);
70 
71     MPP_RET (*reset)(void *ctx);
72     MPP_RET (*flush)(void *ctx);
73     MPP_RET (*control)(void *ctx, MpiCmd cmd, void *param);
74 } MppHalApi;
75 
76 typedef void* MppHal;
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg);
83 MPP_RET mpp_hal_deinit(MppHal ctx);
84 
85 MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTaskInfo *task);
86 MPP_RET mpp_hal_hw_start(MppHal ctx, HalTaskInfo *task);
87 MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTaskInfo *task);
88 
89 MPP_RET mpp_hal_reset(MppHal ctx);
90 MPP_RET mpp_hal_flush(MppHal ctx);
91 MPP_RET mpp_hal_control(MppHal ctx, MpiCmd cmd, void *param);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /*__MPP_HAL_H__*/
98