1626bc4beSJérôme Duval// ****************************************************************************
2626bc4beSJérôme Duval//
3626bc4beSJérôme Duval//		CIndigo.cpp
4626bc4beSJérôme Duval//
5626bc4beSJérôme Duval//		Implementation file for the CIndigo 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 "CIndigo.h"
32626bc4beSJérôme Duval
33626bc4beSJérôme Duval#define INDIGO_ANALOG_OUTPUT_LATENCY	91
34626bc4beSJérôme Duval
35626bc4beSJérôme Duval
36626bc4beSJérôme Duval/****************************************************************************
37626bc4beSJérôme Duval
38626bc4beSJérôme Duval	Construction and destruction
39626bc4beSJérôme Duval
40626bc4beSJérôme Duval ****************************************************************************/
41626bc4beSJérôme Duval
42626bc4beSJérôme Duval//===========================================================================
43626bc4beSJérôme Duval//
44626bc4beSJérôme Duval// Overload new & delete so memory for this object is allocated
45626bc4beSJérôme Duval//	from non-paged memory.
46626bc4beSJérôme Duval//
47626bc4beSJérôme Duval//===========================================================================
48626bc4beSJérôme Duval
49626bc4beSJérôme DuvalPVOID CIndigo::operator new( size_t Size )
50626bc4beSJérôme Duval{
51626bc4beSJérôme Duval	PVOID 		pMemory;
52626bc4beSJérôme Duval	ECHOSTATUS 	Status;
53626bc4beSJérôme Duval
54626bc4beSJérôme Duval	Status = OsAllocateNonPaged(Size,&pMemory);
55626bc4beSJérôme Duval
56626bc4beSJérôme Duval	if ( (ECHOSTATUS_OK != Status) || (NULL == pMemory ))
57626bc4beSJérôme Duval	{
58626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("CIndigo::operator new - memory allocation failed\n"));
59626bc4beSJérôme Duval
60626bc4beSJérôme Duval		pMemory = NULL;
61626bc4beSJérôme Duval	}
62626bc4beSJérôme Duval	else
63626bc4beSJérôme Duval	{
64626bc4beSJérôme Duval		memset( pMemory, 0, Size );
65626bc4beSJérôme Duval	}
66626bc4beSJérôme Duval
67626bc4beSJérôme Duval	return pMemory;
68626bc4beSJérôme Duval
69626bc4beSJérôme Duval}	// PVOID CIndigo::operator new( size_t Size )
70626bc4beSJérôme Duval
71626bc4beSJérôme Duval
72626bc4beSJérôme DuvalVOID  CIndigo::operator delete( PVOID pVoid )
73626bc4beSJérôme Duval{
74626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != OsFreeNonPaged( pVoid ) )
75626bc4beSJérôme Duval	{
76626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("CIndigo::operator delete memory free failed\n"));
77626bc4beSJérôme Duval	}
78626bc4beSJérôme Duval}	// VOID CIndigo::operator delete( PVOID pVoid )
79626bc4beSJérôme Duval
80626bc4beSJérôme Duval
81626bc4beSJérôme Duval
82626bc4beSJérôme Duval//===========================================================================
83626bc4beSJérôme Duval//
84626bc4beSJérôme Duval// Constructor and destructor
85626bc4beSJérôme Duval//
86626bc4beSJérôme Duval//===========================================================================
87626bc4beSJérôme Duval
88626bc4beSJérôme DuvalCIndigo::CIndigo( PCOsSupport pOsSupport )
89626bc4beSJérôme Duval	  : CEchoGalsVmixer( pOsSupport )
90626bc4beSJérôme Duval{
91626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "CIndigo::CIndigo() is born!\n" ) );
92626bc4beSJérôme Duval
93626bc4beSJérôme Duval	m_wAnalogOutputLatency = INDIGO_ANALOG_OUTPUT_LATENCY;
94626bc4beSJérôme Duval}
95626bc4beSJérôme Duval
96626bc4beSJérôme DuvalCIndigo::~CIndigo()
97626bc4beSJérôme Duval{
98626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "CIndigo::~CIndigo() is toast!\n" ) );
99626bc4beSJérôme Duval}
100626bc4beSJérôme Duval
101626bc4beSJérôme Duval
102626bc4beSJérôme Duval
103626bc4beSJérôme Duval
104626bc4beSJérôme Duval/****************************************************************************
105626bc4beSJérôme Duval
106626bc4beSJérôme Duval	Setup and hardware initialization
107626bc4beSJérôme Duval
108626bc4beSJérôme Duval ****************************************************************************/
109626bc4beSJérôme Duval
110626bc4beSJérôme Duval//===========================================================================
111626bc4beSJérôme Duval//
112626bc4beSJérôme Duval// Every card has an InitHw method
113626bc4beSJérôme Duval//
114626bc4beSJérôme Duval//===========================================================================
115626bc4beSJérôme Duval
116626bc4beSJérôme DuvalECHOSTATUS CIndigo::InitHw()
117626bc4beSJérôme Duval{
118626bc4beSJérôme Duval	ECHOSTATUS	Status;
119626bc4beSJérôme Duval
120626bc4beSJérôme Duval	//
121626bc4beSJérôme Duval	// Call the base method
122626bc4beSJérôme Duval	//
123626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != ( Status = CEchoGals::InitHw() ) )
124626bc4beSJérôme Duval		return Status;
125626bc4beSJérôme Duval
126626bc4beSJérôme Duval	//
127626bc4beSJérôme Duval	// Create the DSP comm object
128626bc4beSJérôme Duval	//
129626bc4beSJérôme Duval	m_pDspCommObject = new CIndigoDspCommObject( (PDWORD) m_pvSharedMemory,
130626bc4beSJérôme Duval															 m_pOsSupport );
131626bc4beSJérôme Duval 	if (NULL == m_pDspCommObject)
132626bc4beSJérôme Duval	{
133626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("CIndigo::InitHw - could not create DSP comm object\n"));
134626bc4beSJérôme Duval		return ECHOSTATUS_NO_MEM;
135626bc4beSJérôme Duval	}
136626bc4beSJérôme Duval
137626bc4beSJérôme Duval	//
138626bc4beSJérôme Duval	// Load the DSP
139626bc4beSJérôme Duval	//
140626bc4beSJérôme Duval	GetDspCommObject()->LoadFirmware();
141626bc4beSJérôme Duval	if ( GetDspCommObject()->IsBoardBad() )
142626bc4beSJérôme Duval		return ECHOSTATUS_DSP_DEAD;
143626bc4beSJérôme Duval
144626bc4beSJérôme Duval	//
145626bc4beSJérôme Duval	// Do flags
146626bc4beSJérôme Duval	//
147626bc4beSJérôme Duval	m_wFlags &= ~ECHOGALS_FLAG_BADBOARD;
148626bc4beSJérôme Duval	m_wFlags |= ECHOGALS_ROFLAG_SUPER_INTERLEAVE_OK;
149626bc4beSJérôme Duval
150626bc4beSJérôme Duval	//
151626bc4beSJérôme Duval	//	Must call this here after DSP is init to
152626bc4beSJérôme Duval	//	init gains and mutes
153626bc4beSJérôme Duval	//
154626bc4beSJérôme Duval	Status = InitLineLevels();
155626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != Status )
156626bc4beSJérôme Duval		return Status;
157626bc4beSJérôme Duval
158626bc4beSJérôme Duval	//
159626bc4beSJérôme Duval	//	Get default sample rate from DSP
160626bc4beSJérôme Duval	//
161626bc4beSJérôme Duval	m_dwSampleRate = GetDspCommObject()->GetSampleRate();
162626bc4beSJérôme Duval
163626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "CIndigo::InitHw()\n" ) );
164626bc4beSJérôme Duval	return Status;
165626bc4beSJérôme Duval
166626bc4beSJérôme Duval}	// ECHOSTATUS CIndigo::InitHw()
167626bc4beSJérôme Duval
168626bc4beSJérôme Duval
169626bc4beSJérôme Duval
170626bc4beSJérôme Duval
171626bc4beSJérôme Duval/****************************************************************************
172626bc4beSJérôme Duval
173626bc4beSJérôme Duval	Informational methods
174626bc4beSJérôme Duval
175626bc4beSJérôme Duval ****************************************************************************/
176626bc4beSJérôme Duval
177626bc4beSJérôme Duval//===========================================================================
178626bc4beSJérôme Duval//
179626bc4beSJérôme Duval// Override GetCapabilities to enumerate unique capabilties for this card
180626bc4beSJérôme Duval//
181626bc4beSJérôme Duval//===========================================================================
182626bc4beSJérôme Duval
183626bc4beSJérôme DuvalECHOSTATUS CIndigo::GetCapabilities
184626bc4beSJérôme Duval(
185626bc4beSJérôme Duval	PECHOGALS_CAPS	pCapabilities
186626bc4beSJérôme Duval)
187626bc4beSJérôme Duval{
188626bc4beSJérôme Duval	ECHOSTATUS Status;
189626bc4beSJérôme Duval
190626bc4beSJérôme Duval	Status = GetBaseCapabilities(pCapabilities);
191626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != Status )
192626bc4beSJérôme Duval		return Status;
193626bc4beSJérôme Duval
194626bc4beSJérôme Duval	pCapabilities->dwOutClockTypes = 0;
195626bc4beSJérôme Duval
196626bc4beSJérôme Duval	pCapabilities->dwPipeInCaps[0] = ECHOCAPS_DUMMY;
197626bc4beSJérôme Duval	pCapabilities->dwPipeInCaps[1] = ECHOCAPS_DUMMY;
198626bc4beSJérôme Duval	pCapabilities->dwBusInCaps[0] = ECHOCAPS_DUMMY;
199626bc4beSJérôme Duval	pCapabilities->dwBusInCaps[1] = ECHOCAPS_DUMMY;
200626bc4beSJérôme Duval
201626bc4beSJérôme Duval	return Status;
202626bc4beSJérôme Duval
203626bc4beSJérôme Duval}	// ECHOSTATUS CIndigo::GetCapabilities
204626bc4beSJérôme Duval
205626bc4beSJérôme Duval
206626bc4beSJérôme Duval//===========================================================================
207626bc4beSJérôme Duval//
208626bc4beSJérôme Duval// QueryAudioSampleRate is used to find out if this card can handle a
209626bc4beSJérôme Duval// given sample rate.
210626bc4beSJérôme Duval//
211626bc4beSJérôme Duval//===========================================================================
212626bc4beSJérôme Duval
213626bc4beSJérôme DuvalECHOSTATUS CIndigo::QueryAudioSampleRate
214626bc4beSJérôme Duval(
215626bc4beSJérôme Duval	DWORD		dwSampleRate
216626bc4beSJérôme Duval)
217626bc4beSJérôme Duval{
218626bc4beSJérôme Duval	if ( dwSampleRate != 32000 &&
219626bc4beSJérôme Duval		  dwSampleRate != 44100 &&
220626bc4beSJérôme Duval		  dwSampleRate != 48000 &&
221626bc4beSJérôme Duval		  dwSampleRate != 88200 &&
222626bc4beSJérôme Duval		  dwSampleRate != 96000 )
223626bc4beSJérôme Duval	{
224626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(
225626bc4beSJérôme Duval			("CIndigo::QueryAudioSampleRate() - rate %ld invalid\n",dwSampleRate) );
226626bc4beSJérôme Duval		return ECHOSTATUS_BAD_FORMAT;
227626bc4beSJérôme Duval	}
228626bc4beSJérôme Duval
229626bc4beSJérôme Duval	ECHO_DEBUGPRINTF( ( "CIndigo::QueryAudioSampleRate()\n" ) );
230626bc4beSJérôme Duval	return ECHOSTATUS_OK;
231626bc4beSJérôme Duval
232626bc4beSJérôme Duval}	// ECHOSTATUS CIndigo::QueryAudioSampleRate
233626bc4beSJérôme Duval
234626bc4beSJérôme Duval
2354dd9e436SJérôme Duvalvoid CIndigo::QuerySampleRateRange(DWORD &dwMinRate,DWORD &dwMaxRate)
2364dd9e436SJérôme Duval{
2374dd9e436SJérôme Duval	dwMinRate = 32000;
2384dd9e436SJérôme Duval	dwMaxRate = 96000;
2394dd9e436SJérôme Duval}
2404dd9e436SJérôme Duval
2414dd9e436SJérôme Duval
242626bc4beSJérôme Duval//===========================================================================
243626bc4beSJérôme Duval//
244626bc4beSJérôme Duval// Indigo & Indigo DJ don't have monitor mixers, so this works differently
245626bc4beSJérôme Duval// from other vmixer cards.
246626bc4beSJérôme Duval//
247626bc4beSJérôme Duval//===========================================================================
248626bc4beSJérôme Duval
249626bc4beSJérôme DuvalECHOSTATUS CIndigo::AdjustMonitorsForBusOut(WORD wBusOut)
250626bc4beSJérôme Duval{
251626bc4beSJérôme Duval	return ECHOSTATUS_OK;
252626bc4beSJérôme Duval}
253626bc4beSJérôme Duval
254626bc4beSJérôme Duval// *** CIndigo.cpp ***
255