• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Shenzhen Kaihong DID Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "codec_component_capability_config.h"
17 #include <hdf_log.h>
18 
19 #define HDF_LOG_TAG codec_hdi_server
20 
21 static CodecCapablites g_codecCapabilites = {0};
22 static const struct DeviceResourceNode *g_resourceNode = NULL;
23 
InitDataNode(const struct DeviceResourceNode * node)24 int32_t InitDataNode(const struct DeviceResourceNode *node)
25 {
26     if (node == NULL) {
27         HDF_LOGE("%{public}s: data node is null!", __func__);
28         return HDF_FAILURE;
29     }
30     g_resourceNode = node;
31     return HDF_SUCCESS;
32 }
33 
ClearCapabilityData()34 int32_t ClearCapabilityData()
35 {
36     return ClearCapabilityGroup(&g_codecCapabilites);
37 }
38 
LoadCapabilityData()39 int32_t LoadCapabilityData()
40 {
41     return LoadCodecCapabilityFromHcs(g_resourceNode, &g_codecCapabilites);
42 }
43 
GetComponentNum(int32_t * num)44 int32_t GetComponentNum(int32_t *num)
45 {
46     if (!g_codecCapabilites.inited) {
47         HDF_LOGE("%{public}s: g_codecCapabilites not init!", __func__);
48         return HDF_FAILURE;
49     }
50     *num = g_codecCapabilites.total;
51     return HDF_SUCCESS;
52 }
53 
GetComponentCapabilityList(CodecCompCapability * capList,int32_t count)54 int32_t GetComponentCapabilityList(CodecCompCapability *capList, int32_t count)
55 {
56     if (!g_codecCapabilites.inited) {
57         HDF_LOGE("%{public}s: g_codecCapabilites not init!", __func__);
58         return HDF_FAILURE;
59     }
60     int32_t groupIndex;
61     int32_t capIndex;
62     int32_t curCount = 0;
63     CodecCapablityGroup *group = NULL;
64     CodecCompCapability *cap = NULL;
65     CodecCapablityGroup *codeCapGroups[] = {
66         &(g_codecCapabilites.videoHwEncoderGroup), &(g_codecCapabilites.videoHwDecoderGroup),
67         &(g_codecCapabilites.audioHwEncoderGroup), &(g_codecCapabilites.audioHwDecoderGroup),
68         &(g_codecCapabilites.videoSwEncoderGroup), &(g_codecCapabilites.videoSwDecoderGroup),
69         &(g_codecCapabilites.audioSwEncoderGroup), &(g_codecCapabilites.audioSwDecoderGroup)};
70 
71     for (groupIndex = 0; groupIndex < CODEC_CAPABLITY_GROUP_NUM; groupIndex++) {
72         group = codeCapGroups[groupIndex];
73         for (capIndex = 0; (capIndex < group->num) && (count > 0); capIndex++) {
74             cap = &group->capablitis[capIndex];
75             capList[curCount++] = *cap;
76         }
77     }
78     return HDF_SUCCESS;
79 }
80