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