xref: /haiku/src/add-ons/kernel/drivers/audio/echo/generic/CEchoGals_info.cpp (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 // ****************************************************************************
2 //
3 //		CEchoGals_info.cpp
4 //
5 //		Implementation file for the CEchoGals driver class (info functions).
6 //		Set editor tabs to 3 for your viewing pleasure.
7 //
8 //		Copyright Echo Digital Audio Corporation (c) 1998 - 2002
9 //		All rights reserved
10 //		www.echoaudio.com
11 //
12 //		Permission is hereby granted, free of charge, to any person obtaining a
13 //		copy of this software and associated documentation files (the
14 //		"Software"), to deal with the Software without restriction, including
15 //		without limitation the rights to use, copy, modify, merge, publish,
16 //		distribute, sublicense, and/or sell copies of the Software, and to
17 //		permit persons to whom the Software is furnished to do so, subject to
18 //		the following conditions:
19 //
20 //		- Redistributions of source code must retain the above copyright
21 //		notice, this list of conditions and the following disclaimers.
22 //
23 //		- Redistributions in binary form must reproduce the above copyright
24 //		notice, this list of conditions and the following disclaimers in the
25 //		documentation and/or other materials provided with the distribution.
26 //
27 //		- Neither the name of Echo Digital Audio, nor the names of its
28 //		contributors may be used to endorse or promote products derived from
29 //		this Software without specific prior written permission.
30 //
31 //		THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 //		EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 //		MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34 //		IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
35 //		ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36 //		TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37 //		SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
38 //
39 // ****************************************************************************
40 
41 #include "CEchoGals.h"
42 
43 
44 /****************************************************************************
45 
46 	CEchoGals informational methods
47 
48  ****************************************************************************/
49 
50 //===========================================================================
51 //
52 // GetBaseCapabilities is used by the CEchoGals-derived classes to
53 // help fill out the ECHOGALS_CAPS struct.
54 //
55 //===========================================================================
56 
57 ECHOSTATUS CEchoGals::GetBaseCapabilities
58 (
59 	PECHOGALS_CAPS	pCapabilities
60 )
61 {
62 	CChannelMask	DigMask, ChMask, AdatMask;
63 	WORD				i;
64 
65 	//
66 	//	Test only for no DSP object.  We can still get capabilities even if
67 	//	board is bad.
68 	//
69 	if ( NULL == GetDspCommObject() )
70 		return ECHOSTATUS_DSP_DEAD;
71 
72 	memset( pCapabilities, 0, sizeof(ECHOGALS_CAPS) );
73 	strcpy( pCapabilities->szName, m_szCardInstallName );
74 
75 	pCapabilities->wCardType 		= GetDspCommObject()->GetCardType();
76 	pCapabilities->wNumPipesOut 	= GetNumPipesOut();
77 	pCapabilities->wNumPipesIn 	= GetNumPipesIn();
78 	pCapabilities->wNumBussesOut 	= GetNumBussesOut();
79 	pCapabilities->wNumBussesIn	= GetNumBussesIn();
80 
81 	pCapabilities->wFirstDigitalBusOut 	= GetFirstDigitalBusOut();
82 	pCapabilities->wFirstDigitalBusIn 	= GetFirstDigitalBusIn();
83 
84 	pCapabilities->wNumMidiOut = GetDspCommObject()->GetNumMidiOutChannels();
85 	pCapabilities->wNumMidiIn = GetDspCommObject()->GetNumMidiInChannels();
86 
87 	pCapabilities->dwOutClockTypes = 0;
88 	pCapabilities->dwInClockTypes = ECHO_CLOCK_BIT_INTERNAL;;
89 
90 	//
91 	// Add the controls to the output pipes that are
92 	// the same for all cards
93 	//
94 	for (i = 0; i < GetNumPipesOut(); i++)
95 	{
96 		pCapabilities->dwPipeOutCaps[i] = 	ECHOCAPS_GAIN |
97 														ECHOCAPS_MUTE;
98 	}
99 
100 	//
101 	// Add controls to the input busses that are the same for all cards
102 	//
103 	WORD wFirstDigitalBusIn = GetFirstDigitalBusIn();
104 	for (i = 0; i < GetNumBussesIn(); i++)
105 	{
106 		pCapabilities->dwBusInCaps[i] =	ECHOCAPS_PEAK_METER |
107 													ECHOCAPS_VU_METER;
108 		if (i >= wFirstDigitalBusIn)
109 			pCapabilities->dwBusInCaps[i] |= ECHOCAPS_DIGITAL;
110 	}
111 
112 	//
113 	// And the output busses
114 	//
115 	WORD	wFirstDigitalBusOut = GetFirstDigitalBusOut();
116 	for (i = 0; i < GetNumBussesOut(); i++)
117 	{
118 		pCapabilities->dwBusOutCaps[i] = ECHOCAPS_PEAK_METER |
119 													ECHOCAPS_VU_METER	|
120 													ECHOCAPS_GAIN |
121 													ECHOCAPS_MUTE;
122 		if (i >= wFirstDigitalBusOut)
123 			pCapabilities->dwBusOutCaps[i] |= ECHOCAPS_DIGITAL;
124 	}
125 
126 	//
127 	// Digital modes & vmixer flag
128 	//
129 	pCapabilities->dwDigitalModes = GetDspCommObject()->GetDigitalModes();
130 	pCapabilities->fHasVmixer = GetDspCommObject()->HasVmixer();
131 
132 	//
133 	//	If this is not a vmixer card, output pipes are hard-wired to output busses.
134 	// Mark those pipes that are hard-wired to digital busses as digital pipes
135 	//
136 	if (GetDspCommObject()->HasVmixer())
137 	{
138 		pCapabilities->wFirstDigitalPipeOut = pCapabilities->wNumPipesOut;
139 	}
140 	else
141 	{
142 		pCapabilities->wFirstDigitalPipeOut = pCapabilities->wFirstDigitalBusOut;
143 
144 
145 		for (	i = pCapabilities->wFirstDigitalPipeOut;
146 			  	i < GetNumPipesOut();
147 			  	i++)
148 		{
149 			pCapabilities->dwPipeOutCaps[i] |= ECHOCAPS_DIGITAL;
150 		}
151 
152 	}
153 
154 	//
155 	// Input pipes are the same, vmixer or no vmixer
156 	//
157 	pCapabilities->wFirstDigitalPipeIn = pCapabilities->wFirstDigitalBusIn;
158 
159 	for (	i = pCapabilities->wFirstDigitalPipeIn;
160 		  	i < GetNumPipesIn();
161 		  	i++)
162 	{
163 		pCapabilities->dwPipeInCaps[i] |= ECHOCAPS_DIGITAL;
164 	}
165 	return ECHOSTATUS_OK;
166 
167 }	// ECHOSTATUS CEchoGals::GetBaseCapabilities
168 
169 
170 //===========================================================================
171 //
172 // MakePipeIndex is a utility function; it takes a pipe number and an
173 // input or output flag and returns the pipe index.  Refer to
174 // EchoGalsXface.h for more information.
175 //
176 //===========================================================================
177 
178 WORD CEchoGals::MakePipeIndex(WORD wPipe,BOOL fInput)
179 {
180 	if (fInput)
181 		return wPipe + GetNumPipesOut();
182 
183 	return wPipe;
184 
185 }	// MakePipeIndex
186 
187 
188 //===========================================================================
189 //
190 // Get the card name as an ASCII zero-terminated string
191 //
192 //===========================================================================
193 
194 CONST PCHAR CEchoGals::GetDeviceName()
195 {
196 	return m_szCardInstallName;
197 }
198 
199 
200 //===========================================================================
201 //
202 // Get numbers of pipes and busses
203 //
204 //===========================================================================
205 
206 WORD CEchoGals::GetNumPipesOut()
207 {
208 	if (NULL == GetDspCommObject())
209 		return 0;
210 
211 	return GetDspCommObject()->GetNumPipesOut();
212 }
213 
214 WORD CEchoGals::GetNumPipesIn()
215 {
216 	if (NULL == GetDspCommObject())
217 		return 0;
218 
219 	return GetDspCommObject()->GetNumPipesIn();
220 }
221 
222 WORD CEchoGals::GetNumBussesOut()
223 {
224 	if (NULL == GetDspCommObject())
225 		return 0;
226 
227 	return GetDspCommObject()->GetNumBussesOut();
228 }
229 
230 WORD CEchoGals::GetNumBussesIn()
231 {
232 	if (NULL == GetDspCommObject())
233 		return 0;
234 
235 	return GetDspCommObject()->GetNumBussesIn();
236 }
237 
238 WORD CEchoGals::GetNumBusses()
239 {
240 	if (NULL == GetDspCommObject())
241 		return 0;
242 
243 	return GetDspCommObject()->GetNumBusses();
244 }
245 
246 WORD CEchoGals::GetNumPipes()
247 {
248 	if (NULL == GetDspCommObject())
249 		return 0;
250 
251 	return GetDspCommObject()->GetNumPipes();
252 }
253 
254 WORD CEchoGals::GetFirstDigitalBusOut()
255 {
256 	if (NULL == GetDspCommObject())
257 		return 0;
258 
259 	return GetDspCommObject()->GetFirstDigitalBusOut();
260 }
261 
262 WORD CEchoGals::GetFirstDigitalBusIn()
263 {
264 	if (NULL == GetDspCommObject())
265 		return 0;
266 
267 	return GetDspCommObject()->GetFirstDigitalBusIn();
268 }
269 
270 BOOL CEchoGals::HasVmixer()
271 {
272 	if (NULL == GetDspCommObject())
273 		return 0;
274 
275 	return GetDspCommObject()->HasVmixer();
276 }
277 
278 
279 //===========================================================================
280 //
281 //	Get access to the DSP comm object
282 //
283 //===========================================================================
284 
285 PCDspCommObject CEchoGals::GetDspCommObject()
286 {
287 	return m_pDspCommObject;
288 }
289 
290