Can use both clocks of FDI interface on Falcon, plus digital output
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401108
This commit is contained in:
parent
3bcb730b00
commit
0a4aca5234
7 changed files with 39 additions and 45 deletions
|
@ -76,7 +76,8 @@ void SDL_MintAudio_Callback(void)
|
|||
}
|
||||
|
||||
/* Add a new frequency/clock/predivisor to the current list */
|
||||
void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv)
|
||||
void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
|
||||
Uint32 prediv, int gpio_bits)
|
||||
{
|
||||
int i, p;
|
||||
|
||||
|
@ -94,9 +95,7 @@ void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 pr
|
|||
/* Put all following ones farer */
|
||||
if (MINTAUDIO_freqcount>0) {
|
||||
for (i=MINTAUDIO_freqcount; i>p; i--) {
|
||||
MINTAUDIO_frequencies[i].frequency = MINTAUDIO_frequencies[i-1].frequency;
|
||||
MINTAUDIO_frequencies[i].masterclock = MINTAUDIO_frequencies[i-1].masterclock;
|
||||
MINTAUDIO_frequencies[i].predivisor = MINTAUDIO_frequencies[i-1].predivisor;
|
||||
memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,6 +103,7 @@ void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 pr
|
|||
MINTAUDIO_frequencies[p].frequency = frequency;
|
||||
MINTAUDIO_frequencies[p].masterclock = clock;
|
||||
MINTAUDIO_frequencies[p].predivisor = prediv;
|
||||
MINTAUDIO_frequencies[p].gpio_bits = gpio_bits;
|
||||
|
||||
MINTAUDIO_freqcount++;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef struct {
|
|||
Uint32 frequency;
|
||||
Uint32 masterclock;
|
||||
Uint32 predivisor;
|
||||
int gpio_bits; /* in case of external clock */
|
||||
} mint_frequency_t;
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
|
@ -124,7 +125,8 @@ extern unsigned long SDL_MintAudio_clocktics;
|
|||
|
||||
/* Functions */
|
||||
void SDL_MintAudio_Callback(void);
|
||||
void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv);
|
||||
void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
|
||||
Uint32 prediv, int gpio_bits);
|
||||
int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
|
||||
|
||||
/* ASM interrupt functions */
|
||||
|
|
|
@ -250,7 +250,8 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
MINTAUDIO_freqcount=0;
|
||||
for (i=sfreq;i<4;i++) {
|
||||
SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)), masterclock, i-sfreq);
|
||||
SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)),
|
||||
masterclock, i-sfreq, -1);
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
|
|
@ -276,7 +276,9 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* Calculate and select the closest frequency */
|
||||
MINTAUDIO_freqcount=0;
|
||||
for (i=1;i<4;i++) {
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_44K/(MASTERPREDIV_MILAN*(1<<i)), MASTERCLOCK_44K, (1<<i)-1);
|
||||
SDL_MintAudio_AddFrequency(this,
|
||||
MASTERCLOCK_44K/(MASTERPREDIV_MILAN*(1<<i)), MASTERCLOCK_44K,
|
||||
(1<<i)-1, -1);
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
|
|
@ -233,7 +233,7 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
case MCSN_ST:
|
||||
spec->channels=1;
|
||||
spec->format=8; /* FIXME: is it signed or unsigned ? */
|
||||
SDL_MintAudio_AddFrequency(this, 12500, 0, 0);
|
||||
SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
|
||||
break;
|
||||
case MCSN_TT: /* Also STE, Mega STE */
|
||||
spec->format=AUDIO_S8;
|
||||
|
@ -244,7 +244,8 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
masterprediv=MASTERPREDIV_TT;
|
||||
}
|
||||
for (i=0; i<4; i++) {
|
||||
SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)), masterclock, 3-i);
|
||||
SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)),
|
||||
masterclock, 3-i, -1);
|
||||
}
|
||||
break;
|
||||
case MCSN_FALCON: /* Also Mac */
|
||||
|
@ -253,11 +254,13 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
if ((i==6) || (i==8) || (i==10)) {
|
||||
continue;
|
||||
}
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), CLK25M, i+1);
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)),
|
||||
CLK25M, i+1, -1);
|
||||
}
|
||||
if (cookie_mcsn->res1 != 0) {
|
||||
for (i=1; i<4; i++) {
|
||||
SDL_MintAudio_AddFrequency(this, (cookie_mcsn->res1)/(MASTERPREDIV_FALCON*(1<<i)), CLKEXT, (1<<i)-1);
|
||||
SDL_MintAudio_AddFrequency(this, (cookie_mcsn->res1)/(MASTERPREDIV_FALCON*(1<<i)),
|
||||
CLKEXT, (1<<i)-1, -1);
|
||||
}
|
||||
}
|
||||
spec->format |= 0x8000; /* Audio is always signed */
|
||||
|
|
|
@ -213,7 +213,7 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* Check formats available */
|
||||
MINTAUDIO_freqcount=0;
|
||||
for (i=0;i<16;i++) {
|
||||
SDL_MintAudio_AddFrequency(this, freqs[i], 0, i);
|
||||
SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1);
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
|
|
@ -263,32 +263,29 @@ static void Devconnect2(int src, int dst, int sclk, int pre)
|
|||
Super(oldstack);
|
||||
}
|
||||
|
||||
static Uint32 Mint_CheckExternalClock(void)
|
||||
static void Mint_CheckExternalClock(_THIS)
|
||||
{
|
||||
#define SIZE_BUF_CLOCK_MEASURE (44100/10)
|
||||
|
||||
unsigned long cookie_snd;
|
||||
Uint32 masterclock;
|
||||
char *buffer;
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
/* DSP present with its GPIO port ? */
|
||||
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
if ((cookie_snd & SND_DSP)==0) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = Atari_SysMalloc(SIZE_BUF_CLOCK_MEASURE, MX_STRAM);
|
||||
if (buffer==NULL) {
|
||||
DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n"));
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE);
|
||||
|
||||
masterclock=0;
|
||||
|
||||
Buffoper(0);
|
||||
Settracks(0,0);
|
||||
Setmontracks(0);
|
||||
|
@ -313,13 +310,13 @@ static Uint32 Mint_CheckExternalClock(void)
|
|||
khz = ((SIZE_BUF_CLOCK_MEASURE/SDL_MintAudio_clocktics) +1) & 0xFFFFFFFE;
|
||||
DEBUG_PRINT((DEBUG_NAME "measure %d: freq=%lu KHz\n", i+1, khz));
|
||||
|
||||
if (i==0) {
|
||||
if(khz==44) {
|
||||
masterclock = MASTERCLOCK_44K;
|
||||
if(khz==44) {
|
||||
for (j=1; j<4; j++) {
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_44K/(MASTERPREDIV_FALCON*(1<<j)), MASTERCLOCK_44K, (1<<j)-1, 2+i);
|
||||
}
|
||||
} else {
|
||||
if(khz==48) {
|
||||
masterclock = MASTERCLOCK_48K;
|
||||
} else if (khz==48) {
|
||||
for (j=1; j<4; j++) {
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_48K/(MASTERPREDIV_FALCON*(1<<j)), MASTERCLOCK_48K, (1<<j)-1, 2+i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -331,12 +328,9 @@ static Uint32 Mint_CheckExternalClock(void)
|
|||
|
||||
Buffoper(0); /* stop */
|
||||
Jdisint(MFP_TIMERA); /* Uninstall interrupt */
|
||||
if (masterclock == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
Mfree(buffer);
|
||||
return masterclock;
|
||||
}
|
||||
|
||||
static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
||||
|
@ -356,22 +350,18 @@ static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
|
|||
spec->channels=2; /* 16 bits always stereo */
|
||||
}
|
||||
|
||||
extclock=Mint_CheckExternalClock();
|
||||
MINTAUDIO_freqcount=0;
|
||||
|
||||
/* Add external clocks if present */
|
||||
Mint_CheckExternalClock(this);
|
||||
|
||||
/* Standard clocks */
|
||||
MINTAUDIO_freqcount=0;
|
||||
for (i=1;i<12;i++) {
|
||||
/* Remove unusable Falcon codec predivisors */
|
||||
if ((i==6) || (i==8) || (i==10)) {
|
||||
continue;
|
||||
}
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), MASTERCLOCK_FALCON1, i);
|
||||
}
|
||||
|
||||
if (extclock>0) {
|
||||
for (i=1; i<4; i++) {
|
||||
SDL_MintAudio_AddFrequency(this, extclock/(MASTERPREDIV_FALCON*(1<<i)), extclock, (1<<i)-1);
|
||||
}
|
||||
SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), MASTERCLOCK_FALCON1, i, -1);
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
@ -424,14 +414,10 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock;
|
||||
prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
|
||||
if (dmaclock != MASTERCLOCK_FALCON1) {
|
||||
if (MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits != -1) {
|
||||
Gpio(GPIO_SET,7); /* DSP port gpio outputs */
|
||||
if (dmaclock == MASTERCLOCK_44K) {
|
||||
Gpio(GPIO_WRITE,2); /* 22.5792 MHz for 44.1KHz */
|
||||
} else {
|
||||
Gpio(GPIO_WRITE,3); /* 24.576 MHz for 48KHz */
|
||||
}
|
||||
Devconnect2(DMAPLAY, DAC, CLKEXT, prediv);
|
||||
Gpio(GPIO_WRITE, MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits);
|
||||
Devconnect2(DMAPLAY, DAC|EXTOUT, CLKEXT, prediv);
|
||||
} else {
|
||||
Devconnect2(DMAPLAY, DAC, CLK25M, prediv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue