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

📄 xllp_acodec.c

📁 优龙pxa270平台试验程序
💻 C
📖 第 1 页 / 共 2 页
字号:
			(pDeviceContext->g_pfnDisableSspPath)=		XllpAkDisableSspPath;
			(pDeviceContext->g_pfnCodecSpecificInit)=	XllpAkCodecSpecificInit;
			(pDeviceContext->g_pfnCodecSpecificDeInit)= XllpAkCodecSpecificDeinit;
			(pDeviceContext->g_pfnACodecWrite)=         XllpAKCodecWrite;
			(pDeviceContext->g_pfnACodecRead)=          XllpAKCodecRead;
            (pDeviceContext->g_pfnEnterEquipmentState)=  XllpAKEnterEuipmentState;                                         
            (pDeviceContext->g_pfnQueryEquipmentState)= XllpAKQueryEquipmentState;   
		    XllpACodecI2SInit(pDeviceContext);
			break;
		case CC_A0_ID: //0x9e AKM 2440
			 // XllpACodecI2CInit(pDeviceContext);
			//g_pfnSetMasterVol=XllpAkSetMasterVol;

			(pDeviceContext->g_pfnSetMasterVol)=		XllpCcrA0SetMasterVol;
			(pDeviceContext->g_pfnGetInSampleRate)=		XllpCcrA0GetInSampleRate;
			(pDeviceContext->g_pfnGetOutSampleRate)=	XllpCcrA0GetOutSampleRate;
			(pDeviceContext->g_pfnSetInSampleRate)=		XllpCcrA0SetInSampleRate;
			(pDeviceContext->g_pfnSetOutSampleRate)=	XllpCcrA0SetOutSampleRate;
			(pDeviceContext->g_pfnEnableSspPath)=		XllpCcrA0EnableSspPath;
			(pDeviceContext->g_pfnDisableSspPath)=		XllpCcrA0DisableSspPath;
			(pDeviceContext->g_pfnCodecSpecificInit)=	XllpCcrA0CodecSpecificInit;
			(pDeviceContext->g_pfnCodecSpecificDeInit)= XllpCcrA0CodecSpecificDeinit;
			(pDeviceContext->g_pfnACodecWrite)=         XllpCcrA0CodecWrite;
			(pDeviceContext->g_pfnACodecRead)=          XllpCcrA0CodecRead;
            (pDeviceContext->g_pfnEnterEquipmentState)=  XllpCcrA0EnterEuipmentState;                                         
            (pDeviceContext->g_pfnQueryEquipmentState)=  XllpCcrA0QueryEquipmentState;   
		    XllpACodecI2SInit(pDeviceContext);
			break;

		case WM_8753_ID:
             XllpACodecI2CInit(pDeviceContext);
			(pDeviceContext->g_pfnSetMasterVol)=		XllpWm8753SetMasterVol;
			(pDeviceContext->g_pfnGetInSampleRate)=		XllpWm8753GetInSampleRate;
			(pDeviceContext->g_pfnGetOutSampleRate)=	XllpWm8753GetOutSampleRate;
			(pDeviceContext->g_pfnSetInSampleRate)=		XllpWm8753SetInSampleRate;
			(pDeviceContext->g_pfnSetOutSampleRate)=	XllpWm8753SetOutSampleRate;
			(pDeviceContext->g_pfnEnableSspPath)=		XllpWm8753EnableSspPath;
			(pDeviceContext->g_pfnDisableSspPath)=		XllpWm8753DisableSspPath;
			(pDeviceContext->g_pfnCodecSpecificInit)=	XllpWm8753CodecSpecificInit;
            (pDeviceContext->g_pfnCodecSpecificDeInit)= XllpWm8753CodecSpecificDeinit;
			(pDeviceContext->g_pfnACodecWrite)=          XllpWm8753CodecWrite;
			(pDeviceContext->g_pfnACodecRead)=           XllpWm8753CodecRead;
			(pDeviceContext->g_pfnEnterEquipmentState)=  XllpWm8753EnterEuipmentState;                                         
            (pDeviceContext->g_pfnQueryEquipmentState)= XllpWm8753QueryEquipmentState;   
	        // XllpACodecI2SInit(pDeviceContext);
			break;

		case UCB_1400_ID:
		    XllpAc97ACodecInit(pDeviceContext);  //codec init common to ac97
		    
			//UCB1400-specific functions
			(pDeviceContext->g_pfnSetMasterVol)=		XLLPUCBSetMasterVol;
			(pDeviceContext->g_pfnSetMasterInputGain)=	XLLPUCBSetMasterInputGain;
			(pDeviceContext->g_pfnGetInSampleRate)=		XllpUCBGetInSampleRate;
			(pDeviceContext->g_pfnGetOutSampleRate)=	XllpUCBGetOutSampleRate;
			(pDeviceContext->g_pfnSetInSampleRate)=		XllpUCBSetInSampleRate;
			(pDeviceContext->g_pfnSetOutSampleRate)=	XllpUCBSetOutSampleRate;
			(pDeviceContext->g_pfnEnableSspPath)=		NULL;
			(pDeviceContext->g_pfnDisableSspPath)=		NULL;
			(pDeviceContext->g_pfnCodecSpecificInit)=	XllpUCBSpecificInit;
			(pDeviceContext->g_pfnCodecSpecificDeInit)= XllpUCBSpecificDeInit;
			(pDeviceContext->g_pfnACodecRead)=           XllpAc97ACodecRead;
			(pDeviceContext->g_pfnACodecWrite)=          XllpAc97ACodecWrite;
			(pDeviceContext->g_pfnEnterEquipmentState)= XllpUCBEnterEquipmentState;
			(pDeviceContext->g_pfnQueryEquipmentState)=   XllpUCBGetEquipmentState;
			
	
	    break;

		case WM_9712_ID:
		    XllpAc97ACodecInit(pDeviceContext);  //codec init common to ac97
		    
			//UCB1400-specific functions
			(pDeviceContext->g_pfnSetMasterVol)=		XllpWm9712SetMasterVol;
			(pDeviceContext->g_pfnSetMasterInputGain)=	XllpWm9712SetMasterInputGain;
			(pDeviceContext->g_pfnGetInSampleRate)=		XllpUCBGetInSampleRate;
			(pDeviceContext->g_pfnGetOutSampleRate)=	XllpWm9712GetOutSampleRate;
			(pDeviceContext->g_pfnSetInSampleRate)=		XllpWm9712SetInSampleRate;
			(pDeviceContext->g_pfnSetOutSampleRate)=	XllpWm9712SetOutSampleRate;
			(pDeviceContext->g_pfnEnableSspPath)=		NULL;
			(pDeviceContext->g_pfnDisableSspPath)=		NULL;
			(pDeviceContext->g_pfnCodecSpecificInit)=	XllpWm9712SpecificInit;
			(pDeviceContext->g_pfnCodecSpecificDeInit)= XllpWm9712SpecificDeInit;
			(pDeviceContext->g_pfnACodecRead)=           XllpAc97ACodecRead;
			(pDeviceContext->g_pfnACodecWrite)=          XllpAc97ACodecWrite;
			(pDeviceContext->g_pfnEnterEquipmentState)= XllpWm9712EnterEquipmentState;
			(pDeviceContext->g_pfnQueryEquipmentState)=   XllpWm9712GetEquipmentState;
			
	
	    break;
	//		default:
	} //end switch
    
              pDeviceContext->g_pfnCodecSpecificInit(pDeviceContext);

  return XLLP_ACODEC_SUCCESS;

    

}


