1 // ****************************************************************************
3 // CGMLDspCommObject.cpp
5 // Implementation file for GML cards (Gina24, Mona, and Layla24).
7 // ----------------------------------------------------------------------------
9 // This file is part of Echo Digital Audio's generic driver library.
10 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
11 // All rights reserved
14 // This library is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Lesser General Public
16 // License as published by the Free Software Foundation; either
17 // version 2.1 of the License, or (at your option) any later version.
19 // This library is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 // Lesser General Public License for more details.
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this library; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // ****************************************************************************
30 #include "CEchoGals.h"
31 #include "CGMLDspCommObject.h"
33 //===========================================================================
35 // Set the S/PDIF output format
37 //===========================================================================
39 void CGMLDspCommObject::SetProfessionalSpdif
46 dwControlReg
= GetControlRegister();
49 // Clear the current S/PDIF flags
51 dwControlReg
&= GML_SPDIF_FORMAT_CLEAR_MASK
;
54 // Set the new S/PDIF flags depending on the mode
56 dwControlReg
|= GML_SPDIF_TWO_CHANNEL
|
58 GML_SPDIF_COPY_PERMIT
;
64 dwControlReg
|= GML_SPDIF_PRO_MODE
;
66 switch ( GetSampleRate() )
69 dwControlReg
|= GML_SPDIF_SAMPLE_RATE0
|
70 GML_SPDIF_SAMPLE_RATE1
;
74 dwControlReg
|= GML_SPDIF_SAMPLE_RATE0
;
78 dwControlReg
|= GML_SPDIF_SAMPLE_RATE1
;
87 switch ( GetSampleRate() )
90 dwControlReg
|= GML_SPDIF_SAMPLE_RATE0
|
91 GML_SPDIF_SAMPLE_RATE1
;
95 dwControlReg
|= GML_SPDIF_SAMPLE_RATE1
;
101 // Handle the non-audio bit
104 dwControlReg
|= GML_SPDIF_NOT_AUDIO
;
107 // Write the control reg
109 WriteControlReg( dwControlReg
);
111 m_bProfessionalSpdif
= bNewStatus
;
113 ECHO_DEBUGPRINTF( ("CGMLDspCommObject::SetProfessionalSpdif to %s\n",
114 ( bNewStatus
) ? "Professional" : "Consumer") );
116 } // void CGMLDspCommObject::SetProfessionalSpdif( ... )
121 //===========================================================================
123 // SetSpdifOutNonAudio
125 // Set the state of the non-audio status bit in the S/PDIF out status bits
127 //===========================================================================
129 void CGMLDspCommObject::SetSpdifOutNonAudio(BOOL bNonAudio
)
133 dwControlReg
= GetControlRegister();
136 dwControlReg
|= GML_SPDIF_NOT_AUDIO
;
140 dwControlReg
&= ~GML_SPDIF_NOT_AUDIO
;
143 m_bNonAudio
= bNonAudio
;
145 WriteControlReg( dwControlReg
);
150 //===========================================================================
154 // Most configuration of Gina24, Layla24, or Mona is
155 // accomplished by writing the control register. WriteControlReg
156 // sends the new control register value to the DSP.
158 //===========================================================================
160 ECHOSTATUS
CGMLDspCommObject::WriteControlReg
166 ECHO_DEBUGPRINTF(("CGMLDspCommObject::WriteControlReg 0x%lx\n",dwControlReg
));
168 if ( !m_bASICLoaded
)
170 ECHO_DEBUGPRINTF(("CGMLDspCommObject::WriteControlReg - ASIC not loaded\n"));
171 return( ECHOSTATUS_ASIC_NOT_LOADED
);
175 if ( !WaitForHandshake() )
177 ECHO_DEBUGPRINTF(("CGMLDspCommObject::WriteControlReg - no handshake\n"));
178 return ECHOSTATUS_DSP_DEAD
;
181 #ifdef DIGITAL_INPUT_AUTO_MUTE_SUPPORT
183 // Handle the digital input auto-mute
185 if (TRUE
== m_fDigitalInAutoMute
)
186 dwControlReg
|= GML_DIGITAL_IN_AUTO_MUTE
;
188 dwControlReg
&= ~GML_DIGITAL_IN_AUTO_MUTE
;
192 // Write the control register
194 if (fForceWrite
|| (dwControlReg
!= GetControlRegister()) )
196 SetControlRegister( dwControlReg
);
198 ECHO_DEBUGPRINTF( ("CGMLDspCommObject::WriteControlReg: Setting 0x%lx\n",
202 return SendVector( DSP_VC_WRITE_CONTROL_REG
);
206 ECHO_DEBUGPRINTF( ("CGMLDspCommObject::WriteControlReg: control reg is already 0x%lx\n",
210 return ECHOSTATUS_OK
;
212 } // ECHOSTATUS CGMLDspCommObject::WriteControlReg( DWORD dwControlReg )
214 //===========================================================================
218 //===========================================================================
220 ECHOSTATUS
CGMLDspCommObject::SetDigitalMode
228 // See if the current input clock doesn't match the new digital mode
232 case DIGITAL_MODE_SPDIF_RCA
:
233 case DIGITAL_MODE_SPDIF_OPTICAL
:
234 wInvalidClock
= ECHO_CLOCK_ADAT
;
237 case DIGITAL_MODE_ADAT
:
238 wInvalidClock
= ECHO_CLOCK_SPDIF
;
242 wInvalidClock
= 0xffff;
246 if (wInvalidClock
== GetInputClock())
248 SetInputClock( ECHO_CLOCK_INTERNAL
);
249 SetSampleRate( 48000 );
253 // Clear the current digital mode
257 dwControlReg
= GetControlRegister();
258 dwControlReg
&= GML_DIGITAL_MODE_CLEAR_MASK
;
261 // Tweak the control reg
265 case DIGITAL_MODE_SPDIF_RCA
:
268 case DIGITAL_MODE_SPDIF_OPTICAL
:
269 dwControlReg
|= GML_SPDIF_OPTICAL_MODE
;
272 case DIGITAL_MODE_ADAT
:
273 dwControlReg
|= GML_ADAT_MODE
;
274 dwControlReg
&= ~GML_DOUBLE_SPEED_MODE
;
278 return ECHOSTATUS_DIGITAL_MODE_NOT_SUPPORTED
;
282 // Write the control reg
284 WriteControlReg( dwControlReg
);
286 m_byDigitalMode
= byNewMode
;
288 ECHO_DEBUGPRINTF( ("CGMLDspCommObject::SetDigitalMode to %ld\n",
289 (DWORD
) m_byDigitalMode
) );
291 return ECHOSTATUS_OK
;
293 } // ECHOSTATUS CGMLDspCommObject::SetDigitalMode
296 // **** CGMLDspCommObject.cpp ****