Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
usb_audio.h
Go to the documentation of this file.
1/*
2 * USB audio class core header
3 *
4 * Copyright (c) 2020 Nordic Semiconductor ASA
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
21#ifndef ZEPHYR_INCLUDE_USB_CLASS_AUDIO_H_
22#define ZEPHYR_INCLUDE_USB_CLASS_AUDIO_H_
23
24#include <usb/usb_ch9.h>
25#include <device.h>
26#include <net/buf.h>
27#include <sys/util.h>
28
37};
38
52};
53
62};
63
80};
81
97};
98
103 /* USB Terminal Types */
107
108 /* Input Terminal Types */
116
117 /* Output Terminal Types */
126
127 /* Bi-directional Terminal Types */
134};
135
138 USB_AUDIO_OUT = 0x01
140
160 const void *val;
161};
162
174typedef void (*usb_audio_data_request_cb_t)(const struct device *dev);
175
187typedef void (*usb_audio_data_completion_cb_t)(const struct device *dev,
188 struct net_buf *buffer,
189 size_t size);
190
203typedef void (*usb_audio_feature_updated_cb_t)(const struct device *dev,
204 const struct usb_audio_fu_evt *evt);
205
217 /* Callback called when data could be send */
219
220 /* Callback called when data were successfully written with sending
221 * capable device. Applicable for headset and microphone. Unused for
222 * headphones.
223 */
225
226 /* Callback called when data were successfully received by receive
227 * capable device. Applicable for headset and headphones. Unused for
228 * microphone.
229 */
231
232 /* Callback called when features were modified by the Host */
234};
235
250size_t usb_audio_get_in_frame_size(const struct device *dev);
251
261void usb_audio_register(const struct device *dev,
262 const struct usb_audio_ops *ops);
263
284int usb_audio_send(const struct device *dev, struct net_buf *buffer,
285 size_t len);
286
287#endif /* ZEPHYR_INCLUDE_USB_CLASS_AUDIO_H_ */
void
Definition: eswifi_shell.c:15
static ZTEST_BMEM char buffer[8]
Test mailbox enhance capabilities.
Definition: test_mbox_api.c:566
Buffer management.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
Network buffer representation.
Definition: buf.h:919
uint16_t size
Definition: buf.h:950
Feature Unit event structure.
Definition: usb_audio.h:155
enum usb_audio_fucs cs
Definition: usb_audio.h:157
const void * val
Definition: usb_audio.h:160
enum usb_audio_direction dir
Definition: usb_audio.h:156
uint8_t val_len
Definition: usb_audio.h:159
uint8_t channel
Definition: usb_audio.h:158
Audio callbacks used to interact with audio devices by user App.
Definition: usb_audio.h:216
usb_audio_data_completion_cb_t data_written_cb
Definition: usb_audio.h:224
usb_audio_data_completion_cb_t data_received_cb
Definition: usb_audio.h:230
usb_audio_data_request_cb_t data_request_cb
Definition: usb_audio.h:218
usb_audio_feature_updated_cb_t feature_update_cb
Definition: usb_audio.h:233
usb_audio_int_subclass_codes
Definition: usb_audio.h:32
@ USB_AUDIO_MIDISTREAMING
Definition: usb_audio.h:36
@ USB_AUDIO_AUDIOSTREAMING
Definition: usb_audio.h:35
@ USB_AUDIO_AUDIOCONTROL
Definition: usb_audio.h:34
@ USB_AUDIO_SUBCLASS_UNDEFINED
Definition: usb_audio.h:33
usb_audio_fucs
Definition: usb_audio.h:85
@ USB_AUDIO_FU_CONTROL_UNDEFINED
Definition: usb_audio.h:86
@ USB_AUDIO_FU_BASS_BOOST_CONTROL
Definition: usb_audio.h:95
@ USB_AUDIO_FU_GRAPHIC_EQUALIZER_CONTROL
Definition: usb_audio.h:92
@ USB_AUDIO_FU_BASS_CONTROL
Definition: usb_audio.h:89
@ USB_AUDIO_FU_TREBLE_CONTROL
Definition: usb_audio.h:91
@ USB_AUDIO_FU_VOLUME_CONTROL
Definition: usb_audio.h:88
@ USB_AUDIO_FU_AUTOMATIC_GAIN_CONTROL
Definition: usb_audio.h:93
@ USB_AUDIO_FU_MID_CONTROL
Definition: usb_audio.h:90
@ USB_AUDIO_FU_LOUDNESS_CONTROL
Definition: usb_audio.h:96
@ USB_AUDIO_FU_MUTE_CONTROL
Definition: usb_audio.h:87
@ USB_AUDIO_FU_DELAY_CONTROL
Definition: usb_audio.h:94
void(* usb_audio_data_completion_cb_t)(const struct device *dev, struct net_buf *buffer, size_t size)
Callback type used to inform the app that data were successfully send/received.
Definition: usb_audio.h:187
void(* usb_audio_feature_updated_cb_t)(const struct device *dev, const struct usb_audio_fu_evt *evt)
Callback type used to inform the app that Host has changed one of the features configured for the dev...
Definition: usb_audio.h:203
void usb_audio_register(const struct device *dev, const struct usb_audio_ops *ops)
Register the USB Audio device and make it useable. This must be called in order to make the device wo...
void(* usb_audio_data_request_cb_t)(const struct device *dev)
Callback type used to inform the app that data were requested from the device and may be send to the ...
Definition: usb_audio.h:174
usb_audio_cs_ac_int_desc_subtypes
Definition: usb_audio.h:42
@ USB_AUDIO_MIXER_UNIT
Definition: usb_audio.h:47
@ USB_AUDIO_AC_DESCRIPTOR_UNDEFINED
Definition: usb_audio.h:43
@ USB_AUDIO_OUTPUT_TERMINAL
Definition: usb_audio.h:46
@ USB_AUDIO_HEADER
Definition: usb_audio.h:44
@ USB_AUDIO_INPUT_TERMINAL
Definition: usb_audio.h:45
@ USB_AUDIO_SELECTOR_UNIT
Definition: usb_audio.h:48
@ USB_AUDIO_FEATURE_UNIT
Definition: usb_audio.h:49
@ USB_AUDIO_EXTENSION_UNIT
Definition: usb_audio.h:51
@ USB_AUDIO_PROCESSING_UNIT
Definition: usb_audio.h:50
usb_audio_direction
Definition: usb_audio.h:136
@ USB_AUDIO_OUT
Definition: usb_audio.h:138
@ USB_AUDIO_IN
Definition: usb_audio.h:137
usb_audio_cs_req_codes
Definition: usb_audio.h:67
@ USB_AUDIO_SET_CUR
Definition: usb_audio.h:69
@ USB_AUDIO_SET_RES
Definition: usb_audio.h:75
@ USB_AUDIO_GET_STAT
Definition: usb_audio.h:79
@ USB_AUDIO_GET_MIN
Definition: usb_audio.h:72
@ USB_AUDIO_GET_RES
Definition: usb_audio.h:76
@ USB_AUDIO_GET_MEM
Definition: usb_audio.h:78
@ USB_AUDIO_REQUEST_CODE_UNDEFINED
Definition: usb_audio.h:68
@ USB_AUDIO_SET_MIN
Definition: usb_audio.h:71
@ USB_AUDIO_GET_CUR
Definition: usb_audio.h:70
@ USB_AUDIO_SET_MAX
Definition: usb_audio.h:73
@ USB_AUDIO_GET_MAX
Definition: usb_audio.h:74
@ USB_AUDIO_SET_MEM
Definition: usb_audio.h:77
usb_audio_terminal_types
Definition: usb_audio.h:102
@ USB_AUDIO_IO_SPEAKERPHONE_ECHO_NONE
Definition: usb_audio.h:131
@ USB_AUDIO_IO_HANDSET
Definition: usb_audio.h:129
@ USB_AUDIO_IN_MIC_ARRAY
Definition: usb_audio.h:114
@ USB_AUDIO_IN_DESKTOP_MIC
Definition: usb_audio.h:111
@ USB_AUDIO_IO_SPEAKERPHONE_ECHO_CAN
Definition: usb_audio.h:133
@ USB_AUDIO_OUT_SPEAKER
Definition: usb_audio.h:119
@ USB_AUDIO_IN_PERSONAL_MIC
Definition: usb_audio.h:112
@ USB_AUDIO_IN_OM_DIR_MIC
Definition: usb_audio.h:113
@ USB_AUDIO_USB_VENDOR_SPEC
Definition: usb_audio.h:106
@ USB_AUDIO_OUT_UNDEFINED
Definition: usb_audio.h:118
@ USB_AUDIO_IN_MICROPHONE
Definition: usb_audio.h:110
@ USB_AUDIO_OUT_LOW_FREQ_SPEAKER
Definition: usb_audio.h:125
@ USB_AUDIO_USB_UNDEFINED
Definition: usb_audio.h:104
@ USB_AUDIO_USB_STREAMING
Definition: usb_audio.h:105
@ USB_AUDIO_IO_SPEAKERPHONE_ECHO_SUP
Definition: usb_audio.h:132
@ USB_AUDIO_OUT_HEADPHONES
Definition: usb_audio.h:120
@ USB_AUDIO_IN_PROC_MIC_ARRAY
Definition: usb_audio.h:115
@ USB_AUDIO_IO_UNDEFINED
Definition: usb_audio.h:128
@ USB_AUDIO_OUT_DESKTOP_SPEAKER
Definition: usb_audio.h:122
@ USB_AUDIO_OUT_ROOM_SPEAKER
Definition: usb_audio.h:123
@ USB_AUDIO_OUT_HEAD_AUDIO
Definition: usb_audio.h:121
@ USB_AUDIO_IO_HEADSET
Definition: usb_audio.h:130
@ USB_AUDIO_IN_UNDEFINED
Definition: usb_audio.h:109
@ USB_AUDIO_OUT_COMM_SPEAKER
Definition: usb_audio.h:124
usb_audio_cs_as_int_desc_subtypes
Definition: usb_audio.h:57
@ USB_AUDIO_AS_DESCRIPTOR_UNDEFINED
Definition: usb_audio.h:58
@ USB_AUDIO_AS_GENERAL
Definition: usb_audio.h:59
@ USB_AUDIO_FORMAT_TYPE
Definition: usb_audio.h:60
@ USB_AUDIO_FORMAT_SPECIFIC
Definition: usb_audio.h:61
int usb_audio_send(const struct device *dev, struct net_buf *buffer, size_t len)
Send data using USB Audio device.
size_t usb_audio_get_in_frame_size(const struct device *dev)
Get the frame size that is accepted by the Host.
USB Chapter 9 structures and definitions.
Misc utilities.