1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** USBX Component */ 17 /** */ 18 /** Device Audio Class */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* COMPONENT DEFINITION RELEASE */ 27 /* */ 28 /* ux_device_class_audio.h PORTABLE C */ 29 /* 6.3.0 */ 30 /* AUTHOR */ 31 /* */ 32 /* Chaoqiong Xiao, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file contains all the header and extern functions used by the */ 37 /* USBX audio class. */ 38 /* */ 39 /* RELEASE HISTORY */ 40 /* */ 41 /* DATE NAME DESCRIPTION */ 42 /* */ 43 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 44 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 45 /* used UX prefix to refer to */ 46 /* TX symbols instead of using */ 47 /* them directly, */ 48 /* resulting in version 6.1 */ 49 /* 08-02-2021 Wen Wang Modified comment(s), */ 50 /* added extern "C" keyword */ 51 /* for compatibility with C++, */ 52 /* resulting in version 6.1.8 */ 53 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ 54 /* added feedback support, */ 55 /* resulting in version 6.1.10 */ 56 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */ 57 /* fixed standalone compile, */ 58 /* resulting in version 6.1.11 */ 59 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 60 /* added interrupt support, */ 61 /* resulting in version 6.1.12 */ 62 /* 10-31-2022 Yajun Xia Modified comment(s), */ 63 /* added standalone support, */ 64 /* resulting in version 6.2.0 */ 65 /* 03-08-2023 Chaoqiong Xiao Modified comment(s), */ 66 /* added error checks support, */ 67 /* resulting in version 6.2.1 */ 68 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ 69 /* added a new mode to manage */ 70 /* endpoint buffer in classes */ 71 /* with zero copy enabled, */ 72 /* resulting in version 6.3.0 */ 73 /* */ 74 /**************************************************************************/ 75 76 #ifndef UX_DEVICE_CLASS_AUDIO_H 77 #define UX_DEVICE_CLASS_AUDIO_H 78 79 /* Determine if a C++ compiler is being used. If so, ensure that standard 80 C is used to process the API information. */ 81 82 #ifdef __cplusplus 83 84 /* Yes, C++ compiler is present. Use standard C. */ 85 extern "C" { 86 87 #endif 88 89 90 /* Compile option: if defined, audio feedback endpoint is supported. */ 91 /* #define UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT */ 92 93 /* Compile option: if defined, audio interrupt endpoint is supported. */ 94 /* #define UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT */ 95 96 /* Internal option: enable the basic USBX error checking. This define is typically used 97 while debugging application. */ 98 #if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING) 99 #define UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING 100 #endif 101 102 103 /* Works if UX_DEVICE_ENDPOINT_BUFFER_OWNER is 1. 104 If defined, it represents feedback endpoint buffer size. 105 It should be larger than feedback endpoint max packet size in framework. */ 106 #define UX_DEVICE_CLASS_AUDIO_FEEDBACK_BUFFER_SIZE 8 107 108 109 /* Define Audio Class OS related constants. */ 110 #define UX_DEVICE_CLASS_AUDIO_FEEDBACK_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE 111 #define UX_DEVICE_CLASS_AUDIO_INTERRUPT_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE 112 113 /* Define Audio Class function (AF) constants. */ 114 115 #define UX_DEVICE_CLASS_AUDIO_FUNCTION_CLASS 1 116 #define UX_DEVICE_CLASS_AUDIO_FUNCTION_SUBCLASS_UNDEFINED 0 117 #define UX_DEVICE_CLASS_AUDIO_FUNCTION_PROTOCOL_UNDEFINED 0 118 #define UX_DEVICE_CLASS_AUDIO_FUNCTION_PROTOCOL_VERSION_02_00 0x20 119 120 /* Define Audio Class interface constants. */ 121 122 #define UX_DEVICE_CLASS_AUDIO_CLASS 1 123 124 #define UX_DEVICE_CLASS_AUDIO_SUBCLASS_UNDEFINED 0 125 #define UX_DEVICE_CLASS_AUDIO_SUBCLASS_CONTROL 1 126 #define UX_DEVICE_CLASS_AUDIO_SUBCLASS_AUDIOSTREAMING 2 127 #define UX_DEVICE_CLASS_AUDIO_SUBCLASS_MIDISTREAMING 3 128 129 #define UX_DEVICE_CLASS_AUDIO_PROTOCOL_UNDEFINED 0 130 #define UX_DEVICE_CLASS_AUTIO_PROTOCOL_VERSION_02_00 0x20 131 132 133 /* Define Audio Class-specific (CS) descriptor types. */ 134 135 #define UX_DEVICE_CLASS_AUDIO_CS_UNDEFINED 0x20 136 #define UX_DEVICE_CLASS_AUDIO_CS_DEVICE 0x21 137 #define UX_DEVICE_CLASS_AUDIO_CS_CONFIGURATION 0x22 138 #define UX_DEVICE_CLASS_AUDIO_CS_STRING 0x23 139 #define UX_DEVICE_CLASS_AUDIO_CS_INTERFACE 0x24 140 #define UX_DEVICE_CLASS_AUDIO_CS_ENDPOINT 0x25 141 142 143 /* Define Audio Class specific AC interface descriptor subclasses. */ 144 145 #define UX_DEVICE_CLASS_AUDIO_AC_UNDEFINED 0x00 146 #define UX_DEVICE_CLASS_AUDIO_AC_HEADER 0x01 147 #define UX_DEVICE_CLASS_AUDIO_AC_INPUT_TERMINAL 0x02 148 #define UX_DEVICE_CLASS_AUDIO_AC_OUTPUT_TERMINAL 0x03 149 #define UX_DEVICE_CLASS_AUDIO_AC_FEATURE_UNIT 0x06 150 151 152 /* Define Audio Class specific AS interface descriptor subclasses. */ 153 154 #define UX_DEVICE_CLASS_AUDIO_AS_UNDEFINED 0x00 155 #define UX_DEVICE_CLASS_AUDIO_AS_GENERAL 0x01 156 #define UX_DEVICE_CLASS_AUDIO_AS_FORMAT_TYPE 0x02 157 158 159 /* Define Audio Class data endpoint descriptor attributes. */ 160 161 #define UX_DEVICE_CLASS_AUDIO_EP_TRANSFER_TYPE_MASK (0x3u<<0) 162 #define UX_DEVICE_CLASS_AUDIO_EP_TRANSFER_TYPE_ISOCHRONOUS (0x1u<<0) 163 164 #define UX_DEVICE_CLASS_AUDIO_EP_SYNCHRONIZATION_TYPE_MASK (0x3u<<2) 165 #define UX_DEVICE_CLASS_AUDIO_EP_SYNCHRONIZATION_TYPE_ASYNCHRONOUS (0x1u<<2) 166 #define UX_DEVICE_CLASS_AUDIO_EP_SYNCHRONIZATION_TYPE_ADAPTIVE (0x2u<<2) 167 #define UX_DEVICE_CLASS_AUDIO_EP_SYNCHRONIZATION_TYPE_SYNCHRONOUS (0x3u<<2) 168 169 #define UX_DEVICE_CLASS_AUDIO_EP_USAGE_TYPE_MASK (0x3u<<4) 170 #define UX_DEVICE_CLASS_AUDIO_EP_USAGE_TYPE_DATA (0x0u<<4) 171 #define UX_DEVICE_CLASS_AUDIO_EP_USAGE_TYPE_FEEDBACK (0x1u<<4) 172 #define UX_DEVICE_CLASS_AUDIO_EP_USAGE_TYPE_IMPLICIT_FEEDBACK (0x2u<<4) 173 174 175 /* Define Audio Class specific endpoint descriptor subtypes. */ 176 177 #define UX_DEVICE_CLASS_AUDIO_EP_UNDEFINED 0x00 178 #define UX_DEVICE_CLASS_AUDIO_EP_GENERAL 0x01 179 180 181 /* Define Audio Class specific request codes. */ 182 183 #define UX_DEVICE_CLASS_AUDIO_REQUEST_CODE_UNDEFINED 0x00 184 185 #define UX_DEVICE_CLASS_AUDIO_bmRequestType_GET_INTERFACE 0xA1 186 #define UX_DEVICE_CLASS_AUDIO_bmRequestType_SET_INTERFACE 0x21 187 #define UX_DEVICE_CLASS_AUDIO_bmRequestType_GET_ENDPOINT 0xA2 188 #define UX_DEVICE_CLASS_AUDIO_bmRequestType_SET_ENDPOINT 0x22 189 190 #define UX_DEVICE_CLASS_AUDIO_REQUEST_REQUEST_TYPE 0 191 #define UX_DEVICE_CLASS_AUDIO_REQUEST_REQUEST 1 192 193 #define UX_DEVICE_CLASS_AUDIO_REQUEST_VALUE_LOW 2 194 #define UX_DEVICE_CLASS_AUDIO_REQUEST_CHANNEL_NUMBER 2 195 #define UX_DEVICE_CLASS_AUDIO_REQUEST_CN 2 196 #define UX_DEVICE_CLASS_AUDIO_REQUEST_MIXER_CONTROL_NUMBER 2 197 #define UX_DEVICE_CLASS_AUDIO_REQUEST_MCN 2 198 199 #define UX_DEVICE_CLASS_AUDIO_REQUEST_VALUE_HIGH 3 200 #define UX_DEVICE_CLASS_AUDIO_REQUEST_CONTROL_SELECTOR 3 201 #define UX_DEVICE_CLASS_AUDIO_REQUEST_CS 3 202 203 #define UX_DEVICE_CLASS_AUDIO_REQUEST_INDEX_LOW 4 204 #define UX_DEVICE_CLASS_AUDIO_REQUEST_ENDPOINT 4 205 #define UX_DEVICE_CLASS_AUDIO_REQUEST_INTERFACE 4 206 207 #define UX_DEVICE_CLASS_AUDIO_REQUEST_INDEX_HIGH 5 208 #define UX_DEVICE_CLASS_AUDIO_REQUEST_ENEITY_ID 5 209 210 #define UX_DEVICE_CLASS_AUDIO_REQUEST_LENGTH 6 211 212 213 /* Define Audio Class terminal types. */ 214 215 #define UX_DEVICE_CLASS_AUDIO_UNDEFINED 0x0100 216 #define UX_DEVICE_CLASS_AUDIO_USB_STREAMING 0x0101 217 #define UX_DEVICE_CLASS_AUDIO_USB_VENDOR_SPECIFIC 0x01FF 218 219 220 /* Define Audio Class input terminal types. */ 221 222 #define UX_DEVICE_CLASS_AUDIO_INPUT 0x0200 223 #define UX_DEVICE_CLASS_AUDIO_MICROPHONE 0x0201 224 #define UX_DEVICE_CLASS_AUDIO_DESKTOP_MICROPHONE 0x0202 225 #define UX_DEVICE_CLASS_AUDIO_PERSONAL_MICROPHONE 0x0203 226 #define UX_DEVICE_CLASS_AUDIO_OMNI_DIRECTIONAL_MICROPHONE 0x0204 227 #define UX_DEVICE_CLASS_AUDIO_MICROPHONE_ARRAY 0x0205 228 #define UX_DEVICE_CLASS_AUDIO_PROCESSING_MICROPHONE_ARRAY 0x0206 229 230 231 /* Define Audio Class output terminal types. */ 232 233 #define UX_DEVICE_CLASS_AUDIO_OUTPUT 0x0300 234 #define UX_DEVICE_CLASS_AUDIO_SPEAKER 0x0301 235 #define UX_DEVICE_CLASS_AUDIO_HEADPHONES 0x0302 236 #define UX_DEVICE_CLASS_AUDIO_HEAD_MOUNTED_DISPLAY 0x0303 237 #define UX_DEVICE_CLASS_AUDIO_DESKTOP_SPEAKER 0x0304 238 #define UX_DEVICE_CLASS_AUDIO_ROOM_SPEAKER 0x0305 239 #define UX_DEVICE_CLASS_AUDIO_COMMUNICATION_SPEAKER 0x0306 240 #define UX_DEVICE_CLASS_AUDIO_LOW_FREQUENCY_SPEAKER 0x0307 241 242 243 /* Define Audio Class bidirectional terminal types. */ 244 245 #define UX_DEVICE_CLASS_AUDIO_BIDIRECTIONAL_UNDEFINED 0x0400 246 #define UX_DEVICE_CLASS_AUDIO_HANDSET 0x0401 247 #define UX_DEVICE_CLASS_AUDIO_HEADSET 0x0402 248 #define UX_DEVICE_CLASS_AUDIO_SPEAKERPHONE 0x0403 249 #define UX_DEVICE_CLASS_AUDIO_ECHO_SUPRESS_SPEAKERPHONE 0x0404 250 #define UX_DEVICE_CLASS_AUDIO_ECHO_CANCEL_SPEAKERPHONE 0x0405 251 252 253 /* Define Audio Class telephony terminal types. */ 254 255 #define UX_DEVICE_CLASS_AUDIO_TELEPHONTY_UNDEFINED 0x0500 256 #define UX_DEVICE_CLASS_AUDIO_PHONE_LINE 0x0501 257 #define UX_DEVICE_CLASS_AUDIO_TELEPHONE 0x0502 258 #define UX_DEVICE_CLASS_AUDIO_DOWN_LINE_PHONE 0x0503 259 260 261 /* Define Audio Class external terminal types. */ 262 263 #define UX_DEVICE_CLASS_AUDIO_EXTERNAL_UNDEFINED 0x0600 264 #define UX_DEVICE_CLASS_AUDIO_ANALOG_CONNECTOR 0x0601 265 #define UX_DEVICE_CLASS_AUDIO_DIGITAL_AUDIO_INTERFACE 0x0602 266 #define UX_DEVICE_CLASS_AUDIO_LINE_CONNECTOR 0x0603 267 #define UX_DEVICE_CLASS_AUDIO_LEGACY_AUDIO_CONNECTOR 0x0604 268 #define UX_DEVICE_CLASS_AUDIO_S_PDIF_INTERFACE 0x0605 269 #define UX_DEVICE_CLASS_AUDIO_1394_DA_STREAM 0x0606 270 #define UX_DEVICE_CLASS_AUDIO_1394_DV_STREAM_SOUNDTRACK 0x0607 271 #define UX_DEVICE_CLASS_AUDIO_ADAT_LIGHTPIPE 0x0608 272 #define UX_DEVICE_CLASS_AUDIO_TDIF 0x0609 273 #define UX_DEVICE_CLASS_AUDIO_MADI 0x060A 274 275 276 /* Define Audio Class embedded function terminal types. */ 277 278 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_UNDEFINED 0x0700 279 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_LEVEL_CALIB_NOISE_SRC 0x0701 280 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_EQUALIZATION_NOISE 0x0702 281 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_CD_PLAYER 0x0703 282 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_DAT 0x0704 283 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_DCC 0x0705 284 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_MINIDISK 0x0706 285 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_ANALOG_TAPE 0x0707 286 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_PHONOGRAPH 0x0708 287 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_VCR_AUDIO 0x0709 288 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_VIDEO_DISC_AUDIO 0x070A 289 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_DVD_AUDIO 0x070B 290 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_TV_TUNER_AUDIO 0x070C 291 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_SATELLITE_RECEIVER_AUDIO 0x070D 292 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_CABLE_TUNER_AUDIO 0x070E 293 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_DSS_AUDIO 0x070F 294 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_RADIO_RECEIVER 0x0710 295 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_RADIO_TRANSMITTER 0x0711 296 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_MULTI_TRACK_RECORDER 0x0712 297 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_SYNTHESIZER 0x0713 298 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_PIANO 0x0714 299 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_GUITAR 0x0715 300 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_DRUMS_RHYTHM 0x0716 301 #define UX_DEVICE_CLASS_AUDIO_EMBEDDED_OTHER 0x0717 302 303 304 /* Define Audio Class encoding format types. */ 305 306 #define UX_DEVICE_CLASS_AUDIO_FORMAT_TYPE_UNDEFINED 0 307 #define UX_DEVICE_CLASS_AUDIO_FORMAT_TYPE_I 1 308 #define UX_DEVICE_CLASS_AUDIO_FORMAT_TYPE_II 2 309 #define UX_DEVICE_CLASS_AUDIO_FORMAT_TYPE_III 3 310 #define UX_DEVICE_CLASS_AUDIO_FORMAT_TYPE_IV 4 311 #define UX_DEVICE_CLASS_AUDIO_EXT_FORMAT_TYPE_I 0x81 312 #define UX_DEVICE_CLASS_AUDIO_EXT_FORMAT_TYPE_II 0x82 313 #define UX_DEVICE_CLASS_AUDIO_EXT_FORMAT_TYPE_III 0x83 314 315 316 /* Define channels. */ 317 318 #define UX_DEVICE_CLASS_AUDIO_MASTER_CHANNEL 0 319 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_1 1 320 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_2 2 321 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_3 3 322 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_4 4 323 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_5 5 324 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_6 6 325 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_7 7 326 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_8 8 327 #define UX_DEVICE_CLASS_AUDIO_CHANNEL_9 9 328 329 330 /* Define IOCTL code. 331 ux_device_class_audio_ioctl(audio, IOCTL_CODE, parameter). 332 */ 333 334 #define UX_DEVICE_CLASS_AUDIO_IOCTL_GET_ARG 1 335 336 /* Define Audio Class Task states. */ 337 #define UX_DEVICE_CLASS_AUDIO_INTERRUPT_STOP (UX_STATE_RESET) 338 #define UX_DEVICE_CLASS_AUDIO_INTERRUPT_START (UX_STATE_STEP + 1) 339 #define UX_DEVICE_CLASS_AUDIO_INTERRUPT_WAIT (UX_STATE_STEP + 2) 340 341 #define UX_DEVICE_CLASS_AUDIO_STREAM_RW_STOP (UX_STATE_RESET) 342 #define UX_DEVICE_CLASS_AUDIO_STREAM_RW_START (UX_STATE_STEP + 1) 343 #define UX_DEVICE_CLASS_AUDIO_STREAM_RW_WAIT (UX_STATE_STEP + 2) 344 345 #define UX_DEVICE_CLASS_AUDIO_STREAM_FEEDBACK_RW_STOP (UX_STATE_RESET) 346 #define UX_DEVICE_CLASS_AUDIO_STREAM_FEEDBACK_RW_WAIT (UX_STATE_STEP + 1) 347 348 /* Define Audio Class callback structure. */ 349 350 struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT; 351 struct UX_DEVICE_CLASS_AUDIO_STRUCT; 352 353 typedef struct UX_DEVICE_CLASS_AUDIO_CALLBACKS_STRUCT 354 { 355 356 VOID (*ux_slave_class_audio_instance_activate)(VOID *); 357 VOID (*ux_slave_class_audio_instance_deactivate)(VOID *); 358 UINT (*ux_device_class_audio_control_process)(struct UX_DEVICE_CLASS_AUDIO_STRUCT *, UX_SLAVE_TRANSFER *); 359 VOID *ux_device_class_audio_arg; 360 } UX_DEVICE_CLASS_AUDIO_CALLBACKS; 361 362 typedef struct UX_DEVICE_CLASS_AUDIO_STREAM_CALLBACKS_STRUCT 363 { 364 VOID (*ux_device_class_audio_stream_change)(struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT *, ULONG); 365 VOID (*ux_device_class_audio_stream_frame_done)(struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT *, ULONG); 366 } UX_DEVICE_CLASS_AUDIO_STREAM_CALLBACKS; 367 368 369 /* Define Audio Class Calling Parameter structure */ 370 371 typedef struct UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER_STRUCT 372 { 373 #if !defined(UX_DEVICE_STANDALONE) 374 ULONG ux_device_class_audio_stream_parameter_thread_stack_size; 375 VOID (*ux_device_class_audio_stream_parameter_thread_entry)(ULONG id); 376 #else 377 UINT (*ux_device_class_audio_stream_parameter_task_function)(struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT*); 378 #endif 379 380 #if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT) 381 #if !defined(UX_DEVICE_STANDALONE) 382 ULONG ux_device_class_audio_stream_parameter_feedback_thread_stack_size; 383 VOID (*ux_device_class_audio_stream_parameter_feedback_thread_entry)(ULONG id); 384 #else 385 UINT (*ux_device_class_audio_stream_parameter_feedback_task_function)(struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT*); 386 #endif 387 #endif 388 UX_DEVICE_CLASS_AUDIO_STREAM_CALLBACKS ux_device_class_audio_stream_parameter_callbacks; 389 390 ULONG ux_device_class_audio_stream_parameter_max_frame_buffer_size; 391 ULONG ux_device_class_audio_stream_parameter_max_frame_buffer_nb; 392 } UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER; 393 394 typedef struct UX_DEVICE_CLASS_AUDIO_PARAMETER_STRUCT 395 { 396 ULONG ux_device_class_audio_parameter_master_interface; 397 UX_DEVICE_CLASS_AUDIO_CALLBACKS ux_device_class_audio_parameter_callbacks; 398 399 ULONG ux_device_class_audio_parameter_streams_nb; 400 UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER *ux_device_class_audio_parameter_streams; 401 402 #if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT) 403 ULONG ux_device_class_audio_parameter_status_size; 404 ULONG ux_device_class_audio_parameter_status_queue_size; 405 #endif 406 } UX_DEVICE_CLASS_AUDIO_PARAMETER; 407 408 409 /* Define Audio Class instance structure. */ 410 411 typedef struct UX_DEVICE_CLASS_AUDIO_FRAME_STRUCT 412 { 413 414 ULONG ux_device_class_audio_frame_length; 415 ULONG ux_device_class_audio_frame_pos; 416 UCHAR ux_device_class_audio_frame_data[4]; 417 } UX_DEVICE_CLASS_AUDIO_FRAME; 418 419 typedef struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT 420 { 421 422 struct UX_DEVICE_CLASS_AUDIO_STRUCT *ux_device_class_audio_stream_audio; 423 UX_SLAVE_INTERFACE *ux_device_class_audio_stream_interface; 424 UX_SLAVE_ENDPOINT *ux_device_class_audio_stream_endpoint; 425 426 #if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT) 427 UX_SLAVE_ENDPOINT *ux_device_class_audio_stream_feedback; 428 429 #if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1 430 UCHAR *ux_device_class_audio_stream_feedback_buffer; 431 #endif 432 433 434 #if !defined(UX_DEVICE_STANDALONE) 435 UCHAR *ux_device_class_audio_stream_feedback_thread_stack; 436 UX_THREAD ux_device_class_audio_stream_feedback_thread; 437 #else 438 UINT (*ux_device_class_audio_stream_feedback_task_function)(struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT*); 439 UINT ux_device_class_audio_stream_feedback_task_state; 440 UINT ux_device_class_audio_stream_feedback_task_status; 441 #endif 442 #endif 443 444 UX_DEVICE_CLASS_AUDIO_STREAM_CALLBACKS ux_device_class_audio_stream_callbacks; 445 446 #if !defined(UX_DEVICE_STANDALONE) 447 UCHAR *ux_device_class_audio_stream_thread_stack; 448 UX_THREAD ux_device_class_audio_stream_thread; 449 #else 450 UINT (*ux_device_class_audio_stream_task_function)(struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT*); 451 UINT ux_device_class_audio_stream_task_state; 452 UINT ux_device_class_audio_stream_task_status; 453 #endif 454 455 UCHAR *ux_device_class_audio_stream_buffer; 456 ULONG ux_device_class_audio_stream_buffer_size; 457 ULONG ux_device_class_audio_stream_frame_buffer_size; 458 ULONG ux_device_class_audio_stream_buffer_error_count; 459 460 UX_DEVICE_CLASS_AUDIO_FRAME *ux_device_class_audio_stream_transfer_pos; 461 UX_DEVICE_CLASS_AUDIO_FRAME *ux_device_class_audio_stream_access_pos; 462 } UX_DEVICE_CLASS_AUDIO_STREAM; 463 464 typedef struct UX_DEVICE_CLASS_AUDIO_STRUCT 465 { 466 467 UX_SLAVE_CLASS *ux_device_class_audio_class; 468 UX_SLAVE_DEVICE *ux_device_class_audio_device; 469 UX_SLAVE_INTERFACE *ux_device_class_audio_interface; 470 471 UX_DEVICE_CLASS_AUDIO_CALLBACKS ux_device_class_audio_callbacks; 472 473 ULONG ux_device_class_audio_streams_nb; 474 UX_DEVICE_CLASS_AUDIO_STREAM *ux_device_class_audio_streams; 475 476 #if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT) 477 UX_SLAVE_ENDPOINT *ux_device_class_audio_interrupt; 478 479 #if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1 480 UCHAR *ux_device_class_audio_interrupt_buffer; 481 #endif 482 483 ULONG ux_device_class_audio_status_size; /* in Bytes. */ 484 ULONG ux_device_class_audio_status_queue_bytes;/* in Bytes. */ 485 ULONG ux_device_class_audio_status_queued; /* in Bytes. */ 486 UCHAR *ux_device_class_audio_status_queue; /* in Bytes. */ 487 UCHAR *ux_device_class_audio_status_head; 488 UCHAR *ux_device_class_audio_status_tail; 489 490 #if !defined(UX_DEVICE_STANDALONE) 491 UX_SEMAPHORE ux_device_class_audio_status_semaphore; 492 UX_MUTEX ux_device_class_audio_status_mutex; 493 #else 494 UINT ux_device_class_audio_interrupt_task_state; 495 UINT ux_device_class_audio_interrupt_task_status; 496 #endif 497 #endif 498 } UX_DEVICE_CLASS_AUDIO; 499 500 501 /* Define Audio Class function prototypes. */ 502 503 UINT _ux_device_class_audio_initialize(UX_SLAVE_CLASS_COMMAND *command); 504 UINT _ux_device_class_audio_uninitialize(UX_SLAVE_CLASS_COMMAND *command); 505 UINT _ux_device_class_audio_activate(UX_SLAVE_CLASS_COMMAND *command); 506 UINT _ux_device_class_audio_change(UX_SLAVE_CLASS_COMMAND *command); 507 UINT _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND *command); 508 UINT _ux_device_class_audio_control_request(UX_SLAVE_CLASS_COMMAND *command); 509 510 UINT _ux_device_class_audio_entry(UX_SLAVE_CLASS_COMMAND *command); 511 512 UINT _ux_device_class_audio_ioctl(UX_DEVICE_CLASS_AUDIO *audio, ULONG ioctl_function, 513 VOID *parameter); 514 515 UINT _ux_device_class_audio_stream_get(UX_DEVICE_CLASS_AUDIO *audio, ULONG stream_index, UX_DEVICE_CLASS_AUDIO_STREAM **stream); 516 517 VOID _ux_device_class_audio_write_thread_entry(ULONG audio_stream); 518 VOID _ux_device_class_audio_read_thread_entry(ULONG audio_stream); 519 UINT _ux_device_class_audio_write_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream); 520 UINT _ux_device_class_audio_read_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream); 521 UINT _ux_device_class_audio_reception_start(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 522 UINT _ux_device_class_audio_sample_read8(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *sample); 523 UINT _ux_device_class_audio_sample_read16(UX_DEVICE_CLASS_AUDIO_STREAM *audio, USHORT *sample); 524 UINT _ux_device_class_audio_sample_read24(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG *sample); 525 UINT _ux_device_class_audio_sample_read32(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG *sample); 526 527 UINT _ux_device_class_audio_read_frame_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR **frame_data, ULONG *frame_length); 528 UINT _ux_device_class_audio_read_frame_free(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 529 530 UINT _ux_device_class_audio_transmission_start(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 531 UINT _ux_device_class_audio_frame_write(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *frame, ULONG length); 532 533 UINT _ux_device_class_audio_write_frame_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR **buffer, ULONG *max_length); 534 UINT _ux_device_class_audio_write_frame_commit(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG length); 535 536 VOID _ux_device_class_audio_feedback_thread_entry(ULONG audio_stream); 537 UINT _ux_device_class_audio_feedback_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream); 538 UINT _ux_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *encoded_feedback); 539 UINT _ux_device_class_audio_feedback_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *encoded_feedback); 540 ULONG _ux_device_class_audio_speed_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 541 542 VOID _ux_device_class_audio_interrupt_thread_entry(ULONG audio_inst); 543 UINT _ux_device_class_audio_interrupt_task_function(UX_DEVICE_CLASS_AUDIO *audio); 544 UINT _ux_device_class_audio_interrupt_send(UX_DEVICE_CLASS_AUDIO *audio, UCHAR *int_data); 545 546 UINT _ux_device_class_audio_tasks_run(VOID *instance); 547 548 549 UINT _uxe_device_class_audio_initialize(UX_SLAVE_CLASS_COMMAND *command); 550 551 UINT _uxe_device_class_audio_ioctl(UX_DEVICE_CLASS_AUDIO *audio, ULONG ioctl_function, 552 VOID *parameter); 553 554 UINT _uxe_device_class_audio_stream_get(UX_DEVICE_CLASS_AUDIO *audio, ULONG stream_index, UX_DEVICE_CLASS_AUDIO_STREAM **stream); 555 556 VOID _uxe_device_class_audio_write_thread_entry(ULONG audio_stream); 557 VOID _uxe_device_class_audio_read_thread_entry(ULONG audio_stream); 558 UINT _uxe_device_class_audio_write_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream); 559 UINT _uxe_device_class_audio_read_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream); 560 UINT _uxe_device_class_audio_reception_start(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 561 UINT _uxe_device_class_audio_sample_read8(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *sample); 562 UINT _uxe_device_class_audio_sample_read16(UX_DEVICE_CLASS_AUDIO_STREAM *audio, USHORT *sample); 563 UINT _uxe_device_class_audio_sample_read24(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG *sample); 564 UINT _uxe_device_class_audio_sample_read32(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG *sample); 565 566 UINT _uxe_device_class_audio_read_frame_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR **frame_data, ULONG *frame_length); 567 UINT _uxe_device_class_audio_read_frame_free(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 568 569 UINT _uxe_device_class_audio_transmission_start(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 570 UINT _uxe_device_class_audio_frame_write(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *frame, ULONG length); 571 572 UINT _uxe_device_class_audio_write_frame_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR **buffer, ULONG *max_length); 573 UINT _uxe_device_class_audio_write_frame_commit(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG length); 574 575 UINT _uxe_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *encoded_feedback); 576 UINT _uxe_device_class_audio_feedback_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *encoded_feedback); 577 ULONG _uxe_device_class_audio_speed_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio); 578 579 VOID _uxe_device_class_audio_interrupt_thread_entry(ULONG audio_inst); 580 UINT _uxe_device_class_audio_interrupt_task_function(UX_DEVICE_CLASS_AUDIO *audio); 581 UINT _uxe_device_class_audio_interrupt_send(UX_DEVICE_CLASS_AUDIO *audio, UCHAR *int_data); 582 583 584 /* Define Device Class Audio API prototypes. */ 585 586 #if defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING) 587 588 #define ux_device_class_audio_entry _ux_device_class_audio_entry 589 590 #define ux_device_class_audio_read_thread_entry _ux_device_class_audio_read_thread_entry 591 #define ux_device_class_audio_write_thread_entry _ux_device_class_audio_write_thread_entry 592 593 #define ux_device_class_audio_read_task_function _ux_device_class_audio_read_task_function 594 #define ux_device_class_audio_write_task_function _ux_device_class_audio_write_task_function 595 596 #define ux_device_class_audio_stream_get _uxe_device_class_audio_stream_get 597 598 #define ux_device_class_audio_reception_start _uxe_device_class_audio_reception_start 599 #define ux_device_class_audio_sample_read8 _uxe_device_class_audio_sample_read8 600 #define ux_device_class_audio_sample_read16 _uxe_device_class_audio_sample_read16 601 #define ux_device_class_audio_sample_read24 _uxe_device_class_audio_sample_read24 602 #define ux_device_class_audio_sample_read32 _uxe_device_class_audio_sample_read32 603 604 #define ux_device_class_audio_read_frame_get _uxe_device_class_audio_read_frame_get 605 #define ux_device_class_audio_read_frame_free _uxe_device_class_audio_read_frame_free 606 607 #define ux_device_class_audio_transmission_start _uxe_device_class_audio_transmission_start 608 #define ux_device_class_audio_frame_write _uxe_device_class_audio_frame_write 609 610 #define ux_device_class_audio_write_frame_get _uxe_device_class_audio_write_frame_get 611 #define ux_device_class_audio_write_frame_commit _uxe_device_class_audio_write_frame_commit 612 613 #define ux_device_class_audio_ioctl _uxe_device_class_audio_ioctl 614 615 #define ux_device_class_audio_speed_get _ux_device_class_audio_speed_get 616 #define ux_device_class_audio_feedback_thread_entry _ux_device_class_audio_feedback_thread_entry 617 #define ux_device_class_audio_feedback_task_function _ux_device_class_audio_feedback_task_function 618 #define ux_device_class_audio_feedback_get _uxe_device_class_audio_feedback_get 619 #define ux_device_class_audio_feedback_set _uxe_device_class_audio_feedback_set 620 621 #define ux_device_class_audio_interrupt_send _uxe_device_class_audio_interrupt_send 622 623 #else 624 625 #define ux_device_class_audio_entry _ux_device_class_audio_entry 626 627 #define ux_device_class_audio_read_thread_entry _ux_device_class_audio_read_thread_entry 628 #define ux_device_class_audio_write_thread_entry _ux_device_class_audio_write_thread_entry 629 630 #define ux_device_class_audio_read_task_function _ux_device_class_audio_read_task_function 631 #define ux_device_class_audio_write_task_function _ux_device_class_audio_write_task_function 632 633 #define ux_device_class_audio_stream_get _ux_device_class_audio_stream_get 634 635 #define ux_device_class_audio_reception_start _ux_device_class_audio_reception_start 636 #define ux_device_class_audio_sample_read8 _ux_device_class_audio_sample_read8 637 #define ux_device_class_audio_sample_read16 _ux_device_class_audio_sample_read16 638 #define ux_device_class_audio_sample_read24 _ux_device_class_audio_sample_read24 639 #define ux_device_class_audio_sample_read32 _ux_device_class_audio_sample_read32 640 641 #define ux_device_class_audio_read_frame_get _ux_device_class_audio_read_frame_get 642 #define ux_device_class_audio_read_frame_free _ux_device_class_audio_read_frame_free 643 644 #define ux_device_class_audio_transmission_start _ux_device_class_audio_transmission_start 645 #define ux_device_class_audio_frame_write _ux_device_class_audio_frame_write 646 647 #define ux_device_class_audio_write_frame_get _ux_device_class_audio_write_frame_get 648 #define ux_device_class_audio_write_frame_commit _ux_device_class_audio_write_frame_commit 649 650 #define ux_device_class_audio_ioctl _ux_device_class_audio_ioctl 651 652 #define ux_device_class_audio_speed_get _ux_device_class_audio_speed_get 653 #define ux_device_class_audio_feedback_thread_entry _ux_device_class_audio_feedback_thread_entry 654 #define ux_device_class_audio_feedback_task_function _ux_device_class_audio_feedback_task_function 655 #define ux_device_class_audio_feedback_get _ux_device_class_audio_feedback_get 656 #define ux_device_class_audio_feedback_set _ux_device_class_audio_feedback_set 657 658 #define ux_device_class_audio_interrupt_send _ux_device_class_audio_interrupt_send 659 660 #endif 661 662 /* Determine if a C++ compiler is being used. If so, complete the standard 663 C conditional started above. */ 664 #ifdef __cplusplus 665 } 666 #endif 667 668 #endif /* ifndef UX_DEVICE_CLASS_AUDIO_H */ 669