[LWN Logo]
[LWN.net]
From:	 Rui Sousa <rui.p.m.sousa@clix.pt>
To:	 Linus Torvalds <torvalds@transmeta.com>
Subject: [PATCH] emu10k1 againt kernel 2.4.8
Date:	 Sat, 11 Aug 2001 06:33:09 +0100 (WEST)
Cc:	 <linux-kernel@vger.kernel.org>,
	 <emu10k1-devel@opensource.creative.com>,
	 Robert Love <rml@tech9.net>


Patch against kernel 2.4.8:
1. Fixes makefiles changes (can now be compiled as a module).
2. Reverts addition of joystick.c
3. Enables emu10k1 sequencer support.
4. Adds documentation for the driver new features.

Please apply,

Rui Sousa

diff -uNr linux-2.4.8/Documentation/Configure.help linux-2.4.8.emu10k1.new/Documentation/Configure.help
--- linux-2.4.8/Documentation/Configure.help	Sat Aug 11 05:36:06 2001
+++ linux-2.4.8.emu10k1.new/Documentation/Configure.help	Sat Aug 11 06:22:12 2001
@@ -15585,8 +15585,30 @@
 
 Creative EMU10K1 based PCI sound cards
 CONFIG_SOUND_EMU10K1
-  Say Y or M if you have a PCI sound card using the EMU10K1
-  chipset, such as the Creative SBLive!,  SB PCI512 or Emu-APS.
+  Say Y or M if you have a PCI sound card using the EMU10K1 chipset,
+  such as the Creative SBLive!, SB PCI512 or Emu-APS.
+
+  For more information about the degree of support for the different
+  card models please check:
+
+       http://opensource.creative.com

+
+  It is now possible to load dsp microcode patches into the EMU10K1
+  chip.  These patches are used to implement real time sound 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 the above link. You need to get the source snapshot and then type:
+
+	% make tools
+	% make install-tools
+
+  in the top directory.
+
+Creative EMU10K1 MIDI
+CONFIG_MIDI_EMU10K1
+  Say Y if you want to be able to use the OSS /dev/sequencer interface.
+  This code is still experimental.
 
 Crystal SoundFusion (CS4280/461x)
 CONFIG_SOUND_FUSION
diff -uNr linux-2.4.8/MAINTAINERS linux-2.4.8.emu10k1.new/MAINTAINERS
--- linux-2.4.8/MAINTAINERS	Sat Aug 11 05:36:06 2001
+++ linux-2.4.8.emu10k1.new/MAINTAINERS	Sat Aug 11 05:41:12 2001
@@ -471,7 +471,7 @@
 
 EMU10K1 SOUND DRIVER
 P:	Rui Sousa	
-M:	rsousa@grad.physics.sunysb.edu	
+M:	rui.p.m.sousa@clix.pt	
 L:	emu10k1-devel@opensource.creative.com
 W:	http://opensource.creative.com/

 S:	Maintained
diff -uNr linux-2.4.8/drivers/sound/Config.in linux-2.4.8.emu10k1.new/drivers/sound/Config.in
--- linux-2.4.8/drivers/sound/Config.in	Sun Jul 29 10:34:38 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/Config.in	Sat Aug 11 05:57:50 2001
@@ -30,6 +30,7 @@
     fi
 fi
 dep_tristate '  Creative SBLive! (EMU10K1)' CONFIG_SOUND_EMU10K1 $CONFIG_SOUND $CONFIG_PCI
+dep_mbool    '  Creative SBLive! MIDI' CONFIG_MIDI_EMU10K1 $CONFIG_SOUND_EMU10K1 $CONFIG_EXPERIMENTAL
 dep_tristate '  Crystal SoundFusion (CS4280/461x)' CONFIG_SOUND_FUSION $CONFIG_SOUND
 dep_tristate '  Crystal Sound CS4281' CONFIG_SOUND_CS4281 $CONFIG_SOUND
 dep_tristate '  Ensoniq AudioPCI (ES1370)' CONFIG_SOUND_ES1370 $CONFIG_SOUND $CONFIG_PCI
