diff options
| author | Christos Margiolis <christos@FreeBSD.org> | 2025-04-25 16:55:51 +0000 |
|---|---|---|
| committer | Christos Margiolis <christos@FreeBSD.org> | 2025-04-25 16:55:51 +0000 |
| commit | abb5521bddc24581a1bcbe3e3f016504a4824c73 (patch) | |
| tree | 60c4b2e33df2e382e40788d5d6a0b118262a7032 /sys/dev | |
| parent | ef411cae7e9a644564cd079fac02e23105403136 (diff) | |
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/sound/pcm/dsp.c | 34 | ||||
| -rw-r--r-- | sys/dev/sound/pcm/sound.h | 7 |
2 files changed, 18 insertions, 23 deletions
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index c5caeea8a002..9b174f4592f3 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -67,6 +67,12 @@ SYSCTL_INT(_hw_snd, OID_AUTO, basename_clone, CTLFLAG_RWTUN, #define DSP_REGISTERED(x) (PCM_REGISTERED(x) && (x)->dsp_dev != NULL) +#define DSP_F_VALID(x) ((x) & (FREAD | FWRITE)) +#define DSP_F_DUPLEX(x) (((x) & (FREAD | FWRITE)) == (FREAD | FWRITE)) +#define DSP_F_SIMPLEX(x) (!DSP_F_DUPLEX(x)) +#define DSP_F_READ(x) ((x) & FREAD) +#define DSP_F_WRITE(x) ((x) & FWRITE) + #define OLDPCM_IOCTL static d_open_t dsp_open; @@ -144,18 +150,18 @@ dsp_destroy_dev(device_t dev) static void dsp_lock_chans(struct dsp_cdevpriv *priv, uint32_t prio) { - if (priv->rdch != NULL && (prio & SD_F_PRIO_RD)) + if (priv->rdch != NULL && DSP_F_READ(prio)) CHN_LOCK(priv->rdch); - if (priv->wrch != NULL && (prio & SD_F_PRIO_WR)) + if (priv->wrch != NULL && DSP_F_WRITE(prio)) CHN_LOCK(priv->wrch); } static void dsp_unlock_chans(struct dsp_cdevpriv *priv, uint32_t prio) { - if (priv->rdch != NULL && (prio & SD_F_PRIO_RD)) + if (priv->rdch != NULL && DSP_F_READ(prio)) CHN_UNLOCK(priv->rdch); - if (priv->wrch != NULL && (prio & SD_F_PRIO_WR)) + if (priv->wrch != NULL && DSP_F_WRITE(prio)) CHN_UNLOCK(priv->wrch); } @@ -234,12 +240,6 @@ dsp_chn_alloc(struct snddev_info *d, struct pcm_channel **ch, int direction, return (0); } -#define DSP_F_VALID(x) ((x) & (FREAD | FWRITE)) -#define DSP_F_DUPLEX(x) (((x) & (FREAD | FWRITE)) == (FREAD | FWRITE)) -#define DSP_F_SIMPLEX(x) (!DSP_F_DUPLEX(x)) -#define DSP_F_READ(x) ((x) & FREAD) -#define DSP_F_WRITE(x) ((x) & FWRITE) - static void dsp_close(void *data) { @@ -475,12 +475,12 @@ dsp_io_ops(struct dsp_cdevpriv *priv, struct uio *buf) switch (buf->uio_rw) { case UIO_READ: - prio = SD_F_PRIO_RD; + prio = FREAD; ch = &priv->rdch; chn_io = chn_read; break; case UIO_WRITE: - prio = SD_F_PRIO_WR; + prio = FWRITE; ch = &priv->wrch; chn_io = chn_write; break; @@ -1793,7 +1793,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td) ret = 0; - dsp_lock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_lock_chans(priv, FREAD | FWRITE); wrch = priv->wrch; rdch = priv->rdch; @@ -1809,7 +1809,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td) ret |= chn_poll(rdch, e, td); } - dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_unlock_chans(priv, FREAD | FWRITE); PCM_GIANT_LEAVE(d); @@ -1871,7 +1871,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, PCM_GIANT_ENTER(d); - dsp_lock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_lock_chans(priv, FREAD | FWRITE); wrch = priv->wrch; rdch = priv->rdch; @@ -1880,7 +1880,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, (*offset + size) > sndbuf_getallocsize(c->bufsoft) || (wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) || (rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) { - dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_unlock_chans(priv, FREAD | FWRITE); PCM_GIANT_EXIT(d); return (EINVAL); } @@ -1891,7 +1891,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, rdch->flags |= CHN_F_MMAP; *offset = (uintptr_t)sndbuf_getbufofs(c->bufsoft, *offset); - dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_unlock_chans(priv, FREAD | FWRITE); *object = vm_pager_allocate(OBJT_DEVICE, i_dev, size, nprot, *offset, curthread->td_ucred); diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index a1370180f350..315452e294d1 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -121,9 +121,6 @@ struct snd_mixer; #define SD_F_EQ_MASK (SD_F_EQ | SD_F_EQ_ENABLED | \ SD_F_EQ_BYPASSED | SD_F_EQ_PC) -#define SD_F_PRIO_RD 0x10000000 -#define SD_F_PRIO_WR 0x20000000 - #define SD_F_BITS "\020" \ "\001SIMPLEX" \ /* "\002 */ \ @@ -138,9 +135,7 @@ struct snd_mixer; "\013EQ_BYPASSED" \ "\014EQ_PC" \ "\015PVCHANS" \ - "\016RVCHANS" \ - "\035PRIO_RD" \ - "\036PRIO_WR" + "\016RVCHANS" #define PCM_ALIVE(x) ((x) != NULL && (x)->lock != NULL) #define PCM_REGISTERED(x) (PCM_ALIVE(x) && ((x)->flags & SD_F_REGISTERED)) |
