• 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 HDF_AUDIO_SERVER_COMMON_H
17 #define HDF_AUDIO_SERVER_COMMON_H
18 
19 #include "audio_events.h"
20 #include "audio_internal.h"
21 #include "hdf_audio_server.h"
22 #include "hdf_device_desc.h"
23 #include "hdf_log.h"
24 
25 #define MAX_AUDIO_ADAPTER_NUM_SERVER    8   // Limit the number of sound cards supported to a maximum of 8
26 #define STR_MAX 512
27 
28 enum AudioServerType {
29     AUDIO_SERVER_PRIMARY,
30     AUDIO_SERVER_USB,
31     AUDIO_SERVER_A2DP,
32     AUDIO_SERVER_BOTTOM
33 };
34 
35 typedef int32_t (*AudioAllfunc)(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply);
36 struct HdiServiceDispatchCmdHandleList {
37     enum AudioHdiServerCmdId cmd;
38     AudioAllfunc func;
39 };
40 
41 int32_t HdiServiceRenderCaptureReadData(struct HdfSBuf *data,
42     const char **adapterName, uint32_t *pid);
43 
44 int32_t AudioAdapterListCheckAndGetRender(struct AudioRender **render, struct HdfSBuf *data);
45 
46 int32_t AudioAdapterListCheckAndGetCapture(struct AudioCapture **capture, struct HdfSBuf *data);
47 int32_t ReadAudioSapmleAttrbutes(struct HdfSBuf *data, struct AudioSampleAttributes *attrs);
48 int32_t WriteAudioSampleAttributes(struct HdfSBuf *reply, const struct AudioSampleAttributes *attrs);
49 
50 int32_t HdiServicePositionWrite(struct HdfSBuf *reply,
51     uint64_t frames, struct AudioTimeStamp time);
52 int32_t HdiServiceReqMmapBuffer(struct AudioMmapBufferDescriptor *desc, struct HdfSBuf *data);
53 
54 int32_t HdiServiceGetFuncs();
55 void AudioHdiServerRelease(void);
56 int32_t HdiServiceGetAllAdapter(const struct HdfDeviceIoClient *client,
57     struct HdfSBuf *data, struct HdfSBuf *reply);
58 int32_t HdiServiceLoadAdapter(const struct HdfDeviceIoClient *client,
59     struct HdfSBuf *data, struct HdfSBuf *reply);
60 int32_t HdiServiceInitAllPorts(const struct HdfDeviceIoClient *client,
61     struct HdfSBuf *data, struct HdfSBuf *reply);
62 int32_t HdiServiceUnloadAdapter(const struct HdfDeviceIoClient *client,
63     struct HdfSBuf *data, struct HdfSBuf *reply);
64 int32_t HdiServiceGetPortCapability(const struct HdfDeviceIoClient *client,
65     struct HdfSBuf *data, struct HdfSBuf *reply);
66 int32_t HdiServiceSetPassthroughMode(const struct HdfDeviceIoClient *client,
67     struct HdfSBuf *data, struct HdfSBuf *reply);
68 int32_t HdiServiceGetPassthroughMode(const struct HdfDeviceIoClient *client,
69     struct HdfSBuf *data, struct HdfSBuf *reply);
70 int32_t HdiServiceGetDevStatusByPNP(const struct HdfDeviceIoClient *client,
71     struct HdfSBuf *data, struct HdfSBuf *reply);
72 int32_t AudioServiceStateChange(struct HdfDeviceObject *device,
73     struct AudioEvent *audioSrvEvent);
74 
75 enum AudioServerType AudioHdiGetLoadServerFlag(void);
76 void AudioHdiSetLoadServerFlag(enum AudioServerType serverType);
77 void AudioHdiClearLoadServerFlag(void);
78 
79 int32_t HdiServiceDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data,
80     struct HdfSBuf *reply);
81 #endif
82 
83