5 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 6 * Definitions for Yahama YMF724/740/744/754 chips 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 /* #define YMFREG(codec, reg) (codec->port + YDSXGR_##reg) */ 31 #define YDSXGR_INTFLAG 0x0004 32 #define YDSXGR_ACTIVITY 0x0006 33 #define YDSXGR_GLOBALCTRL 0x0008 34 #define YDSXGR_ZVCTRL 0x000A 35 #define YDSXGR_TIMERCTRL 0x0010 36 #define YDSXGR_TIMERCTRL_TEN 0x0001 37 #define YDSXGR_TIMERCTRL_TIEN 0x0002 38 #define YDSXGR_TIMERCOUNT 0x0012 39 #define YDSXGR_SPDIFOUTCTRL 0x0018 40 #define YDSXGR_SPDIFOUTSTATUS 0x001C 41 #define YDSXGR_EEPROMCTRL 0x0020 42 #define YDSXGR_SPDIFINCTRL 0x0034 43 #define YDSXGR_SPDIFINSTATUS 0x0038 44 #define YDSXGR_DSPPROGRAMDL 0x0048 45 #define YDSXGR_DLCNTRL 0x004C 46 #define YDSXGR_GPIOININTFLAG 0x0050 47 #define YDSXGR_GPIOININTENABLE 0x0052 48 #define YDSXGR_GPIOINSTATUS 0x0054 49 #define YDSXGR_GPIOOUTCTRL 0x0056 50 #define YDSXGR_GPIOFUNCENABLE 0x0058 51 #define YDSXGR_GPIOTYPECONFIG 0x005A 52 #define YDSXGR_AC97CMDDATA 0x0060 53 #define YDSXGR_AC97CMDADR 0x0062 54 #define YDSXGR_PRISTATUSDATA 0x0064 55 #define YDSXGR_PRISTATUSADR 0x0066 56 #define YDSXGR_SECSTATUSDATA 0x0068 57 #define YDSXGR_SECSTATUSADR 0x006A 58 #define YDSXGR_SECCONFIG 0x0070 59 #define YDSXGR_LEGACYOUTVOL 0x0080 60 #define YDSXGR_LEGACYOUTVOLL 0x0080 61 #define YDSXGR_LEGACYOUTVOLR 0x0082 62 #define YDSXGR_NATIVEDACOUTVOL 0x0084 63 #define YDSXGR_NATIVEDACOUTVOLL 0x0084 64 #define YDSXGR_NATIVEDACOUTVOLR 0x0086 65 #define YDSXGR_SPDIFOUTVOL 0x0088 66 #define YDSXGR_SPDIFOUTVOLL 0x0088 67 #define YDSXGR_SPDIFOUTVOLR 0x008A 68 #define YDSXGR_AC3OUTVOL 0x008C 69 #define YDSXGR_AC3OUTVOLL 0x008C 70 #define YDSXGR_AC3OUTVOLR 0x008E 71 #define YDSXGR_PRIADCOUTVOL 0x0090 72 #define YDSXGR_PRIADCOUTVOLL 0x0090 73 #define YDSXGR_PRIADCOUTVOLR 0x0092 74 #define YDSXGR_LEGACYLOOPVOL 0x0094 75 #define YDSXGR_LEGACYLOOPVOLL 0x0094 76 #define YDSXGR_LEGACYLOOPVOLR 0x0096 77 #define YDSXGR_NATIVEDACLOOPVOL 0x0098 78 #define YDSXGR_NATIVEDACLOOPVOLL 0x0098 79 #define YDSXGR_NATIVEDACLOOPVOLR 0x009A 80 #define YDSXGR_SPDIFLOOPVOL 0x009C 81 #define YDSXGR_SPDIFLOOPVOLL 0x009E 82 #define YDSXGR_SPDIFLOOPVOLR 0x009E 83 #define YDSXGR_AC3LOOPVOL 0x00A0 84 #define YDSXGR_AC3LOOPVOLL 0x00A0 85 #define YDSXGR_AC3LOOPVOLR 0x00A2 86 #define YDSXGR_PRIADCLOOPVOL 0x00A4 87 #define YDSXGR_PRIADCLOOPVOLL 0x00A4 88 #define YDSXGR_PRIADCLOOPVOLR 0x00A6 89 #define YDSXGR_NATIVEADCINVOL 0x00A8 90 #define YDSXGR_NATIVEADCINVOLL 0x00A8 91 #define YDSXGR_NATIVEADCINVOLR 0x00AA 92 #define YDSXGR_NATIVEDACINVOL 0x00AC 93 #define YDSXGR_NATIVEDACINVOLL 0x00AC 94 #define YDSXGR_NATIVEDACINVOLR 0x00AE 95 #define YDSXGR_BUF441OUTVOL 0x00B0 96 #define YDSXGR_BUF441OUTVOLL 0x00B0 97 #define YDSXGR_BUF441OUTVOLR 0x00B2 98 #define YDSXGR_BUF441LOOPVOL 0x00B4 99 #define YDSXGR_BUF441LOOPVOLL 0x00B4 100 #define YDSXGR_BUF441LOOPVOLR 0x00B6 101 #define YDSXGR_SPDIFOUTVOL2 0x00B8 102 #define YDSXGR_SPDIFOUTVOL2L 0x00B8 103 #define YDSXGR_SPDIFOUTVOL2R 0x00BA 104 #define YDSXGR_SPDIFLOOPVOL2 0x00BC 105 #define YDSXGR_SPDIFLOOPVOL2L 0x00BC 106 #define YDSXGR_SPDIFLOOPVOL2R 0x00BE 107 #define YDSXGR_ADCSLOTSR 0x00C0 108 #define YDSXGR_RECSLOTSR 0x00C4 109 #define YDSXGR_ADCFORMAT 0x00C8 110 #define YDSXGR_RECFORMAT 0x00CC 111 #define YDSXGR_P44SLOTSR 0x00D0 112 #define YDSXGR_STATUS 0x0100 113 #define YDSXGR_CTRLSELECT 0x0104 114 #define YDSXGR_MODE 0x0108 115 #define YDSXGR_SAMPLECOUNT 0x010C 116 #define YDSXGR_NUMOFSAMPLES 0x0110 117 #define YDSXGR_CONFIG 0x0114 118 #define YDSXGR_PLAYCTRLSIZE 0x0140 119 #define YDSXGR_RECCTRLSIZE 0x0144 120 #define YDSXGR_EFFCTRLSIZE 0x0148 121 #define YDSXGR_WORKSIZE 0x014C 122 #define YDSXGR_MAPOFREC 0x0150 123 #define YDSXGR_MAPOFEFFECT 0x0154 124 #define YDSXGR_PLAYCTRLBASE 0x0158 125 #define YDSXGR_RECCTRLBASE 0x015C 126 #define YDSXGR_EFFCTRLBASE 0x0160 127 #define YDSXGR_WORKBASE 0x0164 128 #define YDSXGR_DSPINSTRAM 0x1000 129 #define YDSXGR_CTRLINSTRAM 0x4000 131 #define YDSXG_AC97READCMD 0x8000 132 #define YDSXG_AC97WRITECMD 0x0000 134 #define PCIR_DSXGCTRL 0x48 136 #define YDSXG_DSPLENGTH 0x0080 137 #define YDSXG_CTRLLENGTH 0x3000 139 #define YDSXG_DEFAULT_WORK_SIZE 0x0400 141 #define YDSXG_PLAYBACK_VOICES 64 142 #define YDSXG_CAPTURE_VOICES 2 143 #define YDSXG_EFFECT_VOICES 5 145 /* maxinum number of AC97 codecs connected, AC97 2.0 defined 4 */ 148 #define YMF_SAMPF 256/* Samples per frame @48000 */ 151 * The slot/voice control bank (2 of these per voice) 154 typedefstruct stru_ymfpci_playback_bank
{ 157 u32 base
;/* 32-bit address */ 158 u32 loop_start
;/* 32-bit offset */ 159 u32 loop_end
;/* 32-bit offset */ 160 u32 loop_frac
;/* 8-bit fraction - loop_start */ 161 u32 delta_end
;/* pitch delta end */ 170 u32 status
;/* P3: Always 0 for some reason. */ 173 u32 start
;/* P3: J. reads this to know where chip is. */ 185 } ymfpci_playback_bank_t
; 187 typedefstruct stru_ymfpci_capture_bank
{ 188 u32 base
;/* 32-bit address */ 189 u32 loop_end
;/* 32-bit offset */ 190 u32 start
;/* 32-bit offset */ 191 u32 num_of_loops
;/* counter */ 192 } ymfpci_capture_bank_t
; 194 typedefstruct stru_ymfpci_effect_bank
{ 195 u32 base
;/* 32-bit address */ 196 u32 loop_end
;/* 32-bit offset */ 197 u32 start
;/* 32-bit offset */ 199 } ymfpci_effect_bank_t
; 201 typedefstruct stru_ymfpci_voice ymfpci_voice_t
; 202 typedefstruct ymf_pcm ymfpci_pcm_t
; 204 * Throughout the code Yaroslav names YMF unit pointer "codec" 205 * even though it does not correspond to any codec. Must be historic. 206 * We replace it with "unit" over time. 207 * AC97 parts use "codec" to denote a codec, naturally. 209 typedefstruct ymf_unit ymfpci_t
; 215 } ymfpci_voice_type_t
; 217 struct stru_ymfpci_voice
{ 224 ymfpci_playback_bank_t
*bank
; 225 void(*interrupt
)(ymfpci_t
*codec
, ymfpci_voice_t
*voice
); 242 ymfpci_pcm_type_t type
; 243 struct ymf_state
*state
; 244 ymfpci_voice_t
*voices
[2];/* playback only */ 250 u8 rev
;/* PCI revision */ 254 unsigned int bank_size_playback
; 255 unsigned int bank_size_capture
; 256 unsigned int bank_size_effect
; 257 unsigned int work_size
; 259 void*bank_base_playback
;// + 260 void*bank_base_capture
;// + 261 void*bank_base_effect
;// + 265 ymfpci_playback_bank_t
*bank_playback
[YDSXG_PLAYBACK_VOICES
][2]; 266 ymfpci_capture_bank_t
*bank_capture
[YDSXG_CAPTURE_VOICES
][2]; 267 ymfpci_effect_bank_t
*bank_effect
[YDSXG_EFFECT_VOICES
][2]; 272 ymfpci_voice_t voices
[64]; 274 struct ac97_codec
*ac97_codec
[NR_AC97
]; 280 spinlock_t voice_lock
; 282 /* soundcore stuff */ 284 struct semaphore open_sem
; 286 struct list_head ymf_devs
; 287 struct ymf_state
*states
[1];// * 288 /* ypcm may be the same thing as state, but not for record, effects. */ 292 * "Software" or virtual channel, an instance of opened /dev/dsp. 297 /* OSS buffer management stuff */ 303 /* our buffer acts like a circular ring */ 304 unsigned hwptr
;/* where dma last started */ 305 unsigned swptr
;/* where driver last clear/filled */ 306 int count
;/* fill count */ 307 unsigned total_bytes
;/* total bytes dmaed by hardware */ 309 unsigned error
;/* number of over/underruns */ 310 wait_queue_head_t wait
;/* put process on wait queue when no more space in buffer */ 312 /* redundant, but makes calculations easier */ 314 unsigned dmasize
;/* Total rawbuf[] size */ 315 unsigned fragsamples
; 320 unsigned ossfragshift
; 322 unsigned subdivision
; 325 struct ymf_pcm_format
{ 326 int format
;/* OSS format */ 327 int rate
;/* rate in Hz */ 328 int voices
;/* number of voices */ 329 int shift
;/* redundant, computed from the above */ 333 struct ymf_unit
*unit
;/* backpointer */ 335 /* virtual channel number */ 336 int virt
;// * unused a.t.m. 338 struct ymf_pcm ypcm
;// * 339 struct ymf_dmabuf dmabuf
;// * 340 struct ymf_pcm_format format
;// * 343 #endif/* __YMFPCI_H */