gus.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. #ifndef __SOUND_GUS_H
  2. #define __SOUND_GUS_H
  3. /*
  4. * Global structures used for GUS part of ALSA driver
  5. * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <sound/pcm.h>
  24. #include <sound/rawmidi.h>
  25. #include <sound/timer.h>
  26. #include <sound/seq_midi_emul.h>
  27. #include <sound/seq_device.h>
  28. #include <linux/io.h>
  29. /* IO ports */
  30. #define GUSP(gus, x) ((gus)->gf1.port + SNDRV_g_u_s_##x)
  31. #define SNDRV_g_u_s_MIDICTRL (0x320-0x220)
  32. #define SNDRV_g_u_s_MIDISTAT (0x320-0x220)
  33. #define SNDRV_g_u_s_MIDIDATA (0x321-0x220)
  34. #define SNDRV_g_u_s_GF1PAGE (0x322-0x220)
  35. #define SNDRV_g_u_s_GF1REGSEL (0x323-0x220)
  36. #define SNDRV_g_u_s_GF1DATALOW (0x324-0x220)
  37. #define SNDRV_g_u_s_GF1DATAHIGH (0x325-0x220)
  38. #define SNDRV_g_u_s_IRQSTAT (0x226-0x220)
  39. #define SNDRV_g_u_s_TIMERCNTRL (0x228-0x220)
  40. #define SNDRV_g_u_s_TIMERDATA (0x229-0x220)
  41. #define SNDRV_g_u_s_DRAM (0x327-0x220)
  42. #define SNDRV_g_u_s_MIXCNTRLREG (0x220-0x220)
  43. #define SNDRV_g_u_s_IRQDMACNTRLREG (0x22b-0x220)
  44. #define SNDRV_g_u_s_REGCNTRLS (0x22f-0x220)
  45. #define SNDRV_g_u_s_BOARDVERSION (0x726-0x220)
  46. #define SNDRV_g_u_s_MIXCNTRLPORT (0x726-0x220)
  47. #define SNDRV_g_u_s_IVER (0x325-0x220)
  48. #define SNDRV_g_u_s_MIXDATAPORT (0x326-0x220)
  49. #define SNDRV_g_u_s_MAXCNTRLPORT (0x326-0x220)
  50. /* GF1 registers */
  51. /* global registers */
  52. #define SNDRV_GF1_GB_ACTIVE_VOICES 0x0e
  53. #define SNDRV_GF1_GB_VOICES_IRQ 0x0f
  54. #define SNDRV_GF1_GB_GLOBAL_MODE 0x19
  55. #define SNDRV_GF1_GW_LFO_BASE 0x1a
  56. #define SNDRV_GF1_GB_VOICES_IRQ_READ 0x1f
  57. #define SNDRV_GF1_GB_DRAM_DMA_CONTROL 0x41
  58. #define SNDRV_GF1_GW_DRAM_DMA_LOW 0x42
  59. #define SNDRV_GF1_GW_DRAM_IO_LOW 0x43
  60. #define SNDRV_GF1_GB_DRAM_IO_HIGH 0x44
  61. #define SNDRV_GF1_GB_SOUND_BLASTER_CONTROL 0x45
  62. #define SNDRV_GF1_GB_ADLIB_TIMER_1 0x46
  63. #define SNDRV_GF1_GB_ADLIB_TIMER_2 0x47
  64. #define SNDRV_GF1_GB_RECORD_RATE 0x48
  65. #define SNDRV_GF1_GB_REC_DMA_CONTROL 0x49
  66. #define SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL 0x4b
  67. #define SNDRV_GF1_GB_RESET 0x4c
  68. #define SNDRV_GF1_GB_DRAM_DMA_HIGH 0x50
  69. #define SNDRV_GF1_GW_DRAM_IO16 0x51
  70. #define SNDRV_GF1_GW_MEMORY_CONFIG 0x52
  71. #define SNDRV_GF1_GB_MEMORY_CONTROL 0x53
  72. #define SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR 0x54
  73. #define SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR 0x55
  74. #define SNDRV_GF1_GW_FIFO_SIZE 0x56
  75. #define SNDRV_GF1_GW_INTERLEAVE 0x57
  76. #define SNDRV_GF1_GB_COMPATIBILITY 0x59
  77. #define SNDRV_GF1_GB_DECODE_CONTROL 0x5a
  78. #define SNDRV_GF1_GB_VERSION_NUMBER 0x5b
  79. #define SNDRV_GF1_GB_MPU401_CONTROL_A 0x5c
  80. #define SNDRV_GF1_GB_MPU401_CONTROL_B 0x5d
  81. #define SNDRV_GF1_GB_EMULATION_IRQ 0x60
  82. /* voice specific registers */
  83. #define SNDRV_GF1_VB_ADDRESS_CONTROL 0x00
  84. #define SNDRV_GF1_VW_FREQUENCY 0x01
  85. #define SNDRV_GF1_VW_START_HIGH 0x02
  86. #define SNDRV_GF1_VW_START_LOW 0x03
  87. #define SNDRV_GF1_VA_START SNDRV_GF1_VW_START_HIGH
  88. #define SNDRV_GF1_VW_END_HIGH 0x04
  89. #define SNDRV_GF1_VW_END_LOW 0x05
  90. #define SNDRV_GF1_VA_END SNDRV_GF1_VW_END_HIGH
  91. #define SNDRV_GF1_VB_VOLUME_RATE 0x06
  92. #define SNDRV_GF1_VB_VOLUME_START 0x07
  93. #define SNDRV_GF1_VB_VOLUME_END 0x08
  94. #define SNDRV_GF1_VW_VOLUME 0x09
  95. #define SNDRV_GF1_VW_CURRENT_HIGH 0x0a
  96. #define SNDRV_GF1_VW_CURRENT_LOW 0x0b
  97. #define SNDRV_GF1_VA_CURRENT SNDRV_GF1_VW_CURRENT_HIGH
  98. #define SNDRV_GF1_VB_PAN 0x0c
  99. #define SNDRV_GF1_VW_OFFSET_RIGHT 0x0c
  100. #define SNDRV_GF1_VB_VOLUME_CONTROL 0x0d
  101. #define SNDRV_GF1_VB_UPPER_ADDRESS 0x10
  102. #define SNDRV_GF1_VW_EFFECT_HIGH 0x11
  103. #define SNDRV_GF1_VW_EFFECT_LOW 0x12
  104. #define SNDRV_GF1_VA_EFFECT SNDRV_GF1_VW_EFFECT_HIGH
  105. #define SNDRV_GF1_VW_OFFSET_LEFT 0x13
  106. #define SNDRV_GF1_VB_ACCUMULATOR 0x14
  107. #define SNDRV_GF1_VB_MODE 0x15
  108. #define SNDRV_GF1_VW_EFFECT_VOLUME 0x16
  109. #define SNDRV_GF1_VB_FREQUENCY_LFO 0x17
  110. #define SNDRV_GF1_VB_VOLUME_LFO 0x18
  111. #define SNDRV_GF1_VW_OFFSET_RIGHT_FINAL 0x1b
  112. #define SNDRV_GF1_VW_OFFSET_LEFT_FINAL 0x1c
  113. #define SNDRV_GF1_VW_EFFECT_VOLUME_FINAL 0x1d
  114. /* ICS registers */
  115. #define SNDRV_ICS_MIC_DEV 0
  116. #define SNDRV_ICS_LINE_DEV 1
  117. #define SNDRV_ICS_CD_DEV 2
  118. #define SNDRV_ICS_GF1_DEV 3
  119. #define SNDRV_ICS_NONE_DEV 4
  120. #define SNDRV_ICS_MASTER_DEV 5
  121. /* LFO */
  122. #define SNDRV_LFO_TREMOLO 0
  123. #define SNDRV_LFO_VIBRATO 1
  124. /* misc */
  125. #define SNDRV_GF1_DMA_UNSIGNED 0x80
  126. #define SNDRV_GF1_DMA_16BIT 0x40
  127. #define SNDRV_GF1_DMA_IRQ 0x20
  128. #define SNDRV_GF1_DMA_WIDTH16 0x04
  129. #define SNDRV_GF1_DMA_READ 0x02 /* read from GUS's DRAM */
  130. #define SNDRV_GF1_DMA_ENABLE 0x01
  131. /* ramp ranges */
  132. #define SNDRV_GF1_ATTEN(x) (snd_gf1_atten_table[x])
  133. #define SNDRV_GF1_MIN_VOLUME 1800
  134. #define SNDRV_GF1_MAX_VOLUME 4095
  135. #define SNDRV_GF1_MIN_OFFSET (SNDRV_GF1_MIN_VOLUME>>4)
  136. #define SNDRV_GF1_MAX_OFFSET 255
  137. #define SNDRV_GF1_MAX_TDEPTH 90
  138. /* defines for memory manager */
  139. #define SNDRV_GF1_MEM_BLOCK_16BIT 0x0001
  140. #define SNDRV_GF1_MEM_OWNER_DRIVER 0x0001
  141. #define SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE 0x0002
  142. #define SNDRV_GF1_MEM_OWNER_WAVE_GF1 0x0003
  143. #define SNDRV_GF1_MEM_OWNER_WAVE_IWFFFF 0x0004
  144. /* constants for interrupt handlers */
  145. #define SNDRV_GF1_HANDLER_MIDI_OUT 0x00010000
  146. #define SNDRV_GF1_HANDLER_MIDI_IN 0x00020000
  147. #define SNDRV_GF1_HANDLER_TIMER1 0x00040000
  148. #define SNDRV_GF1_HANDLER_TIMER2 0x00080000
  149. #define SNDRV_GF1_HANDLER_VOICE 0x00100000
  150. #define SNDRV_GF1_HANDLER_DMA_WRITE 0x00200000
  151. #define SNDRV_GF1_HANDLER_DMA_READ 0x00400000
  152. #define SNDRV_GF1_HANDLER_ALL (0xffff0000&~SNDRV_GF1_HANDLER_VOICE)
  153. /* constants for DMA flags */
  154. #define SNDRV_GF1_DMA_TRIGGER 1
  155. /* --- */
  156. struct snd_gus_card;
  157. /* GF1 specific structure */
  158. struct snd_gf1_bank_info {
  159. unsigned int address;
  160. unsigned int size;
  161. };
  162. struct snd_gf1_mem_block {
  163. unsigned short flags; /* flags - SNDRV_GF1_MEM_BLOCK_XXXX */
  164. unsigned short owner; /* owner - SNDRV_GF1_MEM_OWNER_XXXX */
  165. unsigned int share; /* share count */
  166. unsigned int share_id[4]; /* share ID */
  167. unsigned int ptr;
  168. unsigned int size;
  169. char *name;
  170. struct snd_gf1_mem_block *next;
  171. struct snd_gf1_mem_block *prev;
  172. };
  173. struct snd_gf1_mem {
  174. struct snd_gf1_bank_info banks_8[4];
  175. struct snd_gf1_bank_info banks_16[4];
  176. struct snd_gf1_mem_block *first;
  177. struct snd_gf1_mem_block *last;
  178. struct mutex memory_mutex;
  179. };
  180. struct snd_gf1_dma_block {
  181. void *buffer; /* buffer in computer's RAM */
  182. unsigned long buf_addr; /* buffer address */
  183. unsigned int addr; /* address in onboard memory */
  184. unsigned int count; /* count in bytes */
  185. unsigned int cmd; /* DMA command (format) */
  186. void (*ack)(struct snd_gus_card * gus, void *private_data);
  187. void *private_data;
  188. struct snd_gf1_dma_block *next;
  189. };
  190. struct snd_gus_port {
  191. struct snd_midi_channel_set * chset;
  192. struct snd_gus_card * gus;
  193. int mode; /* operation mode */
  194. int client; /* sequencer client number */
  195. int port; /* sequencer port number */
  196. unsigned int midi_has_voices: 1;
  197. };
  198. struct snd_gus_voice;
  199. #define SNDRV_GF1_VOICE_TYPE_PCM 0
  200. #define SNDRV_GF1_VOICE_TYPE_SYNTH 1
  201. #define SNDRV_GF1_VOICE_TYPE_MIDI 2
  202. #define SNDRV_GF1_VFLG_RUNNING (1<<0)
  203. #define SNDRV_GF1_VFLG_EFFECT_TIMER1 (1<<1)
  204. #define SNDRV_GF1_VFLG_PAN (1<<2)
  205. enum snd_gus_volume_state {
  206. VENV_BEFORE,
  207. VENV_ATTACK,
  208. VENV_SUSTAIN,
  209. VENV_RELEASE,
  210. VENV_DONE,
  211. VENV_VOLUME
  212. };
  213. struct snd_gus_voice {
  214. int number;
  215. unsigned int use: 1,
  216. pcm: 1,
  217. synth:1,
  218. midi: 1;
  219. unsigned int flags;
  220. unsigned char client;
  221. unsigned char port;
  222. unsigned char index;
  223. unsigned char pad;
  224. #ifdef CONFIG_SND_DEBUG
  225. unsigned int interrupt_stat_wave;
  226. unsigned int interrupt_stat_volume;
  227. #endif
  228. void (*handler_wave) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
  229. void (*handler_volume) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
  230. void (*handler_effect) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
  231. void (*volume_change) (struct snd_gus_card * gus);
  232. struct snd_gus_sample_ops *sample_ops;
  233. /* running status / registers */
  234. unsigned short fc_register;
  235. unsigned short fc_lfo;
  236. unsigned short gf1_volume;
  237. unsigned char control;
  238. unsigned char mode;
  239. unsigned char gf1_pan;
  240. unsigned char effect_accumulator;
  241. unsigned char volume_control;
  242. unsigned char venv_value_next;
  243. enum snd_gus_volume_state venv_state;
  244. enum snd_gus_volume_state venv_state_prev;
  245. unsigned short vlo;
  246. unsigned short vro;
  247. unsigned short gf1_effect_volume;
  248. /* --- */
  249. void *private_data;
  250. void (*private_free)(struct snd_gus_voice *voice);
  251. };
  252. struct snd_gf1 {
  253. unsigned int enh_mode:1, /* enhanced mode (GFA1) */
  254. hw_lfo:1, /* use hardware LFO */
  255. sw_lfo:1, /* use software LFO */
  256. effect:1; /* use effect voices */
  257. unsigned long port; /* port of GF1 chip */
  258. struct resource *res_port1;
  259. struct resource *res_port2;
  260. int irq; /* IRQ number */
  261. int dma1; /* DMA1 number */
  262. int dma2; /* DMA2 number */
  263. unsigned int memory; /* GUS's DRAM size in bytes */
  264. unsigned int rom_memory; /* GUS's ROM size in bytes */
  265. unsigned int rom_present; /* bitmask */
  266. unsigned int rom_banks; /* GUS's ROM banks */
  267. struct snd_gf1_mem mem_alloc;
  268. /* registers */
  269. unsigned short reg_page;
  270. unsigned short reg_regsel;
  271. unsigned short reg_data8;
  272. unsigned short reg_data16;
  273. unsigned short reg_irqstat;
  274. unsigned short reg_dram;
  275. unsigned short reg_timerctrl;
  276. unsigned short reg_timerdata;
  277. unsigned char ics_regs[6][2];
  278. /* --------- */
  279. unsigned char active_voices; /* active voices */
  280. unsigned char active_voice; /* selected voice (GF1PAGE register) */
  281. struct snd_gus_voice voices[32]; /* GF1 voices */
  282. unsigned int default_voice_address;
  283. unsigned short playback_freq; /* GF1 playback (mixing) frequency */
  284. unsigned short mode; /* see to SNDRV_GF1_MODE_XXXX */
  285. unsigned char volume_ramp;
  286. unsigned char smooth_pan;
  287. unsigned char full_range_pan;
  288. unsigned char pad0;
  289. unsigned char *lfos;
  290. /* interrupt handlers */
  291. void (*interrupt_handler_midi_out) (struct snd_gus_card * gus);
  292. void (*interrupt_handler_midi_in) (struct snd_gus_card * gus);
  293. void (*interrupt_handler_timer1) (struct snd_gus_card * gus);
  294. void (*interrupt_handler_timer2) (struct snd_gus_card * gus);
  295. void (*interrupt_handler_dma_write) (struct snd_gus_card * gus);
  296. void (*interrupt_handler_dma_read) (struct snd_gus_card * gus);
  297. #ifdef CONFIG_SND_DEBUG
  298. unsigned int interrupt_stat_midi_out;
  299. unsigned int interrupt_stat_midi_in;
  300. unsigned int interrupt_stat_timer1;
  301. unsigned int interrupt_stat_timer2;
  302. unsigned int interrupt_stat_dma_write;
  303. unsigned int interrupt_stat_dma_read;
  304. unsigned int interrupt_stat_voice_lost;
  305. #endif
  306. /* synthesizer */
  307. int seq_client;
  308. struct snd_gus_port seq_ports[4];
  309. /* timer */
  310. unsigned short timer_enabled;
  311. struct snd_timer *timer1;
  312. struct snd_timer *timer2;
  313. /* midi */
  314. unsigned short uart_cmd;
  315. unsigned int uart_framing;
  316. unsigned int uart_overrun;
  317. /* dma operations */
  318. unsigned int dma_flags;
  319. unsigned int dma_shared;
  320. struct snd_gf1_dma_block *dma_data_pcm;
  321. struct snd_gf1_dma_block *dma_data_pcm_last;
  322. struct snd_gf1_dma_block *dma_data_synth;
  323. struct snd_gf1_dma_block *dma_data_synth_last;
  324. void (*dma_ack)(struct snd_gus_card * gus, void *private_data);
  325. void *dma_private_data;
  326. /* pcm */
  327. int pcm_channels;
  328. int pcm_alloc_voices;
  329. unsigned short pcm_volume_level_left;
  330. unsigned short pcm_volume_level_right;
  331. unsigned short pcm_volume_level_left1;
  332. unsigned short pcm_volume_level_right1;
  333. unsigned char pcm_rcntrl_reg;
  334. unsigned char pad_end;
  335. };
  336. /* main structure for GUS card */
  337. struct snd_gus_card {
  338. struct snd_card *card;
  339. unsigned int
  340. initialized: 1, /* resources were initialized */
  341. equal_irq:1, /* GF1 and CODEC shares IRQ (GUS MAX only) */
  342. equal_dma:1, /* if dma channels are equal (not valid for daughter board) */
  343. ics_flag:1, /* have we ICS mixer chip */
  344. ics_flipped:1, /* ICS mixer have flipped some channels? */
  345. codec_flag:1, /* have we CODEC chip? */
  346. max_flag:1, /* have we GUS MAX card? */
  347. max_ctrl_flag:1, /* have we original GUS MAX card? */
  348. daughter_flag:1, /* have we daughter board? */
  349. interwave:1, /* hey - we have InterWave card */
  350. ess_flag:1, /* ESS chip found... GUS Extreme */
  351. ace_flag:1, /* GUS ACE detected */
  352. uart_enable:1; /* enable MIDI UART */
  353. unsigned short revision; /* revision of chip */
  354. unsigned short max_cntrl_val; /* GUS MAX control value */
  355. unsigned short mix_cntrl_reg; /* mixer control register */
  356. unsigned short joystick_dac; /* joystick DAC level */
  357. int timer_dev; /* timer device */
  358. struct snd_gf1 gf1; /* gf1 specific variables */
  359. struct snd_pcm *pcm;
  360. struct snd_pcm_substream *pcm_cap_substream;
  361. unsigned int c_dma_size;
  362. unsigned int c_period_size;
  363. unsigned int c_pos;
  364. struct snd_rawmidi *midi_uart;
  365. struct snd_rawmidi_substream *midi_substream_output;
  366. struct snd_rawmidi_substream *midi_substream_input;
  367. spinlock_t reg_lock;
  368. spinlock_t voice_alloc;
  369. spinlock_t active_voice_lock;
  370. spinlock_t event_lock;
  371. spinlock_t dma_lock;
  372. spinlock_t pcm_volume_level_lock;
  373. spinlock_t uart_cmd_lock;
  374. struct mutex dma_mutex;
  375. struct mutex register_mutex;
  376. };
  377. /* I/O functions for GF1/InterWave chip - gus_io.c */
  378. static inline void snd_gf1_select_voice(struct snd_gus_card * gus, int voice)
  379. {
  380. unsigned long flags;
  381. spin_lock_irqsave(&gus->active_voice_lock, flags);
  382. if (voice != gus->gf1.active_voice) {
  383. gus->gf1.active_voice = voice;
  384. outb(voice, GUSP(gus, GF1PAGE));
  385. }
  386. spin_unlock_irqrestore(&gus->active_voice_lock, flags);
  387. }
  388. static inline void snd_gf1_uart_cmd(struct snd_gus_card * gus, unsigned char b)
  389. {
  390. outb(gus->gf1.uart_cmd = b, GUSP(gus, MIDICTRL));
  391. }
  392. static inline unsigned char snd_gf1_uart_stat(struct snd_gus_card * gus)
  393. {
  394. return inb(GUSP(gus, MIDISTAT));
  395. }
  396. static inline void snd_gf1_uart_put(struct snd_gus_card * gus, unsigned char b)
  397. {
  398. outb(b, GUSP(gus, MIDIDATA));
  399. }
  400. static inline unsigned char snd_gf1_uart_get(struct snd_gus_card * gus)
  401. {
  402. return inb(GUSP(gus, MIDIDATA));
  403. }
  404. extern void snd_gf1_delay(struct snd_gus_card * gus);
  405. extern void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
  406. extern void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
  407. extern unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg);
  408. static inline unsigned char snd_gf1_read8(struct snd_gus_card * gus, unsigned char reg)
  409. {
  410. return snd_gf1_look8(gus, reg | 0x80);
  411. }
  412. extern void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
  413. extern unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg);
  414. static inline unsigned short snd_gf1_read16(struct snd_gus_card * gus, unsigned char reg)
  415. {
  416. return snd_gf1_look16(gus, reg | 0x80);
  417. }
  418. extern void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
  419. extern void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr);
  420. extern void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data);
  421. extern unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr);
  422. extern void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit);
  423. extern unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit);
  424. extern void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
  425. extern void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
  426. extern unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg);
  427. extern void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
  428. static inline unsigned char snd_gf1_i_read8(struct snd_gus_card * gus, unsigned char reg)
  429. {
  430. return snd_gf1_i_look8(gus, reg | 0x80);
  431. }
  432. extern unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg);
  433. static inline unsigned short snd_gf1_i_read16(struct snd_gus_card * gus, unsigned char reg)
  434. {
  435. return snd_gf1_i_look16(gus, reg | 0x80);
  436. }
  437. extern void snd_gf1_select_active_voices(struct snd_gus_card * gus);
  438. /* gus_lfo.c */
  439. struct _SND_IW_LFO_PROGRAM {
  440. unsigned short freq_and_control;
  441. unsigned char depth_final;
  442. unsigned char depth_inc;
  443. unsigned short twave;
  444. unsigned short depth;
  445. };
  446. #if 0
  447. extern irqreturn_t snd_gf1_lfo_effect_interrupt(struct snd_gus_card * gus, snd_gf1_voice_t * voice);
  448. #endif
  449. extern void snd_gf1_lfo_init(struct snd_gus_card * gus);
  450. extern void snd_gf1_lfo_done(struct snd_gus_card * gus);
  451. extern void snd_gf1_lfo_program(struct snd_gus_card * gus, int voice, int lfo_type, struct _SND_IW_LFO_PROGRAM *program);
  452. extern void snd_gf1_lfo_enable(struct snd_gus_card * gus, int voice, int lfo_type);
  453. extern void snd_gf1_lfo_disable(struct snd_gus_card * gus, int voice, int lfo_type);
  454. extern void snd_gf1_lfo_change_freq(struct snd_gus_card * gus, int voice, int lfo_type, int freq);
  455. extern void snd_gf1_lfo_change_depth(struct snd_gus_card * gus, int voice, int lfo_type, int depth);
  456. extern void snd_gf1_lfo_setup(struct snd_gus_card * gus, int voice, int lfo_type, int freq, int current_depth, int depth, int sweep, int shape);
  457. extern void snd_gf1_lfo_shutdown(struct snd_gus_card * gus, int voice, int lfo_type);
  458. #if 0
  459. extern void snd_gf1_lfo_command(struct snd_gus_card * gus, int voice, unsigned char *command);
  460. #endif
  461. /* gus_mem.c */
  462. void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup);
  463. int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block);
  464. struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner,
  465. char *name, int size, int w_16,
  466. int align, unsigned int *share_id);
  467. int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address);
  468. int snd_gf1_mem_free_owner(struct snd_gf1_mem * alloc, int owner);
  469. int snd_gf1_mem_init(struct snd_gus_card * gus);
  470. int snd_gf1_mem_done(struct snd_gus_card * gus);
  471. /* gus_mem_proc.c */
  472. int snd_gf1_mem_proc_init(struct snd_gus_card * gus);
  473. /* gus_dma.c */
  474. int snd_gf1_dma_init(struct snd_gus_card * gus);
  475. int snd_gf1_dma_done(struct snd_gus_card * gus);
  476. int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
  477. struct snd_gf1_dma_block * block,
  478. int atomic,
  479. int synth);
  480. /* gus_volume.c */
  481. unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol);
  482. unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq2);
  483. /* gus_reset.c */
  484. void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what);
  485. void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice);
  486. void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice);
  487. void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max);
  488. struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port);
  489. void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice);
  490. int snd_gf1_start(struct snd_gus_card * gus);
  491. int snd_gf1_stop(struct snd_gus_card * gus);
  492. /* gus_mixer.c */
  493. int snd_gf1_new_mixer(struct snd_gus_card * gus);
  494. /* gus_pcm.c */
  495. int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index);
  496. #ifdef CONFIG_SND_DEBUG
  497. extern void snd_gf1_print_voice_registers(struct snd_gus_card * gus);
  498. #endif
  499. /* gus.c */
  500. int snd_gus_use_inc(struct snd_gus_card * gus);
  501. void snd_gus_use_dec(struct snd_gus_card * gus);
  502. int snd_gus_create(struct snd_card *card,
  503. unsigned long port,
  504. int irq, int dma1, int dma2,
  505. int timer_dev,
  506. int voices,
  507. int pcm_channels,
  508. int effect,
  509. struct snd_gus_card ** rgus);
  510. int snd_gus_initialize(struct snd_gus_card * gus);
  511. /* gus_irq.c */
  512. irqreturn_t snd_gus_interrupt(int irq, void *dev_id);
  513. #ifdef CONFIG_SND_DEBUG
  514. void snd_gus_irq_profile_init(struct snd_gus_card *gus);
  515. #endif
  516. /* gus_uart.c */
  517. int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device);
  518. /* gus_dram.c */
  519. int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr,
  520. unsigned int addr, unsigned int size);
  521. int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr,
  522. unsigned int addr, unsigned int size, int rom);
  523. #endif /* __SOUND_GUS_H */