1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2001 Vojtech Pavlik
7 * EMU10k1 - SB Live / Audigy - gameport driver for Linux
15 #include <linux/module.h>
16 #include <linux/ioport.h>
17 #include <linux/gameport.h>
18 #include <linux/slab.h>
19 #include <linux/pci.h>
21 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
22 MODULE_DESCRIPTION("EMU10k1 gameport driver");
23 MODULE_LICENSE("GPL");
27 struct gameport
*gameport
;
32 static const struct pci_device_id emu_tbl
[] = {
34 { 0x1102, 0x7002, PCI_ANY_ID
, PCI_ANY_ID
}, /* SB Live gameport */
35 { 0x1102, 0x7003, PCI_ANY_ID
, PCI_ANY_ID
}, /* Audigy gameport */
36 { 0x1102, 0x7004, PCI_ANY_ID
, PCI_ANY_ID
}, /* Dell SB Live */
37 { 0x1102, 0x7005, PCI_ANY_ID
, PCI_ANY_ID
}, /* Audigy LS gameport */
41 MODULE_DEVICE_TABLE(pci
, emu_tbl
);
43 static int emu_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
46 struct gameport
*port
;
49 emu
= kzalloc(sizeof(struct emu
), GFP_KERNEL
);
50 port
= gameport_allocate_port();
52 printk(KERN_ERR
"emu10k1-gp: Memory allocation failed\n");
57 error
= pci_enable_device(pdev
);
61 emu
->io
= pci_resource_start(pdev
, 0);
62 emu
->size
= pci_resource_len(pdev
, 0);
67 gameport_set_name(port
, "EMU10K1");
68 gameport_set_phys(port
, "pci%s/gameport0", pci_name(pdev
));
69 port
->dev
.parent
= &pdev
->dev
;
72 if (!request_region(emu
->io
, emu
->size
, "emu10k1-gp")) {
73 printk(KERN_ERR
"emu10k1-gp: unable to grab region 0x%x-0x%x\n",
74 emu
->io
, emu
->io
+ emu
->size
- 1);
76 goto err_out_disable_dev
;
79 pci_set_drvdata(pdev
, emu
);
81 gameport_register_port(port
);
86 pci_disable_device(pdev
);
88 gameport_free_port(port
);
93 static void emu_remove(struct pci_dev
*pdev
)
95 struct emu
*emu
= pci_get_drvdata(pdev
);
97 gameport_unregister_port(emu
->gameport
);
98 release_region(emu
->io
, emu
->size
);
101 pci_disable_device(pdev
);
104 static struct pci_driver emu_driver
= {
105 .name
= "Emu10k1_gameport",
108 .remove
= emu_remove
,
111 module_pci_driver(emu_driver
);