Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jun 2006 08:31:19 GMT
From:      Ryan Beasley <ryanb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 99207 for review
Message-ID:  <200606140831.k5E8VJVD059964@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <ryanb@FreeBSD.org>
+ */
+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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606140831.k5E8VJVD059964>