• 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 writing 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 OHOS {
43 namespace Audio {
44 const int REGISTER_STATUS_ON = 0;
45 const int REGISTER_STATUS_OFF = 1;
46 const int AUDIO_SIZE_FRAME = 16 * 1024;
47 const int AUDIO_REPLY_EXTEND = 16;
48 const int CIR_BUFF_EMPTY = -3;
49 const int32_t CIR_BUFF_NORMAL = -1;
50 const std::string CARD_SEVICE_NAME = "hdf_audio_codec_primary_dev0";
51 
52 enum StreamDispMethodCmd {
53     AUDIO_DRV_PCM_IOCTRL_HW_PARAMS,
54     AUDIO_DRV_PCM_IOCTRL_RENDER_PREPARE,
55     AUDIO_DRV_PCM_IOCTRL_CAPTURE_PREPARE,
56     AUDIO_DRV_PCM_IOCTRL_WRITE,
57     AUDIO_DRV_PCM_IOCTRL_READ,
58     AUDIO_DRV_PCM_IOCTRL_RENDER_START,
59     AUDIO_DRV_PCM_IOCTRL_RENDER_STOP,
60     AUDIO_DRV_PCM_IOCTRL_CAPTURE_START,
61     AUDIO_DRV_PCM_IOCTRL_CAPTURE_STOP,
62     AUDIO_DRV_PCM_IOCTRL_RENDER_PAUSE,
63     AUDIO_DRV_PCM_IOCTRL_CAPTURE_PAUSE,
64     AUDIO_DRV_PCM_IOCTRL_RENDER_RESUME,
65     AUDIO_DRV_PCM_IOCTRL_CAPTURE_RESUME,
66     AUDIO_DRV_PCM_IOCTRL_RENDER_OPEN = 17,
67     AUDIO_DRV_PCM_IOCTRL_CAPTURE_OPEN = 19,
68     AUDIO_DRV_PCM_IOCTRL_BUTT,
69 };
70 
71 struct AudioPcmHwParams {
72     enum AudioStreamType streamType;
73     uint32_t channels;
74     uint32_t rate;
75     uint32_t periodSize;
76     uint32_t periodCount;
77     enum AudioFormat format;
78     const char *cardServiceName;
79     uint32_t period;
80     uint32_t frameSize;
81     bool isBigEndian;
82     bool isSignedData;
83     uint32_t startThreshold;
84     uint32_t stopThreshold;
85     uint32_t silenceThreshold;
86 };
87 
88 struct AudioXferi {
89     char *buf;
90     uint32_t bufsize;
91     uint32_t frameSize;
92 };
93 
94 int32_t WriteHwParamsToBuf(struct HdfSBuf *sBuf, struct AudioPcmHwParams hwParams);
95 
96 int32_t AdmRenderFramePrepare(const std::string& path, char *&frame, uint32_t& numRead, uint32_t& frameSize);
97 
98 int32_t WriteFrameToSBuf(struct HdfSBuf *&sBufT, const std::string& path);
99 
100 int32_t ObtainBuf(struct HdfSBuf *&readBuf, struct HdfSBuf *&readReply);
101 
102 int32_t WriteCtrlInfo(struct HdfIoService *service, struct AudioCtlElemValue writeElemValue);
103 
104 int32_t ReadCtrlInfo(struct HdfIoService *service, struct AudioCtlElemId id, int32_t expectValue);
105 
106 int32_t WriteHwParams(std::string serviceName, struct HdfIoService *&service, struct AudioPcmHwParams hwParams);
107 
108 int32_t WriteToSBuf(struct HdfSBuf *&sBufT);
109 
110 int32_t WriteCardSeviceNameToSBuf(struct HdfSBuf *&sBufT);
111 }
112 }
113 #endif // AUDIO_ADM_COMMON_H
114 
115