2
* Describes the Linux Sound system support
6
* ----- ----- ---------------
7
* 27Oct96 1.0 Initial Program Built from generic filter.c
8
* Reports mixer capabilities etc.
9
* 18Nov96 1.1 Added DSP info
13
* Copyright (C) 1997-2008 Jim Jackson jj@franjam.org.uk
15
* This program is free software; you can redistribute it and/or modify
16
* it under the terms of the GNU General Public License as published by
17
* the Free Software Foundation; either version 2 of the License, or
18
* (at your option) any later version.
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU General Public License for more details.
25
* You should have received a copy of the GNU General Public License
26
* along with this program - see the file COPYING; if not, write to
27
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
33
soundinfo: (version 1) 27Oct96
36
soundinfo - Describes the Linux Sound system support
39
soundinfo [-v] [options]
43
Describes the Linux Sound system support on the system. Mixer devices,
58
This program is covered by the GNU General Public License, see file
59
COPYING for further details.
61
Any questions, suggestions or problems, etc. should be sent to
65
Email Internet: jj@franjam.org.uk
79
#include <sys/types.h>
83
#include <sys/soundcard.h>
85
#include <linux/soundcard.h>
92
#define VERSION "2.3.10 (May 2008)"
93
#define MIXDEV "/dev/mixer"
94
#define DSPDEV "/dev/dsp"
102
#define chkword(a,b) ((n>=a)&&(strncmp(p,b,n)==0))
109
short int debug; /* set if the -d flag is used */
110
short int vflg; /* set if -v flag used */
113
/* declare non-int functions
116
char *delnl(),*reads(),*sindex(),
117
*sindex_nc(),*tab(),*ctime();
118
FILE *fopen(),*mfopen();
121
/* main - for program soundinfo
122
* Describes the Linux Sound system support
130
char fname[132],*fnm,*p;
135
if ((p=strrchr(sys,'/'))!=NULL) { sys=p+1; }
139
printf("%s Ver. %s (c) 1996-2008 Jim Jackson\n",sys,VERSION);
141
while (argc && **argv=='-') /* all flags and options must come */
142
{ n=strlen(p=(*argv++)+1); argc--; /* before paramters */
143
if (*p==0) n=atoi(p+1); /* e.g. num. option -n23 */
144
else /* check for single char. flags */
146
{ if (*p=='h') exit(help(EFAIL));
147
else if (*p=='d') debug=TRUE;
148
else if (*p=='v') vflg=TRUE;
150
{ *fname='-'; *(fname+1)=*p; *(fname+2)=0;
151
exit(help(err_rpt(EINVAL,fname)));
157
if ((fd = open(fnm=MIXDEV, O_RDONLY)) < 0) {
163
if ((fd = open(fnm=DSPDEV, O_RDWR)) < 0) {
173
/* help(e) print brief help message - return parameter given
181
Describes some features of the Linux Sound system support in the kernel.\n\
194
int caps,fmts,blksize;
196
audio_buf_info auobf,auibf;
198
if (ioctl(fd, SNDCTL_DSP_GETCAPS , &caps) < 0) {
199
return(err_rpt(errno,"Reading DSP capabilities."));
201
if (ioctl(fd, SNDCTL_DSP_GETFMTS , &fmts) < 0) {
202
return(err_rpt(errno,"Reading DSP formats."));
204
if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE , &blksize) < 0) {
205
return(err_rpt(errno,"Reading blocksize."));
207
if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &auobf) < 0) {
208
return(err_rpt(errno,"Reading output audio buffer info."));
210
if (ioctl(fd, SNDCTL_DSP_GETISPACE, &auibf) < 0) {
211
return(err_rpt(errno,"Reading input audio buffer info."));
214
printf("\nDSP details ................\n");
215
printf(" capabilities = 0x%09X\n formats = 0x%09X\n",caps,fmts);
216
printf(" blocksize = %d\n", blksize);
218
printf("\nDSP Capability revision level %d\n",caps&255);
219
printf(" %s duplex operation (simultaneous read/write)\n",
220
(caps&DSP_CAP_DUPLEX)?"Supports":"Does not support");
221
if (caps&DSP_CAP_REALTIME)
222
printf(" Supports RealTime capability.\n" );
223
if (caps&DSP_CAP_BATCH)
224
printf(" Has batch facilities (buffers) which may cause timing problems etc.\n");
225
if (caps&DSP_CAP_COPROC)
226
printf(" Has a Co-Processor\n");
227
printf(" %s SETTRIGGER operation.\n",
228
(caps&DSP_CAP_TRIGGER)?"Supports":"Does not support");
230
printf("\nDSP Formats supported are :-\n");
231
if (fmts&AFMT_MU_LAW) printf(" Mu_Law ");
232
if (fmts&AFMT_A_LAW) printf(" A_Law ");
233
if (fmts&AFMT_IMA_ADPCM) printf(" IMA_ADPCM ");
234
if (fmts&AFMT_U8) printf(" U8 ");
235
if (fmts&AFMT_S16_LE) printf(" S16_LE ");
236
if (fmts&AFMT_S16_BE) printf(" S16_BE ");
237
if (fmts&AFMT_S8) printf(" S8 ");
238
if (fmts&AFMT_U16_LE) printf(" U16_LE ");
239
if (fmts&AFMT_U16_BE) printf(" U16_BE ");
240
if (fmts&AFMT_MPEG) printf(" MPEG ");
243
printf("Fragment details Output.. Input..\n");
244
printf(" total fragments %4d %4d\n",
245
auobf.fragstotal,auibf.fragstotal);
246
printf(" available %4d %4d\n",
247
auobf.fragments,auibf.fragments);
248
printf(" fragment size %5d %5d\n",
249
auobf.fragsize,auibf.fragsize);
250
printf(" bytes available %6d %6d\n\n",
251
auobf.bytes,auibf.bytes);
258
int devmask,recmask,sources,stereodevs,capabilities;
261
char *devname[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
262
int level[SOUND_MIXER_NRDEVICES];
263
struct mixer_info Mix_Info;
265
if (ioctl(fd, SOUND_MIXER_INFO, &Mix_Info) < 0) {
266
err_rpt(errno,"Getting mixer_info details.");
267
Mix_Info.id[0]=Mix_Info.name[0]=0;
269
if (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask) < 0) {
270
return(err_rpt(errno,"Reading Mixer Channels."));
273
return(err_rpt(ENODEV,"Mixer has no Channels!"));
275
if (ioctl(fd, SOUND_MIXER_READ_RECMASK, &recmask) < 0) {
276
return(err_rpt(errno,"Reading Recording Mask."));
278
if (ioctl(fd, SOUND_MIXER_READ_RECSRC, &sources) < 0) {
279
return(err_rpt(errno,"Reading Recording Devices."));
281
if (ioctl(fd, SOUND_MIXER_READ_STEREODEVS, &stereodevs) < 0) {
282
return(err_rpt(errno,"Reading Stereo Devices."));
284
if (ioctl(fd, SOUND_MIXER_READ_CAPS, &capabilities) < 0) {
285
return(err_rpt(errno,"Reading Mixer Capabilities."));
288
printf("MIXER DETAILS ......................\n");
289
printf(" Mixer Id = %s\n Name = %s\n",Mix_Info.id,Mix_Info.name);
290
printf(" devmask = 0x%09X\n recmask = 0x%09X\n",devmask,recmask);
291
printf(" sources = 0x%09X\n stereodevs = 0x%09X\n",sources,stereodevs);
292
printf("MIXER capabilities = 0x%09X\n",capabilities);
293
if (capabilities & SOUND_CAP_EXCL_INPUT)
294
printf(" Only one sound source can be selected at a time.\n");
296
printf("\nMIXER (%s) has following channels, set as :-\n",dev);
297
for (i=0; i<SOUND_MIXER_NRDEVICES; i++) {
298
if (devmask & (1<<i)) {
299
if (ioctl(fd, MIXER_READ(i), &n) < 0) {
300
sprintf(buf,"Problem reading current level of mixer channel %s.",
304
printf(" [0x%08X] %2d %-6s %3d",1<<i,i,devname[i],n&255);
305
if (stereodevs & (1<<i)) { printf("/%3d ",(n>>8)&255);
306
} else { printf(" "); }
307
printf("%9s ", (recmask & (1<<i))? "source":"");
308
printf("%10s ", (sources & (1<<i))? "selected":"");
326
if (err) fprintf(stderr,"[%s] %s : %s\n",sys,strerror(err),msg);