XLLP_ACODEC_ERROR_T XllpACodecDeInit(XLLP_ACODEC_CONTEXT_T *pDeviceContext)
{

    if (pDeviceContext->g_pfnCodecSpecificDeInit)
    {
	    pDeviceContext->g_pfnCodecSpecificDeInit(pDeviceContext);
	}
	switch (pDeviceContext->ACodecId)
	{
		case AK_2440_ID: //0x9e AKM 2440
		case WM_8753_ID:
			break;

		case UCB_1400_ID:
		case WM_9712_ID:
		    XllpAc97ACodecDeInit(pDeviceContext);
		break;
		default:
		    return XLLP_ACODEC_NO_CODEC_ID_MATCH;
	}
	
    return XLLP_ACODEC_SUCCESS;    
}


/***********************************************************************************
 * Prototype: XLLP_ACODEC_ERROR_T XllpACodecEnableCodecPcmPath(XLLP_ACODEC_OWNER_T Owner,XLLP_ACODEC_CONTEXT_T *pDeviceContext)
 * Descirption: Initialize SSP, enable the path between Bulverde and AKM2440, Bulverde as Master
 *                   
 *
 * Parameter: XLLP_ACODEC_CONTEXT_T a pointer to device context structure created
 *            by audio codec client software     
 * Return:    success or failure
 *************************************************************************************/
