• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_dsp_base.h"
10 #include "audio_driver_log.h"
11 
12 #define HDF_LOG_TAG HDF_AUDIO_KADM
13 
DspGetServiceName(const struct HdfDeviceObject * device,const char ** drvDspName)14 int32_t DspGetServiceName(const struct HdfDeviceObject *device, const char **drvDspName)
15 {
16     const struct DeviceResourceNode *node = NULL;
17     struct DeviceResourceIface *drsOps = NULL;
18     int32_t ret;
19 
20     if (device == NULL || drvDspName == NULL) {
21         AUDIO_DRIVER_LOG_ERR("device is NULL.");
22         return HDF_FAILURE;
23     }
24 
25     node = device->property;
26     if (node == NULL) {
27         AUDIO_DRIVER_LOG_ERR("device property is NULL.");
28         return HDF_FAILURE;
29     }
30     drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
31     if (drsOps == NULL || drsOps->GetString == NULL) {
32         AUDIO_DRIVER_LOG_ERR("from resource get drsops failed!");
33         return HDF_FAILURE;
34     }
35 
36     ret = drsOps->GetString(node, "serviceName", drvDspName, 0);
37     if (ret != HDF_SUCCESS) {
38         AUDIO_DRIVER_LOG_ERR("read DspServiceName fail!");
39         return ret;
40     }
41 
42     return HDF_SUCCESS;
43 }
44 
DspGetDaiName(const struct HdfDeviceObject * device,const char ** drvDaiName)45 int32_t DspGetDaiName(const struct HdfDeviceObject *device, const char **drvDaiName)
46 {
47     const struct DeviceResourceNode *node = NULL;
48     struct DeviceResourceIface *drsOps = NULL;
49     int32_t ret;
50 
51     if (device == NULL || drvDaiName == NULL) {
52         AUDIO_DRIVER_LOG_ERR("input para is null pointer.");
53         return HDF_FAILURE;
54     }
55 
56     node = device->property;
57     if (node == NULL) {
58         AUDIO_DRIVER_LOG_ERR("drs node is null pointer.");
59         return HDF_FAILURE;
60     }
61     drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
62     if (drsOps == NULL || drsOps->GetString == NULL) {
63         AUDIO_DRIVER_LOG_ERR("drs ops fail!");
64         return HDF_FAILURE;
65     }
66 
67     ret = drsOps->GetString(node, "dspDaiName", drvDaiName, 0);
68     if (ret != HDF_SUCCESS) {
69         AUDIO_DRIVER_LOG_ERR("read dspDaiName fail!");
70         return ret;
71     }
72 
73     return HDF_SUCCESS;
74 }
75