• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup Audio
18  * @{
19  *
20  * @brief Defines audio ADM test-related APIs, including data types and functions for writting data
21 to buffer
22  *
23  * @since 1.0
24  * @version 1.0
25  */
26 
27 /**
28  * @file audio_adm_common.h
29  *
30  * @brief Declares APIs for operations related to the audio ADM testing.
31  *
32  * @since 1.0
33  * @version 1.0
34  */
35 
36 #ifndef AUDIO_ADM_COMMON_H
37 #define AUDIO_ADM_COMMON_H
38 
39 #include "osal_mem.h"
40 #include "audio_hdi_common.h"
41 
42 namespace HMOS {
43 namespace Audio {
44 const int REGISTER_STATUS_ON = 0;
45 const int REGISTER_STATUS_OFF = 1;
46 
47 enum StreamDispMethodCmd {
48     AUDIO_DRV_PCM_IOCTRL_HW_PARAMS,
49     AUDIO_DRV_PCM_IOCTRL_RENDER_PREPARE,
50     AUDIO_DRV_PCM_IOCTRL_CAPTURE_PREPARE,
51     AUDIO_DRV_PCM_IOCTRL_WRITE,
52     AUDIO_DRV_PCM_IOCTRL_READ,
53     AUDIO_DRV_PCM_IOCTRL_RENDER_START,
54     AUDIO_DRV_PCM_IOCTRL_RENDER_STOP,
55     AUDIO_DRV_PCM_IOCTRL_CAPTURE_START,
56     AUDIO_DRV_PCM_IOCTRL_CAPTURE_STOP,
57     AUDIO_DRV_PCM_IOCTRL_RENDER_PAUSE,
58     AUDIO_DRV_PCM_IOCTRL_CAPTURE_PAUSE,
59     AUDIO_DRV_PCM_IOCTRL_RENDER_RESUME,
60     AUDIO_DRV_PCM_IOCTRL_CAPTURE_RESUME,
61     AUDIO_DRV_PCM_IOCTRL_BUTT,
62 };
63 
64 struct AudioPcmHwParams {
65     enum AudioStreamType streamType;
66     uint32_t channels;
67     uint32_t rate;
68     uint32_t periodSize;
69     uint32_t periodCount;
70     enum AudioFormat format;
71     const char *cardServiceName;
72     uint32_t period;
73     uint32_t frameSize;
74     bool isBigEndian;
75     bool isSignedData;
76     uint32_t startThreshold;
77     uint32_t stopThreshold;
78     uint32_t silenceThreshold;
79 };
80 
81 struct AudioXferi {
82     char *buf;
83     unsigned long bufsize;
84     unsigned long frameSize;
85 };
86 
87 int32_t WriteHwParamsToBuf(struct HdfSBuf *sBuf, struct AudioPcmHwParams hwParams);
88 
89 int32_t AdmRenderFramePrepare(const std::string &path, char *&frame, unsigned long& numRead, unsigned long& frameSize);
90 
91 int32_t WriteFrameToSBuf(struct HdfSBuf *&sBufT, const std::string &path);
92 
93 int32_t ObtainBuf(struct HdfSBuf *&readBuf, struct HdfSBuf *&readReply);
94 
95 int32_t WriteCtrlInfo(struct HdfIoService *service, struct AudioCtlElemValue writeElemValue);
96 
97 int32_t ReadCtrlInfo(struct HdfIoService *service, struct AudioCtlElemId id, int32_t expectValue);
98 
99 int32_t WriteHwParams(std::string serviceName, struct HdfIoService *&service, struct AudioPcmHwParams hwParams);
100 }
101 }
102 #endif // AUDIO_ADM_COMMON_H
103 
104