00001
00002
00003
00004
00005
00006 #ifndef __AC97_MODULE_H
00007 #define __AC97_MODULE_H
00008
00009 #include <module.h>
00010 #if _SOUND_COMPATIBILITY
00011 #include "sound.h"
00012 #endif
00013 #include <KernelExport.h>
00014 #include "gaplug.h"
00015
00016
00017 #if _SOUND_COMPATIBILITY
00018 #define B_AC97_MODULE_NAME "media/ac97_module/v2"
00019 #endif
00020
00021 #define B_AC97_MODULE_NAME_V3 "media/ac97_module/v3"
00022 #define B_AC97_MAX_REGS 64
00023 #define AC97_RESET_HARDWARE 0x1
00024
00025 #define CACHE_BIT(OFFSET) (1LL<<(OFFSET))
00026
00027 typedef status_t (*ac97_write_ft)(void* host, uchar offset,
00028 uint16 value, uint16 mask);
00029 typedef uint16 (*ac97_read_ft)(void* host, uchar offset);
00030
00031
00032
00033 typedef struct ac97_t_v3 {
00034 void* host;
00035 void* hw;
00036 } ac97_t_v3;
00037
00038 #if _SOUND_COMPATIBILITY
00039
00040 typedef struct ac97_t_v2 {
00041 void* host;
00042 void* hw;
00043 ac97_write_ft Write;
00044 ac97_read_ft Read;
00045 int32 lock;
00046 sem_id cache_ben_sem;
00047 int32 cache_ben_atom;
00048 uint64 cache_valid;
00049 uint16 cache[B_AC97_MAX_REGS];
00050 } ac97_t_v2;
00051
00052 typedef struct ac97_module_info {
00053 module_info module;
00054
00055 status_t (*ac97init)(ac97_t_v2* ac97, void* host,
00056 ac97_write_ft codec_write_proc,
00057 ac97_read_ft codec_read_proc,
00058 bool init_hw);
00059 void (*ac97uninit)(ac97_t_v2* ac97);
00060
00061 status_t (*AC97_SoundSetup)(ac97_t_v2* ac97, sound_setup* ss);
00062 status_t (*AC97_GetSoundSetup)(ac97_t_v2* ac97, sound_setup* ss);
00063 status_t (*AC97_GameControl)(void* ac97, uint32 iop,
00064 void* data, size_t length);
00065 status_t (*AC97_CachedCodecWrite)(ac97_t_v2* ac97, uchar offset,
00066 uint16 value, uint16 mask);
00067 uint16 (*AC97_CachedCodecRead)(ac97_t_v2* ac97, uchar offset);
00068 } ac97_module_info;
00069
00070 typedef ac97_t_v2 ac97_t;
00071 #else
00072 typedef ac97_t_v3 ac97_t;
00073 #endif
00074
00075 typedef struct ac97_codec_info_v3 ac97_codec_info;
00076 struct ac97_codec_info_v3
00077 {
00078 uint16 capabilities[2];
00079 uint16 vendor_id[2];
00080 uint32 codec_info;
00081
00082 uint32 channel_counts;
00083 uint32 frame_rates;
00084 uint32 formats;
00085 float cvsr_min;
00086 float cvsr_max;
00087
00088 char name[16];
00089
00090 uint32 _reserved_[8];
00091 };
00092
00093 enum ac97_mode_select;
00094 typedef enum ac97_mode_select ac97_mode_select;
00095 enum ac97_mode_select
00096 {
00097 AC97_ALL_INFO,
00098 AC97_ADC_INFO,
00099 AC97_DAC_INFO,
00100 AC97_CURRENT_ADC_INFO,
00101 AC97_CURRENT_DAC_INFO
00102 };
00103
00104 typedef struct virtual_control_data virtual_control_data;
00105 struct virtual_control_data {
00106 ac97_t_v3 * codec;
00107 int32 control_id;
00108 uint32 type;
00109 uint32 _reserved[5];
00110 };
00111
00112 typedef struct ac97_module_info_v3 {
00113 module_info module;
00114
00115 status_t (*AC97_init)(ac97_t_v3* ac97, void* host, ac97_write_ft codec_write_proc, ac97_read_ft codec_read_proc, uint32 flags);
00116 void (*AC97_uninit)(ac97_t_v3* ac97);
00117 status_t (*AC97_game_control)(void* ac97, uint32 iop, void* data, size_t length);
00118 void (*AC97_plug_get_mixer_description)(ac97_t_v3* ac97, plug_api * i_info, int index, game_mixer_info * o_mixers);
00119 void (*AC97_plug_get_mixer_controls)(ac97_t_v3* ac97, plug_api * i_info, const gaplug_get_mixer_controls * io_controls);
00120 void (*AC97_plug_get_mixer_control_values)(ac97_t_v3* ac97, plug_api * i_info, const gaplug_mixer_control_values * io_request);
00121 void (*AC97_plug_set_mixer_control_values)(ac97_t_v3* ac97, plug_api * i_info, const gaplug_mixer_control_values * io_request);
00122 status_t (*AC97_cached_codec_write)(ac97_t_v3* ac97, uchar offset, uint16 value, uint16 mask);
00123 uint16 (*AC97_cached_codec_read)(ac97_t_v3* ac97, uchar offset);
00124
00125 status_t (*AC97_get_codec_info)(ac97_t_v3* ac97, ac97_mode_select what, ac97_codec_info * o_info);
00126
00127 status_t (*AC97_get_codec_format)(ac97_t_v3* ac97, ac97_mode_select what, game_codec_format * o_fmt);
00128 status_t (*AC97_set_codec_format)(ac97_t_v3* ac97, ac97_mode_select what, const game_codec_format * i_fmt);
00129
00130 status_t (*AC97_make_virtual_codec)(ac97_t_v3 * virtual_codec, virtual_control_data * virtual_control_data, int32 i_count );
00131 uint32 _reserved_[3];
00132 } ac97_module_info_v3;
00133
00134
00135
00136
00137
00138
00139
00140 #define AC97_RESET 0x00
00141 #define AC97_MASTER 0x02
00142 #define AC97_HEADPHONE 0x04
00143 #define AC97_MASTER_MONO 0x06
00144 #define AC97_MASTER_TONE 0x08
00145 #define AC97_PC_BEEP 0x0a
00146 #define AC97_PHONE 0x0c
00147 #define AC97_MIC 0x0e
00148 #define AC97_LINE 0x10
00149 #define AC97_CD 0x12
00150 #define AC97_VIDEO 0x14
00151 #define AC97_AUX 0x16
00152 #define AC97_PCM 0x18
00153 #define AC97_REC_SEL 0x1a
00154 #define AC97_REC_GAIN 0x1c
00155 #define AC97_REC_GAIN_MIC 0x1e
00156 #define AC97_GENERAL_PURPOSE 0x20
00157 #define AC97_3D_CONTROL 0x22
00158 #define AC97_RESERVED 0x24
00159 #define AC97_POWERDOWN 0x26
00160 #define AC97_CTRL_STAT 0x26
00161
00162
00163 #define AC97_EXTENDED_ID 0x28
00164 #define AC97_EXTENDED_CTRL_STAT 0x2A
00165 #define AC97_FRONT_DAC_RATE 0x2C
00166 #define AC97_SURR_DAC_RATE 0x2E
00167 #define AC97_LFE_DAC_RATE 0x30
00168 #define AC97_LR_ADC_RATE 0x32
00169 #define AC97_MIC_ADC_RATE 0x34
00170 #define AC97_2_C_LFE 0x36
00171 #define AC97_2_L_R_SURR 0x38
00172
00173 #define AC97_2_LINE1_DAC_ADC 0x46
00174 #define AC97_2_LINE2_DAC_ADC 0x48
00175 #define AC97_2_HANDSET_DAC_ADC 0x48
00176
00177 #define AC97_VENDOR_ID1 0x7c
00178 #define AC97_VENDOR_ID2 0x7e
00179
00180
00181 #define AC97_QUAD_CODEC_NONE (420)
00182 #define AC97_QUAD_CODEC_ASYMMETRIC (AC97_QUAD_CODEC_NONE + 1) // asymmetric quad codec
00183 #define AC97_QUAD_CODEC_SYMMETRIC (AC97_QUAD_CODEC_NONE + 2) // symmetric quad codec
00184
00185
00186 #define AC97_CODEC_3D_NONE (410)
00187 #define AC97_CODEC_3D_FIXED (AC97_CODEC_3D_NONE + 1)
00188 #define AC97_CODEC_3D_VARIABLE (AC97_CODEC_3D_NONE + 2)
00189 #define AC97_CODEC_3D_VAR_CENTER_ONLY (AC97_CODEC_3D_NONE + 3)
00190 #define AC97_CODEC_3D_VAR_DEPTH_ONLY (AC97_CODEC_3D_NONE + 4)
00191
00192 #endif