1 // ****************************************************************************
5 // Implementation file for the CGina24 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 GINA24_ANALOG_OUTPUT_LATENCY 59
34 #define GINA24_ANALOG_INPUT_LATENCY 71
35 #define GINA24_DIGITAL_OUTPUT_LATENCY 32
36 #define GINA24_DIGITAL_INPUT_LATENCY 32
40 /****************************************************************************
42 Construction and destruction
44 ****************************************************************************/
46 //===========================================================================
48 // Overload new & delete so memory for this object is allocated
49 // from non-paged memory.
51 //===========================================================================
53 PVOID
CGina24::operator new( size_t Size
)
58 Status
= OsAllocateNonPaged(Size
,&pMemory
);
60 if ( (ECHOSTATUS_OK
!= Status
) || (NULL
== pMemory
))
62 ECHO_DEBUGPRINTF(("CGina::operator new - memory allocation failed\n"));
68 memset( pMemory
, 0, Size
);
73 } // PVOID CGina24::operator new( size_t Size )
76 VOID
CGina24::operator delete( PVOID pVoid
)
78 if ( ECHOSTATUS_OK
!= OsFreeNonPaged( pVoid
) )
80 ECHO_DEBUGPRINTF(("CGina24::operator delete memory free failed\n"));
82 } // VOID CGina24::operator delete( PVOID pVoid )
85 //===========================================================================
87 // Constructor and destructor
89 //===========================================================================
91 CGina24::CGina24( PCOsSupport pOsSupport
)
92 : CEchoGals( pOsSupport
)
94 ECHO_DEBUGPRINTF( ( "CGina24::CGina24() is born!\n" ) );
96 m_wAnalogOutputLatency
= GINA24_ANALOG_OUTPUT_LATENCY
;
97 m_wAnalogInputLatency
= GINA24_ANALOG_INPUT_LATENCY
;
98 m_wDigitalOutputLatency
= GINA24_DIGITAL_OUTPUT_LATENCY
;
99 m_wDigitalInputLatency
= GINA24_DIGITAL_INPUT_LATENCY
;
105 ECHO_DEBUGPRINTF( ( "CGina24::~CGina24() is toast!\n" ) );
111 /****************************************************************************
113 Setup and hardware initialization
115 ****************************************************************************/
117 //===========================================================================
119 // Every card has an InitHw method
121 //===========================================================================
123 ECHOSTATUS
CGina24::InitHw()
128 // Call the base method
130 if ( ECHOSTATUS_OK
!= ( Status
= CEchoGals::InitHw() ) )
134 // Create the DSP comm object
136 ECHO_ASSERT(NULL
== m_pDspCommObject
);
137 m_pDspCommObject
= new CGina24DspCommObject( (PDWORD
) m_pvSharedMemory
,
139 if (NULL
== m_pDspCommObject
)
141 ECHO_DEBUGPRINTF(("CGina24::InitHw - could not create DSP comm object\n"));
142 return ECHOSTATUS_NO_MEM
;
145 ECHO_ASSERT(GetDspCommObject() );
148 // Load the DSP and the ASIC on the PCI card
150 GetDspCommObject()->LoadFirmware();
151 if ( GetDspCommObject()->IsBoardBad() )
152 return ECHOSTATUS_DSP_DEAD
;
155 // Clear the "bad board" flag; set the flags to indicate that
156 // Gina24 can handle super-interleave and supports the digital
159 m_wFlags
&= ~ECHOGALS_FLAG_BADBOARD
;
160 m_wFlags
|= ECHOGALS_ROFLAG_SUPER_INTERLEAVE_OK
|
161 ECHOGALS_ROFLAG_DIGITAL_IN_AUTOMUTE
;
164 // Must call this here after DSP is init to
165 // init gains and mutes
167 Status
= InitLineLevels();
168 if ( ECHOSTATUS_OK
!= Status
)
172 // Set defaults for +4/-10
175 for (i
= 0; i
< GetFirstDigitalBusOut(); i
++ )
177 Status
= GetDspCommObject()->
178 SetNominalLevel( i
, FALSE
); // FALSE is +4 here
180 for ( i
= 0; i
< GetFirstDigitalBusIn(); i
++ )
182 Status
= GetDspCommObject()->
183 SetNominalLevel( GetNumBussesOut() + i
, FALSE
);
187 // Set the digital mode to S/PDIF RCA
189 SetDigitalMode( DIGITAL_MODE_SPDIF_RCA
);
192 // Set the S/PDIF output format to "professional"
194 SetProfessionalSpdif( TRUE
);
197 // Get default sample rate from DSP
199 m_dwSampleRate
= GetDspCommObject()->GetSampleRate();
201 ECHO_DEBUGPRINTF( ( "CGina24::InitHw()\n" ) );
204 } // ECHOSTATUS CGina24::InitHw()
209 /****************************************************************************
211 Informational methods
213 ****************************************************************************/
215 //===========================================================================
217 // Override GetCapabilities to enumerate unique capabilties for Gina24
219 //===========================================================================
221 ECHOSTATUS
CGina24::GetCapabilities
223 PECHOGALS_CAPS pCapabilities
228 Status
= GetBaseCapabilities(pCapabilities
);
231 // Add nominal level control to analog ins & outs
234 for (i
= 0 ; i
< GetFirstDigitalBusOut(); i
++)
236 pCapabilities
->dwBusOutCaps
[i
] |= ECHOCAPS_NOMINAL_LEVEL
;
239 for (i
= 0 ; i
< GetFirstDigitalBusIn(); i
++)
241 pCapabilities
->dwBusInCaps
[i
] |= ECHOCAPS_NOMINAL_LEVEL
;
244 if ( ECHOSTATUS_OK
!= Status
)
247 pCapabilities
->dwInClockTypes
|=
248 ECHO_CLOCK_BIT_SPDIF
|
249 ECHO_CLOCK_BIT_ESYNC
|
250 ECHO_CLOCK_BIT_ESYNC96
|
254 } // ECHOSTATUS CGina24::GetCapabilities
257 //===========================================================================
259 // QueryAudioSampleRate is used to find out if this card can handle a
260 // given sample rate.
262 //===========================================================================
264 ECHOSTATUS
CGina24::QueryAudioSampleRate
269 if ( dwSampleRate
!= 8000 &&
270 dwSampleRate
!= 11025 &&
271 dwSampleRate
!= 16000 &&
272 dwSampleRate
!= 22050 &&
273 dwSampleRate
!= 32000 &&
274 dwSampleRate
!= 44100 &&
275 dwSampleRate
!= 48000 &&
276 dwSampleRate
!= 88200 &&
277 dwSampleRate
!= 96000 )
280 ("CGina24::QueryAudioSampleRate() - rate %ld invalid\n",dwSampleRate
) );
281 return ECHOSTATUS_BAD_FORMAT
;
283 if ( dwSampleRate
>= 88200 && DIGITAL_MODE_ADAT
== GetDigitalMode() )
286 ("CGina24::QueryAudioSampleRate() Sample rate cannot be "
287 "set to 88,200 Hz or 96,000 Hz in ADAT mode\n") );
288 return ECHOSTATUS_BAD_FORMAT
;
291 ECHO_DEBUGPRINTF( ( "CGina24::QueryAudioSampleRate()\n" ) );
292 return ECHOSTATUS_OK
;
293 } // ECHOSTATUS CGina24::QueryAudioSampleRate
296 void CGina24::QuerySampleRateRange(DWORD
&dwMinRate
,DWORD
&dwMaxRate
)
303 //===========================================================================
305 // GetInputClockDetect returns a bitmask consisting of all the input
306 // clocks currently connected to the hardware; this changes as the user
307 // connects and disconnects clock inputs.
309 // You should use this information to determine which clocks the user is
310 // allowed to select.
312 // Gina24 supports S/PDIF, Esync, and ADAT input clocks.
314 //===========================================================================
316 ECHOSTATUS
CGina24::GetInputClockDetect(DWORD
&dwClockDetectBits
)
318 //ECHO_DEBUGPRINTF(("CGina24::GetInputClockDetect\n"));
320 if ( NULL
== GetDspCommObject() || GetDspCommObject()->IsBoardBad() )
322 ECHO_DEBUGPRINTF( ("CGina24::GetInputClockDetect: DSP Dead!\n") );
323 return ECHOSTATUS_DSP_DEAD
;
327 // Map the DSP clock detect bits to the generic driver clock detect bits
329 DWORD dwClocksFromDsp
= GetDspCommObject()->GetInputClockDetect();
331 dwClockDetectBits
= ECHO_CLOCK_BIT_INTERNAL
;
333 if (0 != (dwClocksFromDsp
& GML_CLOCK_DETECT_BIT_SPDIF
))
334 dwClockDetectBits
|= ECHO_CLOCK_BIT_SPDIF
;
336 if (0 != (dwClocksFromDsp
& GML_CLOCK_DETECT_BIT_ADAT
))
337 dwClockDetectBits
|= ECHO_CLOCK_BIT_ADAT
;
339 if (0 != (dwClocksFromDsp
& GML_CLOCK_DETECT_BIT_ESYNC
))
340 dwClockDetectBits
|= ECHO_CLOCK_BIT_ESYNC
| ECHO_CLOCK_BIT_ESYNC96
;
342 return ECHOSTATUS_OK
;
344 } // GetInputClockDetect
347 // *** CGina24.cpp ***