static int snd_aicapcm_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; struct aica_channel *channel; struct snd_card_aica *dreamcastcard; if (!enable) return -ENOENT; dreamcastcard = substream->pcm->private_data; channel = kmalloc(sizeof(struct aica_channel), GFP_KERNEL); if (!channel) return -ENOMEM; /* set defaults for channel */ channel->sfmt = SM_8BIT; channel->cmd = AICA_CMD_START; channel->vol = dreamcastcard->master_volume; channel->pan = 0x80; channel->pos = 0; channel->flags = 0; /* default to mono */ dreamcastcard->channel = channel; runtime = substream->runtime; runtime->hw = snd_pcm_aica_playback_hw; spu_enable(); dreamcastcard->clicks = 0; dreamcastcard->current_period = 0; dreamcastcard->dma_check = 0; return 0; }
int snd_init_firmware(const char *filename) { file_t f; size_t sz; uint8 *buff; f = fs_open(filename, O_RDONLY); if(f < 0) { ds_printf("DS_ERROR: Can't open firmware %s\n", filename); return -1; } sz = fs_total(f); ds_printf("DS_PROCESS: Loading firmware %s (%d bytes) into SPU RAM\n", filename, sz); buff = (uint8*)malloc(sz); fs_read(f, buff, sz); fs_close(f); spu_disable(); spu_memset(0, 0, AICA_RAM_START); spu_memload(0, buff, sz); /* Enable the AICA and give it a few ms to start up */ spu_enable(); timer_spin_sleep(10); /* Initialize the RAM allocator */ snd_mem_init(AICA_RAM_START); return 0; }
/* Initialize driver; note that this replaces the AICA program so that if you had anything else going on, it's gone now! */ int snd_init() { int amt; /* Finish loading the stream driver */ if (!initted) { spu_disable(); spu_memset(0, 0, AICA_RAM_START); amt = snd_stream_drv_end - snd_stream_drv; if (amt % 4) amt = (amt + 4) & ~3; printf("snd_init(): loading %d bytes into SPU RAM\n", amt); spu_memload(0, snd_stream_drv, amt); /* Enable the AICA and give it a few ms to start up */ spu_enable(); timer_spin_sleep(10); /* Initialize the RAM allocator */ snd_mem_init(AICA_RAM_START); /* Setup semaphores */ sem_qram = sem_create(1); } initted = 1; return 0; }
/* * Halt the sound processor, clear the memory, * load some default ARM7 code, and then restart ARM7 */ static void spu_reset(void) { unsigned long flags; spu_disable(); spu_memset(0, 0, 0x200000 / 4); /* Put ARM7 in endless loop */ local_irq_save(flags); __raw_writel(0xea000002, SPU_MEMORY_BASE); local_irq_restore(flags); spu_enable(); }
static int load_aica_firmware(void) { int err; const struct firmware *fw_entry; spu_reset(); err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev); if (unlikely(err)) return err; /* write firmware into memory */ spu_disable(); spu_memload(0, fw_entry->data, fw_entry->size); spu_enable(); release_firmware(fw_entry); return err; }
void copy_s3m(char *song, int len) { spu_disable(); spu_memload(0x10000, song, len); spu_memload(0, s3mplay, sizeof(s3mplay)); /* Switch channels to mono if uncommented */ /* snd_dbg[1] = 1; */ printf("Load OK, starting ARM\n"); spu_enable(); while(*snd_dbg != 3) ; while(*snd_dbg == 3) ; }