aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/gameport/emu10k1-gp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/gameport/emu10k1-gp.c')
-rw-r--r--drivers/input/gameport/emu10k1-gp.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c
new file mode 100644
index 000000000000..a0118038330a
--- /dev/null
+++ b/drivers/input/gameport/emu10k1-gp.c
@@ -0,0 +1,132 @@
1/*
2 * $Id: emu10k1-gp.c,v 1.8 2002/01/22 20:40:46 vojtech Exp $
3 *
4 * Copyright (c) 2001 Vojtech Pavlik
5 */
6
7/*
8 * EMU10k1 - SB Live / Audigy - gameport driver for Linux
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Should you need to contact me, the author, you can do so either by
27 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
28 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
29 */
30
31#include <asm/io.h>
32
33#include <linux/module.h>
34#include <linux/ioport.h>
35#include <linux/config.h>
36#include <linux/init.h>
37#include <linux/gameport.h>
38#include <linux/slab.h>
39#include <linux/pci.h>
40
41MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
42MODULE_DESCRIPTION("EMU10k1 gameport driver");
43MODULE_LICENSE("GPL");
44
45struct emu {
46 struct pci_dev *dev;
47 struct gameport *gameport;
48 int io;
49 int size;
50};
51
52static struct pci_device_id emu_tbl[] = {
53
54 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
55 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
56 { 0x1102, 0x7004, PCI_ANY_ID, PCI_ANY_ID }, /* Dell SB Live */
57 { 0x1102, 0x7005, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy LS gameport */
58 { 0, }
59};
60
61MODULE_DEVICE_TABLE(pci, emu_tbl);
62
63static int __devinit emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
64{
65 int ioport, iolen;
66 struct emu *emu;
67 struct gameport *port;
68
69 if (pci_enable_device(pdev))
70 return -EBUSY;
71
72 ioport = pci_resource_start(pdev, 0);
73 iolen = pci_resource_len(pdev, 0);
74
75 if (!request_region(ioport, iolen, "emu10k1-gp"))
76 return -EBUSY;
77
78 emu = kcalloc(1, sizeof(struct emu), GFP_KERNEL);
79 port = gameport_allocate_port();
80 if (!emu || !port) {
81 printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");
82 release_region(ioport, iolen);
83 kfree(emu);
84 gameport_free_port(port);
85 return -ENOMEM;
86 }
87
88 emu->io = ioport;
89 emu->size = iolen;
90 emu->dev = pdev;
91 emu->gameport = port;
92
93 gameport_set_name(port, "EMU10K1");
94 gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev));
95 port->dev.parent = &pdev->dev;
96 port->io = ioport;
97
98 pci_set_drvdata(pdev, emu);
99
100 gameport_register_port(port);
101
102 return 0;
103}
104
105static void __devexit emu_remove(struct pci_dev *pdev)
106{
107 struct emu *emu = pci_get_drvdata(pdev);
108
109 gameport_unregister_port(emu->gameport);
110 release_region(emu->io, emu->size);
111 kfree(emu);
112}
113
114static struct pci_driver emu_driver = {
115 .name = "Emu10k1_gameport",
116 .id_table = emu_tbl,
117 .probe = emu_probe,
118 .remove = __devexit_p(emu_remove),
119};
120
121static int __init emu_init(void)
122{
123 return pci_register_driver(&emu_driver);
124}
125
126static void __exit emu_exit(void)
127{
128 pci_unregister_driver(&emu_driver);
129}
130
131module_init(emu_init);
132module_exit(emu_exit);