osAiTest.c
4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*====================================================================
* osAiTest.c
*
* Test for the hardware bug in osAiSetNextBuffer, where buffer ends
* that end in a set bit followed by 13 zeroes cause the next Ai
* DMA to fail.
*
*
* Copyright 1993, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
#include <libaudio.h>
#include "audio.h"
#include "audiotest.h"
static void startOsAiTest();
static void stopOsAiTest();
static void doOsAiRetrace();
static void osAiButtProc(u16 oldButton,u16 newButton);
test_cntrl OsAiTest = {
&startOsAiTest,
&stopOsAiTest,
&osAiButtProc, /* button proc */
&doOsAiRetrace,
NULL, /* void *retraceData */
1 /* u32 numSubTests */
};
extern u32 gTestDone;
extern ALHeap gHeapRec;
extern u8 gHeapBuf[AUDIO_HEAP_SIZE];
static OSThread audThread;
static u64 audThreadStack[STACKSIZE/8];
static void audProc(void *arg);
/***********************************************************************
* Test interface routines
***********************************************************************/
static void startOsAiTest()
{
PRINTF("Audio Hardware bug test. If sound is smooth square wave,\n");
PRINTF("all is OK. If sound is jittery, bug is occurring.\n");
PRINTF("Press any button to continue to next test.\n");
osCreateThread(&audThread, 9, audProc, 0, audThreadStack+STACKSIZE/8, AUDIO_PRIORITY);
osStartThread(&audThread);
}
static void audProc(void *arg)
{
OSMesg *msg = 0;
s32 res;
OSMesgQueue audioTestMsgQ;
OSMesg audioTestMsgBuf[MAX_MESGS];
u32 i, d;
s16 *data;
s32 lastFrame;
s32 thisFrame;
s16 *outData[3];
u32 waveCt = 0;
u32 audioFrameCt = 1;
u32 frmSize = 0x400;
u32 endAddr;
osAiSetFrequency(44100);
endAddr = (u32)&gHeapBuf[0x10000];
endAddr &= 0xFFFFC000; /* clear lower fourteen bits */
endAddr |= 0x00001000; /* set bit 12, */
/* when added with 400 * 4 bytes per sample */
/* will equal clear lower thirteen bits with */
/* next bit set */
outData[0] = (s16*) endAddr;
outData[2] = (s16*)(endAddr + 0x8000 );
outData[1] = (s16*)(endAddr + 0x10010);
osCreateMesgQueue(&audioTestMsgQ, audioTestMsgBuf, MAX_MESGS);
osSetEventMesg(OS_EVENT_AI,&audioTestMsgQ,&msg);
osSendMesg(&audioTestMsgQ,(OSMesg)&msg,OS_MESG_BLOCK);
while(!gTestDone)
{
(void) osRecvMesg(&audioTestMsgQ, (OSMesg *)&msg, OS_MESG_BLOCK);
lastFrame = (audioFrameCt-1)%3;
thisFrame = audioFrameCt%3;
res =osAiSetNextBuffer(outData[lastFrame], (u32)frmSize<<2);
if(res < 0)
PRINTF("osAiSetNextBuffer %d\n",res);
data = outData[thisFrame];
for(d = 0; d < (2*frmSize) ; d++)
{
if(waveCt < 0x7E)
{
data[d] = (s16)0x2000;
waveCt++;
}
else
{
data[d] = (s16)0xe000;
waveCt++;
if(waveCt >= 0xFc)
waveCt = 0;
}
}
osWritebackDCacheAll();
audioFrameCt++;
}
}
static void stopOsAiTest()
{
}
static void doOsAiRetrace()
{
}
static void osAiButtProc(u16 oldButton,u16 newButton)
{
if(newButton)
{
osDestroyThread(&audThread);
gTestDone = 1;
}
}