xref: /OK3568_Linux_fs/external/mpp/mpp/hal/inc/mpp_enc_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_ENC_HAL_H__
18 #define __MPP_ENC_HAL_H__
19 
20 #include "hal_enc_task.h"
21 #include "mpp_enc_cfg.h"
22 #include "mpp_device.h"
23 
24 typedef struct MppEncHalCfg_t {
25     // input for encoder
26     MppCodingType   coding;
27     MppEncCfgSet    *cfg;
28     MppCbCtx        *output_cb;
29     RK_S32          task_cnt;
30 
31     // output from enc_impl
32     MppClientType   type;
33     MppDev          dev;
34     RK_S32          cap_recn_out;
35     HalTaskGroup    tasks;
36 } MppEncHalCfg;
37 
38 typedef struct MppEncHalApi_t {
39     char            *name;
40     MppCodingType   coding;
41     RK_U32          ctx_size;
42     RK_U32          flag;
43 
44     MPP_RET (*init)(void *ctx, MppEncHalCfg *cfg);
45     MPP_RET (*deinit)(void *ctx);
46 
47     // prepare function after encoder config is set
48     MPP_RET (*prepare)(void *ctx);
49 
50     // configure function
51     MPP_RET (*get_task)(void *ctx, HalEncTask *task);
52     MPP_RET (*gen_regs)(void *ctx, HalEncTask *task);
53 
54     // hw operation function
55     MPP_RET (*start)(void *ctx, HalEncTask *task);
56     MPP_RET (*wait)(void *ctx, HalEncTask *task);
57     MPP_RET (*part_start)(void *ctx, HalEncTask *task);
58     MPP_RET (*part_wait)(void *ctx, HalEncTask *task);
59 
60     // return function
61     MPP_RET (*ret_task)(void *ctx, HalEncTask *task);
62 } MppEncHalApi;
63 
64 typedef void* MppEncHal;
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 MPP_RET mpp_enc_hal_init(MppEncHal *ctx, MppEncHalCfg *cfg);
71 MPP_RET mpp_enc_hal_deinit(MppEncHal ctx);
72 
73 /* prepare after cfg */
74 MPP_RET mpp_enc_hal_prepare(MppEncHal ctx);
75 
76 MPP_RET mpp_enc_hal_get_task(MppEncHal ctx, HalEncTask *task);
77 MPP_RET mpp_enc_hal_gen_regs(MppEncHal ctx, HalEncTask *task);
78 
79 // start / wait hardware
80 MPP_RET mpp_enc_hal_start(MppEncHal ctx, HalEncTask *task);
81 MPP_RET mpp_enc_hal_wait(MppEncHal ctx, HalEncTask *task);
82 MPP_RET mpp_enc_hal_part_start(MppEncHal ctx, HalEncTask *task);
83 MPP_RET mpp_enc_hal_part_wait(MppEncHal ctx, HalEncTask *task);
84 
85 MPP_RET mpp_enc_hal_ret_task(MppEncHal ctx, HalEncTask *task);
86 
87 MPP_RET mpp_enc_hal_check_part_mode(MppEncHal ctx);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif /*__MPP_ENC_HAL_H__*/
94