diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -411,6 +411,10 @@ void sound_oss_sysinfo(oss_sysinfo *); int sound_oss_card_info(oss_card_info *); +#define PCM_MODE_NONE 0x00 +#define PCM_MODE_PLAY 0x01 +#define PCM_MODE_REC 0x02 + #define PCM_LOCKOWNED(d) mtx_owned((d)->lock) #define PCM_LOCK(d) mtx_lock((d)->lock) #define PCM_UNLOCK(d) mtx_unlock((d)->lock) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -1012,12 +1012,28 @@ "global clone garbage collector"); #endif +static u_int8_t +pcm_mode_init(struct snddev_info *d) +{ + u_int8_t mode = PCM_MODE_NONE; + + if (d->playcount > 0) + mode |= PCM_MODE_PLAY; + if (d->reccount > 0) + mode |= PCM_MODE_REC; + + return (mode); +} + static void pcm_sysinit(device_t dev) { struct snddev_info *d = device_get_softc(dev); + u_int8_t mode; + + mode = pcm_mode_init(d); - /* XXX: an user should be able to set this with a control tool, the + /* XXX: a user should be able to set this with a control tool, the sysadmin then needs min+max sysctls for this */ SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), @@ -1027,6 +1043,10 @@ "bitperfect", CTLTYPE_INT | CTLFLAG_RWTUN, d, sizeof(d), sysctl_dev_pcm_bitperfect, "I", "bit-perfect playback/recording (0=disable, 1=enable)"); + SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "mode", CTLFLAG_RD, NULL, mode, + "mode (0=none, 1=play, 2=rec, 3=play+rec)"); #ifdef SND_DEBUG SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, @@ -1130,7 +1150,7 @@ sysctl_ctx_init(&d->rec_sysctl_ctx); d->rec_sysctl_tree = SYSCTL_ADD_NODE(&d->rec_sysctl_ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "rec", - CTLFLAG_RD, 0, "record channels node"); + CTLFLAG_RD, 0, "recording channels node"); if (numplay > 0 || numrec > 0) d->flags |= SD_F_AUTOVCHAN;