1626bc4beSJérôme Duval// ****************************************************************************
2626bc4beSJérôme Duval//
3626bc4beSJérôme Duval//		C3g.cpp
4626bc4beSJérôme Duval//
5626bc4beSJérôme Duval//		Implementation file for the C3g driver class.
6626bc4beSJérôme Duval//		Set editor tabs to 3 for your viewing pleasure.
7626bc4beSJérôme Duval//
8626bc4beSJérôme Duval// ----------------------------------------------------------------------------
9626bc4beSJérôme Duval//
10626bc4beSJérôme Duval// This file is part of Echo Digital Audio's generic driver library.
11626bc4beSJérôme Duval// Copyright Echo Digital Audio Corporation (c) 1998 - 2005
12626bc4beSJérôme Duval// All rights reserved
13626bc4beSJérôme Duval// www.echoaudio.com
14626bc4beSJérôme Duval//
15626bc4beSJérôme Duval// This library is free software; you can redistribute it and/or
16626bc4beSJérôme Duval// modify it under the terms of the GNU Lesser General Public
17626bc4beSJérôme Duval// License as published by the Free Software Foundation; either
18626bc4beSJérôme Duval// version 2.1 of the License, or (at your option) any later version.
19626bc4beSJérôme Duval//
20626bc4beSJérôme Duval// This library is distributed in the hope that it will be useful,
21626bc4beSJérôme Duval// but WITHOUT ANY WARRANTY; without even the implied warranty of
22626bc4beSJérôme Duval// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23626bc4beSJérôme Duval// Lesser General Public License for more details.
24626bc4beSJérôme Duval//
25626bc4beSJérôme Duval// You should have received a copy of the GNU Lesser General Public
26626bc4beSJérôme Duval// License along with this library; if not, write to the Free Software
27626bc4beSJérôme Duval// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28626bc4beSJérôme Duval//
29626bc4beSJérôme Duval// ****************************************************************************
30626bc4beSJérôme Duval
31626bc4beSJérôme Duval#include "C3g.h"
32626bc4beSJérôme Duval
33626bc4beSJérôme Duval#define ECHO3G_ANALOG_OUTPUT_LATENCY_1X		(1 + 32 + 12)		// ASIC + DSP + DAC
34626bc4beSJérôme Duval#define ECHO3G_ANALOG_OUTPUT_LATENCY_2X		(1 + 32 + 5)
35626bc4beSJérôme Duval#define ECHO3G_ANALOG_INPUT_LATENCY_1X			(1 + 32 + 12)
36626bc4beSJérôme Duval#define ECHO3G_ANALOG_INPUT_LATENCY_2X			(1 + 32 + 9)
37626bc4beSJérôme Duval
38626bc4beSJérôme Duval#define ECHO3G_DIGITAL_OUTPUT_LATENCY			(1 + 32)
39626bc4beSJérôme Duval#define ECHO3G_DIGITAL_INPUT_LATENCY			(1 + 32)
40626bc4beSJérôme Duval
41626bc4beSJérôme Duval
42626bc4beSJérôme Duval
43626bc4beSJérôme Duval/****************************************************************************
44626bc4beSJérôme Duval
45626bc4beSJérôme Duval	Construction and destruction
46626bc4beSJérôme Duval
47626bc4beSJérôme Duval ****************************************************************************/
48626bc4beSJérôme Duval
49626bc4beSJérôme Duval//===========================================================================
50626bc4beSJérôme Duval//
51626bc4beSJérôme Duval// Overload new & delete so memory for this object is allocated
52626bc4beSJérôme Duval//	from non-paged memory.
53626bc4beSJérôme Duval//
54626bc4beSJérôme Duval//===========================================================================
55626bc4beSJérôme Duval
56626bc4beSJérôme DuvalPVOID C3g::operator new( size_t Size )
57626bc4beSJérôme Duval{
58626bc4beSJérôme Duval	PVOID 		pMemory;
59626bc4beSJérôme Duval	ECHOSTATUS 	Status;
60626bc4beSJérôme Duval
61626bc4beSJérôme Duval	Status = OsAllocateNonPaged(Size,&pMemory);
62626bc4beSJérôme Duval
63626bc4beSJérôme Duval	if ( (ECHOSTATUS_OK != Status) || (NULL == pMemory ))
64626bc4beSJérôme Duval	{
65626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("C3g::operator new - memory allocation failed\n"));
66626bc4beSJérôme Duval
67626bc4beSJérôme Duval		pMemory = NULL;
68626bc4beSJérôme Duval	}
69626bc4beSJérôme Duval	else
70626bc4beSJérôme Duval	{
71626bc4beSJérôme Duval		memset( pMemory, 0, Size );
72626bc4beSJérôme Duval	}
73626bc4beSJérôme Duval
74626bc4beSJérôme Duval	return pMemory;
75626bc4beSJérôme Duval
76626bc4beSJérôme Duval}	// PVOID C3g::operator new( size_t Size )
77626bc4beSJérôme Duval
78626bc4beSJérôme Duval
79626bc4beSJérôme DuvalVOID  C3g::operator delete( PVOID pVoid )
80626bc4beSJérôme Duval{
81626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != OsFreeNonPaged( pVoid ) )
82626bc4beSJérôme Duval	{
83626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("C3g::operator delete memory free failed\n"));
84626bc4beSJérôme Duval	}
85626bc4beSJérôme Duval}	// VOID C3g::operator delete( PVOID pVoid )
86626bc4beSJérôme Duval
87626bc4beSJérôme Duval
88626bc4beSJérôme Duval//===========================================================================
89626bc4beSJérôme Duval//
90626bc4beSJérôme Duval// Constructor and destructor
91626bc4beSJérôme Duval//
92626bc4beSJérôme Duval//===========================================================================
93626bc4beSJérôme Duval
94626bc4beSJérôme DuvalC3g::C3g( PCOsSupport pOsSupport )
95626bc4beSJérôme Duval	  : CEchoGalsMTC( pOsSupport )
96626bc4beSJérôme Duval{
97626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "C3g::C3g() is born!\n" ) );
98626bc4beSJérôme Duval
99626bc4beSJérôme Duval	m_wAnalogOutputLatency = ECHO3G_ANALOG_OUTPUT_LATENCY_1X;
100626bc4beSJérôme Duval	m_wAnalogInputLatency = ECHO3G_ANALOG_INPUT_LATENCY_1X;
101626bc4beSJérôme Duval	m_wDigitalOutputLatency = ECHO3G_DIGITAL_OUTPUT_LATENCY;
102626bc4beSJérôme Duval	m_wDigitalInputLatency = ECHO3G_DIGITAL_INPUT_LATENCY;
103626bc4beSJérôme Duval}
104626bc4beSJérôme Duval
105626bc4beSJérôme Duval
106626bc4beSJérôme DuvalC3g::~C3g()
107626bc4beSJérôme Duval{
108626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "C3g::~C3g() is toast!\n" ) );
109626bc4beSJérôme Duval}
110626bc4beSJérôme Duval
111626bc4beSJérôme Duval
112626bc4beSJérôme Duval
113626bc4beSJérôme Duval
114626bc4beSJérôme Duval/****************************************************************************
115626bc4beSJérôme Duval
116626bc4beSJérôme Duval	Setup and hardware initialization
117626bc4beSJérôme Duval
118626bc4beSJérôme Duval ****************************************************************************/
119626bc4beSJérôme Duval
120626bc4beSJérôme Duval//===========================================================================
121626bc4beSJérôme Duval//
122626bc4beSJérôme Duval// Every card has an InitHw method
123626bc4beSJérôme Duval//
124626bc4beSJérôme Duval//===========================================================================
125626bc4beSJérôme Duval
126626bc4beSJérôme DuvalECHOSTATUS C3g::InitHw()
127626bc4beSJérôme Duval{
128626bc4beSJérôme Duval	ECHOSTATUS	Status;
129626bc4beSJérôme Duval	WORD			i;
130626bc4beSJérôme Duval
131626bc4beSJérôme Duval	//
132626bc4beSJérôme Duval	// Call the base method
133626bc4beSJérôme Duval	//
134626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != ( Status = CEchoGals::InitHw() ) )
135626bc4beSJérôme Duval		return Status;
136626bc4beSJérôme Duval
137626bc4beSJérôme Duval	//
138626bc4beSJérôme Duval	// Create the DSP comm object
139626bc4beSJérôme Duval	//
1404dd9e436SJérôme Duval	ECHO_ASSERT(NULL == m_pDspCommObject );
141626bc4beSJérôme Duval	m_pDspCommObject = new C3gDco( (PDWORD) m_pvSharedMemory, m_pOsSupport );
142626bc4beSJérôme Duval	if (NULL == m_pDspCommObject)
143626bc4beSJérôme Duval	{
144626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("C3g::InitHw - could not create DSP comm object\n"));
145626bc4beSJérôme Duval		return ECHOSTATUS_NO_MEM;
146626bc4beSJérôme Duval	}
147626bc4beSJérôme Duval
148626bc4beSJérôme Duval	//
149626bc4beSJérôme Duval	// Load the DSP
150626bc4beSJérôme Duval	//
151626bc4beSJérôme Duval	DWORD dwBoxType;
152626bc4beSJérôme Duval
153626bc4beSJérôme Duval	GetDspCommObject()->LoadFirmware();
154626bc4beSJérôme Duval
155626bc4beSJérôme Duval	GetDspCommObject()->Get3gBoxType(&dwBoxType,NULL);
156626bc4beSJérôme Duval	if (NO3GBOX == dwBoxType)
157626bc4beSJérôme Duval		return ECHOSTATUS_NO_3G_BOX;
158626bc4beSJérôme Duval
159626bc4beSJérôme Duval	if ( GetDspCommObject()->IsBoardBad() )
160626bc4beSJérôme Duval		return ECHOSTATUS_DSP_DEAD;
161626bc4beSJérôme Duval
162626bc4beSJérôme Duval	//
163626bc4beSJérôme Duval	// Clear the "bad board" flag; set the flags to indicate that
164626bc4beSJérôme Duval	// 3G can handle super-interleave.
165626bc4beSJérôme Duval	//
166626bc4beSJérôme Duval	m_wFlags &= ~ECHOGALS_FLAG_BADBOARD;
167626bc4beSJérôme Duval	m_wFlags |= ECHOGALS_ROFLAG_SUPER_INTERLEAVE_OK;
168626bc4beSJérôme Duval
169626bc4beSJérôme Duval	//
170626bc4beSJérôme Duval	//	Must call this here after DSP is init to
171626bc4beSJérôme Duval	//	init gains and mutes
172626bc4beSJérôme Duval	//
173626bc4beSJérôme Duval	Status = InitLineLevels();
174626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != Status )
175626bc4beSJérôme Duval		return Status;
176626bc4beSJérôme Duval
177626bc4beSJérôme Duval	//
178626bc4beSJérôme Duval	// Initialize the MIDI input
179626bc4beSJérôme Duval	//
180626bc4beSJérôme Duval	Status = m_MidiIn.Init( this );
181626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != Status )
182626bc4beSJérôme Duval		return Status;
183626bc4beSJérôme Duval
184626bc4beSJérôme Duval	//
185626bc4beSJérôme Duval	// Set defaults for +4/-10
186626bc4beSJérôme Duval	//
187626bc4beSJérôme Duval	for (i = 0; i < GetFirstDigitalBusOut(); i++ )
188626bc4beSJérôme Duval	{
189626bc4beSJérôme Duval		GetDspCommObject()->
190626bc4beSJérôme Duval			SetNominalLevel( i, FALSE );	// FALSE is +4 here
191626bc4beSJérôme Duval	}
192626bc4beSJérôme Duval	for ( i = 0; i < GetFirstDigitalBusIn(); i++ )
193626bc4beSJérôme Duval	{
194626bc4beSJérôme Duval		GetDspCommObject()->
195626bc4beSJérôme Duval			SetNominalLevel( GetNumBussesOut() + i, FALSE );
196626bc4beSJérôme Duval	}
197626bc4beSJérôme Duval
198626bc4beSJérôme Duval	//
199626bc4beSJérôme Duval	// Set the digital mode to S/PDIF RCA
200626bc4beSJérôme Duval	//
201626bc4beSJérôme Duval	SetDigitalMode( DIGITAL_MODE_SPDIF_RCA );
202626bc4beSJérôme Duval
203626bc4beSJérôme Duval	//
204626bc4beSJérôme Duval	//	Get default sample rate from DSP
205626bc4beSJérôme Duval	//
206626bc4beSJérôme Duval	m_dwSampleRate = GetDspCommObject()->GetSampleRate();
207626bc4beSJérôme Duval
208626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "C3g::InitHw()\n" ) );
209626bc4beSJérôme Duval	return Status;
210626bc4beSJérôme Duval
211626bc4beSJérôme Duval}	// ECHOSTATUS C3g::InitHw()
212626bc4beSJérôme Duval
213626bc4beSJérôme Duval
214626bc4beSJérôme Duval
215626bc4beSJérôme Duval
216626bc4beSJérôme Duval/****************************************************************************
217626bc4beSJérôme Duval
218626bc4beSJérôme Duval	Informational methods
219626bc4beSJérôme Duval
220626bc4beSJérôme Duval ****************************************************************************/
221626bc4beSJérôme Duval
222626bc4beSJérôme Duval//===========================================================================
223626bc4beSJérôme Duval//
224626bc4beSJérôme Duval// Override GetCapabilities to enumerate unique capabilties for this card
225626bc4beSJérôme Duval//
226626bc4beSJérôme Duval//===========================================================================
227626bc4beSJérôme Duval
228626bc4beSJérôme DuvalECHOSTATUS C3g::GetCapabilities
229626bc4beSJérôme Duval(
230626bc4beSJérôme Duval	PECHOGALS_CAPS	pCapabilities
231626bc4beSJérôme Duval)
232626bc4beSJérôme Duval{
233626bc4beSJérôme Duval	ECHOSTATUS	Status;
234626bc4beSJérôme Duval	WORD			i;
235626bc4beSJérôme Duval
236626bc4beSJérôme Duval	Status = GetBaseCapabilities(pCapabilities);
237626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != Status )
238626bc4beSJérôme Duval		return Status;
239626bc4beSJérôme Duval
240626bc4beSJérôme Duval	//
241626bc4beSJérôme Duval	// Add nominal level control to all ins & outs except the universal
242626bc4beSJérôme Duval	//
243626bc4beSJérôme Duval	for (i = 0 ; i < pCapabilities->wNumBussesOut; i++)
244626bc4beSJérôme Duval	{
245626bc4beSJérôme Duval		pCapabilities->dwBusOutCaps[i] |= ECHOCAPS_NOMINAL_LEVEL;
246626bc4beSJérôme Duval	}
247626bc4beSJérôme Duval
248626bc4beSJérôme Duval	for (i = 2 ; i < pCapabilities->wNumBussesIn; i++)
249626bc4beSJérôme Duval	{
250626bc4beSJérôme Duval		pCapabilities->dwBusInCaps[i] |= ECHOCAPS_NOMINAL_LEVEL;
251626bc4beSJérôme Duval	}
252626bc4beSJérôme Duval
253626bc4beSJérôme Duval	pCapabilities->dwInClockTypes |= ECHO_CLOCK_BIT_SPDIF		|
254626bc4beSJérôme Duval												ECHO_CLOCK_BIT_ADAT		|
255626bc4beSJérôme Duval												ECHO_CLOCK_BIT_MTC;
256626bc4beSJérôme Duval
257626bc4beSJérôme Duval	//
258626bc4beSJérôme Duval	// Box-specific capabilities
259626bc4beSJérôme Duval	//
260626bc4beSJérôme Duval	DWORD dwBoxType;
261626bc4beSJérôme Duval
262626bc4beSJérôme Duval	GetDspCommObject()->Get3gBoxType(&dwBoxType,NULL);
263626bc4beSJérôme Duval	switch (dwBoxType)
264626bc4beSJérôme Duval	{
265626bc4beSJérôme Duval		case GINA3G :
266626bc4beSJérôme Duval			pCapabilities->dwBusInCaps[0] |= ECHOCAPS_PHANTOM_POWER;
267626bc4beSJérôme Duval			pCapabilities->dwBusInCaps[1] |= ECHOCAPS_PHANTOM_POWER;
268626bc4beSJérôme Duval			break;
269626bc4beSJérôme Duval
270626bc4beSJérôme Duval		case LAYLA3G :
271626bc4beSJérôme Duval			pCapabilities->dwInClockTypes |= ECHO_CLOCK_BIT_WORD;
272626bc4beSJérôme Duval			break;
273626bc4beSJérôme Duval
274626bc4beSJérôme Duval	}
275626bc4beSJérôme Duval
276626bc4beSJérôme Duval	pCapabilities->dwOutClockTypes = 0;
277626bc4beSJérôme Duval
278626bc4beSJérôme Duval	return Status;
279626bc4beSJérôme Duval
280626bc4beSJérôme Duval}	// ECHOSTATUS C3g::GetCapabilities
281626bc4beSJérôme Duval
282626bc4beSJérôme Duval
283626bc4beSJérôme Duval//===========================================================================
284626bc4beSJérôme Duval//
285626bc4beSJérôme Duval// QueryAudioSampleRate is used to find out if this card can handle a
286626bc4beSJérôme Duval// given sample rate.
287626bc4beSJérôme Duval//
288626bc4beSJérôme Duval//===========================================================================
289626bc4beSJérôme Duval
290626bc4beSJérôme DuvalECHOSTATUS C3g::QueryAudioSampleRate
291626bc4beSJérôme Duval(
292626bc4beSJérôme Duval	DWORD		dwSampleRate
293626bc4beSJérôme Duval)
294626bc4beSJérôme Duval{
295626bc4beSJérôme Duval	//
296626bc4beSJérôme Duval	// Check rates that are supported by continuous mode; only allow
297626bc4beSJérôme Duval	// double-speed rates if not in ADAT mode
298626bc4beSJérôme Duval	//
299626bc4beSJérôme Duval	if ((dwSampleRate >= 32000) && (dwSampleRate <= 50000))
300626bc4beSJérôme Duval		return ECHOSTATUS_OK;
301626bc4beSJérôme Duval
302626bc4beSJérôme Duval	if (	(DIGITAL_MODE_ADAT != GetDigitalMode()) &&
303626bc4beSJérôme Duval			(dwSampleRate > 50000) &&
304626bc4beSJérôme Duval			(dwSampleRate <= 100000))
305626bc4beSJérôme Duval		return ECHOSTATUS_OK;
306be188ae1SJérôme Duval
307626bc4beSJérôme Duval	ECHO_DEBUGPRINTF(("C3g::QueryAudioSampleRate() - rate %ld invalid\n",dwSampleRate) );
308626bc4beSJérôme Duval
309626bc4beSJérôme Duval	return ECHOSTATUS_BAD_FORMAT;
310626bc4beSJérôme Duval
311626bc4beSJérôme Duval}	// ECHOSTATUS C3g::QueryAudioSampleRate
312626bc4beSJérôme Duval
313626bc4beSJérôme Duval
3144dd9e436SJérôme Duvalvoid C3g::QuerySampleRateRange(DWORD &dwMinRate,DWORD &dwMaxRate)
3154dd9e436SJérôme Duval{
3164dd9e436SJérôme Duval	dwMinRate = 32000;
3174dd9e436SJérôme Duval	dwMaxRate = 96000;
3184dd9e436SJérôme Duval}
3194dd9e436SJérôme Duval
3204dd9e436SJérôme Duval
3214dd9e436SJérôme Duval
322626bc4beSJérôme Duval//===========================================================================
323626bc4beSJérôme Duval//
324626bc4beSJérôme Duval// GetInputClockDetect returns a bitmask consisting of all the input
325626bc4beSJérôme Duval// clocks currently connected to the hardware; this changes as the user
326626bc4beSJérôme Duval// connects and disconnects clock inputs.
327626bc4beSJérôme Duval//
328626bc4beSJérôme Duval// You should use this information to determine which clocks the user is
329626bc4beSJérôme Duval// allowed to select.
330626bc4beSJérôme Duval//
331626bc4beSJérôme Duval//===========================================================================
332626bc4beSJérôme Duval
333626bc4beSJérôme DuvalECHOSTATUS C3g::GetInputClockDetect(DWORD &dwClockDetectBits)
334626bc4beSJérôme Duval{
335626bc4beSJérôme Duval	if ( NULL == GetDspCommObject() || GetDspCommObject()->IsBoardBad() )
336626bc4beSJérôme Duval	{
337626bc4beSJérôme Duval		ECHO_DEBUGPRINTF( ("C3g::GetInputClockDetect: DSP Dead!\n") );
338626bc4beSJérôme Duval		return ECHOSTATUS_DSP_DEAD;
339626bc4beSJérôme Duval	}
340626bc4beSJérôme Duval
341626bc4beSJérôme Duval	//
342626bc4beSJérôme Duval	// Map the DSP clock detect bits to the generic driver clock detect bits
343626bc4beSJérôme Duval	//
344626bc4beSJérôme Duval	DWORD dwClocksFromDsp = GetDspCommObject()->GetInputClockDetect();
345626bc4beSJérôme Duval
346626bc4beSJérôme Duval	dwClockDetectBits = ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_MTC;
347626bc4beSJérôme Duval
348626bc4beSJérôme Duval	if (0 != (dwClocksFromDsp & E3G_CLOCK_DETECT_BIT_WORD))
349626bc4beSJérôme Duval		dwClockDetectBits |= ECHO_CLOCK_BIT_WORD;
350626bc4beSJérôme Duval
351626bc4beSJérôme Duval	switch (GetDigitalMode())
352626bc4beSJérôme Duval	{
353626bc4beSJérôme Duval		case DIGITAL_MODE_SPDIF_RCA :
354626bc4beSJérôme Duval		case DIGITAL_MODE_SPDIF_OPTICAL :
355626bc4beSJérôme Duval			if (0 != (dwClocksFromDsp & E3G_CLOCK_DETECT_BIT_SPDIF))
356626bc4beSJérôme Duval				dwClockDetectBits |= ECHO_CLOCK_BIT_SPDIF;
357626bc4beSJérôme Duval			break;
358626bc4beSJérôme Duval
359626bc4beSJérôme Duval		case DIGITAL_MODE_ADAT :
360626bc4beSJérôme Duval			if (0 != (dwClocksFromDsp & E3G_CLOCK_DETECT_BIT_ADAT))
361626bc4beSJérôme Duval				dwClockDetectBits |= ECHO_CLOCK_BIT_ADAT;
362626bc4beSJérôme Duval			break;
363626bc4beSJérôme Duval	}
364626bc4beSJérôme Duval
365626bc4beSJérôme Duval	return ECHOSTATUS_OK;
366626bc4beSJérôme Duval
367626bc4beSJérôme Duval}	// GetInputClockDetect
368626bc4beSJérôme Duval
369626bc4beSJérôme Duval
370626bc4beSJérôme Duval//===========================================================================
371626bc4beSJérôme Duval//
372626bc4beSJérôme Duval// Get the external box type
373626bc4beSJérôme Duval//
374626bc4beSJérôme Duval//===========================================================================
375626bc4beSJérôme Duval
376626bc4beSJérôme Duvalvoid C3g::Get3gBoxType(DWORD *pOriginalBoxType,DWORD *pCurrentBoxType)
377626bc4beSJérôme Duval{
378626bc4beSJérôme Duval	GetDspCommObject()->Get3gBoxType(pOriginalBoxType,pCurrentBoxType);
379626bc4beSJérôme Duval}
380626bc4beSJérôme Duval
381626bc4beSJérôme Duval
382626bc4beSJérôme Duval//===========================================================================
383626bc4beSJérôme Duval//
384626bc4beSJérôme Duval// Get the external box name
385626bc4beSJérôme Duval//
386626bc4beSJérôme Duval//===========================================================================
387626bc4beSJérôme Duval
388626bc4beSJérôme Duvalchar *C3g::Get3gBoxName()
389626bc4beSJérôme Duval{
390626bc4beSJérôme Duval	char *pszName;
391626bc4beSJérôme Duval	DWORD dwBoxType;
392626bc4beSJérôme Duval
393626bc4beSJérôme Duval	GetDspCommObject()->Get3gBoxType(&dwBoxType,NULL);
394626bc4beSJérôme Duval	switch (dwBoxType)
395626bc4beSJérôme Duval	{
396626bc4beSJérôme Duval		case GINA3G :
397626bc4beSJérôme Duval			pszName = "Gina3G";
398626bc4beSJérôme Duval			break;
399626bc4beSJérôme Duval
400626bc4beSJérôme Duval		case LAYLA3G :
401626bc4beSJérôme Duval			pszName = "Layla3G";
402626bc4beSJérôme Duval			break;
403626bc4beSJérôme Duval
404626bc4beSJérôme Duval		case NO3GBOX :
405626bc4beSJérôme Duval		default :
406626bc4beSJérôme Duval			pszName = "Echo3G";
407626bc4beSJérôme Duval			break;
408626bc4beSJérôme Duval	}
409626bc4beSJérôme Duval
410626bc4beSJérôme Duval	return pszName;
411626bc4beSJérôme Duval}
412626bc4beSJérôme Duval
413626bc4beSJérôme Duval
414626bc4beSJérôme Duval//===========================================================================
415626bc4beSJérôme Duval//
416626bc4beSJérôme Duval// Get phantom power state for Gina3G
417626bc4beSJérôme Duval//
418626bc4beSJérôme Duval//===========================================================================
419626bc4beSJérôme Duval
420626bc4beSJérôme Duvalvoid C3g::GetPhantomPower(BOOL *pfPhantom)
421626bc4beSJérôme Duval{
422626bc4beSJérôme Duval	*pfPhantom = m_fPhantomPower;
423626bc4beSJérôme Duval}
424626bc4beSJérôme Duval
425626bc4beSJérôme Duval
426626bc4beSJérôme Duval//===========================================================================
427626bc4beSJérôme Duval//
428626bc4beSJérôme Duval// Set phantom power state for Gina3G
429626bc4beSJérôme Duval//
430626bc4beSJérôme Duval//===========================================================================
431626bc4beSJérôme Duval
432626bc4beSJérôme Duvalvoid C3g::SetPhantomPower(BOOL fPhantom)
433626bc4beSJérôme Duval{
434626bc4beSJérôme Duval	DWORD dwBoxType;
435626bc4beSJérôme Duval
436626bc4beSJérôme Duval	GetDspCommObject()->Get3gBoxType(&dwBoxType,NULL);
437626bc4beSJérôme Duval	if (GINA3G == dwBoxType)
438626bc4beSJérôme Duval	{
439626bc4beSJérôme Duval		GetDspCommObject()->SetPhantomPower( fPhantom );
440626bc4beSJérôme Duval		m_fPhantomPower = fPhantom;
441626bc4beSJérôme Duval	}
442626bc4beSJérôme Duval}
443626bc4beSJérôme Duval
444626bc4beSJérôme Duval
445626bc4beSJérôme Duval//===========================================================================
446626bc4beSJérôme Duval//
447626bc4beSJérôme Duval// GetAudioLatency - returns the latency for a single pipe
448626bc4beSJérôme Duval//
449626bc4beSJérôme Duval//===========================================================================
450626bc4beSJérôme Duval
451626bc4beSJérôme Duvalvoid C3g::GetAudioLatency(ECHO_AUDIO_LATENCY *pLatency)
452626bc4beSJérôme Duval{
453626bc4beSJérôme Duval	DWORD dwSampleRate;
454626bc4beSJérôme Duval
455626bc4beSJérôme Duval	//
456626bc4beSJérôme Duval	// Adjust the stored latency values based on the sample rate
457626bc4beSJérôme Duval	//
458626bc4beSJérôme Duval	dwSampleRate = GetDspCommObject()->GetSampleRate();
459626bc4beSJérôme Duval	if (dwSampleRate <= 50000)
460626bc4beSJérôme Duval	{
461626bc4beSJérôme Duval		m_wAnalogOutputLatency = ECHO3G_ANALOG_OUTPUT_LATENCY_1X;
462626bc4beSJérôme Duval		m_wAnalogInputLatency = ECHO3G_ANALOG_INPUT_LATENCY_1X;
463626bc4beSJérôme Duval	}
464626bc4beSJérôme Duval	else
465626bc4beSJérôme Duval	{
466626bc4beSJérôme Duval		m_wAnalogOutputLatency = ECHO3G_ANALOG_OUTPUT_LATENCY_2X;
467626bc4beSJérôme Duval		m_wAnalogInputLatency = ECHO3G_ANALOG_INPUT_LATENCY_2X;
468626bc4beSJérôme Duval	}
469626bc4beSJérôme Duval
470626bc4beSJérôme Duval	//
471626bc4beSJérôme Duval	// Let the base class worry about analog vs. digital
472626bc4beSJérôme Duval	//
473626bc4beSJérôme Duval	CEchoGals::GetAudioLatency(pLatency);
474626bc4beSJérôme Duval
475626bc4beSJérôme Duval}	// GetAudioLatency
476626bc4beSJérôme Duval
477626bc4beSJérôme Duval
478be188ae1SJérôme Duval
479be188ae1SJérôme Duval//===========================================================================
480be188ae1SJérôme Duval//
481be188ae1SJérôme Duval//	Start transport for a group of pipes
482be188ae1SJérôme Duval//
483be188ae1SJérôme Duval// Use this to make sure no one tries to start digital channels 3-8
484be188ae1SJérôme Duval// with the hardware in double speed mode.
485be188ae1SJérôme Duval//
486be188ae1SJérôme Duval//===========================================================================
487be188ae1SJérôme Duval
488be188ae1SJérôme DuvalECHOSTATUS C3g::Start
489be188ae1SJérôme Duval(
490be188ae1SJérôme Duval	PCChannelMask	pChannelMask
491be188ae1SJérôme Duval)
492be188ae1SJérôme Duval{
493be188ae1SJérôme Duval	PC3gDco pDCO;
494be188ae1SJérôme Duval
495be188ae1SJérôme Duval	//
496be188ae1SJérôme Duval	// Double speed mode?
497be188ae1SJérôme Duval	//
498be188ae1SJérôme Duval	pDCO = GetDspCommObject();
499be188ae1SJérôme Duval	if (pDCO->DoubleSpeedMode())
500be188ae1SJérôme Duval	{
501be188ae1SJérôme Duval		BOOL intersect;
502be188ae1SJérôme Duval
503be188ae1SJérôme Duval		//
5044dd9e436SJérôme Duval		// See if ADAT in 3-8 or out 3-8 are being started
505be188ae1SJérôme Duval		//
5064dd9e436SJérôme Duval		intersect = pChannelMask->IsIntersectionOf( pDCO->m_Adat38Mask );
507be188ae1SJérôme Duval		if (intersect)
508be188ae1SJérôme Duval		{
509be188ae1SJérôme Duval			ECHO_DEBUGPRINTF(("Cannot start ADAT channels 3-8 in double speed mode\n"));
510be188ae1SJérôme Duval			return ECHOSTATUS_INVALID_CHANNEL;
511be188ae1SJérôme Duval		}
512be188ae1SJérôme Duval	}
513be188ae1SJérôme Duval
514be188ae1SJérôme Duval	return CEchoGals::Start(pChannelMask);
515be188ae1SJérôme Duval}
516be188ae1SJérôme Duval
517626bc4beSJérôme Duval// *** C3g.cpp ***
518