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