1// ****************************************************************************
2//
3//  	CIndigoDspCommObject.cpp
4//
5//		Implementation file for EchoGals generic driver Indigo DSP
6//		interface class.
7//
8// ----------------------------------------------------------------------------
9//
10// This file is part of Echo Digital Audio's generic driver library.
11// Copyright Echo Digital Audio Corporation (c) 1998 - 2005
12// All rights reserved
13// www.echoaudio.com
14//
15// This library is free software; you can redistribute it and/or
16// modify it under the terms of the GNU Lesser General Public
17// License as published by the Free Software Foundation; either
18// version 2.1 of the License, or (at your option) any later version.
19//
20// This library 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 GNU
23// Lesser General Public License for more details.
24//
25// You should have received a copy of the GNU Lesser General Public
26// License along with this library; if not, write to the Free Software
27// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28//
29// ****************************************************************************
30
31#include "CEchoGals.h"
32#include "CIndigoDspCommObject.h"
33
34#ifdef ECHO_WDM
35#pragma optimize("",off)
36#endif
37#include "IndigoDSP.c"
38
39
40//
41//	Construction/destruction
42//
43CIndigoDspCommObject::CIndigoDspCommObject
44(
45	PDWORD		pdwRegBase,				// Virtual ptr to DSP registers
46	PCOsSupport	pOsSupport
47) : CDspCommObjectVmixer( pdwRegBase, pOsSupport )
48{
49	strcpy( m_szCardName, "Indigo" );
50	m_pdwDspRegBase = pdwRegBase;		// Virtual addr DSP's register base
51
52	m_wNumPipesOut = 8;
53	m_wNumPipesIn = 2;
54	m_wNumBussesOut = 2;
55	m_wNumBussesIn = m_wNumPipesIn;
56	m_wFirstDigitalBusOut = m_wNumBussesOut;
57	m_wFirstDigitalBusIn = m_wNumBussesIn;
58
59	m_fHasVmixer = TRUE;
60
61	m_wNumMidiOut = 0;					// # MIDI out channels
62	m_wNumMidiIn = 0;						// # MIDI in  channels
63
64	m_pDspCommPage->dwSampleRate = SWAP( (DWORD) 48000 );
65
66	m_bHasASIC = FALSE;
67
68	m_pwDspCodeToLoad = pwIndigoDSP;
69
70	m_byDigitalMode = DIGITAL_MODE_NONE;
71
72	//
73	// Since this card has no ASIC, mark it as loaded so everything works OK
74	//
75	m_bASICLoaded = TRUE;
76
77}	// CIndigoDspCommObject::CIndigoDspCommObject( DWORD dwPhysRegBase )
78
79
80CIndigoDspCommObject::~CIndigoDspCommObject()
81{
82}	// CIndigoDspCommObject::~CIndigoDspCommObject()
83
84
85//
86//	Save new clock settings and send to DSP.
87//
88ECHOSTATUS CIndigoDspCommObject::SetInputClock(WORD wClock)
89{
90
91	ECHO_DEBUGPRINTF( ("CIndigoDspCommObject::SetInputClock:\n") );
92	return ECHOSTATUS_CLOCK_NOT_SUPPORTED;
93
94}	// ECHOSTATUS CIndigoDspCommObject::SetInputClock
95
96
97//===========================================================================
98//
99// SetSampleRate
100//
101// Set the audio sample rate for Indigo
102//
103//===========================================================================
104
105DWORD CIndigoDspCommObject::SetSampleRate( DWORD dwNewSampleRate )
106{
107	//
108	// Set the sample rate
109	//
110	DWORD dwControlReg = MIA_48000;
111
112	switch ( dwNewSampleRate )
113	{
114		case 96000 :
115			dwControlReg = MIA_96000;
116			break;
117
118		case 88200 :
119			dwControlReg = MIA_88200;
120			break;
121
122		case 44100 :
123			dwControlReg = MIA_44100;
124			break;
125
126		case 32000 :
127			dwControlReg = MIA_32000;
128			break;
129	}
130
131	//
132	// Set the control register if it has changed
133	//
134	if (dwControlReg != GetControlRegister())
135	{
136		if ( !WaitForHandshake() )
137			return 0xffffffff;
138
139		//
140		// Set the values in the comm page; the dwSampleRate
141		// field isn't used by the DSP, but is read by the call
142		// to GetSampleRate below
143		//
144		m_pDspCommPage->dwSampleRate = SWAP( dwNewSampleRate );
145		SetControlRegister( dwControlReg );
146
147		//
148		//	Poke the DSP
149		//
150		ClearHandshake();
151		SendVector( DSP_VC_UPDATE_CLOCKS );
152	}
153
154	return GetSampleRate();
155
156} // DWORD CIndigoDspCommObject::SetSampleRate( DWORD dwNewSampleRate )
157
158// **** CIndigoDspCommObject.cpp ****
159