• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef AUDIO_PLATFORM_IF_H
10 #define AUDIO_PLATFORM_IF_H
11 
12 #include "audio_host.h"
13 #include "audio_platform_base.h"
14 
15 #ifdef __cplusplus
16 #if __cplusplus
17 extern "C" {
18 #endif
19 #endif /* __cplusplus */
20 
21 /**
22  * @brief Defines paltform private data.
23  *
24  * @since 1.0
25  * @version 1.0
26  */
27 struct PlatformData {
28     const char *drvPlatformName;         /**< Platform module name */
29 
30     /**
31      * @brief Defines platform device init.
32      *
33      * @param audioCard Indicates an audio card device.
34      * @param platform Indicates a platform device.
35      *
36      * @return Returns <b>0</b> if Platform device init success; returns a non-zero value otherwise.
37      *
38      * @since 1.0
39      * @version 1.0
40      */
41     int32_t (*PlatformInit)(const struct AudioCard *audioCard, const struct PlatformDevice *platform);
42 
43     struct AudioDmaOps *ops;             /**< Platform module private data */
44     struct CircleBufInfo renderBufInfo;  /**< Render pcm stream transfer */
45     struct CircleBufInfo captureBufInfo; /**< Capture pcm stream transfer */
46     struct PcmInfo renderPcmInfo;        /**< Render pcm stream info */
47     struct PcmInfo capturePcmInfo;       /**< Capture pcm stream info */
48     bool platformInitFlag;               /**< Platform init flag */
49     struct AudioMmapData mmapData;       /**< Mmap mode transfer data */
50     uint32_t mmapLoopCount;              /**< Loop count for mmap mode pcm stream */
51     void *dmaPrv;                        /**< Platform dma private data */
52 };
53 
54 /**
55  * @brief Defines Dma operation function set.
56  *
57  * @since 1.0
58  * @version 1.0
59  */
60 struct AudioDmaOps {
61     /**
62      * @brief Defines Dma buff alloc.
63      *
64      * @param platformData Indicates dma device.
65      * @param streamType Indicates capture or render.
66      *
67      * @return Returns <b>0</b> if dma buffer alloc success; returns a non-zero value otherwise.
68      *
69      * @since 1.0
70      * @version 1.0
71      */
72     int32_t (*DmaBufAlloc)(struct PlatformData *platformData, const enum AudioStreamType streamType);
73 
74     /**
75      * @brief Defines dma buffer free.
76      *
77      * @param platformData Indicates dma device.
78      * @param streamType Indicates capture or render.
79      *
80      * @return Returns <b>0</b> if dma buffer free success; returns a non-zero value otherwise.
81      *
82      * @since 1.0
83      * @version 1.0
84      */
85     int32_t (*DmaBufFree)(struct PlatformData *platformData, const enum AudioStreamType streamType);
86 
87     /**
88      * @brief Defines dma request channel.
89      *
90      * @param platformData Indicates dma device.
91      *
92      * @return Returns <b>0</b> if dma request channel success; returns a non-zero value otherwise.
93      *
94      * @since 1.0
95      * @version 1.0
96      */
97     int32_t (*DmaRequestChannel)(const struct PlatformData *platformData, const enum AudioStreamType streamType);
98 
99     /**
100      * @brief Defines dma channel config.
101      *
102      * @param platformData Indicates dma device.
103      *
104      * @return Returns <b>0</b> if dma channel config set success; returns a non-zero value otherwise.
105      *
106      * @since 1.0
107      * @version 1.0
108      */
109     int32_t (*DmaConfigChannel)(const struct PlatformData *platformData, const enum AudioStreamType streamType);
110 
111     /**
112      * @brief Defines dma prepare function.
113      *
114      * @param platformData Indicates dma device.
115      *
116      * @return Returns <b>0</b> if dma device prep set success; returns a non-zero value otherwise.
117      *
118      * @since 1.0
119      * @version 1.0
120      */
121     int32_t (*DmaPrep)(const struct PlatformData *platformData, const enum AudioStreamType streamType);
122 
123     /**
124      * @brief Defines dma submit function.
125      *
126      * @param platformData Indicates dma device.
127      *
128      * @return Returns <b>0</b> if dma device submit success; returns a non-zero value otherwise.
129      *
130      * @since 1.0
131      * @version 1.0
132      */
133     int32_t (*DmaSubmit)(const struct PlatformData *platformData, const enum AudioStreamType streamType);
134 
135     /**
136      * @brief Defines dma pending function.
137      *
138      * @param platformData Indicates dma device.
139      *
140      * @return Returns <b>0</b> if dma pending success; returns a non-zero value otherwise.
141      *
142      * @since 1.0
143      * @version 1.0
144      */
145     int32_t (*DmaPending)(struct PlatformData *platformData, const enum AudioStreamType streamType);
146 
147     /**
148      * @brief Defines pcm stream transfer pause.
149      *
150      * @param platformData Indicates dma device.
151      *
152      * @return Returns <b>0</b> if pcm stream transfer pause success; returns a non-zero value otherwise.
153      *
154      * @since 1.0
155      * @version 1.0
156      */
157     int32_t (*DmaPause)(struct PlatformData *platformData, const enum AudioStreamType streamType);
158 
159     /**
160      * @brief Defines pcm stream transfer resume.
161      *
162      * @param platformData Indicates dma device.
163      *
164      * @return Returns <b>0</b> if pcm stream transfer resume success; returns a non-zero value otherwise.
165      *
166      * @since 1.0
167      * @version 1.0
168      */
169     int32_t (*DmaResume)(const struct PlatformData *platformData, const enum AudioStreamType streamType);
170 
171     /**
172      * @brief Defines Get the function of the current playback or recording position.
173      *
174      * @param platformData Indicates dma device.
175      * @param pointer Indicates dma pointer.
176      *
177      * @return Returns <b>0</b> if dma device pointer position get success; returns a non-zero value otherwise.
178      *
179      * @since 1.0
180      * @version 1.0
181      */
182     int32_t (*DmaPointer)(struct PlatformData *platformData, const enum AudioStreamType streamType, uint32_t *pointer);
183 };
184 
185 /**
186  * @brief Defines Platform host in audio driver.
187  *
188  * @since 1.0
189  * @version 1.0
190  */
191 struct PlatformHost {
192     struct IDeviceIoService service; /**< Services provided by patform */
193     struct HdfDeviceObject *device;  /**< HDF device */
194     void *priv;                      /**< Platform private data interface */
195 };
196 
197 /**
198  * @brief Defines Dai device name and data.
199  *
200  * @since 1.0
201  * @version 1.0
202  */
203 struct PlatformDevice {
204     const char *devPlatformName;    /**< Platform device name */
205     struct PlatformData *devData;   /**< Platform module private data */
206     struct HdfDeviceObject *device; /**< HDF device */
207     struct DListHead list;          /**< Platform list */
208 };
209 
210 #ifdef __cplusplus
211 #if __cplusplus
212 }
213 #endif
214 #endif /* __cplusplus */
215 
216 #endif
217