diff -uNr linux-2.4.8/drivers/sound/Makefile linux-2.4.8.emu10k1.new/drivers/sound/Makefile
--- linux-2.4.8/drivers/sound/Makefile	Sat Aug 11 05:36:32 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/Makefile	Sat Aug 11 05:42:54 2001
@@ -68,12 +68,16 @@
 obj-$(CONFIG_SOUND_MAESTRO)	+= maestro.o
 obj-$(CONFIG_SOUND_MAESTRO3)	+= maestro3.o ac97_codec.o
 obj-$(CONFIG_SOUND_TRIDENT)	+= trident.o ac97_codec.o
+obj-$(CONFIG_SOUND_EMU10K1)	+= ac97_codec.o
+ifeq ($(CONFIG_MIDI_EMU10K1),y)
+  obj-$(CONFIG_SOUND_EMU10K1)	+= sound.o
+endif
 
 subdir-$(CONFIG_SOUND_EMU10K1) += emu10k1
 subdir-$(CONFIG_SOUND_CS4281) += cs4281
 
 ifeq ($(CONFIG_SOUND_EMU10K1),y)
-  obj-y += ac97_codec.o emu10k1/emu10k1.o
+  obj-y += emu10k1/emu10k1.o
 endif
 
 ifeq ($(CONFIG_SOUND_CS4281),y)
diff -uNr linux-2.4.8/drivers/sound/emu10k1/Makefile linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/Makefile
--- linux-2.4.8/drivers/sound/emu10k1/Makefile	Sat Aug 11 05:36:32 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/Makefile	Sat Aug 11 05:47:43 2001
@@ -5,13 +5,16 @@
 O_TARGET := emu10k1.o
 
 obj-y :=     audio.o cardmi.o cardmo.o cardwi.o cardwo.o ecard.o \
-             efxmgr.o emuadxmg.o hwaccess.o irqmgr.o joystick.o \
-             main.o midi.o mixer.o passthrough.o recmgr.o timer.o \
-             voicemgr.o
+             efxmgr.o emuadxmg.o hwaccess.o irqmgr.o main.o midi.o \
+             mixer.o passthrough.o recmgr.o timer.o voicemgr.o
 obj-m := $(O_TARGET)
 
 ifdef DEBUG
     EXTRA_CFLAGS += -DEMU10K1_DEBUG
+endif
+
+ifdef CONFIG_MIDI_EMU10K1
+    EXTRA_CFLAGS += -DEMU10K1_SEQUENCER
 endif
 
 include $(TOPDIR)/Rules.make
