XilinxProcessorIPLib/drivers/v_hdmitx/src/xv_hdmitx.c
int XV_HdmiTx_SetAudioFormat(XV_HdmiTx *InstancePtr, XV_HdmiTx_AudioFormatType Value)
{
    u32 Status;
    u32 AudioCtrl;
    u32 Data;

    if (Value > XV_HDMITX_AUDFMT_3D) {
	    return XST_FAILURE;
    }

    Data = Value;

    // Stop peripheral
    XV_HdmiTx_WriteReg((InstancePtr)->Config.BaseAddress,
        (XV_HDMITX_AUD_CTRL_CLR_OFFSET), (XV_HDMITX_AUD_CTRL_RUN_MASK));

    AudioCtrl = XV_HdmiTx_ReadReg((InstancePtr)->Config.BaseAddress,
		    XV_HDMITX_AUD_CTRL_OFFSET);

    Data &= XV_HDMITX_AUD_CTRL_AUDFMT_MASK;
    Data <<= XV_HDMITX_AUD_CTRL_AUDFMT_SHIFT;

    AudioCtrl &= ~((u32)(XV_HDMITX_AUD_CTRL_AUDFMT_MASK <<
			XV_HDMITX_AUD_CTRL_AUDFMT_SHIFT));
    AudioCtrl |= Data;

    XV_HdmiTx_WriteReg((InstancePtr)->Config.BaseAddress,
                (XV_HDMITX_AUD_CTRL_OFFSET), (AudioCtrl));

    // Start peripheral
    XV_HdmiTx_WriteReg((InstancePtr)->Config.BaseAddress,
		    (XV_HDMITX_AUD_CTRL_SET_OFFSET),
		    (XV_HDMITX_AUD_CTRL_RUN_MASK));

    Status = (XST_SUCCESS);

    return Status;
}
/*****************************************************************************/
/**
*
* This function sets the active audio format
*
* @param    InstancePtr is a pointer to the XV_HdmiTx core instance.
*
* @return
*       - XST_SUCCESS if active channels were set.
*       - XST_FAILURE if no active channles were set.
*
* @note     None.
*
******************************************************************************/
This function sets the active audio format
This function sets the active audio format
int XV_HdmiTx_SetAudioFormat(XV_HdmiTx *InstancePtr, XV_HdmiTx_AudioFormatType Value)
{
    u32 Status;
    u32 AudioCtrl;
    u32 Data;
    if (Value > XV_HDMITX_AUDFMT_3D) {
	    return XST_FAILURE;
    }
    Data = Value;
    XV_HdmiTx_WriteReg((InstancePtr)->Config.BaseAddress,
        (XV_HDMITX_AUD_CTRL_CLR_OFFSET), (XV_HDMITX_AUD_CTRL_RUN_MASK));
    AudioCtrl = XV_HdmiTx_ReadReg((InstancePtr)->Config.BaseAddress,
		    XV_HDMITX_AUD_CTRL_OFFSET);
    Data &= XV_HDMITX_AUD_CTRL_AUDFMT_MASK;
    Data <<= XV_HDMITX_AUD_CTRL_AUDFMT_SHIFT;
    AudioCtrl &= ~((u32)(XV_HDMITX_AUD_CTRL_AUDFMT_MASK <<
			XV_HDMITX_AUD_CTRL_AUDFMT_SHIFT));
    AudioCtrl |= Data;
    XV_HdmiTx_WriteReg((InstancePtr)->Config.BaseAddress,
                (XV_HDMITX_AUD_CTRL_OFFSET), (AudioCtrl));
    XV_HdmiTx_WriteReg((InstancePtr)->Config.BaseAddress,
		    (XV_HDMITX_AUD_CTRL_SET_OFFSET),
		    (XV_HDMITX_AUD_CTRL_RUN_MASK));
    Status = (XST_SUCCESS);
    return Status;
}
int XV_HdmiTx_SetAudioFormat ( XV_HdmiTx * InstancePtr , XV_HdmiTx_AudioFormatType Value ) { u32 Status ; u32 AudioCtrl ; u32 Data ; if ( Value > XV_HDMITX_AUDFMT_3D ) { return XST_FAILURE ; } Data = Value ; XV_HdmiTx_WriteReg ( ( InstancePtr ) -> Config . BaseAddress , ( XV_HDMITX_AUD_CTRL_CLR_OFFSET ) , ( XV_HDMITX_AUD_CTRL_RUN_MASK ) ) ; AudioCtrl = XV_HdmiTx_ReadReg ( ( InstancePtr ) -> Config . BaseAddress , XV_HDMITX_AUD_CTRL_OFFSET ) ; Data &= XV_HDMITX_AUD_CTRL_AUDFMT_MASK ; Data <<= XV_HDMITX_AUD_CTRL_AUDFMT_SHIFT ; AudioCtrl &= ~ ( ( u32 ) ( XV_HDMITX_AUD_CTRL_AUDFMT_MASK << XV_HDMITX_AUD_CTRL_AUDFMT_SHIFT ) ) ; AudioCtrl |= Data ; XV_HdmiTx_WriteReg ( ( InstancePtr ) -> Config . BaseAddress , ( XV_HDMITX_AUD_CTRL_OFFSET ) , ( AudioCtrl ) ) ; XV_HdmiTx_WriteReg ( ( InstancePtr ) -> Config . BaseAddress , ( XV_HDMITX_AUD_CTRL_SET_OFFSET ) , ( XV_HDMITX_AUD_CTRL_RUN_MASK ) ) ; Status = ( XST_SUCCESS ) ; return Status ; }
This function sets the active audio format
This function sets the active audio format
// Stop peripheral // Start peripheral