📄 ac97_test.c
字号:
/********************************************************************************
*
* Project Name : S3C6400 Validation
*
* Copyright 2006 by Samsung Electronics, Inc.
* All rights reserved.
*
* Project Description :
* This software is only for verifying functions of the S3C6400.
* Anybody can use this software without our permission.
*
*--------------------------------------------------------------------------------
*
* File Name : AC97.c
*
* File Description :
*
* Author : Yoh-Han Lee
* Dept. : AP Development Team
* Created Date : 2007/03/09
* Version : 0.2
*
* History
* - Version 0.1 (Y.H.Lee, 2007/03/09)
* -> Only available with STAC9767 AC97 Codec.
* - Version 0.2 (Y.H.Lee, 2007/04/04)
* -> Working with WM9713 AC97 Codec.
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "def.h"
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "system.h"
#include "gpio.h"
#include "intc.h"
#include "dma.h"
#include "ac97.h"
//Test Functions
void AC97_Test(void);
static void AC97_Powerdown(void);
static void AC97_PCMInOut(void);
static void AC97_MICIn(void);
void AC97_Test(void)
{
const testFuncMenu ac97_function[]=
{
0, "Exit\n",
AC97_Powerdown, "AC97 Power Down Test",
AC97_PCMInOut, "AC97 PCM In/Out (via Slot3, 4) Test",
AC97_MICIn, "AC97 MIC In (via Slot 6) Test",
0, 0
};
AC97_SetPort(PORT0);
Delay(1000);
while (1)
{
u32 i, nSel;
Disp("\n");
Disp("========================================================\n");
for (i=0; (int)(ac97_function[i].desc)!=0; i++)
{
Disp("%2d: %s\n", i,ac97_function[i].desc);
}
Disp("========================================================\n");
Disp("\nSelect the function to test : ");
nSel = GetIntNum();
Disp("\n");
if (nSel == 0)
break;
if (nSel>0 && nSel<(sizeof(ac97_function)/8-1))
(ac97_function[nSel].func)();
}
}
static void AC97_Powerdown()
{
u32 uGlobalCon;
if(AC97_Init())
{
//Normal
Disp("\n=>Normal\n");
AC97_ControllerState();
Disp("AC97 Codec Powerdown Ctrl/Stat Reg. Value (at 0x26): 0x%x\n", AC97_CodecCmd(READ,0x26,0x0000));
UART_Getc();
//ADCs off
Disp("\n=>ADCs off PR1\n");
AC97_CodecCmd(WRITE,0x26,(1<<8));
AC97_ControllerState();
Disp("AC97 Codec Powerdown Ctrl/Stat Reg. Value (at 0x26): 0x%x\n", AC97_CodecCmd(READ,0x26,0x0000));
UART_Getc();
//DACs off
Disp("\n=>DACs off PR1\n");
AC97_CodecCmd(WRITE,0x26,(1<<8)|(1<<9));
AC97_ControllerState();
Disp("AC97 Codec Powerdown Ctrl/Stat Reg. Value (at 0x26): 0x%x\n", AC97_CodecCmd(READ,0x26,0x0000));
UART_Getc();
//Analog off
Disp("\n=>Analog off PR2\n");
AC97_CodecCmd(WRITE,0x26,(1<<8)|(1<<9)|(1<<10));
AC97_ControllerState();
Disp("AC97 Codec Powerdown Ctrl/Stat Reg. Value (at 0x26): 0x%x\n", AC97_CodecCmd(READ,0x26,0x0000));
UART_Getc();
//Digital I/F off
Disp("\n=>Digital I/F off PR4\n");
AC97_CodecCmd(WRITE,0x26,(1<<8)|(1<<9)|(1<<10)|(1<<12));
AC97_ControllerState();
//Shut off AC-Link
Disp("\n=>Shut off AC-Link\n");
uGlobalCon= Inp32(AC97_BASE+rACGLBCTRL);
AC97Outp32(rACGLBCTRL, uGlobalCon & ~(1<<2));
AC97_ControllerState();
Disp("\nPress enter key for Warm Reset\n");
UART_Getc();
//Warm Reset
AC97_WarmReset();
}
}
static void AC97_PCMInOut(void)
{
u32 i;
u32 uFs;
uFs = AC97_SelectSamplingRate();
Disp("Sampling Rate: 0x%d\n", uFs);
if(AC97_Init())
{
Disp("\nSelect PCM In/Out Operation Mode\n");
Disp("0: Interrupt, 1: DMA\n");
i = GetIntNum();
AC97_InitCodecPCMIn(uFs);
if(i==0)
{
AC97_PCMInINT(REC_BUF, AC97_REC_LEN);
AC97_InitCodecPCMOut(uFs);
AC97_PCMOutINT(REC_BUF, AC97_REC_LEN);
}
else
{
AC97_PCMInDMA(REC_BUF, AC97_REC_LEN);
AC97_InitCodecPCMOut(uFs);
AC97_PCMOutDMA(REC_BUF, AC97_REC_LEN);
}
}
AC97_ExitCodecPCMIn(1);
}
static void AC97_MICIn(void)
{
u32 i;
u32 uFs;
uFs = AC97_SelectSamplingRate();
if(AC97_Init())
{
Disp("\nSelect MIC In Operation Mode\n");
Disp("0: Interrupt, 1: DMA\n");
i = GetIntNum();
AC97_InitCodecMICIn(uFs);
if(i==0)
AC97_MICInINT(REC_BUF, AC97_REC_LEN/4);
else
AC97_MICInDMA(REC_BUF, AC97_REC_LEN/4);
AC97_InitCodecPCMOut(uFs);
AC97_PCMOutDMA(REC_BUF, AC97_REC_LEN/4);
}
AC97_ExitCodecMICIn(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -