Esempio n. 1
0
void exit_sound_system()
{
	WORD ltatten, rtatten, ltgain, rtgain;

	/* Save old settings */
	ltatten = soundcmd(LTATTEN, -1);
	rtatten = soundcmd(RTATTEN, -1);
	ltgain = soundcmd(LTGAIN, -1);
	rtgain = soundcmd(RTGAIN, -1);
	/* Reset sound system */
	sndstatus(1);
	/* Restore old settings */
	soundcmd(LTATTEN, ltatten);
	soundcmd(RTATTEN, rtatten);
	soundcmd(LTGAIN, ltgain);
	soundcmd(RTGAIN, rtgain);

	/* Set some necessary parameters */
	settracks(0,0);
	setmontracks(0);
	setmode(STEREO16);
	soundcmd(ADDERIN, 0x2);
	soundcmd(ADCINPUT, 0x0);
	devconnect(ADC, DAC, CLK25M, CLK50K, 1);

	/* Unlock Sound System */
	unlocksnd();
}
Esempio n. 2
0
void init_sound_system()
{
	char lod_buf[30000];
	WORD ltatten, rtatten, ltgain, rtgain;

	/* Lock Sound System */
	locksnd();

	/* Save old settings */
	ltatten = soundcmd(LTATTEN, -1);
	rtatten = soundcmd(RTATTEN, -1);
	ltgain = soundcmd(LTGAIN, -1);
	rtgain = soundcmd(RTGAIN, -1);
	/* Reset sound system */
	sndstatus(1);
	/* Restore old settings */
	soundcmd(LTATTEN, ltatten);
	soundcmd(RTATTEN, rtatten);
	soundcmd(LTGAIN, ltgain);
	soundcmd(RTGAIN, rtgain);

	/* Set some necessary parameters */
	settracks(0,0);
	setmontracks(0);
	setmode(STEREO16);
	setbuffer(0,sound,sound+sizeof(sound));

	soundcmd(ADDERIN, 0x2);
	soundcmd(ADCINPUT, 0x0);

	/* DSP side */
	dsptristate(ENABLE, ENABLE);
	dsp_abil = Dsp_RequestUniqueAbility();
/*	Dsp_LoadProg(DSP_LOD, dsp_abil, lod_buf);	*/
	Dsp_ExecProg(dsp_bin, sizeof(dsp_bin)/3, dsp_abil);

	/* Connect DMA playback with DSP and then to DAC */
	switch (options.function) {
		case replay:
			devconnect(DMAPLAY, DSPRECV, CLK25M, options.prescale, NO_SHAKE);
			devconnect(DSPXMIT, DAC, CLK25M, options.prescale, NO_SHAKE);
			break;
		case record:
			break;
		case thru:
			devconnect(ADC, DSPRECV, CLK25M, options.prescale, NO_SHAKE);
			devconnect(DSPXMIT, DAC, CLK25M, options.prescale, NO_SHAKE);
			break;
	}

	Dsp_BlkUnpacked(&options.dsp.mono, 1L, 0L, 0L);
	Dsp_BlkUnpacked(&options.dsp.karaoke, 1L, 0L, 0L);
	Dsp_BlkUnpacked(&options.dsp.flange, 1L, 0L, 0L);
}
Esempio n. 3
0
static
int queue(struct buffer *buffer)
{
  init_header(&buffer->header, buffer->pcm_data, buffer->pcm_nsamples,
	      config_channels, config_speed, config_precision);

  if (soundcmd(QUEUE, bufferCmd,   0, (long) &buffer->header) == -1 ||
      soundcmd(QUEUE, callBackCmd, 0, (long) buffer) == -1)
    return -1;

  return 0;
}
Esempio n. 4
0
static void falcon_dmasound_init(void)
{
    /*
     * connect DMA playback to DAC (headphone/speaker)
     * set clock = internal 25.175MHz
     * set TT/STe compatibility mode
     * disable handshaking
     */
    devconnect(0,8,0,0,1);

    setsndmode(0);          /* set 8-bit stereo */
    soundcmd(2,0x0080);     /* set left gain = 8 */
    soundcmd(3,0x0080);     /* set right gain = 8 */
    soundcmd(4,0x0003);     /* set ADDER input to ADC & connection matrix */
    soundcmd(5,0x0003);     /* set L & R channel ADC source to PSG */
    soundcmd(6,0x0003);     /* set TT-compatible prescale to /160 = 50MHz */
}
Esempio n. 5
0
static
int set_pause(int flag)
{
  static int paused;

  if (flag != paused) {
    paused = 0;

    if (flag) {
      if (soundcmd(IMMEDIATE, pauseCmd, 0, 0) == -1 ||
	  soundcmd(IMMEDIATE, quietCmd, 0, 0) == -1)
	return -1;
    }
    else if (soundcmd(IMMEDIATE, resumeCmd, 0, 0) == -1)
      return -1;

    paused = flag;
  }

  return 0;
}
Esempio n. 6
0
static
int flush(void)
{
  int i, result = 0;

  if (soundcmd(IMMEDIATE, flushCmd, 0, 0) == -1)
    result = -1;

  for (i = 0; i < NBUFFERS; ++i)
    MPSignalSemaphore(output[i].semaphore);

  output[bindex].pcm_nsamples = 0;

  return result;
}
Esempio n. 7
0
static
int config(struct audio_config *config)
{
  unsigned int bitdepth;

  if (set_pause(0) == -1)
    return -1;

  bitdepth = config->precision & ~7;
  if (bitdepth == 0 || bitdepth > 16)
    bitdepth = 16;

  if (drain() == -1 ||
      soundcmd(QUEUE, reInitCmd, 0, initNoDrop |
	       (config->channels == 1 ? initMono : initStereo)) == -1)
    return -1;

  switch (config->precision = bitdepth) {
  case 8:
    audio_pcm = audio_pcm_u8;
    break;

  case 16:
# if defined(WORDS_BIGENDIAN)
    audio_pcm = audio_pcm_s16be;
# else
    audio_pcm = audio_pcm_s16le;
# endif
    break;
  }

  config_channels  = config->channels;
  config_speed     = config->speed;
  config_precision = config->precision;

  return 0;
}
Esempio n. 8
0
void mute(int mode)
{
	static int ltatten, rtatten, ltgain, rtgain;

	if (mode) { /* mode==MUTE */
		/* Save old settings */
		ltatten = (int) soundcmd(LTATTEN, -1);
		rtatten = (int) soundcmd(RTATTEN, -1);
		ltgain = (int) soundcmd(LTGAIN, -1);
		rtgain = (int) soundcmd(RTGAIN, -1);
		soundcmd(LTATTEN, 0x00f0);
		soundcmd(RTATTEN, 0x00f0);
		soundcmd(RTGAIN, 0x0000);
		soundcmd(LTGAIN, 0x0000);
	} else { /* mode==MUTE_RESTORE */
		/* Restore old settings */
		soundcmd(LTATTEN, ltatten);
		soundcmd(RTATTEN, rtatten);
		soundcmd(LTGAIN, ltgain);
		soundcmd(RTGAIN, rtgain);
	}
}