blob: b278e285fd401103efdae0d9e24d67bb50f5ad84 [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 = {
Raymond Yau76474da2012-01-04 16:16:26 +080051 0x4000, 0x4000, 0x4000, 0x4000, 0x4000,
52 0x4000, 0x4000, 0x4000, 0x4000, 0x4000
Linus Torvalds1da177e2005-04-16 15:20:36 -070053};
54
55static xtalk_gains_t const asXtalkGainsTest = {
Raymond Yau76474da2012-01-04 16:16:26 +080056 0x7fff, 0x8000, 0x0000, 0x0000, 0x0001,
57 0xffff, 0x4000, 0xc000, 0x0002, 0xfffe
Linus Torvalds1da177e2005-04-16 15:20:36 -070058};
Raymond Yau76474da2012-01-04 16:16:26 +080059
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static xtalk_gains_t const asXtalkGains1Chan = {
Raymond Yau76474da2012-01-04 16:16:26 +080061 0x7FFF, 0, 0, 0, 0,
62 0x7FFF, 0, 0, 0, 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063};
64
65// Input gain for 4 A3D slices. One possible input pair is left zero.
66static xtalk_gains_t const asXtalkGainsAllChan = {
Raymond Yau76474da2012-01-04 16:16:26 +080067 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0,
68 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070069};
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Raymond Yau76474da2012-01-04 16:16:26 +080071static xtalk_gains_t const asXtalkGainsZeros = {
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
73};
74
75static xtalk_dline_t const alXtalkDlineZeros = {
76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
78};
Linus Torvalds1da177e2005-04-16 15:20:36 -070079static xtalk_dline_t const alXtalkDlineTest = {
Raymond Yau76474da2012-01-04 16:16:26 +080080 0x0000fc18, 0xfff03e8, 0x000186a0, 0xfffe7960, 1, 0xffffffff, 0, 0,
81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
82 0, 0, 0, 0, 0, 0, 0, 0
83};
84
85static xtalk_instate_t const asXtalkInStateZeros = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 0, 0, 0, 0
87};
88
Raymond Yau76474da2012-01-04 16:16:26 +080089static xtalk_instate_t const asXtalkInStateTest = {
90 0x0080, 0xff80, 0x0001, 0xffff
91};
92
93static xtalk_state_t const asXtalkOutStateZeros = {
94 {0, 0, 0, 0},
95 {0, 0, 0, 0},
96 {0, 0, 0, 0},
97 {0, 0, 0, 0},
98 {0, 0, 0, 0}
99};
Takashi Iwai6581f4e2006-05-17 17:14:51 +0200100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101static short const sDiamondKLeftEq = 0x401d;
102static short const sDiamondKRightEq = 0x401d;
103static short const sDiamondKLeftXt = 0xF90E;
104static short const sDiamondKRightXt = 0xF90E;
Raymond Yau76474da2012-01-04 16:16:26 +0800105static short const sDiamondShiftLeftEq = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106static short const sDiamondShiftRightEq = 1;
107static short const sDiamondShiftLeftXt = 0;
108static short const sDiamondShiftRightXt = 0;
109static unsigned short const wDiamondLeftDelay = 0xb;
110static unsigned short const wDiamondRightDelay = 0xb;
111
112static xtalk_coefs_t const asXtalkWideCoefsLeftEq = {
113 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
114 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
Raymond Yau76474da2012-01-04 16:16:26 +0800115 {0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
116 {0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
118};
119static xtalk_coefs_t const asXtalkWideCoefsRightEq = {
120 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
121 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
Raymond Yau76474da2012-01-04 16:16:26 +0800122 {0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
123 {0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
125};
126static xtalk_coefs_t const asXtalkWideCoefsLeftXt = {
Raymond Yau76474da2012-01-04 16:16:26 +0800127 {0x55c6, 0xc97b, 0x005b, 0x0047, 0},
128 {0x6a60, 0xca20, 0xffc6, 0x0040, 0},
129 {0x6411, 0xd711, 0xfca1, 0x0190, 0},
130 {0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 {0, 0, 0, 0, 0}
132};
133static xtalk_coefs_t const asXtalkWideCoefsRightXt = {
Raymond Yau76474da2012-01-04 16:16:26 +0800134 {0x55c6, 0xc97b, 0x005b, 0x0047, 0},
135 {0x6a60, 0xca20, 0xffc6, 0x0040, 0},
136 {0x6411, 0xd711, 0xfca1, 0x0190, 0},
137 {0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 {0, 0, 0, 0, 0}
139};
140static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = {
141 {0x50B5, 0xD07C, 0x026D, 0xFD21, 0},
142 {0x460F, 0xE44F, 0xF75E, 0xEFA6, 0},
143 {0x556D, 0xDCAB, 0x2098, 0xF0F2, 0},
144 {0x7E03, 0xC1F0, 0x007D, 0xFF89, 0},
145 {0x383E, 0xFD9D, 0xB278, 0x4547, 0}
146};
147
148static xtalk_coefs_t const asXtalkNarrowCoefsRightEq = {
149 {0x50B5, 0xD07C, 0x026D, 0xFD21, 0},
150 {0x460F, 0xE44F, 0xF75E, 0xEFA6, 0},
151 {0x556D, 0xDCAB, 0x2098, 0xF0F2, 0},
152 {0x7E03, 0xC1F0, 0x007D, 0xFF89, 0},
153 {0x383E, 0xFD9D, 0xB278, 0x4547, 0}
154};
155
156static xtalk_coefs_t const asXtalkNarrowCoefsLeftXt = {
157 {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0},
158 {0x6777, 0xC915, 0xFEAF, 0x00B1, 0},
159 {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0},
160 {0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0},
161 {0, 0, 0, 0, 0}
162};
163
164static xtalk_coefs_t const asXtalkNarrowCoefsRightXt = {
165 {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0},
166 {0x6777, 0xC915, 0xFEAF, 0x00B1, 0},
167 {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0},
168 {0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0},
169 {0, 0, 0, 0, 0}
170};
171
Raymond Yau76474da2012-01-04 16:16:26 +0800172static xtalk_coefs_t const asXtalkCoefsZeros = {
173 {0, 0, 0, 0, 0},
174 {0, 0, 0, 0, 0},
175 {0, 0, 0, 0, 0},
176 {0, 0, 0, 0, 0},
177 {0, 0, 0, 0, 0}
178};
179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180static xtalk_coefs_t const asXtalkCoefsPipe = {
181 {0, 0, 0x0FA0, 0, 0},
182 {0, 0, 0x0FA0, 0, 0},
183 {0, 0, 0x0FA0, 0, 0},
184 {0, 0, 0x0FA0, 0, 0},
185 {0, 0, 0x1180, 0, 0},
186};
187static xtalk_coefs_t const asXtalkCoefsNegPipe = {
188 {0, 0, 0xF380, 0, 0},
189 {0, 0, 0xF380, 0, 0},
190 {0, 0, 0xF380, 0, 0},
191 {0, 0, 0xF380, 0, 0},
192 {0, 0, 0xF200, 0, 0}
193};
194
195static xtalk_coefs_t const asXtalkCoefsNumTest = {
196 {0, 0, 0xF380, 0x8000, 0x6D60},
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_coefs_t const asXtalkCoefsDenTest = {
204 {0xC000, 0x2000, 0x4000, 0, 0},
205 {0, 0, 0, 0, 0},
206 {0, 0, 0, 0, 0},
207 {0, 0, 0, 0, 0},
208 {0, 0, 0, 0, 0}
209};
210
211static xtalk_state_t const asXtalkOutStateTest = {
212 {0x7FFF, 0x0004, 0xFFFC, 0},
213 {0xFE00, 0x0008, 0xFFF8, 0x4000},
Raymond Yau76474da2012-01-04 16:16:26 +0800214 {0x0200, 0x0010, 0xFFF0, 0xC000},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 {0x8000, 0x0020, 0xFFE0, 0},
216 {0, 0, 0, 0}
217};
218
219static xtalk_coefs_t const asDiamondCoefsLeftEq = {
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 asDiamondCoefsRightEq = {
228 {0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0},
229 {0x45E2, 0xCA51, 0x0448, 0xFCE7, 0},
230 {0xA93E, 0xDBD5, 0x022C, 0x028A, 0},
231 {0, 0, 0, 0, 0},
232 {0, 0, 0, 0, 0}
233};
234
235static xtalk_coefs_t const asDiamondCoefsLeftXt = {
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
243static xtalk_coefs_t const asDiamondCoefsRightXt = {
244 {0x3B50, 0xFE08, 0xF959, 0x0060, 0},
245 {0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0},
246 {0, 0, 0, 0, 0},
247 {0, 0, 0, 0, 0},
248 {0, 0, 0, 0, 0}
249};
250
251 /**/
252/* XTalk EQ and XT */
253static void
254vortex_XtalkHw_SetLeftEQ(vortex_t * vortex, short arg_0, short arg_4,
255 xtalk_coefs_t const coefs)
256{
257 int i;
258
259 for (i = 0; i < 5; i++) {
260 hwwrite(vortex->mmio, 0x24200 + i * 0x24, coefs[i][0]);
261 hwwrite(vortex->mmio, 0x24204 + i * 0x24, coefs[i][1]);
262 hwwrite(vortex->mmio, 0x24208 + i * 0x24, coefs[i][2]);
263 hwwrite(vortex->mmio, 0x2420c + i * 0x24, coefs[i][3]);
264 hwwrite(vortex->mmio, 0x24210 + i * 0x24, coefs[i][4]);
265 }
266 hwwrite(vortex->mmio, 0x24538, arg_0 & 0xffff);
267 hwwrite(vortex->mmio, 0x2453C, arg_4 & 0xffff);
268}
269
270static void
271vortex_XtalkHw_SetRightEQ(vortex_t * vortex, short arg_0, short arg_4,
272 xtalk_coefs_t const coefs)
273{
274 int i;
275
276 for (i = 0; i < 5; i++) {
277 hwwrite(vortex->mmio, 0x242b4 + i * 0x24, coefs[i][0]);
278 hwwrite(vortex->mmio, 0x242b8 + i * 0x24, coefs[i][1]);
279 hwwrite(vortex->mmio, 0x242bc + i * 0x24, coefs[i][2]);
280 hwwrite(vortex->mmio, 0x242c0 + i * 0x24, coefs[i][3]);
281 hwwrite(vortex->mmio, 0x242c4 + i * 0x24, coefs[i][4]);
282 }
283 hwwrite(vortex->mmio, 0x24540, arg_0 & 0xffff);
284 hwwrite(vortex->mmio, 0x24544, arg_4 & 0xffff);
285}
286
287static void
288vortex_XtalkHw_SetLeftXT(vortex_t * vortex, short arg_0, short arg_4,
289 xtalk_coefs_t const coefs)
290{
291 int i;
292
293 for (i = 0; i < 5; i++) {
294 hwwrite(vortex->mmio, 0x24368 + i * 0x24, coefs[i][0]);
295 hwwrite(vortex->mmio, 0x2436c + i * 0x24, coefs[i][1]);
296 hwwrite(vortex->mmio, 0x24370 + i * 0x24, coefs[i][2]);
297 hwwrite(vortex->mmio, 0x24374 + i * 0x24, coefs[i][3]);
298 hwwrite(vortex->mmio, 0x24378 + i * 0x24, coefs[i][4]);
299 }
300 hwwrite(vortex->mmio, 0x24548, arg_0 & 0xffff);
301 hwwrite(vortex->mmio, 0x2454C, arg_4 & 0xffff);
302}
303
304static void
305vortex_XtalkHw_SetRightXT(vortex_t * vortex, short arg_0, short arg_4,
306 xtalk_coefs_t const coefs)
307{
308 int i;
309
310 for (i = 0; i < 5; i++) {
311 hwwrite(vortex->mmio, 0x2441C + i * 0x24, coefs[i][0]);
312 hwwrite(vortex->mmio, 0x24420 + i * 0x24, coefs[i][1]);
313 hwwrite(vortex->mmio, 0x24424 + i * 0x24, coefs[i][2]);
314 hwwrite(vortex->mmio, 0x24428 + i * 0x24, coefs[i][3]);
315 hwwrite(vortex->mmio, 0x2442C + i * 0x24, coefs[i][4]);
316 }
317 hwwrite(vortex->mmio, 0x24550, arg_0 & 0xffff);
318 hwwrite(vortex->mmio, 0x24554, arg_4 & 0xffff);
319}
320
321static void
322vortex_XtalkHw_SetLeftEQStates(vortex_t * vortex,
323 xtalk_instate_t const arg_0,
324 xtalk_state_t const coefs)
325{
326 int i;
327
328 for (i = 0; i < 5; i++) {
329 hwwrite(vortex->mmio, 0x24214 + i * 0x24, coefs[i][0]);
330 hwwrite(vortex->mmio, 0x24218 + i * 0x24, coefs[i][1]);
331 hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]);
332 hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]);
333 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800334 hwwrite(vortex->mmio, 0x244F8, arg_0[0]);
335 hwwrite(vortex->mmio, 0x244FC, arg_0[1]);
336 hwwrite(vortex->mmio, 0x24500, arg_0[2]);
337 hwwrite(vortex->mmio, 0x24504, arg_0[3]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
340static void
341vortex_XtalkHw_SetRightEQStates(vortex_t * vortex,
342 xtalk_instate_t const arg_0,
343 xtalk_state_t const coefs)
344{
345 int i;
346
347 for (i = 0; i < 5; i++) {
348 hwwrite(vortex->mmio, 0x242C8 + i * 0x24, coefs[i][0]);
349 hwwrite(vortex->mmio, 0x242CC + i * 0x24, coefs[i][1]);
350 hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]);
351 hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]);
352 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800353 hwwrite(vortex->mmio, 0x24508, arg_0[0]);
354 hwwrite(vortex->mmio, 0x2450C, arg_0[1]);
355 hwwrite(vortex->mmio, 0x24510, arg_0[2]);
356 hwwrite(vortex->mmio, 0x24514, arg_0[3]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357}
358
359static void
360vortex_XtalkHw_SetLeftXTStates(vortex_t * vortex,
361 xtalk_instate_t const arg_0,
362 xtalk_state_t const coefs)
363{
364 int i;
365
366 for (i = 0; i < 5; i++) {
367 hwwrite(vortex->mmio, 0x2437C + i * 0x24, coefs[i][0]);
368 hwwrite(vortex->mmio, 0x24380 + i * 0x24, coefs[i][1]);
369 hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]);
370 hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]);
371 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800372 hwwrite(vortex->mmio, 0x24518, arg_0[0]);
373 hwwrite(vortex->mmio, 0x2451C, arg_0[1]);
374 hwwrite(vortex->mmio, 0x24520, arg_0[2]);
375 hwwrite(vortex->mmio, 0x24524, arg_0[3]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376}
377
378static void
379vortex_XtalkHw_SetRightXTStates(vortex_t * vortex,
380 xtalk_instate_t const arg_0,
381 xtalk_state_t const coefs)
382{
383 int i;
384
385 for (i = 0; i < 5; i++) {
386 hwwrite(vortex->mmio, 0x24430 + i * 0x24, coefs[i][0]);
387 hwwrite(vortex->mmio, 0x24434 + i * 0x24, coefs[i][1]);
388 hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]);
389 hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]);
390 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800391 hwwrite(vortex->mmio, 0x24528, arg_0[0]);
392 hwwrite(vortex->mmio, 0x2452C, arg_0[1]);
393 hwwrite(vortex->mmio, 0x24530, arg_0[2]);
394 hwwrite(vortex->mmio, 0x24534, arg_0[3]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395}
396
397#if 0
398static void
399vortex_XtalkHw_GetLeftEQ(vortex_t * vortex, short *arg_0, short *arg_4,
400 xtalk_coefs_t coefs)
401{
402 int i;
403
404 for (i = 0; i < 5; i++) {
405 coefs[i][0] = hwread(vortex->mmio, 0x24200 + i * 0x24);
406 coefs[i][1] = hwread(vortex->mmio, 0x24204 + i * 0x24);
407 coefs[i][2] = hwread(vortex->mmio, 0x24208 + i * 0x24);
408 coefs[i][3] = hwread(vortex->mmio, 0x2420c + i * 0x24);
409 coefs[i][4] = hwread(vortex->mmio, 0x24210 + i * 0x24);
410 }
411 *arg_0 = hwread(vortex->mmio, 0x24538) & 0xffff;
412 *arg_4 = hwread(vortex->mmio, 0x2453c) & 0xffff;
413}
414
415static void
416vortex_XtalkHw_GetRightEQ(vortex_t * vortex, short *arg_0, short *arg_4,
417 xtalk_coefs_t coefs)
418{
419 int i;
420
421 for (i = 0; i < 5; i++) {
422 coefs[i][0] = hwread(vortex->mmio, 0x242b4 + i * 0x24);
423 coefs[i][1] = hwread(vortex->mmio, 0x242b8 + i * 0x24);
424 coefs[i][2] = hwread(vortex->mmio, 0x242bc + i * 0x24);
425 coefs[i][3] = hwread(vortex->mmio, 0x242c0 + i * 0x24);
426 coefs[i][4] = hwread(vortex->mmio, 0x242c4 + i * 0x24);
427 }
428 *arg_0 = hwread(vortex->mmio, 0x24540) & 0xffff;
429 *arg_4 = hwread(vortex->mmio, 0x24544) & 0xffff;
430}
431
432static void
433vortex_XtalkHw_GetLeftXT(vortex_t * vortex, short *arg_0, short *arg_4,
434 xtalk_coefs_t coefs)
435{
436 int i;
437
438 for (i = 0; i < 5; i++) {
439 coefs[i][0] = hwread(vortex->mmio, 0x24368 + i * 0x24);
440 coefs[i][1] = hwread(vortex->mmio, 0x2436C + i * 0x24);
441 coefs[i][2] = hwread(vortex->mmio, 0x24370 + i * 0x24);
442 coefs[i][3] = hwread(vortex->mmio, 0x24374 + i * 0x24);
443 coefs[i][4] = hwread(vortex->mmio, 0x24378 + i * 0x24);
444 }
445 *arg_0 = hwread(vortex->mmio, 0x24548) & 0xffff;
446 *arg_4 = hwread(vortex->mmio, 0x2454C) & 0xffff;
447}
448
449static void
450vortex_XtalkHw_GetRightXT(vortex_t * vortex, short *arg_0, short *arg_4,
451 xtalk_coefs_t coefs)
452{
453 int i;
454
455 for (i = 0; i < 5; i++) {
456 coefs[i][0] = hwread(vortex->mmio, 0x2441C + i * 0x24);
457 coefs[i][1] = hwread(vortex->mmio, 0x24420 + i * 0x24);
458 coefs[i][2] = hwread(vortex->mmio, 0x24424 + i * 0x24);
459 coefs[i][3] = hwread(vortex->mmio, 0x24428 + i * 0x24);
460 coefs[i][4] = hwread(vortex->mmio, 0x2442C + i * 0x24);
461 }
462 *arg_0 = hwread(vortex->mmio, 0x24550) & 0xffff;
463 *arg_4 = hwread(vortex->mmio, 0x24554) & 0xffff;
464}
465
466static void
467vortex_XtalkHw_GetLeftEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
468 xtalk_state_t coefs)
469{
470 int i;
471
472 for (i = 0; i < 5; i++) {
473 coefs[i][0] = hwread(vortex->mmio, 0x24214 + i * 0x24);
474 coefs[i][1] = hwread(vortex->mmio, 0x24218 + i * 0x24);
475 coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24);
476 coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24);
477 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800478 arg_0[0] = hwread(vortex->mmio, 0x244F8);
479 arg_0[1] = hwread(vortex->mmio, 0x244FC);
480 arg_0[2] = hwread(vortex->mmio, 0x24500);
481 arg_0[3] = hwread(vortex->mmio, 0x24504);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482}
483
484static void
485vortex_XtalkHw_GetRightEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
486 xtalk_state_t coefs)
487{
488 int i;
489
490 for (i = 0; i < 5; i++) {
491 coefs[i][0] = hwread(vortex->mmio, 0x242C8 + i * 0x24);
492 coefs[i][1] = hwread(vortex->mmio, 0x242CC + i * 0x24);
493 coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24);
494 coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24);
495 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800496 arg_0[0] = hwread(vortex->mmio, 0x24508);
497 arg_0[1] = hwread(vortex->mmio, 0x2450C);
498 arg_0[2] = hwread(vortex->mmio, 0x24510);
499 arg_0[3] = hwread(vortex->mmio, 0x24514);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500}
501
502static void
503vortex_XtalkHw_GetLeftXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
504 xtalk_state_t coefs)
505{
506 int i;
507
508 for (i = 0; i < 5; i++) {
509 coefs[i][0] = hwread(vortex->mmio, 0x2437C + i * 0x24);
510 coefs[i][1] = hwread(vortex->mmio, 0x24380 + i * 0x24);
511 coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24);
512 coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24);
513 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800514 arg_0[0] = hwread(vortex->mmio, 0x24518);
515 arg_0[1] = hwread(vortex->mmio, 0x2451C);
516 arg_0[2] = hwread(vortex->mmio, 0x24520);
517 arg_0[3] = hwread(vortex->mmio, 0x24524);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518}
519
520static void
521vortex_XtalkHw_GetRightXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
522 xtalk_state_t coefs)
523{
524 int i;
525
526 for (i = 0; i < 5; i++) {
527 coefs[i][0] = hwread(vortex->mmio, 0x24430 + i * 0x24);
528 coefs[i][1] = hwread(vortex->mmio, 0x24434 + i * 0x24);
529 coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24);
530 coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24);
531 }
Raymond Yau9489f2c2012-01-04 15:42:44 +0800532 arg_0[0] = hwread(vortex->mmio, 0x24528);
533 arg_0[1] = hwread(vortex->mmio, 0x2452C);
534 arg_0[2] = hwread(vortex->mmio, 0x24530);
535 arg_0[3] = hwread(vortex->mmio, 0x24534);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536}
537
538#endif
539/* Gains */
540
541static void
542vortex_XtalkHw_SetGains(vortex_t * vortex, xtalk_gains_t const gains)
543{
544 int i;
545
546 for (i = 0; i < XTGAINS_SZ; i++) {
547 hwwrite(vortex->mmio, 0x244D0 + (i * 4), gains[i]);
548 }
549}
550
551static void
552vortex_XtalkHw_SetGainsAllChan(vortex_t * vortex)
553{
554 vortex_XtalkHw_SetGains(vortex, asXtalkGainsAllChan);
555}
556
557#if 0
558static void vortex_XtalkHw_GetGains(vortex_t * vortex, xtalk_gains_t gains)
559{
560 int i;
561
562 for (i = 0; i < XTGAINS_SZ; i++)
563 gains[i] = hwread(vortex->mmio, 0x244D0 + i * 4);
564}
565
566#endif
567/* Delay parameters */
568
569static void
570vortex_XtalkHw_SetDelay(vortex_t * vortex, unsigned short right,
571 unsigned short left)
572{
Takashi Iwai97c67b62006-01-13 17:16:29 +0100573 u32 esp0 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574
575 esp0 &= 0x1FFFFFFF;
576 esp0 |= 0xA0000000;
577 esp0 = (esp0 & 0xffffE0ff) | ((right & 0x1F) << 8);
578 esp0 = (esp0 & 0xfffc1fff) | ((left & 0x1F) << 0xd);
579
580 hwwrite(vortex->mmio, 0x24660, esp0);
581}
582
583static void
584vortex_XtalkHw_SetLeftDline(vortex_t * vortex, xtalk_dline_t const dline)
585{
586 int i;
587
588 for (i = 0; i < 0x20; i++) {
589 hwwrite(vortex->mmio, 0x24000 + (i << 2), dline[i] & 0xffff);
590 hwwrite(vortex->mmio, 0x24080 + (i << 2), dline[i] >> 0x10);
591 }
592}
593
594static void
595vortex_XtalkHw_SetRightDline(vortex_t * vortex, xtalk_dline_t const dline)
596{
597 int i;
598
599 for (i = 0; i < 0x20; i++) {
600 hwwrite(vortex->mmio, 0x24100 + (i << 2), dline[i] & 0xffff);
601 hwwrite(vortex->mmio, 0x24180 + (i << 2), dline[i] >> 0x10);
602 }
603}
604
605#if 0
606static void
607vortex_XtalkHw_GetDelay(vortex_t * vortex, unsigned short *right,
608 unsigned short *left)
609{
610 int esp0;
611
612 esp0 = hwread(vortex->mmio, 0x24660);
613 *right = (esp0 >> 8) & 0x1f;
614 *left = (esp0 >> 0xd) & 0x1f;
615}
616
617static void vortex_XtalkHw_GetLeftDline(vortex_t * vortex, xtalk_dline_t dline)
618{
619 int i;
620
621 for (i = 0; i < 0x20; i++) {
622 dline[i] =
623 (hwread(vortex->mmio, 0x24000 + (i << 2)) & 0xffff) |
624 (hwread(vortex->mmio, 0x24080 + (i << 2)) << 0x10);
625 }
626}
627
628static void vortex_XtalkHw_GetRightDline(vortex_t * vortex, xtalk_dline_t dline)
629{
630 int i;
631
632 for (i = 0; i < 0x20; i++) {
633 dline[i] =
634 (hwread(vortex->mmio, 0x24100 + (i << 2)) & 0xffff) |
635 (hwread(vortex->mmio, 0x24180 + (i << 2)) << 0x10);
636 }
637}
638
639#endif
640/* Control/Global stuff */
641
642#if 0
Takashi Iwai97c67b62006-01-13 17:16:29 +0100643static void vortex_XtalkHw_SetControlReg(vortex_t * vortex, u32 ctrl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644{
645 hwwrite(vortex->mmio, 0x24660, ctrl);
646}
Takashi Iwai97c67b62006-01-13 17:16:29 +0100647static void vortex_XtalkHw_GetControlReg(vortex_t * vortex, u32 *ctrl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648{
649 *ctrl = hwread(vortex->mmio, 0x24660);
650}
651#endif
Takashi Iwai97c67b62006-01-13 17:16:29 +0100652static void vortex_XtalkHw_SetSampleRate(vortex_t * vortex, u32 sr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653{
Takashi Iwai97c67b62006-01-13 17:16:29 +0100654 u32 temp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655
656 temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
657 temp = (temp & 0xffffff07) | ((sr & 0x1f) << 3);
658 hwwrite(vortex->mmio, 0x24660, temp);
659}
660
661#if 0
Takashi Iwai97c67b62006-01-13 17:16:29 +0100662static void vortex_XtalkHw_GetSampleRate(vortex_t * vortex, u32 *sr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663{
664 *sr = (hwread(vortex->mmio, 0x24660) >> 3) & 0x1f;
665}
666
667#endif
668static void vortex_XtalkHw_Enable(vortex_t * vortex)
669{
Takashi Iwai97c67b62006-01-13 17:16:29 +0100670 u32 temp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671
672 temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
673 temp |= 1;
674 hwwrite(vortex->mmio, 0x24660, temp);
675
676}
677
678static void vortex_XtalkHw_Disable(vortex_t * vortex)
679{
Takashi Iwai97c67b62006-01-13 17:16:29 +0100680 u32 temp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681
682 temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000;
683 temp &= 0xfffffffe;
684 hwwrite(vortex->mmio, 0x24660, temp);
685
686}
687
688static void vortex_XtalkHw_ZeroIO(vortex_t * vortex)
689{
690 int i;
691
692 for (i = 0; i < 20; i++)
693 hwwrite(vortex->mmio, 0x24600 + (i << 2), 0);
694 for (i = 0; i < 4; i++)
695 hwwrite(vortex->mmio, 0x24650 + (i << 2), 0);
696}
697
698static void vortex_XtalkHw_ZeroState(vortex_t * vortex)
699{
700 vortex_XtalkHw_ZeroIO(vortex); // inlined
701
702 vortex_XtalkHw_SetLeftEQ(vortex, 0, 0, asXtalkCoefsZeros);
703 vortex_XtalkHw_SetRightEQ(vortex, 0, 0, asXtalkCoefsZeros);
704
705 vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros);
706 vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros);
707
708 vortex_XtalkHw_SetGains(vortex, asXtalkGainsZeros); // inlined
709
710 vortex_XtalkHw_SetDelay(vortex, 0, 0); // inlined
711
712 vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros); // inlined
713 vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros); // inlined
714 vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros); // inlined
715 vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros); // inlined
716
717 vortex_XtalkHw_SetLeftEQStates(vortex, asXtalkInStateZeros,
718 asXtalkOutStateZeros);
719 vortex_XtalkHw_SetRightEQStates(vortex, asXtalkInStateZeros,
720 asXtalkOutStateZeros);
721 vortex_XtalkHw_SetLeftXTStates(vortex, asXtalkInStateZeros,
722 asXtalkOutStateZeros);
723 vortex_XtalkHw_SetRightXTStates(vortex, asXtalkInStateZeros,
724 asXtalkOutStateZeros);
725}
726
727static void vortex_XtalkHw_ProgramPipe(vortex_t * vortex)
728{
729
730 vortex_XtalkHw_SetLeftEQ(vortex, 0, 1, asXtalkCoefsPipe);
731 vortex_XtalkHw_SetRightEQ(vortex, 0, 1, asXtalkCoefsPipe);
732 vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros);
733 vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros);
734
735 vortex_XtalkHw_SetDelay(vortex, 0, 0); // inlined
736}
737
738static void vortex_XtalkHw_ProgramXtalkWide(vortex_t * vortex)
739{
740
741 vortex_XtalkHw_SetLeftEQ(vortex, sXtalkWideKLeftEq,
742 sXtalkWideShiftLeftEq, asXtalkWideCoefsLeftEq);
743 vortex_XtalkHw_SetRightEQ(vortex, sXtalkWideKRightEq,
744 sXtalkWideShiftRightEq,
745 asXtalkWideCoefsRightEq);
746 vortex_XtalkHw_SetLeftXT(vortex, sXtalkWideKLeftXt,
747 sXtalkWideShiftLeftXt, asXtalkWideCoefsLeftXt);
748 vortex_XtalkHw_SetRightXT(vortex, sXtalkWideKLeftXt,
749 sXtalkWideShiftLeftXt,
750 asXtalkWideCoefsLeftXt);
751
752 vortex_XtalkHw_SetDelay(vortex, wXtalkWideRightDelay, wXtalkWideLeftDelay); // inlined
753}
754
755static void vortex_XtalkHw_ProgramXtalkNarrow(vortex_t * vortex)
756{
757
758 vortex_XtalkHw_SetLeftEQ(vortex, sXtalkNarrowKLeftEq,
759 sXtalkNarrowShiftLeftEq,
760 asXtalkNarrowCoefsLeftEq);
761 vortex_XtalkHw_SetRightEQ(vortex, sXtalkNarrowKRightEq,
762 sXtalkNarrowShiftRightEq,
763 asXtalkNarrowCoefsRightEq);
764 vortex_XtalkHw_SetLeftXT(vortex, sXtalkNarrowKLeftXt,
765 sXtalkNarrowShiftLeftXt,
766 asXtalkNarrowCoefsLeftXt);
767 vortex_XtalkHw_SetRightXT(vortex, sXtalkNarrowKLeftXt,
768 sXtalkNarrowShiftLeftXt,
769 asXtalkNarrowCoefsLeftXt);
770
771 vortex_XtalkHw_SetDelay(vortex, wXtalkNarrowRightDelay, wXtalkNarrowLeftDelay); // inlined
772}
773
774static void vortex_XtalkHw_ProgramDiamondXtalk(vortex_t * vortex)
775{
776
777 //sDiamondKLeftEq,sDiamondKRightXt,asDiamondCoefsLeftEq
778 vortex_XtalkHw_SetLeftEQ(vortex, sDiamondKLeftEq,
779 sDiamondShiftLeftEq, asDiamondCoefsLeftEq);
780 vortex_XtalkHw_SetRightEQ(vortex, sDiamondKRightEq,
781 sDiamondShiftRightEq, asDiamondCoefsRightEq);
782 vortex_XtalkHw_SetLeftXT(vortex, sDiamondKLeftXt,
783 sDiamondShiftLeftXt, asDiamondCoefsLeftXt);
784 vortex_XtalkHw_SetRightXT(vortex, sDiamondKLeftXt,
785 sDiamondShiftLeftXt, asDiamondCoefsLeftXt);
786
787 vortex_XtalkHw_SetDelay(vortex, wDiamondRightDelay, wDiamondLeftDelay); // inlined
788}
789
790static void vortex_XtalkHw_init(vortex_t * vortex)
791{
792 vortex_XtalkHw_ZeroState(vortex);
793}
794
795/* End of file */