xref: /OK3568_Linux_fs/external/mpp/osal/mpp_compat.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2021 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 #define MODULE_TAG "mpp_compat"
18 
19 #include "mpp_debug.h"
20 #include "mpp_common.h"
21 
22 #include "mpp_compat.h"
23 #include "mpp_compat_impl.h"
24 
25 static MppCompat compats[] = {
26     {
27         MPP_COMPAT_INC_FBC_BUF_SIZE,
28         MPP_COMPAT_BOOL,
29         1,
30 #if defined(__ANDROID__)
31         /*
32          * The codecs might need extra lines for deblock output, but the
33          * android world rather risk memory overflow than using the correct
34          * buf size.
35          */
36         0,
37 #else
38         1,
39 #endif
40         "increase decoder fbc buffer size",
41         &compats[1],
42     },
43     {
44         MPP_COMPAT_ENC_ASYNC_INPUT,
45         MPP_COMPAT_BOOL,
46         1,
47         0,
48         "support encoder async input mode",
49         NULL,
50     },
51     {
52         MPP_COMPAT_DEC_FBC_HDR_256_ODD,
53         MPP_COMPAT_BOOL,
54         0,
55         0,
56         "set decoder fbc header stride to 256 odd align",
57         NULL,
58     },
59 };
60 
61 RK_S32 *compat_ext_fbc_buf_size = &compats[MPP_COMPAT_INC_FBC_BUF_SIZE].value_usr;
62 RK_S32 *compat_ext_async_input  = &compats[MPP_COMPAT_ENC_ASYNC_INPUT].value_usr;
63 RK_S32 *compat_ext_fbc_hdr_256_odd  = &compats[MPP_COMPAT_DEC_FBC_HDR_256_ODD].value_usr;
64 
mpp_compat_query(void)65 MppCompat *mpp_compat_query(void)
66 {
67     return compats;
68 }
69 
mpp_compat_query_by_id(MppCompatId id)70 MppCompat *mpp_compat_query_by_id(MppCompatId id)
71 {
72     RK_U32 i;
73 
74     for (i = 0; i < MPP_ARRAY_ELEMS(compats); i++) {
75         if (compats[i].feature_id == id)
76             return &compats[i];
77     }
78 
79     return NULL;
80 }
81 
mpp_compat_update(MppCompat * compat,RK_S32 value)82 MPP_RET mpp_compat_update(MppCompat *compat, RK_S32 value)
83 {
84     if (NULL == compat)
85         return MPP_NOK;
86 
87     if (compat->feature_id >= MPP_COMPAT_BUTT)
88         return MPP_NOK;
89 
90     if (compat != &compats[compat->feature_id])
91         return MPP_NOK;
92 
93     if (compat->feature_type == MPP_COMPAT_BOOL)
94         if (value != 0 && value != 1)
95             return MPP_NOK;
96 
97     compat->value_usr = value;
98     return MPP_OK;
99 }
100 
mpp_compat_show(void)101 void mpp_compat_show(void)
102 {
103     const MppCompat *compat = compats;
104 
105     mpp_log("id| name -- mpp compat info\n");
106 
107     while (compat) {
108         mpp_log("%d | %s\n", compat->feature_id, compat->name);
109 
110         compat = compat->next;
111     }
112 }
113