Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / AHI / Drivers / EMU10kx / emu10kx-camd.c
blobe90ac29de34c8471733ad8639c81929997277bb8
1 /*
2 emu10kx.audio - AHI driver for SoundBlaster Live! series
3 Copyright (C) 2002-2005 Martin Blom <martin@blom.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <config.h>
22 #include <clib/alib_protos.h>
23 #include <proto/utility.h>
25 #include "library.h"
26 #include "8010.h"
27 #include "hwaccess.h"
29 /******************************************************************************
30 ** Open CAMD Port ************************************************************
31 ******************************************************************************/
33 ULONG
34 OpenCAMDPort( struct Hook* hook,
35 struct EMU10kxBase* EMU10kxBase,
36 struct OpenMessage* msg )
38 struct DriverBase* AHIsubBase = (struct DriverBase*) EMU10kxBase;
39 struct EMU10kxData* dd;
41 BOOL in_use;
43 // KPrintF( "OpenCAMDPort(%ld,%ld)\n", msg->PortNum, msg->V40Mode );
45 if( msg->PortNum >= EMU10kxBase->cards_found ||
46 EMU10kxBase->driverdatas[ msg->PortNum ] == NULL )
48 Req( "No valid EMU10kxData for CAMD port %ld.", msg->PortNum );
49 return FALSE;
52 dd = EMU10kxBase->driverdatas[ msg->PortNum ];
54 ObtainSemaphore( &EMU10kxBase->semaphore );
55 in_use = ( dd->camd_transmitfunc != NULL ||
56 dd->camd_receivefunc != NULL );
57 if( !in_use )
59 dd->camd_v40 = msg->V40Mode;
60 dd->camd_transmitfunc = msg->TransmitFunc;
61 dd->camd_receivefunc = msg->ReceiveFunc;
63 ReleaseSemaphore( &EMU10kxBase->semaphore );
65 if( in_use )
67 return FALSE;
70 emu10k1_irq_disable( &dd->card, INTE_MIDIRXENABLE );
71 emu10k1_irq_disable( &dd->card, INTE_MIDITXENABLE );
72 emu10k1_mpu_reset( &dd->card );
73 emu10k1_irq_enable( &dd->card, INTE_MIDIRXENABLE );
75 return TRUE;
79 /******************************************************************************
80 ** Close CAMD Port ***********************************************************
81 ******************************************************************************/
83 VOID
84 CloseCAMDPort( struct Hook* hook,
85 struct EMU10kxBase* EMU10kxBase,
86 struct CloseMessage* msg )
88 struct EMU10kxData* dd = EMU10kxBase->driverdatas[ msg->PortNum ];
90 emu10k1_irq_disable( &dd->card, INTE_MIDIRXENABLE );
91 emu10k1_irq_disable( &dd->card, INTE_MIDITXENABLE );
92 emu10k1_mpu_reset( &dd->card );
94 ObtainSemaphore( &EMU10kxBase->semaphore );
95 dd->camd_transmitfunc = NULL;
96 dd->camd_receivefunc = NULL;
97 ReleaseSemaphore( &EMU10kxBase->semaphore );
101 /******************************************************************************
102 ** Start CAMD transmission ***************************************************
103 ******************************************************************************/
105 VOID
106 ActivateCAMDXmit( struct Hook* hook,
107 struct EMU10kxBase* EMU10kxBase,
108 struct ActivateMessage* msg )
110 struct EMU10kxData* dd = EMU10kxBase->driverdatas[ msg->PortNum ];
112 // KPrintF( "ActivateCAMDXmit(%08lx)\n", msg->PortNum );
114 emu10k1_irq_enable( &dd->card, INTE_MIDITXENABLE );
116 // The interrupt handler will now fetch the bytes and transmit them.