diff -uNr linux-2.4.8/drivers/sound/emu10k1/joystick.c linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/joystick.c
--- linux-2.4.8/drivers/sound/emu10k1/joystick.c	Sat Aug 11 05:36:33 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/joystick.c	Thu Jan  1 01:00:00 1970
@@ -1,204 +0,0 @@
-/*
- **********************************************************************
- *     joystick.c - Creative EMU10K1 Joystick port driver
- *     Copyright 2000 Rui Sousa.
- *
- **********************************************************************
- *
- *     Date                 Author          Summary of changes
- *     ----                 ------          ------------------
- *     April  1, 2000       Rui Sousa       initial version 
- *     April 28, 2000       Rui Sousa       fixed a kernel oops,
- *					    make use of kcompat24 for
- *					    2.2 kernels compatibility.
- *     May    1, 2000       Rui Sousa       improved kernel compatibility
- *                                          layer.
- *
- **********************************************************************
- *
- *     This program is free software; you can redistribute it and/or
- *     modify it under the terms of the GNU General Public License as
- *     published by the Free Software Foundation; either version 2 of
- *     the License, or (at your option) any later version.
- *
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- *     You should have received a copy of the GNU General Public
- *     License along with this program; if not, write to the Free
- *     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
- *     USA.
- *
- **********************************************************************/
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/version.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/list.h>
-
-#define DRIVER_VERSION "0.3.1"
-
-#ifndef PCI_VENDOR_ID_CREATIVE
-#define PCI_VENDOR_ID_CREATIVE 0x1102
-#endif
-
-#ifndef PCI_DEVICE_ID_CREATIVE_EMU10K1_JOYSTICK
-#define PCI_DEVICE_ID_CREATIVE_EMU10K1_JOYSTICK 0x7002
-#endif
-
-/* PCI function 1 registers, address = <val> + PCIBASE1 */
-
-#define JOYSTICK1               0x00            /* Analog joystick port register                */
-#define JOYSTICK2               0x01            /* Analog joystick port register                */
-#define JOYSTICK3               0x02            /* Analog joystick port register                */
-#define JOYSTICK4               0x03            /* Analog joystick port register                */
-#define JOYSTICK5               0x04            /* Analog joystick port register                */
-#define JOYSTICK6               0x05            /* Analog joystick port register                */
-#define JOYSTICK7               0x06            /* Analog joystick port register                */
-#define JOYSTICK8               0x07            /* Analog joystick port register                */
-
-/* When writing, any write causes JOYSTICK_COMPARATOR output enable to be pulsed on write.      */
-/* When reading, use these bitfields: */
-#define JOYSTICK_BUTTONS        0x0f            /* Joystick button data                         */
-#define JOYSTICK_COMPARATOR     0xf0            /* Joystick comparator data                     */
-
-#define NR_DEV 5
-
-static int io[NR_DEV] = { 0, };
-
-enum {
-	EMU10K1_JOYSTICK = 0
-};
-
-static char *card_names[] = {
-	"EMU10K1 Joystick Port"
-};
-
-static struct pci_device_id emu10k1_joy_pci_tbl[] __devinitdata = {
-	{PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_EMU10K1_JOYSTICK,
-	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, EMU10K1_JOYSTICK},
-	{0,}
-};
-
-MODULE_DEVICE_TABLE(pci, emu10k1_joy_pci_tbl);
-
-struct emu10k1_joy_card {
-	struct list_head list;
-
-	struct pci_dev *pci_dev;
-	unsigned long iobase;
-	unsigned long length;
-	u8 addr_changed;
-};
-
-static LIST_HEAD(emu10k1_joy_devs);
-static unsigned int devindex = 0;
-
-/* Driver initialization routine */
-static int __devinit emu10k1_joy_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
-{
-	struct emu10k1_joy_card *card;
-	u16 model;
-	u8 chiprev;
-
-	if ((card = kmalloc(sizeof(struct emu10k1_joy_card), GFP_KERNEL)) == NULL) {
-		printk(KERN_ERR "emu10k1-joy: out of memory\n");
-		return -ENOMEM;
-	}
-	memset(card, 0, sizeof(struct emu10k1_joy_card));
-
-	if (pci_enable_device(pci_dev)) {
-		printk(KERN_ERR "emu10k1-joy: couldn't enable device\n");
-		kfree(card);
-		return -ENODEV;
-	}
-
-	card->iobase = pci_resource_start(pci_dev, 0); 
-	card->length = pci_resource_len(pci_dev, 0);
-
-	if (request_region(card->iobase, card->length, card_names[pci_id->driver_data])
-	    == NULL) {
-		printk(KERN_ERR "emu10k1-joy: IO space in use\n");
-		kfree(card);
-		return -ENODEV;
-	}
-
-	pci_set_drvdata(pci_dev, card);
-
-	card->pci_dev = pci_dev;
-	card->addr_changed = 0;
-
-	pci_read_config_byte(pci_dev, PCI_REVISION_ID, &chiprev);
-	pci_read_config_word(pci_dev, PCI_SUBSYSTEM_ID, &model);
-
-	printk(KERN_INFO "emu10k1-joy: %s rev %d model 0x%x found, IO at 0x%04lx-0x%04lx\n",
-		card_names[pci_id->driver_data], chiprev, model, card->iobase,
-		card->iobase + card->length - 1);
-
-	if (io[devindex]) {
-		if ((io[devindex] & ~0x18) != 0x200) {
-			printk(KERN_ERR "emu10k1-joy: invalid io value\n");
-			release_region(card->iobase, card->length);
-			kfree(card);
-			return -ENODEV;
-		}
-
-		card->addr_changed = 1;
-		pci_write_config_dword(pci_dev, PCI_BASE_ADDRESS_0, io[devindex]);
-		printk(KERN_INFO "emu10k1-joy: IO ports mirrored at 0x%03x\n", io[devindex]);
-	}
-
-	list_add(&card->list, &emu10k1_joy_devs);
-	devindex++;
-
-	return 0;
-}
-
-static void __devexit emu10k1_joy_remove(struct pci_dev *pci_dev)
-{
-	struct emu10k1_joy_card *card = pci_get_drvdata(pci_dev);
-
-	if(card->addr_changed)
-		pci_write_config_dword(pci_dev, PCI_BASE_ADDRESS_0, card->iobase);
-
-	release_region(card->iobase, card->length);
-
-	list_del(&card->list);
-	kfree(card);
-	pci_set_drvdata(pci_dev, NULL);
-}
-
-MODULE_PARM(io, "1-" __MODULE_STRING(NR_DEV) "i");
-MODULE_PARM_DESC(io, "sets joystick port address");
-MODULE_AUTHOR("Rui Sousa (Email to: emu10k1-devel@opensource.creative.com)");
-MODULE_DESCRIPTION("Creative EMU10K1 PCI Joystick Port v" DRIVER_VERSION
-		   "\nCopyright (C) 2000 Rui Sousa");
-
-static struct pci_driver emu10k1_joy_pci_driver = {
-	name:"emu10k1 joystick",
-	id_table:emu10k1_joy_pci_tbl,
-	probe:emu10k1_joy_probe,
-	remove:emu10k1_joy_remove,
-};
-
-static int __init emu10k1_joy_init_module(void)
-{
-	printk(KERN_INFO "Creative EMU10K1 PCI Joystick Port, version " DRIVER_VERSION ", " __TIME__
-	       " " __DATE__ "\n");
-
-	return pci_module_init(&emu10k1_joy_pci_driver);
-}
-
-static void __exit emu10k1_joy_cleanup_module(void)
-{
-	pci_unregister_driver(&emu10k1_joy_pci_driver);
-	return;
-}
-
-module_init(emu10k1_joy_init_module);
-module_exit(emu10k1_joy_cleanup_module);
diff -uNr linux-2.4.8/drivers/sound/emu10k1/main.c linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/main.c
--- linux-2.4.8/drivers/sound/emu10k1/main.c	Sat Aug 11 05:36:33 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/main.c	Sat Aug 11 05:47:43 2001
@@ -92,8 +92,8 @@
 #define MIDI_SYNTH_NAME "EMU10K1 MIDI"
 #define MIDI_SYNTH_CAPS SYNTH_CAP_INPUT
  
