• 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 #ifndef AUDIO_INTERFACE_LIB_COMMON_H
17 #define AUDIO_INTERFACE_LIB_COMMON_H
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include "securec.h"
23 #include "audio_internal.h"
24 #include "osal_mem.h"
25 #include "hdf_io_service_if.h"
26 #include "hdf_sbuf.h"
27 
28 #define SERVIC_NAME_MAX_LEN             32
29 #define AUDIO_MIN_DEVICENUM             1
30 
31 #define AUDIODRV_CTL_ELEM_IFACE_MIXER 2 /* virtual mixer control */
32 
33 #define AUDIO_WAIT_DELAY        (10 * 1000) // 10ms
34 #define AUDIO_CAP_WAIT_DELAY    (5 * 1000)  // 5ms
35 
36 
37 #define AUDIODRV_CTL_ACODEC_ENABLE  1
38 #define AUDIODRV_CTL_ACODEC_DISABLE 0
39 #define AUDIODRV_CTL_INTERNAL_ACODEC_ENABLE 1
40 #define AUDIODRV_CTL_EXTERN_ACODEC_ENABLE   2
41 
42 #define AUDIODRV_CTL_INTER_CARD_STR "hdf_audio_codec_primary_dev0"
43 #define AUDIODRV_CTL_EXTN_CARD_STR  "hdf_audio_codec_primary_dev11"
44 
45 enum AudioCriBuffStatus {
46     CIR_BUFF_NORMAL    = -1,
47     CIR_BUFF_FULL      = -2,
48     CIR_BUFF_EMPTY     = -3,
49 };
50 
51 struct AudioCtlElemId {
52     const char *cardServiceName;
53     const char *itemName; /* ASCII name of item */
54     int32_t iface;
55 };
56 
57 struct AudioCtlElemValue {
58     struct AudioCtlElemId id;
59     int32_t value[2];
60 };
61 
62 struct AudioCtrlElemInfo {
63     struct AudioCtlElemId id;
64     uint32_t count; /* count of values */
65     int32_t type;   /* R: value type - AUDIODRV_CTL_ELEM_IFACE_MIXER_* */
66     int32_t min;    /* R: minimum value */
67     int32_t max;    /* R: maximum value */
68 };
69 
70 struct HdfIoService *HdfIoServiceBindName(const char *serviceName);
71 void AudioBufReplyRecycle(struct HdfSBuf *sBuf, struct HdfSBuf *reply);
72 void AudioSbufRecycle(struct HdfSBuf *sBuf);
73 int32_t AudioServiceDispatch(struct HdfIoService *service, int cmdId,
74     struct HdfSBuf *sBuf, struct HdfSBuf *reply);
75 struct HdfSBuf *AudioObtainHdfSBuf(void);
76 int32_t AudioCtlGetVolThresholdRead(struct HdfSBuf *reply, struct AudioCtrlElemInfo *volThreshold);
77 
78 #endif /* AUDIO_INTERFACE_LIB_COMMON_H */
79