1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include "audio_parse.h"
10
11 #define HDF_LOG_TAG audio_parse
12
AudioFillConfigData(const struct HdfDeviceObject * device,struct AudioConfigData * configData)13 int32_t AudioFillConfigData(const struct HdfDeviceObject *device, struct AudioConfigData *configData)
14 {
15 const struct DeviceResourceNode *node = NULL;
16 struct DeviceResourceIface *drsOps = NULL;
17 ADM_LOG_DEBUG("Entry.");
18
19 if (device == NULL || configData == NULL) {
20 ADM_LOG_ERR("Input para check error: device=%p, configData=%p.", device, configData);
21 return HDF_FAILURE;
22 }
23
24 node = device->property;
25 if (node == NULL) {
26 ADM_LOG_ERR("drs node is NULL.");
27 return HDF_FAILURE;
28 }
29 drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
30 if (drsOps == NULL || drsOps->GetString == NULL) {
31 ADM_LOG_ERR("AudioFillConfigData: invalid drs ops fail!");
32 return HDF_FAILURE;
33 }
34
35 int32_t serviceRet = drsOps->GetString(node, "serviceName", &(configData->cardServiceName), 0);
36 int32_t codecRet = drsOps->GetString(node, "codecName", &(configData->codecName), 0);
37 int32_t platformRet = drsOps->GetString(node, "platformName", &(configData->platformName), 0);
38 int32_t cpuRet = drsOps->GetString(node, "cpuDaiName", &(configData->cpuDaiName), 0);
39 int32_t codeDaiRet = drsOps->GetString(node, "codecDaiName", &(configData->codecDaiName), 0);
40 int32_t dspRet = drsOps->GetString(node, "dspName", &(configData->dspName), 0);
41 int32_t dspDaiRet = drsOps->GetString(node, "dspDaiName", &(configData->dspDaiName), 0);
42 int32_t accessoryRet = drsOps->GetString(node, "accessoryName", &(configData->accessoryName), 0);
43 int32_t accessoryDaiRet = drsOps->GetString(node, "accessoryDaiName", &(configData->accessoryDaiName), 0);
44 if (serviceRet || codecRet || platformRet || cpuRet || codeDaiRet ||
45 dspRet || dspDaiRet || accessoryRet || accessoryDaiRet) {
46 ADM_LOG_ERR("Read audioDeviceName fail: serviceRet=%d, codecRet=%d, platformRet=%d, cpuRet=%d, codeDaiRet=%d,"
47 "dspRet=%d, dspDaiRet=%d, accessoryRet=%d, accessoryDaiRet=%d",
48 serviceRet, codecRet, platformRet, cpuRet, codeDaiRet, dspRet,
49 dspDaiRet, accessoryRet, accessoryDaiRet);
50 return HDF_FAILURE;
51 }
52
53 ADM_LOG_DEBUG("Success! codecName = %s, platformName = %s, cpuDaiName = %s, codecDaiName = %s, "
54 "dspName = %s, dspDaiName = %s, accessoryName = %s, accessoryDaiName = %s.",
55 configData->codecName, configData->platformName, configData->cpuDaiName,
56 configData->codecDaiName, configData->dspName, configData->dspDaiName,
57 configData->accessoryName, configData->accessoryDaiName);
58
59 return HDF_SUCCESS;
60 }
61