efxmgr.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /*
  2. **********************************************************************
  3. * sblive_fx.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 _EFXMGR_H
  32. #define _EFXMGR_H
  33. struct emu_efx_info_t{
  34. int opcode_shift;
  35. int high_operand_shift;
  36. int instruction_start;
  37. int gpr_base;
  38. int output_base;
  39. };
  40. #define WRITE_EFX(a, b, c) sblive_writeptr((a), emu_efx_info[card->is_audigy].instruction_start + (b), 0, (c))
  41. #define OP(op, z, w, x, y) \
  42. do { WRITE_EFX(card, (pc) * 2, ((x) << emu_efx_info[card->is_audigy].high_operand_shift) | (y)); \
  43. WRITE_EFX(card, (pc) * 2 + 1, ((op) << emu_efx_info[card->is_audigy].opcode_shift ) | ((z) << emu_efx_info[card->is_audigy].high_operand_shift) | (w)); \
  44. ++pc; } while (0)
  45. #define NUM_INPUTS 0x20
  46. #define NUM_OUTPUTS 0x20
  47. #define NUM_GPRS 0x100
  48. #define A_NUM_INPUTS 0x60
  49. #define A_NUM_OUTPUTS 0x60 //fixme: this may or may not be true
  50. #define A_NUM_GPRS 0x200
  51. #define GPR_NAME_SIZE 32
  52. #define PATCH_NAME_SIZE 32
  53. struct dsp_rpatch {
  54. char name[PATCH_NAME_SIZE];
  55. u16 code_start;
  56. u16 code_size;
  57. unsigned long gpr_used[NUM_GPRS / (sizeof(unsigned long) * 8) + 1];
  58. unsigned long gpr_input[NUM_GPRS / (sizeof(unsigned long) * 8) + 1];
  59. unsigned long route[NUM_OUTPUTS];
  60. unsigned long route_v[NUM_OUTPUTS];
  61. };
  62. struct dsp_patch {
  63. char name[PATCH_NAME_SIZE];
  64. u8 id;
  65. unsigned long input; /* bitmap of the lines used as inputs */
  66. unsigned long output; /* bitmap of the lines used as outputs */
  67. u16 code_start;
  68. u16 code_size;
  69. unsigned long gpr_used[NUM_GPRS / (sizeof(unsigned long) * 8) + 1]; /* bitmap of used gprs */
  70. unsigned long gpr_input[NUM_GPRS / (sizeof(unsigned long) * 8) + 1];
  71. u8 traml_istart; /* starting address of the internal tram lines used */
  72. u8 traml_isize; /* number of internal tram lines used */
  73. u8 traml_estart;
  74. u8 traml_esize;
  75. u16 tramb_istart; /* starting address of the internal tram memory used */
  76. u16 tramb_isize; /* amount of internal memory used */
  77. u32 tramb_estart;
  78. u32 tramb_esize;
  79. };
  80. struct dsp_gpr {
  81. u8 type; /* gpr type, STATIC, DYNAMIC, INPUT, OUTPUT, CONTROL */
  82. char name[GPR_NAME_SIZE]; /* gpr value, only valid for control gprs */
  83. s32 min, max; /* value range for this gpr, only valid for control gprs */
  84. u8 line; /* which input/output line is the gpr attached, only valid for input/output gprs */
  85. u8 usage;
  86. };
  87. enum {
  88. GPR_TYPE_NULL = 0,
  89. GPR_TYPE_IO,
  90. GPR_TYPE_STATIC,
  91. GPR_TYPE_DYNAMIC,
  92. GPR_TYPE_CONTROL,
  93. GPR_TYPE_CONSTANT
  94. };
  95. #define GPR_BASE 0x100
  96. #define OUTPUT_BASE 0x20
  97. #define A_GPR_BASE 0x400
  98. #define A_OUTPUT_BASE 0x60
  99. #define MAX_PATCHES_PAGES 32
  100. struct patch_manager {
  101. void *patch[MAX_PATCHES_PAGES];
  102. int current_pages;
  103. struct dsp_rpatch rpatch;
  104. struct dsp_gpr gpr[NUM_GPRS]; /* gpr usage table */
  105. spinlock_t lock;
  106. s16 ctrl_gpr[SOUND_MIXER_NRDEVICES][2];
  107. };
  108. #define PATCHES_PER_PAGE (PAGE_SIZE / sizeof(struct dsp_patch))
  109. #define PATCH(mgr, i) ((struct dsp_patch *) (mgr)->patch[(i) / PATCHES_PER_PAGE] + (i) % PATCHES_PER_PAGE)
  110. /* PCM volume control */
  111. #define TMP_PCM_L 0x100 //temp PCM L (after the vol control)
  112. #define TMP_PCM_R 0x101
  113. #define VOL_PCM_L 0x102 //vol PCM
  114. #define VOL_PCM_R 0x103
  115. /* Routing patch */
  116. #define TMP_AC_L 0x104 //tmp ac97 out
  117. #define TMP_AC_R 0x105
  118. #define TMP_REAR_L 0x106 //output - Temp Rear
  119. #define TMP_REAR_R 0x107
  120. #define TMP_DIGI_L 0x108 //output - Temp digital
  121. #define TMP_DIGI_R 0x109
  122. #define DSP_VOL_L 0x10a // main dsp volume
  123. #define DSP_VOL_R 0x10b
  124. /* hw inputs */
  125. #define PCM_IN_L 0x00
  126. #define PCM_IN_R 0x01
  127. #define PCM1_IN_L 0x04
  128. #define PCM1_IN_R 0x05
  129. //mutilchannel playback stream appear here:
  130. #define MULTI_FRONT_L 0x08
  131. #define MULTI_FRONT_R 0x09
  132. #define MULTI_REAR_L 0x0a
  133. #define MULTI_REAR_R 0x0b
  134. #define MULTI_CENTER 0x0c
  135. #define MULTI_LFE 0x0d
  136. #define AC97_IN_L 0x10
  137. #define AC97_IN_R 0x11
  138. #define SPDIF_CD_L 0x12
  139. #define SPDIF_CD_R 0x13
  140. /* hw outputs */
  141. #define AC97_FRONT_L 0x20
  142. #define AC97_FRONT_R 0x21
  143. #define DIGITAL_OUT_L 0x22
  144. #define DIGITAL_OUT_R 0x23
  145. #define DIGITAL_CENTER 0x24
  146. #define DIGITAL_LFE 0x25
  147. #define ANALOG_REAR_L 0x28
  148. #define ANALOG_REAR_R 0x29
  149. #define ADC_REC_L 0x2a
  150. #define ADC_REC_R 0x2b
  151. #define ANALOG_CENTER 0x31
  152. #define ANALOG_LFE 0x32
  153. #define INPUT_PATCH_START(patch, nm, ln, i) \
  154. do { \
  155. patch = PATCH(mgr, patch_n); \
  156. strcpy(patch->name, nm); \
  157. patch->code_start = pc * 2; \
  158. patch->input = (1<<(0x1f&ln)); \
  159. patch->output= (1<<(0x1f&ln)); \
  160. patch->id = i; \
  161. } while(0)
  162. #define INPUT_PATCH_END(patch) \
  163. do { \
  164. patch->code_size = pc * 2 - patch->code_start; \
  165. patch_n++; \
  166. } while(0)
  167. #define ROUTING_PATCH_START(patch, nm) \
  168. do { \
  169. patch = &mgr->rpatch; \
  170. strcpy(patch->name, nm); \
  171. patch->code_start = pc * 2; \
  172. } while(0)
  173. #define ROUTING_PATCH_END(patch) \
  174. do { \
  175. patch->code_size = pc * 2 - patch->code_start; \
  176. } while(0)
  177. #define CONNECT(input, output) set_bit(input, &rpatch->route[(output) - OUTPUT_BASE]);
  178. #define CONNECT_V(input, output) set_bit(input, &rpatch->route_v[(output) - OUTPUT_BASE]);
  179. #define OUTPUT_PATCH_START(patch, nm, ln, i) \
  180. do { \
  181. patch = PATCH(mgr, patch_n); \
  182. strcpy(patch->name, nm); \
  183. patch->code_start = pc * 2; \
  184. patch->input = (1<<(0x1f&ln)); \
  185. patch->output= (1<<(0x1f&ln)); \
  186. patch->id = i; \
  187. } while(0)
  188. #define OUTPUT_PATCH_END(patch) \
  189. do { \
  190. patch->code_size = pc * 2 - patch->code_start; \
  191. patch_n++; \
  192. } while(0)
  193. #define GET_OUTPUT_GPR(patch, g, ln) \
  194. do { \
  195. mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_IO; \
  196. mgr->gpr[(g) - GPR_BASE].usage++; \
  197. mgr->gpr[(g) - GPR_BASE].line = ln; \
  198. set_bit((g) - GPR_BASE, patch->gpr_used); \
  199. } while(0)
  200. #define GET_INPUT_GPR(patch, g, ln) \
  201. do { \
  202. mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_IO; \
  203. mgr->gpr[(g) - GPR_BASE].usage++; \
  204. mgr->gpr[(g) - GPR_BASE].line = ln; \
  205. set_bit((g) - GPR_BASE, patch->gpr_used); \
  206. set_bit((g) - GPR_BASE, patch->gpr_input); \
  207. } while(0)
  208. #define GET_DYNAMIC_GPR(patch, g) \
  209. do { \
  210. mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_DYNAMIC; \
  211. mgr->gpr[(g) - GPR_BASE].usage++; \
  212. set_bit((g) - GPR_BASE, patch->gpr_used); \
  213. } while(0)
  214. #define GET_CONTROL_GPR(patch, g, nm, a, b) \
  215. do { \
  216. strcpy(mgr->gpr[(g) - GPR_BASE].name, nm); \
  217. mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_CONTROL; \
  218. mgr->gpr[(g) - GPR_BASE].usage++; \
  219. mgr->gpr[(g) - GPR_BASE].min = a; \
  220. mgr->gpr[(g) - GPR_BASE].max = b; \
  221. sblive_writeptr(card, g, 0, b); \
  222. set_bit((g) - GPR_BASE, patch->gpr_used); \
  223. } while(0)
  224. #endif /* _EFXMGR_H */