From 6039eb05ba6d82ef56f2868c96654c552d117bf9 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 7 Feb 2018 20:04:46 -0500 Subject: sdl: remove non-rockbox drivers We never use any of these other drivers, so having them around just takes up space. Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41 --- apps/plugins/sdl/src/audio/mint/SDL_mintaudio.c | 215 --------- apps/plugins/sdl/src/audio/mint/SDL_mintaudio.h | 121 ----- .../sdl/src/audio/mint/SDL_mintaudio_dma8.c | 357 --------------- .../sdl/src/audio/mint/SDL_mintaudio_dma8.h | 85 ---- .../sdl/src/audio/mint/SDL_mintaudio_gsxb.c | 436 ------------------ .../sdl/src/audio/mint/SDL_mintaudio_gsxb.h | 104 ----- apps/plugins/sdl/src/audio/mint/SDL_mintaudio_it.S | 386 ---------------- .../sdl/src/audio/mint/SDL_mintaudio_mcsn.c | 405 ----------------- .../sdl/src/audio/mint/SDL_mintaudio_mcsn.h | 59 --- .../sdl/src/audio/mint/SDL_mintaudio_stfa.c | 326 -------------- .../sdl/src/audio/mint/SDL_mintaudio_stfa.h | 97 ---- .../sdl/src/audio/mint/SDL_mintaudio_xbios.c | 490 --------------------- 12 files changed, 3081 deletions(-) delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio.c delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio.h delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.c delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.h delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.c delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.h delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_it.S delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.c delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.h delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.c delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.h delete mode 100644 apps/plugins/sdl/src/audio/mint/SDL_mintaudio_xbios.c (limited to 'apps/plugins/sdl/src/audio/mint') diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio.c b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio.c deleted file mode 100644 index 46ba690c3e..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - Audio interrupt variables and callback function - - Patrice Mandin -*/ - -#include - -#include -#include -#include -#include - -#include "SDL_audio.h" -#include "SDL_mintaudio.h" -#include "SDL_mintaudio_stfa.h" - -/* The audio device */ - -SDL_AudioDevice *SDL_MintAudio_device; -Uint8 *SDL_MintAudio_audiobuf[2]; /* Pointers to buffers */ -unsigned long SDL_MintAudio_audiosize; /* Length of audio buffer=spec->size */ -volatile unsigned short SDL_MintAudio_numbuf; /* Buffer to play */ -volatile unsigned short SDL_MintAudio_mutex; -volatile unsigned long SDL_MintAudio_clocktics; -cookie_stfa_t *SDL_MintAudio_stfa; -unsigned short SDL_MintAudio_hasfpu; - -/* MiNT thread variables */ -SDL_bool SDL_MintAudio_mint_present; -SDL_bool SDL_MintAudio_quit_thread; -SDL_bool SDL_MintAudio_thread_finished; -long SDL_MintAudio_thread_pid; - -/* The callback function, called by each driver whenever needed */ - -void SDL_MintAudio_Callback(void) -{ - Uint8 *buffer; - SDL_AudioDevice *audio = SDL_MintAudio_device; - - buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - SDL_memset(buffer, audio->spec.silence, audio->spec.size); - - if (audio->paused) - return; - - if (audio->convert.needed) { - int silence; - - if ( audio->convert.src_format == AUDIO_U8 ) { - silence = 0x80; - } else { - silence = 0; - } - SDL_memset(audio->convert.buf, silence, audio->convert.len); - audio->spec.callback(audio->spec.userdata, - (Uint8 *)audio->convert.buf,audio->convert.len); - SDL_ConvertAudio(&audio->convert); - SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); - } else { - audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); - } -} - -/* Add a new frequency/clock/predivisor to the current list */ -void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, - Uint32 prediv, int gpio_bits) -{ - int i, p; - - if (MINTAUDIO_freqcount==MINTAUDIO_maxfreqs) { - return; - } - - /* Search where to insert the frequency (highest first) */ - for (p=0; p MINTAUDIO_frequencies[p].frequency) { - break; - } - } - - /* Put all following ones farer */ - if (MINTAUDIO_freqcount>0) { - for (i=MINTAUDIO_freqcount; i>p; i--) { - SDL_memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t)); - } - } - - /* And insert new one */ - MINTAUDIO_frequencies[p].frequency = frequency; - MINTAUDIO_frequencies[p].masterclock = clock; - MINTAUDIO_frequencies[p].predivisor = prediv; - MINTAUDIO_frequencies[p].gpio_bits = gpio_bits; - - MINTAUDIO_freqcount++; -} - -/* Search for the nearest frequency */ -int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq) -{ - int i; - - /* Only 1 freq ? */ - if (MINTAUDIO_freqcount==1) { - return 0; - } - - /* Check the array */ - for (i=0; i= ((MINTAUDIO_frequencies[i].frequency+ - MINTAUDIO_frequencies[i+1].frequency)>>1)) { - return i; - } - } - - /* Not in the array, give the latest */ - return MINTAUDIO_freqcount-1; -} - -/* Check if FPU is present */ -void SDL_MintAudio_CheckFpu(void) -{ - long cookie_fpu; - - SDL_MintAudio_hasfpu = 0; - if (Getcookie(C__FPU, &cookie_fpu) != C_FOUND) { - return; - } - switch ((cookie_fpu>>16)&0xfffe) { - case 2: - case 4: - case 6: - case 8: - case 16: - SDL_MintAudio_hasfpu = 1; - break; - } -} - -/* The thread function, used under MiNT with xbios */ -int SDL_MintAudio_Thread(long param) -{ - SndBufPtr pointers; - SDL_bool buffers_filled[2] = {SDL_FALSE, SDL_FALSE}; - - SDL_MintAudio_thread_finished = SDL_FALSE; - while (!SDL_MintAudio_quit_thread) { - if (Buffptr(&pointers)!=0) - continue; - - if (( (unsigned long)pointers.play>=(unsigned long)SDL_MintAudio_audiobuf[0]) - && ( (unsigned long)pointers.play<=(unsigned long)SDL_MintAudio_audiobuf[1])) - { - /* DMA is reading buffer #0, setup buffer #1 if not already done */ - if (!buffers_filled[1]) { - SDL_MintAudio_numbuf = 1; - SDL_MintAudio_Callback(); - Setbuffer(0, SDL_MintAudio_audiobuf[1], SDL_MintAudio_audiobuf[1] + SDL_MintAudio_audiosize); - buffers_filled[1]=SDL_TRUE; - buffers_filled[0]=SDL_FALSE; - } - } else { - /* DMA is reading buffer #1, setup buffer #0 if not already done */ - if (!buffers_filled[0]) { - SDL_MintAudio_numbuf = 0; - SDL_MintAudio_Callback(); - Setbuffer(0, SDL_MintAudio_audiobuf[0], SDL_MintAudio_audiobuf[0] + SDL_MintAudio_audiosize); - buffers_filled[0]=SDL_TRUE; - buffers_filled[1]=SDL_FALSE; - } - } - - usleep(100); - } - SDL_MintAudio_thread_finished = SDL_TRUE; - return 0; -} - -void SDL_MintAudio_WaitThread(void) -{ - if (!SDL_MintAudio_mint_present) - return; - - if (SDL_MintAudio_thread_finished) - return; - - SDL_MintAudio_quit_thread = SDL_TRUE; - while (!SDL_MintAudio_thread_finished) { - Syield(); - } -} diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio.h b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio.h deleted file mode 100644 index ba6056ee3a..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MiNT audio driver - - Patrice Mandin -*/ - -#ifndef _SDL_mintaudio_h -#define _SDL_mintaudio_h - -#include "../SDL_sysaudio.h" -#include "SDL_mintaudio_stfa.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -/* 16 predivisors with 3 clocks max. */ -#define MINTAUDIO_maxfreqs (16*3) - -typedef struct { - Uint32 frequency; - Uint32 masterclock; - Uint32 predivisor; - int gpio_bits; /* in case of external clock */ -} mint_frequency_t; - -struct SDL_PrivateAudioData { - mint_frequency_t frequencies[MINTAUDIO_maxfreqs]; - int freq_count; /* Number of frequencies in the array */ - int numfreq; /* Number of selected frequency */ -}; - -/* Old variable names */ - -#define MINTAUDIO_frequencies (this->hidden->frequencies) -#define MINTAUDIO_freqcount (this->hidden->freq_count) -#define MINTAUDIO_numfreq (this->hidden->numfreq) - -/* _MCH cookie (values>>16) */ -enum { - MCH_ST=0, - MCH_STE, - MCH_TT, - MCH_F30, - MCH_CLONE, - MCH_ARANYM -}; - -/* Master clocks for replay frequencies */ -#define MASTERCLOCK_STE 8010666 /* Not sure of this one */ -#define MASTERCLOCK_TT 16107953 /* Not sure of this one */ -#define MASTERCLOCK_FALCON1 25175000 -#define MASTERCLOCK_FALCON2 32000000 /* Only usable for DSP56K */ -#define MASTERCLOCK_FALCONEXT -1 /* Clock on DSP56K port, unknown */ -#define MASTERCLOCK_44K 22579200 /* Standard clock for 44.1 Khz */ -#define MASTERCLOCK_48K 24576000 /* Standard clock for 48 Khz */ - -/* Master clock predivisors */ -#define MASTERPREDIV_STE 160 -#define MASTERPREDIV_TT 320 -#define MASTERPREDIV_FALCON 256 -#define MASTERPREDIV_MILAN 256 - -/* Variables */ -extern SDL_AudioDevice *SDL_MintAudio_device; -extern Uint8 *SDL_MintAudio_audiobuf[2]; /* Pointers to buffers */ -extern unsigned long SDL_MintAudio_audiosize; /* Length of audio buffer=spec->size */ -extern volatile unsigned short SDL_MintAudio_numbuf; /* Buffer to play */ -extern volatile unsigned short SDL_MintAudio_mutex; -extern cookie_stfa_t *SDL_MintAudio_stfa; -extern volatile unsigned long SDL_MintAudio_clocktics; -extern unsigned short SDL_MintAudio_hasfpu; /* To preserve fpu registers if needed */ - -/* MiNT thread variables */ -extern SDL_bool SDL_MintAudio_mint_present; -extern SDL_bool SDL_MintAudio_quit_thread; -extern SDL_bool SDL_MintAudio_thread_finished; -extern long SDL_MintAudio_thread_pid; - -/* Functions */ -void SDL_MintAudio_Callback(void); -void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, - Uint32 prediv, int gpio_bits); -int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq); -void SDL_MintAudio_CheckFpu(void); - -/* MiNT thread functions */ -int SDL_MintAudio_Thread(long param); -void SDL_MintAudio_WaitThread(void); - -/* ASM interrupt functions */ -void SDL_MintAudio_GsxbInterrupt(void); -void SDL_MintAudio_EmptyGsxbInterrupt(void); -void SDL_MintAudio_XbiosInterruptMeasureClock(void); -void SDL_MintAudio_XbiosInterrupt(void); -void SDL_MintAudio_Dma8Interrupt(void); -void SDL_MintAudio_StfaInterrupt(void); - -#endif /* _SDL_mintaudio_h */ diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.c b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.c deleted file mode 100644 index 61feba3d64..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MiNT audio driver - using DMA 8bits (hardware access) - - Patrice Mandin -*/ - -/* Mint includes */ -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_sysaudio.h" - -#include "../../video/ataricommon/SDL_atarimxalloc_c.h" - -#include "SDL_mintaudio.h" -#include "SDL_mintaudio_dma8.h" - -/*--- Defines ---*/ - -#define MINT_AUDIO_DRIVER_NAME "mint_dma8" - -/* Debug print info */ -#define DEBUG_NAME "audio:dma8: " -#if 0 -#define DEBUG_PRINT(what) \ - { \ - printf what; \ - } -#else -#define DEBUG_PRINT(what) -#endif - -/*--- Static variables ---*/ - -static long cookie_snd, cookie_mch; - -/*--- Audio driver functions ---*/ - -static void Mint_CloseAudio(_THIS); -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_LockAudio(_THIS); -static void Mint_UnlockAudio(_THIS); - -/* To check/init hardware audio */ -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec); - -/* Functions called in supervisor mode */ -static void Mint_InitDma(void); -static void Mint_StopReplay(void); -static void Mint_StartReplay(void); - -/*--- Audio driver bootstrap functions ---*/ - -static int Audio_Available(void) -{ - const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - - /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { - DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); - return 0; - } - - /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { - cookie_mch = MCH_ST; - } - - /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { - cookie_snd = SND_PSG; - } - - /* Check if we have 8 bits audio */ - if ((cookie_snd & SND_8BIT)==0) { - DEBUG_PRINT((DEBUG_NAME "no 8 bits sound\n")); - return(0); - } - - /* Check if audio is lockable */ - if (cookie_snd & SND_16BIT) { - if (Locksnd()!=1) { - DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); - return(0); - } - - Unlocksnd(); - } - - DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n")); - return(1); -} - -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); - if ( this ) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ( (this == NULL) || (this->hidden == NULL) ) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return(0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set the function pointers */ - this->OpenAudio = Mint_OpenAudio; - this->CloseAudio = Mint_CloseAudio; - this->LockAudio = Mint_LockAudio; - this->UnlockAudio = Mint_UnlockAudio; - this->free = Audio_DeleteDevice; - - return this; -} - -AudioBootStrap MINTAUDIO_DMA8_bootstrap = { - MINT_AUDIO_DRIVER_NAME, "MiNT DMA 8 bits audio driver", - Audio_Available, Audio_CreateDevice -}; - -static void Mint_LockAudio(_THIS) -{ - Supexec(Mint_StopReplay); -} - -static void Mint_UnlockAudio(_THIS) -{ - Supexec(Mint_StartReplay); -} - -static void Mint_CloseAudio(_THIS) -{ - Supexec(Mint_StopReplay); - - DEBUG_PRINT((DEBUG_NAME "closeaudio: replay stopped\n")); - - /* Disable interrupt */ - Jdisint(MFP_DMASOUND); - - DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n")); - - /* Wait if currently playing sound */ - while (SDL_MintAudio_mutex != 0) { - } - - DEBUG_PRINT((DEBUG_NAME "closeaudio: no more interrupt running\n")); - - /* Clear buffers */ - if (SDL_MintAudio_audiobuf[0]) { - Mfree(SDL_MintAudio_audiobuf[0]); - SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; - } - - DEBUG_PRINT((DEBUG_NAME "closeaudio: buffers freed\n")); -} - -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) -{ - int i, masterprediv, sfreq; - unsigned long masterclock; - - DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - if (spec->channels > 2) - spec->channels = 2; - - /* Check formats available */ - spec->format = AUDIO_S8; - - /* Calculate and select the closest frequency */ - sfreq=0; - masterclock=MASTERCLOCK_STE; - masterprediv=MASTERPREDIV_STE; - switch(cookie_mch>>16) { -/* - case MCH_STE: - masterclock=MASTERCLOCK_STE; - masterprediv=MASTERPREDIV_STE; - break; -*/ - case MCH_TT: - masterclock=MASTERCLOCK_TT; - masterprediv=MASTERPREDIV_TT; - break; - case MCH_F30: - case MCH_ARANYM: - masterclock=MASTERCLOCK_FALCON1; - masterprediv=MASTERPREDIV_FALCON; - sfreq=1; - break; - } - - MINTAUDIO_freqcount=0; - for (i=sfreq;i<4;i++) { - SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<freq); - spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - - DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - return 0; -} - -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ - SDL_MintAudio_device = this; - - /* Check audio capabilities */ - if (Mint_CheckAudio(this, spec)==-1) { - return -1; - } - - SDL_CalculateAudioSpec(spec); - - /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size *2, MX_STRAM); - if (SDL_MintAudio_audiobuf[0]==NULL) { - SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); - return (-1); - } - SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; - SDL_MintAudio_numbuf=0; - SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); - SDL_MintAudio_audiosize = spec->size; - SDL_MintAudio_mutex = 0; - - DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); - - SDL_MintAudio_CheckFpu(); - - /* Set replay tracks */ - if (cookie_snd & SND_16BIT) { - Settracks(0,0); - Setmontracks(0); - } - - Supexec(Mint_InitDma); - - /* Set interrupt */ - Jdisint(MFP_DMASOUND); - Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt); - Jenabint(MFP_DMASOUND); - - if (cookie_snd & SND_16BIT) { - if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { - DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); - } - } - - Supexec(Mint_StartReplay); - - return(1); /* We don't use threaded audio */ -} - -/* Functions called in supervisor mode */ - -static void Mint_InitDma(void) -{ - unsigned long buffer; - unsigned char mode; - SDL_AudioDevice *this = SDL_MintAudio_device; - - Mint_StopReplay(); - - /* Set buffer */ - buffer = (unsigned long) SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - DMAAUDIO_IO.start_high = (buffer>>16) & 255; - DMAAUDIO_IO.start_mid = (buffer>>8) & 255; - DMAAUDIO_IO.start_low = buffer & 255; - - buffer += SDL_MintAudio_audiosize; - DMAAUDIO_IO.end_high = (buffer>>16) & 255; - DMAAUDIO_IO.end_mid = (buffer>>8) & 255; - DMAAUDIO_IO.end_low = buffer & 255; - - mode = 3-MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - if (this->spec.channels==1) { - mode |= 1<<7; - } - DMAAUDIO_IO.sound_ctrl = mode; -} - -static void Mint_StopReplay(void) -{ - /* Stop replay */ - DMAAUDIO_IO.control=0; -} - -static void Mint_StartReplay(void) -{ - /* Start replay */ - DMAAUDIO_IO.control=3; -} diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.h b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.h deleted file mode 100644 index a52e5db7a5..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_dma8.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - DMA 8bits and Falcon Codec audio definitions - - Patrice Mandin, Didier Méquignon -*/ - -#ifndef _SDL_mintaudio_dma8_h -#define _SDL_mintaudio_dma8_h - -#define DMAAUDIO_IO_BASE (0xffff8900) -struct DMAAUDIO_IO_S { - unsigned char int_ctrl; - unsigned char control; - - unsigned char dummy1; - unsigned char start_high; - unsigned char dummy2; - unsigned char start_mid; - unsigned char dummy3; - unsigned char start_low; - - unsigned char dummy4; - unsigned char cur_high; - unsigned char dummy5; - unsigned char cur_mid; - unsigned char dummy6; - unsigned char cur_low; - - unsigned char dummy7; - unsigned char end_high; - unsigned char dummy8; - unsigned char end_mid; - unsigned char dummy9; - unsigned char end_low; - - unsigned char dummy10[12]; - - unsigned char track_ctrl; /* CODEC only */ - unsigned char sound_ctrl; - unsigned short sound_data; - unsigned short sound_mask; - - unsigned char dummy11[10]; - - unsigned short dev_ctrl; - unsigned short dest_ctrl; - unsigned short sync_div; - unsigned char track_rec; - unsigned char adderin_input; - unsigned char channel_input; - unsigned char channel_amplification; - unsigned char channel_reduction; - - unsigned char dummy12[6]; - - unsigned char data_direction; - unsigned char dummy13; - unsigned char dev_data; -}; -#define DMAAUDIO_IO ((*(volatile struct DMAAUDIO_IO_S *)DMAAUDIO_IO_BASE)) - -#endif /* _SDL_mintaudio_dma8_h */ diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.c b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.c deleted file mode 100644 index 8d7716a137..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MiNT audio driver - using XBIOS functions (GSXB compatible driver) - - Patrice Mandin -*/ - -/* Mint includes */ -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_sysaudio.h" - -#include "../../video/ataricommon/SDL_atarimxalloc_c.h" - -#include "SDL_mintaudio.h" -#include "SDL_mintaudio_gsxb.h" - -/*--- Defines ---*/ - -#define MINT_AUDIO_DRIVER_NAME "mint_gsxb" - -/* Debug print info */ -#define DEBUG_NAME "audio:gsxb: " -#if 0 -#define DEBUG_PRINT(what) \ - { \ - printf what; \ - } -#else -#define DEBUG_PRINT(what) -#endif - -/*--- Static variables ---*/ - -static long cookie_snd, cookie_gsxb; - -/*--- Audio driver functions ---*/ - -static void Mint_CloseAudio(_THIS); -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_LockAudio(_THIS); -static void Mint_UnlockAudio(_THIS); - -/* To check/init hardware audio */ -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); - -/* GSXB callbacks */ -static void Mint_GsxbInterrupt(void); -static void Mint_GsxbNullInterrupt(void); - -/*--- Audio driver bootstrap functions ---*/ - -static int Audio_Available(void) -{ - const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - - /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { - DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); - return(0); - } - - /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { - cookie_snd = SND_PSG; - } - - /* Check if we have 16 bits audio */ - if ((cookie_snd & SND_16BIT)==0) { - DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); - return(0); - } - - /* Cookie GSXB present ? */ - cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND); - - /* Is it GSXB ? */ - if (((cookie_snd & SND_GSXB)==0) || (cookie_gsxb==0)) { - DEBUG_PRINT((DEBUG_NAME "no GSXB audio\n")); - return(0); - } - - /* Check if audio is lockable */ - if (Locksnd()!=1) { - DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); - return(0); - } - - Unlocksnd(); - - DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n")); - return(1); -} - -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); - if ( this ) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ( (this == NULL) || (this->hidden == NULL) ) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return(0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set the function pointers */ - this->OpenAudio = Mint_OpenAudio; - this->CloseAudio = Mint_CloseAudio; - this->LockAudio = Mint_LockAudio; - this->UnlockAudio = Mint_UnlockAudio; - this->free = Audio_DeleteDevice; - - return this; -} - -AudioBootStrap MINTAUDIO_GSXB_bootstrap = { - MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver", - Audio_Available, Audio_CreateDevice -}; - -static void Mint_LockAudio(_THIS) -{ - /* Stop replay */ - Buffoper(0); -} - -static void Mint_UnlockAudio(_THIS) -{ - /* Restart replay */ - Buffoper(SB_PLA_ENA|SB_PLA_RPT); -} - -static void Mint_CloseAudio(_THIS) -{ - /* Stop replay */ - Buffoper(0); - - /* Uninstall interrupt */ - if (NSetinterrupt(2, SI_NONE, Mint_GsxbNullInterrupt)<0) { - DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); - } - - /* Wait if currently playing sound */ - while (SDL_MintAudio_mutex != 0) { - } - - /* Clear buffers */ - if (SDL_MintAudio_audiobuf[0]) { - Mfree(SDL_MintAudio_audiobuf[0]); - SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; - } - - /* Unlock sound system */ - Unlocksnd(); -} - -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) -{ - long snd_format = 0; - int i, resolution, format_signed, format_bigendian; - Uint16 test_format = SDL_FirstAudioFormat(spec->format); - int valid_datatype = 0; - - resolution = spec->format & 0x00ff; - format_signed = ((spec->format & 0x8000)!=0); - format_bigendian = ((spec->format & 0x1000)!=0); - - DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - if (spec->channels > 2) { - spec->channels = 2; /* no more than stereo! */ - } - - while ((!valid_datatype) && (test_format)) { - /* Check formats available */ - snd_format = Sndstatus(SND_QUERYFORMATS); - spec->format = test_format; - resolution = spec->format & 0xff; - format_signed = (spec->format & (1<<15)); - format_bigendian = (spec->format & (1<<12)); - switch (test_format) { - case AUDIO_U8: - case AUDIO_S8: - if (snd_format & SND_FORMAT8) { - valid_datatype = 1; - snd_format = Sndstatus(SND_QUERY8BIT); - } - break; - - case AUDIO_U16LSB: - case AUDIO_S16LSB: - case AUDIO_U16MSB: - case AUDIO_S16MSB: - if (snd_format & SND_FORMAT16) { - valid_datatype = 1; - snd_format = Sndstatus(SND_QUERY16BIT); - } - break; - - default: - test_format = SDL_NextAudioFormat(); - break; - } - } - - if (!valid_datatype) { - SDL_SetError("Unsupported audio format"); - return (-1); - } - - /* Check signed/unsigned format */ - if (format_signed) { - if (snd_format & SND_FORMATSIGNED) { - /* Ok */ - } else if (snd_format & SND_FORMATUNSIGNED) { - /* Give unsigned format */ - spec->format = spec->format & (~0x8000); - } - } else { - if (snd_format & SND_FORMATUNSIGNED) { - /* Ok */ - } else if (snd_format & SND_FORMATSIGNED) { - /* Give signed format */ - spec->format |= 0x8000; - } - } - - if (format_bigendian) { - if (snd_format & SND_FORMATBIGENDIAN) { - /* Ok */ - } else if (snd_format & SND_FORMATLITTLEENDIAN) { - /* Give little endian format */ - spec->format = spec->format & (~0x1000); - } - } else { - if (snd_format & SND_FORMATLITTLEENDIAN) { - /* Ok */ - } else if (snd_format & SND_FORMATBIGENDIAN) { - /* Give big endian format */ - spec->format |= 0x1000; - } - } - - /* Calculate and select the closest frequency */ - MINTAUDIO_freqcount=0; - for (i=1;i<4;i++) { - SDL_MintAudio_AddFrequency(this, - MASTERCLOCK_44K/(MASTERPREDIV_MILAN*(1<freq); - spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - - DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - return 0; -} - -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec) -{ - int channels_mode, prediv; - void *buffer; - - /* Stop currently playing sound */ - Buffoper(0); - - /* Set replay tracks */ - Settracks(0,0); - Setmontracks(0); - - /* Select replay format */ - switch (spec->format & 0xff) { - case 8: - if (spec->channels==2) { - channels_mode=STEREO8; - } else { - channels_mode=MONO8; - } - break; - case 16: - if (spec->channels==2) { - channels_mode=STEREO16; - } else { - channels_mode=MONO16; - } - break; - default: - channels_mode=STEREO16; - break; - } - if (Setmode(channels_mode)<0) { - DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); - } - - prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1); - - /* Set buffer */ - buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - if (Setbuffer(0, buffer, buffer + spec->size)<0) { - DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); - } - - /* Install interrupt */ - if (NSetinterrupt(2, SI_PLAY, Mint_GsxbInterrupt)<0) { - DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n")); - } - - /* Go */ - Buffoper(SB_PLA_ENA|SB_PLA_RPT); - DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); -} - -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ - /* Lock sound system */ - if (Locksnd()!=1) { - SDL_SetError("Mint_OpenAudio: Audio system already in use"); - return(-1); - } - - SDL_MintAudio_device = this; - - /* Check audio capabilities */ - if (Mint_CheckAudio(this, spec)==-1) { - return -1; - } - - SDL_CalculateAudioSpec(spec); - - /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size *2, MX_STRAM); - if (SDL_MintAudio_audiobuf[0]==NULL) { - SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); - return (-1); - } - SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; - SDL_MintAudio_numbuf=0; - SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); - SDL_MintAudio_audiosize = spec->size; - SDL_MintAudio_mutex = 0; - - DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); - - SDL_MintAudio_CheckFpu(); - - /* Setup audio hardware */ - Mint_InitAudio(this, spec); - - return(1); /* We don't use threaded audio */ -} - -static void Mint_GsxbInterrupt(void) -{ - Uint8 *newbuf; - - if (SDL_MintAudio_mutex) - return; - - SDL_MintAudio_mutex=1; - - SDL_MintAudio_numbuf ^= 1; - SDL_MintAudio_Callback(); - newbuf = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - Setbuffer(0, newbuf, newbuf + SDL_MintAudio_audiosize); - - SDL_MintAudio_mutex=0; -} - -static void Mint_GsxbNullInterrupt(void) -{ -} diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.h b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.h deleted file mode 100644 index aee26b7ee3..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_gsxb.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - * GSXB audio definitions - * - * Patrice Mandin - */ - -#ifndef _SDL_mintaudio_gsxb_h -#define _SDL_mintaudio_gsxb_h - -#include /* for trap_14_xxx macros */ - -/* Bit 5 in cookie _SND */ - -#define SND_GSXB (1<<5) - -/* NSoundcmd modes */ - -#define SETRATE 7 /* Set sample rate */ -#define SET8BITFORMAT 8 /* 8 bits format */ -#define SET16BITFORMAT 9 /* 16 bits format */ -#define SET24BITFORMAT 10 /* 24 bits format */ -#define SET32BITFORMAT 11 /* 32 bits format */ -#define LTATTEN_MASTER 12 /* Attenuation */ -#define RTATTEN_MASTER 13 -#define LTATTEN_MICIN 14 -#define RTATTEN_MICIN 15 -#define LTATTEN_FMGEN 16 -#define RTATTEN_FMGEN 17 -#define LTATTEN_LINEIN 18 -#define RTATTEN_LINEIN 19 -#define LTATTEN_CDIN 20 -#define RTATTEN_CDIN 21 -#define LTATTEN_VIDIN 22 -#define RTATTEN_VIDIN 23 -#define LTATTEN_AUXIN 24 -#define RTATTEN_AUXIN 25 - -/* Setmode modes */ - -#define MONO16 3 -#define STEREO24 4 -#define STEREO32 5 -#define MONO24 6 -#define MONO32 7 - -/* Sndstatus modes */ - -#define SND_QUERYFORMATS 2 -#define SND_QUERYMIXERS 3 -#define SND_QUERYSOURCES 4 -#define SND_QUERYDUPLEX 5 -#define SND_QUERY8BIT 8 -#define SND_QUERY16BIT 9 -#define SND_QUERY24BIT 10 -#define SND_QUERY32BIT 11 - -#define SND_FORMAT8 (1<<0) -#define SND_FORMAT16 (1<<1) -#define SND_FORMAT24 (1<<2) -#define SND_FORMAT32 (1<<3) - -#define SND_FORMATSIGNED (1<<0) -#define SND_FORMATUNSIGNED (1<<1) -#define SND_FORMATBIGENDIAN (1<<2) -#define SND_FORMATLITTLEENDIAN (1<<3) - -/* Devconnect prescalers */ - -#define CLK_44K 1 -#define CLK_22K 3 -#define CLK_11K 7 - -/* Extra xbios functions */ - -#define NSoundcmd(mode,data,data2) \ - (long)trap_14_wwl((short)130,(short)(mode),(short)(data),(long)(data2)) -#define NSetinterrupt(src_inter,cause,inth_addr) \ - (long)trap_14_wwwl((short)135,(short)(src_inter),(short)(cause), \ - (long)(inth_addr)) - -#endif /* _SDL_mintaudio_gsxb_h */ diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_it.S b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_it.S deleted file mode 100644 index a2ecac4c65..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_it.S +++ /dev/null @@ -1,386 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* - Audio interrupts - - Patrice Mandin, Didier Méquignon - */ - - .text - - .globl _SDL_MintAudio_Callback - - .globl _SDL_MintAudio_XbiosInterrupt - .globl _SDL_MintAudio_XbiosInterruptMeasureClock - .globl _SDL_MintAudio_Dma8Interrupt - .globl _SDL_MintAudio_StfaInterrupt - - .globl _SDL_MintAudio_mutex - .globl _SDL_MintAudio_audiobuf - .globl _SDL_MintAudio_numbuf - .globl _SDL_MintAudio_audiosize - .globl _SDL_MintAudio_clocktics - .globl _SDL_MintAudio_hasfpu - - .globl _SDL_MintAudio_stfa - -/* - How it works: - - Audio is playing buffer #0 (resp. #1) - - We must calculate a sample in buffer #1 (resp. #0) - so we first call the callback to do it - - Then we swap the buffers -*/ - -#define savptr 0x4a2 -#define savamt 0x46 - -/*--- Save/restore FPU context ---*/ - -#if defined(__mcoldfire__) - -#define SAVE_FPU_CONTEXT \ - lea sp@(-216),sp; \ - fsave sp@; \ - fmovel fpiar,sp@-; \ - lea sp@(-64),sp; \ - fmovemd fp0-fp7,sp@ - -#define RESTORE_FPU_CONTEXT \ - fmovemd sp@,fp0-fp7; \ - lea sp@(64),sp; \ - fmovel sp@+,fpiar; \ - frestore sp@; \ - lea sp@(216),sp - -#else - -#define SAVE_FPU_CONTEXT \ - .chip 68k/68881; \ - fsave sp@-; \ - fmoveml fpcr/fpsr/fpiar,sp@-; \ - fmovemx fp0-fp7,sp@-; \ - .chip 68k - -#define RESTORE_FPU_CONTEXT \ - .chip 68k/68881; \ - fmovemx sp@+,fp0-fp7; \ - fmoveml sp@+,fpcr/fpsr/fpiar; \ - frestore sp@+; \ - .chip 68k - -#endif - -/*--- Xbios interrupt vector to measure Falcon external clock ---*/ - -_SDL_MintAudio_XbiosInterruptMeasureClock: /* 1 mS */ -#if defined(__mcoldfire__) - movel d0,sp@- - - moveql #0,d0 - btst d0,0xFFFF8901:w /* state DMA sound */ -#else - btst #0,0xFFFF8901:w /* state DMA sound */ -#endif - beqs SDL_MintAudio_EndIntMeasure - addql #1,_SDL_MintAudio_clocktics -SDL_MintAudio_EndIntMeasure: -#if defined(__mcoldfire__) - moveql #5,d0 - bclr d0,0xFFFFFA0F:w /* Clear service bit */ - - movel sp@+,d0 -#else - bclr #5,0xFFFFFA0F:w /* Clear service bit */ -#endif - rte - -/*--- Xbios interrupt vector ---*/ - -_SDL_MintAudio_XbiosInterrupt: -#if defined(__mcoldfire__) - lea sp@(-60),sp - moveml d0-d7/a0-a6,sp@ -#else - moveml d0-d7/a0-a6,sp@- -#endif - - /* Reenable interrupts, so other interrupts can work */ - movew #0x2300,sr - - /* Clear service bit, so other MFP interrupts can work */ -#if defined(__mcoldfire__) - moveql #5,d0 - bclr d0,0xfffffa0f:w -#else - bclr #5,0xfffffa0f:w -#endif - - /* Check if we are not already running */ - tstw _SDL_MintAudio_mutex - bne SDL_MintAudio_XbiosEnd - -#if defined(__mcoldfire__) - movew _SDL_MintAudio_mutex,d0 - notl d0 - movew d0,_SDL_MintAudio_mutex - - movew _SDL_MintAudio_numbuf,d1 - eorl #1,d1 - movew d1,_SDL_MintAudio_numbuf -#else - notw _SDL_MintAudio_mutex - - /* Swap buffers */ - eorw #1,_SDL_MintAudio_numbuf -#endif - - /* Save FPU if needed */ - tstw _SDL_MintAudio_hasfpu - beqs SDL_MintAudio_Xbios_nofpu1 - SAVE_FPU_CONTEXT -SDL_MintAudio_Xbios_nofpu1: - - /* Callback */ - jsr _SDL_MintAudio_Callback - - /* Restore FPU if needed */ - tstw _SDL_MintAudio_hasfpu - beqs SDL_MintAudio_Xbios_nofpu2 - RESTORE_FPU_CONTEXT -SDL_MintAudio_Xbios_nofpu2: - - /* Reserve space for registers */ -#if defined(__mcoldfire__) - movel #savamt,d0 - subl d0,savptr -#else - subl #savamt,savptr -#endif - - /* Set new buffer */ - - moveq #0,d0 - movel _SDL_MintAudio_audiosize,d1 - - movew _SDL_MintAudio_numbuf,d0 - lsll #2,d0 - lea _SDL_MintAudio_audiobuf,a0 - movel a0@(d0:l),a1 - - lea a1@(d1:l),a2 - - movel a2,sp@- - movel a1,sp@- - clrw sp@- - movew #131,sp@- - trap #14 - lea sp@(12),sp - - /* Restore registers space */ -#if defined(__mcoldfire__) - movel #savamt,d0 - addl d0,savptr -#else - addl #savamt,savptr -#endif - - clrw _SDL_MintAudio_mutex -SDL_MintAudio_XbiosEnd: -#if defined(__mcoldfire__) - moveml sp@,d0-d7/a0-a6 - lea sp@(60),sp -#else - moveml sp@+,d0-d7/a0-a6 -#endif - rte - -/*--- DMA 8 bits interrupt vector ---*/ - -_SDL_MintAudio_Dma8Interrupt: -#if defined(__mcoldfire__) - lea sp@(-16),sp - moveml d0-d1/a0-a1,sp@ -#else - moveml d0-d1/a0-a1,sp@- -#endif - - /* Reenable interrupts, so other interrupts can work */ - movew #0x2300,sr - - /* Clear service bit, so other MFP interrupts can work */ -#if defined(__mcoldfire__) - moveql #5,d0 - bclr d0,0xfffffa0f:w -#else - bclr #5,0xfffffa0f:w -#endif - /* Check if we are not already running */ - tstw _SDL_MintAudio_mutex - bne SDL_MintAudio_Dma8End - -#if defined(__mcoldfire__) - movew _SDL_MintAudio_mutex,d0 - notl d0 - movew d0,_SDL_MintAudio_mutex - - movew _SDL_MintAudio_numbuf,d1 - eorl #1,d1 - movew d1,_SDL_MintAudio_numbuf -#else - notw _SDL_MintAudio_mutex - - /* Swap buffers */ - eorw #1,_SDL_MintAudio_numbuf -#endif - - /* Save FPU if needed */ - tstw _SDL_MintAudio_hasfpu - beqs SDL_MintAudio_Dma8_nofpu1 - SAVE_FPU_CONTEXT -SDL_MintAudio_Dma8_nofpu1: - - /* Callback */ - jsr _SDL_MintAudio_Callback - - /* Restore FPU if needed */ - tstw _SDL_MintAudio_hasfpu - beqs SDL_MintAudio_Dma8_nofpu2 - RESTORE_FPU_CONTEXT -SDL_MintAudio_Dma8_nofpu2: - - /* Set new buffer */ - - moveq #0,d0 - - movew _SDL_MintAudio_numbuf,d0 - lsll #2,d0 - lea _SDL_MintAudio_audiobuf,a0 - movel a0@(d0:l),d1 - - /* Modify DMA addresses */ - lea 0xffff8900:w,a0 - - movel d1,d0 - - moveb d0,a0@(0x07) /* Start address */ - lsrl #8,d0 - moveb d0,a0@(0x05) - lsrl #8,d0 - moveb d0,a0@(0x03) - - addl _SDL_MintAudio_audiosize,d1 - - movel d1,d0 - - moveb d0,a0@(0x13) /* End address */ - lsrl #8,d0 - moveb d0,a0@(0x11) - lsrl #8,d0 - moveb d0,a0@(0x0f) - - clrw _SDL_MintAudio_mutex -SDL_MintAudio_Dma8End: -#if defined(__mcoldfire__) - moveml sp@,d0-d1/a0-a1 - lea sp@(16),sp -#else - moveml sp@+,d0-d1/a0-a1 -#endif - rte - -/*--- STFA interrupt vector ---*/ - -STFA_SOUND_START = 6 -STFA_SOUND_END = STFA_SOUND_START+8 - -_SDL_MintAudio_StfaInterrupt: - /* Reenable interrupts, so other interrupts can work */ - movew #0x2300,sr - - /* Check if we are not already running */ - tstw _SDL_MintAudio_mutex - -#if defined(__mcoldfire__) - bne SDL_MintAudio_StfaEnd - - lea sp@(-60),sp - moveml d0-d7/a0-a6,sp@ - - movew _SDL_MintAudio_mutex,d0 - notl d0 - movew d0,_SDL_MintAudio_mutex - - movew _SDL_MintAudio_numbuf,d1 - eorl #1,d1 - movew d1,_SDL_MintAudio_numbuf -#else - bnes SDL_MintAudio_StfaEnd - - moveml d0-d7/a0-a6,sp@- - - notw _SDL_MintAudio_mutex - - /* Swap buffers */ - eorw #1,_SDL_MintAudio_numbuf -#endif - - /* Save FPU if needed */ - tstw _SDL_MintAudio_hasfpu - beqs SDL_MintAudio_Stfa_nofpu1 - SAVE_FPU_CONTEXT -SDL_MintAudio_Stfa_nofpu1: - - /* Callback */ - jsr _SDL_MintAudio_Callback - - /* Restore FPU if needed */ - tstw _SDL_MintAudio_hasfpu - beqs SDL_MintAudio_Stfa_nofpu2 - RESTORE_FPU_CONTEXT -SDL_MintAudio_Stfa_nofpu2: - - /* Set new buffer */ - - moveq #0,d0 - movel _SDL_MintAudio_stfa,a1 - - movew _SDL_MintAudio_numbuf,d0 - lsll #2,d0 - lea _SDL_MintAudio_audiobuf,a0 - movel a0@(d0:l),d1 - - /* Modify STFA replay buffers */ - movel d1,a1@(STFA_SOUND_START) - addl _SDL_MintAudio_audiosize,d1 - movel d1,a1@(STFA_SOUND_END) - -#if defined(__mcoldfire__) - moveml sp@,d0-d7/a0-a6 - lea sp@(60),sp -#else - moveml sp@+,d0-d7/a0-a6 -#endif - clrw _SDL_MintAudio_mutex -SDL_MintAudio_StfaEnd: - rte diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.c b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.c deleted file mode 100644 index 387609b168..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.c +++ /dev/null @@ -1,405 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MiNT audio driver - using XBIOS functions (MacSound compatible driver) - - Patrice Mandin -*/ - -#include - -/* Mint includes */ -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_sysaudio.h" - -#include "../../video/ataricommon/SDL_atarimxalloc_c.h" - -#include "SDL_mintaudio.h" -#include "SDL_mintaudio_mcsn.h" - -/*--- Defines ---*/ - -#define MINT_AUDIO_DRIVER_NAME "mint_mcsn" - -/* Debug print info */ -#define DEBUG_NAME "audio:mcsn: " -#if 0 -#define DEBUG_PRINT(what) \ - { \ - printf what; \ - } -#else -#define DEBUG_PRINT(what) -#endif - -/*--- Static variables ---*/ - -static long cookie_snd, cookie_mch; -static cookie_mcsn_t *cookie_mcsn; - -/*--- Audio driver functions ---*/ - -static void Mint_CloseAudio(_THIS); -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_LockAudio(_THIS); -static void Mint_UnlockAudio(_THIS); - -/* To check/init hardware audio */ -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); - -/*--- Audio driver bootstrap functions ---*/ - -static int Audio_Available(void) -{ - long dummy; - const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - - SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); - - /* We can't use XBIOS in interrupt with Magic, don't know about thread */ - if (Getcookie(C_MagX, &dummy) == C_FOUND) { - return(0); - } - - /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { - DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); - return(0); - } - - /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { - cookie_mch = MCH_ST; - } - - /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { - cookie_snd = SND_PSG; - } - - /* Check if we have 16 bits audio */ - if ((cookie_snd & SND_16BIT)==0) { - DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); - return(0); - } - - /* Cookie MCSN present ? */ - if (Getcookie(C_McSn, &dummy) != C_FOUND) { - DEBUG_PRINT((DEBUG_NAME "no MCSN audio\n")); - return(0); - } - cookie_mcsn = (cookie_mcsn_t *) dummy; - - /* Check if interrupt at end of replay */ - if (cookie_mcsn->pint == 0) { - DEBUG_PRINT((DEBUG_NAME "no interrupt at end of replay\n")); - return(0); - } - - /* Check if audio is lockable */ - if (Locksnd()!=1) { - DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); - return(0); - } - - Unlocksnd(); - - DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n")); - return(1); -} - -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); - if ( this ) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ( (this == NULL) || (this->hidden == NULL) ) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return(0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set the function pointers */ - this->OpenAudio = Mint_OpenAudio; - this->CloseAudio = Mint_CloseAudio; - this->LockAudio = Mint_LockAudio; - this->UnlockAudio = Mint_UnlockAudio; - this->free = Audio_DeleteDevice; - - return this; -} - -AudioBootStrap MINTAUDIO_MCSN_bootstrap = { - MINT_AUDIO_DRIVER_NAME, "MiNT MCSN audio driver", - Audio_Available, Audio_CreateDevice -}; - -static void Mint_LockAudio(_THIS) -{ - /* Stop replay */ - Buffoper(0); -} - -static void Mint_UnlockAudio(_THIS) -{ - /* Restart replay */ - Buffoper(SB_PLA_ENA|SB_PLA_RPT); -} - -static void Mint_CloseAudio(_THIS) -{ - /* Stop replay */ - SDL_MintAudio_WaitThread(); - Buffoper(0); - - if (!SDL_MintAudio_mint_present) { - /* Uninstall interrupt */ - Jdisint(MFP_DMASOUND); - } - - /* Wait if currently playing sound */ - while (SDL_MintAudio_mutex != 0) { - } - - /* Clear buffers */ - if (SDL_MintAudio_audiobuf[0]) { - Mfree(SDL_MintAudio_audiobuf[0]); - SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; - } - - /* Unlock sound system */ - Unlocksnd(); -} - -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) -{ - int i; - unsigned long masterclock, masterprediv; - - DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - if (spec->channels > 2) { - spec->channels = 2; /* no more than stereo! */ - } - - /* Check formats available */ - MINTAUDIO_freqcount=0; - switch(cookie_mcsn->play) { - case MCSN_ST: - spec->channels=1; - spec->format=8; /* FIXME: is it signed or unsigned ? */ - SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1); - break; - case MCSN_TT: /* Also STE, Mega STE */ - spec->format=AUDIO_S8; - masterclock=MASTERCLOCK_STE; - masterprediv=MASTERPREDIV_STE; - if ((cookie_mch>>16)==MCH_TT) { - masterclock=MASTERCLOCK_TT; - masterprediv=MASTERPREDIV_TT; - } - for (i=0; i<4; i++) { - SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<res1 != 0) { - for (i=1; i<4; i++) { - SDL_MintAudio_AddFrequency(this, (cookie_mcsn->res1)/(MASTERPREDIV_FALCON*(1<format |= 0x8000; /* Audio is always signed */ - if ((spec->format & 0x00ff)==16) { - spec->format |= 0x1000; /* Audio is always big endian */ - spec->channels=2; /* 16 bits always stereo */ - } - break; - } - -#if 0 - for (i=0; ifreq); - spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - - DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - return 0; -} - -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec) -{ - int channels_mode, prediv, dmaclock; - void *buffer; - - /* Stop currently playing sound */ - SDL_MintAudio_quit_thread = SDL_FALSE; - SDL_MintAudio_thread_finished = SDL_TRUE; - SDL_MintAudio_WaitThread(); - Buffoper(0); - - /* Set replay tracks */ - Settracks(0,0); - Setmontracks(0); - - /* Select replay format */ - channels_mode=STEREO16; - switch (spec->format & 0xff) { - case 8: - if (spec->channels==2) { - channels_mode=STEREO8; - } else { - channels_mode=MONO8; - } - break; - } - if (Setmode(channels_mode)<0) { - DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); - } - - dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock; - prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - switch(cookie_mcsn->play) { - case MCSN_TT: - Devconnect(DMAPLAY, DAC, CLK25M, CLKOLD, 1); - Soundcmd(SETPRESCALE, prediv); - DEBUG_PRINT((DEBUG_NAME "STE/TT prescaler selected\n")); - break; - case MCSN_FALCON: - Devconnect(DMAPLAY, DAC, dmaclock, prediv, 1); - DEBUG_PRINT((DEBUG_NAME "Falcon prescaler selected\n")); - break; - } - - /* Set buffer */ - buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - if (Setbuffer(0, buffer, buffer + spec->size)<0) { - DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); - } - - if (SDL_MintAudio_mint_present) { - SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0); - } else { - /* Install interrupt */ - Jdisint(MFP_DMASOUND); - Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); - Jenabint(MFP_DMASOUND); - - if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { - DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); - } - } - - /* Go */ - Buffoper(SB_PLA_ENA|SB_PLA_RPT); - DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); -} - -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ - /* Lock sound system */ - if (Locksnd()!=1) { - SDL_SetError("Mint_OpenAudio: Audio system already in use"); - return(-1); - } - - SDL_MintAudio_device = this; - - /* Check audio capabilities */ - if (Mint_CheckAudio(this, spec)==-1) { - return -1; - } - - SDL_CalculateAudioSpec(spec); - - /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size *2, MX_STRAM); - if (SDL_MintAudio_audiobuf[0]==NULL) { - SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); - return (-1); - } - SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; - SDL_MintAudio_numbuf=0; - SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); - SDL_MintAudio_audiosize = spec->size; - SDL_MintAudio_mutex = 0; - - DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); - - SDL_MintAudio_CheckFpu(); - - /* Setup audio hardware */ - Mint_InitAudio(this, spec); - - return(1); /* We don't use SDL threaded audio */ -} diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.h b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.h deleted file mode 100644 index b772fdab03..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_mcsn.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MCSN control structure - - Patrice Mandin -*/ - -#ifndef _SDL_mintaudio_mcsh_h -#define _SDL_mintaudio_mcsh_h - -typedef struct { - unsigned short version; /* Version */ - unsigned short size; /* Size of structure */ - - unsigned short play; /* Replay capability */ - unsigned short record; /* Record capability */ - unsigned short dsp; /* DSP56K present */ - unsigned short pint; /* Interrupt at end of replay */ - unsigned short rint; /* Interrupt at end of record */ - - unsigned long res1; /* Frequency of external clock */ - unsigned long res2; - unsigned long res3; - unsigned long res4; -} cookie_mcsn_t; - -enum { - MCSN_ST=0, - MCSN_TT, - MCSN_STE=MCSN_TT, - MCSN_FALCON, - MCSN_MAC=MCSN_FALCON -}; - -#define SETSMPFREQ 7 /* Set sample frequency */ - -#endif /* _SDL_mintaudio_mcsh_h */ diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.c b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.c deleted file mode 100644 index 4a581e0351..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MiNT audio driver - using XBIOS functions (STFA driver) - - Patrice Mandin -*/ - -/* Mint includes */ -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_sysaudio.h" - -#include "../../video/ataricommon/SDL_atarimxalloc_c.h" -#include "../../video/ataricommon/SDL_atarisuper.h" - -#include "SDL_mintaudio.h" -#include "SDL_mintaudio_stfa.h" - -/*--- Defines ---*/ - -#define MINT_AUDIO_DRIVER_NAME "mint_stfa" - -/* Debug print info */ -#define DEBUG_NAME "audio:stfa: " -#if 0 -#define DEBUG_PRINT(what) \ - { \ - printf what; \ - } -#else -#define DEBUG_PRINT(what) -#endif - -/*--- Static variables ---*/ - -static long cookie_snd, cookie_mch; -static cookie_stfa_t *cookie_stfa; - -static const int freqs[16]={ - 4995, 6269, 7493, 8192, - 9830, 10971, 12538, 14985, - 16384, 19819, 21943, 24576, - 30720, 32336, 43885, 49152 -}; - -/*--- Audio driver functions ---*/ - -static void Mint_CloseAudio(_THIS); -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_LockAudio(_THIS); -static void Mint_UnlockAudio(_THIS); - -/* To check/init hardware audio */ -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); - -/*--- Audio driver bootstrap functions ---*/ - -static int Audio_Available(void) -{ - long dummy; - const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - - /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { - DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); - return(0); - } - - /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { - cookie_mch = MCH_ST; - } - - /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { - cookie_snd = SND_PSG; - } - - /* Cookie STFA present ? */ - if (Getcookie(C_STFA, &dummy) != C_FOUND) { - DEBUG_PRINT((DEBUG_NAME "no STFA audio\n")); - return(0); - } - cookie_stfa = (cookie_stfa_t *) dummy; - - SDL_MintAudio_stfa = cookie_stfa; - - DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n")); - return(1); -} - -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); - if ( this ) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ( (this == NULL) || (this->hidden == NULL) ) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return(0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set the function pointers */ - this->OpenAudio = Mint_OpenAudio; - this->CloseAudio = Mint_CloseAudio; - this->LockAudio = Mint_LockAudio; - this->UnlockAudio = Mint_UnlockAudio; - this->free = Audio_DeleteDevice; - - return this; -} - -AudioBootStrap MINTAUDIO_STFA_bootstrap = { - MINT_AUDIO_DRIVER_NAME, "MiNT STFA audio driver", - Audio_Available, Audio_CreateDevice -}; - -static void Mint_LockAudio(_THIS) -{ - void *oldpile; - - /* Stop replay */ - oldpile=(void *)Super(0); - cookie_stfa->sound_enable=STFA_PLAY_DISABLE; - SuperToUser(oldpile); -} - -static void Mint_UnlockAudio(_THIS) -{ - void *oldpile; - - /* Restart replay */ - oldpile=(void *)Super(0); - cookie_stfa->sound_enable=STFA_PLAY_ENABLE|STFA_PLAY_REPEAT; - SuperToUser(oldpile); -} - -static void Mint_CloseAudio(_THIS) -{ - void *oldpile; - - /* Stop replay */ - oldpile=(void *)Super(0); - cookie_stfa->sound_enable=STFA_PLAY_DISABLE; - SuperToUser(oldpile); - - /* Wait if currently playing sound */ - while (SDL_MintAudio_mutex != 0) { - } - - /* Clear buffers */ - if (SDL_MintAudio_audiobuf[0]) { - Mfree(SDL_MintAudio_audiobuf[0]); - SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; - } -} - -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) -{ - int i; - - DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - if (spec->channels > 2) { - spec->channels = 2; /* no more than stereo! */ - } - - /* Check formats available */ - MINTAUDIO_freqcount=0; - for (i=0;i<16;i++) { - SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1); - } - -#if 1 - for (i=0; ifreq); - spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - - DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - return 0; -} - -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec) -{ - void *buffer; - void *oldpile; - - buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - - oldpile=(void *)Super(0); - - /* Stop replay */ - cookie_stfa->sound_enable=STFA_PLAY_DISABLE; - - /* Select replay format */ - cookie_stfa->sound_control = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - if ((spec->format & 0xff)==8) { - cookie_stfa->sound_control |= STFA_FORMAT_8BIT; - } else { - cookie_stfa->sound_control |= STFA_FORMAT_16BIT; - } - if (spec->channels==2) { - cookie_stfa->sound_control |= STFA_FORMAT_STEREO; - } else { - cookie_stfa->sound_control |= STFA_FORMAT_MONO; - } - if ((spec->format & 0x8000)!=0) { - cookie_stfa->sound_control |= STFA_FORMAT_SIGNED; - } else { - cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED; - } - if ((spec->format & 0x1000)!=0) { - cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN; - } else { - cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN; - } - - /* Set buffer */ - cookie_stfa->sound_start = (unsigned long) buffer; - cookie_stfa->sound_end = (unsigned long) (buffer + spec->size); - - /* Set interrupt */ - cookie_stfa->stfa_it = SDL_MintAudio_StfaInterrupt; - - /* Restart replay */ - cookie_stfa->sound_enable=STFA_PLAY_ENABLE|STFA_PLAY_REPEAT; - - SuperToUser(oldpile); - - DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); -} - -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ - SDL_MintAudio_device = this; - - /* Check audio capabilities */ - if (Mint_CheckAudio(this, spec)==-1) { - return -1; - } - - SDL_CalculateAudioSpec(spec); - - /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size *2, MX_STRAM); - if (SDL_MintAudio_audiobuf[0]==NULL) { - SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); - return (-1); - } - SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; - SDL_MintAudio_numbuf=0; - SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); - SDL_MintAudio_audiosize = spec->size; - SDL_MintAudio_mutex = 0; - - DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); - - SDL_MintAudio_CheckFpu(); - - /* Setup audio hardware */ - Mint_InitAudio(this, spec); - - return(1); /* We don't use threaded audio */ -} diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.h b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.h deleted file mode 100644 index 1789b4bb41..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_stfa.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - STFA control structure - - Patrice Mandin -*/ - -#ifndef _SDL_mintaudio_stfa_h -#define _SDL_mintaudio_stfa_h - -/*--- Defines ---*/ - -#define STFA_PLAY_ENABLE (1<<0) -#define STFA_PLAY_DISABLE (0<<0) -#define STFA_PLAY_REPEAT (1<<1) -#define STFA_PLAY_SINGLE (0<<1) - -#define STFA_FORMAT_SIGNED (1<<15) -#define STFA_FORMAT_UNSIGNED (0<<15) -#define STFA_FORMAT_STEREO (1<<14) -#define STFA_FORMAT_MONO (0<<14) -#define STFA_FORMAT_16BIT (1<<13) -#define STFA_FORMAT_8BIT (0<<13) -#define STFA_FORMAT_LITENDIAN (1<<9) -#define STFA_FORMAT_BIGENDIAN (0<<9) -#define STFA_FORMAT_FREQ_MASK 0x0f -enum { - STFA_FORMAT_F4995=0, - STFA_FORMAT_F6269, - STFA_FORMAT_F7493, - STFA_FORMAT_F8192, - - STFA_FORMAT_F9830, - STFA_FORMAT_F10971, - STFA_FORMAT_F12538, - STFA_FORMAT_F14985, - - STFA_FORMAT_F16384, - STFA_FORMAT_F19819, - STFA_FORMAT_F21943, - STFA_FORMAT_F24576, - - STFA_FORMAT_F30720, - STFA_FORMAT_F32336, - STFA_FORMAT_F43885, - STFA_FORMAT_F49152 -}; - -/*--- Types ---*/ - -typedef struct { - unsigned short sound_enable; - unsigned short sound_control; - unsigned short sound_output; - unsigned long sound_start; - unsigned long sound_current; - unsigned long sound_end; - unsigned short version; - void *old_vbl; - void *old_timera; - unsigned long old_mfp_status; - void *new_vbl; - void *drivers_list; - void *play_stop; - unsigned short frequency; - void *set_frequency; - unsigned short frequency_threshold; - unsigned short *custom_freq_table; - unsigned short stfa_on_off; - void *new_drivers_list; - unsigned long old_bit_2_of_cookie_snd; - void (*stfa_it)(void); -} cookie_stfa_t; - -#endif /* _SDL_mintaudio_stfa_h */ diff --git a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_xbios.c b/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_xbios.c deleted file mode 100644 index 42a0d4a2f9..0000000000 --- a/apps/plugins/sdl/src/audio/mint/SDL_mintaudio_xbios.c +++ /dev/null @@ -1,490 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MiNT audio driver - using XBIOS functions (Falcon) - - Patrice Mandin, Didier Méquignon -*/ - -#include -#include - -/* Mint includes */ -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_sysaudio.h" - -#include "../../video/ataricommon/SDL_atarimxalloc_c.h" -#include "../../video/ataricommon/SDL_atarisuper.h" - -#include "SDL_mintaudio.h" -#include "SDL_mintaudio_dma8.h" - -/*--- Defines ---*/ - -#define MINT_AUDIO_DRIVER_NAME "mint_xbios" - -/* Debug print info */ -#define DEBUG_NAME "audio:xbios: " -#if 0 -#define DEBUG_PRINT(what) \ - { \ - printf what; \ - } -#else -#define DEBUG_PRINT(what) -#endif - -/*--- Static variables ---*/ - -static long cookie_snd; - -/*--- Audio driver functions ---*/ - -static void Mint_CloseAudio(_THIS); -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_LockAudio(_THIS); -static void Mint_UnlockAudio(_THIS); - -/* To check/init hardware audio */ -static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec); -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); - -/*--- Audio driver bootstrap functions ---*/ - -static int Audio_Available(void) -{ -/* unsigned long dummy;*/ - const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - - /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);*/ - SDL_MintAudio_mint_present = SDL_FALSE; - - /* We can't use XBIOS in interrupt with Magic, don't know about thread */ - /*if (Getcookie(C_MagX, &dummy) == C_FOUND) { - return(0); - }*/ - - /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { - DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); - return(0); - } - - /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { - cookie_snd = SND_PSG; - } - - /* Check if we have 16 bits audio */ - if ((cookie_snd & SND_16BIT)==0) { - DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); - return(0); - } - - /* Check if audio is lockable */ - if (Locksnd()!=1) { - DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); - return(0); - } - - Unlocksnd(); - - DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n")); - return(1); -} - -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); - if ( this ) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ( (this == NULL) || (this->hidden == NULL) ) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return(0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set the function pointers */ - this->OpenAudio = Mint_OpenAudio; - this->CloseAudio = Mint_CloseAudio; - this->LockAudio = Mint_LockAudio; - this->UnlockAudio = Mint_UnlockAudio; - this->free = Audio_DeleteDevice; - - return this; -} - -AudioBootStrap MINTAUDIO_XBIOS_bootstrap = { - MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver", - Audio_Available, Audio_CreateDevice -}; - -static void Mint_LockAudio(_THIS) -{ - /* Stop replay */ - Buffoper(0); -} - -static void Mint_UnlockAudio(_THIS) -{ - /* Restart replay */ - Buffoper(SB_PLA_ENA|SB_PLA_RPT); -} - -static void Mint_CloseAudio(_THIS) -{ - /* Stop replay */ - SDL_MintAudio_WaitThread(); - Buffoper(0); - - if (!SDL_MintAudio_mint_present) { - /* Uninstall interrupt */ - Jdisint(MFP_DMASOUND); - } - - /* Wait if currently playing sound */ - while (SDL_MintAudio_mutex != 0) { - } - - /* Clear buffers */ - if (SDL_MintAudio_audiobuf[0]) { - Mfree(SDL_MintAudio_audiobuf[0]); - SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; - } - - /* Unlock sound system */ - Unlocksnd(); -} - -/* Falcon XBIOS implementation of Devconnect() is buggy with external clock */ -static void Devconnect2(int src, int dst, int sclk, int pre) -{ - static const unsigned short MASK1[3] = { 0, 0x6000, 0 }; - static const unsigned short MASK2[4] = { 0xFFF0, 0xFF8F, 0xF0FF, 0x0FFF }; - static const unsigned short INDEX1[4] = { 1, 3, 5, 7 }; - static const unsigned short INDEX2[4] = { 0, 2, 4, 6 }; - unsigned short sync_div,dev_ctrl,dest_ctrl; - void *oldstack; - - if (dst==0) { - return; - } - - oldstack=(void *)Super(0); - - dev_ctrl = DMAAUDIO_IO.dev_ctrl; - dest_ctrl = DMAAUDIO_IO.dest_ctrl; - dev_ctrl &= MASK2[src]; - - if (src==ADC) { - dev_ctrl |= MASK1[sclk]; - } else { - dev_ctrl |= (INDEX1[sclk] << (src<<4)); - } - - if (dst & DMAREC) { - dest_ctrl &= 0xFFF0; - dest_ctrl |= INDEX1[src]; - } - - if (dst & DSPRECV) { - dest_ctrl &= 0xFF8F; - dest_ctrl |= (INDEX1[src]<<4); - } - - if (dst & EXTOUT) { - dest_ctrl &= 0xF0FF; - dest_ctrl |= (INDEX1[src]<<8); - } - - if (dst & DAC) { - dev_ctrl &= 0x0FFF; - dev_ctrl |= MASK1[sclk]; - dest_ctrl &= 0x0FFF; - dest_ctrl |= (INDEX2[src]<<12); - } - - sync_div = DMAAUDIO_IO.sync_div; - if (sclk==CLKEXT) { - pre<<=8; - sync_div &= 0xF0FF; - } else { - sync_div &= 0xFFF0; - } - sync_div |= pre; - - DMAAUDIO_IO.dev_ctrl = dev_ctrl; - DMAAUDIO_IO.dest_ctrl = dest_ctrl; - DMAAUDIO_IO.sync_div = sync_div; - - SuperToUser(oldstack); -} - -static void Mint_CheckExternalClock(_THIS) -{ -#define SIZE_BUF_CLOCK_MEASURE (44100/10) - - char *buffer; - int i, j; - - /* DSP present with its GPIO port ? */ - if ((cookie_snd & SND_DSP)==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; - } - SDL_memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE); - - Buffoper(0); - Settracks(0,0); - Setmontracks(0); - Setmode(MONO8); - Jdisint(MFP_TIMERA); - - for (i=0; i<2; i++) { - Gpio(GPIO_SET,7); /* DSP port gpio outputs */ - Gpio(GPIO_WRITE,2+i); /* 22.5792/24.576 MHz for 44.1/48KHz */ - Devconnect2(DMAPLAY, DAC, CLKEXT, CLK50K); /* Matrix and clock source */ - Setbuffer(0, buffer, buffer + SIZE_BUF_CLOCK_MEASURE); /* Set buffer */ - Xbtimer(XB_TIMERA, 5, 38, SDL_MintAudio_XbiosInterruptMeasureClock); /* delay mode timer A, prediv /64, 1KHz */ - Jenabint(MFP_TIMERA); - SDL_MintAudio_clocktics = 0; - Buffoper(SB_PLA_ENA); - usleep(110000); - - if((Buffoper(-1) & 1)==0) { - if (SDL_MintAudio_clocktics) { - unsigned long khz; - - khz = ((SIZE_BUF_CLOCK_MEASURE/SDL_MintAudio_clocktics) +1) & 0xFFFFFFFE; - DEBUG_PRINT((DEBUG_NAME "measure %d: freq=%lu KHz\n", i+1, khz)); - - if(khz==44) { - for (j=1; j<4; j++) { - SDL_MintAudio_AddFrequency(this, MASTERCLOCK_44K/(MASTERPREDIV_FALCON*(1<format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - if (spec->channels > 2) { - spec->channels = 2; /* no more than stereo! */ - } - - spec->format |= 0x8000; /* Audio is always signed */ - if ((spec->format & 0x00ff)==16) { - spec->format |= 0x1000; /* Audio is always big endian */ - spec->channels=2; /* 16 bits always stereo */ - } - - MINTAUDIO_freqcount=0; - - /* Add external clocks if present */ - Mint_CheckExternalClock(this); - - /* Standard clocks */ - 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, -1); - } - -#if 1 - for (i=0; ifreq); - spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - - DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); - DEBUG_PRINT(("channels=%d, ", spec->channels)); - DEBUG_PRINT(("freq=%d\n", spec->freq)); - - return 0; -} - -static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec) -{ - int channels_mode, prediv; - void *buffer; - - /* Stop currently playing sound */ - SDL_MintAudio_quit_thread = SDL_FALSE; - SDL_MintAudio_thread_finished = SDL_TRUE; - SDL_MintAudio_WaitThread(); - Buffoper(0); - - /* Set replay tracks */ - Settracks(0,0); - Setmontracks(0); - - /* Select replay format */ - channels_mode=STEREO16; - switch (spec->format & 0xff) { - case 8: - if (spec->channels==2) { - channels_mode=STEREO8; - } else { - channels_mode=MONO8; - } - break; - } - if (Setmode(channels_mode)<0) { - DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); - } - - prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - if (MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits != -1) { - Gpio(GPIO_SET,7); /* DSP port gpio outputs */ - Gpio(GPIO_WRITE, MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits); - Devconnect2(DMAPLAY, DAC|EXTOUT, CLKEXT, prediv); - } else { - Devconnect2(DMAPLAY, DAC, CLK25M, prediv); - } - - /* Set buffer */ - buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - if (Setbuffer(0, buffer, buffer + spec->size)<0) { - DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); - } - - if (SDL_MintAudio_mint_present) { - SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0); - } else { - /* Install interrupt */ - Jdisint(MFP_DMASOUND); - /*Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt);*/ - Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt); - Jenabint(MFP_DMASOUND); - - if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { - DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); - } - } - - /* Go */ - Buffoper(SB_PLA_ENA|SB_PLA_RPT); - DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); -} - -static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ - /* Lock sound system */ - if (Locksnd()!=1) { - SDL_SetError("Mint_OpenAudio: Audio system already in use"); - return(-1); - } - - SDL_MintAudio_device = this; - - /* Check audio capabilities */ - if (Mint_CheckAudio(this, spec)==-1) { - return -1; - } - - SDL_CalculateAudioSpec(spec); - - /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size *2, MX_STRAM); - if (SDL_MintAudio_audiobuf[0]==NULL) { - SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); - return (-1); - } - SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; - SDL_MintAudio_numbuf=0; - SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); - SDL_MintAudio_audiosize = spec->size; - SDL_MintAudio_mutex = 0; - - DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); - - SDL_MintAudio_CheckFpu(); - - /* Setup audio hardware */ - Mint_InitAudio(this, spec); - - return(1); /* We don't use SDL threaded audio */ -} -- cgit v1.2.3