2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2001 Vojtech Pavlik
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EMU10k1 - SB Live / Audigy - gameport driver for Linux
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/gameport.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
|
|
|
|
MODULE_DESCRIPTION("EMU10k1 gameport driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
struct emu {
|
|
|
|
struct pci_dev *dev;
|
|
|
|
struct gameport *gameport;
|
|
|
|
int io;
|
|
|
|
int size;
|
|
|
|
};
|
|
|
|
|
2010-01-10 15:23:58 +08:00
|
|
|
static const struct pci_device_id emu_tbl[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
{ 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
|
|
|
|
{ 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
|
|
|
|
{ 0x1102, 0x7004, PCI_ANY_ID, PCI_ANY_ID }, /* Dell SB Live */
|
|
|
|
{ 0x1102, 0x7005, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy LS gameport */
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, emu_tbl);
|
|
|
|
|
2012-11-24 13:38:25 +08:00
|
|
|
static int emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct emu *emu;
|
|
|
|
struct gameport *port;
|
2010-09-30 09:50:17 +08:00
|
|
|
int error;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:18:33 +08:00
|
|
|
emu = kzalloc(sizeof(struct emu), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
port = gameport_allocate_port();
|
|
|
|
if (!emu || !port) {
|
|
|
|
printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");
|
2010-09-30 09:50:17 +08:00
|
|
|
error = -ENOMEM;
|
|
|
|
goto err_out_free;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-09-30 09:50:17 +08:00
|
|
|
error = pci_enable_device(pdev);
|
|
|
|
if (error)
|
|
|
|
goto err_out_free;
|
|
|
|
|
|
|
|
emu->io = pci_resource_start(pdev, 0);
|
|
|
|
emu->size = pci_resource_len(pdev, 0);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
emu->dev = pdev;
|
|
|
|
emu->gameport = port;
|
|
|
|
|
|
|
|
gameport_set_name(port, "EMU10K1");
|
|
|
|
gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev));
|
|
|
|
port->dev.parent = &pdev->dev;
|
2010-09-30 09:50:17 +08:00
|
|
|
port->io = emu->io;
|
|
|
|
|
|
|
|
if (!request_region(emu->io, emu->size, "emu10k1-gp")) {
|
|
|
|
printk(KERN_ERR "emu10k1-gp: unable to grab region 0x%x-0x%x\n",
|
|
|
|
emu->io, emu->io + emu->size - 1);
|
|
|
|
error = -EBUSY;
|
|
|
|
goto err_out_disable_dev;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
pci_set_drvdata(pdev, emu);
|
|
|
|
|
|
|
|
gameport_register_port(port);
|
|
|
|
|
|
|
|
return 0;
|
2010-09-30 09:50:17 +08:00
|
|
|
|
|
|
|
err_out_disable_dev:
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
err_out_free:
|
|
|
|
gameport_free_port(port);
|
|
|
|
kfree(emu);
|
|
|
|
return error;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-11-24 13:50:47 +08:00
|
|
|
static void emu_remove(struct pci_dev *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct emu *emu = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
gameport_unregister_port(emu->gameport);
|
|
|
|
release_region(emu->io, emu->size);
|
|
|
|
kfree(emu);
|
2010-09-30 09:17:16 +08:00
|
|
|
|
|
|
|
pci_disable_device(pdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_driver emu_driver = {
|
|
|
|
.name = "Emu10k1_gameport",
|
|
|
|
.id_table = emu_tbl,
|
|
|
|
.probe = emu_probe,
|
2012-11-24 13:27:39 +08:00
|
|
|
.remove = emu_remove,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2012-04-22 14:37:53 +08:00
|
|
|
module_pci_driver(emu_driver);
|