xref: /haiku/src/add-ons/kernel/drivers/audio/echo/generic/CEchoGals_info.cpp (revision 4dd9e43637031d2c5a6755a0184040f0de8f2884)
13895766dSshatty // ****************************************************************************
23895766dSshatty //
33895766dSshatty //		CEchoGals_info.cpp
43895766dSshatty //
53895766dSshatty //		Implementation file for the CEchoGals driver class (info functions).
63895766dSshatty //		Set editor tabs to 3 for your viewing pleasure.
73895766dSshatty //
8c2ddc71cSJérôme Duval // ----------------------------------------------------------------------------
9c2ddc71cSJérôme Duval //
10626bc4beSJérôme Duval // This file is part of Echo Digital Audio's generic driver library.
11626bc4beSJérôme Duval // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
123895766dSshatty // All rights reserved
133895766dSshatty // www.echoaudio.com
143895766dSshatty //
15626bc4beSJérôme Duval // This library is free software; you can redistribute it and/or
16626bc4beSJérôme Duval // modify it under the terms of the GNU Lesser General Public
17626bc4beSJérôme Duval // License as published by the Free Software Foundation; either
18626bc4beSJérôme Duval // version 2.1 of the License, or (at your option) any later version.
193895766dSshatty //
20626bc4beSJérôme Duval // This library is distributed in the hope that it will be useful,
21c2ddc71cSJérôme Duval // but WITHOUT ANY WARRANTY; without even the implied warranty of
22626bc4beSJérôme Duval // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23626bc4beSJérôme Duval // Lesser General Public License for more details.
243895766dSshatty //
25626bc4beSJérôme Duval // You should have received a copy of the GNU Lesser General Public
26626bc4beSJérôme Duval // License along with this library; if not, write to the Free Software
27626bc4beSJérôme Duval // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
283895766dSshatty //
293895766dSshatty // ****************************************************************************
303895766dSshatty 
313895766dSshatty #include "CEchoGals.h"
323895766dSshatty 
333895766dSshatty 
343895766dSshatty /****************************************************************************
353895766dSshatty 
363895766dSshatty 	CEchoGals informational methods
373895766dSshatty 
383895766dSshatty  ****************************************************************************/
393895766dSshatty 
403895766dSshatty //===========================================================================
413895766dSshatty //
423895766dSshatty // GetBaseCapabilities is used by the CEchoGals-derived classes to
433895766dSshatty // help fill out the ECHOGALS_CAPS struct.
443895766dSshatty //
453895766dSshatty //===========================================================================
463895766dSshatty 
GetBaseCapabilities(PECHOGALS_CAPS pCapabilities)473895766dSshatty ECHOSTATUS CEchoGals::GetBaseCapabilities
483895766dSshatty (
493895766dSshatty 	PECHOGALS_CAPS	pCapabilities
503895766dSshatty )
513895766dSshatty {
523895766dSshatty 	CChannelMask	DigMask, ChMask, AdatMask;
533895766dSshatty 	WORD				i;
543895766dSshatty 
553895766dSshatty 	//
563895766dSshatty 	//	Test only for no DSP object.  We can still get capabilities even if
573895766dSshatty 	//	board is bad.
583895766dSshatty 	//
593895766dSshatty 	if ( NULL == GetDspCommObject() )
603895766dSshatty 		return ECHOSTATUS_DSP_DEAD;
613895766dSshatty 
623895766dSshatty 	memset( pCapabilities, 0, sizeof(ECHOGALS_CAPS) );
633895766dSshatty 	strcpy( pCapabilities->szName, m_szCardInstallName );
643895766dSshatty 
653895766dSshatty 	pCapabilities->wCardType 		= GetDspCommObject()->GetCardType();
663895766dSshatty 	pCapabilities->wNumPipesOut 	= GetNumPipesOut();
673895766dSshatty 	pCapabilities->wNumPipesIn 	= GetNumPipesIn();
683895766dSshatty 	pCapabilities->wNumBussesOut 	= GetNumBussesOut();
693895766dSshatty 	pCapabilities->wNumBussesIn	= GetNumBussesIn();
703895766dSshatty 
713895766dSshatty 	pCapabilities->wFirstDigitalBusOut 	= GetFirstDigitalBusOut();
723895766dSshatty 	pCapabilities->wFirstDigitalBusIn 	= GetFirstDigitalBusIn();
733895766dSshatty 
743895766dSshatty 	pCapabilities->wNumMidiOut = GetDspCommObject()->GetNumMidiOutChannels();
753895766dSshatty 	pCapabilities->wNumMidiIn = GetDspCommObject()->GetNumMidiInChannels();
763895766dSshatty 
773895766dSshatty 	pCapabilities->dwOutClockTypes = 0;
78*4dd9e436SJérôme Duval 	pCapabilities->dwInClockTypes = ECHO_CLOCK_BIT_INTERNAL;
793895766dSshatty 
803895766dSshatty 	//
813895766dSshatty 	// Add the controls to the output pipes that are
823895766dSshatty 	// the same for all cards
833895766dSshatty 	//
843895766dSshatty 	for (i = 0; i < GetNumPipesOut(); i++)
853895766dSshatty 	{
863895766dSshatty 		pCapabilities->dwPipeOutCaps[i] = 	ECHOCAPS_GAIN |
873895766dSshatty 														ECHOCAPS_MUTE;
883895766dSshatty 	}
893895766dSshatty 
903895766dSshatty 	//
913895766dSshatty 	// Add controls to the input busses that are the same for all cards
923895766dSshatty 	//
933895766dSshatty 	WORD wFirstDigitalBusIn = GetFirstDigitalBusIn();
943895766dSshatty 	for (i = 0; i < GetNumBussesIn(); i++)
953895766dSshatty 	{
963895766dSshatty 		pCapabilities->dwBusInCaps[i] =	ECHOCAPS_PEAK_METER |
973895766dSshatty 													ECHOCAPS_VU_METER;
983895766dSshatty 		if (i >= wFirstDigitalBusIn)
993895766dSshatty 			pCapabilities->dwBusInCaps[i] |= ECHOCAPS_DIGITAL;
1003895766dSshatty 	}
1013895766dSshatty 
1023895766dSshatty 	//
1033895766dSshatty 	// And the output busses
1043895766dSshatty 	//
1053895766dSshatty 	WORD	wFirstDigitalBusOut = GetFirstDigitalBusOut();
1063895766dSshatty 	for (i = 0; i < GetNumBussesOut(); i++)
1073895766dSshatty 	{
1083895766dSshatty 		pCapabilities->dwBusOutCaps[i] = ECHOCAPS_PEAK_METER |
1093895766dSshatty 													ECHOCAPS_VU_METER	|
1103895766dSshatty 													ECHOCAPS_GAIN |
1113895766dSshatty 													ECHOCAPS_MUTE;
1123895766dSshatty 		if (i >= wFirstDigitalBusOut)
1133895766dSshatty 			pCapabilities->dwBusOutCaps[i] |= ECHOCAPS_DIGITAL;
1143895766dSshatty 	}
1153895766dSshatty 
1163895766dSshatty 	//
1173895766dSshatty 	// Digital modes & vmixer flag
1183895766dSshatty 	//
1193895766dSshatty 	pCapabilities->dwDigitalModes = GetDspCommObject()->GetDigitalModes();
1203895766dSshatty 	pCapabilities->fHasVmixer = GetDspCommObject()->HasVmixer();
1213895766dSshatty 
1223895766dSshatty 	//
1233895766dSshatty 	//	If this is not a vmixer card, output pipes are hard-wired to output busses.
1243895766dSshatty 	// Mark those pipes that are hard-wired to digital busses as digital pipes
1253895766dSshatty 	//
1263895766dSshatty 	if (GetDspCommObject()->HasVmixer())
1273895766dSshatty 	{
1283895766dSshatty 		pCapabilities->wFirstDigitalPipeOut = pCapabilities->wNumPipesOut;
1293895766dSshatty 	}
1303895766dSshatty 	else
1313895766dSshatty 	{
1323895766dSshatty 		pCapabilities->wFirstDigitalPipeOut = pCapabilities->wFirstDigitalBusOut;
1333895766dSshatty 
1343895766dSshatty 
1353895766dSshatty 		for (	i = pCapabilities->wFirstDigitalPipeOut;
1363895766dSshatty 			  	i < GetNumPipesOut();
1373895766dSshatty 			  	i++)
1383895766dSshatty 		{
1393895766dSshatty 			pCapabilities->dwPipeOutCaps[i] |= ECHOCAPS_DIGITAL;
1403895766dSshatty 		}
1413895766dSshatty 
1423895766dSshatty 	}
1433895766dSshatty 
1443895766dSshatty 	//
1453895766dSshatty 	// Input pipes are the same, vmixer or no vmixer
1463895766dSshatty 	//
1473895766dSshatty 	pCapabilities->wFirstDigitalPipeIn = pCapabilities->wFirstDigitalBusIn;
1483895766dSshatty 
1493895766dSshatty 	for (	i = pCapabilities->wFirstDigitalPipeIn;
1503895766dSshatty 		  	i < GetNumPipesIn();
1513895766dSshatty 		  	i++)
1523895766dSshatty 	{
1533895766dSshatty 		pCapabilities->dwPipeInCaps[i] |= ECHOCAPS_DIGITAL;
1543895766dSshatty 	}
1553895766dSshatty 	return ECHOSTATUS_OK;
1563895766dSshatty 
1573895766dSshatty }	// ECHOSTATUS CEchoGals::GetBaseCapabilities
1583895766dSshatty 
1593895766dSshatty 
1603895766dSshatty //===========================================================================
1613895766dSshatty //
1623895766dSshatty // MakePipeIndex is a utility function; it takes a pipe number and an
1633895766dSshatty // input or output flag and returns the pipe index.  Refer to
1643895766dSshatty // EchoGalsXface.h for more information.
1653895766dSshatty //
1663895766dSshatty //===========================================================================
1673895766dSshatty 
MakePipeIndex(WORD wPipe,BOOL fInput)1683895766dSshatty WORD CEchoGals::MakePipeIndex(WORD wPipe,BOOL fInput)
1693895766dSshatty {
1703895766dSshatty 	if (fInput)
1713895766dSshatty 		return wPipe + GetNumPipesOut();
1723895766dSshatty 
1733895766dSshatty 	return wPipe;
1743895766dSshatty 
1753895766dSshatty }	// MakePipeIndex
1763895766dSshatty 
1773895766dSshatty 
1783895766dSshatty //===========================================================================
1793895766dSshatty //
1803895766dSshatty // Get the card name as an ASCII zero-terminated string
1813895766dSshatty //
1823895766dSshatty //===========================================================================
1833895766dSshatty 
GetDeviceName()1843895766dSshatty CONST PCHAR CEchoGals::GetDeviceName()
1853895766dSshatty {
1863895766dSshatty 	return m_szCardInstallName;
1873895766dSshatty }
1883895766dSshatty 
1893895766dSshatty 
1903895766dSshatty //===========================================================================
1913895766dSshatty //
1923895766dSshatty // Get numbers of pipes and busses
1933895766dSshatty //
1943895766dSshatty //===========================================================================
1953895766dSshatty 
GetNumPipesOut()1963895766dSshatty WORD CEchoGals::GetNumPipesOut()
1973895766dSshatty {
1983895766dSshatty 	if (NULL == GetDspCommObject())
1993895766dSshatty 		return 0;
2003895766dSshatty 
2013895766dSshatty 	return GetDspCommObject()->GetNumPipesOut();
2023895766dSshatty }
2033895766dSshatty 
GetNumPipesIn()2043895766dSshatty WORD CEchoGals::GetNumPipesIn()
2053895766dSshatty {
2063895766dSshatty 	if (NULL == GetDspCommObject())
2073895766dSshatty 		return 0;
2083895766dSshatty 
2093895766dSshatty 	return GetDspCommObject()->GetNumPipesIn();
2103895766dSshatty }
2113895766dSshatty 
GetNumBussesOut()2123895766dSshatty WORD CEchoGals::GetNumBussesOut()
2133895766dSshatty {
2143895766dSshatty 	if (NULL == GetDspCommObject())
2153895766dSshatty 		return 0;
2163895766dSshatty 
2173895766dSshatty 	return GetDspCommObject()->GetNumBussesOut();
2183895766dSshatty }
2193895766dSshatty 
GetNumBussesIn()2203895766dSshatty WORD CEchoGals::GetNumBussesIn()
2213895766dSshatty {
2223895766dSshatty 	if (NULL == GetDspCommObject())
2233895766dSshatty 		return 0;
2243895766dSshatty 
2253895766dSshatty 	return GetDspCommObject()->GetNumBussesIn();
2263895766dSshatty }
2273895766dSshatty 
GetNumBusses()2283895766dSshatty WORD CEchoGals::GetNumBusses()
2293895766dSshatty {
2303895766dSshatty 	if (NULL == GetDspCommObject())
2313895766dSshatty 		return 0;
2323895766dSshatty 
2333895766dSshatty 	return GetDspCommObject()->GetNumBusses();
2343895766dSshatty }
2353895766dSshatty 
GetNumPipes()2363895766dSshatty WORD CEchoGals::GetNumPipes()
2373895766dSshatty {
2383895766dSshatty 	if (NULL == GetDspCommObject())
2393895766dSshatty 		return 0;
2403895766dSshatty 
2413895766dSshatty 	return GetDspCommObject()->GetNumPipes();
2423895766dSshatty }
2433895766dSshatty 
GetFirstDigitalBusOut()2443895766dSshatty WORD CEchoGals::GetFirstDigitalBusOut()
2453895766dSshatty {
2463895766dSshatty 	if (NULL == GetDspCommObject())
2473895766dSshatty 		return 0;
2483895766dSshatty 
2493895766dSshatty 	return GetDspCommObject()->GetFirstDigitalBusOut();
2503895766dSshatty }
2513895766dSshatty 
GetFirstDigitalBusIn()2523895766dSshatty WORD CEchoGals::GetFirstDigitalBusIn()
2533895766dSshatty {
2543895766dSshatty 	if (NULL == GetDspCommObject())
2553895766dSshatty 		return 0;
2563895766dSshatty 
2573895766dSshatty 	return GetDspCommObject()->GetFirstDigitalBusIn();
2583895766dSshatty }
2593895766dSshatty 
HasVmixer()2603895766dSshatty BOOL CEchoGals::HasVmixer()
2613895766dSshatty {
2623895766dSshatty 	if (NULL == GetDspCommObject())
2633895766dSshatty 		return 0;
2643895766dSshatty 
2653895766dSshatty 	return GetDspCommObject()->HasVmixer();
2663895766dSshatty }
2673895766dSshatty 
2683895766dSshatty 
2693895766dSshatty //===========================================================================
2703895766dSshatty //
2713895766dSshatty //	Get access to the DSP comm object
2723895766dSshatty //
2733895766dSshatty //===========================================================================
2743895766dSshatty 
GetDspCommObject()2753895766dSshatty PCDspCommObject CEchoGals::GetDspCommObject()
2763895766dSshatty {
2773895766dSshatty 	return m_pDspCommObject;
2783895766dSshatty }
2793895766dSshatty 
280