Skip to content

Commit 56c3f36

Browse files
committed
[doxygen][audio] Fix doxygen comments for audio component
Added comments for data structure and rt_audio_ops in dev_audio.h. Enriched comments for macro group. Moved and renamed folder audio. Signed-off-by: 1078249029 <[email protected]>
1 parent f7d5421 commit 56c3f36

File tree

5 files changed

+68
-49
lines changed

5 files changed

+68
-49
lines changed

components/drivers/audio/dev_audio.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2017-05-09 Urey first version
99
* 2019-07-09 Zero-Free improve device ops interface and data flows
10+
* 2025-03-04 wumingzi add doxygen comments.
1011
*/
1112

1213
#include <stdio.h>
@@ -23,7 +24,7 @@
2324
#endif
2425

2526
/**
26-
* @addtogroup group_AudioPipe
27+
* @addtogroup group_Audio
2728
*/
2829

2930
/** @{ */

components/drivers/audio/dev_audio_pipe.c

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2012-09-30 Bernard first version.
9+
* 2025-03-04 wumingzi add doxygen comments.
910
*/
1011

1112
#include <rthw.h>

components/drivers/audio/dev_audio_pipe.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
* Change Logs:
77
* Date Author Notes
8+
* 2025-03-04 wumingzi add doxygen comments.
89
*/
910
#ifndef __DEV_AUDIO_PIPE_H__
1011
#define __DEV_AUDIO_PIPE_H__

components/drivers/include/drivers/dev_audio.h

+64-48
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Date Author Notes
88
* 2017-05-09 Urey first version
99
* 2019-07-09 Zero-Free improve device ops interface and data flows
10-
*
10+
* 2025-03-04 wumingzi add doxygen comments.
1111
*/
1212

1313
#ifndef __DEV_AUDIO_H__
@@ -54,7 +54,7 @@
5454
#define AUDIO_CTL_STOP _AUDIO_CTL(4) /**< Stop audio device */
5555
#define AUDIO_CTL_GETBUFFERINFO _AUDIO_CTL(5) /**< Get audio device buffer information */
5656

57-
/** @} */ /* End of audio_control*/
57+
/** @} */ /* End of audio_control */
5858

5959
/**
6060
* @defgroup audio_type AUDIO_TYPE
@@ -70,7 +70,7 @@
7070
#define AUDIO_TYPE_INPUT 0x01 /**< Set audio device type to input type */
7171
#define AUDIO_TYPE_OUTPUT 0x02 /**< Set audio device type to output type */
7272
#define AUDIO_TYPE_MIXER 0x04 /**< Set audio device type to mixer type */
73-
/** @} */ /* End of audio_type*/
73+
/** @} */ /* End of audio_type */
7474

7575
/**
7676
* @defgroup audio_samp_rates AUDIO_SAMP_RATES
@@ -94,7 +94,7 @@
9494
#define AUDIO_SAMP_RATE_160K 0x0200 /**< Set audio device sample rate to 160K */
9595
#define AUDIO_SAMP_RATE_172K 0x0400 /**< Set audio device sample rate to 172K */
9696
#define AUDIO_SAMP_RATE_192K 0x0800 /**< Set audio device sample rate to 192K */
97-
/** @} */ /* End of audio_samp_rates*/
97+
/** @} */ /* End of audio_samp_rates */
9898

9999
/**
100100
* @defgroup audio_bit_rates AUDIO_BIT_RATES
@@ -114,13 +114,14 @@
114114
#define AUDIO_BIT_RATE_160K 0x20 /**< Set audio device bit rates to 160K */
115115
#define AUDIO_BIT_RATE_172K 0x40 /**< Set audio device bit rates to 172K */
116116
#define AUDIO_BIT_RATE_192K 0x80 /**< Set audio device bit rates to 192K */
117-
/** @} */ /* End of audio_bit_rates*/
117+
/** @} */ /* End of audio_bit_rates */
118118

119119

120120
/**
121121
* @defgroup audio_dsp AUDIO_DSP
122122
*
123-
* @brief Support Dsp(input/output) Units controls
123+
* @brief Support Dsp(input/output) Units controls. The macro group from application level, can
124+
* set audio mixer parameters including samplerate, channels etc.
124125
*/
125126

126127
/**
@@ -131,12 +132,13 @@
131132
#define AUDIO_DSP_SAMPLERATE 1 /**< samplerate */
132133
#define AUDIO_DSP_CHANNELS 2 /**< channels */
133134
#define AUDIO_DSP_SAMPLEBITS 3 /**< sample bits width */
134-
/** @} */ /* End of audio_dsp*/
135+
/** @} */ /* End of audio_dsp */
135136

