hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * Copyright 2015 Rockchip Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#ifndef __MPP_DEC_IMPL_H__
#define __MPP_DEC_IMPL_H__
 
#include "mpp_time.h"
#include "mpp_mem_pool.h"
#include "mpp_lock.h"
#include "hal_info.h"
 
#include "mpp.h"
#include "mpp_dec_cfg.h"
#include "mpp_callback.h"
 
#include "mpp_parser.h"
#include "mpp_hal.h"
 
// for timing record
typedef enum MppDecTimingType_e {
    DEC_PRS_TOTAL,
    DEC_PRS_WAIT,
    DEC_PRS_PROC,
    DEC_PRS_PREPARE,
    DEC_PRS_PARSE,
    DEC_HAL_GEN_REG,
    DEC_HW_START,
 
    DEC_HAL_TOTAL,
    DEC_HAL_WAIT,
    DEC_HAL_PROC,
    DEC_HW_WAIT,
    DEC_TIMING_BUTT,
} MppDecTimingType;
 
typedef struct MppDecImpl_t {
    MppCodingType       coding;
 
    Parser              parser;
    MppHal              hal;
 
    // worker thread
    MppThread           *thread_parser;
    MppThread           *thread_hal;
 
    // common resource
    MppBufSlots         frame_slots;
    MppBufSlots         packet_slots;
    MppCbCtx            dec_cb;
    const MppDecHwCap   *hw_info;
    MppDev              dev;
    HalInfo             hal_info;
    RK_U32              info_updated;
 
    HalTaskGroup        tasks;
    HalTaskGroup        vproc_tasks;
 
    // runtime configure set
    MppDecCfgSet        cfg;
 
    /* control process */
    Mutex               *cmd_lock;
    RK_U32              cmd_send;
    RK_U32              cmd_recv;
    MpiCmd              cmd;
    void                *param;
    MPP_RET             *cmd_ret;
    sem_t               cmd_start;
    sem_t               cmd_done;
 
    // status flags
    RK_U32              parser_work_count;
    RK_U32              parser_wait_count;
    RK_U32              parser_status_flag;
    RK_U32              parser_wait_flag;
    RK_U32              parser_notify_flag;
    RK_U32              hal_notify_flag;
 
    // reset process:
    // 1. mpp_dec set reset flag and signal parser
    // 2. mpp_dec wait on parser_reset sem
    // 3. parser wait hal reset done
    // 4. hal wait vproc reset done
    // 5. vproc do reset and signal hal
    // 6. hal do reset and signal parser
    // 7. parser do reset and signal mpp_dec
    // 8. mpp_dec reset done
    RK_U32              reset_flag;
 
    RK_U32              hal_reset_post;
    RK_U32              hal_reset_done;
    sem_t               parser_reset;
    sem_t               hal_reset;
 
    // work mode flags
    RK_U32              parser_fast_mode;
    RK_U32              disable_error;
    RK_U32              enable_deinterlace;
 
    // dec parser thread runtime resource context
    MppPacket           mpp_pkt_in;
    void                *mpp;
    void                *vproc;
 
    // statistics data
    RK_U32              statistics_en;
    MppClock            clocks[DEC_TIMING_BUTT];
 
    // query data
    RK_U32              dec_in_pkt_count;
    RK_U32              dec_hw_run_count;
    RK_U32              dec_out_frame_count;
 
    MppMemPool          ts_pool;
    struct list_head    ts_link;
    spinlock_t          ts_lock;
} MppDecImpl;
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
#ifdef __cplusplus
}
#endif
 
#endif /*__MPP_DEC_IMPL_H__*/