2 * $Id: emu10k1-gp.c,v 1.1.1.1 2005/04/11 02:50:21 jack Exp $
4 * Copyright (c) 2001 Vojtech Pavlik
10 * EMU10k1 - SB Live! - gameport driver for Linux
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * Should you need to contact me, the author, you can do so either by
29 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
30 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
35 #include <linux/module.h>
36 #include <linux/ioport.h>
37 #include <linux/config.h>
38 #include <linux/init.h>
39 #include <linux/gameport.h>
40 #include <linux/slab.h>
41 #include <linux/pci.h>
43 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
44 MODULE_LICENSE("GPL");
49 struct gameport gameport;
53 static struct pci_device_id emu_tbl[] __devinitdata = {
54 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live! gameport */
55 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy! gameport */
59 MODULE_DEVICE_TABLE(pci, emu_tbl);
61 static int __devinit emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
67 rc = pci_enable_device(pdev);
69 printk(KERN_ERR "emu10k1-gp: Cannot enable emu10k1 gameport (bus %d, devfn %d) error=%d\n",
70 pdev->bus->number, pdev->devfn, rc);
74 ioport = pci_resource_start(pdev, 0);
75 iolen = pci_resource_len(pdev, 0);
77 if (!request_region(ioport, iolen, "emu10k1-gp"))
80 if (!(port = kmalloc(sizeof(struct emu), GFP_KERNEL))) {
81 printk(KERN_ERR "emu10k1-gp: Memory allocation failed.\n");
82 release_region(ioport, iolen);
85 memset(port, 0, sizeof(struct emu));
87 port->gameport.io = ioport;
90 pci_set_drvdata(pdev, port);
92 gameport_register_port(&port->gameport);
94 printk(KERN_INFO "gameport%d: Emu10k1 Gameport at %#x size %d speed %d kHz\n",
95 port->gameport.number, port->gameport.io, iolen, port->gameport.speed);
100 static void __devexit emu_remove(struct pci_dev *pdev)
102 struct emu *port = pci_get_drvdata(pdev);
103 gameport_unregister_port(&port->gameport);
104 release_region(port->gameport.io, port->size);
108 static struct pci_driver emu_driver = {
109 name: "Emu10k1 Gameport",
112 remove: __devexit_p(emu_remove),
115 int __init emu_init(void)
117 return pci_module_init(&emu_driver);
120 void __exit emu_exit(void)
122 pci_unregister_driver(&emu_driver);
125 module_init(emu_init);
126 module_exit(emu_exit);