18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/***************************************************************************
38c2ecf20Sopenharmony_ci *            au88x0_cxtalk.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Wed Nov 19 16:29:47 2003
68c2ecf20Sopenharmony_ci *  Copyright  2003  mjander
78c2ecf20Sopenharmony_ci *  mjander@users.sourceforge.org
88c2ecf20Sopenharmony_ci ****************************************************************************/
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/*
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include "au88x0_xtalk.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/* Data (a whole lot of data.... ) */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic short const sXtalkWideKLeftEq = 0x269C;
188c2ecf20Sopenharmony_cistatic short const sXtalkWideKRightEq = 0x269C;
198c2ecf20Sopenharmony_cistatic short const sXtalkWideKLeftXt = 0xF25E;
208c2ecf20Sopenharmony_cistatic __maybe_unused short const sXtalkWideKRightXt = 0xF25E;
218c2ecf20Sopenharmony_cistatic short const sXtalkWideShiftLeftEq = 1;
228c2ecf20Sopenharmony_cistatic short const sXtalkWideShiftRightEq = 1;
238c2ecf20Sopenharmony_cistatic short const sXtalkWideShiftLeftXt = 0;
248c2ecf20Sopenharmony_cistatic __maybe_unused short const sXtalkWideShiftRightXt = 0;
258c2ecf20Sopenharmony_cistatic unsigned short const wXtalkWideLeftDelay = 0xd;
268c2ecf20Sopenharmony_cistatic unsigned short const wXtalkWideRightDelay = 0xd;
278c2ecf20Sopenharmony_cistatic short const sXtalkNarrowKLeftEq = 0x468D;
288c2ecf20Sopenharmony_cistatic short const sXtalkNarrowKRightEq = 0x468D;
298c2ecf20Sopenharmony_cistatic short const sXtalkNarrowKLeftXt = 0xF82E;
308c2ecf20Sopenharmony_cistatic __maybe_unused short const sXtalkNarrowKRightXt = 0xF82E;
318c2ecf20Sopenharmony_cistatic short const sXtalkNarrowShiftLeftEq = 0x3;
328c2ecf20Sopenharmony_cistatic short const sXtalkNarrowShiftRightEq = 0x3;
338c2ecf20Sopenharmony_cistatic short const sXtalkNarrowShiftLeftXt = 0;
348c2ecf20Sopenharmony_cistatic __maybe_unused short const sXtalkNarrowShiftRightXt = 0;
358c2ecf20Sopenharmony_cistatic unsigned short const wXtalkNarrowLeftDelay = 0x7;
368c2ecf20Sopenharmony_cistatic unsigned short const wXtalkNarrowRightDelay = 0x7;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_gains_t const asXtalkGainsDefault = {
398c2ecf20Sopenharmony_ci	0x4000, 0x4000, 0x4000, 0x4000, 0x4000,
408c2ecf20Sopenharmony_ci	0x4000, 0x4000, 0x4000, 0x4000,	0x4000
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_gains_t const asXtalkGainsTest = {
448c2ecf20Sopenharmony_ci	0x7fff, 0x8000, 0x0000, 0x0000, 0x0001,
458c2ecf20Sopenharmony_ci	0xffff, 0x4000, 0xc000, 0x0002, 0xfffe
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_gains_t const asXtalkGains1Chan = {
498c2ecf20Sopenharmony_ci	0x7FFF, 0, 0, 0, 0,
508c2ecf20Sopenharmony_ci	0x7FFF, 0, 0, 0, 0,
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci// Input gain for 4 A3D slices. One possible input pair is left zero.
548c2ecf20Sopenharmony_cistatic xtalk_gains_t const asXtalkGainsAllChan = {
558c2ecf20Sopenharmony_ci	0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0,
568c2ecf20Sopenharmony_ci	0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,	0
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistatic xtalk_gains_t const asXtalkGainsZeros = {
608c2ecf20Sopenharmony_ci	0, 0, 0, 0, 0, 0, 0, 0, 0, 0
618c2ecf20Sopenharmony_ci};
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cistatic xtalk_dline_t const alXtalkDlineZeros = {
648c2ecf20Sopenharmony_ci	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
658c2ecf20Sopenharmony_ci	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_dline_t const alXtalkDlineTest = {
688c2ecf20Sopenharmony_ci	0x0000fc18, 0xfff03e8, 0x000186a0, 0xfffe7960, 1, 0xffffffff, 0, 0,
698c2ecf20Sopenharmony_ci	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
708c2ecf20Sopenharmony_ci	0, 0, 0, 0, 0, 0, 0, 0
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic xtalk_instate_t const asXtalkInStateZeros = {
748c2ecf20Sopenharmony_ci	0, 0, 0, 0
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_instate_t const asXtalkInStateTest = {
788c2ecf20Sopenharmony_ci	0x0080, 0xff80, 0x0001, 0xffff
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic xtalk_state_t const asXtalkOutStateZeros = {
828c2ecf20Sopenharmony_ci	{0, 0, 0, 0},
838c2ecf20Sopenharmony_ci	{0, 0, 0, 0},
848c2ecf20Sopenharmony_ci	{0, 0, 0, 0},
858c2ecf20Sopenharmony_ci	{0, 0, 0, 0},
868c2ecf20Sopenharmony_ci	{0, 0, 0, 0}
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cistatic short const sDiamondKLeftEq = 0x401d;
908c2ecf20Sopenharmony_cistatic short const sDiamondKRightEq = 0x401d;
918c2ecf20Sopenharmony_cistatic short const sDiamondKLeftXt = 0xF90E;
928c2ecf20Sopenharmony_cistatic __maybe_unused short const sDiamondKRightXt = 0xF90E;
938c2ecf20Sopenharmony_cistatic short const sDiamondShiftLeftEq = 1;
948c2ecf20Sopenharmony_cistatic short const sDiamondShiftRightEq = 1;
958c2ecf20Sopenharmony_cistatic short const sDiamondShiftLeftXt = 0;
968c2ecf20Sopenharmony_cistatic __maybe_unused short const sDiamondShiftRightXt = 0;
978c2ecf20Sopenharmony_cistatic unsigned short const wDiamondLeftDelay = 0xb;
988c2ecf20Sopenharmony_cistatic unsigned short const wDiamondRightDelay = 0xb;
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkWideCoefsLeftEq = {
1018c2ecf20Sopenharmony_ci	{0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
1028c2ecf20Sopenharmony_ci	{0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
1038c2ecf20Sopenharmony_ci	{0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
1048c2ecf20Sopenharmony_ci	{0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
1058c2ecf20Sopenharmony_ci	{0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkWideCoefsRightEq = {
1088c2ecf20Sopenharmony_ci	{0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
1098c2ecf20Sopenharmony_ci	{0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
1108c2ecf20Sopenharmony_ci	{0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
1118c2ecf20Sopenharmony_ci	{0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
1128c2ecf20Sopenharmony_ci	{0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkWideCoefsLeftXt = {
1158c2ecf20Sopenharmony_ci	{0x55c6, 0xc97b, 0x005b, 0x0047, 0},
1168c2ecf20Sopenharmony_ci	{0x6a60, 0xca20, 0xffc6, 0x0040, 0},
1178c2ecf20Sopenharmony_ci	{0x6411, 0xd711, 0xfca1, 0x0190, 0},
1188c2ecf20Sopenharmony_ci	{0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
1198c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1208c2ecf20Sopenharmony_ci};
1218c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_coefs_t const asXtalkWideCoefsRightXt = {
1228c2ecf20Sopenharmony_ci	{0x55c6, 0xc97b, 0x005b, 0x0047, 0},
1238c2ecf20Sopenharmony_ci	{0x6a60, 0xca20, 0xffc6, 0x0040, 0},
1248c2ecf20Sopenharmony_ci	{0x6411, 0xd711, 0xfca1, 0x0190, 0},
1258c2ecf20Sopenharmony_ci	{0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
1268c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = {
1298c2ecf20Sopenharmony_ci	{0x50B5, 0xD07C, 0x026D, 0xFD21, 0},
1308c2ecf20Sopenharmony_ci	{0x460F, 0xE44F, 0xF75E, 0xEFA6, 0},
1318c2ecf20Sopenharmony_ci	{0x556D, 0xDCAB, 0x2098, 0xF0F2, 0},
1328c2ecf20Sopenharmony_ci	{0x7E03, 0xC1F0, 0x007D, 0xFF89, 0},
1338c2ecf20Sopenharmony_ci	{0x383E, 0xFD9D, 0xB278, 0x4547, 0}
1348c2ecf20Sopenharmony_ci};
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkNarrowCoefsRightEq = {
1378c2ecf20Sopenharmony_ci	{0x50B5, 0xD07C, 0x026D, 0xFD21, 0},
1388c2ecf20Sopenharmony_ci	{0x460F, 0xE44F, 0xF75E, 0xEFA6, 0},
1398c2ecf20Sopenharmony_ci	{0x556D, 0xDCAB, 0x2098, 0xF0F2, 0},
1408c2ecf20Sopenharmony_ci	{0x7E03, 0xC1F0, 0x007D, 0xFF89, 0},
1418c2ecf20Sopenharmony_ci	{0x383E, 0xFD9D, 0xB278, 0x4547, 0}
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkNarrowCoefsLeftXt = {
1458c2ecf20Sopenharmony_ci	{0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0},
1468c2ecf20Sopenharmony_ci	{0x6777, 0xC915, 0xFEAF, 0x00B1, 0},
1478c2ecf20Sopenharmony_ci	{0x7762, 0xC7D9, 0x025B, 0xFDA6, 0},
1488c2ecf20Sopenharmony_ci	{0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0},
1498c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_coefs_t const asXtalkNarrowCoefsRightXt = {
1538c2ecf20Sopenharmony_ci	{0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0},
1548c2ecf20Sopenharmony_ci	{0x6777, 0xC915, 0xFEAF, 0x00B1, 0},
1558c2ecf20Sopenharmony_ci	{0x7762, 0xC7D9, 0x025B, 0xFDA6, 0},
1568c2ecf20Sopenharmony_ci	{0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0},
1578c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1588c2ecf20Sopenharmony_ci};
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkCoefsZeros = {
1618c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1628c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1638c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1648c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1658c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asXtalkCoefsPipe = {
1698c2ecf20Sopenharmony_ci	{0, 0, 0x0FA0, 0, 0},
1708c2ecf20Sopenharmony_ci	{0, 0, 0x0FA0, 0, 0},
1718c2ecf20Sopenharmony_ci	{0, 0, 0x0FA0, 0, 0},
1728c2ecf20Sopenharmony_ci	{0, 0, 0x0FA0, 0, 0},
1738c2ecf20Sopenharmony_ci	{0, 0, 0x1180, 0, 0},
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_coefs_t const asXtalkCoefsNegPipe = {
1768c2ecf20Sopenharmony_ci	{0, 0, 0xF380, 0, 0},
1778c2ecf20Sopenharmony_ci	{0, 0, 0xF380, 0, 0},
1788c2ecf20Sopenharmony_ci	{0, 0, 0xF380, 0, 0},
1798c2ecf20Sopenharmony_ci	{0, 0, 0xF380, 0, 0},
1808c2ecf20Sopenharmony_ci	{0, 0, 0xF200, 0, 0}
1818c2ecf20Sopenharmony_ci};
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_coefs_t const asXtalkCoefsNumTest = {
1848c2ecf20Sopenharmony_ci	{0, 0, 0xF380, 0x8000, 0x6D60},
1858c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1868c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1878c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1888c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_coefs_t const asXtalkCoefsDenTest = {
1928c2ecf20Sopenharmony_ci	{0xC000, 0x2000, 0x4000, 0, 0},
1938c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1948c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1958c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
1968c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_state_t const asXtalkOutStateTest = {
2008c2ecf20Sopenharmony_ci	{0x7FFF, 0x0004, 0xFFFC, 0},
2018c2ecf20Sopenharmony_ci	{0xFE00, 0x0008, 0xFFF8, 0x4000},
2028c2ecf20Sopenharmony_ci	{0x0200, 0x0010, 0xFFF0, 0xC000},
2038c2ecf20Sopenharmony_ci	{0x8000, 0x0020, 0xFFE0, 0},
2048c2ecf20Sopenharmony_ci	{0, 0, 0, 0}
2058c2ecf20Sopenharmony_ci};
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asDiamondCoefsLeftEq = {
2088c2ecf20Sopenharmony_ci	{0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0},
2098c2ecf20Sopenharmony_ci	{0x45E2, 0xCA51, 0x0448, 0xFCE7, 0},
2108c2ecf20Sopenharmony_ci	{0xA93E, 0xDBD5, 0x022C, 0x028A, 0},
2118c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
2128c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
2138c2ecf20Sopenharmony_ci};
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asDiamondCoefsRightEq = {
2168c2ecf20Sopenharmony_ci	{0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0},
2178c2ecf20Sopenharmony_ci	{0x45E2, 0xCA51, 0x0448, 0xFCE7, 0},
2188c2ecf20Sopenharmony_ci	{0xA93E, 0xDBD5, 0x022C, 0x028A, 0},
2198c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
2208c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistatic xtalk_coefs_t const asDiamondCoefsLeftXt = {
2248c2ecf20Sopenharmony_ci	{0x3B50, 0xFE08, 0xF959, 0x0060, 0},
2258c2ecf20Sopenharmony_ci	{0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0},
2268c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
2278c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
2288c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
2298c2ecf20Sopenharmony_ci};
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_cistatic __maybe_unused xtalk_coefs_t const asDiamondCoefsRightXt = {
2328c2ecf20Sopenharmony_ci	{0x3B50, 0xFE08, 0xF959, 0x0060, 0},
2338c2ecf20Sopenharmony_ci	{0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0},
2348c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
2358c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0},
2368c2ecf20Sopenharmony_ci	{0, 0, 0, 0, 0}
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci /**/
2408c2ecf20Sopenharmony_ci/* XTalk EQ and XT */
2418c2ecf20Sopenharmony_cistatic void
2428c2ecf20Sopenharmony_civortex_XtalkHw_SetLeftEQ(vortex_t * vortex, short arg_0, short arg_4,
2438c2ecf20Sopenharmony_ci			 xtalk_coefs_t const coefs)
2448c2ecf20Sopenharmony_ci{
2458c2ecf20Sopenharmony_ci	int i;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
2488c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24200 + i * 0x24, coefs[i][0]);
2498c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24204 + i * 0x24, coefs[i][1]);
2508c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24208 + i * 0x24, coefs[i][2]);
2518c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2420c + i * 0x24, coefs[i][3]);
2528c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24210 + i * 0x24, coefs[i][4]);
2538c2ecf20Sopenharmony_ci	}
2548c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24538, arg_0 & 0xffff);
2558c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x2453C, arg_4 & 0xffff);
2568c2ecf20Sopenharmony_ci}
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistatic void
2598c2ecf20Sopenharmony_civortex_XtalkHw_SetRightEQ(vortex_t * vortex, short arg_0, short arg_4,
2608c2ecf20Sopenharmony_ci			  xtalk_coefs_t const coefs)
2618c2ecf20Sopenharmony_ci{
2628c2ecf20Sopenharmony_ci	int i;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
2658c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242b4 + i * 0x24, coefs[i][0]);
2668c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242b8 + i * 0x24, coefs[i][1]);
2678c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242bc + i * 0x24, coefs[i][2]);
2688c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242c0 + i * 0x24, coefs[i][3]);
2698c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242c4 + i * 0x24, coefs[i][4]);
2708c2ecf20Sopenharmony_ci	}
2718c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24540, arg_0 & 0xffff);
2728c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24544, arg_4 & 0xffff);
2738c2ecf20Sopenharmony_ci}
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_cistatic void
2768c2ecf20Sopenharmony_civortex_XtalkHw_SetLeftXT(vortex_t * vortex, short arg_0, short arg_4,
2778c2ecf20Sopenharmony_ci			 xtalk_coefs_t const coefs)
2788c2ecf20Sopenharmony_ci{
2798c2ecf20Sopenharmony_ci	int i;
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
2828c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24368 + i * 0x24, coefs[i][0]);
2838c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2436c + i * 0x24, coefs[i][1]);
2848c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24370 + i * 0x24, coefs[i][2]);
2858c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24374 + i * 0x24, coefs[i][3]);
2868c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24378 + i * 0x24, coefs[i][4]);
2878c2ecf20Sopenharmony_ci	}
2888c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24548, arg_0 & 0xffff);
2898c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x2454C, arg_4 & 0xffff);
2908c2ecf20Sopenharmony_ci}
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic void
2938c2ecf20Sopenharmony_civortex_XtalkHw_SetRightXT(vortex_t * vortex, short arg_0, short arg_4,
2948c2ecf20Sopenharmony_ci			  xtalk_coefs_t const coefs)
2958c2ecf20Sopenharmony_ci{
2968c2ecf20Sopenharmony_ci	int i;
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
2998c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2441C + i * 0x24, coefs[i][0]);
3008c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24420 + i * 0x24, coefs[i][1]);
3018c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24424 + i * 0x24, coefs[i][2]);
3028c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24428 + i * 0x24, coefs[i][3]);
3038c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2442C + i * 0x24, coefs[i][4]);
3048c2ecf20Sopenharmony_ci	}
3058c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24550, arg_0 & 0xffff);
3068c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24554, arg_4 & 0xffff);
3078c2ecf20Sopenharmony_ci}
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_cistatic void
3108c2ecf20Sopenharmony_civortex_XtalkHw_SetLeftEQStates(vortex_t * vortex,
3118c2ecf20Sopenharmony_ci			       xtalk_instate_t const arg_0,
3128c2ecf20Sopenharmony_ci			       xtalk_state_t const coefs)
3138c2ecf20Sopenharmony_ci{
3148c2ecf20Sopenharmony_ci	int i;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
3178c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24214 + i * 0x24, coefs[i][0]);
3188c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24218 + i * 0x24, coefs[i][1]);
3198c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]);
3208c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]);
3218c2ecf20Sopenharmony_ci	}
3228c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x244F8, arg_0[0]);
3238c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x244FC, arg_0[1]);
3248c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24500, arg_0[2]);
3258c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24504, arg_0[3]);
3268c2ecf20Sopenharmony_ci}
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistatic void
3298c2ecf20Sopenharmony_civortex_XtalkHw_SetRightEQStates(vortex_t * vortex,
3308c2ecf20Sopenharmony_ci				xtalk_instate_t const arg_0,
3318c2ecf20Sopenharmony_ci				xtalk_state_t const coefs)
3328c2ecf20Sopenharmony_ci{
3338c2ecf20Sopenharmony_ci	int i;
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
3368c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242C8 + i * 0x24, coefs[i][0]);
3378c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242CC + i * 0x24, coefs[i][1]);
3388c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]);
3398c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]);
3408c2ecf20Sopenharmony_ci	}
3418c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24508, arg_0[0]);
3428c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x2450C, arg_0[1]);
3438c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24510, arg_0[2]);
3448c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24514, arg_0[3]);
3458c2ecf20Sopenharmony_ci}
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_cistatic void
3488c2ecf20Sopenharmony_civortex_XtalkHw_SetLeftXTStates(vortex_t * vortex,
3498c2ecf20Sopenharmony_ci			       xtalk_instate_t const arg_0,
3508c2ecf20Sopenharmony_ci			       xtalk_state_t const coefs)
3518c2ecf20Sopenharmony_ci{
3528c2ecf20Sopenharmony_ci	int i;
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
3558c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2437C + i * 0x24, coefs[i][0]);
3568c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24380 + i * 0x24, coefs[i][1]);
3578c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]);
3588c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]);
3598c2ecf20Sopenharmony_ci	}
3608c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24518, arg_0[0]);
3618c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x2451C, arg_0[1]);
3628c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24520, arg_0[2]);
3638c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24524, arg_0[3]);
3648c2ecf20Sopenharmony_ci}
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_cistatic void
3678c2ecf20Sopenharmony_civortex_XtalkHw_SetRightXTStates(vortex_t * vortex,
3688c2ecf20Sopenharmony_ci				xtalk_instate_t const arg_0,
3698c2ecf20Sopenharmony_ci				xtalk_state_t const coefs)
3708c2ecf20Sopenharmony_ci{
3718c2ecf20Sopenharmony_ci	int i;
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
3748c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24430 + i * 0x24, coefs[i][0]);
3758c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24434 + i * 0x24, coefs[i][1]);
3768c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]);
3778c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]);
3788c2ecf20Sopenharmony_ci	}
3798c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24528, arg_0[0]);
3808c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x2452C, arg_0[1]);
3818c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24530, arg_0[2]);
3828c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24534, arg_0[3]);
3838c2ecf20Sopenharmony_ci}
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci#if 0
3868c2ecf20Sopenharmony_cistatic void
3878c2ecf20Sopenharmony_civortex_XtalkHw_GetLeftEQ(vortex_t * vortex, short *arg_0, short *arg_4,
3888c2ecf20Sopenharmony_ci			 xtalk_coefs_t coefs)
3898c2ecf20Sopenharmony_ci{
3908c2ecf20Sopenharmony_ci	int i;
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
3938c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x24200 + i * 0x24);
3948c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x24204 + i * 0x24);
3958c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x24208 + i * 0x24);
3968c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x2420c + i * 0x24);
3978c2ecf20Sopenharmony_ci		coefs[i][4] = hwread(vortex->mmio, 0x24210 + i * 0x24);
3988c2ecf20Sopenharmony_ci	}
3998c2ecf20Sopenharmony_ci	*arg_0 = hwread(vortex->mmio, 0x24538) & 0xffff;
4008c2ecf20Sopenharmony_ci	*arg_4 = hwread(vortex->mmio, 0x2453c) & 0xffff;
4018c2ecf20Sopenharmony_ci}
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistatic void
4048c2ecf20Sopenharmony_civortex_XtalkHw_GetRightEQ(vortex_t * vortex, short *arg_0, short *arg_4,
4058c2ecf20Sopenharmony_ci			  xtalk_coefs_t coefs)
4068c2ecf20Sopenharmony_ci{
4078c2ecf20Sopenharmony_ci	int i;
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
4108c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x242b4 + i * 0x24);
4118c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x242b8 + i * 0x24);
4128c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x242bc + i * 0x24);
4138c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x242c0 + i * 0x24);
4148c2ecf20Sopenharmony_ci		coefs[i][4] = hwread(vortex->mmio, 0x242c4 + i * 0x24);
4158c2ecf20Sopenharmony_ci	}
4168c2ecf20Sopenharmony_ci	*arg_0 = hwread(vortex->mmio, 0x24540) & 0xffff;
4178c2ecf20Sopenharmony_ci	*arg_4 = hwread(vortex->mmio, 0x24544) & 0xffff;
4188c2ecf20Sopenharmony_ci}
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cistatic void
4218c2ecf20Sopenharmony_civortex_XtalkHw_GetLeftXT(vortex_t * vortex, short *arg_0, short *arg_4,
4228c2ecf20Sopenharmony_ci			 xtalk_coefs_t coefs)
4238c2ecf20Sopenharmony_ci{
4248c2ecf20Sopenharmony_ci	int i;
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
4278c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x24368 + i * 0x24);
4288c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x2436C + i * 0x24);
4298c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x24370 + i * 0x24);
4308c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x24374 + i * 0x24);
4318c2ecf20Sopenharmony_ci		coefs[i][4] = hwread(vortex->mmio, 0x24378 + i * 0x24);
4328c2ecf20Sopenharmony_ci	}
4338c2ecf20Sopenharmony_ci	*arg_0 = hwread(vortex->mmio, 0x24548) & 0xffff;
4348c2ecf20Sopenharmony_ci	*arg_4 = hwread(vortex->mmio, 0x2454C) & 0xffff;
4358c2ecf20Sopenharmony_ci}
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_cistatic void
4388c2ecf20Sopenharmony_civortex_XtalkHw_GetRightXT(vortex_t * vortex, short *arg_0, short *arg_4,
4398c2ecf20Sopenharmony_ci			  xtalk_coefs_t coefs)
4408c2ecf20Sopenharmony_ci{
4418c2ecf20Sopenharmony_ci	int i;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
4448c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x2441C + i * 0x24);
4458c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x24420 + i * 0x24);
4468c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x24424 + i * 0x24);
4478c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x24428 + i * 0x24);
4488c2ecf20Sopenharmony_ci		coefs[i][4] = hwread(vortex->mmio, 0x2442C + i * 0x24);
4498c2ecf20Sopenharmony_ci	}
4508c2ecf20Sopenharmony_ci	*arg_0 = hwread(vortex->mmio, 0x24550) & 0xffff;
4518c2ecf20Sopenharmony_ci	*arg_4 = hwread(vortex->mmio, 0x24554) & 0xffff;
4528c2ecf20Sopenharmony_ci}
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistatic void
4558c2ecf20Sopenharmony_civortex_XtalkHw_GetLeftEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
4568c2ecf20Sopenharmony_ci			       xtalk_state_t coefs)
4578c2ecf20Sopenharmony_ci{
4588c2ecf20Sopenharmony_ci	int i;
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
4618c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x24214 + i * 0x24);
4628c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x24218 + i * 0x24);
4638c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24);
4648c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24);
4658c2ecf20Sopenharmony_ci	}
4668c2ecf20Sopenharmony_ci	arg_0[0] = hwread(vortex->mmio, 0x244F8);
4678c2ecf20Sopenharmony_ci	arg_0[1] = hwread(vortex->mmio, 0x244FC);
4688c2ecf20Sopenharmony_ci	arg_0[2] = hwread(vortex->mmio, 0x24500);
4698c2ecf20Sopenharmony_ci	arg_0[3] = hwread(vortex->mmio, 0x24504);
4708c2ecf20Sopenharmony_ci}
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_cistatic void
4738c2ecf20Sopenharmony_civortex_XtalkHw_GetRightEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
4748c2ecf20Sopenharmony_ci				xtalk_state_t coefs)
4758c2ecf20Sopenharmony_ci{
4768c2ecf20Sopenharmony_ci	int i;
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
4798c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x242C8 + i * 0x24);
4808c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x242CC + i * 0x24);
4818c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24);
4828c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24);
4838c2ecf20Sopenharmony_ci	}
4848c2ecf20Sopenharmony_ci	arg_0[0] = hwread(vortex->mmio, 0x24508);
4858c2ecf20Sopenharmony_ci	arg_0[1] = hwread(vortex->mmio, 0x2450C);
4868c2ecf20Sopenharmony_ci	arg_0[2] = hwread(vortex->mmio, 0x24510);
4878c2ecf20Sopenharmony_ci	arg_0[3] = hwread(vortex->mmio, 0x24514);
4888c2ecf20Sopenharmony_ci}
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_cistatic void
4918c2ecf20Sopenharmony_civortex_XtalkHw_GetLeftXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
4928c2ecf20Sopenharmony_ci			       xtalk_state_t coefs)
4938c2ecf20Sopenharmony_ci{
4948c2ecf20Sopenharmony_ci	int i;
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
4978c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x2437C + i * 0x24);
4988c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x24380 + i * 0x24);
4998c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24);
5008c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24);
5018c2ecf20Sopenharmony_ci	}
5028c2ecf20Sopenharmony_ci	arg_0[0] = hwread(vortex->mmio, 0x24518);
5038c2ecf20Sopenharmony_ci	arg_0[1] = hwread(vortex->mmio, 0x2451C);
5048c2ecf20Sopenharmony_ci	arg_0[2] = hwread(vortex->mmio, 0x24520);
5058c2ecf20Sopenharmony_ci	arg_0[3] = hwread(vortex->mmio, 0x24524);
5068c2ecf20Sopenharmony_ci}
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_cistatic void
5098c2ecf20Sopenharmony_civortex_XtalkHw_GetRightXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
5108c2ecf20Sopenharmony_ci				xtalk_state_t coefs)
5118c2ecf20Sopenharmony_ci{
5128c2ecf20Sopenharmony_ci	int i;
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
5158c2ecf20Sopenharmony_ci		coefs[i][0] = hwread(vortex->mmio, 0x24430 + i * 0x24);
5168c2ecf20Sopenharmony_ci		coefs[i][1] = hwread(vortex->mmio, 0x24434 + i * 0x24);
5178c2ecf20Sopenharmony_ci		coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24);
5188c2ecf20Sopenharmony_ci		coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24);
5198c2ecf20Sopenharmony_ci	}
5208c2ecf20Sopenharmony_ci	arg_0[0] = hwread(vortex->mmio, 0x24528);
5218c2ecf20Sopenharmony_ci	arg_0[1] = hwread(vortex->mmio, 0x2452C);
5228c2ecf20Sopenharmony_ci	arg_0[2] = hwread(vortex->mmio, 0x24530);
5238c2ecf20Sopenharmony_ci	arg_0[3] = hwread(vortex->mmio, 0x24534);
5248c2ecf20Sopenharmony_ci}
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci#endif
5278c2ecf20Sopenharmony_ci/* Gains */
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_cistatic void
5308c2ecf20Sopenharmony_civortex_XtalkHw_SetGains(vortex_t * vortex, xtalk_gains_t const gains)
5318c2ecf20Sopenharmony_ci{
5328c2ecf20Sopenharmony_ci	int i;
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_ci	for (i = 0; i < XTGAINS_SZ; i++) {
5358c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x244D0 + (i * 4), gains[i]);
5368c2ecf20Sopenharmony_ci	}
5378c2ecf20Sopenharmony_ci}
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_cistatic void
5408c2ecf20Sopenharmony_civortex_XtalkHw_SetGainsAllChan(vortex_t * vortex)
5418c2ecf20Sopenharmony_ci{
5428c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetGains(vortex, asXtalkGainsAllChan);
5438c2ecf20Sopenharmony_ci}
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci#if 0
5468c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_GetGains(vortex_t * vortex, xtalk_gains_t gains)
5478c2ecf20Sopenharmony_ci{
5488c2ecf20Sopenharmony_ci	int i;
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ci	for (i = 0; i < XTGAINS_SZ; i++)
5518c2ecf20Sopenharmony_ci		gains[i] = hwread(vortex->mmio, 0x244D0 + i * 4);
5528c2ecf20Sopenharmony_ci}
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_ci#endif
5558c2ecf20Sopenharmony_ci/* Delay parameters */
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_cistatic void
5588c2ecf20Sopenharmony_civortex_XtalkHw_SetDelay(vortex_t * vortex, unsigned short right,
5598c2ecf20Sopenharmony_ci			unsigned short left)
5608c2ecf20Sopenharmony_ci{
5618c2ecf20Sopenharmony_ci	u32 esp0 = 0;
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	esp0 &= 0x1FFFFFFF;
5648c2ecf20Sopenharmony_ci	esp0 |= 0xA0000000;
5658c2ecf20Sopenharmony_ci	esp0 = (esp0 & 0xffffE0ff) | ((right & 0x1F) << 8);
5668c2ecf20Sopenharmony_ci	esp0 = (esp0 & 0xfffc1fff) | ((left & 0x1F) << 0xd);
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24660, esp0);
5698c2ecf20Sopenharmony_ci}
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_cistatic void
5728c2ecf20Sopenharmony_civortex_XtalkHw_SetLeftDline(vortex_t * vortex, xtalk_dline_t const dline)
5738c2ecf20Sopenharmony_ci{
5748c2ecf20Sopenharmony_ci	int i;
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci	for (i = 0; i < 0x20; i++) {
5778c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24000 + (i << 2), dline[i] & 0xffff);
5788c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24080 + (i << 2), dline[i] >> 0x10);
5798c2ecf20Sopenharmony_ci	}
5808c2ecf20Sopenharmony_ci}
5818c2ecf20Sopenharmony_ci
5828c2ecf20Sopenharmony_cistatic void
5838c2ecf20Sopenharmony_civortex_XtalkHw_SetRightDline(vortex_t * vortex, xtalk_dline_t const dline)
5848c2ecf20Sopenharmony_ci{
5858c2ecf20Sopenharmony_ci	int i;
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci	for (i = 0; i < 0x20; i++) {
5888c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24100 + (i << 2), dline[i] & 0xffff);
5898c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24180 + (i << 2), dline[i] >> 0x10);
5908c2ecf20Sopenharmony_ci	}
5918c2ecf20Sopenharmony_ci}
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci#if 0
5948c2ecf20Sopenharmony_cistatic void
5958c2ecf20Sopenharmony_civortex_XtalkHw_GetDelay(vortex_t * vortex, unsigned short *right,
5968c2ecf20Sopenharmony_ci			unsigned short *left)
5978c2ecf20Sopenharmony_ci{
5988c2ecf20Sopenharmony_ci	int esp0;
5998c2ecf20Sopenharmony_ci
6008c2ecf20Sopenharmony_ci	esp0 = hwread(vortex->mmio, 0x24660);
6018c2ecf20Sopenharmony_ci	*right = (esp0 >> 8) & 0x1f;
6028c2ecf20Sopenharmony_ci	*left = (esp0 >> 0xd) & 0x1f;
6038c2ecf20Sopenharmony_ci}
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_GetLeftDline(vortex_t * vortex, xtalk_dline_t dline)
6068c2ecf20Sopenharmony_ci{
6078c2ecf20Sopenharmony_ci	int i;
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci	for (i = 0; i < 0x20; i++) {
6108c2ecf20Sopenharmony_ci		dline[i] =
6118c2ecf20Sopenharmony_ci		    (hwread(vortex->mmio, 0x24000 + (i << 2)) & 0xffff) |
6128c2ecf20Sopenharmony_ci		    (hwread(vortex->mmio, 0x24080 + (i << 2)) << 0x10);
6138c2ecf20Sopenharmony_ci	}
6148c2ecf20Sopenharmony_ci}
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_GetRightDline(vortex_t * vortex, xtalk_dline_t dline)
6178c2ecf20Sopenharmony_ci{
6188c2ecf20Sopenharmony_ci	int i;
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci	for (i = 0; i < 0x20; i++) {
6218c2ecf20Sopenharmony_ci		dline[i] =
6228c2ecf20Sopenharmony_ci		    (hwread(vortex->mmio, 0x24100 + (i << 2)) & 0xffff) |
6238c2ecf20Sopenharmony_ci		    (hwread(vortex->mmio, 0x24180 + (i << 2)) << 0x10);
6248c2ecf20Sopenharmony_ci	}
6258c2ecf20Sopenharmony_ci}
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_ci#endif
6288c2ecf20Sopenharmony_ci/* Control/Global stuff */
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci#if 0
6318c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_SetControlReg(vortex_t * vortex, u32 ctrl)
6328c2ecf20Sopenharmony_ci{
6338c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24660, ctrl);
6348c2ecf20Sopenharmony_ci}
6358c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_GetControlReg(vortex_t * vortex, u32 *ctrl)
6368c2ecf20Sopenharmony_ci{
6378c2ecf20Sopenharmony_ci	*ctrl = hwread(vortex->mmio, 0x24660);
6388c2ecf20Sopenharmony_ci}
6398c2ecf20Sopenharmony_ci#endif
6408c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_SetSampleRate(vortex_t * vortex, u32 sr)
6418c2ecf20Sopenharmony_ci{
6428c2ecf20Sopenharmony_ci	u32 temp;
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_ci	temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
6458c2ecf20Sopenharmony_ci	temp = (temp & 0xffffff07) | ((sr & 0x1f) << 3);
6468c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24660, temp);
6478c2ecf20Sopenharmony_ci}
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci#if 0
6508c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_GetSampleRate(vortex_t * vortex, u32 *sr)
6518c2ecf20Sopenharmony_ci{
6528c2ecf20Sopenharmony_ci	*sr = (hwread(vortex->mmio, 0x24660) >> 3) & 0x1f;
6538c2ecf20Sopenharmony_ci}
6548c2ecf20Sopenharmony_ci
6558c2ecf20Sopenharmony_ci#endif
6568c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_Enable(vortex_t * vortex)
6578c2ecf20Sopenharmony_ci{
6588c2ecf20Sopenharmony_ci	u32 temp;
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci	temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
6618c2ecf20Sopenharmony_ci	temp |= 1;
6628c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24660, temp);
6638c2ecf20Sopenharmony_ci
6648c2ecf20Sopenharmony_ci}
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_Disable(vortex_t * vortex)
6678c2ecf20Sopenharmony_ci{
6688c2ecf20Sopenharmony_ci	u32 temp;
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci	temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
6718c2ecf20Sopenharmony_ci	temp &= 0xfffffffe;
6728c2ecf20Sopenharmony_ci	hwwrite(vortex->mmio, 0x24660, temp);
6738c2ecf20Sopenharmony_ci
6748c2ecf20Sopenharmony_ci}
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_ZeroIO(vortex_t * vortex)
6778c2ecf20Sopenharmony_ci{
6788c2ecf20Sopenharmony_ci	int i;
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci	for (i = 0; i < 20; i++)
6818c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24600 + (i << 2), 0);
6828c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++)
6838c2ecf20Sopenharmony_ci		hwwrite(vortex->mmio, 0x24650 + (i << 2), 0);
6848c2ecf20Sopenharmony_ci}
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_ZeroState(vortex_t * vortex)
6878c2ecf20Sopenharmony_ci{
6888c2ecf20Sopenharmony_ci	vortex_XtalkHw_ZeroIO(vortex);	// inlined
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftEQ(vortex, 0, 0, asXtalkCoefsZeros);
6918c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightEQ(vortex, 0, 0, asXtalkCoefsZeros);
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros);
6948c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros);
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetGains(vortex, asXtalkGainsZeros);	// inlined
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetDelay(vortex, 0, 0);	// inlined
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros);	// inlined
7018c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros);	// inlined
7028c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros);	// inlined
7038c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros);	// inlined
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftEQStates(vortex, asXtalkInStateZeros,
7068c2ecf20Sopenharmony_ci				       asXtalkOutStateZeros);
7078c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightEQStates(vortex, asXtalkInStateZeros,
7088c2ecf20Sopenharmony_ci					asXtalkOutStateZeros);
7098c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftXTStates(vortex, asXtalkInStateZeros,
7108c2ecf20Sopenharmony_ci				       asXtalkOutStateZeros);
7118c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightXTStates(vortex, asXtalkInStateZeros,
7128c2ecf20Sopenharmony_ci					asXtalkOutStateZeros);
7138c2ecf20Sopenharmony_ci}
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_ProgramPipe(vortex_t * vortex)
7168c2ecf20Sopenharmony_ci{
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftEQ(vortex, 0, 1, asXtalkCoefsPipe);
7198c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightEQ(vortex, 0, 1, asXtalkCoefsPipe);
7208c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros);
7218c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros);
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetDelay(vortex, 0, 0);	// inlined
7248c2ecf20Sopenharmony_ci}
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_ProgramXtalkWide(vortex_t * vortex)
7278c2ecf20Sopenharmony_ci{
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftEQ(vortex, sXtalkWideKLeftEq,
7308c2ecf20Sopenharmony_ci				 sXtalkWideShiftLeftEq, asXtalkWideCoefsLeftEq);
7318c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightEQ(vortex, sXtalkWideKRightEq,
7328c2ecf20Sopenharmony_ci				  sXtalkWideShiftRightEq,
7338c2ecf20Sopenharmony_ci				  asXtalkWideCoefsRightEq);
7348c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftXT(vortex, sXtalkWideKLeftXt,
7358c2ecf20Sopenharmony_ci				 sXtalkWideShiftLeftXt, asXtalkWideCoefsLeftXt);
7368c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightXT(vortex, sXtalkWideKLeftXt,
7378c2ecf20Sopenharmony_ci				  sXtalkWideShiftLeftXt,
7388c2ecf20Sopenharmony_ci				  asXtalkWideCoefsLeftXt);
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetDelay(vortex, wXtalkWideRightDelay, wXtalkWideLeftDelay);	// inlined
7418c2ecf20Sopenharmony_ci}
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_ProgramXtalkNarrow(vortex_t * vortex)
7448c2ecf20Sopenharmony_ci{
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftEQ(vortex, sXtalkNarrowKLeftEq,
7478c2ecf20Sopenharmony_ci				 sXtalkNarrowShiftLeftEq,
7488c2ecf20Sopenharmony_ci				 asXtalkNarrowCoefsLeftEq);
7498c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightEQ(vortex, sXtalkNarrowKRightEq,
7508c2ecf20Sopenharmony_ci				  sXtalkNarrowShiftRightEq,
7518c2ecf20Sopenharmony_ci				  asXtalkNarrowCoefsRightEq);
7528c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftXT(vortex, sXtalkNarrowKLeftXt,
7538c2ecf20Sopenharmony_ci				 sXtalkNarrowShiftLeftXt,
7548c2ecf20Sopenharmony_ci				 asXtalkNarrowCoefsLeftXt);
7558c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightXT(vortex, sXtalkNarrowKLeftXt,
7568c2ecf20Sopenharmony_ci				  sXtalkNarrowShiftLeftXt,
7578c2ecf20Sopenharmony_ci				  asXtalkNarrowCoefsLeftXt);
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetDelay(vortex, wXtalkNarrowRightDelay, wXtalkNarrowLeftDelay);	// inlined
7608c2ecf20Sopenharmony_ci}
7618c2ecf20Sopenharmony_ci
7628c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_ProgramDiamondXtalk(vortex_t * vortex)
7638c2ecf20Sopenharmony_ci{
7648c2ecf20Sopenharmony_ci
7658c2ecf20Sopenharmony_ci	//sDiamondKLeftEq,sDiamondKRightXt,asDiamondCoefsLeftEq
7668c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftEQ(vortex, sDiamondKLeftEq,
7678c2ecf20Sopenharmony_ci				 sDiamondShiftLeftEq, asDiamondCoefsLeftEq);
7688c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightEQ(vortex, sDiamondKRightEq,
7698c2ecf20Sopenharmony_ci				  sDiamondShiftRightEq, asDiamondCoefsRightEq);
7708c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetLeftXT(vortex, sDiamondKLeftXt,
7718c2ecf20Sopenharmony_ci				 sDiamondShiftLeftXt, asDiamondCoefsLeftXt);
7728c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetRightXT(vortex, sDiamondKLeftXt,
7738c2ecf20Sopenharmony_ci				  sDiamondShiftLeftXt, asDiamondCoefsLeftXt);
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ci	vortex_XtalkHw_SetDelay(vortex, wDiamondRightDelay, wDiamondLeftDelay);	// inlined
7768c2ecf20Sopenharmony_ci}
7778c2ecf20Sopenharmony_ci
7788c2ecf20Sopenharmony_cistatic void vortex_XtalkHw_init(vortex_t * vortex)
7798c2ecf20Sopenharmony_ci{
7808c2ecf20Sopenharmony_ci	vortex_XtalkHw_ZeroState(vortex);
7818c2ecf20Sopenharmony_ci}
7828c2ecf20Sopenharmony_ci
7838c2ecf20Sopenharmony_ci/* End of file */
784