-#include "sound_config.h"
-#include "midi_synth.h"
+#include "../sound_config.h"
+#include "../midi_synth.h"
 
 /* this should be in dev_table.h */
 #define SNDCARD_EMU10K1 46
@@ -1039,6 +1039,7 @@
 
 static struct midi_operations emu10k1_midi_operations =
 {
+    THIS_MODULE,
     {"EMU10K1 MIDI", 0, 0, SNDCARD_EMU10K1},
 	&std_midi_synth,
 	{0},
diff -uNr linux-2.4.8/drivers/sound/emu10k1/midi.c linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/midi.c
--- linux-2.4.8/drivers/sound/emu10k1/midi.c	Sat Aug 11 05:36:34 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/midi.c	Sat Aug 11 05:47:43 2001
@@ -43,7 +43,7 @@
 #include "midi.h"
 
 #ifdef EMU10K1_SEQUENCER
-#include "sound_config.h"
+#include "../sound_config.h"
 #endif
 
 static spinlock_t midi_spinlock __attribute((unused)) = SPIN_LOCK_UNLOCKED;
diff -uNr linux-2.4.8/drivers/sound/emu10k1/passthrough.h linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/passthrough.h
--- linux-2.4.8/drivers/sound/emu10k1/passthrough.h	Sat Aug 11 05:36:34 2001
+++ linux-2.4.8.emu10k1.new/drivers/sound/emu10k1/passthrough.h	Sat Aug 11 05:47:43 2001
@@ -32,6 +32,7 @@
 #ifndef _PASSTHROUGH_H
 #define _PASSTHROUGH_H
 
+#include "hwaccess.h"
 #include "audio.h"
 
 /* number of 16-bit stereo samples in XTRAM buffer */