diff options
author | mav <mav@FreeBSD.org> | 2009-01-10 18:19:22 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2009-01-10 18:19:22 +0000 |
commit | 9082151e885579970b7cdaf4dade6f00061ff492 (patch) | |
tree | 1f5691d103cff49d616131ff1db4697d2ae96495 /sys/dev/sound | |
parent | 4c485439e2faaa7e882274afbce929ee3726752a (diff) | |
download | FreeBSD-src-9082151e885579970b7cdaf4dade6f00061ff492.zip FreeBSD-src-9082151e885579970b7cdaf4dade6f00061ff492.tar.gz |
Import some new constants and structures fields from OSSv4.
Implement some OSSv4 ioctls to make ossinfo tool work and print
something reasonable.
Diffstat (limited to 'sys/dev/sound')
-rw-r--r-- | sys/dev/sound/pcm/dsp.c | 30 | ||||
-rw-r--r-- | sys/dev/sound/pcm/mixer.c | 35 | ||||
-rw-r--r-- | sys/dev/sound/pcm/sound.c | 32 | ||||
-rw-r--r-- | sys/dev/sound/pcm/sound.h | 1 |
4 files changed, 68 insertions, 30 deletions
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index f13ae31..a1494c7 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -814,7 +814,12 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread * case SNDCTL_SYSINFO: sound_oss_sysinfo((oss_sysinfo *)arg); break; + case SNDCTL_CARDINFO: + ret = sound_oss_card_info((oss_card_info *)arg); + break; case SNDCTL_AUDIOINFO: + case SNDCTL_AUDIOINFO_EX: + case SNDCTL_ENGINEINFO: ret = dsp_oss_audioinfo(i_dev, (oss_audioinfo *)arg); break; case SNDCTL_MIXERINFO: @@ -1370,9 +1375,9 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread * case SNDCTL_DSP_GETCAPS: pcm_lock(d); - *arg_i = DSP_CAP_REALTIME | DSP_CAP_MMAP | DSP_CAP_TRIGGER; + *arg_i = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER; if (rdch && wrch && !(dsp_get_flags(i_dev) & SD_F_SIMPLEX)) - *arg_i |= DSP_CAP_DUPLEX; + *arg_i |= PCM_CAP_DUPLEX; pcm_unlock(d); break; @@ -1770,18 +1775,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread * break; #if 0 /** - * @note The SNDCTL_CARDINFO ioctl was omitted per 4Front developer - * documentation. "The usability of this call is very limited. It's - * provided only for completeness of the API. OSS API doesn't have - * any concept of card. Any information returned by this ioctl calld - * is reserved exclusively for the utility programs included in the - * OSS package. Applications should not try to use for this - * information in any ways." - */ - case SNDCTL_CARDINFO: - ret = EINVAL; - break; - /** * @note The S/PDIF interface ioctls, @c SNDCTL_DSP_READCTL and * @c SNDCTL_DSP_WRITECTL have been omitted at the suggestion of * 4Front Technologies. @@ -2282,13 +2275,14 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai) /* * These flags stolen from SNDCTL_DSP_GETCAPS handler. * Note, however, that a single channel operates in - * only one direction, so DSP_CAP_DUPLEX is out. + * only one direction, so PCM_CAP_DUPLEX is out. */ /** * @todo @c SNDCTL_AUDIOINFO::caps - Make drivers keep * these in pcmchan::caps? */ - ai->caps = DSP_CAP_REALTIME | DSP_CAP_MMAP | DSP_CAP_TRIGGER; + ai->caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER | + ((ch->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : PCM_CAP_INPUT); /* * Collect formats supported @b natively by the @@ -2369,7 +2363,11 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai) for (i = 0; i < ai->nrates; i++) ai->rates[i] = rates[i]; + + ai->next_play_engine = 0; + ai->next_rec_engine = 0; +printf("flags: %08x %d\n", ch->flags, ai->busy); CHN_UNLOCK(ch); } diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index dd3b7bb..3cb953a 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1022,6 +1022,27 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, int ret, *arg_i = (int *)arg; int v = -1, j = cmd & 0xff; + /* + * Certain ioctls may be made on any type of device (audio, mixer, + * and MIDI). Handle those special cases here. + */ + if (IOCGROUP(cmd) == 'X') { + switch (cmd) { + case SNDCTL_SYSINFO: + sound_oss_sysinfo((oss_sysinfo *)arg); + return (0); + case SNDCTL_CARDINFO: + return (sound_oss_card_info((oss_card_info *)arg)); + case SNDCTL_AUDIOINFO: + case SNDCTL_AUDIOINFO_EX: + case SNDCTL_ENGINEINFO: + return (dsp_oss_audioinfo(i_dev, (oss_audioinfo *)arg)); + case SNDCTL_MIXERINFO: + return (mixer_oss_mixerinfo(i_dev, (oss_mixerinfo *)arg)); + } + return (ENXIO); + } + m = i_dev->si_drv1; if (m == NULL) @@ -1033,11 +1054,6 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, return (EBADF); } - if (cmd == SNDCTL_MIXERINFO) { - snd_mtxunlock(m->lock); - return (mixer_oss_mixerinfo(i_dev, (oss_mixerinfo *)arg)); - } - if ((cmd & MIXER_WRITE(0)) == MIXER_WRITE(0)) { if (j == SOUND_MIXER_RECSRC) ret = mixer_setrecsrc(m, *arg_i); @@ -1075,15 +1091,6 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, switch (cmd) { /** @todo Double check return values, error codes. */ - case SNDCTL_SYSINFO: - snd_mtxunlock(m->lock); - sound_oss_sysinfo((oss_sysinfo *)arg); - return (ret); - break; - case SNDCTL_AUDIOINFO: - snd_mtxunlock(m->lock); - return (dsp_oss_audioinfo(i_dev, (oss_audioinfo *)arg)); - break; case SNDCTL_DSP_GET_RECSRC_NAMES: bcopy((void *)&m->enuminfo, arg, sizeof(oss_mixer_enuminfo)); break; diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index e9878a6..cdaf8ba 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -1493,6 +1493,38 @@ sound_oss_sysinfo(oss_sysinfo *si) si->filler[i] = -1; } +int +sound_oss_card_info(oss_card_info *si) +{ + struct snddev_info *d; + int i, ncards; + + ncards = 0; + + for (i = 0; pcm_devclass != NULL && + i < devclass_get_maxunit(pcm_devclass); i++) { + d = devclass_get_softc(pcm_devclass, i); + if (!PCM_REGISTERED(d)) + continue; + + if (ncards++ != si->card) + continue; + + mtx_assert(d->lock, MA_NOTOWNED); + pcm_lock(d); + + strlcpy(si->shortname, device_get_nameunit(d->dev), + sizeof(si->shortname)); + strlcpy(si->longname, device_get_desc(d->dev), + sizeof(si->longname)); + strlcpy(si->hw_info, d->status, sizeof(si->hw_info)); + si->intr_count = si->ack_count = 0; + pcm_unlock(d); + return (0); + } + return (ENXIO); +} + /************************************************************************/ static int diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index b743ec0..391414c 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -601,6 +601,7 @@ struct snddev_info { }; void sound_oss_sysinfo(oss_sysinfo *); +int sound_oss_card_info(oss_card_info *); #ifdef PCM_DEBUG_MTX #define pcm_lock(d) mtx_lock(((struct snddev_info *)(d))->lock) |