au88x0_xtalk.c 23 KB

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