• 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_DAI_IF_H
10 #define AUDIO_DAI_IF_H
11 
12 #include "audio_host.h"
13 #include "audio_parse.h"
14 #include "audio_control.h"
15 
16 #ifdef __cplusplus
17 #if __cplusplus
18 extern "C" {
19 #endif
20 #endif /* __cplusplus */
21 
22 /**
23  * @brief Defines Dai device name and data.
24  *
25  * @since 1.0
26  * @version 1.0
27  */
28 struct DaiDevice {
29     const char *devDaiName;         /**< Dai device name */
30     struct DaiData *devData;        /**< Dai module private data */
31     struct HdfDeviceObject *device; /**< HDF device */
32     struct DListHead list;          /**< Dai list */
33 };
34 
35 /**
36  * @brief Defines Dai operation function set.
37  *
38  * @since 1.0
39  * @version 1.0
40  */
41 struct AudioDaiOps {
42     /**
43      * @brief Defines Dai device start up function.
44      *
45      * @param audioCard Indicates a audio card device.
46      * @param dai Indicates a dai device.
47      *
48      * @return Returns <b>0</b> if dai device start up success; returns a non-zero value otherwise.
49      *
50      * @since 1.0
51      * @version 1.0
52      */
53     int32_t (*Startup)(const struct AudioCard *audioCard, const struct DaiDevice *dai);
54 
55     /**
56      * @brief Defines Dai device hardware param set function.
57      *
58      * @param audioCard Indicates a audio card device.
59      * @param param Indicates pcm param set.
60      *
61      * @return Returns <b>0</b> if dai pcm param set success; returns a non-zero value otherwise.
62      *
63      * @since 1.0
64      * @version 1.0
65      */
66     int32_t (*HwParams)(const struct AudioCard *audioCard, const struct AudioPcmHwParams *param);
67 
68     /**
69      * @brief Defines Dai device trigger function.
70      *
71      * @param audioCard Indicates a audio card device.
72      * @param cmd Indicates a Command id.
73      * @param dai Indicates a dai device.
74      *
75      * @return Returns <b>0</b> if dai device trigger success; returns a non-zero value otherwise.
76      *
77      * @since 1.0
78      * @version 1.0
79      */
80     int32_t (*Trigger)(const struct AudioCard *audioCard, int cmd, const struct DaiDevice *dai);
81 };
82 
83 /**
84  * @brief Defines dai private data.
85  *
86  * @since 1.0
87  * @version 1.0
88  */
89 struct DaiData {
90     const char *drvDaiName;                    /**< dai driver name */
91 
92     /**
93      * @brief Defines Dai device init.
94      *
95      * @param audioCard Indicates a audio card device.
96      * @param dai Indicates a dai device.
97      *
98      * @return Returns <b>0</b> if dai device init success; returns a non-zero value otherwise.
99      *
100      * @since 1.0
101      * @version 1.0
102      */
103     int32_t (*DaiInit)(struct AudioCard *audioCard, const struct DaiDevice *dai);
104 
105     /**
106      * @brief Defines Dai device reg read.
107      *
108      * @param virtualAddress Indicates base reg IoRemap address.
109      * @param reg Indicates reg offset.
110      * @param value Indicates read reg value.
111      *
112      * @return Returns <b>0</b> if dai device read reg success; returns a non-zero value otherwise.
113      *
114      * @since 1.0
115      * @version 1.0
116      */
117     int32_t (*Read)(unsigned long virtualAddress, uint32_t reg, uint32_t *value);
118 
119     /**
120      * @brief Defines Dai device reg write.
121      *
122      * @param virtualAddress Indicates base reg IoRemap address.
123      * @param reg Indicates reg offset.
124      * @param value Indicates write reg value.
125      *
126      * @return Returns <b>0</b> if dai device write reg success; returns a non-zero value otherwise.
127      *
128      * @since 1.0
129      * @version 1.0
130      */
131     int32_t (*Write)(unsigned long virtualAddress, uint32_t reg, uint32_t value);
132 
133     const struct AudioDaiOps *ops;             /**< dai set of operation functions */
134     struct PcmInfo pcmInfo;                    /**< dai pcm info */
135     struct AudioKcontrol *controls;            /**< dai control structure array pointer */
136     int numControls;                           /**< dai controls the number of structure array elements */
137     bool daiInitFlag;                          /**< dai init flag */
138     unsigned long regVirtualAddr;              /**< dai base reg IoRemap address */
139     struct AudioRegCfgData *regConfig;         /**< dai registers configured in HCS */
140     struct AudioRegCfgGroupNode **regCfgGroup; /**< dai register group configured in HCS */
141     struct OsalMutex mutex;                    /**< dai mutex */
142 };
143 
144 /**
145  * @brief Defines Dai host in audio driver.
146  *
147  * @since 1.0
148  * @version 1.0
149  */
150 struct DaiHost {
151     struct IDeviceIoService service; /**< Services provided by dai */
152     struct HdfDeviceObject *device;  /**< HDF device */
153     void *priv;                      /**< Dai private data interface */
154 };
155 
156 #ifdef __cplusplus
157 #if __cplusplus
158 }
159 #endif
160 #endif /* __cplusplus */
161 
162 #endif
163