Mercurial > sdl-ios-xcode
changeset 1107:856f76a099c7
Can use both clocks of FDI interface on Falcon, plus digital output
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Sun, 07 Aug 2005 12:17:28 +0000 |
parents | 524fd51f5d2c |
children | 5fe7c6b8adc3 |
files | src/audio/mint/SDL_mintaudio.c src/audio/mint/SDL_mintaudio.h src/audio/mint/SDL_mintaudio_dma8.c src/audio/mint/SDL_mintaudio_gsxb.c src/audio/mint/SDL_mintaudio_mcsn.c src/audio/mint/SDL_mintaudio_stfa.c src/audio/mint/SDL_mintaudio_xbios.c |
diffstat | 7 files changed, 39 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio.c Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio.c Sun Aug 07 12:17:28 2005 +0000 @@ -76,7 +76,8 @@ } /* 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 @@ /* 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 @@ MINTAUDIO_frequencies[p].frequency = frequency; MINTAUDIO_frequencies[p].masterclock = clock; MINTAUDIO_frequencies[p].predivisor = prediv; + MINTAUDIO_frequencies[p].gpio_bits = gpio_bits; MINTAUDIO_freqcount++; }
--- a/src/audio/mint/SDL_mintaudio.h Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio.h Sun Aug 07 12:17:28 2005 +0000 @@ -42,6 +42,7 @@ Uint32 frequency; Uint32 masterclock; Uint32 predivisor; + int gpio_bits; /* in case of external clock */ } mint_frequency_t; struct SDL_PrivateAudioData { @@ -124,7 +125,8 @@ /* 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 */
--- a/src/audio/mint/SDL_mintaudio_dma8.c Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio_dma8.c Sun Aug 07 12:17:28 2005 +0000 @@ -250,7 +250,8 @@ 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
--- a/src/audio/mint/SDL_mintaudio_gsxb.c Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c Sun Aug 07 12:17:28 2005 +0000 @@ -276,7 +276,9 @@ /* 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
--- a/src/audio/mint/SDL_mintaudio_mcsn.c Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c Sun Aug 07 12:17:28 2005 +0000 @@ -233,7 +233,7 @@ 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 @@ 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 @@ 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 */
--- a/src/audio/mint/SDL_mintaudio_stfa.c Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio_stfa.c Sun Aug 07 12:17:28 2005 +0000 @@ -213,7 +213,7 @@ /* 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
--- a/src/audio/mint/SDL_mintaudio_xbios.c Fri Jul 29 10:59:49 2005 +0000 +++ b/src/audio/mint/SDL_mintaudio_xbios.c Sun Aug 07 12:17:28 2005 +0000 @@ -263,32 +263,29 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); }