The branch main has been updated by christos:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b50f53cf872eca6b9a174a51fa183e8c2f88d97c

commit b50f53cf872eca6b9a174a51fa183e8c2f88d97c
Author:     Christos Margiolis <chris...@freebsd.org>
AuthorDate: 2025-02-25 11:43:46 +0000
Commit:     Christos Margiolis <chris...@freebsd.org>
CommitDate: 2025-02-25 11:43:46 +0000

    sound: Cache vchanmode
    
    We already cache vchanrate and vchanformat.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D48335
---
 sys/dev/sound/pcm/sound.h |  4 ++--
 sys/dev/sound/pcm/vchan.c | 11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
index 0452a58dfcbf..92d6e79600d1 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -238,8 +238,8 @@ struct snddev_info {
        struct mtx *lock;
        struct cdev *mixer_dev;
        struct cdev *dsp_dev;
-       uint32_t pvchanrate, pvchanformat;
-       uint32_t rvchanrate, rvchanformat;
+       uint32_t pvchanrate, pvchanformat, pvchanmode;
+       uint32_t rvchanrate, rvchanformat, rvchanmode;
        int32_t eqpreamp;
        struct sysctl_ctx_list play_sysctl_ctx, rec_sysctl_ctx;
        struct sysctl_oid *play_sysctl_tree, *rec_sysctl_tree;
diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 297120199fe7..379d647cbcf8 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -356,7 +356,7 @@ sysctl_dev_pcm_vchanmode(SYSCTL_HANDLER_ARGS)
        struct snddev_info *d;
        struct pcm_channel *c;
        uint32_t dflags;
-       int direction, ret;
+       int *vchanmode, direction, ret;
        char dtype[16];
 
        d = devclass_get_softc(pcm_devclass, VCHAN_SYSCTL_UNIT(oidp->oid_arg1));
@@ -373,6 +373,7 @@ sysctl_dev_pcm_vchanmode(SYSCTL_HANDLER_ARGS)
                        return (ENODEV);
                }
                direction = PCMDIR_PLAY;
+               vchanmode = &d->pvchanmode;
                break;
        case VCHAN_REC:
                if ((d->flags & SD_F_RVCHANS) == 0) {
@@ -380,6 +381,7 @@ sysctl_dev_pcm_vchanmode(SYSCTL_HANDLER_ARGS)
                        return (ENODEV);
                }
                direction = PCMDIR_REC;
+               vchanmode = &d->rvchanmode;
                break;
        default:
                PCM_UNLOCK(d);
@@ -402,14 +404,12 @@ sysctl_dev_pcm_vchanmode(SYSCTL_HANDLER_ARGS)
        KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d",
            __func__, direction, c->direction));
 
-       CHN_LOCK(c);
-       if (c->flags & CHN_F_VCHAN_PASSTHROUGH)
+       if (*vchanmode & CHN_F_VCHAN_PASSTHROUGH)
                strlcpy(dtype, "passthrough", sizeof(dtype));
-       else if (c->flags & CHN_F_VCHAN_ADAPTIVE)
+       else if (*vchanmode & CHN_F_VCHAN_ADAPTIVE)
                strlcpy(dtype, "adaptive", sizeof(dtype));
        else
                strlcpy(dtype, "fixed", sizeof(dtype));
-       CHN_UNLOCK(c);
 
        ret = sysctl_handle_string(oidp, dtype, sizeof(dtype), req);
        if (ret == 0 && req->newptr != NULL) {
@@ -436,6 +436,7 @@ sysctl_dev_pcm_vchanmode(SYSCTL_HANDLER_ARGS)
                c->flags &= ~CHN_F_VCHAN_DYNAMIC;
                c->flags |= dflags;
                CHN_UNLOCK(c);
+               *vchanmode = dflags;
        }
 
        PCM_RELEASE_QUICK(d);

Reply via email to