ad1848_mixer.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*
  2. * sound/oss/ad1848_mixer.h
  3. *
  4. * Definitions for the mixer of AD1848 and compatible codecs.
  5. */
  6. /*
  7. * Copyright (C) by Hannu Savolainen 1993-1997
  8. *
  9. * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
  10. * Version 2 (June 1991). See the "COPYING" file distributed with this software
  11. * for more info.
  12. */
  13. /*
  14. * The AD1848 codec has generic input lines called Line, Aux1 and Aux2.
  15. * Sound card manufacturers have connected actual inputs (CD, synth, line,
  16. * etc) to these inputs in different order. Therefore it's difficult
  17. * to assign mixer channels to these inputs correctly. The following
  18. * contains two alternative mappings. The first one is for GUS MAX and
  19. * the second is just a generic one (line1, line2 and line3).
  20. * (Actually this is not a mapping but rather some kind of interleaving
  21. * solution).
  22. */
  23. #define MODE1_REC_DEVICES (SOUND_MASK_LINE3 | SOUND_MASK_MIC | \
  24. SOUND_MASK_LINE1 | SOUND_MASK_IMIX)
  25. #define SPRO_REC_DEVICES (SOUND_MASK_LINE | SOUND_MASK_MIC | \
  26. SOUND_MASK_CD | SOUND_MASK_LINE1)
  27. #define MODE1_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_MIC | \
  28. SOUND_MASK_LINE2 | \
  29. SOUND_MASK_IGAIN | \
  30. SOUND_MASK_PCM | SOUND_MASK_IMIX)
  31. #define MODE2_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_LINE2 | \
  32. SOUND_MASK_MIC | \
  33. SOUND_MASK_LINE3 | SOUND_MASK_SPEAKER | \
  34. SOUND_MASK_IGAIN | \
  35. SOUND_MASK_PCM | SOUND_MASK_IMIX)
  36. #define MODE3_MIXER_DEVICES (MODE2_MIXER_DEVICES | SOUND_MASK_VOLUME)
  37. /* OPTi 82C930 has no IMIX level control, but it can still be selected as an
  38. * input
  39. */
  40. #define C930_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_LINE2 | \
  41. SOUND_MASK_MIC | SOUND_MASK_VOLUME | \
  42. SOUND_MASK_LINE3 | \
  43. SOUND_MASK_IGAIN | SOUND_MASK_PCM)
  44. #define SPRO_MIXER_DEVICES (SOUND_MASK_VOLUME | SOUND_MASK_PCM | \
  45. SOUND_MASK_LINE | SOUND_MASK_SYNTH | \
  46. SOUND_MASK_CD | SOUND_MASK_MIC | \
  47. SOUND_MASK_SPEAKER | SOUND_MASK_LINE1 | \
  48. SOUND_MASK_OGAIN)
  49. struct mixer_def {
  50. unsigned int regno:6; /* register number for volume */
  51. unsigned int polarity:1; /* volume polarity: 0=normal, 1=reversed */
  52. unsigned int bitpos:3; /* position of bits in register for volume */
  53. unsigned int nbits:3; /* number of bits in register for volume */
  54. unsigned int mutereg:6; /* register number for mute bit */
  55. unsigned int mutepol:1; /* mute polarity: 0=normal, 1=reversed */
  56. unsigned int mutepos:4; /* position of mute bit in register */
  57. unsigned int recreg:6; /* register number for recording bit */
  58. unsigned int recpol:1; /* recording polarity: 0=normal, 1=reversed */
  59. unsigned int recpos:4; /* position of recording bit in register */
  60. };
  61. static char mix_cvt[101] = {
  62. 0, 0, 3, 7,10,13,16,19,21,23,26,28,30,32,34,35,37,39,40,42,
  63. 43,45,46,47,49,50,51,52,53,55,56,57,58,59,60,61,62,63,64,65,
  64. 65,66,67,68,69,70,70,71,72,73,73,74,75,75,76,77,77,78,79,79,
  65. 80,81,81,82,82,83,84,84,85,85,86,86,87,87,88,88,89,89,90,90,
  66. 91,91,92,92,93,93,94,94,95,95,96,96,96,97,97,98,98,98,99,99,
  67. 100
  68. };
  69. typedef struct mixer_def mixer_ent;
  70. typedef mixer_ent mixer_ents[2];
  71. /*
  72. * Most of the mixer entries work in backwards. Setting the polarity field
  73. * makes them to work correctly.
  74. *
  75. * The channel numbering used by individual sound cards is not fixed. Some
  76. * cards have assigned different meanings for the AUX1, AUX2 and LINE inputs.
  77. * The current version doesn't try to compensate this.
  78. */
  79. #define MIX_ENT(name, reg_l, pola_l, pos_l, len_l, reg_r, pola_r, pos_r, len_r, mute_bit) \
  80. [name] = {{reg_l, pola_l, pos_l, len_l, reg_l, 0, mute_bit, 0, 0, 8}, \
  81. {reg_r, pola_r, pos_r, len_r, reg_r, 0, mute_bit, 0, 0, 8}}
  82. #define MIX_ENT2(name, reg_l, pola_l, pos_l, len_l, mute_reg_l, mute_pola_l, mute_pos_l, \
  83. rec_reg_l, rec_pola_l, rec_pos_l, \
  84. reg_r, pola_r, pos_r, len_r, mute_reg_r, mute_pola_r, mute_pos_r, \
  85. rec_reg_r, rec_pola_r, rec_pos_r) \
  86. [name] = {{reg_l, pola_l, pos_l, len_l, mute_reg_l, mute_pola_l, mute_pos_l, \
  87. rec_reg_l, rec_pola_l, rec_pos_l}, \
  88. {reg_r, pola_r, pos_r, len_r, mute_reg_r, mute_pola_r, mute_pos_r, \
  89. rec_reg_r, rec_pola_r, rec_pos_r}}
  90. static mixer_ents ad1848_mix_devices[32] = {
  91. MIX_ENT(SOUND_MIXER_VOLUME, 27, 1, 0, 4, 29, 1, 0, 4, 8),
  92. MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  93. MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  94. MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7),
  95. MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7),
  96. MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8),
  97. MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7),
  98. MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1, 8),
  99. MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7),
  100. MIX_ENT(SOUND_MIXER_IMIX, 13, 1, 2, 6, 0, 0, 0, 0, 8),
  101. MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  102. MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  103. MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
  104. MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  105. MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7),
  106. MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7),
  107. MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 0, 5, 19, 1, 0, 5, 7)
  108. };
  109. static mixer_ents iwave_mix_devices[32] = {
  110. MIX_ENT(SOUND_MIXER_VOLUME, 25, 1, 0, 5, 27, 1, 0, 5, 8),
  111. MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  112. MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  113. MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7),
  114. MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7),
  115. MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8),
  116. MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7),
  117. MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1, 8),
  118. MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7),
  119. MIX_ENT(SOUND_MIXER_IMIX, 16, 1, 0, 5, 17, 1, 0, 5, 8),
  120. MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  121. MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  122. MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
  123. MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  124. MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7),
  125. MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7),
  126. MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 0, 5, 19, 1, 0, 5, 7)
  127. };
  128. static mixer_ents cs42xb_mix_devices[32] = {
  129. /* Digital master volume actually has seven bits, but we only use
  130. six to avoid the discontinuity when the analog gain kicks in. */
  131. MIX_ENT(SOUND_MIXER_VOLUME, 46, 1, 0, 6, 47, 1, 0, 6, 7),
  132. MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  133. MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  134. MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7),
  135. MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7),
  136. MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8),
  137. MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7),
  138. MIX_ENT(SOUND_MIXER_MIC, 34, 1, 0, 5, 35, 1, 0, 5, 7),
  139. MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7),
  140. /* For the IMIX entry, it was not possible to use the MIX_ENT macro
  141. because the mute bit is in different positions for the two
  142. channels and requires reverse polarity. */
  143. [SOUND_MIXER_IMIX] = {{13, 1, 2, 6, 13, 1, 0, 0, 0, 8},
  144. {42, 1, 0, 6, 42, 1, 7, 0, 0, 8}},
  145. MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  146. MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  147. MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
  148. MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  149. MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7),
  150. MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7),
  151. MIX_ENT(SOUND_MIXER_LINE3, 38, 1, 0, 6, 39, 1, 0, 6, 7)
  152. };
  153. /* OPTi 82C930 has somewhat different port addresses.
  154. * Note: VOLUME == SPEAKER, SYNTH == LINE2, LINE == LINE3, CD == LINE1
  155. * VOLUME, SYNTH, LINE, CD are not enabled above.
  156. * MIC is level of mic monitoring direct to output. Same for CD, LINE, etc.
  157. */
  158. static mixer_ents c930_mix_devices[32] = {
  159. MIX_ENT(SOUND_MIXER_VOLUME, 22, 1, 1, 5, 23, 1, 1, 5, 7),
  160. MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  161. MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  162. MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 1, 4, 5, 1, 1, 4, 7),
  163. MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 5, 7, 1, 0, 5, 7),
  164. MIX_ENT(SOUND_MIXER_SPEAKER, 22, 1, 1, 5, 23, 1, 1, 5, 7),
  165. MIX_ENT(SOUND_MIXER_LINE, 18, 1, 1, 4, 19, 1, 1, 4, 7),
  166. MIX_ENT(SOUND_MIXER_MIC, 20, 1, 1, 4, 21, 1, 1, 4, 7),
  167. MIX_ENT(SOUND_MIXER_CD, 2, 1, 1, 4, 3, 1, 1, 4, 7),
  168. MIX_ENT(SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  169. MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  170. MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  171. MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
  172. MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  173. MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 1, 4, 3, 1, 1, 4, 7),
  174. MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 1, 4, 5, 1, 1, 4, 7),
  175. MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 1, 4, 19, 1, 1, 4, 7)
  176. };
  177. static mixer_ents spro_mix_devices[32] = {
  178. MIX_ENT (SOUND_MIXER_VOLUME, 19, 0, 4, 4, 19, 0, 0, 4, 8),
  179. MIX_ENT (SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  180. MIX_ENT (SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  181. MIX_ENT2(SOUND_MIXER_SYNTH, 4, 1, 1, 4, 23, 0, 3, 0, 0, 8,
  182. 5, 1, 1, 4, 23, 0, 3, 0, 0, 8),
  183. MIX_ENT (SOUND_MIXER_PCM, 6, 1, 1, 4, 7, 1, 1, 4, 8),
  184. MIX_ENT (SOUND_MIXER_SPEAKER, 18, 0, 3, 2, 0, 0, 0, 0, 8),
  185. MIX_ENT2(SOUND_MIXER_LINE, 20, 0, 4, 4, 17, 1, 4, 16, 0, 2,
  186. 20, 0, 0, 4, 17, 1, 3, 16, 0, 1),
  187. MIX_ENT2(SOUND_MIXER_MIC, 18, 0, 0, 3, 17, 1, 0, 16, 0, 0,
  188. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
  189. MIX_ENT2(SOUND_MIXER_CD, 21, 0, 4, 4, 17, 1, 2, 16, 0, 4,
  190. 21, 0, 0, 4, 17, 1, 1, 16, 0, 3),
  191. MIX_ENT (SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  192. MIX_ENT (SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  193. MIX_ENT (SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  194. MIX_ENT (SOUND_MIXER_IGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
  195. MIX_ENT (SOUND_MIXER_OGAIN, 17, 1, 6, 1, 0, 0, 0, 0, 8),
  196. /* This is external wavetable */
  197. MIX_ENT2(SOUND_MIXER_LINE1, 22, 0, 4, 4, 23, 1, 1, 23, 0, 4,
  198. 22, 0, 0, 4, 23, 1, 0, 23, 0, 5),
  199. };
  200. static int default_mixer_levels[32] =
  201. {
  202. 0x3232, /* Master Volume */
  203. 0x3232, /* Bass */
  204. 0x3232, /* Treble */
  205. 0x4b4b, /* FM */
  206. 0x3232, /* PCM */
  207. 0x1515, /* PC Speaker */
  208. 0x2020, /* Ext Line */
  209. 0x1010, /* Mic */
  210. 0x4b4b, /* CD */
  211. 0x0000, /* Recording monitor */
  212. 0x4b4b, /* Second PCM */
  213. 0x4b4b, /* Recording level */
  214. 0x4b4b, /* Input gain */
  215. 0x4b4b, /* Output gain */
  216. 0x2020, /* Line1 */
  217. 0x2020, /* Line2 */
  218. 0x1515 /* Line3 (usually line in)*/
  219. };
  220. #define LEFT_CHN 0
  221. #define RIGHT_CHN 1
  222. /*
  223. * Channel enable bits for ioctl(SOUND_MIXER_PRIVATE1)
  224. */
  225. #ifndef AUDIO_SPEAKER
  226. #define AUDIO_SPEAKER 0x01 /* Enable mono output */
  227. #define AUDIO_HEADPHONE 0x02 /* Sparc only */
  228. #define AUDIO_LINE_OUT 0x04 /* Sparc only */
  229. #endif