Remove something like counters.

- Counting {open,close} is done by the MI audio layer.
- trigger_* is not called again between trigger_* and halt_*.
This commit is contained in:
isaki 2021-02-06 09:15:11 +00:00
parent bc9fc63318
commit e5d4bf8933
2 changed files with 11 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbri.c,v 1.43 2020/08/25 13:36:41 skrll Exp $ */
/* $NetBSD: dbri.c,v 1.44 2021/02/06 09:15:11 isaki Exp $ */
/*
* Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de)
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.43 2020/08/25 13:36:41 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.44 2021/02/06 09:15:11 isaki Exp $");
#include "audio.h"
#if NAUDIO > 0
@ -368,7 +368,6 @@ dbri_attach_sbus(device_t parent, device_t self, void *aux)
sc->sc_locked = 0;
sc->sc_desc_used = 0;
sc->sc_refcount = 0;
sc->sc_playing = 0;
sc->sc_recording = 0;
sc->sc_init_done = 0;
@ -1894,8 +1893,7 @@ dbri_trigger_output(void *hdl, void *start, void *end, int blksize,
struct dbri_softc *sc = hdl;
unsigned long count, num;
if (sc->sc_playing)
return 0;
KASSERT(sc->sc_playing == 0);
count = (unsigned long)(((char *)end - (char *)start));
num = count / blksize;
@ -1937,8 +1935,7 @@ dbri_trigger_input(void *hdl, void *start, void *end, int blksize,
struct dbri_softc *sc = hdl;
unsigned long count, num;
if (sc->sc_recording)
return 0;
KASSERT(sc->sc_recording == 0);
count = (unsigned long)(((char *)end - (char *)start));
num = count / blksize;
@ -2051,14 +2048,9 @@ dbri_open(void *cookie, int flags)
{
struct dbri_softc *sc = cookie;
DPRINTF("%s: %d\n", __func__, sc->sc_refcount);
if (sc->sc_refcount == 0) {
dbri_bring_up(sc);
}
sc->sc_refcount++;
DPRINTF("%s\n", __func__);
dbri_bring_up(sc);
return 0;
}
@ -2067,16 +2059,11 @@ dbri_close(void *cookie)
{
struct dbri_softc *sc = cookie;
DPRINTF("%s: %d\n", __func__, sc->sc_refcount);
sc->sc_refcount--;
KASSERT(sc->sc_refcount >= 0);
if (sc->sc_refcount > 0)
return;
DPRINTF("%s\n", __func__);
KASSERT(sc->sc_playing == 0);
KASSERT(sc->sc_recording == 0);
dbri_set_power(sc, 0);
sc->sc_playing = 0;
sc->sc_recording = 0;
}
static bool
@ -2097,7 +2084,7 @@ dbri_resume(device_t self, const pmf_qual_t *qual)
if (sc->sc_powerstate != 0)
return true;
aprint_verbose("resume: %d\n", sc->sc_refcount);
aprint_verbose("resume\n");
if (sc->sc_playing) {
volatile uint32_t *cmd;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbrivar.h,v 1.16 2019/05/08 13:40:19 isaki Exp $ */
/* $NetBSD: dbrivar.h,v 1.17 2021/02/06 09:15:11 isaki Exp $ */
/*
* Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de)
@ -140,7 +140,6 @@ struct dbri_softc {
int sc_waitseen;
int sc_refcount;
int sc_playing;
int sc_recording;