hwaccess.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. **********************************************************************
  3. * hwaccess.h
  4. * Copyright 1999, 2000 Creative Labs, Inc.
  5. *
  6. **********************************************************************
  7. *
  8. * Date Author Summary of changes
  9. * ---- ------ ------------------
  10. * October 20, 1999 Bertrand Lee base code release
  11. *
  12. **********************************************************************
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public
  25. * License along with this program; if not, write to the Free
  26. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
  27. * USA.
  28. *
  29. **********************************************************************
  30. */
  31. #ifndef _HWACCESS_H
  32. #define _HWACCESS_H
  33. #include <linux/fs.h>
  34. #include <linux/sound.h>
  35. #include <linux/soundcard.h>
  36. #include <linux/ac97_codec.h>
  37. #include <linux/pci.h>
  38. #include <linux/slab.h>
  39. #include <linux/sched.h>
  40. #include <asm/io.h>
  41. #include "efxmgr.h"
  42. #include "passthrough.h"
  43. #include "midi.h"
  44. #define EMUPAGESIZE 4096 /* don't change */
  45. #define NUM_G 64 /* use all channels */
  46. #define NUM_FXSENDS 4 /* don't change */
  47. /* setting this to other than a power of two may break some applications */
  48. #define MAXBUFSIZE 65536
  49. #define MAXPAGES 8192
  50. #define BUFMAXPAGES (MAXBUFSIZE / PAGE_SIZE)
  51. #define FLAGS_AVAILABLE 0x0001
  52. #define FLAGS_READY 0x0002
  53. struct memhandle
  54. {
  55. dma_addr_t dma_handle;
  56. void *addr;
  57. u32 size;
  58. };
  59. #define DEBUG_LEVEL 2
  60. #ifdef EMU10K1_DEBUG
  61. # define DPD(level,x,y...) do {if(level <= DEBUG_LEVEL) printk( KERN_NOTICE "emu10k1: %s: %d: " x , __FILE__ , __LINE__ , y );} while(0)
  62. # define DPF(level,x) do {if(level <= DEBUG_LEVEL) printk( KERN_NOTICE "emu10k1: %s: %d: " x , __FILE__ , __LINE__ );} while(0)
  63. #else
  64. # define DPD(level,x,y...) do { } while (0) /* not debugging: nothing */
  65. # define DPF(level,x) do { } while (0)
  66. #endif /* EMU10K1_DEBUG */
  67. #define ERROR() DPF(1,"error\n")
  68. /* DATA STRUCTURES */
  69. struct emu10k1_waveout
  70. {
  71. u32 send_routing[3];
  72. // audigy only:
  73. u32 send_routing2[3];
  74. u32 send_dcba[3];
  75. // audigy only:
  76. u32 send_hgfe[3];
  77. };
  78. #define ROUTE_PCM 0
  79. #define ROUTE_PT 1
  80. #define ROUTE_PCM1 2
  81. #define SEND_MONO 0
  82. #define SEND_LEFT 1
  83. #define SEND_RIGHT 2
  84. struct emu10k1_wavein
  85. {
  86. struct wiinst *ac97;
  87. struct wiinst *mic;
  88. struct wiinst *fx;
  89. u8 recsrc;
  90. u32 fxwc;
  91. };
  92. #define CMD_READ 1
  93. #define CMD_WRITE 2
  94. struct mixer_private_ioctl {
  95. u32 cmd;
  96. u32 val[90];
  97. };
  98. /* bogus ioctls numbers to escape from OSS mixer limitations */
  99. #define CMD_WRITEFN0 _IOW('D', 0, struct mixer_private_ioctl)
  100. #define CMD_READFN0 _IOR('D', 1, struct mixer_private_ioctl)
  101. #define CMD_WRITEPTR _IOW('D', 2, struct mixer_private_ioctl)
  102. #define CMD_READPTR _IOR('D', 3, struct mixer_private_ioctl)
  103. #define CMD_SETRECSRC _IOW('D', 4, struct mixer_private_ioctl)
  104. #define CMD_GETRECSRC _IOR('D', 5, struct mixer_private_ioctl)
  105. #define CMD_GETVOICEPARAM _IOR('D', 6, struct mixer_private_ioctl)
  106. #define CMD_SETVOICEPARAM _IOW('D', 7, struct mixer_private_ioctl)
  107. #define CMD_GETPATCH _IOR('D', 8, struct mixer_private_ioctl)
  108. #define CMD_GETGPR _IOR('D', 9, struct mixer_private_ioctl)
  109. #define CMD_GETCTLGPR _IOR('D', 10, struct mixer_private_ioctl)
  110. #define CMD_SETPATCH _IOW('D', 11, struct mixer_private_ioctl)
  111. #define CMD_SETGPR _IOW('D', 12, struct mixer_private_ioctl)
  112. #define CMD_SETCTLGPR _IOW('D', 13, struct mixer_private_ioctl)
  113. #define CMD_SETGPOUT _IOW('D', 14, struct mixer_private_ioctl)
  114. #define CMD_GETGPR2OSS _IOR('D', 15, struct mixer_private_ioctl)
  115. #define CMD_SETGPR2OSS _IOW('D', 16, struct mixer_private_ioctl)
  116. #define CMD_SETMCH_FX _IOW('D', 17, struct mixer_private_ioctl)
  117. #define CMD_SETPASSTHROUGH _IOW('D', 18, struct mixer_private_ioctl)
  118. #define CMD_PRIVATE3_VERSION _IOW('D', 19, struct mixer_private_ioctl)
  119. #define CMD_AC97_BOOST _IOW('D', 20, struct mixer_private_ioctl)
  120. //up this number when breaking compatibility
  121. #define PRIVATE3_VERSION 2
  122. struct emu10k1_card
  123. {
  124. struct list_head list;
  125. struct memhandle virtualpagetable;
  126. struct memhandle tankmem;
  127. struct memhandle silentpage;
  128. spinlock_t lock;
  129. u8 voicetable[NUM_G];
  130. u16 emupagetable[MAXPAGES];
  131. struct list_head timers;
  132. u16 timer_delay;
  133. spinlock_t timer_lock;
  134. struct pci_dev *pci_dev;
  135. unsigned long iobase;
  136. unsigned long length;
  137. unsigned short model;
  138. unsigned int irq;
  139. int audio_dev;
  140. int audio_dev1;
  141. int midi_dev;
  142. #ifdef EMU10K1_SEQUENCER
  143. int seq_dev;
  144. struct emu10k1_mididevice *seq_mididev;
  145. #endif
  146. struct ac97_codec *ac97;
  147. int ac97_supported_mixers;
  148. int ac97_stereo_mixers;
  149. /* Number of first fx voice for multichannel output */
  150. u8 mchannel_fx;
  151. struct emu10k1_waveout waveout;
  152. struct emu10k1_wavein wavein;
  153. struct emu10k1_mpuout *mpuout;
  154. struct emu10k1_mpuin *mpuin;
  155. struct semaphore open_sem;
  156. mode_t open_mode;
  157. wait_queue_head_t open_wait;
  158. u32 mpuacqcount; // Mpu acquire count
  159. u32 has_toslink; // TOSLink detection
  160. u8 chiprev; /* Chip revision */
  161. u8 is_audigy;
  162. u8 is_aps;
  163. struct patch_manager mgr;
  164. struct pt_data pt;
  165. };
  166. int emu10k1_addxmgr_alloc(u32, struct emu10k1_card *);
  167. void emu10k1_addxmgr_free(struct emu10k1_card *, int);
  168. int emu10k1_find_control_gpr(struct patch_manager *, const char *, const char *);
  169. void emu10k1_set_control_gpr(struct emu10k1_card *, int , s32, int );
  170. void emu10k1_set_volume_gpr(struct emu10k1_card *, int, s32, int);
  171. #define VOL_6BIT 0x40
  172. #define VOL_5BIT 0x20
  173. #define VOL_4BIT 0x10
  174. #define TIMEOUT 16384
  175. u32 srToPitch(u32);
  176. extern struct list_head emu10k1_devs;
  177. /* Hardware Abstraction Layer access functions */
  178. void emu10k1_writefn0(struct emu10k1_card *, u32, u32);
  179. void emu10k1_writefn0_2(struct emu10k1_card *, u32, u32, int);
  180. u32 emu10k1_readfn0(struct emu10k1_card *, u32);
  181. void emu10k1_timer_set(struct emu10k1_card *, u16);
  182. void sblive_writeptr(struct emu10k1_card *, u32, u32, u32);
  183. void sblive_writeptr_tag(struct emu10k1_card *, u32, ...);
  184. #define TAGLIST_END 0
  185. u32 sblive_readptr(struct emu10k1_card *, u32 , u32 );
  186. void emu10k1_irq_enable(struct emu10k1_card *, u32);
  187. void emu10k1_irq_disable(struct emu10k1_card *, u32);
  188. void emu10k1_clear_stop_on_loop(struct emu10k1_card *, u32);
  189. /* AC97 Codec register access function */
  190. u16 emu10k1_ac97_read(struct ac97_codec *, u8);
  191. void emu10k1_ac97_write(struct ac97_codec *, u8, u16);
  192. /* MPU access function*/
  193. int emu10k1_mpu_write_data(struct emu10k1_card *, u8);
  194. int emu10k1_mpu_read_data(struct emu10k1_card *, u8 *);
  195. int emu10k1_mpu_reset(struct emu10k1_card *);
  196. int emu10k1_mpu_acquire(struct emu10k1_card *);
  197. int emu10k1_mpu_release(struct emu10k1_card *);
  198. #endif /* _HWACCESS_H */