// // MAIN // //int main (void) // Console Mode int WinMainCRTStartup (void) // Window Mode { // Init OpenGL Window //if (!TDS_Init (RES_X, RES_Y, "Cube!", TDS_FULLSCREEN)) if (!TDS_Init (RES_X, RES_Y, "Cube!", TDS_WINDOWED)) { MessageBox (0, TDS_GetLastError ( ), "Error", MB_OK); return 1; } // Init FX if (!fx_init (RES_X, RES_Y)) { MessageBox (0, "FX Init Error", "Error", MB_OK); return 1; } // Init Timer TDS_InitTimer (0, 60); // Main loop while (1) { fx_do (TDS_GetTimer (0)); TDS_Update ( ); } TDS_Close ( ); return 0; }
int main(int argc, char *argv[]) { if (!fx_init()) { fprintf(stderr, "init the libfetion fail \n"); exit(0); } init_db(); #ifdef WIN32 #else //compatible old app's config file moveOldConfigFile(); #endif QApplication app(argc, argv); QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); #ifdef HAVE_LOG4QT_DEBUG_ENABLED /*FIXME: real log4qt configuration path */ Log4Qt::PropertyConfigurator::configure( app.applicationDirPath() + "/log4qt.properties"); #endif QTranslator translator_fetion; translator_fetion.load("fetion_utf8_CN", defaultResPath()); QTranslator translator_qt; translator_qt.load("qt_zh_CN", defaultResPath()); app.installTranslator(&translator_fetion); app.installTranslator(&translator_qt); app.setFont(Settings::instance().getCurrentFont()); setSkins(Settings::instance().SkinPath(), Settings::instance().SkinName()); FxMain *mainWin = new FxMain(); app.setQuitOnLastWindowClosed(false); int reslut = app.exec(); if (mainWin) { delete mainWin; } destoy_db(); //destroy the libfetion fx_terminate(); return reslut; }
static int bitcui_init(void) { int res; bitcui_set_status("ui starting.."); btcui->poll = poll_create(); res = bitcui_notify_init(&btcui->eventFd, &btcui->notifyFd); ASSERT(res == 0); fx_init(); ncui_init(); bitcui_log_init(); poll_callback_device(btcui->poll, STDIN_FILENO, 1, 0, 1, ncui_input_cb, NULL); poll_callback_time(btcui->poll, 1 * 1000 * 1000 / 2, TRUE, ncui_time_cb, NULL); return 0; }
int main(int argc, char **argv) { int c; int err; uint8_t buf[MS_BUF_SIZE]; u32_t pstart, pend, cstart, cend, dstart, dend; int do_dblk_loc, do_panic0; while ((c = getopt_long(argc,argv,"c:d:p:DhvVw", longopts, NULL)) != EOF) switch (c) { case 'c': fprintf(stderr, "-c not implemented yet, defaults to 8192\n"); break; case 'd': fprintf(stderr, "-d not implemented yet, defaults to 0 (rest of partition\n"); break; case 'D': debug++; break; case 'h': usage(argv[0]); break; case 'p': fprintf(stderr, "-c not implemented yet, defaults to 128k\n"); break; case 'v': verbose++; break; case 'V': fprintf(stderr, VERSION); exit(0); break; case 'w': do_write++; break; default: usage(argv[0]); break; } if (optind != argc - 1) usage(argv[0]); if (verbose) fprintf(stderr, VERSION); fx_hard_init(); err = ms_init(argv[optind]); if (err == MS_READONLY) { fprintf(stderr, "mkdblk: %s is read only\n", argv[optind]); err = MS_OK; do_write = 0; } if (err) { fprintf(stderr, "ms_init: %s (0x%x)\n", ms_dsp_err(err), err); exit(1); } err = fx_set_buf(buf); if (err) { fprintf(stderr, "fx_set_buf: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } err = fx_init(); if (err) { fprintf(stderr, "fx_init: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } if (!do_write) { display_info(); exit(0); } do_dblk_loc = 1; do_panic0 = !msc.panic0_blk; err = fx_create_contig("PANIC001", " ", panic_size, &pstart, &pend); if (err) { fprintf(stderr, "fx_create_contig: PANIC001: %s (0x%x)\n", fx_dsp_err(err), err); pstart = msc.panic_start; pend = msc.panic_end; do_dblk_loc = 0; } err = fx_create_contig("CNFG0001", " ", config_size, &cstart, &cend); if (err) { fprintf(stderr, "fx_create_contig: CNFG0001: %s (0x%x)\n", fx_dsp_err(err), err); cstart = msc.config_start; cend = msc.config_end; do_dblk_loc = 0; } err = fx_create_contig("DBLK0001", " ", dblk_size, &dstart, &dend); if (err) { fprintf(stderr, "fx_create_contig: DBLK0001: %s (0x%x)\n", fx_dsp_err(err), err); dstart = msc.dblk_start; dend = msc.dblk_end; do_dblk_loc = 0; } if (do_dblk_loc) { fprintf(stderr, "*** writing dblk locator\n"); err = fx_write_locator(pstart, pend, cstart, cend, dstart, dend); if (err) { fprintf(stderr, "fx_write_locator: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } do_panic0 = 1; /* always write if we wrote the dblk locator */ } if (do_panic0) { fprintf(stderr, "*** writing PANIC0 blk\n"); err = fx_write_panic0(pstart, pend); if (err) { fprintf(stderr, "fx_write_panic: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } } display_info(); if (!do_dblk_loc && !do_panic0) fprintf(stderr, "*** no changes written\n"); err = fx_set_buf(NULL); if (err) { fprintf(stderr, "fx_set_buf: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } return(0); }
static int hw_init(struct emu10k1_card *card) { int nCh; u32 pagecount; /* tmp */ int ret; /* Disable audio and lock cache */ emu10k1_writefn0(card, HCFG, HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE); /* Reset recording buffers */ sblive_writeptr_tag(card, 0, MICBS, ADCBS_BUFSIZE_NONE, MICBA, 0, FXBS, ADCBS_BUFSIZE_NONE, FXBA, 0, ADCBS, ADCBS_BUFSIZE_NONE, ADCBA, 0, TAGLIST_END); /* Disable channel interrupt */ emu10k1_writefn0(card, INTE, 0); sblive_writeptr_tag(card, 0, CLIEL, 0, CLIEH, 0, SOLEL, 0, SOLEH, 0, TAGLIST_END); /* Init envelope engine */ for (nCh = 0; nCh < NUM_G; nCh++) { sblive_writeptr_tag(card, nCh, DCYSUSV, 0, IP, 0, VTFT, 0xffff, CVCF, 0xffff, PTRX, 0, //CPF, 0, CCR, 0, PSST, 0, DSL, 0x10, CCCA, 0, Z1, 0, Z2, 0, FXRT, 0xd01c0000, ATKHLDM, 0, DCYSUSM, 0, IFATN, 0xffff, PEFE, 0, FMMOD, 0, TREMFRQ, 24, /* 1 Hz */ FM2FRQ2, 24, /* 1 Hz */ TEMPENV, 0, /*** These are last so OFF prevents writing ***/ LFOVAL2, 0, LFOVAL1, 0, ATKHLDV, 0, ENVVOL, 0, ENVVAL, 0, TAGLIST_END); sblive_writeptr(card, CPF, nCh, 0); } /* ** Init to 0x02109204 : ** Clock accuracy = 0 (1000ppm) ** Sample Rate = 2 (48kHz) ** Audio Channel = 1 (Left of 2) ** Source Number = 0 (Unspecified) ** Generation Status = 1 (Original for Cat Code 12) ** Cat Code = 12 (Digital Signal Mixer) ** Mode = 0 (Mode 0) ** Emphasis = 0 (None) ** CP = 1 (Copyright unasserted) ** AN = 0 (Digital audio) ** P = 0 (Consumer) */ sblive_writeptr_tag(card, 0, /* SPDIF0 */ SPCS0, (SPCS_CLKACCY_1000PPM | 0x002000000 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT), /* SPDIF1 */ SPCS1, (SPCS_CLKACCY_1000PPM | 0x002000000 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT), /* SPDIF2 & SPDIF3 */ SPCS2, (SPCS_CLKACCY_1000PPM | 0x002000000 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT), TAGLIST_END); ret = fx_init(card); /* initialize effects engine */ if (ret < 0) return ret; card->tankmem.size = 0; card->virtualpagetable.size = MAXPAGES * sizeof(u32); card->virtualpagetable.addr = pci_alloc_consistent(card->pci_dev, card->virtualpagetable.size, &card->virtualpagetable.dma_handle); if (card->virtualpagetable.addr == NULL) { ERROR(); ret = -ENOMEM; goto err0; } card->silentpage.size = EMUPAGESIZE; card->silentpage.addr = pci_alloc_consistent(card->pci_dev, card->silentpage.size, &card->silentpage.dma_handle); if (card->silentpage.addr == NULL) { ERROR(); ret = -ENOMEM; goto err1; } for (pagecount = 0; pagecount < MAXPAGES; pagecount++) ((u32 *) card->virtualpagetable.addr)[pagecount] = cpu_to_le32((card->silentpage.dma_handle * 2) | pagecount); /* Init page table & tank memory base register */ sblive_writeptr_tag(card, 0, PTB, card->virtualpagetable.dma_handle, TCB, 0, TCBS, 0, TAGLIST_END); for (nCh = 0; nCh < NUM_G; nCh++) { sblive_writeptr_tag(card, nCh, MAPA, MAP_PTI_MASK | (card->silentpage.dma_handle * 2), MAPB, MAP_PTI_MASK | (card->silentpage.dma_handle * 2), TAGLIST_END); } /* Hokay, now enable the AUD bit */ /* Enable Audio = 1 */ /* Mute Disable Audio = 0 */ /* Lock Tank Memory = 1 */ /* Lock Sound Memory = 0 */ /* Auto Mute = 1 */ if (card->model == 0x20 || card->model == 0xc400 || (card->model == 0x21 && card->chiprev < 6)) emu10k1_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE); else emu10k1_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE); /* Enable Vol_Ctrl irqs */ emu10k1_irq_enable(card, INTE_VOLINCRENABLE | INTE_VOLDECRENABLE | INTE_MUTEENABLE | INTE_FXDSPENABLE); /* FIXME: TOSLink detection */ card->has_toslink = 0; #ifdef lcs /* Initialize digital passthrough variables */ card->pt.pos_gpr = card->pt.intr_gpr = card->pt.enable_gpr = -1; card->pt.selected = 0; card->pt.state = PT_STATE_INACTIVE; card->pt.spcs_to_use = 0x01; card->pt.patch_name = "AC3pass"; card->pt.intr_gpr_name = "count"; card->pt.enable_gpr_name = "enable"; card->pt.pos_gpr_name = "ptr"; spin_lock_init(&card->pt.lock); init_waitqueue_head(&card->pt.wait); #endif /* tmp = sblive_readfn0(card, HCFG); if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) { sblive_writefn0(card, HCFG, tmp | 0x800); udelay(512); if (tmp != (sblive_readfn0(card, HCFG) & ~0x800)) { card->has_toslink = 1; sblive_writefn0(card, HCFG, tmp); } } */ return 0; err1: pci_free_consistent(card->pci_dev, card->virtualpagetable.size, card->virtualpagetable.addr, card->virtualpagetable.dma_handle); err0: fx_cleanup(&card->mgr); return ret; }
/* Main function * * - Initialise device and any global variables * - Enable Interrupts * - Start endless loop */ void main(void) { unsigned long ulRetcode; // Initialise the device clock to 80MHz ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN ); // Enable SysTick for FatFS at 10ms intervals ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 100); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Configure and enable uDMA // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlDelay(10); ROM_uDMAControlBaseSet(&sDMAControlTable[0]); ROM_uDMAEnable(); // // Enable the USB controller. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); // // Set the USB pins to be controlled by the USB controller. ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5); // Initialize the idle timeout and reset all flags. // g_ulIdleTimeout = 0; g_ulFlags = 0; // // Initialize the state to idle. // g_eMSCState = MSC_DEV_DISCONNECTED; // // Set the USB stack mode to Device mode with VBUS monitoring. // USBStackModeSet(0, USB_MODE_DEVICE, 0); // // Pass our device information to the USB library and place the device // on the bus. // USBDMSCInit(0, (tUSBDMSCDevice *)&g_sMSCDevice); // // Determine whether or not an SDCard is installed. If not, print a // warning and have the user install one and restart. // ulRetcode = disk_initialize(0); // Enable Global interrupts ROM_IntMasterEnable(); // Enable floating point arithmetic unit, but disable stacking ROM_FPUEnable(); ROM_FPUStackingDisable(); // Initialise GPIO - All ports enabled ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Unlock NMI pins for GPIO usage (PD7 + PF0) HWREG(GPIO_PORTD_BASE + 0x520) = 0x4C4F434B; HWREG(GPIO_PORTF_BASE + 0x520) = 0x4C4F434B; HWREG(GPIO_PORTD_BASE + 0x524) = 0x000000FF; HWREG(GPIO_PORTF_BASE + 0x524) = 0x000000FF; HWREG(GPIO_PORTD_BASE + 0x520) = 0x00000000; HWREG(GPIO_PORTF_BASE + 0x520) = 0x00000000; // Initialise GPIO Expander (probably not happening) // Initialise Buttons btn_init(); // Initialise FX fx_init(); // Initialise ADC adc_init(); // Initialise DAC dac_init(); // Initialise SD Card and Mass storage sdcard_init(); // Initialise UART for debugging uart_init(); // Initialise Timers timers_init(); for(;;) { // Endless Loop ADCProcessorTrigger(ADC0_BASE, 0); SysCtlDelay(SysCtlClockGet() / 120); // 25ms } }
void OSPC_Play(char *fname,int release,int vol) { u16 *menu_bg; u16 *dst,*src; int i,j,pollcpt; char str[256]; char *emulator[3]={"Unknown","Zsnes","Snes9x"}; uint8 *scr; OSPC_Init(); if (i=OSPC_Load(fname)) { sprintf(str,"Error at SPC loading, code : %d",i); msgBoxLines(str,60); //gp32_pause(); //GpAppExit(); return; } OSPC_id=OSPC_GetID666(spc_data); OSPC_sound_fd = sceAudioChReserve( -1, 1024, 0 ); OSPC_exit=0; OSPC_volume=vol; OSPC_thread = sceKernelCreateThread( "OSPC Thread", (SceKernelThreadEntry)OSPC_PlayThread, 0x8, 256*1024, 0, 0 ); if (OSPC_thread<0) { msgBoxLines("Cannot create OSPC playback thread",60); } else { //init start time scePowerSetClockFrequency(266,266,133); sceKernelLibcGettimeofday( &OSPC_start_time, 0 ); sceKernelStartThread( OSPC_thread, 0, 0 ); if (release) return; //init bg menu_bg=(u16*)malloc_64(480*272*2); dst=menu_bg; show_background(bg_img_mul,(os9x_lowbat?0x600000:0)); for (i=0;i<272;i++) { src = (u16*)pgGetVramAddr(0,i); memcpy(dst,src,480*2); dst+=480; } //init fx fx_init(); for (;;) { //show bg OSPC_show_bg(menu_bg); //show bg fx fx_main(pgGetVramAddr(0,0)); //batt infos show_batteryinfo(); //music info //draw frame pgDrawFrame(14,14,20+230+5+1,75+1,12|(12<<5)|(12<<10)); pgDrawFrame(13,13,20+230+5+2,75+2,30|(30<<5)|(30<<10)); pgDrawFrame(12,12,20+230+5+3,75+3,12|(12<<5)|(12<<10)); pgFillBoxHalfer(15,15,20+230+5,75); // if (strlen(OSPC_id->gametitle)) sprintf(str,"Game : %s",OSPC_id->gametitle); else sprintf(str,"Game : unknown"); mh_print(20,20,(char*)str,30|(30<<5)|(30<<10)); if (strlen(OSPC_id->songname)) sprintf(str,"Song : %s",OSPC_id->songname); else sprintf(str,"Song : unknown"); mh_print(20,30,(char*)str,30|(30<<5)|(30<<10)); if (strlen(OSPC_id->dumper)) sprintf(str,"Dumper : %s",OSPC_id->dumper); else sprintf(str,"Dumper : unknown"); mh_print(20,40,(char*)str,30|(30<<5)|(30<<10)); if (strlen(OSPC_id->comments)) sprintf(str,"Comments : %s",OSPC_id->comments); else sprintf(str,"Comments : unknown"); mh_print(20,50,(char*)str,30|(30<<5)|(30<<10)); if (strlen(OSPC_id->author)) sprintf(str,"Author : %s",OSPC_id->author); else sprintf(str,"Author : unknown"); mh_print(20,60,(char*)str,30|(30<<5)|(30<<10)); //time infos //draw frame //draw frame pgDrawFrame(14,94,20+65+5+1,116,8|(8<<5)|(16<<10)); pgDrawFrame(13,93,20+65+5+2,117,28|(28<<5)|(31<<10)); pgDrawFrame(12,92,20+65+5+3,118,8|(8<<5)|(16<<10)); pgFillBoxHalfer(15,95,20+65+5,115); sceKernelLibcGettimeofday( &OSPC_cur_time, 0 ); i=(OSPC_cur_time.tv_sec-OSPC_start_time.tv_sec)+(OSPC_cur_time.tv_usec-OSPC_start_time.tv_usec)/1000000; sprintf(str,"%2d%c%.2d / %2d:%.2d",i/60,((i&1)?':':' '),i%60,OSPC_id->playtime/60,OSPC_id->playtime%60); mh_print(20,100,(char*)str,(20)|(31<<5)|(18<<10)); if (get_pad()) break; pgScreenFlip(); } OSPC_exit=1; sceKernelWaitThreadEnd( OSPC_thread, NULL ); sceKernelDeleteThread( OSPC_thread ); OSPC_thread=-1; free(menu_bg); fx_close(); } sceAudioChRelease( OSPC_sound_fd ); OSPC_Stop(); OSPC_Close(); if (OSPC_id) free(OSPC_id); }
int main(int argc, char **argv) { int c; int err; uint8_t buf[MS_BUF_SIZE]; u32_t image_size; int do_fs_loc, do_panic0; while ((c = getopt_long(argc,argv,"c:d:i:p:DhvVw", longopts, NULL)) != EOF) switch (c) { case 'c': fprintf(stderr, "-c not implemented yet, defaults to 8192\n"); break; case 'd': fprintf(stderr, "-d not implemented yet, defaults to 0 (rest of partition)\n"); break; case 'D': debug++; break; case 'h': usage(argv[0]); break; case 'i': fprintf(stderr, "-i not implemented yet, defaults to 4 slots, 128k each\n"); break; case 'p': fprintf(stderr, "-p not implemented yet, defaults to 128k\n"); break; case 'v': verbose++; break; case 'V': fprintf(stderr, VERSION); exit(0); break; case 'w': do_write++; break; default: usage(argv[0]); break; } if (optind != argc - 1) usage(argv[0]); if (verbose) fprintf(stderr, VERSION); fx_hard_init(); err = ms_init(argv[optind]); if (err == MS_READONLY) { fprintf(stderr, "tagfmtsd: %s is read only\n", argv[optind]); err = MS_OK; do_write = 0; } if (err) { fprintf(stderr, "ms_init: %s (0x%x)\n", ms_dsp_err(err), err); exit(1); } err = fx_set_buf(buf); if (err) { fprintf(stderr, "fx_set_buf: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } err = fx_init(); if (err) { fprintf(stderr, "fx_init: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } if (!do_write) { display_info(); exit(0); } do_fs_loc = 1; do_panic0 = !msc_panic0_blk; err = fx_create_contig("PANIC001", " ", panic_size, &loc.locators[FS_LOC_PANIC].start, &loc.locators[FS_LOC_PANIC].end); if (err) { fprintf(stderr, "fx_create_contig: PANIC001: %s (0x%x)\n", fx_dsp_err(err), err); do_fs_loc = 0; } err = fx_create_contig("CNFG0001", " ", config_size, &loc.locators[FS_LOC_CONFIG].start, &loc.locators[FS_LOC_CONFIG].end); if (err) { fprintf(stderr, "fx_create_contig: CNFG0001: %s (0x%x)\n", fx_dsp_err(err), err); do_fs_loc = 0; } /* * each slot is 128KiB (128 * 1024) bytes + 512, directory sector. */ image_size = img_slots * 128 * 1024 + 512; err = fx_create_contig("IMAGE001", " ", image_size, &loc.locators[FS_LOC_IMAGE].start, &loc.locators[FS_LOC_IMAGE].end); if (err) { fprintf(stderr, "fx_create_contig: IMAGE001: %s (0x%x)\n", fx_dsp_err(err), err); do_fs_loc = 0; } else { } err = fx_create_contig("DBLK0001", " ", dblk_size, &loc.locators[FS_LOC_DBLK].start, &loc.locators[FS_LOC_DBLK].end); if (err) { fprintf(stderr, "fx_create_contig: DBLK0001: %s (0x%x)\n", fx_dsp_err(err), err); do_fs_loc = 0; } if (do_fs_loc) { fprintf(stderr, "*** writing fs locator\n"); err = fx_write_locator(&loc); if (err) { fprintf(stderr, "fx_write_locator: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } do_panic0 = 1; /* always write if we wrote the dblk locator */ } if (do_panic0) { fprintf(stderr, "*** writing PANIC0 blk\n"); err = fx_write_panic0(loc.locators[FS_LOC_PANIC].start, loc.locators[FS_LOC_PANIC].end); if (err) { fprintf(stderr, "fx_write_panic: %s (0x%x)\n", fx_dsp_err(err), err); exit(1); } } display_info(); if (!do_fs_loc && !do_panic0) fprintf(stderr, "*** no changes written\n"); return(0); }
static int __devinit hw_init(struct emu10k1_card *card) { int nCh; #ifdef TANKMEM u32 size = 0; #endif u32 sizeIdx = 0; u32 pagecount, tmp; /* Disable audio and lock cache */ sblive_writefn0(card, HCFG, HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE | HCFG_MUTEBUTTONENABLE); /* Reset recording buffers */ sblive_writeptr(card, MICBS, 0, ADCBS_BUFSIZE_NONE); sblive_writeptr(card, MICBA, 0, 0); sblive_writeptr(card, FXBS, 0, ADCBS_BUFSIZE_NONE); sblive_writeptr(card, FXBA, 0, 0); sblive_writeptr(card, ADCBS, 0, ADCBS_BUFSIZE_NONE); sblive_writeptr(card, ADCBA, 0, 0); /* Disable channel interrupt */ sblive_writefn0(card, INTE, DISABLE); sblive_writeptr(card, CLIEL, 0, 0); sblive_writeptr(card, CLIEH, 0, 0); sblive_writeptr(card, SOLEL, 0, 0); sblive_writeptr(card, SOLEH, 0, 0); /* Init envelope engine */ for (nCh = 0; nCh < NUM_G; nCh++) { sblive_writeptr(card, DCYSUSV, nCh, ENV_OFF); sblive_writeptr(card, IP, nCh, 0); sblive_writeptr(card, VTFT, nCh, 0xffff); sblive_writeptr(card, CVCF, nCh, 0xffff); sblive_writeptr(card, PTRX, nCh, 0); sblive_writeptr(card, CPF, nCh, 0); sblive_writeptr(card, CCR, nCh, 0); sblive_writeptr(card, PSST, nCh, 0); sblive_writeptr(card, DSL, nCh, 0x10); sblive_writeptr(card, CCCA, nCh, 0); sblive_writeptr(card, Z1, nCh, 0); sblive_writeptr(card, Z2, nCh, 0); sblive_writeptr(card, FXRT, nCh, 0xd01c0000); sblive_writeptr(card, ATKHLDM, nCh, 0); sblive_writeptr(card, DCYSUSM, nCh, 0); sblive_writeptr(card, IFATN, nCh, 0xffff); sblive_writeptr(card, PEFE, nCh, 0); sblive_writeptr(card, FMMOD, nCh, 0); sblive_writeptr(card, TREMFRQ, nCh, 24); /* 1 Hz */ sblive_writeptr(card, FM2FRQ2, nCh, 24); /* 1 Hz */ sblive_writeptr(card, TEMPENV, nCh, 0); /*** These are last so OFF prevents writing ***/ sblive_writeptr(card, LFOVAL2, nCh, 0); sblive_writeptr(card, LFOVAL1, nCh, 0); sblive_writeptr(card, ATKHLDV, nCh, 0); sblive_writeptr(card, ENVVOL, nCh, 0); sblive_writeptr(card, ENVVAL, nCh, 0); } /* ** Init to 0x02109204 : ** Clock accuracy = 0 (1000ppm) ** Sample Rate = 2 (48kHz) ** Audio Channel = 1 (Left of 2) ** Source Number = 0 (Unspecified) ** Generation Status = 1 (Original for Cat Code 12) ** Cat Code = 12 (Digital Signal Mixer) ** Mode = 0 (Mode 0) ** Emphasis = 0 (None) ** CP = 1 (Copyright unasserted) ** AN = 0 (Digital audio) ** P = 0 (Consumer) */ /* SPDIF0 */ sblive_writeptr(card, SPCS0, 0, SPCS_CLKACCY_1000PPM | 0x002000000 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); /* SPDIF1 */ sblive_writeptr(card, SPCS1, 0, SPCS_CLKACCY_1000PPM | 0x002000000 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); /* SPDIF2 & SPDIF3 */ sblive_writeptr(card, SPCS2, 0, SPCS_CLKACCY_1000PPM | 0x002000000 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); fx_init(card); /* initialize effects engine */ card->tankmem = NULL; #ifdef TANKMEM size = TMEMSIZE; sizeIdx = TMEMSIZEREG; while (size > 16384) { if ((card->tankmem = emu10k1_alloc_memphysical(size)) != NULL) break; size /= 2; sizeIdx -= 1; } if (card->tankmem == NULL) { card->tmemsize = 0; return CTSTATUS_ERROR; } card->tmemsize = size; #else /* !TANKMEM */ card->tmemsize = 0; #endif /* TANKMEM */ if ((card->virtualpagetable = emu10k1_alloc_memphysical((MAXPAGES - RESERVED) * sizeof(u32))) == NULL) { ERROR(); emu10k1_free_memphysical(card->tankmem); return CTSTATUS_ERROR; } if ((card->silentpage = emu10k1_alloc_memphysical(EMUPAGESIZE)) == NULL) { ERROR(); emu10k1_free_memphysical(card->tankmem); emu10k1_free_memphysical(card->virtualpagetable); return CTSTATUS_ERROR; } else memset(card->silentpage->virtaddx, 0, EMUPAGESIZE); for (pagecount = 0; pagecount < (MAXPAGES - RESERVED); pagecount++) ((u32 *) card->virtualpagetable->virtaddx)[pagecount] = (card->silentpage->busaddx * 2) | pagecount; /* Init page table & tank memory base register */ sblive_writeptr(card, PTB, 0, card->virtualpagetable->busaddx); #ifdef TANKMEM sblive_writeptr(card, TCB, 0, card->tankmem->busaddx); #else sblive_writeptr(card, TCB, 0, 0); #endif sblive_writeptr(card, TCBS, 0, sizeIdx); for (nCh = 0; nCh < NUM_G; nCh++) { sblive_writeptr(card, MAPA, nCh, MAP_PTI_MASK | (card->silentpage->busaddx * 2)); sblive_writeptr(card, MAPB, nCh, MAP_PTI_MASK | (card->silentpage->busaddx * 2)); } /* Hokay, now enable the AUD bit */ /* Enable Audio = 1 */ /* Mute Disable Audio = 0 */ /* Lock Tank Memory = 1 */ /* Lock Sound Memory = 0 */ /* Auto Mute = 1 */ sblive_rmwac97(card, AC97_MASTERVOLUME, 0x8000, 0x8000); sblive_writeac97(card, AC97_MASTERVOLUME, 0); sblive_writeac97(card, AC97_PCMOUTVOLUME, 0); sblive_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_LOCKTANKCACHE | HCFG_AUTOMUTE | HCFG_JOYENABLE); /* TOSLink detection */ card->has_toslink = 0; tmp = sblive_readfn0(card, HCFG); if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) { sblive_writefn0(card, HCFG, tmp | 0x800); udelay(512); if (tmp != (sblive_readfn0(card, HCFG) & ~0x800)) { card->has_toslink = 1; sblive_writefn0(card, HCFG, tmp); } } return CTSTATUS_SUCCESS; }