src/audio/mint/SDL_mintaudio.h
author Sam Lantinga
Sat, 19 Sep 2009 13:29:40 +0000
changeset 3280 00cace2d9080
parent 2859 99210400e8b9
permissions -rw-r--r--
Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Library General Public
     7     License as published by the Free Software Foundation; either
     8     version 2 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Library General Public License for more details.
    14 
    15     You should have received a copy of the GNU Library General Public
    16     License along with this library; if not, write to the Free
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 /*
    25 	MiNT audio driver
    26 
    27 	Patrice Mandin
    28 */
    29 
    30 #ifndef _SDL_mintaudio_h
    31 #define _SDL_mintaudio_h
    32 
    33 #include "../SDL_sysaudio.h"
    34 #include "SDL_mintaudio_stfa.h"
    35 
    36 /* Hidden "this" pointer for the audio functions */
    37 #define _THIS	SDL_AudioDevice *this
    38 
    39 /* 16 predivisors with 3 clocks max. */
    40 #define MINTAUDIO_maxfreqs		(16*3)
    41 
    42 typedef struct
    43 {
    44     Uint32 frequency;
    45     Uint32 masterclock;
    46     Uint32 predivisor;
    47     int gpio_bits;              /* in case of external clock */
    48 } mint_frequency_t;
    49 
    50 struct SDL_PrivateAudioData
    51 {
    52     mint_frequency_t frequencies[MINTAUDIO_maxfreqs];
    53     int freq_count;             /* Number of frequencies in the array */
    54     int numfreq;                /* Number of selected frequency */
    55 };
    56 
    57 /* Old variable names */
    58 
    59 #define MINTAUDIO_frequencies	(this->hidden->frequencies)
    60 #define MINTAUDIO_freqcount		(this->hidden->freq_count)
    61 #define MINTAUDIO_numfreq		(this->hidden->numfreq)
    62 
    63 /* _MCH cookie (values>>16) */
    64 enum
    65 {
    66     MCH_ST = 0,
    67     MCH_STE,
    68     MCH_TT,
    69     MCH_F30,
    70     MCH_CLONE,
    71     MCH_ARANYM
    72 };
    73 
    74 /* Master clocks for replay frequencies */
    75 #define MASTERCLOCK_STE		8010666 /* Not sure of this one */
    76 #define MASTERCLOCK_TT		16107953        /* Not sure of this one */
    77 #define MASTERCLOCK_FALCON1	25175000
    78 #define MASTERCLOCK_FALCON2	32000000        /* Only usable for DSP56K */
    79 #define MASTERCLOCK_FALCONEXT	-1      /* Clock on DSP56K port, unknown */
    80 #define MASTERCLOCK_44K		22579200        /* Standard clock for 44.1 Khz */
    81 #define MASTERCLOCK_48K		24576000        /* Standard clock for 48 Khz */
    82 
    83 /* Master clock predivisors */
    84 #define MASTERPREDIV_STE	160
    85 #define MASTERPREDIV_TT		320
    86 #define MASTERPREDIV_FALCON	256
    87 #define MASTERPREDIV_MILAN	256
    88 
    89 /* MFP 68901 interrupt sources */
    90 enum
    91 {
    92     MFP_PARALLEL = 0,
    93     MFP_DCD,
    94     MFP_CTS,
    95     MFP_BITBLT,
    96     MFP_TIMERD,
    97     MFP_BAUDRATE = MFP_TIMERD,
    98     MFP_TIMERC,
    99     MFP_200HZ = MFP_TIMERC,
   100     MFP_ACIA,
   101     MFP_DISK,
   102     MFP_TIMERB,
   103     MFP_HBLANK = MFP_TIMERB,
   104     MFP_TERR,
   105     MFP_TBE,
   106     MFP_RERR,
   107     MFP_RBF,
   108     MFP_TIMERA,
   109     MFP_DMASOUND = MFP_TIMERA,
   110     MFP_RING,
   111     MFP_MONODETECT
   112 };
   113 
   114 /* Xbtimer() timers */
   115 enum
   116 {
   117     XB_TIMERA = 0,
   118     XB_TIMERB,
   119     XB_TIMERC,
   120     XB_TIMERD
   121 };
   122 
   123 /* Variables */
   124 extern SDL_AudioDevice *SDL_MintAudio_device;
   125 extern Uint8 *SDL_MintAudio_audiobuf[2];        /* Pointers to buffers */
   126 extern unsigned long SDL_MintAudio_audiosize;   /* Length of audio buffer=spec->size */
   127 extern volatile unsigned short SDL_MintAudio_numbuf;    /* Buffer to play */
   128 extern volatile unsigned short SDL_MintAudio_mutex;
   129 extern cookie_stfa_t *SDL_MintAudio_stfa;
   130 extern volatile unsigned long SDL_MintAudio_clocktics;
   131 extern unsigned short SDL_MintAudio_hasfpu;     /* To preserve fpu registers if needed */
   132 
   133 /* MiNT thread variables */
   134 extern SDL_bool SDL_MintAudio_mint_present;
   135 extern SDL_bool SDL_MintAudio_quit_thread;
   136 extern SDL_bool SDL_MintAudio_thread_finished;
   137 extern long SDL_MintAudio_thread_pid;
   138 
   139 /* Functions */
   140 void SDL_MintAudio_Callback(void);
   141 void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
   142                                 Uint32 prediv, int gpio_bits);
   143 int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
   144 void SDL_MintAudio_CheckFpu(void);
   145 
   146 /* MiNT thread functions */
   147 int SDL_MintAudio_Thread(long param);
   148 void SDL_MintAudio_WaitThread(void);
   149 
   150 /* ASM interrupt functions */
   151 void SDL_MintAudio_GsxbInterrupt(void);
   152 void SDL_MintAudio_EmptyGsxbInterrupt(void);
   153 void SDL_MintAudio_XbiosInterruptMeasureClock(void);
   154 void SDL_MintAudio_XbiosInterrupt(void);
   155 void SDL_MintAudio_Dma8Interrupt(void);
   156 void SDL_MintAudio_StfaInterrupt(void);
   157 
   158 #endif /* _SDL_mintaudio_h */
   159 /* vi: set ts=4 sw=4 expandtab: */