Add macro guards to the templated C files to prevent compile errors if they are mista...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / Audio.h
index 0ceaf88..81dcedb 100644 (file)
 */\r
 \r
 /** \file\r
- *  \brief Host mode driver for the library USB Audio Class driver.\r
+ *  \brief Host mode driver for the library USB Audio 1.0 Class driver.\r
  *\r
- *  Host mode driver for the library USB Audio Class driver.\r
+ *  Host mode driver for the library USB Audio 1.0 Class driver.\r
  *\r
  *  \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
  *        dispatch header located in LUFA/Drivers/USB.h.\r
  */\r
 \r
 /** \ingroup Group_USBClassAudio\r
- *  \defgroup Group_USBClassAudioHost Audio Class Host Mode Driver\r
+ *  \defgroup Group_USBClassAudioHost Audio 1.0 Class Host Mode Driver\r
  *\r
  *  \section Sec_Dependencies Module Source Dependencies\r
  *  The following files must be built with any user project that uses this module:\r
  *    - LUFA/Drivers/USB/Class/Host/Audio.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
  *\r
  *  \section Sec_ModDescription Module Description\r
- *  Host Mode USB Class driver framework interface, for the Audio USB Class driver.\r
+ *  Host Mode USB Class driver framework interface, for the Audio 1.0 USB Class driver.\r
  *\r
  *  @{\r
  */\r
                        {\r
                                const struct\r
                                {\r
-                                       uint8_t  DataINPipeNumber; /**< Pipe number of the Audio interface's IN data pipe. */\r
-                                       uint8_t  DataOUTPipeNumber; /**< Pipe number of the Audio interface's OUT data pipe. */\r
+                                       uint8_t  DataINPipeNumber; /**< Pipe number of the Audio interface's IN data pipe. If this interface should not\r
+                                                                   *   bind to an IN endpoint, this may be set to 0 to disable audio input streaming for\r
+                                                                   *   this driver instance.\r
+                                                                   */\r
+                                       uint8_t  DataOUTPipeNumber; /**< Pipe number of the Audio interface's OUT data pipe. If this interface should not\r
+                                                                   *   bind to an OUT endpoint, this may be set to 0 to disable audio output streaming for\r
+                                                                   *   this driver instance.\r
+                                                                   */\r
                                } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
                                           *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
                                           */\r
                         *\r
                         *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
                         */\r
-                       uint8_t AUDIO_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
-                                                             bool EnableStreaming);\r
+                       uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+                                                             const bool EnableStreaming);\r
+\r
+                       /** Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given\r
+                        *  class instance.\r
+                        *\r
+                        *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class host configuration and state.\r
+                        *  \param[in]     DataPipeIndex       Index of the data pipe whose bound endpoint is to be altered.\r
+                        *  \param[in]     EndpointProperty    Property of the endpoint to get or set, a value from \ref Audio_ClassRequests_t.\r
+                        *  \param[in]     EndpointControl     Parameter of the endpoint to get or set, a value from \ref Audio_EndpointControls_t.\r
+                        *  \param[in,out] DataLength          For SET operations, the length of the parameter data to set. For GET operations, the maximum\r
+                        *                                     length of the retrieved data.\r
+                        *  \param[in,out] Data                Pointer to a location where the parameter data is stored for SET operations, or where\r
+                        *                                     the retrieved data is to be stored for GET operations.\r
+                        *\r
+                        *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+                        */                     \r
+                       uint8_t Audio_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+                                                            const uint8_t DataPipeIndex,\r
+                                                            const uint8_t EndpointProperty,\r
+                                                            const uint8_t EndpointControl,\r
+                                                            const uint16_t DataLength,\r
+                                                            void* const Data);\r
 \r
                /* Inline Functions: */\r
                        /** General management task for a given Audio host class interface, required for the correct operation of\r
                                if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive))\r
                                  return false;\r
 \r
-                               Pipe_SelectPipe(AudioInterfaceInfo->Config.DataOUTPipeNumber);\r
-                               return Pipe_IsINReceived();\r
+                               bool SampleReceived = false;\r
+\r
+                               Pipe_SelectPipe(AudioInterfaceInfo->Config.DataINPipeNumber);\r
+                               Pipe_Unfreeze();\r
+                               SampleReceived = Pipe_IsINReceived();\r
+                               Pipe_Freeze();\r
+\r
+                               return SampleReceived;\r
                        }\r
 \r
                        /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects\r
                                if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive))\r
                                  return false;\r
 \r
-                               Pipe_SelectPipe(AudioInterfaceInfo->Config.DataINPipeNumber);\r
+                               Pipe_SelectPipe(AudioInterfaceInfo->Config.DataOUTPipeNumber);\r
                                return Pipe_IsOUTReady();\r
                        }\r
 \r
                                Sample = Pipe_Read_8();\r
 \r
                                if (!(Pipe_BytesInPipe()))\r
-                                 Pipe_ClearIN();\r
+                               {\r
+                                       Pipe_Unfreeze();\r
+                                       Pipe_ClearIN();\r
+                                       Pipe_Freeze();\r
+                               }\r
 \r
                                return Sample;\r
                        }\r
                                Sample = (int16_t)Pipe_Read_16_LE();\r
 \r
                                if (!(Pipe_BytesInPipe()))\r
-                                 Pipe_ClearIN();\r
+                               {\r
+                                       Pipe_Unfreeze();\r
+                                       Pipe_ClearIN();\r
+                                       Pipe_Freeze();\r
+                               }\r
 \r
                                return Sample;\r
                        }\r
                                Sample = (((uint32_t)Pipe_Read_8() << 16) | Pipe_Read_16_LE());\r
 \r
                                if (!(Pipe_BytesInPipe()))\r
-                                 Pipe_ClearIN();\r
+                               {\r
+                                       Pipe_Unfreeze();\r
+                                       Pipe_ClearIN();\r
+                                       Pipe_Freeze();\r
+                               }\r
 \r
                                return Sample;\r
                        }\r
                        {\r
                                Pipe_Write_8(Sample);\r
 \r
-                               if (Pipe_BytesInPipe() == AudioInterfaceInfo->State.DataINPipeSize)\r
-                                 Pipe_ClearOUT();\r
+                               if (!(Pipe_IsReadWriteAllowed()))\r
+                               {\r
+                                       Pipe_Unfreeze();\r
+                                       Pipe_ClearOUT();\r
+                                       Pipe_WaitUntilReady();\r
+                                       Pipe_Freeze();\r
+                               }\r
                        }\r
 \r
                        /** Writes the next 16-bit audio sample to the current audio interface.\r
                        {\r
                                Pipe_Write_16_LE(Sample);\r
 \r
-                               if (Pipe_BytesInPipe() == AudioInterfaceInfo->State.DataINPipeSize)\r
-                                 Pipe_ClearOUT();\r
+                               if (!(Pipe_IsReadWriteAllowed()))\r
+                               {\r
+                                       Pipe_Unfreeze();\r
+                                       Pipe_ClearOUT();\r
+                                       Pipe_WaitUntilReady();\r
+                                       Pipe_Freeze();\r
+                               }\r
                        }\r
 \r
                        /** Writes the next 24-bit audio sample to the current audio interface.\r
                                Pipe_Write_16_LE(Sample);\r
                                Pipe_Write_8(Sample >> 16);\r
 \r
-                               if (Pipe_BytesInPipe() == AudioInterfaceInfo->State.DataINPipeSize)\r
-                                 Pipe_ClearOUT();\r
+                               if (!(Pipe_IsReadWriteAllowed()))\r
+                               {\r
+                                       Pipe_Unfreeze();\r
+                                       Pipe_ClearOUT();\r
+                                       Pipe_WaitUntilReady();\r
+                                       Pipe_Freeze();\r
+                               }\r
                        }\r
                        \r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Function Prototypes: */\r
                        #if defined(__INCLUDE_FROM_AUDIO_HOST_C)\r
-                               static uint8_t DComp_NextAudioControlInterface(void* CurrentDescriptor);\r
-                               static uint8_t DComp_NextAudioStreamInterface(void* CurrentDescriptor);\r
-                               static uint8_t DComp_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor);\r
+                               static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(void* CurrentDescriptor);\r
+                               static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(void* CurrentDescriptor);\r
+                               static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor);\r
                        #endif\r
        #endif\r
 \r