1 // ****************************************************************************
5 // Implementation file for the CDarla24 driver class.
6 // Set editor tabs to 3 for your viewing pleasure.
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 // ****************************************************************************
33 #define DARLA24_ANALOG_OUTPUT_LATENCY 59
34 #define DARLA24_ANALOG_INPUT_LATENCY 71
37 /****************************************************************************
39 Construction and destruction
41 ****************************************************************************/
43 //===========================================================================
45 // Overload new & delete so memory for this object is allocated
46 // from non-paged memory.
48 //===========================================================================
50 PVOID
CDarla24::operator new( size_t Size
)
55 Status
= OsAllocateNonPaged(Size
,&pMemory
);
57 if ( (ECHOSTATUS_OK
!= Status
) || (NULL
== pMemory
))
59 ECHO_DEBUGPRINTF(("CDarla24::operator new - memory allocation failed\n"));
65 memset( pMemory
, 0, Size
);
70 } // PVOID CDarla24::operator new( size_t Size )
73 VOID
CDarla24::operator delete( PVOID pVoid
)
75 if ( ECHOSTATUS_OK
!= OsFreeNonPaged( pVoid
) )
77 ECHO_DEBUGPRINTF(("CDarla24::operator delete memory free failed\n"));
79 } // VOID CDarla24::operator delete( PVOID pVoid )
82 //===========================================================================
84 // Constructor and destructor
86 //===========================================================================
88 CDarla24::CDarla24( PCOsSupport pOsSupport
)
89 : CEchoGals( pOsSupport
)
91 ECHO_DEBUGPRINTF( ( "CDarla24::CDarla24() is born!\n" ) );
93 m_wAnalogOutputLatency
= DARLA24_ANALOG_OUTPUT_LATENCY
;
94 m_wAnalogInputLatency
= DARLA24_ANALOG_INPUT_LATENCY
;
100 ECHO_DEBUGPRINTF( ( "CDarla24::~CDarla24() is toast!\n" ) );
106 /****************************************************************************
108 Setup and hardware initialization
110 ****************************************************************************/
112 //===========================================================================
114 // Every card has an InitHw method
116 //===========================================================================
118 ECHOSTATUS
CDarla24::InitHw()
124 // Call the base method
126 if ( ECHOSTATUS_OK
!= ( Status
= CEchoGals::InitHw() ) )
130 // Create the DSP comm object
132 ECHO_ASSERT(NULL
== m_pDspCommObject
);
133 m_pDspCommObject
= new CDarla24DspCommObject( (PDWORD
) m_pvSharedMemory
,
135 if (NULL
== m_pDspCommObject
)
137 ECHO_DEBUGPRINTF(("CDarla24::InitHw - could not create DSP comm object\n"));
138 return ECHOSTATUS_NO_MEM
;
144 GetDspCommObject()->LoadFirmware();
145 if ( GetDspCommObject()->IsBoardBad() )
146 return ECHOSTATUS_DSP_DEAD
;
149 // Clear the "bad board" flag; set the flag to indicate that
150 // Darla24 can handle super-interleave.
152 m_wFlags
&= ~ECHOGALS_FLAG_BADBOARD
;
153 m_wFlags
|= ECHOGALS_ROFLAG_SUPER_INTERLEAVE_OK
;
156 // Must call this here after DSP is init to
159 Status
= InitLineLevels();
160 if ( ECHOSTATUS_OK
!= Status
)
164 // Set defaults for +4/-10
166 for (i
= 0; i
< GetNumBusses(); i
++ )
168 GetDspCommObject()->SetNominalLevel( i
, FALSE
); // FALSE is +4 here
172 // Get default sample rate from DSP
174 m_dwSampleRate
= GetDspCommObject()->GetSampleRate();
175 ECHO_DEBUGPRINTF( ( "CDarla24::InitHw()\n" ) );
179 } // ECHOSTATUS CDarla24::InitHw()
184 /****************************************************************************
186 Informational methods
188 ****************************************************************************/
190 //===========================================================================
192 // Override GetCapabilities to enumerate unique capabilties for this card
194 //===========================================================================
196 ECHOSTATUS
CDarla24::GetCapabilities
198 PECHOGALS_CAPS pCapabilities
204 Status
= GetBaseCapabilities(pCapabilities
);
207 // Add nominal level control to in & out busses
209 for (i
= 0 ; i
< GetNumBussesOut(); i
++)
211 pCapabilities
->dwBusOutCaps
[i
] |= ECHOCAPS_NOMINAL_LEVEL
;
214 for (i
= 0 ; i
< GetNumBussesIn(); i
++)
216 pCapabilities
->dwBusInCaps
[i
] |= ECHOCAPS_NOMINAL_LEVEL
;
219 if ( ECHOSTATUS_OK
!= Status
)
222 pCapabilities
->dwInClockTypes
|= ECHO_CLOCK_BIT_ESYNC
;
226 } // ECHOSTATUS CDarla24::GetCapabilities
229 //===========================================================================
231 // GetInputClockDetect returns a bitmask consisting of all the input
232 // clocks currently connected to the hardware; this changes as the user
233 // connects and disconnects clock inputs.
235 // You should use this information to determine which clocks the user is
236 // allowed to select.
238 // Darla24 only supports Esync input clock.
240 //===========================================================================
242 ECHOSTATUS
CDarla24::GetInputClockDetect(DWORD
&dwClockDetectBits
)
244 if ( NULL
== GetDspCommObject() || GetDspCommObject()->IsBoardBad() )
246 ECHO_DEBUGPRINTF( ("CDarla24::GetInputClockDetect: DSP Dead!\n") );
247 return ECHOSTATUS_DSP_DEAD
;
250 DWORD dwClocksFromDsp
= GetDspCommObject()->GetInputClockDetect();
252 dwClockDetectBits
= ECHO_CLOCK_BIT_INTERNAL
;
254 if (0 != (dwClocksFromDsp
& GLDM_CLOCK_DETECT_BIT_ESYNC
))
255 dwClockDetectBits
|= ECHO_CLOCK_BIT_ESYNC
;
257 return ECHOSTATUS_OK
;
259 } // GetInputClockDetect
262 //===========================================================================
264 // QueryAudioSampleRate is used to find out if this card can handle a
265 // given sample rate.
267 //===========================================================================
269 ECHOSTATUS
CDarla24::QueryAudioSampleRate
274 if ( dwSampleRate
!= 8000 &&
275 dwSampleRate
!= 11025 &&
276 dwSampleRate
!= 16000 &&
277 dwSampleRate
!= 22050 &&
278 dwSampleRate
!= 32000 &&
279 dwSampleRate
!= 44100 &&
280 dwSampleRate
!= 48000 &&
281 dwSampleRate
!= 88200 &&
282 dwSampleRate
!= 96000 )
285 ("CDarla24::QueryAudioSampleRate() - rate %ld invalid\n",
287 return ECHOSTATUS_BAD_FORMAT
;
290 ECHO_DEBUGPRINTF( ( "CDarla24::QueryAudioSampleRate()\n" ) );
291 return ECHOSTATUS_OK
;
293 } // ECHOSTATUS CDarla24::QueryAudioSampleRate
295 void CDarla24::QuerySampleRateRange(DWORD
&dwMinRate
,DWORD
&dwMaxRate
)
303 // *** CDarla24.cpp ***