revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Drivers / EMU10kx / emu10kx-ac97.c
bloba711330c79ff8d5e472ed3074d849d941d7dcdc9
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 static ULONG dsp_register[] = {
30 /* Input volume GPR */
31 VOL_AHI_FRONT_L,
32 VOL_AHI_FRONT_R,
33 VOL_AHI_REAR_L,
34 VOL_AHI_REAR_R,
35 VOL_AHI_SURROUND_L,
36 VOL_AHI_SURROUND_R,
37 VOL_AHI_CENTER,
38 VOL_AHI_LFE,
40 VOL_SPDIF_CD_L,
41 VOL_SPDIF_CD_R,
42 VOL_SPDIF_IN_L,
43 VOL_SPDIF_IN_R,
45 /* Output volume GPR */
46 VOL_SPDIF_FRONT_L,
47 VOL_SPDIF_FRONT_R,
48 VOL_SPDIF_REAR_L,
49 VOL_SPDIF_REAR_R,
50 VOL_SPDIF_SURROUND_L,
51 VOL_SPDIF_SURROUND_R,
52 VOL_SPDIF_CENTER,
53 VOL_SPDIF_LFE,
55 VOL_ANALOG_FRONT_L,
56 VOL_ANALOG_FRONT_R,
57 VOL_ANALOG_REAR_L,
58 VOL_ANALOG_REAR_R,
59 VOL_ANALOG_SURROUND_L,
60 VOL_ANALOG_SURROUND_R,
61 VOL_ANALOG_CENTER,
62 VOL_ANALOG_LFE,
64 /* AHI_FRONT-to-rear GPR */
65 VOL_FRONT_REAR_L,
66 VOL_FRONT_REAR_R,
68 /* AHI_SURROUND-to-rear GPR */
69 VOL_SURROUND_REAR_L,
70 VOL_SURROUND_REAR_R,
72 /* AHI_FRONT-to-center and AHI_FRONT-to-LFE GPRs */
73 VOL_FRONT_CENTER,
74 VOL_FRONT_LFE
77 /******************************************************************************
78 ** Read from AC97 register ****************************************************
79 ******************************************************************************/
81 ULONG
82 AC97GetFunc( struct Hook* hook,
83 struct EMU10kxBase* EMU10kxBase,
84 struct AC97GetMessage* msg )
86 struct DriverBase* AHIsubBase = (struct DriverBase*) EMU10kxBase;
87 struct EMU10kxData* dd;
89 if( msg->CardNum >= (ULONG) EMU10kxBase->cards_found ||
90 EMU10kxBase->driverdatas[ msg->CardNum ] == NULL )
92 Req( "No valid EMU10kxData for AC97 card %ld.", msg->CardNum );
93 return ~0UL;
96 dd = EMU10kxBase->driverdatas[ msg->CardNum ];
98 if (msg->Register >= emu10kx_dsp_first &&
99 msg->Register < emu10kx_dsp_last) {
100 #if 0
101 ULONG reg = dsp_register[msg->Register - emu10kx_dsp_first];
102 #endif
104 // Reading is not supported yet ...
105 return ~0UL;
107 else {
108 return emu10k1_readac97( &dd->card, msg->Register );
113 /******************************************************************************
114 ** Write to AC97 register *****************************************************
115 ******************************************************************************/
117 VOID
118 AC97SetFunc( struct Hook* hook,
119 struct EMU10kxBase* EMU10kxBase,
120 struct AC97SetMessage* msg )
122 struct DriverBase* AHIsubBase = (struct DriverBase*) EMU10kxBase;
123 struct EMU10kxData* dd;
125 if( msg->CardNum >= (ULONG) EMU10kxBase->cards_found ||
126 EMU10kxBase->driverdatas[ msg->CardNum ] == NULL )
128 Req( "No valid EMU10kxData for AC97 card %ld.", msg->CardNum );
129 return;
132 dd = EMU10kxBase->driverdatas[ msg->CardNum ];
134 if (msg->Register >= emu10kx_dsp_first &&
135 msg->Register < emu10kx_dsp_last) {
136 ULONG reg = dsp_register[msg->Register - emu10kx_dsp_first];
138 emu10k1_set_volume_gpr( &dd->card, reg, 100, VOL_5BIT);
140 else {
141 emu10k1_writeac97( &dd->card, msg->Register, msg->Value );