summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ic/opl.c61
-rw-r--r--sys/dev/ic/oplvar.h4
-rw-r--r--sys/dev/isa/opl_ess.c12
-rw-r--r--sys/dev/isa/opl_sb.c12
-rw-r--r--sys/dev/pci/opl_cmpci.c14
-rw-r--r--sys/dev/pci/opl_yds.c12
6 files changed, 70 insertions, 45 deletions
diff --git a/sys/dev/ic/opl.c b/sys/dev/ic/opl.c
index c18530ab414..f5cecaf520d 100644
--- a/sys/dev/ic/opl.c
+++ b/sys/dev/ic/opl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opl.c,v 1.7 2005/11/21 18:16:39 millert Exp $ */
+/* $OpenBSD: opl.c,v 1.8 2006/07/27 05:55:00 miod Exp $ */
/* $NetBSD: opl.c,v 1.7 1998/12/08 14:26:56 augustss Exp $ */
/*
@@ -107,6 +107,7 @@ const struct opl_voice voicetab[] = {
{ 8, OPL_R, {0x12, 0x15, 0x00, 0x00}}
};
+static void opl_probe_command(struct opl_attach_arg *, int, int);
static void opl_command(struct opl_softc *, int, int, int);
void opl_reset(struct opl_softc *);
void opl_freq_to_fnum (int freq, int *block, int *fnum);
@@ -152,8 +153,14 @@ opl_attach(sc)
struct opl_softc *sc;
{
int i;
+ struct opl_attach_arg oaa;
- if (!opl_find(sc)) {
+ oaa.iot = sc->iot;
+ oaa.ioh = sc->ioh;
+ oaa.offs = sc->offs;
+ oaa.done = 0;
+
+ if ((sc->model = opl_find(&oaa)) == 0) {
printf("\nopl: find failed\n");
return;
}
@@ -178,6 +185,21 @@ opl_attach(sc)
}
static void
+opl_probe_command(oaa, addr, data)
+ struct opl_attach_arg *oaa;
+ int addr, data;
+{
+ DPRINTFN(4, ("opl_probe_command: addr=0x%02x data=0x%02x\n",
+ addr, data));
+ bus_space_write_1(oaa->iot, oaa->ioh, OPL_ADDR + OPL_L + oaa->offs,
+ addr);
+ delay(10);
+ bus_space_write_1(oaa->iot, oaa->ioh, OPL_DATA + OPL_L + oaa->offs,
+ data);
+ delay(30);
+}
+
+static void
opl_command(sc, offs, addr, data)
struct opl_softc *sc;
int offs;
@@ -199,34 +221,37 @@ opl_command(sc, offs, addr, data)
}
int
-opl_find(sc)
- struct opl_softc *sc;
+opl_find(oaa)
+ struct opl_attach_arg *oaa;
{
u_int8_t status1, status2;
+ int model;
- DPRINTFN(2,("opl_find: ioh=0x%x\n", (int)sc->ioh));
- sc->model = OPL_2; /* worst case assumption */
+ DPRINTFN(2,("opl_find: ioh=0x%x\n", (int)oaa->ioh));
+ model = OPL_2; /* worst case assumption */
/* Reset timers 1 and 2 */
- opl_command(sc, OPL_L, OPL_TIMER_CONTROL,
+ opl_probe_command(oaa, OPL_TIMER_CONTROL,
OPL_TIMER1_MASK | OPL_TIMER2_MASK);
/* Reset the IRQ of the FM chip */
- opl_command(sc, OPL_L, OPL_TIMER_CONTROL, OPL_IRQ_RESET);
+ opl_probe_command(oaa, OPL_TIMER_CONTROL, OPL_IRQ_RESET);
/* get status bits */
- status1 = bus_space_read_1(sc->iot,sc->ioh,OPL_STATUS+OPL_L+sc->offs);
+ status1 = bus_space_read_1(oaa->iot, oaa->ioh,
+ OPL_STATUS + OPL_L + oaa->offs);
- opl_command(sc, OPL_L, OPL_TIMER1, -2); /* wait 2 ticks */
- opl_command(sc, OPL_L, OPL_TIMER_CONTROL, /* start timer1 */
+ opl_probe_command(oaa, OPL_TIMER1, -2); /* wait 2 ticks */
+ opl_probe_command(oaa, OPL_TIMER_CONTROL, /* start timer1 */
OPL_TIMER1_START | OPL_TIMER2_MASK);
delay(1000); /* wait for timer to expire */
/* get status bits again */
- status2 = bus_space_read_1(sc->iot,sc->ioh,OPL_STATUS+OPL_L+sc->offs);
+ status2 = bus_space_read_1(oaa->iot, oaa->ioh,
+ OPL_STATUS + OPL_L + oaa->offs);
- opl_command(sc, OPL_L, OPL_TIMER_CONTROL,
+ opl_probe_command(oaa, OPL_TIMER_CONTROL,
OPL_TIMER1_MASK | OPL_TIMER2_MASK);
- opl_command(sc, OPL_L, OPL_TIMER_CONTROL, OPL_IRQ_RESET);
+ opl_probe_command(oaa, OPL_TIMER_CONTROL, OPL_IRQ_RESET);
DPRINTFN(2,("opl_find: %02x %02x\n", status1, status2));
@@ -237,18 +262,18 @@ opl_find(sc)
switch(status1) {
case 0x00:
case 0x0f:
- sc->model = OPL_3;
+ model = OPL_3;
break;
case 0x06:
- sc->model = OPL_2;
+ model = OPL_2;
break;
default:
return 0;
}
DPRINTFN(2,("opl_find: OPL%d at 0x%x detected\n",
- sc->model, (int)sc->ioh));
- return (1);
+ model, (int)oaa->ioh));
+ return (model);
}
void
diff --git a/sys/dev/ic/oplvar.h b/sys/dev/ic/oplvar.h
index 341778b16c2..32f350ae175 100644
--- a/sys/dev/ic/oplvar.h
+++ b/sys/dev/ic/oplvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: oplvar.h,v 1.3 2002/03/14 01:26:55 millert Exp $ */
+/* $OpenBSD: oplvar.h,v 1.4 2006/07/27 05:55:00 miod Exp $ */
/* $NetBSD: oplvar.h,v 1.3 1998/11/25 22:17:06 augustss Exp $ */
/*
@@ -88,5 +88,5 @@ struct opl_operators {
extern const struct opl_operators opl2_instrs[];
extern const struct opl_operators opl3_instrs[];
-int opl_find(struct opl_softc *);
+int opl_find(struct opl_attach_arg *);
void opl_attach(struct opl_softc *);
diff --git a/sys/dev/isa/opl_ess.c b/sys/dev/isa/opl_ess.c
index 8e1ba457f0a..42c5bc1fca9 100644
--- a/sys/dev/isa/opl_ess.c
+++ b/sys/dev/isa/opl_ess.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opl_ess.c,v 1.4 2005/11/21 18:16:40 millert Exp $ */
+/* $OpenBSD: opl_ess.c,v 1.5 2006/07/27 05:55:03 miod Exp $ */
/* $NetBSD: opl_ess.c,v 1.3 1998/12/08 14:26:57 augustss Exp $ */
/*
@@ -75,14 +75,14 @@ opl_ess_match(parent, match, aux)
{
struct audio_attach_args *aa = (struct audio_attach_args *)aux;
struct ess_softc *ssc = (struct ess_softc *)parent;
- struct opl_softc sc;
+ struct opl_attach_arg oaa;
if (aa->type != AUDIODEV_TYPE_OPL)
return (0);
- memset(&sc, 0, sizeof sc);
- sc.ioh = ssc->sc_ioh;
- sc.iot = ssc->sc_iot;
- return (opl_find(&sc));
+ memset(&oaa, 0, sizeof oaa);
+ oaa.ioh = ssc->sc_ioh;
+ oaa.iot = ssc->sc_iot;
+ return (opl_find(&oaa));
}
void
diff --git a/sys/dev/isa/opl_sb.c b/sys/dev/isa/opl_sb.c
index bf8d38ba907..78d35b19ac9 100644
--- a/sys/dev/isa/opl_sb.c
+++ b/sys/dev/isa/opl_sb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opl_sb.c,v 1.5 2006/01/02 05:21:40 brad Exp $ */
+/* $OpenBSD: opl_sb.c,v 1.6 2006/07/27 05:55:03 miod Exp $ */
/* $NetBSD: opl_sb.c,v 1.4 1998/12/08 14:26:57 augustss Exp $ */
/*
@@ -74,14 +74,14 @@ opl_sb_match(parent, match, aux)
{
struct audio_attach_args *aa = (struct audio_attach_args *)aux;
struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent;
- struct opl_softc sc;
+ struct opl_attach_arg oaa;
if (aa->type != AUDIODEV_TYPE_OPL)
return (0);
- memset(&sc, 0, sizeof sc);
- sc.ioh = ssc->sc_ioh;
- sc.iot = ssc->sc_iot;
- return (opl_find(&sc));
+ memset(&oaa, 0, sizeof oaa);
+ oaa.ioh = ssc->sc_ioh;
+ oaa.iot = ssc->sc_iot;
+ return (opl_find(&oaa));
}
void
diff --git a/sys/dev/pci/opl_cmpci.c b/sys/dev/pci/opl_cmpci.c
index ae867ede6d0..f58b303eed3 100644
--- a/sys/dev/pci/opl_cmpci.c
+++ b/sys/dev/pci/opl_cmpci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opl_cmpci.c,v 1.1 2006/07/27 00:45:59 brad Exp $ */
+/* $OpenBSD: opl_cmpci.c,v 1.2 2006/07/27 05:55:03 miod Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -77,15 +77,15 @@ opl_cmpci_match(struct device *parent, void *match, void *aux)
{
struct audio_attach_args *aa = (struct audio_attach_args *)aux;
struct cmpci_softc *ssc = (struct cmpci_softc *)parent;
- struct opl_softc sc;
+ struct opl_attach_args oaa;
if (aa->type != AUDIODEV_TYPE_OPL)
return (0);
- memset(&sc, 0, sizeof sc);
- sc.iot = ssc->sc_iot;
- sc.ioh = ssc->sc_ioh;
- sc.offs = CMPCI_REG_FM_BASE;
- return (opl_find(&sc));
+ memset(&oaa, 0, sizeof oaa);
+ oaa.iot = ssc->sc_iot;
+ oaa.ioh = ssc->sc_ioh;
+ oaa.offs = CMPCI_REG_FM_BASE;
+ return (opl_find(&oaa));
}
void
diff --git a/sys/dev/pci/opl_yds.c b/sys/dev/pci/opl_yds.c
index 4f378779d7a..0e0fa685b93 100644
--- a/sys/dev/pci/opl_yds.c
+++ b/sys/dev/pci/opl_yds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opl_yds.c,v 1.5 2005/11/21 18:16:41 millert Exp $ */
+/* $OpenBSD: opl_yds.c,v 1.6 2006/07/27 05:55:03 miod Exp $ */
/* $NetBSD$ */
/*
@@ -82,14 +82,14 @@ opl_yds_match(parent, match, aux)
{
struct audio_attach_args *aa = (struct audio_attach_args *)aux;
struct yds_softc *ssc = (struct yds_softc *)parent;
- struct opl_softc sc;
+ struct opl_attach_arg oaa;
if (aa->type != AUDIODEV_TYPE_OPL)
return (0);
- memset(&sc, 0, sizeof sc);
- sc.iot = ssc->sc_opl_iot;
- sc.ioh = ssc->sc_opl_ioh;
- return (opl_find(&sc));
+ memset(&oaa, 0, sizeof oaa);
+ oaa.iot = ssc->sc_opl_iot;
+ oaa.ioh = ssc->sc_opl_ioh;
+ return (opl_find(&oaa));
}
void