diff -ur linux-2.4.19-pre5.orig/Documentation/Configure.help linux-2.4.19-pre5/Documentation/Configure.help --- linux-2.4.19-pre5.orig/Documentation/Configure.help Tue Apr 2 02:46:01 2002 +++ linux-2.4.19-pre5/Documentation/Configure.help Tue Apr 2 03:03:43 2002 @@ -18986,7 +18986,7 @@ processing effects which include for example: signal routing, bass/treble control, AC3 passthrough, ... Userspace tools to create new patches and load/unload them can be - found at . + found at . Creative SBLive! (EMU10K1) MIDI CONFIG_MIDI_EMU10K1 diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/audio.c linux-2.4.19-pre5/drivers/sound/emu10k1/audio.c --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/audio.c Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/audio.c Tue Apr 2 02:58:05 2002 @@ -1365,6 +1365,13 @@ buffer->fragment_size = 1 << buffer->ossfragshift; + while (buffer->fragment_size * WAVEOUT_MINFRAGS > WAVEOUT_MAXBUFSIZE) + buffer->fragment_size >>= 1; + + /* now we are sure that: + (2^WAVEOUT_MINFRAGSHIFT) <= (fragment_size = 2^n) <= (WAVEOUT_MAXBUFSIZE / WAVEOUT_MINFRAGS) + */ + if (!buffer->numfrags) { u32 numfrags; @@ -1379,19 +1386,14 @@ } } - if (buffer->numfrags < MINFRAGS) - buffer->numfrags = MINFRAGS; + if (buffer->numfrags < WAVEOUT_MINFRAGS) + buffer->numfrags = WAVEOUT_MINFRAGS; - if (buffer->numfrags * buffer->fragment_size > WAVEOUT_MAXBUFSIZE) { + if (buffer->numfrags * buffer->fragment_size > WAVEOUT_MAXBUFSIZE) buffer->numfrags = WAVEOUT_MAXBUFSIZE / buffer->fragment_size; - if (buffer->numfrags < MINFRAGS) { - buffer->numfrags = MINFRAGS; - buffer->fragment_size = WAVEOUT_MAXBUFSIZE / MINFRAGS; - } - - } else if (buffer->numfrags * buffer->fragment_size < WAVEOUT_MINBUFSIZE) - buffer->numfrags = WAVEOUT_MINBUFSIZE / buffer->fragment_size; + if (buffer->numfrags < WAVEOUT_MINFRAGS) + BUG(); buffer->size = buffer->fragment_size * buffer->numfrags; buffer->pages = buffer->size / PAGE_SIZE + ((buffer->size % PAGE_SIZE) ? 1 : 0); @@ -1425,24 +1427,29 @@ buffer->fragment_size = 1 << buffer->ossfragshift; + while (buffer->fragment_size * WAVEIN_MINFRAGS > WAVEIN_MAXBUFSIZE) + buffer->fragment_size >>= 1; + + /* now we are sure that: + (2^WAVEIN_MINFRAGSHIFT) <= (fragment_size = 2^n) <= (WAVEIN_MAXBUFSIZE / WAVEIN_MINFRAGS) + */ + + if (!buffer->numfrags) buffer->numfrags = (wiinst->format.bytespersec * WAVEIN_DEFAULTBUFLEN) / (buffer->fragment_size * 1000) - 1; - if (buffer->numfrags < MINFRAGS) - buffer->numfrags = MINFRAGS; + if (buffer->numfrags < WAVEIN_MINFRAGS) + buffer->numfrags = WAVEIN_MINFRAGS; - if (buffer->numfrags * buffer->fragment_size > WAVEIN_MAXBUFSIZE) { + if (buffer->numfrags * buffer->fragment_size > WAVEIN_MAXBUFSIZE) buffer->numfrags = WAVEIN_MAXBUFSIZE / buffer->fragment_size; - if (buffer->numfrags < MINFRAGS) { - buffer->numfrags = MINFRAGS; - buffer->fragment_size = WAVEIN_MAXBUFSIZE / MINFRAGS; - } - } else if (buffer->numfrags * buffer->fragment_size < WAVEIN_MINBUFSIZE) - buffer->numfrags = WAVEIN_MINBUFSIZE / buffer->fragment_size; + if (buffer->numfrags < WAVEIN_MINFRAGS) + BUG(); bufsize = buffer->fragment_size * buffer->numfrags; + /* the buffer size for recording is restricted to certain values, adjust it now */ if (bufsize >= 0x10000) { buffer->size = 0x10000; buffer->sizeregval = 0x1f; @@ -1468,10 +1475,12 @@ } } + /* adjust the fragment size so that buffer size is an integer multiple */ + while (buffer->size % buffer->fragment_size) + buffer->fragment_size >>= 1; + buffer->numfrags = buffer->size / buffer->fragment_size; buffer->pages = buffer->size / PAGE_SIZE + ((buffer->size % PAGE_SIZE) ? 1 : 0); - if (buffer->size % buffer->fragment_size) - BUG(); DPD(2, " calculated recording fragment_size -> %d\n", buffer->fragment_size); DPD(2, " calculated recording numfrags -> %d\n", buffer->numfrags); diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/audio.h linux-2.4.19-pre5/drivers/sound/emu10k1/audio.h --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/audio.h Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/audio.h Tue Apr 2 02:58:05 2002 @@ -33,8 +33,6 @@ #ifndef _AUDIO_H #define _AUDIO_H -#define MINFRAGS 3 /* _don't_ go bellow 3 */ - struct emu10k1_wavedevice { struct emu10k1_card *card; diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/cardwi.h linux-2.4.19-pre5/drivers/sound/emu10k1/cardwi.h --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/cardwi.h Sat Mar 9 12:39:41 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/cardwi.h Tue Apr 2 02:58:05 2002 @@ -69,13 +69,14 @@ u16 fxwc; }; -#define WAVEIN_MAXBUFSIZE 65536 -#define WAVEIN_MINBUFSIZE 368 +#define WAVEIN_MAXBUFSIZE 65536 +#define WAVEIN_MINBUFSIZE 368 -#define WAVEIN_DEFAULTFRAGLEN 100 -#define WAVEIN_DEFAULTBUFLEN 1000 +#define WAVEIN_DEFAULTFRAGLEN 100 +#define WAVEIN_DEFAULTBUFLEN 1000 -#define WAVEIN_MINFRAGSHIFT 8 +#define WAVEIN_MINFRAGSHIFT 8 +#define WAVEIN_MINFRAGS 2 int emu10k1_wavein_open(struct emu10k1_wavedevice *); void emu10k1_wavein_close(struct emu10k1_wavedevice *); diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/cardwo.h linux-2.4.19-pre5/drivers/sound/emu10k1/cardwo.h --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/cardwo.h Sat Mar 9 12:39:41 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/cardwo.h Tue Apr 2 02:58:05 2002 @@ -39,13 +39,13 @@ /* setting this to other than a power of two may break some applications */ #define WAVEOUT_MAXBUFSIZE MAXBUFSIZE -#define WAVEOUT_MINBUFSIZE 64 #define WAVEOUT_DEFAULTFRAGLEN 20 /* Time to play a fragment in ms (latency) */ #define WAVEOUT_DEFAULTBUFLEN 500 /* Time to play the entire buffer in ms */ -#define WAVEOUT_MINFRAGSHIFT 6 -#define WAVEOUT_MAXVOICES 6 +#define WAVEOUT_MINFRAGSHIFT 6 /* Minimum fragment size in bytes is 2^6 */ +#define WAVEOUT_MINFRAGS 3 /* _don't_ go bellow 3, it would break silence filling */ +#define WAVEOUT_MAXVOICES 6 struct waveout_buffer { u16 ossfragshift; diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/efxmgr.c linux-2.4.19-pre5/drivers/sound/emu10k1/efxmgr.c --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/efxmgr.c Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/efxmgr.c Tue Apr 2 02:58:05 2002 @@ -103,7 +103,7 @@ card->ac97.mixer_state[oss_mixer] = (right << 8) | left; - if (!card->isaps) + if (!card->is_aps) card->ac97.write_mixer(&card->ac97, oss_mixer, left, right); emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][0], left, diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/hwaccess.h linux-2.4.19-pre5/drivers/sound/emu10k1/hwaccess.h --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/hwaccess.h Sat Mar 9 12:39:41 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/hwaccess.h Tue Apr 2 02:58:05 2002 @@ -182,7 +182,7 @@ u8 chiprev; /* Chip revision */ - int isaps; + u8 is_aps; struct patch_manager mgr; struct pt_data pt; diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/main.c linux-2.4.19-pre5/drivers/sound/emu10k1/main.c --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/main.c Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/main.c Tue Apr 2 02:58:05 2002 @@ -196,7 +196,7 @@ /* Assign default recording parameters */ /* FIXME */ - if(card->isaps) + if (card->is_aps) card->wavein.recsrc = WAVERECORD_FX; else card->wavein.recsrc = WAVERECORD_AC97; @@ -229,7 +229,7 @@ card->ac97.private_data = card; - if (!card->isaps) { + if (!card->is_aps) { card->ac97.id = 0; card->ac97.codec_read = emu10k1_ac97_read; card->ac97.codec_write = emu10k1_ac97_write; @@ -287,7 +287,7 @@ { char s[32]; - if (!card->isaps) { + if (!card->is_aps) { sprintf(s, "driver/emu10k1/%s/ac97", card->pci_dev->slot_name); remove_proc_entry(s, NULL); @@ -867,19 +867,19 @@ } for (pagecount = 0; pagecount < MAXPAGES; pagecount++) - ((u32 *) card->virtualpagetable.addr)[pagecount] = cpu_to_le32((card->silentpage.dma_handle * 2) | pagecount); + ((u32 *) card->virtualpagetable.addr)[pagecount] = cpu_to_le32(((u32)card->silentpage.dma_handle * 2) | pagecount); /* Init page table & tank memory base register */ sblive_writeptr_tag(card, 0, - PTB, card->virtualpagetable.dma_handle, + PTB, (u32)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), + MAPA, MAP_PTI_MASK |( (u32)card->silentpage.dma_handle * 2), + MAPB, MAP_PTI_MASK |( (u32)card->silentpage.dma_handle * 2), TAGLIST_END); } @@ -1059,7 +1059,7 @@ card->iobase + card->length - 1, card->irq); pci_read_config_dword(pci_dev, PCI_SUBSYSTEM_VENDOR_ID, &subsysvid); - card->isaps = (subsysvid == EMU_APS_SUBID); + card->is_aps = (subsysvid == EMU_APS_SUBID); spin_lock_init(&card->lock); init_MUTEX(&card->open_sem); @@ -1090,7 +1090,7 @@ goto err_emu10k1_init; } - if (card->isaps) + if (card->is_aps) emu10k1_ecard_init(card); list_add(&card->list, &emu10k1_devs); @@ -1135,7 +1135,7 @@ pci_set_drvdata(pci_dev, NULL); } -MODULE_AUTHOR("Bertrand Lee, Cai Ying. (Email to: emu10k1-devel@opensource.creative.com)"); +MODULE_AUTHOR("Bertrand Lee, Cai Ying. (Email to: emu10k1-devel@lists.sourceforge.net)"); MODULE_DESCRIPTION("Creative EMU10K1 PCI Audio Driver v" DRIVER_VERSION "\nCopyright (C) 1999 Creative Technology Ltd."); MODULE_LICENSE("GPL"); diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/mixer.c linux-2.4.19-pre5/drivers/sound/emu10k1/mixer.c --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/mixer.c Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/mixer.c Tue Apr 2 02:58:05 2002 @@ -251,7 +251,7 @@ case CMD_SETRECSRC: switch (ctl->val[0]) { case WAVERECORD_AC97: - if (card->isaps) { + if (card->is_aps) { ret = -EINVAL; break; } @@ -455,7 +455,7 @@ card->mgr.ctrl_gpr[id][ch] = addr; - if (card->isaps) + if (card->is_aps) break; if (addr >= 0) { @@ -558,7 +558,7 @@ card->tankmem.size = size; - sblive_writeptr_tag(card, 0, TCB, card->tankmem.dma_handle, TCBS, size_reg, TAGLIST_END); + sblive_writeptr_tag(card, 0, TCB,(u32) card->tankmem.dma_handle, TCBS, size_reg, TAGLIST_END); emu10k1_writefn0(card, HCFG_LOCKTANKCACHE, 0); } @@ -621,7 +621,7 @@ unsigned int oss_mixer = _IOC_NR(cmd); ret = -EINVAL; - if (!card->isaps) { + if (!card->is_aps) { if (cmd == SOUND_MIXER_INFO) { mixer_info info; diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/recmgr.c linux-2.4.19-pre5/drivers/sound/emu10k1/recmgr.c --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/recmgr.c Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/recmgr.c Tue Apr 2 02:58:05 2002 @@ -132,7 +132,7 @@ DPD(2, "bus addx: %#lx\n", (unsigned long) buffer->dma_handle); - sblive_writeptr(card, buffer->addrreg, 0, buffer->dma_handle); + sblive_writeptr(card, buffer->addrreg, 0, (u32)buffer->dma_handle); return; } diff -ur linux-2.4.19-pre5.orig/drivers/sound/emu10k1/voicemgr.c linux-2.4.19-pre5/drivers/sound/emu10k1/voicemgr.c --- linux-2.4.19-pre5.orig/drivers/sound/emu10k1/voicemgr.c Sat Mar 9 12:26:06 2002 +++ linux-2.4.19-pre5/drivers/sound/emu10k1/voicemgr.c Tue Apr 2 02:58:05 2002 @@ -66,7 +66,7 @@ DPD(2, "Virtual Addx: %p\n", mem->addr[pagecount]); for (i = 0; i < PAGE_SIZE / EMUPAGESIZE; i++) { - busaddx = mem->dma_handle[pagecount] + i * EMUPAGESIZE; + busaddx = (u32)(mem->dma_handle[pagecount]) + i * EMUPAGESIZE; DPD(3, "Bus Addx: %#lx\n", busaddx); @@ -102,7 +102,7 @@ for (i = 0; i < PAGE_SIZE / EMUPAGESIZE; i++) { pageindex = mem->emupageindex + pagecount * PAGE_SIZE / EMUPAGESIZE + i; ((u32 *) card->virtualpagetable.addr)[pageindex] = - cpu_to_le32((card->silentpage.dma_handle * 2) | pageindex); + cpu_to_le32(((u32)card->silentpage.dma_handle * 2) | pageindex); } } @@ -231,8 +231,8 @@ Z1, 0, Z2, 0, /* Invalidate maps */ - MAPA, MAP_PTI_MASK | (card->silentpage.dma_handle * 2), - MAPB, MAP_PTI_MASK | (card->silentpage.dma_handle * 2), + MAPA, MAP_PTI_MASK | ((u32)card->silentpage.dma_handle * 2), + MAPB, MAP_PTI_MASK | ((u32)card->silentpage.dma_handle * 2), /* modulation envelope */ CVCF, 0x0000ffff, VTFT, 0x0000ffff,