Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Split the first special element from sc_audiochan list.
details: https://anonhg.NetBSD.org/src/rev/305b779a1854
branches: trunk
changeset: 826086:305b779a1854
user: isaki <isaki%NetBSD.org@localhost>
date: Tue Aug 15 04:42:56 2017 +0000
description:
Split the first special element from sc_audiochan list.
- This makes sc_audiochan a list of only open audio chan.
- "SIMPLEQ_FIRST(&sc->sc_audiochan)->vc" is now "sc->hwvc".
No functional changes (except one debug message).
diffstat:
sys/dev/audio.c | 168 ++++++++++++++++++----------------------------------
sys/dev/audiovar.h | 11 +-
2 files changed, 64 insertions(+), 115 deletions(-)
diffs (truncated from 612 to 300 lines):
diff -r 93e15907ab26 -r 305b779a1854 sys/dev/audio.c
--- a/sys/dev/audio.c Mon Aug 14 12:51:11 2017 +0000
+++ b/sys/dev/audio.c Tue Aug 15 04:42:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.393 2017/08/13 05:04:08 isaki Exp $ */
+/* $NetBSD: audio.c,v 1.394 2017/08/15 04:42:56 isaki Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.393 2017/08/13 05:04:08 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.394 2017/08/15 04:42:56 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -215,12 +215,12 @@
#endif
#define HW_LOCK(x) do { \
- if ((x) == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc) \
+ if ((x) == sc->sc_hwvc) \
mutex_enter(sc->sc_intr_lock); \
} while (0)
#define HW_UNLOCK(x) do { \
- if ((x) == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc) \
+ if ((x) == sc->sc_hwvc) \
mutex_exit(sc->sc_intr_lock); \
} while (0)
@@ -284,7 +284,7 @@
struct audio_ringbuffer *, int);
int audio_initbufs(struct audio_softc *, struct virtual_channel *);
void audio_calcwater(struct audio_softc *, struct virtual_channel *);
-int audio_drain(struct audio_softc *, struct audio_chan *);
+int audio_drain(struct audio_softc *, struct virtual_channel *);
void audio_clear(struct audio_softc *, struct virtual_channel *);
void audio_clear_intr_unlocked(struct audio_softc *sc,
struct virtual_channel *);
@@ -481,7 +481,6 @@
struct audio_softc *sc;
struct audio_attach_args *sa;
struct virtual_channel *vc;
- struct audio_chan *chan;
const struct audio_hw_if *hwp;
const struct sysctlnode *node;
void *hdlp;
@@ -517,11 +516,10 @@
sc->sc_trigger_started = false;
sc->sc_rec_started = false;
sc->sc_dying = false;
- chan = kmem_zalloc(sizeof(struct audio_chan), KM_SLEEP);
+ SIMPLEQ_INIT(&sc->sc_audiochan);
+
vc = kmem_zalloc(sizeof(struct virtual_channel), KM_SLEEP);
- chan->vc = vc;
- SIMPLEQ_INIT(&sc->sc_audiochan);
- SIMPLEQ_INSERT_HEAD(&sc->sc_audiochan, chan, entries);
+ sc->sc_hwvc = vc;
vc->sc_open = 0;
vc->sc_mode = 0;
vc->sc_npfilters = 0;
@@ -930,12 +928,16 @@
audio_free_ring(sc, &chan->vc->sc_mpr);
audio_free_ring(sc, &chan->vc->sc_mrr);
}
+ audio_free_ring(sc, &sc->sc_hwvc->sc_mpr);
+ audio_free_ring(sc, &sc->sc_hwvc->sc_mrr);
audio_free_ring(sc, &sc->sc_pr);
audio_free_ring(sc, &sc->sc_rr);
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
audio_destroy_pfilters(chan->vc);
audio_destroy_rfilters(chan->vc);
}
+ audio_destroy_pfilters(sc->sc_hwvc);
+ audio_destroy_rfilters(sc->sc_hwvc);
auconv_delete_encodings(sc->sc_encodings);
@@ -948,10 +950,7 @@
sc->sc_sih_wr = NULL;
}
- chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
- kmem_free(chan->vc, sizeof(struct virtual_channel));
- SIMPLEQ_REMOVE(&sc->sc_audiochan, chan, audio_chan, entries);
- kmem_free(chan, sizeof(struct audio_chan));
+ kmem_free(sc->sc_hwvc, sizeof(struct virtual_channel));
kmem_free(sc->sc_mixer_state, sizeof(mixer_ctrl_t) *
(sc->sc_nmixer_states + 1));
@@ -1081,26 +1080,21 @@
void
audio_printsc(struct audio_softc *sc)
{
- struct audio_chan *chan;
-
- chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
-
- if (chan == NULL)
- return;
+ struct virtual_channel *vc;
+
+ vc = sc->sc_hwvc;
printf("hwhandle %p hw_if %p ", sc->hw_hdl, sc->hw_if);
- printf("open 0x%x mode 0x%x\n", chan->vc->sc_open,
- chan->vc->sc_mode);
+ printf("open 0x%x mode 0x%x\n", vc->sc_open, vc->sc_mode);
printf("rchan 0x%x wchan 0x%x ", cv_has_waiters(&sc->sc_rchan),
cv_has_waiters(&sc->sc_wchan));
printf("rring used 0x%x pring used=%d\n",
- audio_stream_get_used(&chan->vc->sc_mrr.s),
- audio_stream_get_used(&chan->vc->sc_mpr.s));
- printf("rbus 0x%x pbus 0x%x ", chan->vc->sc_rbus,
- chan->vc->sc_pbus);
- printf("blksize %d", chan->vc->sc_mpr.blksize);
- printf("hiwat %d lowat %d\n", chan->vc->sc_mpr.usedhigh,
- chan->vc->sc_mpr.usedlow);
+ audio_stream_get_used(&vc->sc_mrr.s),
+ audio_stream_get_used(&vc->sc_mpr.s));
+ printf("rbus 0x%x pbus 0x%x ", vc->sc_rbus, vc->sc_pbus);
+ printf("blksize %d", vc->sc_mpr.blksize);
+ printf("hiwat %d lowat %d\n", vc->sc_mpr.usedhigh,
+ vc->sc_mpr.usedlow);
}
void
@@ -1164,13 +1158,13 @@
int direction, size_t bufsize)
{
const struct audio_hw_if *hw;
- struct audio_chan *chan;
+ struct virtual_channel *vc;
void *hdl;
vaddr_t vstart;
vsize_t vsize;
int error;
- chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
+ vc = sc->sc_hwvc;
hw = sc->hw_if;
hdl = sc->hw_hdl;
/*
@@ -1182,7 +1176,7 @@
if (hw->round_buffersize)
bufsize = hw->round_buffersize(hdl, direction, bufsize);
- if (hw->allocm && (r == &chan->vc->sc_mpr || r == &chan->vc->sc_mrr)) {
+ if (hw->allocm && (r == &vc->sc_mpr || r == &vc->sc_mrr)) {
/* Hardware ringbuffer. No dedicated uvm object.*/
r->uobj = NULL;
r->s.start = hw->allocm(hdl, direction, bufsize);
@@ -1227,17 +1221,16 @@
void
audio_free_ring(struct audio_softc *sc, struct audio_ringbuffer *r)
{
- struct audio_chan *chan;
+ struct virtual_channel *vc;
vaddr_t vstart;
vsize_t vsize;
if (r->s.start == NULL)
return;
- chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
-
- if (sc->hw_if->freem && (r == &chan->vc->sc_mpr ||
- r == &chan->vc->sc_mrr)) {
+ vc = sc->sc_hwvc;
+
+ if (sc->hw_if->freem && (r == &vc->sc_mpr || r == &vc->sc_mrr)) {
/* Hardware ringbuffer. */
KASSERT(r->uobj == NULL);
sc->hw_if->freem(sc->hw_hdl, r->s.start, r->s.bufsize);
@@ -1585,8 +1578,6 @@
found = false;
SIMPLEQ_FOREACH(vchan, &sc->sc_audiochan, entries) {
- if (vchan == SIMPLEQ_FIRST(&sc->sc_audiochan))
- continue;
if (vchan->vc == vc) {
found = true;
break;
@@ -2022,12 +2013,10 @@
audio_initbufs(struct audio_softc *sc, struct virtual_channel *vc)
{
const struct audio_hw_if *hw;
- struct audio_chan *chan;
int error;
- chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
if (vc == NULL) {
- vc = chan->vc;
+ vc = sc->sc_hwvc;
sc->sc_pr.blksize = vc->sc_mrr.blksize;
sc->sc_rr.blksize = vc->sc_mrr.blksize;
}
@@ -2035,7 +2024,7 @@
DPRINTF(("audio_initbufs: mode=0x%x\n", vc->sc_mode));
hw = sc->hw_if;
if (audio_can_capture(sc) &&
- ((vc->sc_open & AUOPEN_READ) || vc == chan->vc)) {
+ ((vc->sc_open & AUOPEN_READ) || vc == sc->sc_hwvc)) {
audio_init_ringbuffer(sc, &vc->sc_mrr,
AUMODE_RECORD);
if (sc->sc_opens == 0 && hw->init_input &&
@@ -2046,11 +2035,11 @@
return error;
}
}
- if (vc == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc)
+ if (vc == sc->sc_hwvc)
sc->sc_rr.blksize = vc->sc_mrr.blksize;
if (audio_can_playback(sc) &&
- ((vc->sc_open & AUOPEN_WRITE) || vc == chan->vc)) {
+ ((vc->sc_open & AUOPEN_WRITE) || vc == sc->sc_hwvc)) {
audio_init_ringbuffer(sc, &vc->sc_mpr,
AUMODE_PLAY);
vc->sc_sil_count = 0;
@@ -2062,7 +2051,7 @@
return error;
}
}
- if (vc == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc)
+ if (vc == sc->sc_hwvc)
sc->sc_pr.blksize = vc->sc_mpr.blksize;
#ifdef AUDIO_INTR_TIME
@@ -2134,8 +2123,6 @@
return ENXIO;
n = 1;
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
- if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
- continue;
n = chan->chan + 1;
}
if (n < 0)
@@ -2328,10 +2315,9 @@
}
int
-audio_drain(struct audio_softc *sc, struct audio_chan *chan)
+audio_drain(struct audio_softc *sc, struct virtual_channel *vc)
{
struct audio_ringbuffer *cb;
- struct virtual_channel *vc;
int error, cc, i, used;
uint drops;
bool hw = false;
@@ -2340,14 +2326,13 @@
KASSERT(mutex_owned(sc->sc_intr_lock));
error = 0;
- vc = chan->vc;
DPRINTF(("audio_drain: enter busy=%d\n", vc->sc_pbus));
- cb = &chan->vc->sc_mpr;
+ cb = &vc->sc_mpr;
if (cb->mmapped)
return 0;
used = audio_stream_get_used(&cb->s);
- if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan)) {
+ if (vc == sc->sc_hwvc) {
hw = true;
used += audio_stream_get_used(&sc->sc_pr.s);
}
@@ -2401,8 +2386,8 @@
drops = cb->drops;
error = 0;
while (cb->drops == drops && !error) {
- DPRINTF(("audio_drain: chan=%d used=%d, drops=%ld\n",
- chan->chan,
+ DPRINTF(("audio_drain: vc=%p used=%d, drops=%ld\n",
+ vc,
audio_stream_get_used(&vc->sc_mpr.s),
cb->drops));
mutex_exit(sc->sc_intr_lock);
@@ -2459,12 +2444,12 @@
*/
if ((flags & FWRITE) && vc->sc_pbus) {
if (!vc->sc_mpr.pause)
- audio_drain(sc, chan);
+ audio_drain(sc, chan->vc);
vc->sc_pbus = false;
}
if (sc->sc_opens == 1) {
if (vc->sc_mpr.mmapped == false)
- audio_drain(sc, SIMPLEQ_FIRST(&sc->sc_audiochan));
+ audio_drain(sc, sc->sc_hwvc);
if (hw->drain)
(void)hw->drain(sc->hw_hdl);
hw->halt_output(sc->hw_hdl);
@@ -2733,14 +2718,12 @@
int
audio_silence_copyout(struct audio_softc *sc, int n, struct uio *uio)
Home |
Main Index |
Thread Index |
Old Index