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 "hi3516_dai_ops_test.h"
10 #include "audio_host.h"
11 #include "audio_dai_if.h"
12 #include "audio_platform_if.h"
13 #include "hi3516_dai_ops.h"
14 #include "hdf_base.h"
15 #include "hdf_log.h"
16 #include "hi3516_common_func.h"
17
18 #define HDF_LOG_TAG hi3516_dai_ops_test
19
20
TestDaiDeviceInit(void)21 int32_t TestDaiDeviceInit(void)
22 {
23 struct AudioCard *audioCard = NULL;
24 struct DaiDevice *dai = NULL;
25 int ret;
26
27 ret = DaiDeviceInit(audioCard, dai);
28
29 HDF_LOGI("TestDaiHwParams: success");
30 return HDF_SUCCESS;
31 }
32
TestDaiStartup(void)33 int32_t TestDaiStartup(void)
34 {
35 struct AudioCard *card = NULL;
36 struct DaiDevice *device = NULL;
37 int ret;
38
39 ret = DaiDeviceInit(card, device);
40 HDF_LOGI("TestDaiHwParams: success");
41 return HDF_SUCCESS;
42 }
43
TestDaiHwParams(void)44 int32_t TestDaiHwParams(void)
45 {
46 // CodecDaiHwParams: channels = 2, rate = 48000,
47 // PERIODSIZE = 960, PERIODCOUNT = 8, FORMAT = 2,
48 // cardServiceName = audio_service_0
49 int ret;
50 struct AudioCard *card = NULL;
51 struct AudioPcmHwParams *param = NULL;
52
53 ret = DaiHwParams(card, param);
54
55 HDF_LOGI("TestDaiHwParams: success");
56 return HDF_SUCCESS;
57 }
58
TestDaiTrigger(void)59 int32_t TestDaiTrigger(void)
60 {
61 int ret;
62 struct AudioCard *card = NULL;
63 int cmd;
64 struct DaiDevice *cpuDai = NULL;
65
66 ret = GetAudioCard(&card);
67 if (ret != HDF_SUCCESS) {
68 HDF_LOGE("TestDaiTrigger: get card instance failed.");
69 return HDF_FAILURE;
70 }
71
72 if (card->rtd == NULL || card->rtd->cpuDai == NULL) {
73 HDF_LOGE("TestDaiTrigger: card rtd is NULL.");
74 return HDF_FAILURE;
75 }
76 cpuDai = card->rtd->cpuDai;
77 if (cpuDai->devData == NULL || cpuDai->devData->ops == NULL) {
78 HDF_LOGE("TestDaiTrigger: cpuDai param is NULL.");
79 return HDF_FAILURE;
80 }
81 cmd = 1;
82
83 if (ret != HDF_SUCCESS) {
84 HDF_LOGE("TestDaiTrigger: Trigger fail ret = %d", ret);
85 return HDF_FAILURE;
86 }
87
88 HDF_LOGI("TestDaiTrigger: success");
89 return HDF_SUCCESS;
90 }
91