au88x0_xtalk.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /***************************************************************************
  2. * au88x0_cxtalk.c
  3. *
  4. * Wed Nov 19 16:29:47 2003
  5. * Copyright 2003 mjander
  6. * mjander@users.sourceforge.org
  7. ****************************************************************************/
  8. /*
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Library General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. #include "au88x0_xtalk.h"
  24. /* Data (a whole lot of data.... ) */
  25. static short const sXtalkWideKLeftEq = 0x269C;
  26. static short const sXtalkWideKRightEq = 0x269C;
  27. static short const sXtalkWideKLeftXt = 0xF25E;
  28. static short const sXtalkWideKRightXt = 0xF25E;
  29. static short const sXtalkWideShiftLeftEq = 1;
  30. static short const sXtalkWideShiftRightEq = 1;
  31. static short const sXtalkWideShiftLeftXt = 0;
  32. static short const sXtalkWideShiftRightXt = 0;
  33. static unsigned short const wXtalkWideLeftDelay = 0xd;
  34. static unsigned short const wXtalkWideRightDelay = 0xd;
  35. static short const sXtalkNarrowKLeftEq = 0x468D;
  36. static short const sXtalkNarrowKRightEq = 0x468D;
  37. static short const sXtalkNarrowKLeftXt = 0xF82E;
  38. static short const sXtalkNarrowKRightXt = 0xF82E;
  39. static short const sXtalkNarrowShiftLeftEq = 0x3;
  40. static short const sXtalkNarrowShiftRightEq = 0x3;
  41. static short const sXtalkNarrowShiftLeftXt = 0;
  42. static short const sXtalkNarrowShiftRightXt = 0;
  43. static unsigned short const wXtalkNarrowLeftDelay = 0x7;
  44. static unsigned short const wXtalkNarrowRightDelay = 0x7;
  45. static xtalk_gains_t const asXtalkGainsDefault = {
  46. 0x4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000,
  47. 0x4000
  48. };
  49. static xtalk_gains_t const asXtalkGainsTest = {
  50. 0x8000, 0x7FFF, 0, 0xFFFF, 0x0001, 0xC000, 0x4000, 0xFFFE, 0x0002,
  51. 0
  52. };
  53. static xtalk_gains_t const asXtalkGains1Chan = {
  54. 0x7FFF, 0, 0, 0, 0x7FFF, 0, 0, 0, 0, 0
  55. };
  56. // Input gain for 4 A3D slices. One possible input pair is left zero.
  57. static xtalk_gains_t const asXtalkGainsAllChan = {
  58. 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
  59. 0
  60. //0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff,0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff
  61. };
  62. static xtalk_gains_t const asXtalkGainsZeros = {
  63. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  64. };
  65. static xtalk_dline_t const alXtalkDlineZeros = {
  66. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  67. 0, 0, 0,
  68. 0, 0, 0, 0, 0, 0, 0
  69. };
  70. static xtalk_dline_t const alXtalkDlineTest = {
  71. 0xFC18, 0x03E8FFFF, 0x186A0, 0x7960FFFE, 1, 0xFFFFFFFF,
  72. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  73. 0, 0, 0, 0
  74. };
  75. static xtalk_instate_t const asXtalkInStateZeros = { 0, 0, 0, 0 };
  76. static xtalk_instate_t const asXtalkInStateTest =
  77. { 0xFF80, 0x0080, 0xFFFF, 0x0001 };
  78. static xtalk_state_t const asXtalkOutStateZeros = {
  79. {0, 0, 0, 0},
  80. {0, 0, 0, 0},
  81. {0, 0, 0, 0},
  82. {0, 0, 0, 0},
  83. {0, 0, 0, 0}
  84. };
  85. static short const sDiamondKLeftEq = 0x401d;
  86. static short const sDiamondKRightEq = 0x401d;
  87. static short const sDiamondKLeftXt = 0xF90E;
  88. static short const sDiamondKRightXt = 0xF90E;
  89. static short const sDiamondShiftLeftEq = 1; /* 0xF90E Is this a bug ??? */
  90. static short const sDiamondShiftRightEq = 1;
  91. static short const sDiamondShiftLeftXt = 0;
  92. static short const sDiamondShiftRightXt = 0;
  93. static unsigned short const wDiamondLeftDelay = 0xb;
  94. static unsigned short const wDiamondRightDelay = 0xb;
  95. static xtalk_coefs_t const asXtalkWideCoefsLeftEq = {
  96. {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
  97. {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
  98. {0x340B, 0xf504, 0x6CE8, 0x0D23, 0x00E4},
  99. {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA},
  100. {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
  101. };
  102. static xtalk_coefs_t const asXtalkWideCoefsRightEq = {
  103. {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
  104. {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
  105. {0x340B, 0xF504, 0x6CE8, 0x0D23, 0x00E4},
  106. {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA},
  107. {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
  108. };
  109. static xtalk_coefs_t const asXtalkWideCoefsLeftXt = {
  110. {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047},
  111. {0x6000, 0x206A, 0xC6CA, 0x40FF, 0},
  112. {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001},
  113. {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0},
  114. {0, 0, 0, 0, 0}
  115. };
  116. static xtalk_coefs_t const asXtalkWideCoefsRightXt = {
  117. {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047},
  118. {0x6000, 0x206A, 0xC6CA, 0x40FF, 0},
  119. {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001},
  120. {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0},
  121. {0, 0, 0, 0, 0}
  122. };
  123. static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = {
  124. {0x50B5, 0xD07C, 0x026D, 0xFD21, 0},
  125. {0x460F, 0xE44F, 0xF75E, 0xEFA6, 0},
  126. {0x556D, 0xDCAB, 0x2098, 0xF0F2, 0},
  127. {0x7E03, 0xC1F0, 0x007D, 0xFF89, 0},
  128. {0x383E, 0xFD9D, 0xB278, 0x4547, 0}
  129. };
  130. static xtalk_coefs_t const asXtalkNarrowCoefsRightEq = {
  131. {0x50B5, 0xD07C, 0x026D, 0xFD21, 0},
  132. {0x460F, 0xE44F, 0xF75E, 0xEFA6, 0},
  133. {0x556D, 0xDCAB, 0x2098, 0xF0F2, 0},
  134. {0x7E03, 0xC1F0, 0x007D, 0xFF89, 0},
  135. {0x383E, 0xFD9D, 0xB278, 0x4547, 0}
  136. };
  137. static xtalk_coefs_t const asXtalkNarrowCoefsLeftXt = {
  138. {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0},
  139. {0x6777, 0xC915, 0xFEAF, 0x00B1, 0},
  140. {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0},
  141. {0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0},
  142. {0, 0, 0, 0, 0}
  143. };
  144. static xtalk_coefs_t const asXtalkNarrowCoefsRightXt = {
  145. {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0},
  146. {0x6777, 0xC915, 0xFEAF, 0x00B1, 0},
  147. {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0},
  148. {0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0},
  149. {0, 0, 0, 0, 0}
  150. };
  151. static xtalk_coefs_t const asXtalkCoefsZeros = {
  152. {0, 0, 0, 0, 0},
  153. {0, 0, 0, 0, 0},
  154. {0, 0, 0, 0, 0},
  155. {0, 0, 0, 0, 0},
  156. {0, 0, 0, 0, 0}
  157. };
  158. static xtalk_coefs_t const asXtalkCoefsPipe = {
  159. {0, 0, 0x0FA0, 0, 0},
  160. {0, 0, 0x0FA0, 0, 0},
  161. {0, 0, 0x0FA0, 0, 0},
  162. {0, 0, 0x0FA0, 0, 0},
  163. {0, 0, 0x1180, 0, 0},
  164. };
  165. static xtalk_coefs_t const asXtalkCoefsNegPipe = {
  166. {0, 0, 0xF380, 0, 0},
  167. {0, 0, 0xF380, 0, 0},
  168. {0, 0, 0xF380, 0, 0},
  169. {0, 0, 0xF380, 0, 0},
  170. {0, 0, 0xF200, 0, 0}
  171. };
  172. static xtalk_coefs_t const asXtalkCoefsNumTest = {
  173. {0, 0, 0xF380, 0x8000, 0x6D60},
  174. {0, 0, 0, 0, 0},
  175. {0, 0, 0, 0, 0},
  176. {0, 0, 0, 0, 0},
  177. {0, 0, 0, 0, 0}
  178. };
  179. static xtalk_coefs_t const asXtalkCoefsDenTest = {
  180. {0xC000, 0x2000, 0x4000, 0, 0},
  181. {0, 0, 0, 0, 0},
  182. {0, 0, 0, 0, 0},
  183. {0, 0, 0, 0, 0},
  184. {0, 0, 0, 0, 0}
  185. };
  186. static xtalk_state_t const asXtalkOutStateTest = {
  187. {0x7FFF, 0x0004, 0xFFFC, 0},
  188. {0xFE00, 0x0008, 0xFFF8, 0x4000},
  189. {0x200, 0x0010, 0xFFF0, 0xC000},
  190. {0x8000, 0x0020, 0xFFE0, 0},
  191. {0, 0, 0, 0}
  192. };
  193. static xtalk_coefs_t const asDiamondCoefsLeftEq = {
  194. {0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0},
  195. {0x45E2, 0xCA51, 0x0448, 0xFCE7, 0},
  196. {0xA93E, 0xDBD5, 0x022C, 0x028A, 0},
  197. {0, 0, 0, 0, 0},
  198. {0, 0, 0, 0, 0}
  199. };
  200. static xtalk_coefs_t const asDiamondCoefsRightEq = {
  201. {0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0},
  202. {0x45E2, 0xCA51, 0x0448, 0xFCE7, 0},
  203. {0xA93E, 0xDBD5, 0x022C, 0x028A, 0},
  204. {0, 0, 0, 0, 0},
  205. {0, 0, 0, 0, 0}
  206. };
  207. static xtalk_coefs_t const asDiamondCoefsLeftXt = {
  208. {0x3B50, 0xFE08, 0xF959, 0x0060, 0},
  209. {0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0},
  210. {0, 0, 0, 0, 0},
  211. {0, 0, 0, 0, 0},
  212. {0, 0, 0, 0, 0}
  213. };
  214. static xtalk_coefs_t const asDiamondCoefsRightXt = {
  215. {0x3B50, 0xFE08, 0xF959, 0x0060, 0},
  216. {0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0},
  217. {0, 0, 0, 0, 0},
  218. {0, 0, 0, 0, 0},
  219. {0, 0, 0, 0, 0}
  220. };
  221. /**/
  222. /* XTalk EQ and XT */
  223. static void
  224. vortex_XtalkHw_SetLeftEQ(vortex_t * vortex, short arg_0, short arg_4,
  225. xtalk_coefs_t const coefs)
  226. {
  227. int i;
  228. for (i = 0; i < 5; i++) {
  229. hwwrite(vortex->mmio, 0x24200 + i * 0x24, coefs[i][0]);
  230. hwwrite(vortex->mmio, 0x24204 + i * 0x24, coefs[i][1]);
  231. hwwrite(vortex->mmio, 0x24208 + i * 0x24, coefs[i][2]);
  232. hwwrite(vortex->mmio, 0x2420c + i * 0x24, coefs[i][3]);
  233. hwwrite(vortex->mmio, 0x24210 + i * 0x24, coefs[i][4]);
  234. }
  235. hwwrite(vortex->mmio, 0x24538, arg_0 & 0xffff);
  236. hwwrite(vortex->mmio, 0x2453C, arg_4 & 0xffff);
  237. }
  238. static void
  239. vortex_XtalkHw_SetRightEQ(vortex_t * vortex, short arg_0, short arg_4,
  240. xtalk_coefs_t const coefs)
  241. {
  242. int i;
  243. for (i = 0; i < 5; i++) {
  244. hwwrite(vortex->mmio, 0x242b4 + i * 0x24, coefs[i][0]);
  245. hwwrite(vortex->mmio, 0x242b8 + i * 0x24, coefs[i][1]);
  246. hwwrite(vortex->mmio, 0x242bc + i * 0x24, coefs[i][2]);
  247. hwwrite(vortex->mmio, 0x242c0 + i * 0x24, coefs[i][3]);
  248. hwwrite(vortex->mmio, 0x242c4 + i * 0x24, coefs[i][4]);
  249. }
  250. hwwrite(vortex->mmio, 0x24540, arg_0 & 0xffff);
  251. hwwrite(vortex->mmio, 0x24544, arg_4 & 0xffff);
  252. }
  253. static void
  254. vortex_XtalkHw_SetLeftXT(vortex_t * vortex, short arg_0, short arg_4,
  255. xtalk_coefs_t const coefs)
  256. {
  257. int i;
  258. for (i = 0; i < 5; i++) {
  259. hwwrite(vortex->mmio, 0x24368 + i * 0x24, coefs[i][0]);
  260. hwwrite(vortex->mmio, 0x2436c + i * 0x24, coefs[i][1]);
  261. hwwrite(vortex->mmio, 0x24370 + i * 0x24, coefs[i][2]);
  262. hwwrite(vortex->mmio, 0x24374 + i * 0x24, coefs[i][3]);
  263. hwwrite(vortex->mmio, 0x24378 + i * 0x24, coefs[i][4]);
  264. }
  265. hwwrite(vortex->mmio, 0x24548, arg_0 & 0xffff);
  266. hwwrite(vortex->mmio, 0x2454C, arg_4 & 0xffff);
  267. }
  268. static void
  269. vortex_XtalkHw_SetRightXT(vortex_t * vortex, short arg_0, short arg_4,
  270. xtalk_coefs_t const coefs)
  271. {
  272. int i;
  273. for (i = 0; i < 5; i++) {
  274. hwwrite(vortex->mmio, 0x2441C + i * 0x24, coefs[i][0]);
  275. hwwrite(vortex->mmio, 0x24420 + i * 0x24, coefs[i][1]);
  276. hwwrite(vortex->mmio, 0x24424 + i * 0x24, coefs[i][2]);
  277. hwwrite(vortex->mmio, 0x24428 + i * 0x24, coefs[i][3]);
  278. hwwrite(vortex->mmio, 0x2442C + i * 0x24, coefs[i][4]);
  279. }
  280. hwwrite(vortex->mmio, 0x24550, arg_0 & 0xffff);
  281. hwwrite(vortex->mmio, 0x24554, arg_4 & 0xffff);
  282. }
  283. static void
  284. vortex_XtalkHw_SetLeftEQStates(vortex_t * vortex,
  285. xtalk_instate_t const arg_0,
  286. xtalk_state_t const coefs)
  287. {
  288. int i;
  289. for (i = 0; i < 5; i++) {
  290. hwwrite(vortex->mmio, 0x24214 + i * 0x24, coefs[i][0]);
  291. hwwrite(vortex->mmio, 0x24218 + i * 0x24, coefs[i][1]);
  292. hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]);
  293. hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]);
  294. }
  295. hwwrite(vortex->mmio, 0x244F8 + i * 0x24, arg_0[0]);
  296. hwwrite(vortex->mmio, 0x244FC + i * 0x24, arg_0[1]);
  297. hwwrite(vortex->mmio, 0x24500 + i * 0x24, arg_0[2]);
  298. hwwrite(vortex->mmio, 0x24504 + i * 0x24, arg_0[3]);
  299. }
  300. static void
  301. vortex_XtalkHw_SetRightEQStates(vortex_t * vortex,
  302. xtalk_instate_t const arg_0,
  303. xtalk_state_t const coefs)
  304. {
  305. int i;
  306. for (i = 0; i < 5; i++) {
  307. hwwrite(vortex->mmio, 0x242C8 + i * 0x24, coefs[i][0]);
  308. hwwrite(vortex->mmio, 0x242CC + i * 0x24, coefs[i][1]);
  309. hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]);
  310. hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]);
  311. }
  312. hwwrite(vortex->mmio, 0x24508 + i * 0x24, arg_0[0]);
  313. hwwrite(vortex->mmio, 0x2450C + i * 0x24, arg_0[1]);
  314. hwwrite(vortex->mmio, 0x24510 + i * 0x24, arg_0[2]);
  315. hwwrite(vortex->mmio, 0x24514 + i * 0x24, arg_0[3]);
  316. }
  317. static void
  318. vortex_XtalkHw_SetLeftXTStates(vortex_t * vortex,
  319. xtalk_instate_t const arg_0,
  320. xtalk_state_t const coefs)
  321. {
  322. int i;
  323. for (i = 0; i < 5; i++) {
  324. hwwrite(vortex->mmio, 0x2437C + i * 0x24, coefs[i][0]);
  325. hwwrite(vortex->mmio, 0x24380 + i * 0x24, coefs[i][1]);
  326. hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]);
  327. hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]);
  328. }
  329. hwwrite(vortex->mmio, 0x24518 + i * 0x24, arg_0[0]);
  330. hwwrite(vortex->mmio, 0x2451C + i * 0x24, arg_0[1]);
  331. hwwrite(vortex->mmio, 0x24520 + i * 0x24, arg_0[2]);
  332. hwwrite(vortex->mmio, 0x24524 + i * 0x24, arg_0[3]);
  333. }
  334. static void
  335. vortex_XtalkHw_SetRightXTStates(vortex_t * vortex,
  336. xtalk_instate_t const arg_0,
  337. xtalk_state_t const coefs)
  338. {
  339. int i;
  340. for (i = 0; i < 5; i++) {
  341. hwwrite(vortex->mmio, 0x24430 + i * 0x24, coefs[i][0]);
  342. hwwrite(vortex->mmio, 0x24434 + i * 0x24, coefs[i][1]);
  343. hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]);
  344. hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]);
  345. }
  346. hwwrite(vortex->mmio, 0x24528 + i * 0x24, arg_0[0]);
  347. hwwrite(vortex->mmio, 0x2452C + i * 0x24, arg_0[1]);
  348. hwwrite(vortex->mmio, 0x24530 + i * 0x24, arg_0[2]);
  349. hwwrite(vortex->mmio, 0x24534 + i * 0x24, arg_0[3]);
  350. }
  351. #if 0
  352. static void
  353. vortex_XtalkHw_GetLeftEQ(vortex_t * vortex, short *arg_0, short *arg_4,
  354. xtalk_coefs_t coefs)
  355. {
  356. int i;
  357. for (i = 0; i < 5; i++) {
  358. coefs[i][0] = hwread(vortex->mmio, 0x24200 + i * 0x24);
  359. coefs[i][1] = hwread(vortex->mmio, 0x24204 + i * 0x24);
  360. coefs[i][2] = hwread(vortex->mmio, 0x24208 + i * 0x24);
  361. coefs[i][3] = hwread(vortex->mmio, 0x2420c + i * 0x24);
  362. coefs[i][4] = hwread(vortex->mmio, 0x24210 + i * 0x24);
  363. }
  364. *arg_0 = hwread(vortex->mmio, 0x24538) & 0xffff;
  365. *arg_4 = hwread(vortex->mmio, 0x2453c) & 0xffff;
  366. }
  367. static void
  368. vortex_XtalkHw_GetRightEQ(vortex_t * vortex, short *arg_0, short *arg_4,
  369. xtalk_coefs_t coefs)
  370. {
  371. int i;
  372. for (i = 0; i < 5; i++) {
  373. coefs[i][0] = hwread(vortex->mmio, 0x242b4 + i * 0x24);
  374. coefs[i][1] = hwread(vortex->mmio, 0x242b8 + i * 0x24);
  375. coefs[i][2] = hwread(vortex->mmio, 0x242bc + i * 0x24);
  376. coefs[i][3] = hwread(vortex->mmio, 0x242c0 + i * 0x24);
  377. coefs[i][4] = hwread(vortex->mmio, 0x242c4 + i * 0x24);
  378. }
  379. *arg_0 = hwread(vortex->mmio, 0x24540) & 0xffff;
  380. *arg_4 = hwread(vortex->mmio, 0x24544) & 0xffff;
  381. }
  382. static void
  383. vortex_XtalkHw_GetLeftXT(vortex_t * vortex, short *arg_0, short *arg_4,
  384. xtalk_coefs_t coefs)
  385. {
  386. int i;
  387. for (i = 0; i < 5; i++) {
  388. coefs[i][0] = hwread(vortex->mmio, 0x24368 + i * 0x24);
  389. coefs[i][1] = hwread(vortex->mmio, 0x2436C + i * 0x24);
  390. coefs[i][2] = hwread(vortex->mmio, 0x24370 + i * 0x24);
  391. coefs[i][3] = hwread(vortex->mmio, 0x24374 + i * 0x24);
  392. coefs[i][4] = hwread(vortex->mmio, 0x24378 + i * 0x24);
  393. }
  394. *arg_0 = hwread(vortex->mmio, 0x24548) & 0xffff;
  395. *arg_4 = hwread(vortex->mmio, 0x2454C) & 0xffff;
  396. }
  397. static void
  398. vortex_XtalkHw_GetRightXT(vortex_t * vortex, short *arg_0, short *arg_4,
  399. xtalk_coefs_t coefs)
  400. {
  401. int i;
  402. for (i = 0; i < 5; i++) {
  403. coefs[i][0] = hwread(vortex->mmio, 0x2441C + i * 0x24);
  404. coefs[i][1] = hwread(vortex->mmio, 0x24420 + i * 0x24);
  405. coefs[i][2] = hwread(vortex->mmio, 0x24424 + i * 0x24);
  406. coefs[i][3] = hwread(vortex->mmio, 0x24428 + i * 0x24);
  407. coefs[i][4] = hwread(vortex->mmio, 0x2442C + i * 0x24);
  408. }
  409. *arg_0 = hwread(vortex->mmio, 0x24550) & 0xffff;
  410. *arg_4 = hwread(vortex->mmio, 0x24554) & 0xffff;
  411. }
  412. static void
  413. vortex_XtalkHw_GetLeftEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
  414. xtalk_state_t coefs)
  415. {
  416. int i;
  417. for (i = 0; i < 5; i++) {
  418. coefs[i][0] = hwread(vortex->mmio, 0x24214 + i * 0x24);
  419. coefs[i][1] = hwread(vortex->mmio, 0x24218 + i * 0x24);
  420. coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24);
  421. coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24);
  422. }
  423. arg_0[0] = hwread(vortex->mmio, 0x244F8 + i * 0x24);
  424. arg_0[1] = hwread(vortex->mmio, 0x244FC + i * 0x24);
  425. arg_0[2] = hwread(vortex->mmio, 0x24500 + i * 0x24);
  426. arg_0[3] = hwread(vortex->mmio, 0x24504 + i * 0x24);
  427. }
  428. static void
  429. vortex_XtalkHw_GetRightEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
  430. xtalk_state_t coefs)
  431. {
  432. int i;
  433. for (i = 0; i < 5; i++) {
  434. coefs[i][0] = hwread(vortex->mmio, 0x242C8 + i * 0x24);
  435. coefs[i][1] = hwread(vortex->mmio, 0x242CC + i * 0x24);
  436. coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24);
  437. coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24);
  438. }
  439. arg_0[0] = hwread(vortex->mmio, 0x24508 + i * 0x24);
  440. arg_0[1] = hwread(vortex->mmio, 0x2450C + i * 0x24);
  441. arg_0[2] = hwread(vortex->mmio, 0x24510 + i * 0x24);
  442. arg_0[3] = hwread(vortex->mmio, 0x24514 + i * 0x24);
  443. }
  444. static void
  445. vortex_XtalkHw_GetLeftXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
  446. xtalk_state_t coefs)
  447. {
  448. int i;
  449. for (i = 0; i < 5; i++) {
  450. coefs[i][0] = hwread(vortex->mmio, 0x2437C + i * 0x24);
  451. coefs[i][1] = hwread(vortex->mmio, 0x24380 + i * 0x24);
  452. coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24);
  453. coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24);
  454. }
  455. arg_0[0] = hwread(vortex->mmio, 0x24518 + i * 0x24);
  456. arg_0[1] = hwread(vortex->mmio, 0x2451C + i * 0x24);
  457. arg_0[2] = hwread(vortex->mmio, 0x24520 + i * 0x24);
  458. arg_0[3] = hwread(vortex->mmio, 0x24524 + i * 0x24);
  459. }
  460. static void
  461. vortex_XtalkHw_GetRightXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
  462. xtalk_state_t coefs)
  463. {
  464. int i;
  465. for (i = 0; i < 5; i++) {
  466. coefs[i][0] = hwread(vortex->mmio, 0x24430 + i * 0x24);
  467. coefs[i][1] = hwread(vortex->mmio, 0x24434 + i * 0x24);
  468. coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24);
  469. coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24);
  470. }
  471. arg_0[0] = hwread(vortex->mmio, 0x24528 + i * 0x24);
  472. arg_0[1] = hwread(vortex->mmio, 0x2452C + i * 0x24);
  473. arg_0[2] = hwread(vortex->mmio, 0x24530 + i * 0x24);
  474. arg_0[3] = hwread(vortex->mmio, 0x24534 + i * 0x24);
  475. }
  476. #endif
  477. /* Gains */
  478. static void
  479. vortex_XtalkHw_SetGains(vortex_t * vortex, xtalk_gains_t const gains)
  480. {
  481. int i;
  482. for (i = 0; i < XTGAINS_SZ; i++) {
  483. hwwrite(vortex->mmio, 0x244D0 + (i * 4), gains[i]);
  484. }
  485. }
  486. static void
  487. vortex_XtalkHw_SetGainsAllChan(vortex_t * vortex)
  488. {
  489. vortex_XtalkHw_SetGains(vortex, asXtalkGainsAllChan);
  490. }
  491. #if 0
  492. static void vortex_XtalkHw_GetGains(vortex_t * vortex, xtalk_gains_t gains)
  493. {
  494. int i;
  495. for (i = 0; i < XTGAINS_SZ; i++)
  496. gains[i] = hwread(vortex->mmio, 0x244D0 + i * 4);
  497. }
  498. #endif
  499. /* Delay parameters */
  500. static void
  501. vortex_XtalkHw_SetDelay(vortex_t * vortex, unsigned short right,
  502. unsigned short left)
  503. {
  504. int esp0 = 0;
  505. esp0 &= 0x1FFFFFFF;
  506. esp0 |= 0xA0000000;
  507. esp0 = (esp0 & 0xffffE0ff) | ((right & 0x1F) << 8);
  508. esp0 = (esp0 & 0xfffc1fff) | ((left & 0x1F) << 0xd);
  509. hwwrite(vortex->mmio, 0x24660, esp0);
  510. }
  511. static void
  512. vortex_XtalkHw_SetLeftDline(vortex_t * vortex, xtalk_dline_t const dline)
  513. {
  514. int i;
  515. for (i = 0; i < 0x20; i++) {
  516. hwwrite(vortex->mmio, 0x24000 + (i << 2), dline[i] & 0xffff);
  517. hwwrite(vortex->mmio, 0x24080 + (i << 2), dline[i] >> 0x10);
  518. }
  519. }
  520. static void
  521. vortex_XtalkHw_SetRightDline(vortex_t * vortex, xtalk_dline_t const dline)
  522. {
  523. int i;
  524. for (i = 0; i < 0x20; i++) {
  525. hwwrite(vortex->mmio, 0x24100 + (i << 2), dline[i] & 0xffff);
  526. hwwrite(vortex->mmio, 0x24180 + (i << 2), dline[i] >> 0x10);
  527. }
  528. }
  529. #if 0
  530. static void
  531. vortex_XtalkHw_GetDelay(vortex_t * vortex, unsigned short *right,
  532. unsigned short *left)
  533. {
  534. int esp0;
  535. esp0 = hwread(vortex->mmio, 0x24660);
  536. *right = (esp0 >> 8) & 0x1f;
  537. *left = (esp0 >> 0xd) & 0x1f;
  538. }
  539. static void vortex_XtalkHw_GetLeftDline(vortex_t * vortex, xtalk_dline_t dline)
  540. {
  541. int i;
  542. for (i = 0; i < 0x20; i++) {
  543. dline[i] =
  544. (hwread(vortex->mmio, 0x24000 + (i << 2)) & 0xffff) |
  545. (hwread(vortex->mmio, 0x24080 + (i << 2)) << 0x10);
  546. }
  547. }
  548. static void vortex_XtalkHw_GetRightDline(vortex_t * vortex, xtalk_dline_t dline)
  549. {
  550. int i;
  551. for (i = 0; i < 0x20; i++) {
  552. dline[i] =
  553. (hwread(vortex->mmio, 0x24100 + (i << 2)) & 0xffff) |
  554. (hwread(vortex->mmio, 0x24180 + (i << 2)) << 0x10);
  555. }
  556. }
  557. #endif
  558. /* Control/Global stuff */
  559. #if 0
  560. static void vortex_XtalkHw_SetControlReg(vortex_t * vortex, unsigned long ctrl)
  561. {
  562. hwwrite(vortex->mmio, 0x24660, ctrl);
  563. }
  564. static void vortex_XtalkHw_GetControlReg(vortex_t * vortex, unsigned long *ctrl)
  565. {
  566. *ctrl = hwread(vortex->mmio, 0x24660);
  567. }
  568. #endif
  569. static void vortex_XtalkHw_SetSampleRate(vortex_t * vortex, int sr)
  570. {
  571. int temp;
  572. temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
  573. temp = (temp & 0xffffff07) | ((sr & 0x1f) << 3);
  574. hwwrite(vortex->mmio, 0x24660, temp);
  575. }
  576. #if 0
  577. static void vortex_XtalkHw_GetSampleRate(vortex_t * vortex, int *sr)
  578. {
  579. *sr = (hwread(vortex->mmio, 0x24660) >> 3) & 0x1f;
  580. }
  581. #endif
  582. static void vortex_XtalkHw_Enable(vortex_t * vortex)
  583. {
  584. int temp;
  585. temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
  586. temp |= 1;
  587. hwwrite(vortex->mmio, 0x24660, temp);
  588. }
  589. static void vortex_XtalkHw_Disable(vortex_t * vortex)
  590. {
  591. int temp;
  592. temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
  593. temp &= 0xfffffffe;
  594. hwwrite(vortex->mmio, 0x24660, temp);
  595. }
  596. static void vortex_XtalkHw_ZeroIO(vortex_t * vortex)
  597. {
  598. int i;
  599. for (i = 0; i < 20; i++)
  600. hwwrite(vortex->mmio, 0x24600 + (i << 2), 0);
  601. for (i = 0; i < 4; i++)
  602. hwwrite(vortex->mmio, 0x24650 + (i << 2), 0);
  603. }
  604. static void vortex_XtalkHw_ZeroState(vortex_t * vortex)
  605. {
  606. vortex_XtalkHw_ZeroIO(vortex); // inlined
  607. vortex_XtalkHw_SetLeftEQ(vortex, 0, 0, asXtalkCoefsZeros);
  608. vortex_XtalkHw_SetRightEQ(vortex, 0, 0, asXtalkCoefsZeros);
  609. vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros);
  610. vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros);
  611. vortex_XtalkHw_SetGains(vortex, asXtalkGainsZeros); // inlined
  612. vortex_XtalkHw_SetDelay(vortex, 0, 0); // inlined
  613. vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros); // inlined
  614. vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros); // inlined
  615. vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros); // inlined
  616. vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros); // inlined
  617. vortex_XtalkHw_SetLeftEQStates(vortex, asXtalkInStateZeros,
  618. asXtalkOutStateZeros);
  619. vortex_XtalkHw_SetRightEQStates(vortex, asXtalkInStateZeros,
  620. asXtalkOutStateZeros);
  621. vortex_XtalkHw_SetLeftXTStates(vortex, asXtalkInStateZeros,
  622. asXtalkOutStateZeros);
  623. vortex_XtalkHw_SetRightXTStates(vortex, asXtalkInStateZeros,
  624. asXtalkOutStateZeros);
  625. }
  626. static void vortex_XtalkHw_ProgramPipe(vortex_t * vortex)
  627. {
  628. vortex_XtalkHw_SetLeftEQ(vortex, 0, 1, asXtalkCoefsPipe);
  629. vortex_XtalkHw_SetRightEQ(vortex, 0, 1, asXtalkCoefsPipe);
  630. vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros);
  631. vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros);
  632. vortex_XtalkHw_SetDelay(vortex, 0, 0); // inlined
  633. }
  634. static void vortex_XtalkHw_ProgramXtalkWide(vortex_t * vortex)
  635. {
  636. vortex_XtalkHw_SetLeftEQ(vortex, sXtalkWideKLeftEq,
  637. sXtalkWideShiftLeftEq, asXtalkWideCoefsLeftEq);
  638. vortex_XtalkHw_SetRightEQ(vortex, sXtalkWideKRightEq,
  639. sXtalkWideShiftRightEq,
  640. asXtalkWideCoefsRightEq);
  641. vortex_XtalkHw_SetLeftXT(vortex, sXtalkWideKLeftXt,
  642. sXtalkWideShiftLeftXt, asXtalkWideCoefsLeftXt);
  643. vortex_XtalkHw_SetRightXT(vortex, sXtalkWideKLeftXt,
  644. sXtalkWideShiftLeftXt,
  645. asXtalkWideCoefsLeftXt);
  646. vortex_XtalkHw_SetDelay(vortex, wXtalkWideRightDelay, wXtalkWideLeftDelay); // inlined
  647. }
  648. static void vortex_XtalkHw_ProgramXtalkNarrow(vortex_t * vortex)
  649. {
  650. vortex_XtalkHw_SetLeftEQ(vortex, sXtalkNarrowKLeftEq,
  651. sXtalkNarrowShiftLeftEq,
  652. asXtalkNarrowCoefsLeftEq);
  653. vortex_XtalkHw_SetRightEQ(vortex, sXtalkNarrowKRightEq,
  654. sXtalkNarrowShiftRightEq,
  655. asXtalkNarrowCoefsRightEq);
  656. vortex_XtalkHw_SetLeftXT(vortex, sXtalkNarrowKLeftXt,
  657. sXtalkNarrowShiftLeftXt,
  658. asXtalkNarrowCoefsLeftXt);
  659. vortex_XtalkHw_SetRightXT(vortex, sXtalkNarrowKLeftXt,
  660. sXtalkNarrowShiftLeftXt,
  661. asXtalkNarrowCoefsLeftXt);
  662. vortex_XtalkHw_SetDelay(vortex, wXtalkNarrowRightDelay, wXtalkNarrowLeftDelay); // inlined
  663. }
  664. static void vortex_XtalkHw_ProgramDiamondXtalk(vortex_t * vortex)
  665. {
  666. //sDiamondKLeftEq,sDiamondKRightXt,asDiamondCoefsLeftEq
  667. vortex_XtalkHw_SetLeftEQ(vortex, sDiamondKLeftEq,
  668. sDiamondShiftLeftEq, asDiamondCoefsLeftEq);
  669. vortex_XtalkHw_SetRightEQ(vortex, sDiamondKRightEq,
  670. sDiamondShiftRightEq, asDiamondCoefsRightEq);
  671. vortex_XtalkHw_SetLeftXT(vortex, sDiamondKLeftXt,
  672. sDiamondShiftLeftXt, asDiamondCoefsLeftXt);
  673. vortex_XtalkHw_SetRightXT(vortex, sDiamondKLeftXt,
  674. sDiamondShiftLeftXt, asDiamondCoefsLeftXt);
  675. vortex_XtalkHw_SetDelay(vortex, wDiamondRightDelay, wDiamondLeftDelay); // inlined
  676. }
  677. static void vortex_XtalkHw_init(vortex_t * vortex)
  678. {
  679. vortex_XtalkHw_ZeroState(vortex);
  680. }
  681. /* End of file */