wavefront_fx.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. /*
  2. * Copyright (c) 1998-2002 by Paul Davis <pbd@op.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #include <sound/driver.h>
  19. #include <asm/io.h>
  20. #include <linux/init.h>
  21. #include <linux/time.h>
  22. #include <linux/wait.h>
  23. #include <sound/core.h>
  24. #include <sound/snd_wavefront.h>
  25. #include <sound/initval.h>
  26. /* Control bits for the Load Control Register
  27. */
  28. #define FX_LSB_TRANSFER 0x01 /* transfer after DSP LSB byte written */
  29. #define FX_MSB_TRANSFER 0x02 /* transfer after DSP MSB byte written */
  30. #define FX_AUTO_INCR 0x04 /* auto-increment DSP address after transfer */
  31. /* weird stuff, derived from port I/O tracing with dosemu */
  32. static unsigned char page_zero[] __initdata = {
  33. 0x01, 0x7c, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x00,
  34. 0x11, 0x00, 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x13, 0x00, 0x00,
  35. 0x00, 0x14, 0x02, 0x76, 0x00, 0x60, 0x00, 0x80, 0x02, 0x00, 0x00,
  36. 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  37. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  38. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  39. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  40. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  41. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  42. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x19,
  45. 0x01, 0x1a, 0x01, 0x20, 0x01, 0x40, 0x01, 0x17, 0x00, 0x00, 0x01,
  46. 0x80, 0x01, 0x20, 0x00, 0x10, 0x01, 0xa0, 0x03, 0xd1, 0x00, 0x00,
  47. 0x01, 0xf2, 0x02, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf4, 0x02,
  48. 0xe0, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17,
  49. 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x50, 0x00, 0x00, 0x00,
  50. 0x40, 0x00, 0x00, 0x00, 0x71, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00,
  51. 0x00, 0x92, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xb3, 0x02,
  52. 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x40,
  53. 0x00, 0x80, 0x00, 0xf5, 0x00, 0x20, 0x00, 0x70, 0x00, 0xa0, 0x02,
  54. 0x11, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
  55. 0x02, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x17, 0x00, 0x1b, 0x00,
  56. 0x1d, 0x02, 0xdf
  57. };
  58. static unsigned char page_one[] __initdata = {
  59. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x19, 0x00,
  60. 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xd8, 0x00, 0x00,
  61. 0x02, 0x20, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01,
  62. 0xc0, 0x01, 0xfa, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  63. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  64. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  65. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  66. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  67. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  69. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  70. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x02, 0x60,
  71. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x02, 0x80, 0x00,
  72. 0x00, 0x02, 0xfb, 0x02, 0xa0, 0x00, 0x00, 0x00, 0x1b, 0x02, 0xd7,
  73. 0x00, 0x00, 0x02, 0xf7, 0x03, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00,
  74. 0x1c, 0x03, 0x3c, 0x00, 0x00, 0x03, 0x3f, 0x00, 0x00, 0x03, 0xc0,
  75. 0x00, 0x00, 0x03, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x03, 0x5d, 0x00,
  76. 0x00, 0x03, 0xc0, 0x00, 0x00, 0x03, 0x7d, 0x00, 0x00, 0x03, 0xc0,
  77. 0x00, 0x00, 0x03, 0x9e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x03,
  78. 0xbe, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  79. 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
  80. 0xdb, 0x00, 0x00, 0x02, 0xdb, 0x00, 0x00, 0x02, 0xe0, 0x00, 0x00,
  81. 0x02, 0xfb, 0x00, 0x00, 0x02, 0xc0, 0x02, 0x40, 0x02, 0xfb, 0x02,
  82. 0x60, 0x00, 0x1b
  83. };
  84. static unsigned char page_two[] __initdata = {
  85. 0xc4, 0x00, 0x44, 0x07, 0x44, 0x00, 0x40, 0x25, 0x01, 0x06, 0xc4,
  86. 0x07, 0x40, 0x25, 0x01, 0x00, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00,
  87. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  88. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  89. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  90. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x07,
  91. 0x05, 0x05, 0x05, 0x04, 0x07, 0x05, 0x04, 0x07, 0x05, 0x44, 0x46,
  92. 0x44, 0x46, 0x46, 0x07, 0x05, 0x44, 0x46, 0x05, 0x46, 0x05, 0x46,
  93. 0x05, 0x46, 0x05, 0x44, 0x46, 0x05, 0x07, 0x44, 0x46, 0x05, 0x07,
  94. 0x44, 0x46, 0x05, 0x07, 0x44, 0x46, 0x05, 0x07, 0x44, 0x05, 0x05,
  95. 0x05, 0x44, 0x05, 0x05, 0x05, 0x46, 0x05, 0x46, 0x05, 0x46, 0x05,
  96. 0x46, 0x05, 0x46, 0x07, 0x46, 0x07, 0x44
  97. };
  98. static unsigned char page_three[] __initdata = {
  99. 0x07, 0x40, 0x00, 0x00, 0x00, 0x47, 0x00, 0x40, 0x00, 0x40, 0x06,
  100. 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  101. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  102. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  103. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  104. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
  105. 0xc0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00,
  106. 0x60, 0x00, 0x70, 0x00, 0x40, 0x00, 0x40, 0x00, 0x42, 0x00, 0x40,
  107. 0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
  108. 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
  109. 0x00, 0x42, 0x00, 0x40, 0x00, 0x42, 0x00, 0x02, 0x00, 0x02, 0x00,
  110. 0x02, 0x00, 0x42, 0x00, 0xc0, 0x00, 0x40
  111. };
  112. static unsigned char page_four[] __initdata = {
  113. 0x63, 0x03, 0x26, 0x02, 0x2c, 0x00, 0x24, 0x00, 0x2e, 0x02, 0x02,
  114. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  115. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  116. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  117. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  118. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  119. 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20,
  120. 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x60, 0x00,
  121. 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60,
  122. 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00,
  123. 0x20, 0x00, 0x22, 0x02, 0x22, 0x02, 0x20, 0x00, 0x60, 0x00, 0x22,
  124. 0x02, 0x62, 0x02, 0x20, 0x01, 0x21, 0x01
  125. };
  126. static unsigned char page_six[] __initdata = {
  127. 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x00,
  128. 0x00, 0x08, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x0e,
  129. 0x00, 0x00, 0x10, 0x00, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x00,
  130. 0x16, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x1c, 0x00,
  131. 0x00, 0x1e, 0x00, 0x00, 0x20, 0x00, 0x00, 0x22, 0x00, 0x00, 0x24,
  132. 0x00, 0x00, 0x26, 0x00, 0x00, 0x28, 0x00, 0x00, 0x2a, 0x00, 0x00,
  133. 0x2c, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x30, 0x00, 0x00, 0x32, 0x00,
  134. 0x00, 0x34, 0x00, 0x00, 0x36, 0x00, 0x00, 0x38, 0x00, 0x00, 0x3a,
  135. 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x40, 0x00, 0x00,
  136. 0x42, 0x03, 0x00, 0x44, 0x01, 0x00, 0x46, 0x0a, 0x21, 0x48, 0x0d,
  137. 0x23, 0x4a, 0x23, 0x1b, 0x4c, 0x37, 0x8f, 0x4e, 0x45, 0x77, 0x50,
  138. 0x52, 0xe2, 0x52, 0x1c, 0x92, 0x54, 0x1c, 0x52, 0x56, 0x07, 0x00,
  139. 0x58, 0x2f, 0xc6, 0x5a, 0x0b, 0x00, 0x5c, 0x30, 0x06, 0x5e, 0x17,
  140. 0x00, 0x60, 0x3d, 0xda, 0x62, 0x29, 0x00, 0x64, 0x3e, 0x41, 0x66,
  141. 0x39, 0x00, 0x68, 0x4c, 0x48, 0x6a, 0x49, 0x00, 0x6c, 0x4c, 0x6c,
  142. 0x6e, 0x11, 0xd2, 0x70, 0x16, 0x0c, 0x72, 0x00, 0x00, 0x74, 0x00,
  143. 0x80, 0x76, 0x0f, 0x00, 0x78, 0x00, 0x80, 0x7a, 0x13, 0x00, 0x7c,
  144. 0x80, 0x00, 0x7e, 0x80, 0x80
  145. };
  146. static unsigned char page_seven[] __initdata = {
  147. 0x0f, 0xff, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00,
  148. 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
  149. 0x08, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f,
  150. 0xff, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  151. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  152. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  153. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  154. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  155. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  156. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  157. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  158. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  159. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  160. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x0f, 0xff,
  161. 0x0f, 0xff, 0x0f, 0xff, 0x02, 0xe9, 0x06, 0x8c, 0x06, 0x8c, 0x0f,
  162. 0xff, 0x1a, 0x75, 0x0d, 0x8b, 0x04, 0xe9, 0x0b, 0x16, 0x1a, 0x38,
  163. 0x0d, 0xc8, 0x04, 0x6f, 0x0b, 0x91, 0x0f, 0xff, 0x06, 0x40, 0x06,
  164. 0x40, 0x02, 0x8f, 0x0f, 0xff, 0x06, 0x62, 0x06, 0x62, 0x02, 0x7b,
  165. 0x0f, 0xff, 0x06, 0x97, 0x06, 0x97, 0x02, 0x52, 0x0f, 0xff, 0x06,
  166. 0xf6, 0x06, 0xf6, 0x02, 0x19, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55,
  167. 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x14,
  168. 0xda, 0x0d, 0x93, 0x04, 0xda, 0x05, 0x93, 0x14, 0xda, 0x0d, 0x93,
  169. 0x04, 0xda, 0x05, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  170. 0x00, 0x02, 0x00
  171. };
  172. static unsigned char page_zero_v2[] __initdata = {
  173. 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  174. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  175. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  176. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  177. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  178. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  179. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  180. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  181. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  182. };
  183. static unsigned char page_one_v2[] __initdata = {
  184. 0x01, 0xc0, 0x01, 0xfa, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,
  185. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  186. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  187. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  188. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  189. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  190. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  191. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  192. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  193. };
  194. static unsigned char page_two_v2[] __initdata = {
  195. 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  196. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  197. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  198. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  199. 0x00, 0x00, 0x00, 0x00
  200. };
  201. static unsigned char page_three_v2[] __initdata = {
  202. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  203. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  204. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  205. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  206. 0x00, 0x00, 0x00, 0x00
  207. };
  208. static unsigned char page_four_v2[] __initdata = {
  209. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  210. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  211. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  212. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  213. 0x00, 0x00, 0x00, 0x00
  214. };
  215. static unsigned char page_seven_v2[] __initdata = {
  216. 0x0f, 0xff, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  217. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  218. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  219. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  220. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  221. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  222. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  223. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  224. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  225. };
  226. static unsigned char mod_v2[] __initdata = {
  227. 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02,
  228. 0x00, 0x01, 0x03, 0x02, 0x00, 0x01, 0x04, 0x02, 0x00, 0x01, 0x05,
  229. 0x02, 0x00, 0x01, 0x06, 0x02, 0x00, 0x01, 0x07, 0x02, 0x00, 0xb0,
  230. 0x20, 0xb1, 0x20, 0xb2, 0x20, 0xb3, 0x20, 0xb4, 0x20, 0xb5, 0x20,
  231. 0xb6, 0x20, 0xb7, 0x20, 0xf0, 0x20, 0xf1, 0x20, 0xf2, 0x20, 0xf3,
  232. 0x20, 0xf4, 0x20, 0xf5, 0x20, 0xf6, 0x20, 0xf7, 0x20, 0x10, 0xff,
  233. 0x11, 0xff, 0x12, 0xff, 0x13, 0xff, 0x14, 0xff, 0x15, 0xff, 0x16,
  234. 0xff, 0x17, 0xff, 0x20, 0xff, 0x21, 0xff, 0x22, 0xff, 0x23, 0xff,
  235. 0x24, 0xff, 0x25, 0xff, 0x26, 0xff, 0x27, 0xff, 0x30, 0x00, 0x31,
  236. 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00,
  237. 0x37, 0x00, 0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44,
  238. 0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00, 0x50, 0x00, 0x51, 0x00,
  239. 0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57,
  240. 0x00, 0x60, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00,
  241. 0x65, 0x00, 0x66, 0x00, 0x67, 0x00, 0x70, 0xc0, 0x71, 0xc0, 0x72,
  242. 0xc0, 0x73, 0xc0, 0x74, 0xc0, 0x75, 0xc0, 0x76, 0xc0, 0x77, 0xc0,
  243. 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, 0x00, 0x84, 0x00, 0x85,
  244. 0x00, 0x86, 0x00, 0x87, 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00,
  245. 0x93, 0x00, 0x94, 0x00, 0x95, 0x00, 0x96, 0x00, 0x97, 0x00, 0xa0,
  246. 0x00, 0xa1, 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00,
  247. 0xa6, 0x00, 0xa7, 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3,
  248. 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xd0, 0x00,
  249. 0xd1, 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6,
  250. 0x00, 0xd7, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, 0x00,
  251. 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0x01, 0x00, 0x02,
  252. 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x03,
  253. 0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x05, 0x02, 0x01, 0x01,
  254. 0x06, 0x02, 0x01, 0x01, 0x07, 0x02, 0x01
  255. };
  256. static unsigned char coefficients[] __initdata = {
  257. 0x07, 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x00, 0x4b, 0x03,
  258. 0x11, 0x00, 0x4d, 0x01, 0x32, 0x07, 0x46, 0x00, 0x00, 0x07, 0x49,
  259. 0x00, 0x00, 0x07, 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x01,
  260. 0x40, 0x02, 0x40, 0x01, 0x41, 0x02, 0x60, 0x07, 0x40, 0x00, 0x00,
  261. 0x07, 0x41, 0x00, 0x00, 0x07, 0x47, 0x00, 0x00, 0x07, 0x4a, 0x00,
  262. 0x00, 0x00, 0x47, 0x01, 0x00, 0x00, 0x4a, 0x01, 0x20, 0x07, 0x47,
  263. 0x00, 0x00, 0x07, 0x4a, 0x00, 0x00, 0x07, 0x7c, 0x00, 0x00, 0x07,
  264. 0x7e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1c, 0x07, 0x7c, 0x00, 0x00,
  265. 0x07, 0x7e, 0x00, 0x00, 0x07, 0x44, 0x00, 0x00, 0x00, 0x44, 0x01,
  266. 0x00, 0x07, 0x44, 0x00, 0x00, 0x07, 0x42, 0x00, 0x00, 0x07, 0x43,
  267. 0x00, 0x00, 0x00, 0x42, 0x01, 0x1a, 0x00, 0x43, 0x01, 0x20, 0x07,
  268. 0x42, 0x00, 0x00, 0x07, 0x43, 0x00, 0x00, 0x07, 0x40, 0x00, 0x00,
  269. 0x07, 0x41, 0x00, 0x00, 0x01, 0x40, 0x02, 0x40, 0x01, 0x41, 0x02,
  270. 0x60, 0x07, 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x07, 0x44,
  271. 0x0f, 0xff, 0x07, 0x42, 0x00, 0x00, 0x07, 0x43, 0x00, 0x00, 0x07,
  272. 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x07, 0x51, 0x06, 0x40,
  273. 0x07, 0x50, 0x06, 0x40, 0x07, 0x4f, 0x03, 0x81, 0x07, 0x53, 0x1a,
  274. 0x76, 0x07, 0x54, 0x0d, 0x8b, 0x07, 0x55, 0x04, 0xe9, 0x07, 0x56,
  275. 0x0b, 0x17, 0x07, 0x57, 0x1a, 0x38, 0x07, 0x58, 0x0d, 0xc9, 0x07,
  276. 0x59, 0x04, 0x6f, 0x07, 0x5a, 0x0b, 0x91, 0x07, 0x73, 0x14, 0xda,
  277. 0x07, 0x74, 0x0d, 0x93, 0x07, 0x75, 0x04, 0xd9, 0x07, 0x76, 0x05,
  278. 0x93, 0x07, 0x77, 0x14, 0xda, 0x07, 0x78, 0x0d, 0x93, 0x07, 0x79,
  279. 0x04, 0xd9, 0x07, 0x7a, 0x05, 0x93, 0x07, 0x5e, 0x03, 0x68, 0x07,
  280. 0x5c, 0x04, 0x31, 0x07, 0x5d, 0x04, 0x31, 0x07, 0x62, 0x03, 0x52,
  281. 0x07, 0x60, 0x04, 0x76, 0x07, 0x61, 0x04, 0x76, 0x07, 0x66, 0x03,
  282. 0x2e, 0x07, 0x64, 0x04, 0xda, 0x07, 0x65, 0x04, 0xda, 0x07, 0x6a,
  283. 0x02, 0xf6, 0x07, 0x68, 0x05, 0x62, 0x07, 0x69, 0x05, 0x62, 0x06,
  284. 0x46, 0x0a, 0x22, 0x06, 0x48, 0x0d, 0x24, 0x06, 0x6e, 0x11, 0xd3,
  285. 0x06, 0x70, 0x15, 0xcb, 0x06, 0x52, 0x20, 0x93, 0x06, 0x54, 0x20,
  286. 0x54, 0x06, 0x4a, 0x27, 0x1d, 0x06, 0x58, 0x2f, 0xc8, 0x06, 0x5c,
  287. 0x30, 0x07, 0x06, 0x4c, 0x37, 0x90, 0x06, 0x60, 0x3d, 0xdb, 0x06,
  288. 0x64, 0x3e, 0x42, 0x06, 0x4e, 0x45, 0x78, 0x06, 0x68, 0x4c, 0x48,
  289. 0x06, 0x6c, 0x4c, 0x6c, 0x06, 0x50, 0x52, 0xe2, 0x06, 0x42, 0x02,
  290. 0xba
  291. };
  292. static unsigned char coefficients2[] __initdata = {
  293. 0x07, 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x07, 0x45, 0x0f,
  294. 0xff, 0x07, 0x48, 0x0f, 0xff, 0x07, 0x7b, 0x04, 0xcc, 0x07, 0x7d,
  295. 0x04, 0xcc, 0x07, 0x7c, 0x00, 0x00, 0x07, 0x7e, 0x00, 0x00, 0x07,
  296. 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x07, 0x47, 0x00, 0x00,
  297. 0x07, 0x4a, 0x00, 0x00, 0x07, 0x4c, 0x00, 0x00, 0x07, 0x4e, 0x00, 0x00
  298. };
  299. static unsigned char coefficients3[] __initdata = {
  300. 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, 0x00, 0x51, 0x00,
  301. 0x51, 0x00, 0x7a, 0x00, 0x7a, 0x00, 0xa3, 0x00, 0xa3, 0x00, 0xcc,
  302. 0x00, 0xcc, 0x00, 0xf5, 0x00, 0xf5, 0x01, 0x1e, 0x01, 0x1e, 0x01,
  303. 0x47, 0x01, 0x47, 0x01, 0x70, 0x01, 0x70, 0x01, 0x99, 0x01, 0x99,
  304. 0x01, 0xc2, 0x01, 0xc2, 0x01, 0xeb, 0x01, 0xeb, 0x02, 0x14, 0x02,
  305. 0x14, 0x02, 0x3d, 0x02, 0x3d, 0x02, 0x66, 0x02, 0x66, 0x02, 0x8f,
  306. 0x02, 0x8f, 0x02, 0xb8, 0x02, 0xb8, 0x02, 0xe1, 0x02, 0xe1, 0x03,
  307. 0x0a, 0x03, 0x0a, 0x03, 0x33, 0x03, 0x33, 0x03, 0x5c, 0x03, 0x5c,
  308. 0x03, 0x85, 0x03, 0x85, 0x03, 0xae, 0x03, 0xae, 0x03, 0xd7, 0x03,
  309. 0xd7, 0x04, 0x00, 0x04, 0x00, 0x04, 0x28, 0x04, 0x28, 0x04, 0x51,
  310. 0x04, 0x51, 0x04, 0x7a, 0x04, 0x7a, 0x04, 0xa3, 0x04, 0xa3, 0x04,
  311. 0xcc, 0x04, 0xcc, 0x04, 0xf5, 0x04, 0xf5, 0x05, 0x1e, 0x05, 0x1e,
  312. 0x05, 0x47, 0x05, 0x47, 0x05, 0x70, 0x05, 0x70, 0x05, 0x99, 0x05,
  313. 0x99, 0x05, 0xc2, 0x05, 0xc2, 0x05, 0xeb, 0x05, 0xeb, 0x06, 0x14,
  314. 0x06, 0x14, 0x06, 0x3d, 0x06, 0x3d, 0x06, 0x66, 0x06, 0x66, 0x06,
  315. 0x8f, 0x06, 0x8f, 0x06, 0xb8, 0x06, 0xb8, 0x06, 0xe1, 0x06, 0xe1,
  316. 0x07, 0x0a, 0x07, 0x0a, 0x07, 0x33, 0x07, 0x33, 0x07, 0x5c, 0x07,
  317. 0x5c, 0x07, 0x85, 0x07, 0x85, 0x07, 0xae, 0x07, 0xae, 0x07, 0xd7,
  318. 0x07, 0xd7, 0x08, 0x00, 0x08, 0x00, 0x08, 0x28, 0x08, 0x28, 0x08,
  319. 0x51, 0x08, 0x51, 0x08, 0x7a, 0x08, 0x7a, 0x08, 0xa3, 0x08, 0xa3,
  320. 0x08, 0xcc, 0x08, 0xcc, 0x08, 0xf5, 0x08, 0xf5, 0x09, 0x1e, 0x09,
  321. 0x1e, 0x09, 0x47, 0x09, 0x47, 0x09, 0x70, 0x09, 0x70, 0x09, 0x99,
  322. 0x09, 0x99, 0x09, 0xc2, 0x09, 0xc2, 0x09, 0xeb, 0x09, 0xeb, 0x0a,
  323. 0x14, 0x0a, 0x14, 0x0a, 0x3d, 0x0a, 0x3d, 0x0a, 0x66, 0x0a, 0x66,
  324. 0x0a, 0x8f, 0x0a, 0x8f, 0x0a, 0xb8, 0x0a, 0xb8, 0x0a, 0xe1, 0x0a,
  325. 0xe1, 0x0b, 0x0a, 0x0b, 0x0a, 0x0b, 0x33, 0x0b, 0x33, 0x0b, 0x5c,
  326. 0x0b, 0x5c, 0x0b, 0x85, 0x0b, 0x85, 0x0b, 0xae, 0x0b, 0xae, 0x0b,
  327. 0xd7, 0x0b, 0xd7, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x28, 0x0c, 0x28,
  328. 0x0c, 0x51, 0x0c, 0x51, 0x0c, 0x7a, 0x0c, 0x7a, 0x0c, 0xa3, 0x0c,
  329. 0xa3, 0x0c, 0xcc, 0x0c, 0xcc, 0x0c, 0xf5, 0x0c, 0xf5, 0x0d, 0x1e,
  330. 0x0d, 0x1e, 0x0d, 0x47, 0x0d, 0x47, 0x0d, 0x70, 0x0d, 0x70, 0x0d,
  331. 0x99, 0x0d, 0x99, 0x0d, 0xc2, 0x0d, 0xc2, 0x0d, 0xeb, 0x0d, 0xeb,
  332. 0x0e, 0x14, 0x0e, 0x14, 0x0e, 0x3d, 0x0e, 0x3d, 0x0e, 0x66, 0x0e,
  333. 0x66, 0x0e, 0x8f, 0x0e, 0x8f, 0x0e, 0xb8, 0x0e, 0xb8, 0x0e, 0xe1,
  334. 0x0e, 0xe1, 0x0f, 0x0a, 0x0f, 0x0a, 0x0f, 0x33, 0x0f, 0x33, 0x0f,
  335. 0x5c, 0x0f, 0x5c, 0x0f, 0x85, 0x0f, 0x85, 0x0f, 0xae, 0x0f, 0xae,
  336. 0x0f, 0xd7, 0x0f, 0xd7, 0x0f, 0xff, 0x0f, 0xff
  337. };
  338. static int
  339. wavefront_fx_idle (snd_wavefront_t *dev)
  340. {
  341. int i;
  342. unsigned int x = 0x80;
  343. for (i = 0; i < 1000; i++) {
  344. x = inb (dev->fx_status);
  345. if ((x & 0x80) == 0) {
  346. break;
  347. }
  348. }
  349. if (x & 0x80) {
  350. snd_printk ("FX device never idle.\n");
  351. return 0;
  352. }
  353. return (1);
  354. }
  355. static void
  356. wavefront_fx_mute (snd_wavefront_t *dev, int onoff)
  357. {
  358. if (!wavefront_fx_idle(dev)) {
  359. return;
  360. }
  361. outb (onoff ? 0x02 : 0x00, dev->fx_op);
  362. }
  363. static int
  364. wavefront_fx_memset (snd_wavefront_t *dev,
  365. int page,
  366. int addr,
  367. int cnt,
  368. unsigned short *data)
  369. {
  370. if (page < 0 || page > 7) {
  371. snd_printk ("FX memset: "
  372. "page must be >= 0 and <= 7\n");
  373. return -(EINVAL);
  374. }
  375. if (addr < 0 || addr > 0x7f) {
  376. snd_printk ("FX memset: "
  377. "addr must be >= 0 and <= 7f\n");
  378. return -(EINVAL);
  379. }
  380. if (cnt == 1) {
  381. outb (FX_LSB_TRANSFER, dev->fx_lcr);
  382. outb (page, dev->fx_dsp_page);
  383. outb (addr, dev->fx_dsp_addr);
  384. outb ((data[0] >> 8), dev->fx_dsp_msb);
  385. outb ((data[0] & 0xff), dev->fx_dsp_lsb);
  386. snd_printk ("FX: addr %d:%x set to 0x%x\n",
  387. page, addr, data[0]);
  388. } else {
  389. int i;
  390. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  391. outb (page, dev->fx_dsp_page);
  392. outb (addr, dev->fx_dsp_addr);
  393. for (i = 0; i < cnt; i++) {
  394. outb ((data[i] >> 8), dev->fx_dsp_msb);
  395. outb ((data[i] & 0xff), dev->fx_dsp_lsb);
  396. if (!wavefront_fx_idle (dev)) {
  397. break;
  398. }
  399. }
  400. if (i != cnt) {
  401. snd_printk ("FX memset "
  402. "(0x%x, 0x%x, 0x%lx, %d) incomplete\n",
  403. page, addr, (unsigned long) data, cnt);
  404. return -(EIO);
  405. }
  406. }
  407. return 0;
  408. }
  409. int
  410. snd_wavefront_fx_detect (snd_wavefront_t *dev)
  411. {
  412. /* This is a crude check, but its the best one I have for now.
  413. Certainly on the Maui and the Tropez, wavefront_fx_idle() will
  414. report "never idle", which suggests that this test should
  415. work OK.
  416. */
  417. if (inb (dev->fx_status) & 0x80) {
  418. snd_printk ("Hmm, probably a Maui or Tropez.\n");
  419. return -1;
  420. }
  421. return 0;
  422. }
  423. int
  424. snd_wavefront_fx_open (struct snd_hwdep *hw, struct file *file)
  425. {
  426. if (!try_module_get(hw->card->module))
  427. return -EFAULT;
  428. file->private_data = hw;
  429. return 0;
  430. }
  431. int
  432. snd_wavefront_fx_release (struct snd_hwdep *hw, struct file *file)
  433. {
  434. module_put(hw->card->module);
  435. return 0;
  436. }
  437. int
  438. snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
  439. unsigned int cmd, unsigned long arg)
  440. {
  441. struct snd_card *card;
  442. snd_wavefront_card_t *acard;
  443. snd_wavefront_t *dev;
  444. wavefront_fx_info r;
  445. unsigned short *page_data = NULL;
  446. unsigned short *pd;
  447. int err = 0;
  448. snd_assert(sdev->card != NULL, return -ENODEV);
  449. card = sdev->card;
  450. snd_assert(card->private_data != NULL, return -ENODEV);
  451. acard = card->private_data;
  452. dev = &acard->wavefront;
  453. if (copy_from_user (&r, (void __user *)arg, sizeof (wavefront_fx_info)))
  454. return -EFAULT;
  455. switch (r.request) {
  456. case WFFX_MUTE:
  457. wavefront_fx_mute (dev, r.data[0]);
  458. return -EIO;
  459. case WFFX_MEMSET:
  460. if (r.data[2] <= 0) {
  461. snd_printk ("cannot write "
  462. "<= 0 bytes to FX\n");
  463. return -EIO;
  464. } else if (r.data[2] == 1) {
  465. pd = (unsigned short *) &r.data[3];
  466. } else {
  467. if (r.data[2] > 256) {
  468. snd_printk ("cannot write "
  469. "> 512 bytes to FX\n");
  470. return -EIO;
  471. }
  472. page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL);
  473. if (!page_data)
  474. return -ENOMEM;
  475. if (copy_from_user (page_data,
  476. (unsigned char __user *) r.data[3],
  477. r.data[2] * sizeof(short))) {
  478. kfree(page_data);
  479. return -EFAULT;
  480. }
  481. pd = page_data;
  482. }
  483. err = wavefront_fx_memset (dev,
  484. r.data[0], /* page */
  485. r.data[1], /* addr */
  486. r.data[2], /* cnt */
  487. pd);
  488. kfree(page_data);
  489. break;
  490. default:
  491. snd_printk ("FX: ioctl %d not yet supported\n",
  492. r.request);
  493. return -ENOTTY;
  494. }
  495. return err;
  496. }
  497. /* YSS225 initialization.
  498. This code was developed using DOSEMU. The Turtle Beach SETUPSND
  499. utility was run with I/O tracing in DOSEMU enabled, and a reconstruction
  500. of the port I/O done, using the Yamaha faxback document as a guide
  501. to add more logic to the code. Its really pretty weird.
  502. There was an alternative approach of just dumping the whole I/O
  503. sequence as a series of port/value pairs and a simple loop
  504. that output it. However, I hope that eventually I'll get more
  505. control over what this code does, and so I tried to stick with
  506. a somewhat "algorithmic" approach.
  507. */
  508. int __init
  509. snd_wavefront_fx_start (snd_wavefront_t *dev)
  510. {
  511. unsigned int i, j;
  512. /* Set all bits for all channels on the MOD unit to zero */
  513. /* XXX But why do this twice ? */
  514. for (j = 0; j < 2; j++) {
  515. for (i = 0x10; i <= 0xff; i++) {
  516. if (!wavefront_fx_idle (dev)) {
  517. return (-1);
  518. }
  519. outb (i, dev->fx_mod_addr);
  520. outb (0x0, dev->fx_mod_data);
  521. }
  522. }
  523. if (!wavefront_fx_idle (dev)) return (-1);
  524. outb (0x02, dev->fx_op); /* mute on */
  525. if (!wavefront_fx_idle (dev)) return (-1);
  526. outb (0x07, dev->fx_dsp_page);
  527. outb (0x44, dev->fx_dsp_addr);
  528. outb (0x00, dev->fx_dsp_msb);
  529. outb (0x00, dev->fx_dsp_lsb);
  530. if (!wavefront_fx_idle (dev)) return (-1);
  531. outb (0x07, dev->fx_dsp_page);
  532. outb (0x42, dev->fx_dsp_addr);
  533. outb (0x00, dev->fx_dsp_msb);
  534. outb (0x00, dev->fx_dsp_lsb);
  535. if (!wavefront_fx_idle (dev)) return (-1);
  536. outb (0x07, dev->fx_dsp_page);
  537. outb (0x43, dev->fx_dsp_addr);
  538. outb (0x00, dev->fx_dsp_msb);
  539. outb (0x00, dev->fx_dsp_lsb);
  540. if (!wavefront_fx_idle (dev)) return (-1);
  541. outb (0x07, dev->fx_dsp_page);
  542. outb (0x7c, dev->fx_dsp_addr);
  543. outb (0x00, dev->fx_dsp_msb);
  544. outb (0x00, dev->fx_dsp_lsb);
  545. if (!wavefront_fx_idle (dev)) return (-1);
  546. outb (0x07, dev->fx_dsp_page);
  547. outb (0x7e, dev->fx_dsp_addr);
  548. outb (0x00, dev->fx_dsp_msb);
  549. outb (0x00, dev->fx_dsp_lsb);
  550. if (!wavefront_fx_idle (dev)) return (-1);
  551. outb (0x07, dev->fx_dsp_page);
  552. outb (0x46, dev->fx_dsp_addr);
  553. outb (0x00, dev->fx_dsp_msb);
  554. outb (0x00, dev->fx_dsp_lsb);
  555. if (!wavefront_fx_idle (dev)) return (-1);
  556. outb (0x07, dev->fx_dsp_page);
  557. outb (0x49, dev->fx_dsp_addr);
  558. outb (0x00, dev->fx_dsp_msb);
  559. outb (0x00, dev->fx_dsp_lsb);
  560. if (!wavefront_fx_idle (dev)) return (-1);
  561. outb (0x07, dev->fx_dsp_page);
  562. outb (0x47, dev->fx_dsp_addr);
  563. outb (0x00, dev->fx_dsp_msb);
  564. outb (0x00, dev->fx_dsp_lsb);
  565. if (!wavefront_fx_idle (dev)) return (-1);
  566. outb (0x07, dev->fx_dsp_page);
  567. outb (0x4a, dev->fx_dsp_addr);
  568. outb (0x00, dev->fx_dsp_msb);
  569. outb (0x00, dev->fx_dsp_lsb);
  570. /* either because of stupidity by TB's programmers, or because it
  571. actually does something, rezero the MOD page.
  572. */
  573. for (i = 0x10; i <= 0xff; i++) {
  574. if (!wavefront_fx_idle (dev)) {
  575. return (-1);
  576. }
  577. outb (i, dev->fx_mod_addr);
  578. outb (0x0, dev->fx_mod_data);
  579. }
  580. /* load page zero */
  581. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  582. outb (0x00, dev->fx_dsp_page);
  583. outb (0x00, dev->fx_dsp_addr);
  584. for (i = 0; i < sizeof (page_zero); i += 2) {
  585. outb (page_zero[i], dev->fx_dsp_msb);
  586. outb (page_zero[i+1], dev->fx_dsp_lsb);
  587. if (!wavefront_fx_idle (dev)) return (-1);
  588. }
  589. /* Now load page one */
  590. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  591. outb (0x01, dev->fx_dsp_page);
  592. outb (0x00, dev->fx_dsp_addr);
  593. for (i = 0; i < sizeof (page_one); i += 2) {
  594. outb (page_one[i], dev->fx_dsp_msb);
  595. outb (page_one[i+1], dev->fx_dsp_lsb);
  596. if (!wavefront_fx_idle (dev)) return (-1);
  597. }
  598. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  599. outb (0x02, dev->fx_dsp_page);
  600. outb (0x00, dev->fx_dsp_addr);
  601. for (i = 0; i < sizeof (page_two); i++) {
  602. outb (page_two[i], dev->fx_dsp_lsb);
  603. if (!wavefront_fx_idle (dev)) return (-1);
  604. }
  605. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  606. outb (0x03, dev->fx_dsp_page);
  607. outb (0x00, dev->fx_dsp_addr);
  608. for (i = 0; i < sizeof (page_three); i++) {
  609. outb (page_three[i], dev->fx_dsp_lsb);
  610. if (!wavefront_fx_idle (dev)) return (-1);
  611. }
  612. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  613. outb (0x04, dev->fx_dsp_page);
  614. outb (0x00, dev->fx_dsp_addr);
  615. for (i = 0; i < sizeof (page_four); i++) {
  616. outb (page_four[i], dev->fx_dsp_lsb);
  617. if (!wavefront_fx_idle (dev)) return (-1);
  618. }
  619. /* Load memory area (page six) */
  620. outb (FX_LSB_TRANSFER, dev->fx_lcr);
  621. outb (0x06, dev->fx_dsp_page);
  622. for (i = 0; i < sizeof (page_six); i += 3) {
  623. outb (page_six[i], dev->fx_dsp_addr);
  624. outb (page_six[i+1], dev->fx_dsp_msb);
  625. outb (page_six[i+2], dev->fx_dsp_lsb);
  626. if (!wavefront_fx_idle (dev)) return (-1);
  627. }
  628. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  629. outb (0x07, dev->fx_dsp_page);
  630. outb (0x00, dev->fx_dsp_addr);
  631. for (i = 0; i < sizeof (page_seven); i += 2) {
  632. outb (page_seven[i], dev->fx_dsp_msb);
  633. outb (page_seven[i+1], dev->fx_dsp_lsb);
  634. if (!wavefront_fx_idle (dev)) return (-1);
  635. }
  636. /* Now setup the MOD area. We do this algorithmically in order to
  637. save a little data space. It could be done in the same fashion
  638. as the "pages".
  639. */
  640. for (i = 0x00; i <= 0x0f; i++) {
  641. outb (0x01, dev->fx_mod_addr);
  642. outb (i, dev->fx_mod_data);
  643. if (!wavefront_fx_idle (dev)) return (-1);
  644. outb (0x02, dev->fx_mod_addr);
  645. outb (0x00, dev->fx_mod_data);
  646. if (!wavefront_fx_idle (dev)) return (-1);
  647. }
  648. for (i = 0xb0; i <= 0xbf; i++) {
  649. outb (i, dev->fx_mod_addr);
  650. outb (0x20, dev->fx_mod_data);
  651. if (!wavefront_fx_idle (dev)) return (-1);
  652. }
  653. for (i = 0xf0; i <= 0xff; i++) {
  654. outb (i, dev->fx_mod_addr);
  655. outb (0x20, dev->fx_mod_data);
  656. if (!wavefront_fx_idle (dev)) return (-1);
  657. }
  658. for (i = 0x10; i <= 0x1d; i++) {
  659. outb (i, dev->fx_mod_addr);
  660. outb (0xff, dev->fx_mod_data);
  661. if (!wavefront_fx_idle (dev)) return (-1);
  662. }
  663. outb (0x1e, dev->fx_mod_addr);
  664. outb (0x40, dev->fx_mod_data);
  665. if (!wavefront_fx_idle (dev)) return (-1);
  666. for (i = 0x1f; i <= 0x2d; i++) {
  667. outb (i, dev->fx_mod_addr);
  668. outb (0xff, dev->fx_mod_data);
  669. if (!wavefront_fx_idle (dev)) return (-1);
  670. }
  671. outb (0x2e, dev->fx_mod_addr);
  672. outb (0x00, dev->fx_mod_data);
  673. if (!wavefront_fx_idle (dev)) return (-1);
  674. for (i = 0x2f; i <= 0x3e; i++) {
  675. outb (i, dev->fx_mod_addr);
  676. outb (0x00, dev->fx_mod_data);
  677. if (!wavefront_fx_idle (dev)) return (-1);
  678. }
  679. outb (0x3f, dev->fx_mod_addr);
  680. outb (0x20, dev->fx_mod_data);
  681. if (!wavefront_fx_idle (dev)) return (-1);
  682. for (i = 0x40; i <= 0x4d; i++) {
  683. outb (i, dev->fx_mod_addr);
  684. outb (0x00, dev->fx_mod_data);
  685. if (!wavefront_fx_idle (dev)) return (-1);
  686. }
  687. outb (0x4e, dev->fx_mod_addr);
  688. outb (0x0e, dev->fx_mod_data);
  689. if (!wavefront_fx_idle (dev)) return (-1);
  690. outb (0x4f, dev->fx_mod_addr);
  691. outb (0x0e, dev->fx_mod_data);
  692. if (!wavefront_fx_idle (dev)) return (-1);
  693. for (i = 0x50; i <= 0x6b; i++) {
  694. outb (i, dev->fx_mod_addr);
  695. outb (0x00, dev->fx_mod_data);
  696. if (!wavefront_fx_idle (dev)) return (-1);
  697. }
  698. outb (0x6c, dev->fx_mod_addr);
  699. outb (0x40, dev->fx_mod_data);
  700. if (!wavefront_fx_idle (dev)) return (-1);
  701. outb (0x6d, dev->fx_mod_addr);
  702. outb (0x00, dev->fx_mod_data);
  703. if (!wavefront_fx_idle (dev)) return (-1);
  704. outb (0x6e, dev->fx_mod_addr);
  705. outb (0x40, dev->fx_mod_data);
  706. if (!wavefront_fx_idle (dev)) return (-1);
  707. outb (0x6f, dev->fx_mod_addr);
  708. outb (0x40, dev->fx_mod_data);
  709. if (!wavefront_fx_idle (dev)) return (-1);
  710. for (i = 0x70; i <= 0x7f; i++) {
  711. outb (i, dev->fx_mod_addr);
  712. outb (0xc0, dev->fx_mod_data);
  713. if (!wavefront_fx_idle (dev)) return (-1);
  714. }
  715. for (i = 0x80; i <= 0xaf; i++) {
  716. outb (i, dev->fx_mod_addr);
  717. outb (0x00, dev->fx_mod_data);
  718. if (!wavefront_fx_idle (dev)) return (-1);
  719. }
  720. for (i = 0xc0; i <= 0xdd; i++) {
  721. outb (i, dev->fx_mod_addr);
  722. outb (0x00, dev->fx_mod_data);
  723. if (!wavefront_fx_idle (dev)) return (-1);
  724. }
  725. outb (0xde, dev->fx_mod_addr);
  726. outb (0x10, dev->fx_mod_data);
  727. if (!wavefront_fx_idle (dev)) return (-1);
  728. outb (0xdf, dev->fx_mod_addr);
  729. outb (0x10, dev->fx_mod_data);
  730. if (!wavefront_fx_idle (dev)) return (-1);
  731. for (i = 0xe0; i <= 0xef; i++) {
  732. outb (i, dev->fx_mod_addr);
  733. outb (0x00, dev->fx_mod_data);
  734. if (!wavefront_fx_idle (dev)) return (-1);
  735. }
  736. for (i = 0x00; i <= 0x0f; i++) {
  737. outb (0x01, dev->fx_mod_addr);
  738. outb (i, dev->fx_mod_data);
  739. outb (0x02, dev->fx_mod_addr);
  740. outb (0x01, dev->fx_mod_data);
  741. if (!wavefront_fx_idle (dev)) return (-1);
  742. }
  743. outb (0x02, dev->fx_op); /* mute on */
  744. /* Now set the coefficients and so forth for the programs above */
  745. for (i = 0; i < sizeof (coefficients); i += 4) {
  746. outb (coefficients[i], dev->fx_dsp_page);
  747. outb (coefficients[i+1], dev->fx_dsp_addr);
  748. outb (coefficients[i+2], dev->fx_dsp_msb);
  749. outb (coefficients[i+3], dev->fx_dsp_lsb);
  750. if (!wavefront_fx_idle (dev)) return (-1);
  751. }
  752. /* Some settings (?) that are too small to bundle into loops */
  753. if (!wavefront_fx_idle (dev)) return (-1);
  754. outb (0x1e, dev->fx_mod_addr);
  755. outb (0x14, dev->fx_mod_data);
  756. if (!wavefront_fx_idle (dev)) return (-1);
  757. outb (0xde, dev->fx_mod_addr);
  758. outb (0x20, dev->fx_mod_data);
  759. if (!wavefront_fx_idle (dev)) return (-1);
  760. outb (0xdf, dev->fx_mod_addr);
  761. outb (0x20, dev->fx_mod_data);
  762. /* some more coefficients */
  763. if (!wavefront_fx_idle (dev)) return (-1);
  764. outb (0x06, dev->fx_dsp_page);
  765. outb (0x78, dev->fx_dsp_addr);
  766. outb (0x00, dev->fx_dsp_msb);
  767. outb (0x40, dev->fx_dsp_lsb);
  768. if (!wavefront_fx_idle (dev)) return (-1);
  769. outb (0x07, dev->fx_dsp_page);
  770. outb (0x03, dev->fx_dsp_addr);
  771. outb (0x0f, dev->fx_dsp_msb);
  772. outb (0xff, dev->fx_dsp_lsb);
  773. if (!wavefront_fx_idle (dev)) return (-1);
  774. outb (0x07, dev->fx_dsp_page);
  775. outb (0x0b, dev->fx_dsp_addr);
  776. outb (0x0f, dev->fx_dsp_msb);
  777. outb (0xff, dev->fx_dsp_lsb);
  778. if (!wavefront_fx_idle (dev)) return (-1);
  779. outb (0x07, dev->fx_dsp_page);
  780. outb (0x02, dev->fx_dsp_addr);
  781. outb (0x00, dev->fx_dsp_msb);
  782. outb (0x00, dev->fx_dsp_lsb);
  783. if (!wavefront_fx_idle (dev)) return (-1);
  784. outb (0x07, dev->fx_dsp_page);
  785. outb (0x0a, dev->fx_dsp_addr);
  786. outb (0x00, dev->fx_dsp_msb);
  787. outb (0x00, dev->fx_dsp_lsb);
  788. if (!wavefront_fx_idle (dev)) return (-1);
  789. outb (0x07, dev->fx_dsp_page);
  790. outb (0x46, dev->fx_dsp_addr);
  791. outb (0x00, dev->fx_dsp_msb);
  792. outb (0x00, dev->fx_dsp_lsb);
  793. if (!wavefront_fx_idle (dev)) return (-1);
  794. outb (0x07, dev->fx_dsp_page);
  795. outb (0x49, dev->fx_dsp_addr);
  796. outb (0x00, dev->fx_dsp_msb);
  797. outb (0x00, dev->fx_dsp_lsb);
  798. /* Now, for some strange reason, lets reload every page
  799. and all the coefficients over again. I have *NO* idea
  800. why this is done. I do know that no sound is produced
  801. is this phase is omitted.
  802. */
  803. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  804. outb (0x00, dev->fx_dsp_page);
  805. outb (0x10, dev->fx_dsp_addr);
  806. for (i = 0; i < sizeof (page_zero_v2); i += 2) {
  807. outb (page_zero_v2[i], dev->fx_dsp_msb);
  808. outb (page_zero_v2[i+1], dev->fx_dsp_lsb);
  809. if (!wavefront_fx_idle (dev)) return (-1);
  810. }
  811. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  812. outb (0x01, dev->fx_dsp_page);
  813. outb (0x10, dev->fx_dsp_addr);
  814. for (i = 0; i < sizeof (page_one_v2); i += 2) {
  815. outb (page_one_v2[i], dev->fx_dsp_msb);
  816. outb (page_one_v2[i+1], dev->fx_dsp_lsb);
  817. if (!wavefront_fx_idle (dev)) return (-1);
  818. }
  819. if (!wavefront_fx_idle (dev)) return (-1);
  820. if (!wavefront_fx_idle (dev)) return (-1);
  821. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  822. outb (0x02, dev->fx_dsp_page);
  823. outb (0x10, dev->fx_dsp_addr);
  824. for (i = 0; i < sizeof (page_two_v2); i++) {
  825. outb (page_two_v2[i], dev->fx_dsp_lsb);
  826. if (!wavefront_fx_idle (dev)) return (-1);
  827. }
  828. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  829. outb (0x03, dev->fx_dsp_page);
  830. outb (0x10, dev->fx_dsp_addr);
  831. for (i = 0; i < sizeof (page_three_v2); i++) {
  832. outb (page_three_v2[i], dev->fx_dsp_lsb);
  833. if (!wavefront_fx_idle (dev)) return (-1);
  834. }
  835. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  836. outb (0x04, dev->fx_dsp_page);
  837. outb (0x10, dev->fx_dsp_addr);
  838. for (i = 0; i < sizeof (page_four_v2); i++) {
  839. outb (page_four_v2[i], dev->fx_dsp_lsb);
  840. if (!wavefront_fx_idle (dev)) return (-1);
  841. }
  842. outb (FX_LSB_TRANSFER, dev->fx_lcr);
  843. outb (0x06, dev->fx_dsp_page);
  844. /* Page six v.2 is algorithmic */
  845. for (i = 0x10; i <= 0x3e; i += 2) {
  846. outb (i, dev->fx_dsp_addr);
  847. outb (0x00, dev->fx_dsp_msb);
  848. outb (0x00, dev->fx_dsp_lsb);
  849. if (!wavefront_fx_idle (dev)) return (-1);
  850. }
  851. outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
  852. outb (0x07, dev->fx_dsp_page);
  853. outb (0x10, dev->fx_dsp_addr);
  854. for (i = 0; i < sizeof (page_seven_v2); i += 2) {
  855. outb (page_seven_v2[i], dev->fx_dsp_msb);
  856. outb (page_seven_v2[i+1], dev->fx_dsp_lsb);
  857. if (!wavefront_fx_idle (dev)) return (-1);
  858. }
  859. for (i = 0x00; i < sizeof(mod_v2); i += 2) {
  860. outb (mod_v2[i], dev->fx_mod_addr);
  861. outb (mod_v2[i+1], dev->fx_mod_data);
  862. if (!wavefront_fx_idle (dev)) return (-1);
  863. }
  864. for (i = 0; i < sizeof (coefficients2); i += 4) {
  865. outb (coefficients2[i], dev->fx_dsp_page);
  866. outb (coefficients2[i+1], dev->fx_dsp_addr);
  867. outb (coefficients2[i+2], dev->fx_dsp_msb);
  868. outb (coefficients2[i+3], dev->fx_dsp_lsb);
  869. if (!wavefront_fx_idle (dev)) return (-1);
  870. }
  871. for (i = 0; i < sizeof (coefficients3); i += 2) {
  872. int x;
  873. outb (0x07, dev->fx_dsp_page);
  874. x = (i % 4) ? 0x4e : 0x4c;
  875. outb (x, dev->fx_dsp_addr);
  876. outb (coefficients3[i], dev->fx_dsp_msb);
  877. outb (coefficients3[i+1], dev->fx_dsp_lsb);
  878. }
  879. outb (0x00, dev->fx_op); /* mute off */
  880. if (!wavefront_fx_idle (dev)) return (-1);
  881. return (0);
  882. }