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 19 #include <stdlib.h> 20 #include <stdio.h> 21 #include <string.h> 22 #include <unistd.h> 23 #include "securec.h" 24 #include "audio_internal.h" 25 #include "audio_adapter.h" 26 #include "osal_mem.h" 27 #include "hdf_io_service_if.h" 28 #include "hdf_sbuf.h" 29 30 #define CTRL_NUM 100 31 #define SERVIC_NAME_MAX_LEN 32 32 #define AUDIO_MIN_DEVICENUM 1 33 #define AUDIODRV_CTL_ELEM_IFACE_GAIN 2 34 35 #define AUDIO_WAIT_DELAY (10 * 1000) // 10ms 36 #define AUDIO_CAP_WAIT_DELAY (5 * 1000) // 5ms 37 38 #define CTRL_CMD "control" // For Bind control service 39 40 struct AudioPcmHwParams { 41 enum AudioStreamType streamType; 42 uint32_t channels; 43 uint32_t rate; 44 uint32_t periodSize; 45 uint32_t periodCount; 46 enum AudioFormat format; 47 char *cardServiceName; 48 uint32_t period; 49 uint32_t frameSize; 50 uint32_t startThreshold; 51 uint32_t stopThreshold; 52 uint32_t silenceThreshold; 53 bool isBigEndian; 54 bool isSignedData; 55 }; 56 57 struct AudioCtlElemId { 58 const char *cardServiceName; 59 const char *itemName; /* ASCII name of item */ 60 int32_t iface; 61 }; 62 63 struct AudioCtlElemValue { 64 struct AudioCtlElemId id; 65 int32_t value[2]; 66 }; 67 68 struct AudioCtrlElemInfo { 69 struct AudioCtlElemId id; 70 uint32_t count; /* count of values */ 71 int32_t type; /* R: value type - AUDIODRV_CTL_ELEM_IFACE_MIXER_* */ 72 int32_t min; /* R: minimum value */ 73 int32_t max; /* R: maximum value */ 74 }; 75 76 struct HdfIoService *HdfIoServiceBindName(const char *serviceName); 77 void AudioBufReplyRecycle(struct HdfSBuf *sBuf, struct HdfSBuf *reply); 78 int32_t AudioServiceDispatch(struct HdfIoService *service, int cmdId, 79 struct HdfSBuf *sBuf, struct HdfSBuf *reply); 80 struct HdfSBuf *AudioObtainHdfSBuf(void); 81 int32_t AudioCtlGetVolThresholdRead(struct HdfSBuf *reply, struct AudioCtrlElemInfo *volThreshold); 82 83 #endif /* AUDIO_INTERFACE_LIB_COMMON_H */ 84