1 /*
2 * Copyright 1993 Network Computing Devices, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name Network Computing Devices, Inc. not be
9 * used in advertising or publicity pertaining to distribution of this
10 * software without specific, written prior permission.
11 *
12 * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
13 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14 * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15 * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
16 * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17 * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18 * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19 * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 *
22 * $NCDId: @(#)auconfig.c,v 1.8 1994/08/15 22:41:06 greg Exp $
23 */
24 #include "misc.h"
25 #include "dixstruct.h"
26 #include <audio/audio.h>
27 #include <audio/Aproto.h>
28 #include "au.h"
29
30 extern AuBool AuInitPhysicalDevices();
31 extern void AuCreateResourceTypes(void);
32
33 ComponentPtr *auServerDevices, /* array of devices */
34 *auServerBuckets, /* array of server owned
35 * buckets */
36 *auServerRadios, /* array of server owned
37 * radios */
38 auDevices, /* list of all devices */
39 auBuckets, /* list of all buckets */
40 auRadios; /* list of all radios */
41 AuUint32 auNumServerDevices, /* number of devices */
42 auNumActions, /* number of defined actions */
43 auNumServerBuckets, /* number of server owned
44 * buckets */
45 auNumServerRadios; /* number of server owned
46 * radios */
47
48 #define auNumFormats NUMARRAY(auFormats)
49 AuUint8 auFormats[] = /* data formats supported */
50 {
51 AuFormatULAW8,
52 AuFormatLinearUnsigned8,
53 AuFormatLinearSigned8,
54 AuFormatLinearSigned16MSB,
55 AuFormatLinearUnsigned16MSB,
56 AuFormatLinearSigned16LSB,
57 AuFormatLinearUnsigned16LSB,
58 };
59
60 #define auNumElementTypes NUMARRAY(auElementTypes)
61 AuUint8 auElementTypes[] = /* element types supported */
62 {
63 AuElementTypeImportClient,
64 AuElementTypeImportDevice,
65 AuElementTypeImportBucket,
66 AuElementTypeImportWaveForm,
67 /* AuElementTypeImportRadio, */
68 AuElementTypeBundle,
69 AuElementTypeMultiplyConstant,
70 AuElementTypeAddConstant,
71 AuElementTypeSum,
72 AuElementTypeExportClient,
73 AuElementTypeExportDevice,
74 AuElementTypeExportBucket,
75 /* AuElementTypeExportRadio, */
76 AuElementTypeExportMonitor,
77 };
78
79 #define auNumWaveForms NUMARRAY(auWaveForms)
80 AuUint8 auWaveForms[] = /* wave forms supported */
81 {
82 AuWaveFormSquare, AuWaveFormSine, /* AuWaveFormConstant,
83 * AuWaveFormSaw, */
84 };
85
86 #define auNumActions NUMARRAY(auActions)
87 AuUint8 auActions[] = /* actions supported */
88 {
89 AuElementActionChangeState,
90 AuElementActionSendNotify,
91 AuElementActionNoop,
92 };
93
94 AuBool
AuInitDevice(auSetup,len)95 AuInitDevice(auSetup, len)
96 auConnSetup *auSetup;
97 int *len;
98 {
99 AuUint32 auServerDeviceListSize,
100 auServerBucketListSize,
101 auServerRadioListSize, auServerMinRate, auServerMaxRate, i;
102 extern AuUint32 auCurrentSampleRate;
103
104 /* free up old arrays */
105 if (auServerDevices)
106 aufree(auServerDevices);
107 if (auServerBuckets)
108 aufree(auServerBuckets);
109 if (auServerRadios)
110 aufree(auServerRadios);
111
112 for (i = 0; i < AuMaxCB; i++)
113 AuCallbacks[i] = 0;
114
115 if (!AuInitPhysicalDevices())
116 return AuFalse;
117
118 AuCreateResourceTypes();
119 AuCallback(AuCreateServerComponentsCB,
120 (&auServerDeviceListSize, &auServerBucketListSize,
121 &auServerRadioListSize, &auServerMinRate,
122 &auServerMaxRate));
123
124 auSetup->minSampleRate = auServerMinRate;
125 auSetup->maxSampleRate = auServerMaxRate;
126 auSetup->maxTracks = auMaxTracks;
127 auSetup->numFormats = auNumFormats;
128 auSetup->numElementTypes = auNumElementTypes;
129 auSetup->numWaveForms = auNumWaveForms;
130 auSetup->numActions = auNumActions;
131 auSetup->numDevices = auNumServerDevices;
132 auSetup->numBuckets = auNumServerBuckets;
133 auSetup->numRadios = auNumServerRadios;
134
135 *len = PAD4(auNumFormats) +
136 PAD4(auNumElementTypes) +
137 PAD4(auNumWaveForms) +
138 PAD4(auNumActions) +
139 auServerDeviceListSize +
140 auServerBucketListSize + auServerRadioListSize;
141
142 auCurrentSampleRate = 0;
143
144 return AuTrue;
145 }
146