136137
/**
137138
* @defgroup audio_mixer AUDIO_MIXER
138139
*
139-
* @brief Supported Mixer Units controls
140+
* @brief Supported Mixer Units controls. The macro group from driver level, can set audio mixer
141+
* parameters including volume, frequence db, microphone etc.
140142
*/
141143

142144
/**
@@ -147,15 +149,15 @@
147149
#define AUDIO_MIXER_MUTE 0x0001 /**< Mute audio device */
148150
#define AUDIO_MIXER_VOLUME 0x0002 /**< Set mixer volume */
149151
#define AUDIO_MIXER_BASS 0x0004 /**< Set the low-frequency section of the mixer */
150-
#define AUDIO_MIXER_MID 0x0008 /**< Set the mid-frequency section of the mixer*/
152+
#define AUDIO_MIXER_MID 0x0008 /**< Set the mid-frequency section of the mixer */
151153
#define AUDIO_MIXER_TREBLE 0x0010 /**< Set the high-frequency section of the mixer */
152154
#define AUDIO_MIXER_EQUALIZER 0x0020 /**< Set equalizer option */
153155
#define AUDIO_MIXER_LINE 0x0040 /**< Set line control option */
154156
#define AUDIO_MIXER_DIGITAL 0x0080 /**< Set digital source */
155157
#define AUDIO_MIXER_MIC 0x0100 /**< Set microphone option */
156158
#define AUDIO_MIXER_VITURAL 0x0200 /**< Set virtual audio option */
157159
#define AUDIO_MIXER_EXTEND 0x8000 /**< Extend mixer command */
158-
/** @} */ /* End of audio_mixer*/
160+
/** @} */ /* End of audio_mixer */
159161

160162
#define AUDIO_VOLUME_MAX (100)
161163
#define AUDIO_VOLUME_MIN (0)
@@ -181,25 +183,36 @@ enum
181183
*/
182184
struct rt_audio_buf_info
183185
{
184-
rt_uint8_t *buffer;
185-
rt_uint16_t block_size;
186-
rt_uint16_t block_count;
187-
rt_uint32_t total_size;
186+
rt_uint8_t *buffer; /**< Audio buffer information */
187+
rt_uint16_t block_size; /**< Audio block_size information for replay function */
188+
rt_uint16_t block_count; /**< Audio block_count information for replay function */
189+
rt_uint32_t total_size; /**< Audio total_size which is equal to block_size multiplying
190+
block_count information for replay function */
188191
};
189192

190193
struct rt_audio_device;
191194
struct rt_audio_caps;
192195
struct rt_audio_configure;
196+
197+
/**
198+
* @brief Aduio device operators
199+
*/
193200
struct rt_audio_ops
194-
{
195-
rt_err_t (*getcaps)(struct rt_audio_device *audio, struct rt_audio_caps *caps);
196-
rt_err_t (*configure)(struct rt_audio_device *audio, struct rt_audio_caps *caps);
197-
rt_err_t (*init)(struct rt_audio_device *audio);
198-
rt_err_t (*start)(struct rt_audio_device *audio, int stream);
199-
rt_err_t (*stop)(struct rt_audio_device *audio, int stream);
201+
{
202+
/** Get audio capabilities information */
203+
rt_err_t (*getcaps)(struct rt_audio_device *audio, struct rt_audio_caps *caps);
204+
/** Configure audio devices */
205+
rt_err_t (*configure)(struct rt_audio_device *audio, struct rt_audio_caps *caps);
206+
/** Initialize audio device */
207+
rt_err_t (*init)(struct rt_audio_device *audio);
208+
/** Turn on the audio device */
209+
rt_err_t (*start)(struct rt_audio_device *audio, int stream);
210+
/** Turn off the audio device */
211+
rt_err_t (*stop)(struct rt_audio_device *audio, int stream);
212+
/** Transmit data between application and device */
200213
rt_ssize_t (*transmit)(struct rt_audio_device *audio, const void *writeBuf, void *readBuf, rt_size_t size);
201-
/* get page size of codec or private buffer's info */
202-
void (*buffer_info)(struct rt_audio_device *audio, struct rt_audio_buf_info *info);
214+
/** Get page size of codec or private buffer's info */
215+
void (*buffer_info)(struct rt_audio_device *audio, struct rt_audio_buf_info *info);
203216
};
204217

205218
/**
@@ -211,43 +224,45 @@ struct rt_audio_ops
211224
*/
212225
struct rt_audio_configure
213226
{
214-
rt_uint32_t samplerate;
215-
rt_uint16_t channels;
216-
rt_uint16_t samplebits;
227+
rt_uint32_t samplerate; /**< Audio samplerate information */
228+
rt_uint16_t channels; /**< Audio channels information */
229+
rt_uint16_t samplebits; /**< Audio samplebits information */
217230
};
218231

219232
/**
220233
* @brief Audio capabilities
221234
*/
222235
struct rt_audio_caps
223236
{
224-
int main_type;
225-
int sub_type;
237+
int main_type; /**< Audio main type, one value of @ref audio_type */
238+
int sub_type; /**< Audio sub type, one value of @ref audio_dsp @ref audio_mixer */
226239

227240
union
228241
{
229-
rt_uint32_t mask;
230-
int value;
231-
struct rt_audio_configure config;
232-
} udata;
242+
rt_uint32_t mask; /**< Capabilities mask */
243+
int value; /**< Capabilities value */
244+
struct rt_audio_configure config; /**< Audio samplebits information */
245+
} udata; /**< User data */
233246
};
234247

