From owner-p4-projects@FreeBSD.ORG Wed Jun 14 08:33:42 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BECF916A479; Wed, 14 Jun 2006 08:33:42 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8353416A47F for ; Wed, 14 Jun 2006 08:33:42 +0000 (UTC) (envelope-from ryanb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A78C43D45 for ; Wed, 14 Jun 2006 08:33:42 +0000 (GMT) (envelope-from ryanb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5E8VJwh059967 for ; Wed, 14 Jun 2006 08:31:19 GMT (envelope-from ryanb@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5E8VJVD059964 for perforce@freebsd.org; Wed, 14 Jun 2006 08:31:19 GMT (envelope-from ryanb@FreeBSD.org) Date: Wed, 14 Jun 2006 08:31:19 GMT Message-Id: <200606140831.k5E8VJVD059964@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ryanb@FreeBSD.org using -f From: Ryan Beasley To: Perforce Change Reviews Cc: Subject: PERFORCE change 99207 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jun 2006 08:33:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=99207 Change 99207 by ryanb@ryanb_yuki on 2006/06/14 08:30:34 Added stub handler for SNDCTL_SYSINFO ioctl available to audio (/dev/dsp), mixer, and MIDI devices. (Currently only supported on dsp and mixer devices>) Submission also includes tweaked sys/soundcard.h with definitions from the new API. For the time being, all of my changes will be wrapped in gross OSSV4_EXPERIMENT ifdefs until things begin to take shape. Affected files ... .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/dsp.c#2 edit .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.c#2 edit .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.h#2 edit .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/sound.c#2 edit .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/sound.h#2 edit .. //depot/projects/soc2006/rbeasley_sound/sys/sys/soundcard.h#2 edit Differences ... ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/dsp.c#2 (text+ko) ==== @@ -1032,6 +1032,11 @@ dsp_set_flags(i_dev, dsp_get_flags(i_dev)^SD_F_SIMPLEX); break; +#ifdef OSSV4_EXPERIMENT + case SNDCTL_SYSINFO: + sound_oss_sysinfo((oss_sysinfo *)arg); + break; +#endif /* !OSSV4_EXPERIMENT */ case SNDCTL_DSP_MAPINBUF: case SNDCTL_DSP_MAPOUTBUF: case SNDCTL_DSP_SETSYNCRO: @@ -1206,4 +1211,5 @@ SYSUNINIT(dsp_sysuninit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dsp_sysuninit, NULL); #endif - +#ifdef OSSV4_EXPERIMENT +#endif /* !OSSV4_EXPERIMENT */ ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.c#2 (text+ko) ==== @@ -513,6 +513,13 @@ snd_mtxunlock(m->lock); return (v != -1)? 0 : ENXIO; } +#ifdef OSSV4_EXPERIMENT + if (cmd == SNDCTL_SYSINFO) { + sound_oss_sysinfo((oss_sysinfo *)arg); + snd_mtxunlock(m->lock); + return 0; + } +#endif /* !OSSV4_EXPERIMENT */ snd_mtxunlock(m->lock); return ENXIO; } @@ -552,4 +559,24 @@ SYSUNINIT(mixer_sysuninit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, mixer_sysuninit, NULL); #endif +#ifdef OSSV4_EXPERIMENT +/** + * @brief Counts the number of mixers in the system. + * @returns Number of mixer devices + * + * Used for SNDCTL_SYSINFO. Return the number of mixer devices in the + * system. Gross hack! (There has to be a better way.) + */ +int +mixer_get_num_mixers(void) +{ + struct cdev *mdev; + int count = 0; + LIST_FOREACH(mdev, &mixer_cdevsw.d_devs, si_list) { + ++count; + } + + return count; +} +#endif /* !OSSV4_EXPERIMENT */ ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.h#2 (text+ko) ==== @@ -41,6 +41,10 @@ u_int32_t mix_getrecdevs(struct snd_mixer *m); void *mix_getdevinfo(struct snd_mixer *m); +#ifdef OSSV4_EXPERIMENT +int mixer_get_num_mixers(void); +#endif /* !OSSV4_EXPERIMENT */ + /* * this is a kludge to allow hiding of the struct snd_mixer definition * 512 should be enough for all architectures ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/sound.c#2 (text+ko) ==== @@ -1120,6 +1120,70 @@ /************************************************************************/ +#ifdef OSSV4_EXPERIMENT +/** + * @brief Handle OSSv4 SNDCTL_SYSINFO ioctl. + * + * @param si Pointer to oss_sysinfo struct where information about the + * sound subsystem will be written/copied. + * + * This routine returns information about the sound system, such as the + * current OSS version, number of audio, MIDI, and mixer drivers, etc. + * Also includes a bitmask showing which of the above types of devices + * are open (busy). + * + * @author Ryan Beasley + */ +void +sound_oss_sysinfo(oss_sysinfo *si) +{ + static char si_product[] = "OSS/FreeBSD"; + static char si_version[] = "4.0.0a"; + + strncpy(si->product, si_product, sizeof(si->product)); + strncpy(si->version, si_version, sizeof(si->version)); + si->versionnum = SOUND_VERSION; + si->numaudios = (pcm_devclass != NULL) ? + devclass_get_count(pcm_devclass) : + 0; + si->numsynths = 0; /* OSSv4 docs: this field is obsolete */ + /** + * @todo Collect num{midis,timers}. + * + * Need access to sound/midi/midi.c::midistat_lock in order + * to safely touch midi_devices and get a head count of, well, + * MIDI devices. midistat_lock is a global static (i.e., local to + * midi.c), but midi_devices is a regular global; should the mutex + * be publicized, or is there another way to get this information? + * + * NB: MIDI/sequencer stuff is currently on hold. + */ + si->nummidis = 0; + si->numtimers = 0; + si->nummixers = mixer_get_num_mixers(); + si->numcards = 0; /* OSSv4 docs: Intended only for test apps; + API doesn't really have much of a concept + of cards. Shouldn't be used by + applications. */ + + /** + * @todo Fill in "busy devices" fields. + * + * si->openedaudio = bitmask of open/busy audio devices + * si->openedmidi = " MIDI devices + */ + bzero((void *)&si->openedaudio, sizeof(si->openedaudio)); + bzero((void *)&si->openedmidi, sizeof(si->openedmidi)); + + /* + * XXX Si->filler is a reserved array, but according to docs each + * element should be set to -1. + */ +} +#endif /* !OSSV4_EXPERIMENT */ + +/************************************************************************/ + static int sound_modevent(module_t mod, int type, void *data) { ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/sound.h#2 (text+ko) ==== @@ -318,6 +318,10 @@ #define PCM_KLDSTRING(a) "" #endif +#ifdef OSSV4_EXPERIMENT +void sound_oss_sysinfo(oss_sysinfo *); +#endif /* !OSSV4_EXPERIMENT */ + #endif /* _KERNEL */ #endif /* _OS_H_ */ ==== //depot/projects/soc2006/rbeasley_sound/sys/sys/soundcard.h#2 (text+ko) ==== @@ -1437,4 +1437,54 @@ #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF +/***********************************************************************/ + +/** + * XXX OSSv4 defines -- some bits taken straight out of the new + * sys/soundcard.h bundled with recent OSS releases. + * + * NB: These macros and structures will be reorganized and inserted + * in appropriate places throughout this file once the code begins + * to take shape. + */ +#define OSSV4_EXPERIMENT 1 +#ifdef OSSV4_EXPERIMENT + +#ifdef SOUND_VERSION +# undef SOUND_VERSION +# define SOUND_VERSION 0x040000 +#endif /* !SOUND_VERSION */ + +/** + * @struct oss_sysinfo + * @brief Argument for SNDCTL_SYSINFO ioctl. + * + * For use w/ the SNDCTL_SYSINFO ioctl available on audio (/dev/dsp*), + * mixer, and MIDI devices. + */ +typedef struct oss_sysinfo +{ + char product[32]; /* For example OSS/Free, OSS/Linux or OSS/Solaris */ + char version[32]; /* For example 4.0a */ + int versionnum; /* See OSS_GETVERSION */ + char options[128]; /* Reserved */ + + int numaudios; /* # of audio/dsp devices */ + int openedaudio[8]; /* Bit mask telling which audio devices are busy */ + + int numsynths; /* # of availavle synth devices */ + int nummidis; /* # of available MIDI ports */ + int numtimers; /* # of available timer devices */ + int nummixers; /* # of mixer devices */ + + int openedmidi[8]; /* Bit mask telling which midi devices are busy */ + int numcards; /* Number of sound cards in the system */ + int filler[241]; /* For future expansion (set to -1) */ +} oss_sysinfo; + +#define SNDCTL_SYSINFO _IOR ('X', 1, oss_sysinfo) +#define OSS_SYSINFO SNDCTL_SYSINFO /* Old name */ + +#endif /* !OSSV4_EXPERIMENT */ + #endif /* !_SYS_SOUNDCARD_H_ */