1 // ****************************************************************************
3 // CMiaDspCommObject.cpp
5 // Implementation file for EchoGals generic driver Mia DSP
8 // ----------------------------------------------------------------------------
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
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.
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.
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
29 // ****************************************************************************
31 #include "CEchoGals.h"
32 #include "CMiaDspCommObject.h"
37 /****************************************************************************
39 Construction and destruction
41 ****************************************************************************/
43 //===========================================================================
47 //===========================================================================
49 CMiaDspCommObject::CMiaDspCommObject
51 PDWORD pdwRegBase
, // Virtual ptr to DSP registers
52 PCOsSupport pOsSupport
53 ) : CDspCommObjectVmixer( pdwRegBase
, pOsSupport
)
55 strcpy( m_szCardName
, "Mia" );
56 m_pdwDspRegBase
= pdwRegBase
; // Virtual addr DSP's register base
62 m_wFirstDigitalBusOut
= 2;
63 m_wFirstDigitalBusIn
= 2;
67 if (MIA_MIDI_REV
== pOsSupport
->GetCardRev())
69 m_wNumMidiOut
= 1; // # MIDI out channels
70 m_wNumMidiIn
= 1; // # MIDI in channels
73 m_pDspCommPage
->dwSampleRate
= SWAP( (DWORD
) 44100 );
77 m_pwDspCodeToLoad
= pwMiaDSP
;
79 m_byDigitalMode
= DIGITAL_MODE_NONE
;
82 // Since this card has no ASIC, mark it as loaded so everything works OK
86 } // CMiaDspCommObject::CMiaDspCommObject( DWORD dwPhysRegBase )
89 //===========================================================================
93 //===========================================================================
95 CMiaDspCommObject::~CMiaDspCommObject()
97 } // CMiaDspCommObject::~CMiaDspCommObject()
102 /****************************************************************************
104 Hardware setup and config
106 ****************************************************************************/
108 //===========================================================================
110 // Set the input clock
112 //===========================================================================
114 ECHOSTATUS
CMiaDspCommObject::SetInputClock(WORD wClock
)
116 DWORD dwSampleRate
= GetSampleRate();
118 ECHO_DEBUGPRINTF( ("CMiaDspCommObject::SetInputClock:\n") );
122 case ECHO_CLOCK_INTERNAL
:
124 ECHO_DEBUGPRINTF( ( "\tSet Mia clock to INTERNAL\n" ) );
126 // If the sample rate is out of range for some reason, set it
127 // to a reasonable value. mattg
128 if ( ( dwSampleRate
< 32000 ) ||
129 ( dwSampleRate
> 96000 ) )
131 dwSampleRate
= 48000;
135 } // CLK_CLOCKININTERNAL
137 case ECHO_CLOCK_SPDIF
:
139 ECHO_DEBUGPRINTF( ( "\tSet Mia clock to SPDIF\n" ) );
141 } // CLK_CLOCKINSPDIF
144 ECHO_DEBUGPRINTF(("Input clock 0x%x not supported for Mia\n",wClock
));
146 return ECHOSTATUS_CLOCK_NOT_SUPPORTED
;
147 } // switch (wInputClock)
149 m_wInputClock
= wClock
;
151 SetSampleRate( dwSampleRate
);
153 return ECHOSTATUS_OK
;
154 } // ECHOSTATUS CMiaDspCommObject::SetInputClock
157 //===========================================================================
161 // Set the audio sample rate for Mia
163 //===========================================================================
165 DWORD
CMiaDspCommObject::SetSampleRate( DWORD dwNewSampleRate
)
168 // Set the sample rate
170 DWORD dwControlReg
= MIA_48000
;
172 switch ( dwNewSampleRate
)
175 dwControlReg
= MIA_96000
;
179 dwControlReg
= MIA_88200
;
183 dwControlReg
= MIA_44100
;
187 dwControlReg
= MIA_32000
;
192 // Override the clock setting if this Mia is set to S/PDIF clock
194 if ( ECHO_CLOCK_SPDIF
== GetInputClock() )
195 dwControlReg
|= MIA_SPDIF
;
198 // Set the control register if it has changed
200 if (dwControlReg
!= GetControlRegister())
202 if ( !WaitForHandshake() )
206 // Set the values in the comm page; the dwSampleRate
207 // field isn't used by the DSP, but is read by the call
208 // to GetSampleRate below
210 m_pDspCommPage
->dwSampleRate
= SWAP( dwNewSampleRate
);
211 SetControlRegister( dwControlReg
);
217 SendVector( DSP_VC_UPDATE_CLOCKS
);
220 return GetSampleRate();
222 } // DWORD CMiaDspCommObject::SetSampleRate( DWORD dwNewSampleRate )
224 // **** CMiaDspCommObject.cpp ****