235248
/**
236249
* @brief Audio replay
237250
*/
238251
struct rt_audio_replay
239252
{
240-
struct rt_mempool *mp;
241-
struct rt_data_queue queue;
242-
struct rt_mutex lock;
243-
struct rt_completion cmp;
244-
struct rt_audio_buf_info buf_info;
245-
rt_uint8_t *write_data;
246-
rt_uint16_t write_index;
247-
rt_uint16_t read_index;
248-
rt_uint32_t pos;
249-
rt_uint8_t event;
250-
rt_bool_t activated;
253+
struct rt_mempool *mp; /**< Memory pool for audio replay */
254+
struct rt_data_queue queue; /**< Replay data queue */
255+
struct rt_mutex lock; /**< Replay mutex lock */
256+
struct rt_completion cmp; /**< Replay completion, it will be */
257+
struct rt_audio_buf_info buf_info; /**< Replay buffer information */
258+
rt_uint8_t *write_data; /**< Pointer to the data to be written into data queue */
259+
rt_uint16_t write_index; /**< Index of pointer write_data.It records how much data
260+
has been written in currently being played block */
261+
rt_uint16_t read_index; /**< Index of replaying data for audio device, it indicates index
262+
of replay in the blocks which is currently being played */
263+
rt_uint32_t pos; /**< Global position of audio replay */
264+
rt_uint8_t event; /**< Event flag */
265+
rt_bool_t activated; /**< Activaty flag */
251266
};
252267

253268
/**
@@ -264,10 +279,10 @@ struct rt_audio_record
264279
*/
265280
struct rt_audio_device
266281
{
267-
struct rt_device parent;
268-
struct rt_audio_ops *ops;
269-
struct rt_audio_replay *replay;
270-
struct rt_audio_record *record;
282+
struct rt_device parent; /**< Audio device parents */
283+
struct rt_audio_ops *ops; /**< Audio device operator */
284+
struct rt_audio_replay *replay; /**< Pointer to audio replay structure */
285+
struct rt_audio_record *record; /**< Pointer to audio record structure */
271286
};
272287

273288
rt_err_t rt_audio_register(struct rt_audio_device *audio, const char *name, rt_uint32_t flag, void *data);
@@ -277,7 +292,8 @@ void rt_audio_rx_done(struct rt_audio_device *audio, rt_uint8_t *pbuf, rt
277292
/**
278293
* @defgroup audio_codec_cmd CODEC_CMD
279294
*
280-
* @brief Device Control Commands
295+
* @brief Device Control Commands. The macro group from hardware level, can set codec
296+
* parametes including volume, EQ and 3D etc.
281297
*/
282298

283299
/**
@@ -292,7 +308,7 @@ void rt_audio_rx_done(struct rt_audio_device *audio, rt_uint8_t *pbuf, rt
292308
#define CODEC_CMD_3D 5 /**< Set 3D effect by codec */
293309

294310
#define CODEC_VOLUME_MAX (63)
295-
/** @} */ /* End of audio_codec_cmd*/
311+
/** @} */ /* End of audio_codec_cmd */
296312

297313
/** @} group_Audio */
298314

0 commit comments

Comments
 (0)