1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "hi3516_dai_ops_test.h"
20 #include "audio_host.h"
21 #include "audio_dai_if.h"
22 #include "audio_platform_if.h"
23 #include "hi3516_dai_ops.h"
24 #include "hdf_base.h"
25 #include "hdf_log.h"
26 #include "hi3516_common_func.h"
27
28 #define HDF_LOG_TAG HDF_AUDIO_DRIVER
29
30
TestDaiDeviceInit(void)31 int32_t TestDaiDeviceInit(void)
32 {
33 struct AudioCard *audioCard = NULL;
34 struct DaiDevice *dai = NULL;
35 int ret;
36
37 ret = Hi3516DaiDeviceInit(audioCard, dai);
38
39 HDF_LOGI("TestDaiHwParams: success");
40 return HDF_SUCCESS;
41 }
42
TestDaiStartup(void)43 int32_t TestDaiStartup(void)
44 {
45 struct AudioCard *card = NULL;
46 struct DaiDevice *device = NULL;
47 int ret;
48
49 ret = Hi3516DaiDeviceInit(card, device);
50 HDF_LOGI("TestDaiHwParams: success");
51 return HDF_SUCCESS;
52 }
53
TestDaiHwParams(void)54 int32_t TestDaiHwParams(void)
55 {
56 int ret;
57 struct AudioCard *card = NULL;
58 struct AudioPcmHwParams *param = NULL;
59
60 ret = Hi3516DaiHwParams(card, param);
61
62 HDF_LOGI("TestDaiHwParams: success");
63 return HDF_SUCCESS;
64 }
65
TestDaiTrigger(void)66 int32_t TestDaiTrigger(void)
67 {
68 int ret;
69 struct AudioCard *card = NULL;
70 int cmd;
71 struct DaiDevice *cpuDai = NULL;
72
73 ret = GetAudioCard(&card);
74 if (ret != HDF_SUCCESS) {
75 HDF_LOGE("TestDaiTrigger: get card instance failed.");
76 return HDF_FAILURE;
77 }
78
79 if (card->rtd == NULL || card->rtd->cpuDai == NULL) {
80 HDF_LOGE("TestDaiTrigger: card rtd is NULL.");
81 return HDF_FAILURE;
82 }
83 cpuDai = card->rtd->cpuDai;
84 if (cpuDai->devData == NULL || cpuDai->devData->ops == NULL) {
85 HDF_LOGE("TestDaiTrigger: cpuDai param is NULL.");
86 return HDF_FAILURE;
87 }
88 cmd = 1;
89
90 if (ret != HDF_SUCCESS) {
91 HDF_LOGE("TestDaiTrigger: Trigger fail ret = %d", ret);
92 return HDF_FAILURE;
93 }
94
95 HDF_LOGI("TestDaiTrigger: success");
96 return HDF_SUCCESS;
97 }
98