Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Jan 1998 07:25:57 -0800 (PST)
From:      ohashi@mickey.ai.kyutech.ac.jp
To:        freebsd-gnats-submit@FreeBSD.ORG
Subject:   i386/5559: PC-Card joystick ports were not supported by joy.c.
Message-ID:  <199801241525.HAA16927@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         5559
>Category:       i386
>Synopsis:       PC-Card joystick ports were not supported by joy.c.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 24 07:30:00 PST 1998
>Last-Modified:
>Originator:     Takeshi OHASHI
>Organization:
Kyushu Institute of Technology
>Release:        FreeBSD-2.2.5-RELEASE + PAO package
>Environment:
FreeBSD atohasi.mickey.ai.kyutech.ac.jp 2.2.5-RELEASE FreeBSD 2.2.5-RELEASE #1: Fri Jan 23 16:59:43 JST 1998     ohashi@atohasi.mickey.ai.kyutech.ac.jp:/usr/src/sys/compile/atohasi  i386

>Description:
Please change joy.c as the following patches. This patch can support
PC-Card type joystick/game ports. I tested one of them I-O DATA JOYPC.
I think the patch would be also work for FreeBSD-current.
>How-To-Repeat:

>Fix:
Appending /etc/pccard.conf entory
==============================================================
#-----------------------------------------------------------------------
# Joystick Port Cards
#-----------------------------------------------------------------------
card    "IO DATA" "PCJOY"
        config  default "joy0" pio
#       config  0x1 "joy0" pio
#       config  0x2 "joy0" pio
        insert  echo IO DATA PCJOY inserted
        remove  echo IO DATA PCJOY removed
==============================================================

patch for joy.c
diff -u sys/i386/isa/joy.c.orig sys/i386/isa/joy.c
--- sys/i386/isa/joy.c.orig     Tue Sep 10 17:21:59 1996
+++ sys/i386/isa/joy.c  Wed Jan 21 13:32:56 1998
@@ -46,6 +46,16 @@
 #include <i386/isa/isa_device.h>
 #include <i386/isa/timerreg.h>
 
+/*********************************************************/
+#include "crd.h"
+#if NCRD > 0
+#include <sys/select.h>
+#include <pccard/card.h>
+#include <pccard/driver.h>
+#include <pccard/slot.h>
+#endif
+/*********************************************************/
+
 /* The game port can manage 4 buttons and 4 variable resistors (usually 2
  * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201.
  * Getting the state of the buttons is done by reading the game port:
@@ -97,6 +107,105 @@
 
 static int get_tick __P((void));
 
+/*********************************************************/
+#if NCRD > 0
+/*
+ *      PC-Card (PCMCIA) specific code.
+ */
+static int  joy_card_intr(struct pccard_dev *);       /* Interrupt handler */
+static void joy_card_unload(struct pccard_dev *);     /* Disable driver */
+static void joy_card_suspend(struct pccard_dev *);    /* Suspend driver */
+static int  joy_card_init(struct pccard_dev *, int);  /* init device */
+
+static struct pccard_drv joy_info = {
+        "joy",
+        joy_card_intr,
+        joy_card_unload,
+        joy_card_suspend,
+        joy_card_init,
+        0,                      /* Attributes - presently unused */
+        &bio_imask              /* Interrupt mask for device */
+                                /* XXX - Should this also include net_imask? */
+};
+
+DATA_SET(pccarddrv_set, joy_info);
+
+static int pccard_mode[NJOY];
+/*
+ *      Called when a power down is requested. Shuts down the
+ *      device and configures the device as unavailable (but
+ *      still loaded...). A resume is done by calling
+ *      joyinit with first=0. This is called when the user suspends
+ *      the system, or the APM code suspends the system.
+ */
+static void
+joy_card_suspend(struct pccard_dev *dp)
+{
+        printf("joy%d: suspending\n", dp->isahd.id_unit);
+}
+
+/*
+ *      Initialize the device - called from Slot manager.
+ *      If first is set, then check for the device's existence
+ *      before initializing it.  Once initialized, the device table may
+ *      be set up.
+ */
+int
+joy_card_init(struct pccard_dev *dp, int first)
+{
+        int     unit = dp->isahd.id_unit;
+        /* validate unit number. */
+        if (first) {
+                if (unit >= NJOY)
+                        return(ENODEV);
+                pccard_mode[unit] = 1;
+                /*
+                 * Probe the device. If a value is returned, the
+                 * device was found at the location.
+                 */
+                if (joyprobe(&dp->isahd)==0)
+                        return(ENXIO);
+                if (joyattach(&dp->isahd)==0)
+                        return(ENXIO);
+        }
+        /*
+         * XXX TODO:
+         * If it was initialized before, the device structure
+         * should also be initialized.  We should
+         * reset (and possibly restart) the hardware, but
+         * I am not sure of the best way to do this...
+         */
+        return(0);
+}
+
+/*
+ *      joy_card_unload - unload the driver and clear the table.
+ *      XXX TODO:
+ *      This is usually called when the card is ejected, but
+ *      can be caused by a modunload of a controller driver.
+ *      The idea is to reset the driver's view of the device
+ *      and ensure that any driver entry points such as
+ *      read and write do not hang.
+ */
+static void
+joy_card_unload(struct pccard_dev *dp)
+{
+    int unit = dp->isahd.id_unit;
+
+    pccard_mode[unit] = 0;
+}
+
+/*
+ *      card_intr - Shared interrupt called from
+ *      front end of PC-Card handler.
+ */
+static int
+joy_card_intr(struct pccard_dev *dp)
+{
+        return(1);
+}
+#endif /* NCRD > 0 */
+/*********************************************************/
 
 static int
 joyprobe (struct isa_device *dev)
==============================================================
 

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801241525.HAA16927>