⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tm1300debug_audio.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (c) 1995,1996,1997 by TriMedia Technologies. 
 *
 * +------------------------------------------------------------------+
 * | This software is furnished under a license and may only be used  |
 * | and copied in accordance with the terms and conditions of  such  |
 * | a license and with the inclusion of this copyright notice. This  |
 * | software or any other copies of this software may not be provided|
 * | or otherwise made available to any other person.  The ownership  |
 * | and title of this software is not transferred.                   |
 * |                                                                  |
 * | The information in this software is subject  to change without   |
 * | any  prior notice and should not be construed as a commitment by |
 * | TriMedia Technologies.                                           |
 * |                                                                  |
 * | this code and information is provided "as is" without any        |
 * | warranty of any kind, either expressed or implied, including but |
 * | not limited to the implied warranties of merchantability and/or  |
 * | fitness for any particular purpose.                              |
 * +------------------------------------------------------------------+
 *
 *  Module name              : tm1300Debug_audio.c    1.6
 *
 *  Last update              : 18:47:23 - 00/11/09
 *
 *  Description              :
 *
 *
 */


/* TriMedia standard shared includes */
#include <tm1/tmAssert.h>
#include <tmlib/dprintf.h>
#include <tmlib/tmtypes.h>
#include <tm1/tmAOmmio.h>
#include <tm1/tmAImmio.h>
#include <tm1/tmSPDOmmio.h>
#include <tm1/tmIIC.h>
#include <tm1/tmProcessor.h>
#include <tm1/tmLibdevErr.h>

#include "uda13xx.h"
#include "xioReg.h"

#include "philips_debug_tm1300.h"
#include "tm1300Debug_audio.h"

/***********************************************************/

