aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/vdec/hal/vdec_hal_if_h265.h
blob: b87ffe7258dd87ba3023a085b333546d1a064407 (plain) (blame)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#ifndef _VDEC_HAL_IF_H265_H_
#define _VDEC_HAL_IF_H265_H_

#include "../include/vdec_info_h265.h"
#include "../include/vdec_info_common.h"

#if CONFIG_DRV_VERIFY_SUPPORT
#include "../verify/vdec_verify_general.h"
#endif

//#include "vdec_hw_common.h"
//#include "vdec_verify_typedef.h"
//#include "vdec_verify_keydef.h"
//#include "typedef.h"

/*! \name Video Decoder HAL H265 Interface
* @{
*/

/// Initialize video decoder hardware
/// \return If return value < 0, it's failed. Please reference hal_vdec_errcode.h.
INT32 i4VDEC_HAL_H265_InitVDecHW(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Read Barrel Shifter after shifting
/// \return Value of barrel shifter input window after shifting
UINT32 u4VDEC_HAL_H265_ShiftGetBitStream(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 u4ShiftBits                                  ///< [IN] Shift bits number
);


/// Read Barrel Shifter before shifting
/// \return Value of barrel shifter input window before shifting
UINT32 u4VDEC_HAL_H265_GetBitStreamShift(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 u4ShiftBits                                 ///< [IN] Shift bits number
);


/// Read Barrel Shifter before shifting
/// \return  Most significant (32 - u4ShiftBits) bits of barrel shifter input window before shifting
UINT32 u4VDEC_HAL_H265_GetRealBitStream(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 u4ShiftBits                                 ///< [IN] Shift bits number
);


/// Read Barrel Shifter before shifting
/// \return  MSB of barrel shifter input window before shifting
BOOL bVDEC_HAL_H265_GetBitStreamFlg(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID                                     ///< [IN] Video decoder hardware ID
);


/// Do UE variable length decoding
/// \return  Input window after UE variable length decoding
UINT32 u4VDEC_HAL_H265_UeCodeNum(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID                                     ///< [IN] Video decoder hardware ID
);


/// Do SE variable length decoding
/// \return  Input window after SE variable length decoding
INT32 i4VDEC_HAL_H265_SeCodeNum(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID                                     ///< [IN] Video decoder hardware ID
);

/// Get next start code
/// \return Current input window of vld while finding start code
UINT32 u4VDEC_HAL_H265_GetStartCode_PicStart(
    UINT32 u4BSID,                                     ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);

/// Get next start code
/// \return Current input window of vld while finding start code
UINT32 u4VDEC_HAL_H265_GetStartCode_8530(
    UINT32 u4BSID,                                     ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Initialize barrel shifter with byte alignment
/// \return If return value < 0, it's failed. Please reference hal_vdec_errcode.h.
INT32 i4VDEC_HAL_H265_InitBarrelShifter(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID,                                     ///< [IN] Video decoder hardware ID
    VDEC_INFO_H265_BS_INIT_PRM_T *prH265BSInitPrm
);


/// Read current read pointer
/// \return Current read pointer with byte alignment
UINT32 u4VDEC_HAL_H265_ReadRdPtr(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 u4VFIFOSa,
    UINT32 *pu4Bits                                     ///< [OUT] Read pointer with remained bits
);


/// Align read pointer to byte,word or double word
/// \return None
void vVDEC_HAL_H265_AlignRdPtr(
    UINT32 u4BSID,                                      ///< [IN] Barrel shifter hardware ID of one video decoder
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 u4AlignType                                  ///< [IN] Align type
);


/// Read barrel shifter bitcount after initializing
/// \return Bitcount counted by HAL
UINT32 u4VDEC_HAL_H265_GetBitcount(
    UINT32 u4BSID,                                        ///< [IN] Barrel shifter ID
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);

/// Reference list reordering
/// \return None
void vVDEC_HAL_H265_RPL_Modification(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Decode prediction weighting table
/// \return None
void vVDEC_HAL_H265_PredWeightTable(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Remove traling bits to byte align
/// \return None
void vVDEC_HAL_H265_TrailingBits(
    UINT32 u4BSID,                                        ///< [IN] Barrel shifter ID
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Check whether there is more rbsp data
/// \return Is morw Rbsp data or not
BOOL bVDEC_HAL_H265_IsMoreRbspData(
    UINT32 u4BSID,                                        ///< [IN] Barrel shifter ID
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Set HW registers to initialize picture info
/// \return None
void vVDEC_HAL_H265_SetPicInfoReg(
    UINT32 u4VDecID                                  ///< [IN] Video decoder hardware ID
);


/// Set HW registers related with P reference list
/// \return None
void vVDEC_HAL_H265_SetRefPicListReg(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);

/// Set SPS data to HW
/// \return None
void vVDEC_HAL_H265_SetSPSHEVLD(
    UINT32 u4VDecID,                                   ///< [IN] Video decoder hardware ID
    H265_SPS_Data *prSPS,          ///< [IN] Pointer to struct of sequence parameter set
    H265_PPS_Data *prPPS
);


/// Set PPS data to HW
/// \return None
void vVDEC_HAL_H265_SetPPSHEVLD(
    UINT32 u4VDecID,                                   ///< [IN] Video decoder hardware ID
    H265_SPS_Data *prSPS,          ///< [IN] Pointer to struct of sequence parameter set
    H265_PPS_Data *prPPS
);


/// Set part of slice header data to HW
/// \return None
void vVDEC_HAL_H265_SetSHDRHEVLD(
    UINT32 u4VDecID,                                              ///< [IN] Video decoder hardware ID
    H265_Slice_Hdr_Data *prSliceHdr,        ///< [IN] Pointer to struct of picutre parameter set
    BOOL bUseSAO,
    H265_PPS_Data *prPPS
);

void vVDEC_HAL_H265_SetSLVLD(
    UINT32 u4VDecID,
    INT32 *coeff,
    INT32 width,
    INT32 height,
    INT32 invQuantScales
);

void vVDEC_HAL_H265_SetSLPP(
    UINT32 u4VDecID,
    pH265_SL_Data ScallingList
);

void vVDEC_HAL_H265_SetTilesInfo(
    UINT32 u4VDecID,
    H265_SPS_Data *prSPS,
    H265_PPS_Data *prPPS
);

#ifdef  HEVC_STILL_IMAGE
void vVDEC_HAL_H265_SetStillImageInfo(
    UINT32 u4VDecID,
    H265_SPS_Data *prSPS,
    H265_PPS_Data *prPPS
);
#endif

void vVDecWriteHEVCPP(
    UINT32 u4VDecID,
    UINT32 u4Addr,
    UINT32 u4Va
);

void vVDecWriteHEVCVLD(
    UINT32 u4VDecID,
    UINT32 u4Addr,
    UINT32 u4Va
);


void vVDecWriteHEVCMISC(
    UINT32 u4VDecID,
    UINT32 u4Addr,
    UINT32 u4Val
);

UINT32 u4VDecReadHEVCMISC(
    UINT32 u4VDecID,
    UINT32 u4Addr
);

/// Set video decoder hardware registers to decode
/// \return If return value < 0, it's failed. Please reference hal_vdec_errcode.h.
INT32 i4VDEC_HAL_H265_DecStart(
    UINT32 u4VDecID,
    VDEC_INFO_DEC_PRM_T *prDecPrm              ///< [IN] Pointer to H265 decode Information
);


/// Read current decoded mbx and mby
/// \return None
void vVDEC_HAL_H265_GetMbxMby(
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 *pu4Mbx,                                      ///< [OUT] Pointer to current decoded macroblock in x axis
    UINT32 *pu4Mby                                       ///< [OUT] Pointer to current decoded macroblock in y axis
);


/// Check if all video decoder modules are finish
/// \return TRUE: Finish, FALSE: Not yet
BOOL fgVDEC_HAL_H265_DecPicComplete(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);



/// Read h265 error message after decoding end
/// \return h265 decode error message
UINT32 u4VDEC_HAL_H265_GetErrMsg(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);


/// Check h265 error info
/// \return h265 decode error check result
BOOL fgVDEC_HAL_H265_ChkErrInfo(
    UINT32 u4BSID,                                        ///< [IN] Barrel shifter ID
    UINT32 u4VDecID,                                    ///< [IN] Video decoder hardware ID
    UINT32 u4DecErrInfo,                               ///< [IN] Err Info
    UINT32 u4ECLevel                               ///< [IN] Check the EC level
);

void vVDEC_HAL_H265_VDec_PowerDown(UCHAR u4VDecID);

void vVDEC_HAL_H265_VDec_GetYCbCrCRC(UINT32 u4VDecID, UINT32 *pu4CRC);

#ifdef MPV_DUMP_H265_CHKSUM
/// Compare decode checksum with golden, only for verification
/// \return True for match, false for mismatch
void vVDEC_HAL_H265_VDec_ReadCheckSum1(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);
/// Compare decode checksum with golden, only for verification
/// \return True for match, false for mismatch
void vVDEC_HAL_H265_VDec_ReadCheckSum2(
    UINT32 u4VDecID                                    ///< [IN] Video decoder hardware ID
);
#endif

//
/*! @} */

#if (CONFIG_DRV_VERIFY_SUPPORT)

/// Read H265 video decoder finish register, only for verification
/// \return Register value
UINT32 u4VDEC_HAL_H265_VDec_ReadFinishFlag(
    UINT32 u4VDecID
);

/// H265 video decoder clear interrupt setting, only for verification
UINT32 u4VDEC_HAL_H265_VDec_ClearInt(
    UINT32 u4VDecID
);

UINT32 vVDEC_HAL_H265_VDec_VPmode(
    UINT32 u4VDecID
);

/// Dump H265 video decoder registers, only for verification
/// return None
void vVDEC_HAL_H265_VDec_DumpReg(
    UINT32 u4VDecID,
    UINT32 i4DecodeDone
);

/// Read H265 video decoder checksum registers, only for verification
/// \return None
void vVDEC_HAL_H265_VDec_ReadCheckSum(
    UINT32 u4VDecID,
    UINT32 *pu4CheckSum
);


/// Compare decode checksum with golden, only for verification
/// \return True for match, false for mismatch
BOOL fgVDEC_HAL_H265_VDec_CompCheckSum(
    UINT32 *pu4DecCheckSum,
    UINT32 *pu4GoldenCheckSum
);

#endif

//
/*! @} */


#endif //#ifndef _HAL_VDEC_H265_IF_H_