au88x0_xtalk.c 22 KB

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