XilinxProcessorIPLib/drivers/dpdma/src/xdpdma.c
int XDpDma_PlayAudio(XDpDma *InstancePtr, XDpDma_AudioBuffer *Buffer,
		      u8 ChannelNum)
{
	XDpDma_AudioChannel *Channel;
	u64 DescAddr;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(Buffer != NULL);
	Xil_AssertNonvoid(Buffer->Size >= 512U);
	Xil_AssertNonvoid(Buffer->Size % 128U == 0U);
	Xil_AssertNonvoid(Buffer->Address % 128U == 0U);

	Channel = &InstancePtr->Audio[ChannelNum];
	Channel->Buffer = Buffer;

	if(Channel->Current == NULL) {
		Channel->TriggerStatus = XDPDMA_TRIGGER_EN;
		Channel->Current = &Channel->Descriptor0;
		Channel->Used = 0;
	}

	else if(Channel->Current == &Channel->Descriptor0) {
		/* Check if descriptor chain can be updated */
		if ((Channel->Descriptor1.MSB_Timestamp >>
		     XDPDMA_DESC_DONE_SHIFT) != 0U) {
			Channel->Current = NULL;
			return (int)XST_FAILURE;
		} else if (((Channel->Descriptor7.MSB_Timestamp >>
			     XDPDMA_DESC_DONE_SHIFT) == 1U) ||
			     (Channel->Used == 0U)) {
			DescAddr = (UINTPTR) &Channel->Descriptor4;
			Channel->Descriptor3.Control = XDPDMA_DESC_PREAMBLE |
				XDPDMA_DESC_UPDATE | XDPDMA_DESC_IGNR_DONE;
			Channel->Descriptor3.NEXT_DESR =
				LOWER_32_BITS(DescAddr);
			Channel->Descriptor3.ADDR_EXT &=
				~XDPDMA_DESCRIPTOR_ADDR_EXT_DSC_NXT_MASK;
			Channel->Descriptor3.ADDR_EXT |=
				UPPER_32_BITS(DescAddr);
			Channel->Current = &Channel->Descriptor4;
			Channel->Used = 1;
			XDpDma_InitAudioDescriptor(Channel, Buffer);
		}
		else {
			return (int)XST_FAILURE;
		}
	}

	else if(Channel->Current == &Channel->Descriptor4)  {
		/* Check if descriptor chain can be updated */
		if ((Channel->Descriptor5.MSB_Timestamp >>
		   XDPDMA_DESC_DONE_SHIFT) != 0U) {
			Channel->Current = NULL;
			return (int)XST_FAILURE;
		} else if ((Channel->Descriptor3.MSB_Timestamp >>
			XDPDMA_DESC_DONE_SHIFT) != 0U) {
			DescAddr = (UINTPTR) &Channel->Descriptor0;
			Channel->Descriptor7.Control = XDPDMA_DESC_PREAMBLE |
				XDPDMA_DESC_UPDATE | XDPDMA_DESC_IGNR_DONE;
			Channel->Descriptor7.NEXT_DESR =
				LOWER_32_BITS(DescAddr);
			Channel->Descriptor7.ADDR_EXT &=
				~XDPDMA_DESCRIPTOR_ADDR_EXT_DSC_NXT_MASK;
			Channel->Descriptor7.ADDR_EXT |=
				UPPER_32_BITS(DescAddr);
			Channel->Current = &Channel->Descriptor0;
			XDpDma_InitAudioDescriptor(Channel, Buffer);
		}
		else {
			return (int)XST_FAILURE;
		}
	} else {
		/* This should never occurs for audio channel */
		return (int)XST_FAILURE;
	}

	return (int)XST_SUCCESS;

}
/*************************************************************************/
/**
 *
 * This function sets the next Audio Buffer to be played on Audio Channel 0
 *
 * @param    InstancePtr is pointer to the instance of DPDMA.
 * @param    Buffer is a pointer to the attributes of the Audio information
 *	     to be played.
 * @param    ChannelNum selects between Audio Channel 0 and Audio Channel 1
 *
 * @return   XST_SUCCESS when the play audio request is successful.
 *	     XST_FAILURE when the play audio request fails, user has to
 *	     retry to play the audio.
 *
 * @note     The user has to schedule new audio buffer before half the audio
 *	     information is consumed by DPDMA to have a seamless playback.
 *
 **************************************************************************/
