Can use both clocks of FDI interface on Falcon, plus digital output
authorPatrice Mandin
Sun, 07 Aug 2005 12:17:28 +0000
changeset 1107856f76a099c7
parent 1106 524fd51f5d2c
child 1108 5fe7c6b8adc3
Can use both clocks of FDI interface on Falcon, plus digital output
src/audio/mint/SDL_mintaudio.c
src/audio/mint/SDL_mintaudio.h
src/audio/mint/SDL_mintaudio_dma8.c
src/audio/mint/SDL_mintaudio_gsxb.c
src/audio/mint/SDL_mintaudio_mcsn.c
src/audio/mint/SDL_mintaudio_stfa.c
src/audio/mint/SDL_mintaudio_xbios.c
     1.1 --- a/src/audio/mint/SDL_mintaudio.c	Fri Jul 29 10:59:49 2005 +0000
     1.2 +++ b/src/audio/mint/SDL_mintaudio.c	Sun Aug 07 12:17:28 2005 +0000
     1.3 @@ -76,7 +76,8 @@
     1.4  }
     1.5  
     1.6  /* Add a new frequency/clock/predivisor to the current list */
     1.7 -void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv)
     1.8 +void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
     1.9 +	Uint32 prediv, int gpio_bits)
    1.10  {
    1.11  	int i, p;
    1.12  
    1.13 @@ -94,9 +95,7 @@
    1.14  	/* Put all following ones farer */
    1.15  	if (MINTAUDIO_freqcount>0) {
    1.16  		for (i=MINTAUDIO_freqcount; i>p; i--) {
    1.17 -			MINTAUDIO_frequencies[i].frequency = MINTAUDIO_frequencies[i-1].frequency;
    1.18 -			MINTAUDIO_frequencies[i].masterclock = MINTAUDIO_frequencies[i-1].masterclock;
    1.19 -			MINTAUDIO_frequencies[i].predivisor = MINTAUDIO_frequencies[i-1].predivisor;
    1.20 +			memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t));
    1.21  		}
    1.22  	}
    1.23  
    1.24 @@ -104,6 +103,7 @@
    1.25  	MINTAUDIO_frequencies[p].frequency = frequency;
    1.26  	MINTAUDIO_frequencies[p].masterclock = clock;
    1.27  	MINTAUDIO_frequencies[p].predivisor = prediv;
    1.28 +	MINTAUDIO_frequencies[p].gpio_bits = gpio_bits;
    1.29  
    1.30  	MINTAUDIO_freqcount++;
    1.31  }
     2.1 --- a/src/audio/mint/SDL_mintaudio.h	Fri Jul 29 10:59:49 2005 +0000
     2.2 +++ b/src/audio/mint/SDL_mintaudio.h	Sun Aug 07 12:17:28 2005 +0000
     2.3 @@ -42,6 +42,7 @@
     2.4  	Uint32	frequency;
     2.5  	Uint32	masterclock;
     2.6  	Uint32	predivisor;
     2.7 +	int	gpio_bits;	/* in case of external clock */
     2.8  } mint_frequency_t;
     2.9  
    2.10  struct SDL_PrivateAudioData {
    2.11 @@ -124,7 +125,8 @@
    2.12  
    2.13  /* Functions */
    2.14  void SDL_MintAudio_Callback(void);
    2.15 -void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv);
    2.16 +void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
    2.17 +	Uint32 prediv, int gpio_bits);
    2.18  int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
    2.19  
    2.20  /* ASM interrupt functions */
     3.1 --- a/src/audio/mint/SDL_mintaudio_dma8.c	Fri Jul 29 10:59:49 2005 +0000
     3.2 +++ b/src/audio/mint/SDL_mintaudio_dma8.c	Sun Aug 07 12:17:28 2005 +0000
     3.3 @@ -250,7 +250,8 @@
     3.4  	
     3.5  	MINTAUDIO_freqcount=0;
     3.6  	for (i=sfreq;i<4;i++) {
     3.7 -		SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)), masterclock, i-sfreq);
     3.8 +		SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)),
     3.9 +			masterclock, i-sfreq, -1);
    3.10  	}
    3.11  
    3.12  #if 1
     4.1 --- a/src/audio/mint/SDL_mintaudio_gsxb.c	Fri Jul 29 10:59:49 2005 +0000
     4.2 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c	Sun Aug 07 12:17:28 2005 +0000
     4.3 @@ -276,7 +276,9 @@
     4.4  	/* Calculate and select the closest frequency */
     4.5  	MINTAUDIO_freqcount=0;
     4.6  	for (i=1;i<4;i++) {
     4.7 -		SDL_MintAudio_AddFrequency(this, MASTERCLOCK_44K/(MASTERPREDIV_MILAN*(1<<i)), MASTERCLOCK_44K, (1<<i)-1);
     4.8 +		SDL_MintAudio_AddFrequency(this,
     4.9 +			MASTERCLOCK_44K/(MASTERPREDIV_MILAN*(1<<i)), MASTERCLOCK_44K,
    4.10 +			(1<<i)-1, -1);
    4.11  	}
    4.12  
    4.13  #if 1
     5.1 --- a/src/audio/mint/SDL_mintaudio_mcsn.c	Fri Jul 29 10:59:49 2005 +0000
     5.2 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Sun Aug 07 12:17:28 2005 +0000
     5.3 @@ -233,7 +233,7 @@
     5.4  		case MCSN_ST:
     5.5  			spec->channels=1;
     5.6  			spec->format=8; /* FIXME: is it signed or unsigned ? */
     5.7 -			SDL_MintAudio_AddFrequency(this, 12500, 0, 0);
     5.8 +			SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
     5.9  			break;
    5.10  		case MCSN_TT:	/* Also STE, Mega STE */
    5.11  			spec->format=AUDIO_S8;
    5.12 @@ -244,7 +244,8 @@
    5.13  				masterprediv=MASTERPREDIV_TT;
    5.14  			}
    5.15  			for (i=0; i<4; i++) {
    5.16 -				SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)), masterclock, 3-i);
    5.17 +				SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)),
    5.18 +					masterclock, 3-i, -1);
    5.19  			}
    5.20  			break;
    5.21  		case MCSN_FALCON:	/* Also Mac */
    5.22 @@ -253,11 +254,13 @@
    5.23  				if ((i==6) || (i==8) || (i==10)) {
    5.24  					continue;
    5.25  				}
    5.26 -				SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), CLK25M, i+1);
    5.27 +				SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)),
    5.28 +					CLK25M, i+1, -1);
    5.29  			}
    5.30  			if (cookie_mcsn->res1 != 0) {
    5.31  				for (i=1; i<4; i++) {
    5.32 -					SDL_MintAudio_AddFrequency(this, (cookie_mcsn->res1)/(MASTERPREDIV_FALCON*(1<<i)), CLKEXT, (1<<i)-1);
    5.33 +					SDL_MintAudio_AddFrequency(this, (cookie_mcsn->res1)/(MASTERPREDIV_FALCON*(1<<i)),
    5.34 +						CLKEXT, (1<<i)-1, -1);
    5.35  				}
    5.36  			}
    5.37  			spec->format |= 0x8000;	/* Audio is always signed */
     6.1 --- a/src/audio/mint/SDL_mintaudio_stfa.c	Fri Jul 29 10:59:49 2005 +0000
     6.2 +++ b/src/audio/mint/SDL_mintaudio_stfa.c	Sun Aug 07 12:17:28 2005 +0000
     6.3 @@ -213,7 +213,7 @@
     6.4  	/* Check formats available */
     6.5  	MINTAUDIO_freqcount=0;
     6.6  	for (i=0;i<16;i++) {
     6.7 -		SDL_MintAudio_AddFrequency(this, freqs[i], 0, i);
     6.8 +		SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1);
     6.9  	}
    6.10  
    6.11  #if 1
     7.1 --- a/src/audio/mint/SDL_mintaudio_xbios.c	Fri Jul 29 10:59:49 2005 +0000
     7.2 +++ b/src/audio/mint/SDL_mintaudio_xbios.c	Sun Aug 07 12:17:28 2005 +0000
     7.3 @@ -263,32 +263,29 @@
     7.4  	Super(oldstack);
     7.5  }
     7.6  
     7.7 -static Uint32 Mint_CheckExternalClock(void)
     7.8 +static void Mint_CheckExternalClock(_THIS)
     7.9  {
    7.10  #define SIZE_BUF_CLOCK_MEASURE (44100/10)
    7.11  
    7.12  	unsigned long cookie_snd;
    7.13 -	Uint32 masterclock;
    7.14  	char *buffer;
    7.15 -	int i;
    7.16 +	int i, j;
    7.17  
    7.18  	/* DSP present with its GPIO port ? */
    7.19  	if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
    7.20 -		return 0;
    7.21 +		return;
    7.22  	}
    7.23  	if ((cookie_snd & SND_DSP)==0) {
    7.24 -		return 0;
    7.25 +		return;
    7.26  	}
    7.27  
    7.28  	buffer = Atari_SysMalloc(SIZE_BUF_CLOCK_MEASURE, MX_STRAM);
    7.29  	if (buffer==NULL) {
    7.30  		DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n"));
    7.31 -		return 0;
    7.32 +		return;
    7.33  	}
    7.34  	memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE);
    7.35  
    7.36 -	masterclock=0;
    7.37 -
    7.38  	Buffoper(0);
    7.39  	Settracks(0,0);
    7.40  	Setmontracks(0);
    7.41 @@ -313,13 +310,13 @@
    7.42  				khz = ((SIZE_BUF_CLOCK_MEASURE/SDL_MintAudio_clocktics) +1) & 0xFFFFFFFE;
    7.43  				DEBUG_PRINT((DEBUG_NAME "measure %d: freq=%lu KHz\n", i+1, khz));
    7.44  
    7.45 -				if (i==0) {
    7.46 -					if(khz==44) {
    7.47 -						masterclock = MASTERCLOCK_44K;
    7.48 +				if(khz==44) {
    7.49 +					for (j=1; j<4; j++) {
    7.50 +						SDL_MintAudio_AddFrequency(this, MASTERCLOCK_44K/(MASTERPREDIV_FALCON*(1<<j)), MASTERCLOCK_44K, (1<<j)-1, 2+i);
    7.51  					}
    7.52 -				} else {
    7.53 -					if(khz==48) {
    7.54 -						masterclock = MASTERCLOCK_48K;
    7.55 +				} else if (khz==48) {
    7.56 +					for (j=1; j<4; j++) {
    7.57 +						SDL_MintAudio_AddFrequency(this, MASTERCLOCK_48K/(MASTERPREDIV_FALCON*(1<<j)), MASTERCLOCK_48K, (1<<j)-1, 2+i);
    7.58  					}
    7.59  				}
    7.60  			} else {
    7.61 @@ -331,12 +328,9 @@
    7.62  
    7.63  		Buffoper(0);             /* stop */
    7.64  		Jdisint(MFP_TIMERA);     /* Uninstall interrupt */
    7.65 -		if (masterclock == 0)
    7.66 -			break;
    7.67  	}
    7.68  
    7.69  	Mfree(buffer);
    7.70 -	return masterclock;
    7.71  }
    7.72  
    7.73  static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
    7.74 @@ -356,22 +350,18 @@
    7.75  		spec->channels=2;	/* 16 bits always stereo */
    7.76  	}
    7.77  
    7.78 -	extclock=Mint_CheckExternalClock();
    7.79 +	MINTAUDIO_freqcount=0;
    7.80 +
    7.81 +	/* Add external clocks if present */
    7.82 +	Mint_CheckExternalClock(this);
    7.83  
    7.84  	/* Standard clocks */
    7.85 -	MINTAUDIO_freqcount=0;
    7.86  	for (i=1;i<12;i++) {
    7.87  		/* Remove unusable Falcon codec predivisors */
    7.88  		if ((i==6) || (i==8) || (i==10)) {
    7.89  			continue;
    7.90  		}
    7.91 -		SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), MASTERCLOCK_FALCON1, i);
    7.92 -	}
    7.93 -
    7.94 -	if (extclock>0) {
    7.95 -		for (i=1; i<4; i++) {
    7.96 -			SDL_MintAudio_AddFrequency(this, extclock/(MASTERPREDIV_FALCON*(1<<i)), extclock, (1<<i)-1);
    7.97 -		}
    7.98 +		SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), MASTERCLOCK_FALCON1, i, -1);
    7.99  	}
   7.100  
   7.101  #if 1
   7.102 @@ -424,14 +414,10 @@
   7.103  
   7.104  	dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock;
   7.105  	prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
   7.106 -	if (dmaclock != MASTERCLOCK_FALCON1) {
   7.107 +	if (MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits != -1) {
   7.108  		Gpio(GPIO_SET,7);		/* DSP port gpio outputs */
   7.109 -		if (dmaclock == MASTERCLOCK_44K) {
   7.110 -			Gpio(GPIO_WRITE,2);	/* 22.5792 MHz for 44.1KHz */
   7.111 -		} else {
   7.112 -			Gpio(GPIO_WRITE,3);	/* 24.576 MHz for 48KHz */
   7.113 -		}
   7.114 -		Devconnect2(DMAPLAY, DAC, CLKEXT, prediv);
   7.115 +		Gpio(GPIO_WRITE, MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits);
   7.116 +		Devconnect2(DMAPLAY, DAC|EXTOUT, CLKEXT, prediv);
   7.117  	} else {
   7.118  		Devconnect2(DMAPLAY, DAC, CLK25M, prediv);
   7.119  	}