xref: /haiku/src/add-ons/kernel/drivers/audio/echo/generic/CGinaDspCommObject.cpp (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
1 // ****************************************************************************
2 //
3 //  	CGinaDspCommObject.cpp
4 //
5 //		Implementation file Gina20 DSP interface class.
6 //
7 //		Copyright Echo Digital Audio Corporation (c) 1998 - 2002
8 //		All rights reserved
9 //		www.echoaudio.com
10 //
11 //		Permission is hereby granted, free of charge, to any person obtaining a
12 //		copy of this software and associated documentation files (the
13 //		"Software"), to deal with the Software without restriction, including
14 //		without limitation the rights to use, copy, modify, merge, publish,
15 //		distribute, sublicense, and/or sell copies of the Software, and to
16 //		permit persons to whom the Software is furnished to do so, subject to
17 //		the following conditions:
18 //
19 //		- Redistributions of source code must retain the above copyright
20 //		notice, this list of conditions and the following disclaimers.
21 //
22 //		- Redistributions in binary form must reproduce the above copyright
23 //		notice, this list of conditions and the following disclaimers in the
24 //		documentation and/or other materials provided with the distribution.
25 //
26 //		- Neither the name of Echo Digital Audio, nor the names of its
27 //		contributors may be used to endorse or promote products derived from
28 //		this Software without specific prior written permission.
29 //
30 //		THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 //		EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 //		MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33 //		IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
34 //		ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
35 //		TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
36 //		SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
37 //
38 // ****************************************************************************
39 
40 #include "CEchoGals.h"
41 #include "CGinaDspCommObject.h"
42 
43 #include "Gina20DSP.c"
44 
45 
46 /****************************************************************************
47 
48 	Construction and destruction
49 
50  ****************************************************************************/
51 
52 //===========================================================================
53 //
54 // Constructor
55 //
56 //===========================================================================
57 
58 CGinaDspCommObject::CGinaDspCommObject
59 (
60 	PDWORD		pdwRegBase,				// Virtual ptr to DSP registers
61 	PCOsSupport	pOsSupport
62 ) : CGdDspCommObject( pdwRegBase, pOsSupport )
63 {
64 	strcpy( m_szCardName, "Gina" );
65 	m_pdwDspRegBase = pdwRegBase;		// Virtual addr DSP's register base
66 
67 	m_wNumPipesOut = 10;
68 	m_wNumPipesIn = 4;
69 	m_wNumBussesOut = 10;
70 	m_wNumBussesIn = 4;
71 	m_wFirstDigitalBusOut = 8;
72 	m_wFirstDigitalBusIn = 2;
73 
74 	m_fHasVmixer = FALSE;
75 
76 	m_wNumMidiOut = 0;					// # MIDI out channels
77 	m_wNumMidiIn = 0;						// # MIDI in  channels
78 
79 	m_pwDspCodeToLoad = pwGina20DSP;
80 
81 	//
82 	// Since this card has no ASIC, mark it as loaded so everything works OK
83 	//
84 	m_bASICLoaded = TRUE;
85 
86 }	// CGinaDspCommObject::CGinaDspCommObject( DWORD dwPhysRegBase )
87 
88 
89 //===========================================================================
90 //
91 // Destructor
92 //
93 //===========================================================================
94 
95 CGinaDspCommObject::~CGinaDspCommObject()
96 {
97 }	// CGinaDspCommObject::~CGinaDspCommObject()
98 
99 
100 
101 
102 /****************************************************************************
103 
104 	Hardware config
105 
106  ****************************************************************************/
107 
108 //===========================================================================
109 //
110 // Destructor
111 //
112 //===========================================================================
113 
114 ECHOSTATUS CGinaDspCommObject::SetInputClock(WORD wClock)
115 {
116 	ECHO_DEBUGPRINTF( ( "CGinaDspCommObject::SetInputClock:\n" ) );
117 
118 	switch ( wClock )
119 	{
120 		case ECHO_CLOCK_INTERNAL :
121 
122 			// Reset the audio state to unknown (just in case)
123 			m_byGDCurrentClockState = GD_CLOCK_UNDEF;
124 			m_byGDCurrentSpdifStatus = GD_SPDIF_STATUS_UNDEF;
125 
126 			SetSampleRate();
127 
128 			m_wInputClock = wClock;
129 
130 			ECHO_DEBUGPRINTF( ( "\tSet Gina clock to INTERNAL\n" ) );
131 			break;
132 
133 		case ECHO_CLOCK_SPDIF :
134 			m_pDspCommPage->byGDClockState = GD_CLOCK_SPDIFIN;
135 			m_pDspCommPage->byGDSpdifStatus = GD_SPDIF_STATUS_NOCHANGE;
136 
137 			ClearHandshake();
138 			SendVector( DSP_VC_SET_GD_AUDIO_STATE );
139 
140 			m_byGDCurrentClockState = GD_CLOCK_SPDIFIN;
141 
142 			ECHO_DEBUGPRINTF( ( "\tSet Gina clock to SPDIF\n" ) );
143 
144 			m_wInputClock = wClock;
145 			break;
146 
147 		default :
148 			return ECHOSTATUS_CLOCK_NOT_SUPPORTED;
149 
150 	}		// switch ( wClock )
151 
152 	return ECHOSTATUS_OK;
153 
154 } 		// ECHOSTATUS CGinaDspCommObject::SetInputClock()
155 
156 
157 // **** GinaDspCommObject.cpp ****
158