OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [joystick/] [emu10k1-gp.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * $Id: emu10k1-gp.c,v 1.1.1.1 2004-04-15 02:03:28 phoenix Exp $
3
 *
4
 *  Copyright (c) 2001 Vojtech Pavlik
5
 *
6
 *  Sponsored by SuSE
7
 */
8
 
9
/*
10
 * EMU10k1 - SB Live! - gameport driver for Linux
11
 */
12
 
13
/*
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.
18
 *
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.
23
 *
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
27
 *
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
31
 */
32
 
33
#include <asm/io.h>
34
 
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>
42
 
43
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
44
MODULE_LICENSE("GPL");
45
 
46
struct emu {
47
        struct pci_dev *dev;
48
        struct emu *next;
49
        struct gameport gameport;
50
        int size;
51
};
52
 
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 */
56
        { 0, }
57
};
58
 
59
MODULE_DEVICE_TABLE(pci, emu_tbl);
60
 
61
static int __devinit emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
62
{
63
        int ioport, iolen;
64
        int rc;
65
        struct emu *port;
66
 
67
        rc = pci_enable_device(pdev);
68
        if (rc) {
69
                printk(KERN_ERR "emu10k1-gp: Cannot enable emu10k1 gameport (bus %d, devfn %d) error=%d\n",
70
                        pdev->bus->number, pdev->devfn, rc);
71
                return rc;
72
        }
73
 
74
        ioport = pci_resource_start(pdev, 0);
75
        iolen = pci_resource_len(pdev, 0);
76
 
77
        if (!request_region(ioport, iolen, "emu10k1-gp"))
78
                return -EBUSY;
79
 
80
        if (!(port = kmalloc(sizeof(struct emu), GFP_KERNEL))) {
81
                printk(KERN_ERR "emu10k1-gp: Memory allocation failed.\n");
82
                release_region(ioport, iolen);
83
                return -ENOMEM;
84
        }
85
        memset(port, 0, sizeof(struct emu));
86
 
87
        port->gameport.io = ioport;
88
        port->size = iolen;
89
        port->dev = pdev;
90
        pci_set_drvdata(pdev, port);
91
 
92
        gameport_register_port(&port->gameport);
93
 
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);
96
 
97
        return 0;
98
}
99
 
100
static void __devexit emu_remove(struct pci_dev *pdev)
101
{
102
        struct emu *port = pci_get_drvdata(pdev);
103
        gameport_unregister_port(&port->gameport);
104
        release_region(port->gameport.io, port->size);
105
        kfree(port);
106
}
107
 
108
static struct pci_driver emu_driver = {
109
        name:           "Emu10k1 Gameport",
110
        id_table:       emu_tbl,
111
        probe:          emu_probe,
112
        remove:         __devexit_p(emu_remove),
113
};
114
 
115
int __init emu_init(void)
116
{
117
        return pci_module_init(&emu_driver);
118
}
119
 
120
void __exit emu_exit(void)
121
{
122
        pci_unregister_driver(&emu_driver);
123
}
124
 
125
module_init(emu_init);
126
module_exit(emu_exit);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.