gus.h 20 KB

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