support the game port on eap1371
This is only usable with some caution because these soundcards only allow to map IO port 0x20x for this, thus bypassing PCI address management. Very likely this will only work on primary PCI buses, and there is some potential for conflicts with ISA devices as well. (XXX cannot be detached because the "joy" driver doesn't support it yet)
This commit is contained in:
parent
7cd90d66b7
commit
315673e79a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: eap.c,v 1.68 2004/04/23 21:13:06 itojun Exp $ */
|
||||
/* $NetBSD: eap.c,v 1.69 2004/07/08 19:39:00 drochner Exp $ */
|
||||
/* $OpenBSD: eap.c,v 1.6 1999/10/05 19:24:42 csapuntz Exp $ */
|
||||
|
||||
/*
|
||||
@ -57,9 +57,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: eap.c,v 1.68 2004/04/23 21:13:06 itojun Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: eap.c,v 1.69 2004/07/08 19:39:00 drochner Exp $");
|
||||
|
||||
#include "midi.h"
|
||||
#include "joy_eap.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -84,6 +85,7 @@ __KERNEL_RCSID(0, "$NetBSD: eap.c,v 1.68 2004/04/23 21:13:06 itojun Exp $");
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/pci/eapreg.h>
|
||||
#include <dev/pci/eapvar.h>
|
||||
|
||||
#define PCI_CBIO 0x10
|
||||
|
||||
@ -156,6 +158,9 @@ struct eap_softc {
|
||||
void *sc_arg;
|
||||
struct device *sc_mididev;
|
||||
#endif
|
||||
#if NJOY_EAP > 0
|
||||
struct device *sc_gameport;
|
||||
#endif
|
||||
|
||||
u_short sc_port[AK_NPORTS]; /* mirror of the hardware setting */
|
||||
u_int sc_record_source; /* recording source mask */
|
||||
@ -585,6 +590,9 @@ eap_attach(struct device *parent, struct device *self, void *aux)
|
||||
int i;
|
||||
int revision, ct5880;
|
||||
const char *revstr = "";
|
||||
#if NJOY_EAP > 0
|
||||
struct eap_gameport_args gpargs;
|
||||
#endif
|
||||
|
||||
aprint_naive(": Audio controller\n");
|
||||
|
||||
@ -793,13 +801,29 @@ eap_attach(struct device *parent, struct device *self, void *aux)
|
||||
#if NMIDI > 0
|
||||
sc->sc_mididev = midi_attach_mi(&eap_midi_hw_if, sc, &sc->sc_dev);
|
||||
#endif
|
||||
|
||||
#if NJOY_EAP > 0
|
||||
if (sc->sc_1371) {
|
||||
gpargs.gpa_iot = sc->iot;
|
||||
gpargs.gpa_ioh = sc->ioh;
|
||||
sc->sc_gameport = eap_joy_attach(&sc->sc_dev, &gpargs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
eap_detach(struct device *self, int flags)
|
||||
{
|
||||
struct eap_softc *sc = (struct eap_softc *) self;
|
||||
#if NJOY_EAP > 0
|
||||
struct eap_gameport_args gpargs;
|
||||
|
||||
if (sc->sc_gameport) {
|
||||
gpargs.gpa_iot = sc->iot;
|
||||
gpargs.gpa_ioh = sc->ioh;
|
||||
eap_joy_detach(sc->sc_gameport, &gpargs);
|
||||
}
|
||||
#endif
|
||||
#if NMIDI > 0
|
||||
if (sc->sc_mididev != NULL)
|
||||
config_detach(sc->sc_mididev, 0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: eapreg.h,v 1.7 2003/12/04 13:57:31 keihan Exp $ */
|
||||
/* $NetBSD: eapreg.h,v 1.8 2004/07/08 19:39:00 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
|
||||
@ -65,6 +65,8 @@
|
||||
#define EAP_SET_PCLKDIV(n) (((n)&0x1fff)<<16)
|
||||
#define EAP_GET_PCLKDIV(n) (((n)>>16)&0x1fff)
|
||||
#define EAP_PCLKBITS 0x1fff0000
|
||||
#define E1371_JOY_ASEL(n) (((n)&3)<<24)
|
||||
#define E1371_JOY_ASELBITS 0x03000000
|
||||
#define EAP_XTCL1 0x40000000
|
||||
#define EAP_ADC_STOP 0x80000000
|
||||
|
||||
|
9
sys/dev/pci/eapvar.h
Normal file
9
sys/dev/pci/eapvar.h
Normal file
@ -0,0 +1,9 @@
|
||||
/* $NetBSD: eapvar.h,v 1.1 2004/07/08 19:39:00 drochner Exp $ */
|
||||
|
||||
struct eap_gameport_args {
|
||||
bus_space_tag_t gpa_iot;
|
||||
bus_space_handle_t gpa_ioh;
|
||||
};
|
||||
|
||||
struct device *eap_joy_attach(struct device *, struct eap_gameport_args *);
|
||||
int eap_joy_detach(struct device *, struct eap_gameport_args *);
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.pci,v 1.212 2004/05/28 23:27:28 thorpej Exp $
|
||||
# $NetBSD: files.pci,v 1.213 2004/07/08 19:39:00 drochner Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent PCI code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
@ -388,10 +388,13 @@ attach mpu at fms with mpu_fms
|
||||
file dev/pci/mpu_fms.c mpu_fms
|
||||
|
||||
# Ensoniq AudioPCI S5016
|
||||
device eap: audiobus, auconv, mulaw, ac97, midibus
|
||||
device eap { }: audiobus, auconv, mulaw, ac97, midibus
|
||||
attach eap at pci
|
||||
file dev/pci/eap.c eap
|
||||
|
||||
attach joy at eap with joy_eap
|
||||
file dev/pci/joy_eap.c joy_eap needs-flag
|
||||
|
||||
# Intel ICH AC'97 audio
|
||||
device auich: audiobus, auconv, mulaw, ac97, aurateconv
|
||||
attach auich at pci
|
||||
|
124
sys/dev/pci/joy_eap.c
Normal file
124
sys/dev/pci/joy_eap.c
Normal file
@ -0,0 +1,124 @@
|
||||
/* $NetBSD: joy_eap.c,v 1.1 2004/07/08 19:39:00 drochner Exp $ */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/audioio.h>
|
||||
#include <dev/audio_if.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/pci/eapreg.h>
|
||||
#include <dev/pci/eapvar.h>
|
||||
#include <dev/ic/joyvar.h>
|
||||
|
||||
int joy_eap_match(struct device *, struct cfdata *, void *);
|
||||
void joy_eap_attach(struct device *, struct device *, void *);
|
||||
int joy_eap_detach(struct device *, int);
|
||||
|
||||
CFATTACH_DECL(joy_eap, sizeof (struct joy_softc),
|
||||
joy_eap_match, joy_eap_attach, joy_eap_detach, NULL);
|
||||
|
||||
struct joy_eap_aa {
|
||||
struct audio_attach_args aa_aaa;
|
||||
bus_space_tag_t aa_iot;
|
||||
bus_space_handle_t aa_ioh;
|
||||
};
|
||||
|
||||
struct device *
|
||||
eap_joy_attach(struct device *eapdev, struct eap_gameport_args *gpa)
|
||||
{
|
||||
int i;
|
||||
bus_space_handle_t ioh;
|
||||
u_int32_t icsc;
|
||||
struct joy_eap_aa aa;
|
||||
struct device *joydev;
|
||||
|
||||
/*
|
||||
* There are 4 possible locations. Just try to map one of them.
|
||||
* XXX This is questionable for 2 reasons:
|
||||
* - We don't know whether these addresses are usable on our
|
||||
* PCI bus (might be a secondary one).
|
||||
* - PCI probing is early. ISA devices might conflict.
|
||||
*/
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (bus_space_map(gpa->gpa_iot, 0x200 + i * 8, 1,
|
||||
0, &ioh) == 0)
|
||||
break;
|
||||
}
|
||||
if (i == 4)
|
||||
return (0);
|
||||
|
||||
printf("%s: enabling gameport at legacy io port 0x%x\n",
|
||||
eapdev->dv_xname, 0x200 + i * 8);
|
||||
|
||||
/* enable gameport on eap */
|
||||
icsc = bus_space_read_4(gpa->gpa_iot, gpa->gpa_ioh, EAP_ICSC);
|
||||
icsc &= ~E1371_JOY_ASELBITS;
|
||||
icsc |= EAP_JYSTK_EN | E1371_JOY_ASEL(i);
|
||||
bus_space_write_4(gpa->gpa_iot, gpa->gpa_ioh, EAP_ICSC, icsc);
|
||||
|
||||
aa.aa_aaa.type = AUDIODEV_TYPE_AUX;
|
||||
aa.aa_iot = gpa->gpa_iot;
|
||||
aa.aa_ioh = ioh;
|
||||
joydev = config_found(eapdev, &aa, 0);
|
||||
/* this cannot fail */
|
||||
KASSERT(joydev != NULL);
|
||||
|
||||
return (joydev);
|
||||
}
|
||||
|
||||
int
|
||||
eap_joy_detach(struct device *joydev, struct eap_gameport_args *gpa)
|
||||
{
|
||||
int res;
|
||||
struct joy_softc *sc = (struct joy_softc *)joydev;
|
||||
u_int32_t icsc;
|
||||
|
||||
res = config_detach(joydev, 0);
|
||||
if (res)
|
||||
return (res);
|
||||
|
||||
/* disable gameport on eap */
|
||||
icsc = bus_space_read_4(gpa->gpa_iot, gpa->gpa_ioh, EAP_ICSC);
|
||||
icsc &= ~EAP_JYSTK_EN;
|
||||
bus_space_write_4(gpa->gpa_iot, gpa->gpa_ioh, EAP_ICSC, icsc);
|
||||
|
||||
bus_space_unmap(sc->sc_iot, sc->sc_ioh, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
joy_eap_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct joy_eap_aa *eaa = aux;
|
||||
|
||||
if (eaa->aa_aaa.type != AUDIODEV_TYPE_AUX)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
joy_eap_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct joy_softc *sc = (struct joy_softc *)self;
|
||||
struct joy_eap_aa *eaa = aux;
|
||||
|
||||
printf("\n");
|
||||
|
||||
sc->sc_iot = eaa->aa_iot;
|
||||
sc->sc_ioh = eaa->aa_ioh;
|
||||
|
||||
joyattach(sc);
|
||||
}
|
||||
|
||||
int
|
||||
joy_eap_detach(struct device *self, int flags)
|
||||
{
|
||||
|
||||
#ifdef notyet
|
||||
return (joydetach((struct joy_softc *)self));
|
||||
#else
|
||||
return (EBUSY);
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user