X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/e572ee7ff271a3f454fcd8a5fb0d2079bbda4be2..21a012a018221fd1e55b8b054d09d7900ed9fd79:/LUFA/Drivers/USB/Class/Host/Audio.c?ds=sidebyside diff --git a/LUFA/Drivers/USB/Class/Host/Audio.c b/LUFA/Drivers/USB/Class/Host/Audio.c index 7397ef986..1d590e841 100644 --- a/LUFA/Drivers/USB/Class/Host/Audio.c +++ b/LUFA/Drivers/USB/Class/Host/Audio.c @@ -51,18 +51,19 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) return AUDIO_ENUMERROR_InvalidConfigDescriptor; - while (!(DataINEndpoint) || !(DataOUTEndpoint)) + while ((AudioInterfaceInfo->Config.DataINPipeNumber && !(DataINEndpoint)) || + (AudioInterfaceInfo->Config.DataOUTPipeNumber && !(DataOUTEndpoint))) { if (!(AudioControlInterface) || USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextAudioInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { if (!(AudioControlInterface) || USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DCOMP_Audio_Host_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found) { if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextAudioControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DCOMP_Audio_Host_NextAudioControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) { return AUDIO_ENUMERROR_NoCompatibleInterfaceFound; } @@ -70,13 +71,16 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa AudioControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DCOMP_Audio_Host_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found) { return AUDIO_ENUMERROR_NoCompatibleInterfaceFound; } } AudioStreamingInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; continue; } @@ -102,7 +106,7 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa Size = DataINEndpoint->EndpointSize; EndpointAddress = DataINEndpoint->EndpointAddress; Token = PIPE_TOKEN_IN; - Type = EP_TYPE_BULK; + Type = EP_TYPE_ISOCHRONOUS; DoubleBanked = true; AudioInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; @@ -137,7 +141,7 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa return AUDIO_ENUMERROR_NoError; } -static uint8_t DComp_NextAudioControlInterface(void* CurrentDescriptor) +static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(void* CurrentDescriptor) { USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); @@ -156,7 +160,7 @@ static uint8_t DComp_NextAudioControlInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -static uint8_t DComp_NextAudioStreamInterface(void* CurrentDescriptor) +static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(void* CurrentDescriptor) { USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); @@ -175,7 +179,7 @@ static uint8_t DComp_NextAudioStreamInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -static uint8_t DComp_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor) +static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor) { USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); @@ -194,8 +198,8 @@ static uint8_t DComp_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -uint8_t AUDIO_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, - bool EnableStreaming) +uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const bool EnableStreaming) { if (!(AudioInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnected; @@ -204,5 +208,40 @@ uint8_t AUDIO_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInt EnableStreaming ? AudioInterfaceInfo->State.EnabledStreamingAltIndex : 0); } +uint8_t Audio_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const uint8_t DataPipeIndex, + const uint8_t EndpointProperty, + const uint8_t EndpointControl, + const uint16_t DataLength, + void* const Data) +{ + if (!(AudioInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t RequestType; + uint8_t EndpointAddress; + + if (EndpointProperty & 0x80) + RequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT); + else + RequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT); + + Pipe_SelectPipe(DataPipeIndex); + EndpointAddress = Pipe_GetBoundEndpointAddress(); + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = RequestType, + .bRequest = EndpointProperty, + .wValue = ((uint16_t)EndpointControl << 8), + .wIndex = EndpointAddress, + .wLength = DataLength, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Data); +} + #endif