This function sets the next Audio Buffer to be played on Audio Channel 0
@param    InstancePtr is pointer to the instance of DPDMA.
@param    Buffer is a pointer to the attributes of the Audio information
to be played.
@param    ChannelNum selects between Audio Channel 0 and Audio Channel 1

@return   XST_SUCCESS when the play audio request is successful.
XST_FAILURE when the play audio request fails, user has to
retry to play the audio.

@note     The user has to schedule new audio buffer before half the audio
information is consumed by DPDMA to have a seamless playback.
This function sets the next Audio Buffer to be played on Audio Channel 0 @param InstancePtr is pointer to the instance of DPDMA . @param Buffer is a pointer to the attributes of the Audio information to be played . @param ChannelNum selects between Audio Channel 0 and Audio Channel 1 @return XST_SUCCESS when the play audio request is successful . XST_FAILURE when the play audio request fails user has to retry to play the audio . @note The user has to schedule new audio buffer before half the audio information is consumed by DPDMA to have a seamless playback .
int XDpDma_PlayAudio(XDpDma *InstancePtr, XDpDma_AudioBuffer *Buffer,
		      u8 ChannelNum)
{
	XDpDma_AudioChannel *Channel;
	u64 DescAddr;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(Buffer != NULL);
	Xil_AssertNonvoid(Buffer->Size >= 512U);
	Xil_AssertNonvoid(Buffer->Size % 128U == 0U);
	Xil_AssertNonvoid(Buffer->Address % 128U == 0U);
	Channel = &InstancePtr->Audio[ChannelNum];
	Channel->Buffer = Buffer;
	if(Channel->Current == NULL) {
		Channel->TriggerStatus = XDPDMA_TRIGGER_EN;
		Channel->Current = &Channel->Descriptor0;
		Channel->Used = 0;
	}
	else if(Channel->Current == &Channel->Descriptor0) {
		if ((Channel->Descriptor1.MSB_Timestamp >>
		     XDPDMA_DESC_DONE_SHIFT) != 0U) {
			Channel->Current = NULL;
			return (int)XST_FAILURE;
		} else if (((Channel->Descriptor7.MSB_Timestamp >>
			     XDPDMA_DESC_DONE_SHIFT) == 1U) ||
			     (Channel->Used == 0U)) {
			DescAddr = (UINTPTR) &Channel->Descriptor4;
			Channel->Descriptor3.Control = XDPDMA_DESC_PREAMBLE |
				XDPDMA_DESC_UPDATE | XDPDMA_DESC_IGNR_DONE;
			Channel->Descriptor3.NEXT_DESR =
				LOWER_32_BITS(DescAddr);
			Channel->Descriptor3.ADDR_EXT &=
				~XDPDMA_DESCRIPTOR_ADDR_EXT_DSC_NXT_MASK;
			Channel->Descriptor3.ADDR_EXT |=
				UPPER_32_BITS(DescAddr);
			Channel->Current = &Channel->Descriptor4;
			Channel->Used = 1;
			XDpDma_InitAudioDescriptor(Channel, Buffer);
		}
		else {
			return (int)XST_FAILURE;
		}
	}
	else if(Channel->Current == &Channel->Descriptor4)  {
		if ((Channel->Descriptor5.MSB_Timestamp >>
		   XDPDMA_DESC_DONE_SHIFT) != 0U) {
			Channel->Current = NULL;
			return (int)XST_FAILURE;
		} else if ((Channel->Descriptor3.MSB_Timestamp >>
			XDPDMA_DESC_DONE_SHIFT) != 0U) {
			DescAddr = (UINTPTR) &Channel->Descriptor0;
			Channel->Descriptor7.Control = XDPDMA_DESC_PREAMBLE |
				XDPDMA_DESC_UPDATE | XDPDMA_DESC_IGNR_DONE;
			Channel->Descriptor7.NEXT_DESR =
				LOWER_32_BITS(DescAddr);
			Channel->Descriptor7.ADDR_EXT &=
				~XDPDMA_DESCRIPTOR_ADDR_EXT_DSC_NXT_MASK;
			Channel->Descriptor7.ADDR_EXT |=
				UPPER_32_BITS(DescAddr);
			Channel->Current = &Channel->Descriptor0;
			XDpDma_InitAudioDescriptor(Channel, Buffer);
		}
		else {
			return (int)XST_FAILURE;
		}
	} else {
		return (int)XST_FAILURE;
	}
	return (int)XST_SUCCESS;
}
int XDpDma_PlayAudio ( XDpDma * InstancePtr , XDpDma_AudioBuffer * Buffer , u8 ChannelNum ) { XDpDma_AudioChannel * Channel ; u64 DescAddr ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( Buffer != NULL ) ; Xil_AssertNonvoid ( Buffer -> Size >= 512U ) ; Xil_AssertNonvoid ( Buffer -> Size % 128U == 0U ) ; Xil_AssertNonvoid ( Buffer -> Address % 128U == 0U ) ; Channel = & InstancePtr -> Audio [ ChannelNum ] ; Channel -> Buffer = Buffer ; if ( Channel -> Current == NULL ) { Channel -> TriggerStatus = XDPDMA_TRIGGER_EN ; Channel -> Current = & Channel -> Descriptor0 ; Channel -> Used = 0 ; } else if ( Channel -> Current == & Channel -> Descriptor0 ) { if ( ( Channel -> Descriptor1 . MSB_Timestamp >> XDPDMA_DESC_DONE_SHIFT ) != 0U ) { Channel -> Current = NULL ; return ( int ) XST_FAILURE ; } else if ( ( ( Channel -> Descriptor7 . MSB_Timestamp >> XDPDMA_DESC_DONE_SHIFT ) == 1U ) || ( Channel -> Used == 0U ) ) { DescAddr = ( UINTPTR ) & Channel -> Descriptor4 ; Channel -> Descriptor3 . Control = XDPDMA_DESC_PREAMBLE | XDPDMA_DESC_UPDATE | XDPDMA_DESC_IGNR_DONE ; Channel -> Descriptor3 . NEXT_DESR = LOWER_32_BITS ( DescAddr ) ; Channel -> Descriptor3 . ADDR_EXT &= ~ XDPDMA_DESCRIPTOR_ADDR_EXT_DSC_NXT_MASK ; Channel -> Descriptor3 . ADDR_EXT |= UPPER_32_BITS ( DescAddr ) ; Channel -> Current = & Channel -> Descriptor4 ; Channel -> Used = 1 ; XDpDma_InitAudioDescriptor ( Channel , Buffer ) ; } else { return ( int ) XST_FAILURE ; } } else if ( Channel -> Current == & Channel -> Descriptor4 ) { if ( ( Channel -> Descriptor5 . MSB_Timestamp >> XDPDMA_DESC_DONE_SHIFT ) != 0U ) { Channel -> Current = NULL ; return ( int ) XST_FAILURE ; } else if ( ( Channel -> Descriptor3 . MSB_Timestamp >> XDPDMA_DESC_DONE_SHIFT ) != 0U ) { DescAddr = ( UINTPTR ) & Channel -> Descriptor0 ; Channel -> Descriptor7 . Control = XDPDMA_DESC_PREAMBLE | XDPDMA_DESC_UPDATE | XDPDMA_DESC_IGNR_DONE ; Channel -> Descriptor7 . NEXT_DESR = LOWER_32_BITS ( DescAddr ) ; Channel -> Descriptor7 . ADDR_EXT &= ~ XDPDMA_DESCRIPTOR_ADDR_EXT_DSC_NXT_MASK ; Channel -> Descriptor7 . ADDR_EXT |= UPPER_32_BITS ( DescAddr ) ; Channel -> Current = & Channel -> Descriptor0 ; XDpDma_InitAudioDescriptor ( Channel , Buffer ) ; } else { return ( int ) XST_FAILURE ; } } else { return ( int ) XST_FAILURE ; } return ( int ) XST_SUCCESS ; }
This function sets the next Audio Buffer to be played on Audio Channel 0
 @param    InstancePtr is pointer to the instance of DPDMA.
This function sets the next Audio Buffer to be played on Audio Channel 0 @param InstancePtr is pointer to the instance of DPDMA .
/* Check if descriptor chain can be updated */ /* Check if descriptor chain can be updated */ /* This should never occurs for audio channel */