xref: /haiku/src/add-ons/kernel/drivers/audio/emuxki/ac97.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Emuxki BeOS Driver for Creative Labs SBLive!/Audigy series
3  *
4  * Copyright (c) 2002, Jerome Duval (jerome.duval@free.fr)
5  *
6  * Original code : BeOS Driver for Intel ICH AC'97 Link interface
7  * Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
8  *
9  * All rights reserved.
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * - Redistributions of source code must retain the above copyright notice,
14  *   this list of conditions and the following disclaimer.
15  * - Redistributions in binary form must reproduce the above copyright notice,
16  *   this list of conditions and the following disclaimer in the documentation
17  *   and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31 #ifndef _AC97_H_
32 #define _AC97_H_
33 
34 #include "config.h"
35 
36 enum AC97_REGISTER {
37 	AC97_RESET				= 0x00,
38 	AC97_MASTER_VOLUME		= 0x02,
39 	AC97_AUX_OUT_VOLUME		= 0x04,
40 	AC97_MONO_VOLUME		= 0x06,
41 	AC97_MASTER_TONE		= 0x08,
42 	AC97_PC_BEEP_VOLUME		= 0x0A,
43 	AC97_PHONE_VOLUME		= 0x0C,
44 	AC97_MIC_VOLUME			= 0x0E,
45 	AC97_LINE_IN_VOLUME		= 0x10,
46 	AC97_CD_VOLUME			= 0x12,
47 	AC97_VIDEO_VOLUME		= 0x14,
48 	AC97_AUX_IN_VOLUME		= 0x16,
49 	AC97_PCM_OUT_VOLUME		= 0x18,
50 	AC97_RECORD_SELECT		= 0x1A,
51 	AC97_RECORD_GAIN		= 0x1C,
52 	AC97_RECORD_GAIN_MIC	= 0x1E,
53 	AC97_GENERAL_PURPOSE	= 0x20,
54 	AC97_3D_CONTROL			= 0x22,
55 	AC97_PAGING				= 0x24,
56 	AC97_POWERDOWN			= 0x26,
57 	AC97_EXTENDED_AUDIO_ID 	= 0x28,
58 	AC97_EXTENDED_AUDIO_STATUS	= 0x2A,
59 	AC97_PCM_FRONT_DAC_RATE	= 0x2C,
60 	AC97_PCM_SURR_DAC_RATE	= 0x2E,
61 	AC97_PCM_LFE_DAC_RATE	= 0x30,
62 	AC97_PCM_LR_ADC_RATE	= 0x32,
63 	AC97_MIC_ADC_RATE		= 0x34,
64 	AC97_CENTER_LFE_VOLUME	= 0x36,
65 	AC97_SURROUND_VOLUME	= 0x38,
66 	AC97_SPDIF_CONTROL		= 0x3A,
67 	AC97_VENDOR_ID1			= 0x7C,
68 	AC97_VENDOR_ID2			= 0x7E
69 };
70 
71 const char *	ac97_get_3d_stereo_enhancement(device_config *config);
72 const char *	ac97_get_vendor_id_description(device_config *config);
73 uint32			ac97_get_vendor_id(device_config *config);
74 void			ac97_init(device_config *config);
75 
76 void ac97_amp_enable(device_config *config, bool yesno);
77 
78 typedef enum {
79 	B_MIX_GAIN = 1 << 0,
80 	B_MIX_MUTE = 1 << 1,
81 	B_MIX_MONO = 1 << 2,
82 	B_MIX_STEREO = 1 << 3,
83 	B_MIX_MUX = 1 << 4,
84 	B_MIX_MICBOOST = 1 << 5,
85 	B_MIX_RECORDMUX = 1 << 6
86 } ac97_mixer_type;
87 
88 typedef struct _ac97_source_info {
89 	const char *name;
90 	ac97_mixer_type  type;
91 
92 	int32	id;
93 	uint8	reg;
94 	uint16	default_value;
95 	uint8 	bits:3;
96 	uint8	ofs:4;
97 	uint8	mute:1;
98 	uint8	polarity:1; // max_gain -> 0
99 	float	min_gain;
100 	float	max_gain;
101 	float	granularity;
102 } ac97_source_info;
103 
104 extern const ac97_source_info source_info[];
105 extern const int32 source_info_size;
106 
107 #endif
108