• 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_CODEC_IF_H
10 #define AUDIO_CODEC_IF_H
11 
12 #include "audio_host.h"
13 #include "audio_control.h"
14 
15 #ifdef __cplusplus
16 #if __cplusplus
17 extern "C" {
18 #endif
19 #endif /* __cplusplus */
20 
21 /**
22  * @brief Defines Codec device name and data.
23  *
24  * @since 1.0
25  * @version 1.0
26  */
27 struct CodecDevice {
28     const char *devCodecName;       /**< Codec device name */
29     struct CodecData *devData;      /**< Codec module private data */
30     struct HdfDeviceObject *device; /**< HDF device */
31     struct DListHead list;          /**< Codec list */
32     struct OsalMutex mutex;         /**< Codec mutex */
33 };
34 
35 /**
36  * @brief Defines Codec private data.
37  *
38  * @since 1.0
39  * @version 1.0
40  */
41 struct CodecData {
42     const char *drvCodecName;                  /**< Codec driver name */
43 
44     /**
45      * @brief Defines Codec device init.
46      *
47      * @param audioCard Indicates a audio card device.
48      * @param codec Indicates a codec device.
49      *
50      * @return Returns <b>0</b> if codec device init success; returns a non-zero value otherwise.
51      *
52      * @since 1.0
53      * @version 1.0
54      */
55     int32_t (*Init)(struct AudioCard *audioCard, const struct CodecDevice *codec);
56 
57     /**
58      * @brief Defines Codec device reg read.
59      *
60      * @param virtualAddress Indicates base reg IoRemap address.
61      * @param reg Indicates reg offset.
62      * @param value Indicates read reg value.
63      *
64      * @return Returns <b>0</b> if codec device read reg success; returns a non-zero value otherwise.
65      *
66      * @since 1.0
67      * @version 1.0
68      */
69     int32_t (*Read)(unsigned long virtualAddress, uint32_t reg, uint32_t *value);
70 
71     /**
72      * @brief Defines Codec device reg write.
73      *
74      * @param virtualAddress Indicates base reg IoRemap address.
75      * @param reg Indicates reg offset.
76      * @param value Indicates write reg value.
77      *
78      * @return Returns <b>0</b> if codec device write reg success; returns a non-zero value otherwise.
79      *
80      * @since 1.0
81      * @version 1.0
82      */
83     int32_t (*Write)(unsigned long virtualAddress, uint32_t reg, uint32_t value);
84 
85     struct AudioKcontrol *controls;            /**< Codec control structure array pointer */
86     int numControls;                           /**< Number of array elements of Codec controls */
87     struct AudioSapmComponent *sapmComponents; /**< Codec power management component array pointer */
88     int numSapmComponent;                      /**< Number of array elements of codec power management component */
89     const struct AudioSapmRoute *sapmRoutes;   /**< Codec power management route array pointer */
90     int numSapmRoutes;                         /**< Number of power management route array elements */
91     unsigned long virtualAddress;              /**< Codec base reg IoRemap address */
92     struct AudioRegCfgData *regConfig;         /**< Codec registers configured in HCS */
93     struct AudioRegCfgGroupNode **regCfgGroup; /**< Codec register group configured in HCS */
94 };
95 
96 /**
97  * @brief Defines Codec host in audio driver.
98  *
99  * @since 1.0
100  * @version 1.0
101  */
102 struct CodecHost {
103     struct IDeviceIoService service; /**< Services provided by codec */
104     struct HdfDeviceObject *device;  /**< HDF device */
105     void *priv;                      /**< Codec private data interface */
106 };
107 
108 #ifdef __cplusplus
109 #if __cplusplus
110 }
111 #endif
112 #endif /* __cplusplus */
113 
114 #endif /* CODEC_CORE_H */
115