ac97_module.h

Go to the documentation of this file.
00001 /* ac97_module.h */
00002 
00003 /* Interface description for drivers interfacing with AC97 compliant codecs */
00004 /* Copyright © 1998-2001 Be Incorporated. All rights reserved. */
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 //  Do not use the members of this struct; treat it as opaque. Actual use in
00032 //  the AC97 module may vary from these names.
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;               /* spinlock for Read/Write */
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];    //  reset reg (00h), extended caps (28h)
00079     uint16      vendor_id[2];       //  vendor ID (7Ch and 7Eh)
00080     uint32      codec_info;         //  codec specific (rev ID etc)
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];           //  "cs4297" or similar short chip name
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   //    get_codec_info works on all mode_select values
00125   status_t  (*AC97_get_codec_info)(ac97_t_v3* ac97, ac97_mode_select what, ac97_codec_info * o_info);
00126   //    get/set_codec_format works only on CURRENT mode_select values
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   //  binding
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  *  Audio Codec '97 registers
00136  *  For more details see AC'97 Component Specification, revision 2.1,
00137  *  by Intel Corporation (http://developer.intel.com).
00138  */
00139 
00140 #define AC97_RESET          0x00    /* Reset */
00141 #define AC97_MASTER         0x02    /* Master Volume */
00142 #define AC97_HEADPHONE      0x04    /* Headphone Volume (optional) */
00143 #define AC97_MASTER_MONO    0x06    /* Master Volume Mono (optional) */
00144 #define AC97_MASTER_TONE    0x08    /* Master Tone (Bass & Treble) (optional) */
00145 #define AC97_PC_BEEP        0x0a    /* PC Beep Volume (optinal) */
00146 #define AC97_PHONE          0x0c    /* Phone Volume (optional) */
00147 #define AC97_MIC            0x0e    /* MIC Volume */
00148 #define AC97_LINE           0x10    /* Line In Volume */
00149 #define AC97_CD             0x12    /* CD Volume */
00150 #define AC97_VIDEO          0x14    /* Video Volume (optional) */
00151 #define AC97_AUX            0x16    /* AUX Volume (optional) */
00152 #define AC97_PCM            0x18    /* PCM Volume */
00153 #define AC97_REC_SEL        0x1a    /* Record Select */
00154 #define AC97_REC_GAIN       0x1c    /* Record Gain */
00155 #define AC97_REC_GAIN_MIC   0x1e    /* Record Gain MIC (optional) */
00156 #define AC97_GENERAL_PURPOSE    0x20    /* General Purpose (optional) */
00157 #define AC97_3D_CONTROL     0x22    /* 3D Control (optional) */
00158 #define AC97_RESERVED       0x24    /* Reserved */
00159 #define AC97_POWERDOWN      0x26    /* Powerdown control / status */
00160 #define AC97_CTRL_STAT  0x26
00161 
00162 /* range 0x28-0x3a - AUDIO */
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    /* 6-channel volume control (optional) */
00171 #define AC97_2_L_R_SURR     0x38    /* 4-channel volume control (optional) */
00172 /* range 0x3c-0x58 - MODEM */
00173 #define AC97_2_LINE1_DAC_ADC    0x46    /* modem dac/adc level conrol */
00174 #define AC97_2_LINE2_DAC_ADC    0x48    
00175 #define AC97_2_HANDSET_DAC_ADC  0x48    
00176 /* range 0x5a-0x7b - Vendor Specific */
00177 #define AC97_VENDOR_ID1     0x7c    /* Vendor ID1 */
00178 #define AC97_VENDOR_ID2     0x7e    /* Vendor ID2 (revision) */
00179 
00180 /* AC'97 Quad codec type */
00181 #define AC97_QUAD_CODEC_NONE            (420)                           // non-quad codec
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 /* AC'97 CODEC 3D Effect Type */
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

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.