1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright 2021 Rockchip Electronics Co. LTD
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Licensed under the Apache License, Version 2.0 (the "License");
5*4882a593Smuzhiyun * you may not use this file except in compliance with the License.
6*4882a593Smuzhiyun * You may obtain a copy of the License at
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * http://www.apache.org/licenses/LICENSE-2.0
9*4882a593Smuzhiyun *
10*4882a593Smuzhiyun * Unless required by applicable law or agreed to in writing, software
11*4882a593Smuzhiyun * distributed under the License is distributed on an "AS IS" BASIS,
12*4882a593Smuzhiyun * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4882a593Smuzhiyun * See the License for the specific language governing permissions and
14*4882a593Smuzhiyun * limitations under the License.
15*4882a593Smuzhiyun */
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #define MODULE_TAG "mpp_compat"
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun #include "mpp_debug.h"
20*4882a593Smuzhiyun #include "mpp_common.h"
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun #include "mpp_compat.h"
23*4882a593Smuzhiyun #include "mpp_compat_impl.h"
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun static MppCompat compats[] = {
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun MPP_COMPAT_INC_FBC_BUF_SIZE,
28*4882a593Smuzhiyun MPP_COMPAT_BOOL,
29*4882a593Smuzhiyun 1,
30*4882a593Smuzhiyun #if defined(__ANDROID__)
31*4882a593Smuzhiyun /*
32*4882a593Smuzhiyun * The codecs might need extra lines for deblock output, but the
33*4882a593Smuzhiyun * android world rather risk memory overflow than using the correct
34*4882a593Smuzhiyun * buf size.
35*4882a593Smuzhiyun */
36*4882a593Smuzhiyun 0,
37*4882a593Smuzhiyun #else
38*4882a593Smuzhiyun 1,
39*4882a593Smuzhiyun #endif
40*4882a593Smuzhiyun "increase decoder fbc buffer size",
41*4882a593Smuzhiyun &compats[1],
42*4882a593Smuzhiyun },
43*4882a593Smuzhiyun {
44*4882a593Smuzhiyun MPP_COMPAT_ENC_ASYNC_INPUT,
45*4882a593Smuzhiyun MPP_COMPAT_BOOL,
46*4882a593Smuzhiyun 1,
47*4882a593Smuzhiyun 0,
48*4882a593Smuzhiyun "support encoder async input mode",
49*4882a593Smuzhiyun NULL,
50*4882a593Smuzhiyun },
51*4882a593Smuzhiyun {
52*4882a593Smuzhiyun MPP_COMPAT_DEC_FBC_HDR_256_ODD,
53*4882a593Smuzhiyun MPP_COMPAT_BOOL,
54*4882a593Smuzhiyun 0,
55*4882a593Smuzhiyun 0,
56*4882a593Smuzhiyun "set decoder fbc header stride to 256 odd align",
57*4882a593Smuzhiyun NULL,
58*4882a593Smuzhiyun },
59*4882a593Smuzhiyun };
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun RK_S32 *compat_ext_fbc_buf_size = &compats[MPP_COMPAT_INC_FBC_BUF_SIZE].value_usr;
62*4882a593Smuzhiyun RK_S32 *compat_ext_async_input = &compats[MPP_COMPAT_ENC_ASYNC_INPUT].value_usr;
63*4882a593Smuzhiyun RK_S32 *compat_ext_fbc_hdr_256_odd = &compats[MPP_COMPAT_DEC_FBC_HDR_256_ODD].value_usr;
64*4882a593Smuzhiyun
mpp_compat_query(void)65*4882a593Smuzhiyun MppCompat *mpp_compat_query(void)
66*4882a593Smuzhiyun {
67*4882a593Smuzhiyun return compats;
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun
mpp_compat_query_by_id(MppCompatId id)70*4882a593Smuzhiyun MppCompat *mpp_compat_query_by_id(MppCompatId id)
71*4882a593Smuzhiyun {
72*4882a593Smuzhiyun RK_U32 i;
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun for (i = 0; i < MPP_ARRAY_ELEMS(compats); i++) {
75*4882a593Smuzhiyun if (compats[i].feature_id == id)
76*4882a593Smuzhiyun return &compats[i];
77*4882a593Smuzhiyun }
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun return NULL;
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun
mpp_compat_update(MppCompat * compat,RK_S32 value)82*4882a593Smuzhiyun MPP_RET mpp_compat_update(MppCompat *compat, RK_S32 value)
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun if (NULL == compat)
85*4882a593Smuzhiyun return MPP_NOK;
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun if (compat->feature_id >= MPP_COMPAT_BUTT)
88*4882a593Smuzhiyun return MPP_NOK;
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun if (compat != &compats[compat->feature_id])
91*4882a593Smuzhiyun return MPP_NOK;
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun if (compat->feature_type == MPP_COMPAT_BOOL)
94*4882a593Smuzhiyun if (value != 0 && value != 1)
95*4882a593Smuzhiyun return MPP_NOK;
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun compat->value_usr = value;
98*4882a593Smuzhiyun return MPP_OK;
99*4882a593Smuzhiyun }
100*4882a593Smuzhiyun
mpp_compat_show(void)101*4882a593Smuzhiyun void mpp_compat_show(void)
102*4882a593Smuzhiyun {
103*4882a593Smuzhiyun const MppCompat *compat = compats;
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun mpp_log("id| name -- mpp compat info\n");
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun while (compat) {
108*4882a593Smuzhiyun mpp_log("%d | %s\n", compat->feature_id, compat->name);
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun compat = compat->next;
111*4882a593Smuzhiyun }
112*4882a593Smuzhiyun }
113