2 * Initialisation code for Cyrix/NatSemi VSA1 softaudio
4 * (C) Copyright 2003 Red Hat Inc <alan@redhat.com>
6 * XpressAudio(tm) is used on the Cyrix MediaGX (now NatSemi Geode) systems.
7 * The older version (VSA1) provides fairly good soundblaster emulation
8 * although there are a couple of bugs: large DMA buffers break record,
9 * and the MPU event handling seems suspect. VSA2 allows the native driver
10 * to control the AC97 audio engine directly and requires a different driver.
12 * Thanks to National Semiconductor for providing the needed information
13 * on the XpressAudio(tm) internals.
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2, or (at your option) any
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
26 * Investigate whether we can portably support Cognac (5520) in the
30 #include <linux/config.h>
31 #include <linux/delay.h>
32 #include <linux/init.h>
33 #include <linux/module.h>
34 #include <linux/pci.h>
36 #include "sound_config.h"
41 * Read a soundblaster compatible mixer register.
42 * In this case we are actually reading an SMI trap
46 static u8 __devinit mixer_read(unsigned long io, u8 reg)
55 static int __devinit probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
57 struct address_info *hw_config;
64 extern int sb_be_quiet;
66 base = pci_resource_start(pdev, 0);
70 mem = ioremap(base, 128);
73 map = readw(mem + 0x18); /* Read the SMI enables */
77 0:1 * 0x20 + 0x200 = sb base
83 The other bits may be used internally so must be masked */
85 io = 0x220 + 0x20 * (map & 3);
88 printk(KERN_INFO "kahlua: XpressAudio at 0x%lx\n", io);
93 printk(KERN_INFO "kahlua: MPU at 0x300\n");
95 printk(KERN_INFO "kahlua: MPU at 0x330\n");
97 irq = mixer_read(io, 0x80) & 0x0F;
98 dma8 = mixer_read(io, 0x81);
100 // printk("IRQ=%x MAP=%x DMA=%x\n", irq, map, dma8);
110 printk(KERN_ERR "kahlua: No 16bit DMA enabled.\n");
122 printk(KERN_ERR "kahlua: No 8bit DMA enabled.\n");
136 printk(KERN_ERR "kahlua: SB IRQ not set.\n");
140 printk(KERN_INFO "kahlua: XpressAudio on IRQ %d, DMA %d, %d\n",
143 hw_config = kmalloc(sizeof(struct address_info), GFP_KERNEL);
144 if(hw_config == NULL)
146 printk(KERN_ERR "kahlua: out of memory.\n");
149 memset(hw_config, 0, sizeof(*hw_config));
151 pci_set_drvdata(pdev, hw_config);
153 hw_config->io_base = io;
154 hw_config->irq = irq;
155 hw_config->dma = dma8;
156 hw_config->dma2 = dma16;
157 hw_config->name = "Cyrix XpressAudio";
158 hw_config->driver_use_1 = SB_NO_MIDI | SB_PCI_IRQ;
160 if (!request_region(io, 16, "soundblaster"))
163 if(sb_dsp_detect(hw_config, 0, 0, NULL)==0)
165 printk(KERN_ERR "kahlua: audio not responding.\n");
166 release_region(io, 16);
170 oldquiet = sb_be_quiet;
172 if(sb_dsp_init(hw_config, THIS_MODULE))
174 sb_be_quiet = oldquiet;
177 sb_be_quiet = oldquiet;
182 pci_set_drvdata(pdev, NULL);
187 static void __devexit remove_one(struct pci_dev *pdev)
189 struct address_info *hw_config = pci_get_drvdata(pdev);
190 sb_dsp_unload(hw_config, 0);
191 pci_set_drvdata(pdev, NULL);
195 MODULE_AUTHOR("Alan Cox");
196 MODULE_DESCRIPTION("Kahlua VSA1 PCI Audio");
197 MODULE_LICENSE("GPL");
200 * 5530 only. The 5510/5520 decode is different.
203 static struct pci_device_id id_tbl[] = {
204 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
208 MODULE_DEVICE_TABLE(pci, id_tbl);
210 static struct pci_driver kahlua_driver = {
214 .remove = __devexit_p(remove_one),
218 static int __init kahlua_init_module(void)
220 printk(KERN_INFO "Cyrix Kahlua VSA1 XpressAudio support (c) Copyright 2003 Red Hat Inc\n");
221 return pci_register_driver(&kahlua_driver);
224 static void __devexit kahlua_cleanup_module(void)
226 pci_unregister_driver(&kahlua_driver);
230 module_init(kahlua_init_module);
231 module_exit(kahlua_cleanup_module);