// As Jesse suggested, using GPIO 13,22,29,88
XLLP_ACODEC_ERROR_T XllpACodecEnableCodecPcmPath(XLLP_ACODEC_OWNER_T Owner, XLLP_ACODEC_CONTEXT_T *pDeviceContext)
{
	XLLP_ACODEC_ERROR_T retval=XLLP_ACODEC_SUCCESS;

	if (Owner==XLLP_NEARSIDE)
	{
		//GPIO configuration for enabling SSP path from Bulverde to AKM2440
		if(pDeviceContext->pGpioReg)
		{	
 			(pDeviceContext->pGpioReg)->GAFR0_U &= ~XLLP_GPIO_AF_BIT_SSP2_SSPRXD2_MASK;
			(pDeviceContext->pGpioReg)->GAFR2_U &=~XLLP_GPIO_AF_BIT_SSPFRM2_MASK; 
			(pDeviceContext->pGpioReg)->GPDR0 |=  XLLP_GPIO_BIT_SSPCLK2 | XLLP_GPIO_BIT_SSPTXD2;
			(pDeviceContext->pGpioReg)->GPDR0 |=  XXLP_GPIO_BIT_SSP2_SSPRXD2;   //GPIO29
			(pDeviceContext->pGpioReg)->GPDR2 |= XLLP_GPIO_BIT_SSPFRM2;    //GPIO 88
			(pDeviceContext->pGpioReg)->GAFR0_L |=  XLLP_GPIO_AF_BIT_SSPTXD2;  //GPIO 13
			(pDeviceContext->pGpioReg)->GAFR0_U |=  XLLP_GPIO_AF_BIT_SSP2_SSPRXD2;   //GPIO29
			(pDeviceContext->pGpioReg)->GAFR0_U |= XLLP_GPIO_AF_BIT_SSPCLK2;        //GPIO 22
			(pDeviceContext->pGpioReg)->GAFR2_U |= XLLP_GPIO_AF_BIT_SSPFRM2;   //GPIO 88
								  
			retval = XLLP_ACODEC_SUCCESS;
		}

	//	EdbgOutputDebugString ( "In SSP Enable code, GPDR0  is %x\r\n",(pDeviceContext->pGpioReg)->GPDR0 );
	//	EdbgOutputDebugString ( "In SSP Enable code, GPDR2  is %x\r\n",(pDeviceContext->pGpioReg)->GPDR2 );
	//	EdbgOutputDebugString ( "In SSP Enable code, GAFR0_U  is %x\r\n",(pDeviceContext->pGpioReg)->GAFR0_U );
	//	EdbgOutputDebugString ( "In SSP Enable code, GAFR0_L  is %x\r\n",(pDeviceContext->pGpioReg)->GAFR0_L );
	//    EdbgOutputDebugString ( "In SSP Enable code, GAFR2_U  is %x\r\n",(pDeviceContext->pGpioReg)->GAFR2_U );
		  //Configure SSP path
		 //| XXLP_SSCR1_RSRE
			if(pDeviceContext->pSSPReg)
		{
			(pDeviceContext->pSSPReg)->sscr0;
			(pDeviceContext->pSSPReg)->sscr0 = (XLLP_SSCR0_DSS_16BIT | XLLP_SSCR0_FRF_PSP  |XLLP_SSCR0_SCR_128K|XLLP_SSCR0_RIM |XLLP_SSCR0_TIM);   
			(pDeviceContext->pSSPReg)->sscr0 &= ~(XLLP_SSCR0_EDSS | XLLP_SSCR0_NCS | XLLP_SSCR0_ECS);   //due to 16 bit data trnasfer & on_chip clock
			(pDeviceContext->pSSPReg)->sscr1 = 0x00000000;
			(pDeviceContext->pSSPReg)->sscr1 = (XLLP_SSCR1_RWOT |XXLP_SSCR1_RSRE|XLLP_SSCR1_TTE | (0x7<<10)  );  //XXLP_SSCR1_RSRE |XXLP_SSCR1_RIE
			
			//(pDeviceContext->pSSPReg)->sscr1 = 0x02000C01;   //set RFT is 15  bit 10 - 13
			 (pDeviceContext->pSSPReg)->sspsp = 0x00010005;
			 (pDeviceContext->pSSPReg)->ssitr = 0;
			 (pDeviceContext->pSSPReg)->ssto = 0x1000;
			(pDeviceContext->pClockReg)->cken |=XLLP_CLKEN_SSP2;
			XllpOstDelayMicroSeconds( pDeviceContext->pOSTRegs,1);
			 (pDeviceContext->pSSPReg)->sscr0 |=XLLP_SSCR0_SSE;

			 
		}
		else
			retval = XLLP_ACODEC_CONTROLLER_NOT_INITIALIZED;
	}
	else
	{
	    
	   //Tri-state Bulverde, setting GPIO as input, clear alternative function, not sure that it is real tristate
	   // On Bulverde SSP section, SSCR1, bit 30(TTE) can be used to tristate TXD line. Never try!

		(pDeviceContext->pGpioReg)->GPDR0 &= ~(XLLP_GPIO_BIT_SSPCLK2 | XLLP_GPIO_BIT_SSPTXD2);
		(pDeviceContext->pGpioReg)->GPDR0 &=  ~XXLP_GPIO_BIT_SSP2_SSPRXD2;   //GPIO29
        (pDeviceContext->pGpioReg)->GPDR2 &= ~XLLP_GPIO_BIT_SSPFRM2;    //GPIO 88

		(pDeviceContext->pGpioReg)->GAFR0_U &= ~XLLP_GPIO_AF_BIT_SSP2_SSPRXD2_MASK;
		(pDeviceContext->pGpioReg)->GAFR0_L &= ~(XLLP_GPIO_AF_BIT_SSPTXD2_MASK);
        (pDeviceContext->pGpioReg)->GAFR0_U &= ~(XLLP_GPIO_AF_BIT_SSPCLK2);
        (pDeviceContext->pGpioReg)->GAFR2_U &=~XLLP_GPIO_AF_BIT_SSPFRM2_MASK;
        
        //Garson SSP controller port needs to be configured, Now, we don't have Garson, so, we didn't do this part
	}
	return(retval);


}

/***********************************************************************************
 * Prototype: XLLP_ACODEC_ERROR_T XllpACodecEnableCodecPcmPath(XLLP_ACODEC_OWNER_T Owner,XLLP_ACODEC_CONTEXT_T *pDeviceContext)
 * Descirption: Initialize SSP, enable the path between Bulverde and AKM2440, Bulverde as Master
 *                   
 *
 * Parameter: XLLP_ACODEC_CONTEXT_T a pointer to device context structure created
 *            by audio codec client software     
 * Return:    success or failure
 *************************************************************************************/
XLLP_ACODEC_ERROR_T XllpACodecDisableCodecPcmPath(XLLP_ACODEC_OWNER_T Owner,XLLP_ACODEC_CONTEXT_T *pDeviceContext)
{
	XLLP_ACODEC_ERROR_T retval=XLLP_ACODEC_SUCCESS;

	(pDeviceContext->pSSPReg)->sscr0 &=~XLLP_SSCR0_SSE;
	XllpOstDelayMicroSeconds( pDeviceContext->pOSTRegs,1);
	(pDeviceContext->pClockReg)->cken &=~XLLP_CLKEN_SSP2;

	return (retval);
}






⌨️ 快捷键说明

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