1 /*
2 * Copyright 2021 Rockchip Electronics Co. LTD
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "rk_mpi_ao.h"
18
19 #include "rk_debug.h"
20
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif /* End of #ifdef __cplusplus */
26
TEST_AO_Start(AUDIO_DEV AoDev,AIO_ATTR_S * pstAoAttr,RK_U32 u32ChnCnt,AUDIO_SAMPLE_RATE_E * pEnSmpRates)27 RK_S32 TEST_AO_Start(AUDIO_DEV AoDev, AIO_ATTR_S *pstAoAttr, RK_U32 u32ChnCnt, AUDIO_SAMPLE_RATE_E *pEnSmpRates) {
28 RK_S32 s32Ret = RK_SUCCESS;
29
30 s32Ret = RK_MPI_AO_SetPubAttr(AoDev, pstAoAttr);
31 if (s32Ret != RK_SUCCESS) {
32 RK_LOGE("failed with 0x%x!", s32Ret);
33 return s32Ret;
34 }
35
36 s32Ret = RK_MPI_AO_Enable(AoDev);
37 if (s32Ret != RK_SUCCESS) {
38 RK_LOGE("failed with 0x%x!", s32Ret);
39 return s32Ret;
40 }
41
42 for (RK_S32 i = 0; i < u32ChnCnt; i++) {
43 s32Ret = RK_MPI_AO_EnableChn(AoDev, i);
44 if (s32Ret != RK_SUCCESS) {
45 RK_LOGE("failed with 0x%x!", s32Ret);
46 return s32Ret;
47 }
48
49 // set sample rate of input data
50 s32Ret = RK_MPI_AO_EnableReSmp(AoDev, i, pEnSmpRates[i]);
51 if (s32Ret != RK_SUCCESS) {
52 RK_LOGE("failed with 0x%x!", s32Ret);
53 return s32Ret;
54 }
55 }
56
57 return RK_SUCCESS;
58 }
59
TEST_AO_Stop(AUDIO_DEV aoDevId,RK_U32 u32ChnCnt)60 RK_S32 TEST_AO_Stop(AUDIO_DEV aoDevId, RK_U32 u32ChnCnt) {
61 RK_S32 s32Ret = RK_SUCCESS;
62
63 for (RK_S32 i = 0; i < u32ChnCnt; i++) {
64 s32Ret = RK_MPI_AO_DisableReSmp(aoDevId, i);
65 if (s32Ret != RK_SUCCESS) {
66 RK_LOGE("failed with 0x%x!", s32Ret);
67 return RK_FAILURE;
68 }
69
70 s32Ret = RK_MPI_AO_DisableChn(aoDevId, i);
71 if (s32Ret != RK_SUCCESS) {
72 RK_LOGE("failed with 0x%x!", s32Ret);
73 return RK_FAILURE;
74 }
75 }
76
77 s32Ret = RK_MPI_AO_Disable(aoDevId);
78 if (s32Ret != RK_SUCCESS) {
79 RK_LOGE("failed with 0x%x!", s32Ret);
80 return RK_FAILURE;
81 }
82
83 return RK_SUCCESS;
84 }
85
86 #ifdef __cplusplus
87 #if __cplusplus
88 }
89 #endif
90 #endif /* End of #ifdef __cplusplus */
91
92