···4949 To compile this driver as a module, choose M here: the5050 module will be called emu10k1-gp.51515252-config GAMEPORT_VORTEX5353- tristate "Aureal Vortex, Vortex 2 gameport support"5454- depends on PCI5555- help5656- Say Y here if you have an Aureal Vortex 1 or 2 card and want5757- to use its gameport.5858-5959- To compile this driver as a module, choose M here: the6060- module will be called vortex.6161-6252config GAMEPORT_FM8016353 tristate "ForteMedia FM801 gameport support"6454 depends on PCI
···11-/*22- * $Id: vortex.c,v 1.5 2002/07/01 15:39:30 vojtech Exp $33- *44- * Copyright (c) 2000-2001 Vojtech Pavlik55- *66- * Based on the work of:77- * Raymond Ingles88- */99-1010-/*1111- * Trident 4DWave and Aureal Vortex gameport driver for Linux1212- */1313-1414-/*1515- * This program is free software; you can redistribute it and/or modify1616- * it under the terms of the GNU General Public License as published by1717- * the Free Software Foundation; either version 2 of the License, or1818- * (at your option) any later version.1919- *2020- * This program is distributed in the hope that it will be useful,2121- * but WITHOUT ANY WARRANTY; without even the implied warranty of2222- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2323- * GNU General Public License for more details.2424- *2525- * You should have received a copy of the GNU General Public License2626- * along with this program; if not, write to the Free Software2727- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2828- *2929- * Should you need to contact me, the author, you can do so either by3030- * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:3131- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic3232- */3333-3434-#include <asm/io.h>3535-#include <linux/delay.h>3636-#include <linux/errno.h>3737-#include <linux/ioport.h>3838-#include <linux/kernel.h>3939-#include <linux/module.h>4040-#include <linux/pci.h>4141-#include <linux/init.h>4242-#include <linux/slab.h>4343-#include <linux/delay.h>4444-#include <linux/gameport.h>4545-4646-MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");4747-MODULE_DESCRIPTION("Aureal Vortex and Vortex2 gameport driver");4848-MODULE_LICENSE("GPL");4949-5050-#define VORTEX_GCR 0x0c /* Gameport control register */5151-#define VORTEX_LEG 0x08 /* Legacy port location */5252-#define VORTEX_AXD 0x10 /* Axes start */5353-#define VORTEX_DATA_WAIT 20 /* 20 ms */5454-5555-struct vortex {5656- struct gameport *gameport;5757- struct pci_dev *dev;5858- unsigned char __iomem *base;5959- unsigned char __iomem *io;6060-};6161-6262-static unsigned char vortex_read(struct gameport *gameport)6363-{6464- struct vortex *vortex = gameport->port_data;6565- return readb(vortex->io + VORTEX_LEG);6666-}6767-6868-static void vortex_trigger(struct gameport *gameport)6969-{7070- struct vortex *vortex = gameport->port_data;7171- writeb(0xff, vortex->io + VORTEX_LEG);7272-}7373-7474-static int vortex_cooked_read(struct gameport *gameport, int *axes, int *buttons)7575-{7676- struct vortex *vortex = gameport->port_data;7777- int i;7878-7979- *buttons = (~readb(vortex->base + VORTEX_LEG) >> 4) & 0xf;8080-8181- for (i = 0; i < 4; i++) {8282- axes[i] = readw(vortex->io + VORTEX_AXD + i * sizeof(u32));8383- if (axes[i] == 0x1fff) axes[i] = -1;8484- }8585-8686- return 0;8787-}8888-8989-static int vortex_open(struct gameport *gameport, int mode)9090-{9191- struct vortex *vortex = gameport->port_data;9292-9393- switch (mode) {9494- case GAMEPORT_MODE_COOKED:9595- writeb(0x40, vortex->io + VORTEX_GCR);9696- msleep(VORTEX_DATA_WAIT);9797- return 0;9898- case GAMEPORT_MODE_RAW:9999- writeb(0x00, vortex->io + VORTEX_GCR);100100- return 0;101101- default:102102- return -1;103103- }104104-105105- return 0;106106-}107107-108108-static int __devinit vortex_probe(struct pci_dev *dev, const struct pci_device_id *id)109109-{110110- struct vortex *vortex;111111- struct gameport *port;112112- int i;113113-114114- vortex = kcalloc(1, sizeof(struct vortex), GFP_KERNEL);115115- port = gameport_allocate_port();116116- if (!vortex || !port) {117117- printk(KERN_ERR "vortex: Memory allocation failed.\n");118118- kfree(vortex);119119- gameport_free_port(port);120120- return -ENOMEM;121121- }122122-123123- for (i = 0; i < 6; i++)124124- if (~pci_resource_flags(dev, i) & IORESOURCE_IO)125125- break;126126-127127- pci_enable_device(dev);128128-129129- vortex->dev = dev;130130- vortex->gameport = port;131131- vortex->base = ioremap(pci_resource_start(vortex->dev, i),132132- pci_resource_len(vortex->dev, i));133133- vortex->io = vortex->base + id->driver_data;134134-135135- pci_set_drvdata(dev, vortex);136136-137137- port->port_data = vortex;138138- port->fuzz = 64;139139-140140- gameport_set_name(port, "AU88x0");141141- gameport_set_phys(port, "pci%s/gameport0", pci_name(dev));142142- port->dev.parent = &dev->dev;143143- port->read = vortex_read;144144- port->trigger = vortex_trigger;145145- port->cooked_read = vortex_cooked_read;146146- port->open = vortex_open;147147-148148- gameport_register_port(port);149149-150150- return 0;151151-}152152-153153-static void __devexit vortex_remove(struct pci_dev *dev)154154-{155155- struct vortex *vortex = pci_get_drvdata(dev);156156-157157- gameport_unregister_port(vortex->gameport);158158- iounmap(vortex->base);159159- kfree(vortex);160160-}161161-162162-static struct pci_device_id vortex_id_table[] = {163163- { 0x12eb, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x11000 },164164- { 0x12eb, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x28800 },165165- { 0 }166166-};167167-168168-static struct pci_driver vortex_driver = {169169- .name = "vortex_gameport",170170- .id_table = vortex_id_table,171171- .probe = vortex_probe,172172- .remove = __devexit_p(vortex_remove),173173-};174174-175175-static int __init vortex_init(void)176176-{177177- return pci_register_driver(&vortex_driver);178178-}179179-180180-static void __exit vortex_exit(void)181181-{182182- pci_unregister_driver(&vortex_driver);183183-}184184-185185-module_init(vortex_init);186186-module_exit(vortex_exit);