xref: /rockchip-linux_mpp/mpp/hal/inc/mpp_hal.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
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     SlotHalFbcAdjCfg    *hal_fbc_adj_cfg;
53 } MppHalCfg;
54 
55 typedef struct MppHalApi_t {
56     char            *name;
57     MppCtxType      type;
58     MppCodingType   coding;
59     RK_U32          ctx_size;
60     RK_U32          flag;
61 
62     MPP_RET (*init)(void *ctx, MppHalCfg *cfg);
63     MPP_RET (*deinit)(void *ctx);
64 
65     // task preprocess function
66     MPP_RET (*reg_gen)(void *ctx, HalTaskInfo *syn);
67 
68     // hw operation function
69     MPP_RET (*start)(void *ctx, HalTaskInfo *task);
70     MPP_RET (*wait)(void *ctx, HalTaskInfo *task);
71 
72     MPP_RET (*reset)(void *ctx);
73     MPP_RET (*flush)(void *ctx);
74     MPP_RET (*control)(void *ctx, MpiCmd cmd, void *param);
75 } MppHalApi;
76 
77 typedef void* MppHal;
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg);
84 MPP_RET mpp_hal_deinit(MppHal ctx);
85 
86 MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTaskInfo *task);
87 MPP_RET mpp_hal_hw_start(MppHal ctx, HalTaskInfo *task);
88 MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTaskInfo *task);
89 
90 MPP_RET mpp_hal_reset(MppHal ctx);
91 MPP_RET mpp_hal_flush(MppHal ctx);
92 MPP_RET mpp_hal_control(MppHal ctx, MpiCmd cmd, void *param);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /*__MPP_HAL_H__*/
99