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