/*******************************************************/
extern tmLibdevErr_t tm1300Debug_AO_Init(boardAOParam_t * param)
{
    Float               val;
    pprocCapabilities_t procCap;
    Int                 err = TMLIBDEV_OK;
    Float               tm1300DebugCPUClock;

    /* get the clock frequency of the TriMedia CPU */       
    err = procGetCapabilities(&procCap);
    if (err) return err;
    tm1300DebugCPUClock = (Float) procCap->cpuClockFrequency;
    
    /* reset the audio output peripheral */
    aoRESETM(AO_STATUS);

    /* Set initial frequency to get AO into a stable state */
    val = param->sRate * 256.0; /* 256 * sampleRate */
    val = 0.5 + (477218588.0 * (val / tm1300DebugCPUClock));    /* 2**32 / 9 */
    aoSetFREQM(AO_STATUS, ((UInt) val) | 0x80000000);
    
    aoEnableSER_MASTERM(AO_STATUS);
    microsleep(10); /* wait until AO unit stabalized */

    if (! (param->audioTypeFormat & TM1300DEBUG_SUPPORTED_AUDIO_OUT_TYPES) )
        return AIO_ERR_UNSUPPORTED_FORMAT;
    if (! (param->audioSubtypeFormat & TM1300DEBUG_SUPPORTED_AUDIO_OUT_SUBTYPES) )
        return AIO_ERR_UNSUPPORTED_FORMAT;

#ifdef __LITTLE_ENDIAN__
    aoEnableLITTLE_ENDIANM(AO_STATUS);
#else
    aoDisableLITTLE_ENDIANM(AO_STATUS);
#endif
    aoMsbFirstM(AO_STATUS);
    aoStartRisingEdgeWSM(AO_STATUS);  
    aoSampleRisingCLOCK_EDGEM(AO_STATUS); /* sample on rising edge */
    aoSetSSPOSM(AO_STATUS, 0);               /* Left and right channel start at bit 0 */
    aoDisableSIGN_CONVERTM(AO_STATUS);    /* Disable Sign Convert for MSB */
    aoDisableWS_PULSEM(AO_STATUS);        /* word strobe in pulse mode */
    aoDisableTRANS_ENABLEM(AO_STATUS);
    
    switch (param->audioSubtypeFormat) {
        case apfStereo16:               /* Two channel Audio */
        {   /* 64 * 4 * 1 = 256fs */
            DP(("stereo 16 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 3);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 0);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size);
            break;
        }
        case apfStereo32:               /* Two channel Audio, 32-bit */
        {   /* 64 * 4 * 1 = 256 fs */
            DP(("stereo 32 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 1);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 0);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size);
            break;
        }
        case apfFourCh_3_1_0_16:       /* Four channel Audio */
        case apfFourCh_2_2_0_16:       /* Four channel Audio */
        case apfFourCh_2_1_1_16:       /* Four channel Audio */
        case apfFourCh_3_0_1_16:       /* Four channel Audio */
        {
            DP(("four channels 16 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 3);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 1);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size * 2);
            break;
        }
        case apfFourCh_3_1_0_32:       /* Four channel Audio, 32-bit */
        case apfFourCh_2_2_0_32:       /* Four channel Audio, 32-bit */
        case apfFourCh_2_1_1_32:       /* Four channel Audio, 32-bit */
        case apfFourCh_3_0_1_32:       /* Four channel Audio, 32-bit */
        {
            DP(("four channels 32 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 1);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 1);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size * 2);
            break;
        }
        case apfFiveDotOne16:  /* Six Channel Audio */
        {
            DP(("six channels 16 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 3);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 2);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size * 3);
            break;
        }
        case apfFiveDotOne32:  /* Six Channel Audio, 32-bit */
        {
            DP(("six channels 32 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 1);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 2);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size * 3);
            break;
        }
        case apfSevenDotOne16:  /* Eight Channel Audio */
        {
            DP(("eight channels 16 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 3);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 3);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size * 4);
            break;
        }
        case apfSevenDotOne32:  /* Eight Channel Audio, 32-bit */
        {
            DP(("eight channels 32 bit\n"));
            aoSetTRANS_MODEM(AO_STATUS, 1);
            aoSetWSDIVM(AO_STATUS, 63);
            aoSetSCKDIVM(AO_STATUS, 3);
            aoSetNR_CHANM(AO_STATUS, 3);
            aoSetLEFTPOSM(AO_STATUS, 0);
            aoSetRIGHTPOSM(AO_STATUS, 32);
            aoSetSIZEM(AO_STATUS, param->size * 4);
            break;
        }
        default:
            /* unsupported subtype */
            return(AIO_ERR_UNSUPPORTED_FORMAT);
    }

    /* set sample rate */    
    err = tm1300Debug_AO_SetSRate(param->sRate);
    if (err)
        return err;

    return TMLIBDEV_OK;
}   /* end of tm1300Debug_AO_Init() */


/*******************************************************/
extern tmLibdevErr_t tm1300Debug_AO_Term(void)
{
    Int     err = TMLIBDEV_OK;

    /* reset statics */
    
    aoRESETM(AO_STATUS);
    return err;
}

/*******************************************************/
extern tmLibdevErr_t tm1300Debug_AO_Start(void)
{
    aoEnableTRANS_ENABLEM(AO_STATUS);
    
    return TMLIBDEV_OK;
}

/*******************************************************/
extern tmLibdevErr_t tm1300Debug_AO_Stop(void)
{
    aoDisableTRANS_ENABLEM(AO_STATUS);

    return TMLIBDEV_OK;
}

/***********************************************************************
 * Convert a floating point sample rate value
 * to a 32 bit frequency control value for the DDS.
 *
 * NOTE:  YOU MUST SET THE sckdiv, wsdiv and sfdiv FIELDS FOR THIS TO WORK!
 *
 * Accurate to .5 ppm.
 * The DDS can do better than this, but 64 bit math is
 *  required to use this interface.
 */
extern tmLibdevErr_t tm1300Debug_AO_SetSRate(Float sRate)
{
    UInt                ao_serial;
    Float               sckdiv, wsdiv, val;
    pprocCapabilities_t procCap;
    Float               tm1300DebugCPUClock;
    Int                 err = TMLIBDEV_OK;

    /* get the clock frequency of the TriMedia CPU */       
    err = procGetCapabilities(&procCap);
    if (err) return err;
    tm1300DebugCPUClock = (Float) procCap->cpuClockFrequency;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -