2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Library General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 Vortex core low level functions.
20 Author: Manuel Jander (mjander@users.sourceforge.cl)
21 These functions are mainly the result of translations made
22 from the original disassembly of the au88x0 binary drivers,
23 written by Aureal before they went down.
24 Many thanks to the Jeff Muizelar, Kester Maddock, and whoever
25 contributed to the OpenVortex project.
26 The author of this file, put the few available pieces together
27 and translated the rest of the riddle (Mix, Src and connection stuff).
28 Some things are still to be discovered, and their meanings are unclear.
30 Some of these functions aren't intended to be really used, rather
31 to help to understand how does the AU88X0 chips work. Keep them in, because
32 they could be used somewhere in the future.
34 This code hasn't been tested or proof read thoroughly. If you wanna help,
35 take a look at the AU88X0 assembly and check if this matches.
36 Functions tested ok so far are (they show the desired effect
38 vortex_routes(); (1 bug fixed).
39 vortex_adb_addroute();
40 vortex_adb_addroutes();
41 vortex_connect_codecplay();
42 vortex_src_flushbuffers();
43 vortex_adbdma_setmode(); note: still some unknown arguments!
44 vortex_adbdma_startfifo();
45 vortex_adbdma_stopfifo();
46 vortex_fifo_setadbctrl(); note: still some unknown arguments!
47 vortex_mix_setinputvolumebyte();
48 vortex_mix_enableinput();
49 vortex_mixer_addWTD(); (fixed)
50 vortex_connection_adbdma_src_src();
51 vortex_connection_adbdma_src();
52 vortex_src_change_convratio();
53 vortex_src_addWTD(); (fixed)
57 01-03-2003 First revision.
58 01-21-2003 Some bug fixes.
59 17-02-2003 many bugfixes after a big versioning mess.
60 18-02-2003 JAAAAAHHHUUUUUU!!!! The mixer works !! I'm just so happy !
61 (2 hours later...) I cant believe it! Im really lucky today.
62 Now the SRC is working too! Yeah! XMMS works !
63 20-02-2003 First steps into the ALSA world.
64 28-02-2003 As my birthday present, i discovered how the DMA buffer pages really
65 work :-). It was all wrong.
66 12-03-2003 ALSA driver starts working (2 channels).
67 16-03-2003 More srcblock_setupchannel discoveries.
68 12-04-2003 AU8830 playback support. Recording in the works.
69 17-04-2003 vortex_route() and vortex_routes() bug fixes. AU8830 recording
70 works now, but chipn' dale effect is still there.
71 16-05-2003 SrcSetupChannel cleanup. Moved the Src setup stuff entirely
73 06-06-2003 Buffer shifter bugfix. Mixer volume fix.
74 07-12-2003 A3D routing finally fixed. Believed to be OK.
79 #include "au88x0_a3d.h"
80 #include <linux/delay.h>
82 /* MIXER (CAsp4Mix.s and CAsp4Mixer.s) */
84 // FIXME: get rid of this.
85 static int mchannels[NR_MIXIN];
86 static int rampchs[NR_MIXIN];
88 static void vortex_mixer_en_sr(vortex_t * vortex, int channel)
90 hwwrite(vortex->mmio, VORTEX_MIXER_SR,
91 hwread(vortex->mmio, VORTEX_MIXER_SR) | (0x1 << channel));
93 static void vortex_mixer_dis_sr(vortex_t * vortex, int channel)
95 hwwrite(vortex->mmio, VORTEX_MIXER_SR,
96 hwread(vortex->mmio, VORTEX_MIXER_SR) & ~(0x1 << channel));
101 vortex_mix_muteinputgain(vortex_t * vortex, unsigned char mix,
102 unsigned char channel)
104 hwwrite(vortex->mmio, VORTEX_MIX_INVOL_A + ((mix << 5) + channel),
106 hwwrite(vortex->mmio, VORTEX_MIX_INVOL_B + ((mix << 5) + channel),
110 static int vortex_mix_getvolume(vortex_t * vortex, unsigned char mix)
113 a = hwread(vortex->mmio, VORTEX_MIX_VOL_A + (mix << 2)) & 0xff;
119 vortex_mix_getinputvolume(vortex_t * vortex, unsigned char mix,
120 int channel, int *vol)
123 if (!(mchannels[mix] & (1 << channel)))
125 a = hwread(vortex->mmio,
126 VORTEX_MIX_INVOL_A + (((mix << 5) + channel) << 2));
128 if (rampchs[mix] == 0)
129 a = FP2LinearFrac(a);
131 a = FP2LinearFracWT(a);
137 static unsigned int vortex_mix_boost6db(unsigned char vol)
139 return (vol + 8); /* WOW! what a complex function! */
142 static void vortex_mix_rampvolume(vortex_t * vortex, int mix)
146 // This function is intended for ramping down only (see vortex_disableinput()).
147 for (ch = 0; ch < 0x20; ch++) {
148 if (((1 << ch) & rampchs[mix]) == 0)
150 a = hwread(vortex->mmio,
151 VORTEX_MIX_INVOL_B + (((mix << 5) + ch) << 2));
154 hwwrite(vortex->mmio,
156 (((mix << 5) + ch) << 2), a);
157 hwwrite(vortex->mmio,
159 (((mix << 5) + ch) << 2), a);
161 vortex_mix_killinput(vortex, mix, ch);
166 vortex_mix_getenablebit(vortex_t * vortex, unsigned char mix, int mixin)
173 addr = ((mix << 3) + (addr >> 2)) << 2;
174 temp = hwread(vortex->mmio, VORTEX_MIX_ENIN + addr);
175 return ((temp >> (mixin & 3)) & 1);
179 vortex_mix_setvolumebyte(vortex_t * vortex, unsigned char mix,
183 hwwrite(vortex->mmio, VORTEX_MIX_VOL_A + (mix << 2), vol);
184 if (1) { /*if (this_10) */
185 temp = hwread(vortex->mmio, VORTEX_MIX_VOL_B + (mix << 2));
186 if ((temp != 0x80) || (vol == 0x80))
189 hwwrite(vortex->mmio, VORTEX_MIX_VOL_B + (mix << 2), vol);
193 vortex_mix_setinputvolumebyte(vortex_t * vortex, unsigned char mix,
194 int mixin, unsigned char vol)
198 hwwrite(vortex->mmio,
199 VORTEX_MIX_INVOL_A + (((mix << 5) + mixin) << 2), vol);
200 if (1) { /* this_10, initialized to 1. */
203 VORTEX_MIX_INVOL_B + (((mix << 5) + mixin) << 2));
204 if ((temp != 0x80) || (vol == 0x80))
207 hwwrite(vortex->mmio,
208 VORTEX_MIX_INVOL_B + (((mix << 5) + mixin) << 2), vol);
212 vortex_mix_setenablebit(vortex_t * vortex, unsigned char mix, int mixin, int en)
220 addr = ((mix << 3) + (addr >> 2)) << 2;
221 temp = hwread(vortex->mmio, VORTEX_MIX_ENIN + addr);
223 temp |= (1 << (mixin & 3));
225 temp &= ~(1 << (mixin & 3));
226 /* Mute input. Astatic void crackling? */
227 hwwrite(vortex->mmio,
228 VORTEX_MIX_INVOL_B + (((mix << 5) + mixin) << 2), 0x80);
229 /* Looks like clear buffer. */
230 hwwrite(vortex->mmio, VORTEX_MIX_SMP + (mixin << 2), 0x0);
231 hwwrite(vortex->mmio, VORTEX_MIX_SMP + 4 + (mixin << 2), 0x0);
232 /* Write enable bit. */
233 hwwrite(vortex->mmio, VORTEX_MIX_ENIN + addr, temp);
237 vortex_mix_killinput(vortex_t * vortex, unsigned char mix, int mixin)
239 rampchs[mix] &= ~(1 << mixin);
240 vortex_mix_setinputvolumebyte(vortex, mix, mixin, 0x80);
241 mchannels[mix] &= ~(1 << mixin);
242 vortex_mix_setenablebit(vortex, mix, mixin, 0);
246 vortex_mix_enableinput(vortex_t * vortex, unsigned char mix, int mixin)
248 vortex_mix_killinput(vortex, mix, mixin);
249 if ((mchannels[mix] & (1 << mixin)) == 0) {
250 vortex_mix_setinputvolumebyte(vortex, mix, mixin, 0x80); /*0x80 : mute */
251 mchannels[mix] |= (1 << mixin);
253 vortex_mix_setenablebit(vortex, mix, mixin, 1);
257 vortex_mix_disableinput(vortex_t * vortex, unsigned char mix, int channel,
261 rampchs[mix] |= (1 << channel);
262 // Register callback.
263 //vortex_mix_startrampvolume(vortex);
264 vortex_mix_killinput(vortex, mix, channel);
266 vortex_mix_killinput(vortex, mix, channel);
270 vortex_mixer_addWTD(vortex_t * vortex, unsigned char mix, unsigned char ch)
272 int temp, lifeboat = 0, prev;
274 temp = hwread(vortex->mmio, VORTEX_MIXER_SR);
275 if ((temp & (1 << ch)) == 0) {
276 hwwrite(vortex->mmio, VORTEX_MIXER_CHNBASE + (ch << 2), mix);
277 vortex_mixer_en_sr(vortex, ch);
280 prev = VORTEX_MIXER_CHNBASE + (ch << 2);
281 temp = hwread(vortex->mmio, prev);
282 while (temp & 0x10) {
283 prev = VORTEX_MIXER_RTBASE + ((temp & 0xf) << 2);
284 temp = hwread(vortex->mmio, prev);
285 //printk(KERN_INFO "vortex: mixAddWTD: while addr=%x, val=%x\n", prev, temp);
286 if ((++lifeboat) > 0xf) {
288 "vortex_mixer_addWTD: lifeboat overflow\n");
292 hwwrite(vortex->mmio, VORTEX_MIXER_RTBASE + ((temp & 0xf) << 2), mix);
293 hwwrite(vortex->mmio, prev, (temp & 0xf) | 0x10);
298 vortex_mixer_delWTD(vortex_t * vortex, unsigned char mix, unsigned char ch)
300 int esp14 = -1, esp18, eax, ebx, edx, ebp, esi = 0;
301 //int esp1f=edi(while)=src, esp10=ch;
303 eax = hwread(vortex->mmio, VORTEX_MIXER_SR);
304 if (((1 << ch) & eax) == 0) {
305 printk(KERN_ERR "mix ALARM %x\n", eax);
308 ebp = VORTEX_MIXER_CHNBASE + (ch << 2);
309 esp18 = hwread(vortex->mmio, ebp);
313 ebx = VORTEX_MIXER_RTBASE + (mix << 2);
314 edx = hwread(vortex->mmio, ebx);
316 hwwrite(vortex->mmio, ebp, edx);
317 hwwrite(vortex->mmio, ebx, 0);
322 VORTEX_MIXER_RTBASE + (ebx << 2));
323 //printk(KERN_INFO "vortex: mixdelWTD: 1 addr=%x, val=%x, src=%x\n", ebx, edx, src);
324 while ((edx & 0xf) != mix) {
327 "vortex: mixdelWTD: error lifeboat overflow\n");
335 VORTEX_MIXER_RTBASE + ebp);
336 //printk(KERN_INFO "vortex: mixdelWTD: while addr=%x, val=%x\n", ebp, edx);
341 if (edx & 0x10) { /* Delete entry in between others */
342 ebx = VORTEX_MIXER_RTBASE + ((edx & 0xf) << 2);
343 edx = hwread(vortex->mmio, ebx);
345 hwwrite(vortex->mmio,
346 VORTEX_MIXER_RTBASE + ebp, edx);
347 hwwrite(vortex->mmio, ebx, 0);
348 //printk(KERN_INFO "vortex mixdelWTD between addr= 0x%x, val= 0x%x\n", ebp, edx);
349 } else { /* Delete last entry */
352 hwwrite(vortex->mmio,
353 VORTEX_MIXER_CHNBASE +
354 (ch << 2), esp18 & 0xef);
356 ebx = (0xffffffe0 & edx) | (0xf & ebx);
357 hwwrite(vortex->mmio,
358 VORTEX_MIXER_RTBASE +
360 //printk(KERN_INFO "vortex mixdelWTD last addr= 0x%x, val= 0x%x\n", esp14, ebx);
362 hwwrite(vortex->mmio,
363 VORTEX_MIXER_RTBASE + ebp, 0);
368 //printk(KERN_INFO "removed last mix\n");
370 vortex_mixer_dis_sr(vortex, ch);
371 hwwrite(vortex->mmio, ebp, 0);
376 static void vortex_mixer_init(vortex_t * vortex)
381 // FIXME: get rid of this crap.
382 memset(mchannels, 0, NR_MIXOUT * sizeof(int));
383 memset(rampchs, 0, NR_MIXOUT * sizeof(int));
385 addr = VORTEX_MIX_SMP + 0x17c;
386 for (x = 0x5f; x >= 0; x--) {
387 hwwrite(vortex->mmio, addr, 0);
390 addr = VORTEX_MIX_ENIN + 0x1fc;
391 for (x = 0x7f; x >= 0; x--) {
392 hwwrite(vortex->mmio, addr, 0);
395 addr = VORTEX_MIX_SMP + 0x17c;
396 for (x = 0x5f; x >= 0; x--) {
397 hwwrite(vortex->mmio, addr, 0);
400 addr = VORTEX_MIX_INVOL_A + 0x7fc;
401 for (x = 0x1ff; x >= 0; x--) {
402 hwwrite(vortex->mmio, addr, 0x80);
405 addr = VORTEX_MIX_VOL_A + 0x3c;
406 for (x = 0xf; x >= 0; x--) {
407 hwwrite(vortex->mmio, addr, 0x80);
410 addr = VORTEX_MIX_INVOL_B + 0x7fc;
411 for (x = 0x1ff; x >= 0; x--) {
412 hwwrite(vortex->mmio, addr, 0x80);
415 addr = VORTEX_MIX_VOL_B + 0x3c;
416 for (x = 0xf; x >= 0; x--) {
417 hwwrite(vortex->mmio, addr, 0x80);
420 addr = VORTEX_MIXER_RTBASE + (MIXER_RTBASE_SIZE - 1) * 4;
421 for (x = (MIXER_RTBASE_SIZE - 1); x >= 0; x--) {
422 hwwrite(vortex->mmio, addr, 0x0);
425 hwwrite(vortex->mmio, VORTEX_MIXER_SR, 0);
427 /* Set clipping ceiling (this may be all wrong). */
429 for (x = 0; x > 0x80; x++) {
430 hwwrite(vortex->mmio, VORTEX_MIXER_CLIP + (x << 2), 0x3ffff);
434 call CAsp4Mix__Initialize_CAsp4HwIO____CAsp4Mixer____
435 Register ISR callback for volume smooth fade out.
436 Maybe this avoids clicks when press "stop" ?
440 /* SRC (CAsp4Src.s and CAsp4SrcBlock) */
442 static void vortex_src_en_sr(vortex_t * vortex, int channel)
444 hwwrite(vortex->mmio, VORTEX_SRCBLOCK_SR,
445 hwread(vortex->mmio, VORTEX_SRCBLOCK_SR) | (0x1 << channel));
448 static void vortex_src_dis_sr(vortex_t * vortex, int channel)
450 hwwrite(vortex->mmio, VORTEX_SRCBLOCK_SR,
451 hwread(vortex->mmio, VORTEX_SRCBLOCK_SR) & ~(0x1 << channel));
454 static void vortex_src_flushbuffers(vortex_t * vortex, unsigned char src)
458 for (i = 0x1f; i >= 0; i--)
459 hwwrite(vortex->mmio,
460 VORTEX_SRC_DATA0 + (src << 7) + (i << 2), 0);
461 hwwrite(vortex->mmio, VORTEX_SRC_DATA + (src << 3), 0);
462 hwwrite(vortex->mmio, VORTEX_SRC_DATA + (src << 3) + 4, 0);
465 static void vortex_src_cleardrift(vortex_t * vortex, unsigned char src)
467 hwwrite(vortex->mmio, VORTEX_SRC_DRIFT0 + (src << 2), 0);
468 hwwrite(vortex->mmio, VORTEX_SRC_DRIFT1 + (src << 2), 0);
469 hwwrite(vortex->mmio, VORTEX_SRC_DRIFT2 + (src << 2), 1);
473 vortex_src_set_throttlesource(vortex_t * vortex, unsigned char src, int en)
477 temp = hwread(vortex->mmio, VORTEX_SRC_SOURCE);
482 hwwrite(vortex->mmio, VORTEX_SRC_SOURCE, temp);
486 vortex_src_persist_convratio(vortex_t * vortex, unsigned char src, int ratio)
488 int temp, lifeboat = 0;
491 hwwrite(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2), ratio);
492 temp = hwread(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2));
493 if ((++lifeboat) > 0x9) {
494 printk(KERN_ERR "Vortex: Src cvr fail\n");
498 while (temp != ratio);
503 static void vortex_src_slowlock(vortex_t * vortex, unsigned char src)
507 hwwrite(vortex->mmio, VORTEX_SRC_DRIFT2 + (src << 2), 1);
508 hwwrite(vortex->mmio, VORTEX_SRC_DRIFT0 + (src << 2), 0);
509 temp = hwread(vortex->mmio, VORTEX_SRC_U0 + (src << 2));
511 hwwrite(vortex->mmio, VORTEX_SRC_U0 + (src << 2),
516 vortex_src_change_convratio(vortex_t * vortex, unsigned char src, int ratio)
520 if ((ratio & 0x10000) && (ratio != 0x10000)) {
522 a = (0x11 - ((ratio >> 0xe) & 0x3)) - 1;
524 a = (0x11 - ((ratio >> 0xe) & 0x3)) - 2;
527 temp = hwread(vortex->mmio, VORTEX_SRC_U0 + (src << 2));
528 if (((temp >> 4) & 0xf) != a)
529 hwwrite(vortex->mmio, VORTEX_SRC_U0 + (src << 2),
530 (temp & 0xf) | ((a & 0xf) << 4));
532 vortex_src_persist_convratio(vortex, src, ratio);
536 vortex_src_checkratio(vortex_t * vortex, unsigned char src,
537 unsigned int desired_ratio)
539 int hw_ratio, lifeboat = 0;
541 hw_ratio = hwread(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2));
543 while (hw_ratio != desired_ratio) {
544 hwwrite(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2), desired_ratio);
546 if ((lifeboat++) > 15) {
547 printk(KERN_ERR "Vortex: could not set src-%d from %d to %d\n",
548 src, hw_ratio, desired_ratio);
558 Objective: Set samplerate for given SRC module.
560 card: pointer to vortex_t strcut.
561 src: Integer index of the SRC module.
562 cr: Current sample rate conversion factor.
563 b: unknown 16 bit value.
564 sweep: Enable Samplerate fade from cr toward tr flag.
565 dirplay: 1: playback, 0: recording.
567 tr: Target samplerate conversion.
568 thsource: Throttle source flag (no idea what that means).
570 static void vortex_src_setupchannel(vortex_t * card, unsigned char src,
571 unsigned int cr, unsigned int b, int sweep, int d,
572 int dirplay, int sl, unsigned int tr, int thsource)
574 // noplayback: d=2,4,7,0xa,0xb when using first 2 src's.
575 // c: enables pitch sweep.
576 // looks like g is c related. Maybe g is a sweep parameter ?
578 // dirplay: 0 = recording, 1 = playback
581 int esi, ebp = 0, esp10;
583 vortex_src_flushbuffers(card, src);
586 if ((tr & 0x10000) && (tr != 0x10000)) {
590 if ((((short)tr) < 0) && (tr != 0x8000)) {
599 if ((cr & 0x10000) && (cr != 0x10000)) {
601 esi = 0x11 - ((cr >> 0xe) & 7);
611 vortex_src_cleardrift(card, src);
612 vortex_src_set_throttlesource(card, src, thsource);
614 if ((dirplay == 0) && (sweep == 0)) {
627 hwwrite(card->mmio, VORTEX_SRC_U0 + (src << 2),
628 (sl << 0x9) | (sweep << 0x8) | ((esi & 0xf) << 4) | d);
629 /* 0xc0 esi=0xc c=f=0 d=0 */
630 vortex_src_persist_convratio(card, src, cr);
631 hwwrite(card->mmio, VORTEX_SRC_U1 + (src << 2), b & 0xffff);
633 hwwrite(card->mmio, VORTEX_SRC_U2 + (src << 2),
634 (tr << 0x11) | (dirplay << 0x10) | (ebp << 0x8) | esp10);
635 /* 0x30f00 e=g=1 esp10=0 ebp=f */
636 //printk(KERN_INFO "vortex: SRC %d, d=0x%x, esi=0x%x, esp10=0x%x, ebp=0x%x\n", src, d, esi, esp10, ebp);
639 static void vortex_srcblock_init(vortex_t * vortex)
643 hwwrite(vortex->mmio, VORTEX_SRC_SOURCESIZE, 0x1ff);
645 for (x=0; x<0x10; x++) {
646 vortex_src_init(&vortex_src[x], x);
651 addr = VORTEX_SRC_RTBASE + 0x3c;
652 for (x = 0xf; x >= 0; x--) {
653 hwwrite(vortex->mmio, addr, 0);
658 addr = VORTEX_SRC_CHNBASE + 0x54;
659 for (x = 0x15; x >= 0; x--) {
660 hwwrite(vortex->mmio, addr, 0);
666 vortex_src_addWTD(vortex_t * vortex, unsigned char src, unsigned char ch)
668 int temp, lifeboat = 0, prev;
671 temp = hwread(vortex->mmio, VORTEX_SRCBLOCK_SR);
672 if ((temp & (1 << ch)) == 0) {
673 hwwrite(vortex->mmio, VORTEX_SRC_CHNBASE + (ch << 2), src);
674 vortex_src_en_sr(vortex, ch);
677 prev = VORTEX_SRC_CHNBASE + (ch << 2); /*ebp */
678 temp = hwread(vortex->mmio, prev);
679 //while (temp & NR_SRC) {
680 while (temp & 0x10) {
681 prev = VORTEX_SRC_RTBASE + ((temp & 0xf) << 2); /*esp12 */
682 //prev = VORTEX_SRC_RTBASE + ((temp & (NR_SRC-1)) << 2); /*esp12*/
683 temp = hwread(vortex->mmio, prev);
684 //printk(KERN_INFO "vortex: srcAddWTD: while addr=%x, val=%x\n", prev, temp);
685 if ((++lifeboat) > 0xf) {
687 "vortex_src_addWTD: lifeboat overflow\n");
691 hwwrite(vortex->mmio, VORTEX_SRC_RTBASE + ((temp & 0xf) << 2), src);
692 //hwwrite(vortex->mmio, prev, (temp & (NR_SRC-1)) | NR_SRC);
693 hwwrite(vortex->mmio, prev, (temp & 0xf) | 0x10);
698 vortex_src_delWTD(vortex_t * vortex, unsigned char src, unsigned char ch)
700 int esp14 = -1, esp18, eax, ebx, edx, ebp, esi = 0;
701 //int esp1f=edi(while)=src, esp10=ch;
703 eax = hwread(vortex->mmio, VORTEX_SRCBLOCK_SR);
704 if (((1 << ch) & eax) == 0) {
705 printk(KERN_ERR "src alarm\n");
708 ebp = VORTEX_SRC_CHNBASE + (ch << 2);
709 esp18 = hwread(vortex->mmio, ebp);
713 ebx = VORTEX_SRC_RTBASE + (src << 2);
714 edx = hwread(vortex->mmio, ebx);
716 hwwrite(vortex->mmio, ebp, edx);
717 hwwrite(vortex->mmio, ebx, 0);
722 VORTEX_SRC_RTBASE + (ebx << 2));
723 //printk(KERN_INFO "vortex: srcdelWTD: 1 addr=%x, val=%x, src=%x\n", ebx, edx, src);
724 while ((edx & 0xf) != src) {
727 ("vortex: srcdelWTD: error, lifeboat overflow\n");
735 VORTEX_SRC_RTBASE + ebp);
736 //printk(KERN_INFO "vortex: srcdelWTD: while addr=%x, val=%x\n", ebp, edx);
741 if (edx & 0x10) { /* Delete entry in between others */
742 ebx = VORTEX_SRC_RTBASE + ((edx & 0xf) << 2);
743 edx = hwread(vortex->mmio, ebx);
745 hwwrite(vortex->mmio,
746 VORTEX_SRC_RTBASE + ebp, edx);
747 hwwrite(vortex->mmio, ebx, 0);
748 //printk(KERN_INFO "vortex srcdelWTD between addr= 0x%x, val= 0x%x\n", ebp, edx);
749 } else { /* Delete last entry */
752 hwwrite(vortex->mmio,
754 (ch << 2), esp18 & 0xef);
756 ebx = (0xffffffe0 & edx) | (0xf & ebx);
757 hwwrite(vortex->mmio,
760 //printk(KERN_INFO"vortex srcdelWTD last addr= 0x%x, val= 0x%x\n", esp14, ebx);
762 hwwrite(vortex->mmio,
763 VORTEX_SRC_RTBASE + ebp, 0);
769 vortex_src_dis_sr(vortex, ch);
770 hwwrite(vortex->mmio, ebp, 0);
776 vortex_fifo_clearadbdata(vortex_t * vortex, int fifo, int x)
778 for (x--; x >= 0; x--)
779 hwwrite(vortex->mmio,
780 VORTEX_FIFO_ADBDATA +
781 (((fifo << FIFO_SIZE_BITS) + x) << 2), 0);
785 static void vortex_fifo_adbinitialize(vortex_t * vortex, int fifo, int j)
787 vortex_fifo_clearadbdata(vortex, fifo, FIFO_SIZE);
789 hwwrite(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2),
790 (FIFO_U1 | ((j & FIFO_MASK) << 0xb)));
792 hwwrite(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2),
793 (FIFO_U1 | ((j & FIFO_MASK) << 0xc)));
797 static void vortex_fifo_setadbvalid(vortex_t * vortex, int fifo, int en)
799 hwwrite(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2),
800 (hwread(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2)) &
801 0xffffffef) | ((1 & en) << 4) | FIFO_U1);
805 vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int b, int priority,
806 int empty, int valid, int f)
808 int temp, lifeboat = 0;
809 //int this_8[NR_ADB] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* position */
811 /* f seems priority related.
812 * CAsp4AdbDma::SetPriority is the only place that calls SetAdbCtrl with f set to 1
813 * every where else it is set to 0. It seems, however, that CAsp4AdbDma::SetPriority
814 * is never called, thus the f related bits remain a mystery for now.
817 temp = hwread(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2));
818 if (lifeboat++ > 0xbb8) {
820 "Vortex: vortex_fifo_setadbctrl fail\n");
824 while (temp & FIFO_RDONLY);
826 // AU8830 semes to take some special care about fifo content (data).
827 // But i'm just to lazy to translate that :)
829 if ((temp & FIFO_VALID) == 0) {
831 vortex_fifo_clearadbdata(vortex, fifo, FIFO_SIZE); // this_4
833 temp = (this_4 & 0x1f) << 0xb;
835 temp = (this_4 & 0x3f) << 0xc;
837 temp = (temp & 0xfffffffd) | ((b & 1) << 1);
838 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
839 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
841 temp = (temp & 0xffffffdf) | ((empty & 1) << 5);
843 temp = (temp & 0xfffbffff) | ((f & 1) << 0x12);
846 temp = (temp & 0xf7ffffff) | ((f & 1) << 0x1b);
847 temp = (temp & 0xefffffff) | ((f & 1) << 0x1c);
850 temp = (temp & 0xfeffffff) | ((f & 1) << 0x18);
851 temp = (temp & 0xfdffffff) | ((f & 1) << 0x19);
855 if (temp & FIFO_VALID) {
857 temp = ((f & 1) << 0x12) | (temp & 0xfffbffef);
861 ((f & 1) << 0x1b) | (temp & 0xe7ffffef) | FIFO_BITS;
865 ((f & 1) << 0x18) | (temp & 0xfcffffef) | FIFO_BITS;
868 /*if (this_8[fifo]) */
869 vortex_fifo_clearadbdata(vortex, fifo, FIFO_SIZE);
871 hwwrite(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2), temp);
872 hwread(vortex->mmio, VORTEX_FIFO_ADBCTRL + (fifo << 2));
876 static void vortex_fifo_clearwtdata(vortex_t * vortex, int fifo, int x)
880 for (x--; x >= 0; x--)
881 hwwrite(vortex->mmio,
883 (((fifo << FIFO_SIZE_BITS) + x) << 2), 0);
886 static void vortex_fifo_wtinitialize(vortex_t * vortex, int fifo, int j)
888 vortex_fifo_clearwtdata(vortex, fifo, FIFO_SIZE);
890 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2),
891 (FIFO_U1 | ((j & FIFO_MASK) << 0xb)));
893 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2),
894 (FIFO_U1 | ((j & FIFO_MASK) << 0xc)));
898 static void vortex_fifo_setwtvalid(vortex_t * vortex, int fifo, int en)
900 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2),
901 (hwread(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2)) &
902 0xffffffef) | ((en & 1) << 4) | FIFO_U1);
906 vortex_fifo_setwtctrl(vortex_t * vortex, int fifo, int ctrl, int priority,
907 int empty, int valid, int f)
909 int temp = 0, lifeboat = 0;
913 temp = hwread(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2));
914 if (lifeboat++ > 0xbb8) {
915 printk(KERN_ERR "Vortex: vortex_fifo_setwtctrl fail\n");
919 while (temp & FIFO_RDONLY);
922 if ((temp & FIFO_VALID) == 0) {
923 vortex_fifo_clearwtdata(vortex, fifo, FIFO_SIZE); // this_4
925 temp = (this_4 & 0x1f) << 0xb;
927 temp = (this_4 & 0x3f) << 0xc;
929 temp = (temp & 0xfffffffd) | ((ctrl & 1) << 1);
930 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
931 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
933 temp = (temp & 0xffffffdf) | ((empty & 1) << 5);
935 temp = (temp & 0xfffbffff) | ((f & 1) << 0x12);
938 temp = (temp & 0xf7ffffff) | ((f & 1) << 0x1b);
939 temp = (temp & 0xefffffff) | ((f & 1) << 0x1c);
942 temp = (temp & 0xfeffffff) | ((f & 1) << 0x18);
943 temp = (temp & 0xfdffffff) | ((f & 1) << 0x19);
947 if (temp & FIFO_VALID) {
949 temp = ((f & 1) << 0x12) | (temp & 0xfffbffef);
953 ((f & 1) << 0x1b) | (temp & 0xe7ffffef) | FIFO_BITS;
957 ((f & 1) << 0x18) | (temp & 0xfcffffef) | FIFO_BITS;
960 /*if (this_8[fifo]) */
961 vortex_fifo_clearwtdata(vortex, fifo, FIFO_SIZE);
963 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2), temp);
964 hwread(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2));
968 temp = hwread(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2));
969 if (lifeboat++ > 0xbb8) {
970 printk(KERN_ERR "Vortex: vortex_fifo_setwtctrl fail (hanging)\n");
973 } while ((temp & FIFO_RDONLY)&&(temp & FIFO_VALID)&&(temp != 0xFFFFFFFF));
977 if (temp & FIFO_VALID) {
979 //temp |= 0x08000000;
980 //temp |= 0x10000000;
981 //temp |= 0x04000000;
982 //temp |= 0x00400000;
986 temp |= (valid & 1) << 4;
987 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2), temp);
990 vortex_fifo_clearwtdata(vortex, fifo, FIFO_SIZE);
999 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2), temp);
1000 temp = hwread(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2));
1001 //((temp >> 6) & 0x3f)
1004 if (((temp & 0x0fc0) ^ ((temp >> 6) & 0x0fc0)) & 0FFFFFFC0)
1005 vortex_fifo_clearwtdata(vortex, fifo, FIFO_SIZE);
1007 temp = (temp & 0xfffffffd) | ((ctrl & 1) << 1);
1008 temp = (temp & 0xfffdffff) | ((f & 1) << 0x11);
1009 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
1010 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
1011 temp = (temp & 0xffffffdf) | ((empty & 1) << 5);
1012 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2), temp);
1018 temp = (temp & 0xfffffffd) | ((ctrl & 1) << 1);
1019 temp = (temp & 0xfffdffff) | ((f & 1) << 0x11);
1020 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
1021 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
1022 temp = (temp & 0xffffffdf) | ((empty & 1) << 5);
1024 temp = temp | FIFO_BITS | 40000;
1026 // 0x1c440010, 0x1c400000
1027 hwwrite(vortex->mmio, VORTEX_FIFO_WTCTRL + (fifo << 2), temp);
1032 static void vortex_fifo_init(vortex_t * vortex)
1037 /* ADB DMA channels fifos. */
1038 addr = VORTEX_FIFO_ADBCTRL + ((NR_ADB - 1) * 4);
1039 for (x = NR_ADB - 1; x >= 0; x--) {
1040 hwwrite(vortex->mmio, addr, (FIFO_U0 | FIFO_U1));
1041 if (hwread(vortex->mmio, addr) != (FIFO_U0 | FIFO_U1))
1042 printk(KERN_ERR "bad adb fifo reset!");
1043 vortex_fifo_clearadbdata(vortex, x, FIFO_SIZE);
1048 /* WT DMA channels fifos. */
1049 addr = VORTEX_FIFO_WTCTRL + ((NR_WT - 1) * 4);
1050 for (x = NR_WT - 1; x >= 0; x--) {
1051 hwwrite(vortex->mmio, addr, FIFO_U0);
1052 if (hwread(vortex->mmio, addr) != FIFO_U0)
1054 "bad wt fifo reset (0x%08lx, 0x%08x)!\n",
1055 addr, hwread(vortex->mmio, addr));
1056 vortex_fifo_clearwtdata(vortex, x, FIFO_SIZE);
1062 hwwrite(vortex->mmio, 0xf8c0, 0xd03); //0x0843 0xd6b
1065 hwwrite(vortex->mmio, 0x17000, 0x61); /* wt a */
1066 hwwrite(vortex->mmio, 0x17004, 0x61); /* wt b */
1068 hwwrite(vortex->mmio, 0x17008, 0x61); /* adb */
1074 static void vortex_adbdma_init(vortex_t * vortex)
1078 static void vortex_adbdma_setfirstbuffer(vortex_t * vortex, int adbdma)
1080 stream_t *dma = &vortex->dma_adb[adbdma];
1082 hwwrite(vortex->mmio, VORTEX_ADBDMA_CTRL + (adbdma << 2),
1086 static void vortex_adbdma_setstartbuffer(vortex_t * vortex, int adbdma, int sb)
1088 stream_t *dma = &vortex->dma_adb[adbdma];
1089 //hwwrite(vortex->mmio, VORTEX_ADBDMA_START + (adbdma << 2), sb << (((NR_ADB-1)-((adbdma&0xf)*2))));
1090 hwwrite(vortex->mmio, VORTEX_ADBDMA_START + (adbdma << 2),
1091 sb << ((0xf - (adbdma & 0xf)) * 2));
1092 dma->period_real = dma->period_virt = sb;
1096 vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma,
1097 snd_pcm_sgbuf_t * sgbuf, int psize, int count)
1099 stream_t *dma = &vortex->dma_adb[adbdma];
1101 if (sgbuf == NULL) {
1102 printk(KERN_INFO "vortex: FATAL: sgbuf is NULL!\n");
1105 //printk(KERN_INFO "vortex: page count = %d, tblcount = %d\n", count, sgbuf->tblsize);
1107 dma->period_bytes = psize;
1108 dma->nr_periods = count;
1114 /* Four or more pages */
1117 dma->cfg1 |= 0x88000000 | 0x44000000 | 0x30000000 | (psize - 1);
1118 hwwrite(vortex->mmio,
1119 VORTEX_ADBDMA_BUFBASE + (adbdma << 4) + 0xc,
1120 snd_sgbuf_get_addr(sgbuf, psize * 3));
1123 dma->cfg0 |= 0x12000000;
1124 dma->cfg1 |= 0x80000000 | 0x40000000 | ((psize - 1) << 0xc);
1125 hwwrite(vortex->mmio,
1126 VORTEX_ADBDMA_BUFBASE + (adbdma << 4) + 0x8,
1127 snd_sgbuf_get_addr(sgbuf, psize * 2));
1130 dma->cfg0 |= 0x88000000 | 0x44000000 | 0x10000000 | (psize - 1);
1131 hwwrite(vortex->mmio,
1132 VORTEX_ADBDMA_BUFBASE + (adbdma << 4) + 0x4,
1133 snd_sgbuf_get_addr(sgbuf, psize));
1136 dma->cfg0 |= 0x80000000 | 0x40000000 | ((psize - 1) << 0xc);
1137 hwwrite(vortex->mmio,
1138 VORTEX_ADBDMA_BUFBASE + (adbdma << 4),
1139 snd_sgbuf_get_addr(sgbuf, 0));
1142 //printk("vortex: cfg0 = 0x%x\nvortex: cfg1=0x%x\n", dma->cfg0, dma->cfg1);
1143 hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG0 + (adbdma << 3), dma->cfg0);
1144 hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG1 + (adbdma << 3), dma->cfg1);
1146 vortex_adbdma_setfirstbuffer(vortex, adbdma);
1147 vortex_adbdma_setstartbuffer(vortex, adbdma, 0);
1151 vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, int dir,
1152 int fmt, int d, unsigned long offset)
1154 stream_t *dma = &vortex->dma_adb[adbdma];
1156 dma->dma_unknown = d;
1158 ((offset & OFFSET_MASK) | (dma->dma_ctrl & ~OFFSET_MASK));
1159 /* Enable PCMOUT interrupts. */
1161 (dma->dma_ctrl & ~IE_MASK) | ((ie << IE_SHIFT) & IE_MASK);
1164 (dma->dma_ctrl & ~DIR_MASK) | ((dir << DIR_SHIFT) & DIR_MASK);
1166 (dma->dma_ctrl & ~FMT_MASK) | ((fmt << FMT_SHIFT) & FMT_MASK);
1168 hwwrite(vortex->mmio, VORTEX_ADBDMA_CTRL + (adbdma << 2),
1170 hwread(vortex->mmio, VORTEX_ADBDMA_CTRL + (adbdma << 2));
1173 static int vortex_adbdma_bufshift(vortex_t * vortex, int adbdma)
1175 stream_t *dma = &vortex->dma_adb[adbdma];
1176 int page, p, pp, delta, i;
1179 (hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)) &
1180 ADB_SUBBUF_MASK) >> ADB_SUBBUF_SHIFT;
1181 if (dma->nr_periods >= 4)
1182 delta = (page - dma->period_real) & 3;
1184 delta = (page - dma->period_real);
1186 delta += dma->nr_periods;
1191 /* refresh hw page table */
1192 if (dma->nr_periods > 4) {
1193 for (i = 0; i < delta; i++) {
1194 /* p: audio buffer page index */
1195 p = dma->period_virt + i + 4;
1196 if (p >= dma->nr_periods)
1197 p -= dma->nr_periods;
1198 /* pp: hardware DMA page index. */
1199 pp = dma->period_real + i;
1202 //hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE+(((adbdma << 2)+pp) << 2), dma->table[p].addr);
1203 hwwrite(vortex->mmio,
1204 VORTEX_ADBDMA_BUFBASE + (((adbdma << 2) + pp) << 2),
1205 snd_sgbuf_get_addr(dma->sgbuf,
1206 dma->period_bytes * p));
1207 /* Force write thru cache. */
1208 hwread(vortex->mmio, VORTEX_ADBDMA_BUFBASE +
1209 (((adbdma << 2) + pp) << 2));
1212 dma->period_virt += delta;
1213 dma->period_real = page;
1214 if (dma->period_virt >= dma->nr_periods)
1215 dma->period_virt -= dma->nr_periods;
1217 printk(KERN_INFO "vortex: %d virt=%d, real=%d, delta=%d\n",
1218 adbdma, dma->period_virt, dma->period_real, delta);
1223 static int inline vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma)
1225 stream_t *dma = &vortex->dma_adb[adbdma];
1228 temp = hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2));
1229 temp = (dma->period_virt * dma->period_bytes) + (temp & POS_MASK);
1233 static void vortex_adbdma_startfifo(vortex_t * vortex, int adbdma)
1235 int this_8 = 0 /*empty */ , this_4 = 0 /*priority */ ;
1236 stream_t *dma = &vortex->dma_adb[adbdma];
1238 switch (dma->fifo_status) {
1240 vortex_fifo_setadbvalid(vortex, adbdma,
1241 dma->fifo_enabled ? 1 : 0);
1245 hwwrite(vortex->mmio, VORTEX_ADBDMA_CTRL + (adbdma << 2),
1247 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1249 dma->fifo_enabled ? 1 : 0, 0);
1252 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1254 dma->fifo_enabled ? 1 : 0, 0);
1257 dma->fifo_status = FIFO_START;
1260 static void vortex_adbdma_resumefifo(vortex_t * vortex, int adbdma)
1262 stream_t *dma = &vortex->dma_adb[adbdma];
1264 int this_8 = 1, this_4 = 0;
1265 switch (dma->fifo_status) {
1267 hwwrite(vortex->mmio, VORTEX_ADBDMA_CTRL + (adbdma << 2),
1269 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1271 dma->fifo_enabled ? 1 : 0, 0);
1274 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1276 dma->fifo_enabled ? 1 : 0, 0);
1279 dma->fifo_status = FIFO_START;
1282 static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma)
1284 stream_t *dma = &vortex->dma_adb[adbdma];
1286 int this_8 = 0, this_4 = 0;
1287 switch (dma->fifo_status) {
1289 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1290 this_4, this_8, 0, 0);
1293 hwwrite(vortex->mmio, VORTEX_ADBDMA_CTRL + (adbdma << 2),
1295 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1296 this_4, this_8, 0, 0);
1299 dma->fifo_status = FIFO_PAUSE;
1302 #if 0 // Using pause instead
1303 static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma)
1305 stream_t *dma = &vortex->dma_adb[adbdma];
1307 int this_4 = 0, this_8 = 0;
1308 if (dma->fifo_status == FIFO_START)
1309 vortex_fifo_setadbctrl(vortex, adbdma, dma->dma_unknown,
1310 this_4, this_8, 0, 0);
1311 else if (dma->fifo_status == FIFO_STOP)
1313 dma->fifo_status = FIFO_STOP;
1314 dma->fifo_enabled = 0;
1321 static void vortex_wtdma_setfirstbuffer(vortex_t * vortex, int wtdma)
1323 //int this_7c=dma_ctrl;
1324 stream_t *dma = &vortex->dma_wt[wtdma];
1326 hwwrite(vortex->mmio, VORTEX_WTDMA_CTRL + (wtdma << 2), dma->dma_ctrl);
1329 static void vortex_wtdma_setstartbuffer(vortex_t * vortex, int wtdma, int sb)
1331 stream_t *dma = &vortex->dma_wt[wtdma];
1332 //hwwrite(vortex->mmio, VORTEX_WTDMA_START + (wtdma << 2), sb << ((0x1f-(wtdma&0xf)*2)));
1333 hwwrite(vortex->mmio, VORTEX_WTDMA_START + (wtdma << 2),
1334 sb << ((0xf - (wtdma & 0xf)) * 2));
1335 dma->period_real = dma->period_virt = sb;
1339 vortex_wtdma_setbuffers(vortex_t * vortex, int wtdma,
1340 snd_pcm_sgbuf_t * sgbuf, int psize, int count)
1342 stream_t *dma = &vortex->dma_wt[wtdma];
1344 dma->period_bytes = psize;
1345 dma->nr_periods = count;
1353 /* Four or more pages */
1356 dma->cfg1 |= 0x88000000 | 0x44000000 | 0x30000000 | psize;
1357 hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4),
1358 snd_sgbuf_get_addr(sgbuf, psize * 3));
1361 dma->cfg0 |= 0x12000000;
1362 dma->cfg1 |= 0x80000000 | 0x40000000 | (psize << 0xc);
1363 hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4),
1364 snd_sgbuf_get_addr(sgbuf, psize * 2));
1367 dma->cfg0 |= 0x88000000 | 0x44000000 | 0x10000000 | psize;
1368 hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4),
1369 snd_sgbuf_get_addr(sgbuf, psize));
1372 dma->cfg0 |= 0x80000000 | 0x40000000 | (psize << 0xc);
1373 hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4),
1374 snd_sgbuf_get_addr(sgbuf, 0));
1377 hwwrite(vortex->mmio, VORTEX_WTDMA_BUFCFG0 + (wtdma << 3), dma->cfg0);
1378 hwwrite(vortex->mmio, VORTEX_WTDMA_BUFCFG1 + (wtdma << 3), dma->cfg1);
1380 vortex_wtdma_setfirstbuffer(vortex, wtdma);
1381 vortex_wtdma_setstartbuffer(vortex, wtdma, 0);
1385 vortex_wtdma_setmode(vortex_t * vortex, int wtdma, int ie, int fmt, int d,
1386 /*int e, */ unsigned long offset)
1388 stream_t *dma = &vortex->dma_wt[wtdma];
1391 dma->dma_unknown = d;
1394 ((offset & OFFSET_MASK) | (dma->dma_ctrl & ~OFFSET_MASK));
1395 /* PCMOUT interrupt */
1397 (dma->dma_ctrl & ~IE_MASK) | ((ie << IE_SHIFT) & IE_MASK);
1398 /* Always playback. */
1399 dma->dma_ctrl |= (1 << DIR_SHIFT);
1402 (dma->dma_ctrl & FMT_MASK) | ((fmt << FMT_SHIFT) & FMT_MASK);
1403 /* Write into hardware */
1404 hwwrite(vortex->mmio, VORTEX_WTDMA_CTRL + (wtdma << 2), dma->dma_ctrl);
1407 static int vortex_wtdma_bufshift(vortex_t * vortex, int wtdma)
1409 stream_t *dma = &vortex->dma_wt[wtdma];
1410 int page, p, pp, delta, i;
1413 (hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)) &
1416 if (dma->nr_periods >= 4)
1417 delta = (page - dma->period_real) & 3;
1419 delta = (page - dma->period_real);
1421 delta += dma->nr_periods;
1426 /* refresh hw page table */
1427 if (dma->nr_periods > 4) {
1428 for (i = 0; i < delta; i++) {
1429 /* p: audio buffer page index */
1430 p = dma->period_virt + i + 4;
1431 if (p >= dma->nr_periods)
1432 p -= dma->nr_periods;
1433 /* pp: hardware DMA page index. */
1434 pp = dma->period_real + i;
1437 hwwrite(vortex->mmio,
1438 VORTEX_WTDMA_BUFBASE +
1439 (((wtdma << 2) + pp) << 2),
1440 snd_sgbuf_get_addr(dma->sgbuf, dma->period_bytes * p));
1441 /* Force write thru cache. */
1442 hwread(vortex->mmio, VORTEX_WTDMA_BUFBASE +
1443 (((wtdma << 2) + pp) << 2));
1446 dma->period_virt += delta;
1447 if (dma->period_virt >= dma->nr_periods)
1448 dma->period_virt -= dma->nr_periods;
1449 dma->period_real = page;
1452 printk(KERN_WARNING "vortex: wt virt = %d, delta = %d\n",
1453 dma->period_virt, delta);
1460 vortex_wtdma_getposition(vortex_t * vortex, int wtdma, int *subbuf, int *pos)
1463 temp = hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2));
1464 *subbuf = (temp >> WT_SUBBUF_SHIFT) & WT_SUBBUF_MASK;
1465 *pos = temp & POS_MASK;
1468 static int vortex_wtdma_getcursubuffer(vortex_t * vortex, int wtdma)
1470 return ((hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)) >>
1471 POS_SHIFT) & POS_MASK);
1474 static int inline vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma)
1476 stream_t *dma = &vortex->dma_wt[wtdma];
1479 temp = hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2));
1480 //temp = (temp & POS_MASK) + (((temp>>WT_SUBBUF_SHIFT) & WT_SUBBUF_MASK)*(dma->cfg0&POS_MASK));
1481 temp = (temp & POS_MASK) + ((dma->period_virt) * (dma->period_bytes));
1485 static void vortex_wtdma_startfifo(vortex_t * vortex, int wtdma)
1487 stream_t *dma = &vortex->dma_wt[wtdma];
1488 int this_8 = 0, this_4 = 0;
1490 switch (dma->fifo_status) {
1492 vortex_fifo_setwtvalid(vortex, wtdma,
1493 dma->fifo_enabled ? 1 : 0);
1497 hwwrite(vortex->mmio, VORTEX_WTDMA_CTRL + (wtdma << 2),
1499 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1501 dma->fifo_enabled ? 1 : 0, 0);
1504 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1506 dma->fifo_enabled ? 1 : 0, 0);
1509 dma->fifo_status = FIFO_START;
1512 static void vortex_wtdma_resumefifo(vortex_t * vortex, int wtdma)
1514 stream_t *dma = &vortex->dma_wt[wtdma];
1516 int this_8 = 0, this_4 = 0;
1517 switch (dma->fifo_status) {
1519 hwwrite(vortex->mmio, VORTEX_WTDMA_CTRL + (wtdma << 2),
1521 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1523 dma->fifo_enabled ? 1 : 0, 0);
1526 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1528 dma->fifo_enabled ? 1 : 0, 0);
1531 dma->fifo_status = FIFO_START;
1534 static void vortex_wtdma_pausefifo(vortex_t * vortex, int wtdma)
1536 stream_t *dma = &vortex->dma_wt[wtdma];
1538 int this_8 = 0, this_4 = 0;
1539 switch (dma->fifo_status) {
1541 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1542 this_4, this_8, 0, 0);
1545 hwwrite(vortex->mmio, VORTEX_WTDMA_CTRL + (wtdma << 2),
1547 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1548 this_4, this_8, 0, 0);
1551 dma->fifo_status = FIFO_PAUSE;
1554 static void vortex_wtdma_stopfifo(vortex_t * vortex, int wtdma)
1556 stream_t *dma = &vortex->dma_wt[wtdma];
1558 int this_4 = 0, this_8 = 0;
1559 if (dma->fifo_status == FIFO_START)
1560 vortex_fifo_setwtctrl(vortex, wtdma, dma->dma_unknown,
1561 this_4, this_8, 0, 0);
1562 else if (dma->fifo_status == FIFO_STOP)
1564 dma->fifo_status = FIFO_STOP;
1565 dma->fifo_enabled = 0;
1571 typedef int ADBRamLink;
1572 static void vortex_adb_init(vortex_t * vortex)
1575 /* it looks like we are writing more than we need to...
1576 * if we write what we are supposed to it breaks things... */
1577 hwwrite(vortex->mmio, VORTEX_ADB_SR, 0);
1578 for (i = 0; i < VORTEX_ADB_RTBASE_SIZE; i++)
1579 hwwrite(vortex->mmio, VORTEX_ADB_RTBASE + (i << 2),
1580 hwread(vortex->mmio,
1581 VORTEX_ADB_RTBASE + (i << 2)) | ROUTE_MASK);
1582 for (i = 0; i < VORTEX_ADB_CHNBASE_SIZE; i++) {
1583 hwwrite(vortex->mmio, VORTEX_ADB_CHNBASE + (i << 2),
1584 hwread(vortex->mmio,
1585 VORTEX_ADB_CHNBASE + (i << 2)) | ROUTE_MASK);
1589 static void vortex_adb_en_sr(vortex_t * vortex, int channel)
1591 hwwrite(vortex->mmio, VORTEX_ADB_SR,
1592 hwread(vortex->mmio, VORTEX_ADB_SR) | (0x1 << channel));
1595 static void vortex_adb_dis_sr(vortex_t * vortex, int channel)
1597 hwwrite(vortex->mmio, VORTEX_ADB_SR,
1598 hwread(vortex->mmio, VORTEX_ADB_SR) & ~(0x1 << channel));
1602 vortex_adb_addroutes(vortex_t * vortex, unsigned char channel,
1603 ADBRamLink * route, int rnum)
1605 int temp, prev, lifeboat = 0;
1607 if ((rnum <= 0) || (route == NULL))
1609 /* Write last routes. */
1611 hwwrite(vortex->mmio,
1612 VORTEX_ADB_RTBASE + ((route[rnum] & ADB_MASK) << 2),
1615 hwwrite(vortex->mmio,
1617 ((route[rnum - 1] & ADB_MASK) << 2), route[rnum]);
1620 /* Write first route. */
1622 hwread(vortex->mmio,
1623 VORTEX_ADB_CHNBASE + (channel << 2)) & ADB_MASK;
1624 if (temp == ADB_MASK) {
1625 /* First entry on this channel. */
1626 hwwrite(vortex->mmio, VORTEX_ADB_CHNBASE + (channel << 2),
1628 vortex_adb_en_sr(vortex, channel);
1631 /* Not first entry on this channel. Need to link. */
1635 hwread(vortex->mmio,
1636 VORTEX_ADB_RTBASE + (temp << 2)) & ADB_MASK;
1637 if ((lifeboat++) > ADB_MASK) {
1639 "vortex_adb_addroutes: unending route! 0x%x\n",
1644 while (temp != ADB_MASK);
1645 hwwrite(vortex->mmio, VORTEX_ADB_RTBASE + (prev << 2), route[0]);
1649 vortex_adb_delroutes(vortex_t * vortex, unsigned char channel,
1650 ADBRamLink route0, ADBRamLink route1)
1652 int temp, lifeboat = 0, prev;
1656 hwread(vortex->mmio,
1657 VORTEX_ADB_CHNBASE + (channel << 2)) & ADB_MASK;
1658 if (temp == (route0 & ADB_MASK)) {
1660 hwread(vortex->mmio,
1661 VORTEX_ADB_RTBASE + ((route1 & ADB_MASK) << 2));
1662 if ((temp & ADB_MASK) == ADB_MASK)
1663 vortex_adb_dis_sr(vortex, channel);
1664 hwwrite(vortex->mmio, VORTEX_ADB_CHNBASE + (channel << 2),
1671 hwread(vortex->mmio,
1672 VORTEX_ADB_RTBASE + (prev << 2)) & ADB_MASK;
1673 if (((lifeboat++) > ADB_MASK) || (temp == ADB_MASK)) {
1675 "vortex_adb_delroutes: route not found! 0x%x\n",
1680 while (temp != (route0 & ADB_MASK));
1681 temp = hwread(vortex->mmio, VORTEX_ADB_RTBASE + (temp << 2));
1682 if ((temp & ADB_MASK) == route1)
1683 temp = hwread(vortex->mmio, VORTEX_ADB_RTBASE + (temp << 2));
1684 /* Make bridge over deleted route. */
1685 hwwrite(vortex->mmio, VORTEX_ADB_RTBASE + (prev << 2), temp);
1689 vortex_route(vortex_t * vortex, int en, unsigned char channel,
1690 unsigned char source, unsigned char dest)
1694 route = ((source & ADB_MASK) << ADB_SHIFT) | (dest & ADB_MASK);
1696 vortex_adb_addroutes(vortex, channel, &route, 1);
1697 if ((source < (OFFSET_SRCOUT + NR_SRC))
1698 && (source >= OFFSET_SRCOUT))
1699 vortex_src_addWTD(vortex, (source - OFFSET_SRCOUT),
1701 else if ((source < (OFFSET_MIXOUT + NR_MIXOUT))
1702 && (source >= OFFSET_MIXOUT))
1703 vortex_mixer_addWTD(vortex,
1704 (source - OFFSET_MIXOUT), channel);
1706 vortex_adb_delroutes(vortex, channel, route, route);
1707 if ((source < (OFFSET_SRCOUT + NR_SRC))
1708 && (source >= OFFSET_SRCOUT))
1709 vortex_src_delWTD(vortex, (source - OFFSET_SRCOUT),
1711 else if ((source < (OFFSET_MIXOUT + NR_MIXOUT))
1712 && (source >= OFFSET_MIXOUT))
1713 vortex_mixer_delWTD(vortex,
1714 (source - OFFSET_MIXOUT), channel);
1720 vortex_routes(vortex_t * vortex, int en, unsigned char channel,
1721 unsigned char source, unsigned char dest0, unsigned char dest1)
1723 ADBRamLink route[2];
1725 route[0] = ((source & ADB_MASK) << ADB_SHIFT) | (dest0 & ADB_MASK);
1726 route[1] = ((source & ADB_MASK) << ADB_SHIFT) | (dest1 & ADB_MASK);
1729 vortex_adb_addroutes(vortex, channel, route, 2);
1730 if ((source < (OFFSET_SRCOUT + NR_SRC))
1731 && (source >= (OFFSET_SRCOUT)))
1732 vortex_src_addWTD(vortex, (source - OFFSET_SRCOUT),
1734 else if ((source < (OFFSET_MIXOUT + NR_MIXOUT))
1735 && (source >= (OFFSET_MIXOUT)))
1736 vortex_mixer_addWTD(vortex,
1737 (source - OFFSET_MIXOUT), channel);
1739 vortex_adb_delroutes(vortex, channel, route[0], route[1]);
1740 if ((source < (OFFSET_SRCOUT + NR_SRC))
1741 && (source >= (OFFSET_SRCOUT)))
1742 vortex_src_delWTD(vortex, (source - OFFSET_SRCOUT),
1744 else if ((source < (OFFSET_MIXOUT + NR_MIXOUT))
1745 && (source >= (OFFSET_MIXOUT)))
1746 vortex_mixer_delWTD(vortex,
1747 (source - OFFSET_MIXOUT), channel);
1752 /* Route two sources to same target. Sources must be of same class !!! */
1754 vortex_routeLRT(vortex_t * vortex, int en, unsigned char ch,
1755 unsigned char source0, unsigned char source1,
1758 ADBRamLink route[2];
1760 route[0] = ((source0 & ADB_MASK) << ADB_SHIFT) | (dest & ADB_MASK);
1761 route[1] = ((source1 & ADB_MASK) << ADB_SHIFT) | (dest & ADB_MASK);
1764 route[1] = (route[1] & ~ADB_MASK) | (dest + 0x20); /* fifo A */
1767 vortex_adb_addroutes(vortex, ch, route, 2);
1768 if ((source0 < (OFFSET_SRCOUT + NR_SRC))
1769 && (source0 >= OFFSET_SRCOUT)) {
1770 vortex_src_addWTD(vortex,
1771 (source0 - OFFSET_SRCOUT), ch);
1772 vortex_src_addWTD(vortex,
1773 (source1 - OFFSET_SRCOUT), ch);
1774 } else if ((source0 < (OFFSET_MIXOUT + NR_MIXOUT))
1775 && (source0 >= OFFSET_MIXOUT)) {
1776 vortex_mixer_addWTD(vortex,
1777 (source0 - OFFSET_MIXOUT), ch);
1778 vortex_mixer_addWTD(vortex,
1779 (source1 - OFFSET_MIXOUT), ch);
1782 vortex_adb_delroutes(vortex, ch, route[0], route[1]);
1783 if ((source0 < (OFFSET_SRCOUT + NR_SRC))
1784 && (source0 >= OFFSET_SRCOUT)) {
1785 vortex_src_delWTD(vortex,
1786 (source0 - OFFSET_SRCOUT), ch);
1787 vortex_src_delWTD(vortex,
1788 (source1 - OFFSET_SRCOUT), ch);
1789 } else if ((source0 < (OFFSET_MIXOUT + NR_MIXOUT))
1790 && (source0 >= OFFSET_MIXOUT)) {
1791 vortex_mixer_delWTD(vortex,
1792 (source0 - OFFSET_MIXOUT), ch);
1793 vortex_mixer_delWTD(vortex,
1794 (source1 - OFFSET_MIXOUT), ch);
1799 /* Connection stuff */
1801 // Connect adbdma to src('s).
1803 vortex_connection_adbdma_src(vortex_t * vortex, int en, unsigned char ch,
1804 unsigned char adbdma, unsigned char src)
1806 vortex_route(vortex, en, ch, ADB_DMA(adbdma), ADB_SRCIN(src));
1809 // Connect SRC to mixin.
1811 vortex_connection_src_mixin(vortex_t * vortex, int en,
1812 unsigned char channel, unsigned char src,
1813 unsigned char mixin)
1815 vortex_route(vortex, en, channel, ADB_SRCOUT(src), ADB_MIXIN(mixin));
1818 // Connect mixin with mix output.
1820 vortex_connection_mixin_mix(vortex_t * vortex, int en, unsigned char mixin,
1821 unsigned char mix, int a)
1824 vortex_mix_enableinput(vortex, mix, mixin);
1825 vortex_mix_setinputvolumebyte(vortex, mix, mixin, MIX_DEFIGAIN); // added to original code.
1827 vortex_mix_disableinput(vortex, mix, mixin, a);
1830 // Connect absolut address to mixin.
1832 vortex_connection_adb_mixin(vortex_t * vortex, int en,
1833 unsigned char channel, unsigned char source,
1834 unsigned char mixin)
1836 vortex_route(vortex, en, channel, source, ADB_MIXIN(mixin));
1840 vortex_connection_src_adbdma(vortex_t * vortex, int en, unsigned char ch,
1841 unsigned char src, unsigned char adbdma)
1843 vortex_route(vortex, en, ch, ADB_SRCOUT(src), ADB_DMA(adbdma));
1847 vortex_connection_src_src_adbdma(vortex_t * vortex, int en,
1848 unsigned char ch, unsigned char src0,
1849 unsigned char src1, unsigned char adbdma)
1852 vortex_routeLRT(vortex, en, ch, ADB_SRCOUT(src0), ADB_SRCOUT(src1),
1856 // mix to absolut address.
1858 vortex_connection_mix_adb(vortex_t * vortex, int en, unsigned char ch,
1859 unsigned char mix, unsigned char dest)
1861 vortex_route(vortex, en, ch, ADB_MIXOUT(mix), dest);
1862 vortex_mix_setvolumebyte(vortex, mix, MIX_DEFOGAIN); // added to original code.
1867 vortex_connection_mix_src(vortex_t * vortex, int en, unsigned char ch,
1868 unsigned char mix, unsigned char src)
1870 vortex_route(vortex, en, ch, ADB_MIXOUT(mix), ADB_SRCIN(src));
1871 vortex_mix_setvolumebyte(vortex, mix, MIX_DEFOGAIN); // added to original code.
1876 vortex_connection_adbdma_src_src(vortex_t * vortex, int en,
1877 unsigned char channel,
1878 unsigned char adbdma, unsigned char src0,
1881 vortex_routes(vortex, en, channel, ADB_DMA(adbdma),
1882 ADB_SRCIN(src0), ADB_SRCIN(src1));
1885 // Connect two mix to AdbDma.
1887 vortex_connection_mix_mix_adbdma(vortex_t * vortex, int en,
1888 unsigned char ch, unsigned char mix0,
1889 unsigned char mix1, unsigned char adbdma)
1892 ADBRamLink routes[2];
1895 OFFSET_MIXOUT) & ADB_MASK) << ADB_SHIFT) | (adbdma & ADB_MASK);
1897 (((mix1 + OFFSET_MIXOUT) & ADB_MASK) << ADB_SHIFT) | ((adbdma +
1901 vortex_adb_addroutes(vortex, ch, routes, 0x2);
1902 vortex_mixer_addWTD(vortex, mix0, ch);
1903 vortex_mixer_addWTD(vortex, mix1, ch);
1905 vortex_adb_delroutes(vortex, ch, routes[0], routes[1]);
1906 vortex_mixer_delWTD(vortex, mix0, ch);
1907 vortex_mixer_delWTD(vortex, mix1, ch);
1912 /* CODEC connect. */
1915 vortex_connect_codecplay(vortex_t * vortex, int en, unsigned char mixers[])
1918 vortex_connection_mix_adb(vortex, en, 0x11, mixers[0], ADB_CODECOUT(0));
1919 vortex_connection_mix_adb(vortex, en, 0x11, mixers[1], ADB_CODECOUT(1));
1922 // Connect front channels through EQ.
1923 vortex_connection_mix_adb(vortex, en, 0x11, mixers[0], ADB_EQIN(0));
1924 vortex_connection_mix_adb(vortex, en, 0x11, mixers[1], ADB_EQIN(1));
1925 vortex_route(vortex, en, 0x11, ADB_EQOUT(0), ADB_CODECOUT(0));
1926 vortex_route(vortex, en, 0x11, ADB_EQOUT(1), ADB_CODECOUT(1));
1928 /* Check if reg 0x28 has SDAC bit set. */
1929 if (VORTEX_IS_QUAD(vortex)) {
1930 /* Rear channel. Note: ADB_CODECOUT(0+2) and (1+2) is for AC97 modem */
1931 vortex_connection_mix_adb(vortex, en, 0x11, mixers[2],
1932 ADB_CODECOUT(0 + 4));
1933 vortex_connection_mix_adb(vortex, en, 0x11, mixers[3],
1934 ADB_CODECOUT(1 + 4));
1935 //printk("SDAC detected ");
1938 // Use plain direct output to codec.
1939 vortex_connection_mix_adb(vortex, en, 0x11, mixers[0], ADB_CODECOUT(0));
1940 vortex_connection_mix_adb(vortex, en, 0x11, mixers[1], ADB_CODECOUT(1));
1946 vortex_connect_codecrec(vortex_t * vortex, int en, unsigned char mixin0,
1947 unsigned char mixin1)
1952 ADB Source address: 0x48, 0x49
1953 Destination Asp4Topology_0x9c,0x98
1955 vortex_connection_adb_mixin(vortex, en, 0x11, ADB_CODECIN(0), mixin0);
1956 vortex_connection_adb_mixin(vortex, en, 0x11, ADB_CODECIN(1), mixin1);
1959 // Higher level ADB audio path (de)allocator.
1961 /* Resource manager */
1962 static int resnum[VORTEX_RESOURCE_LAST] =
1963 { NR_ADB, NR_SRC, NR_MIXIN, NR_MIXOUT, NR_A3D };
1965 Checkout/Checkin resource of given type.
1966 resmap: resource map to be used. If NULL means that we want to allocate
1967 a DMA resource (root of all other resources of a dma channel).
1968 out: Mean checkout if != 0. Else mean Checkin resource.
1969 restype: Indicates type of resource to be checked in or out.
1972 vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out, int restype)
1974 int i, qty = resnum[restype], resinuse = 0;
1977 /* Gather used resources by all streams. */
1978 for (i = 0; i < NR_ADB; i++) {
1979 resinuse |= vortex->dma_adb[i].resources[restype];
1981 resinuse |= vortex->fixed_res[restype];
1982 /* Find and take free resource. */
1983 for (i = 0; i < qty; i++) {
1984 if ((resinuse & (1 << i)) == 0) {
1986 resmap[restype] |= (1 << i);
1988 vortex->dma_adb[i].resources[restype] |= (1 << i);
1989 //printk("vortex: ResManager: type %d out %d\n", restype, i);
1996 /* Checkin first resource of type restype. */
1997 for (i = 0; i < qty; i++) {
1998 if (resmap[restype] & (1 << i)) {
1999 resmap[restype] &= ~(1 << i);
2000 //printk("vortex: ResManager: type %d in %d\n",restype, i);
2005 printk("vortex: FATAL: ResManager: resource type %d exhausted.\n", restype);
2009 /* Default Connections */
2010 static void vortex_connect_default(vortex_t * vortex, int en)
2012 // FIXME: check if checkout was succesful.
2013 // Connect AC97 codec.
2014 vortex->mixplayb[0] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2015 VORTEX_RESOURCE_MIXOUT);
2016 vortex->mixplayb[1] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2017 VORTEX_RESOURCE_MIXOUT);
2018 if (VORTEX_IS_QUAD(vortex)) {
2019 vortex->mixplayb[2] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2020 VORTEX_RESOURCE_MIXOUT);
2021 vortex->mixplayb[3] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2022 VORTEX_RESOURCE_MIXOUT);
2024 vortex_connect_codecplay(vortex, en, vortex->mixplayb);
2026 vortex->mixcapt[0] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2027 VORTEX_RESOURCE_MIXIN);
2028 vortex->mixcapt[1] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2029 VORTEX_RESOURCE_MIXIN);
2030 vortex_connect_codecrec(vortex, en, MIX_CAPT(0), MIX_CAPT(1));
2034 vortex->mixspdif[0] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2035 VORTEX_RESOURCE_MIXOUT);
2036 vortex->mixspdif[1] = vortex_adb_checkinout(vortex, vortex->fixed_res, en,
2037 VORTEX_RESOURCE_MIXOUT);
2038 vortex_connection_mix_adb(vortex, en, 0x14, vortex->mixspdif[0],
2040 vortex_connection_mix_adb(vortex, en, 0x14, vortex->mixspdif[1],
2045 vortex_wt_connect(vortex, en);
2047 // A3D (crosstalk canceler and A3D slices).
2049 vortex_Vort3D_connect(vortex, en);
2053 // Connect DSP interface for SQ3500 turbo (not here i think...)
2055 // Connect AC98 modem codec
2057 /* Fast Play Workaround. Revision 0xFE does not seem to need it. */
2058 printk(KERN_INFO "vortex: revision = 0x%x, device = %d\n", vortex->rev, vortex->device);
2059 if (IS_BAD_CHIP(vortex)) {
2060 printk(KERN_INFO "vortex: Erratum workaround enabled.\n");
2062 vortex->fixed_res[VORTEX_RESOURCE_DMA] = 0x00000001;
2064 // Channel swapping workaround. We are nuking registers somewhere, or
2065 // its a hardware bug.
2066 vortex->fixed_res[VORTEX_RESOURCE_SRC] = 0x00000001;
2071 Allocate nr_ch pcm audio routes if dma < 0. If dma >= 0, existing routes
2073 dma: DMA engine routes to be deallocated when dma >= 0.
2074 nr_ch: Number of channels to be de/allocated.
2075 dir: direction of stream. Uses same values as substream->stream.
2076 type: Type of audio output/source (codec, spdif, i2s, dsp, etc)
2077 Return: Return allocated DMA or same DMA passed as "dma" when dma >= 0.
2080 vortex_adb_allocroute(vortex_t * vortex, int dma, int nr_ch, int dir, int type)
2086 || ((dir == SNDRV_PCM_STREAM_CAPTURE) && (nr_ch > 2)))
2089 spin_lock(&vortex->lock);
2092 vortex_adb_checkinout(vortex,
2093 vortex->dma_adb[dma].resources, en,
2094 VORTEX_RESOURCE_DMA);
2098 vortex_adb_checkinout(vortex, NULL, en,
2099 VORTEX_RESOURCE_DMA)) < 0)
2103 stream = &vortex->dma_adb[dma];
2106 stream->type = type;
2108 // FIXME: check for success of checkout or checkin.
2109 /* PLAYBACK ROUTES. */
2110 if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2111 int src[4], mix[4], ch_top;
2115 /* Get SRC and MIXER hardware resources. */
2116 if (stream->type != VORTEX_PCM_SPDIF) {
2117 for (i = 0; i < nr_ch; i++) {
2118 if ((src[i] = vortex_adb_checkinout(vortex,
2119 stream->resources, en,
2120 VORTEX_RESOURCE_SRC)) < 0) {
2121 memset(stream->resources, 0,
2122 sizeof(unsigned char) *
2123 VORTEX_RESOURCE_LAST);
2126 if (stream->type != VORTEX_PCM_A3D) {
2127 if ((mix[i] = vortex_adb_checkinout(vortex,
2130 VORTEX_RESOURCE_MIXIN)) < 0) {
2131 memset(stream->resources,
2133 sizeof(unsigned char) * VORTEX_RESOURCE_LAST);
2140 if (stream->type == VORTEX_PCM_A3D) {
2142 vortex_adb_checkinout(vortex,
2143 stream->resources, en,
2144 VORTEX_RESOURCE_A3D)) < 0) {
2145 memset(stream->resources, 0,
2146 sizeof(unsigned char) *
2147 VORTEX_RESOURCE_LAST);
2148 printk("vortex: out of A3D sources. Sorry\n");
2151 /* (De)Initialize A3D hardware source. */
2152 vortex_Vort3D_InitializeSource(&(vortex->a3d[a3d]), en);
2154 /* Make SPDIF out exclusive to "spdif" device when in use. */
2155 if ((stream->type == VORTEX_PCM_SPDIF) && (en)) {
2156 vortex_route(vortex, 0, 0x14,
2157 ADB_MIXOUT(vortex->mixspdif[0]),
2159 vortex_route(vortex, 0, 0x14,
2160 ADB_MIXOUT(vortex->mixspdif[1]),
2164 /* Make playback routes. */
2165 for (i = 0; i < nr_ch; i++) {
2166 if (stream->type == VORTEX_PCM_ADB) {
2167 vortex_connection_adbdma_src(vortex, en,
2172 vortex_connection_src_mixin(vortex, en,
2175 vortex_connection_mixin_mix(vortex, en,
2179 vortex_connection_mixin_mix(vortex, en,
2181 MIX_SPDIF(i % 2), 0);
2182 vortex_mix_setinputvolumebyte(vortex,
2189 if (stream->type == VORTEX_PCM_A3D) {
2190 vortex_connection_adbdma_src(vortex, en,
2194 vortex_route(vortex, en, 0x11, ADB_SRCOUT(src[i]), ADB_A3DIN(a3d));
2196 //vortex_route(vortex, en, 0x11, dma, ADB_XTALKIN(i?9:4));
2197 //vortex_route(vortex, en, 0x11, ADB_SRCOUT(src[i]), ADB_XTALKIN(i?4:9));
2199 if (stream->type == VORTEX_PCM_SPDIF)
2200 vortex_route(vortex, en, 0x14,
2201 ADB_DMA(stream->dma),
2205 if (stream->type != VORTEX_PCM_SPDIF && stream->type != VORTEX_PCM_A3D) {
2206 ch_top = (VORTEX_IS_QUAD(vortex) ? 4 : 2);
2207 for (i = nr_ch; i < ch_top; i++) {
2208 vortex_connection_mixin_mix(vortex, en,
2212 vortex_connection_mixin_mix(vortex, en,
2216 vortex_mix_setinputvolumebyte(vortex,
2225 if (nr_ch == 1 && stream->type == VORTEX_PCM_SPDIF)
2226 vortex_route(vortex, en, 0x14,
2227 ADB_DMA(stream->dma),
2230 /* Reconnect SPDIF out when "spdif" device is down. */
2231 if ((stream->type == VORTEX_PCM_SPDIF) && (!en)) {
2232 vortex_route(vortex, 1, 0x14,
2233 ADB_MIXOUT(vortex->mixspdif[0]),
2235 vortex_route(vortex, 1, 0x14,
2236 ADB_MIXOUT(vortex->mixspdif[1]),
2240 /* CAPTURE ROUTES. */
2244 /* Get SRC and MIXER hardware resources. */
2245 for (i = 0; i < nr_ch; i++) {
2247 vortex_adb_checkinout(vortex,
2248 stream->resources, en,
2249 VORTEX_RESOURCE_MIXOUT))
2251 memset(stream->resources, 0,
2252 sizeof(unsigned char) *
2253 VORTEX_RESOURCE_LAST);
2257 vortex_adb_checkinout(vortex,
2258 stream->resources, en,
2259 VORTEX_RESOURCE_SRC)) < 0) {
2260 memset(stream->resources, 0,
2261 sizeof(unsigned char) *
2262 VORTEX_RESOURCE_LAST);
2267 /* Make capture routes. */
2268 vortex_connection_mixin_mix(vortex, en, MIX_CAPT(0), mix[0], 0);
2269 vortex_connection_mix_src(vortex, en, 0x11, mix[0], src[0]);
2271 vortex_connection_mixin_mix(vortex, en,
2272 MIX_CAPT(1), mix[0], 0);
2273 vortex_connection_src_adbdma(vortex, en,
2277 vortex_connection_mixin_mix(vortex, en,
2278 MIX_CAPT(1), mix[1], 0);
2279 vortex_connection_mix_src(vortex, en, 0x11, mix[1],
2281 vortex_connection_src_src_adbdma(vortex, en,
2286 vortex->dma_adb[dma].nr_ch = nr_ch;
2287 spin_unlock(&vortex->lock);
2290 /* AC97 Codec channel setup. FIXME: this has no effect on some cards !! */
2292 /* Copy stereo to rear channel (surround) */
2293 snd_ac97_write_cache(vortex->codec,
2294 AC97_SIGMATEL_DAC2INVERT,
2295 snd_ac97_read(vortex->codec,
2296 AC97_SIGMATEL_DAC2INVERT)
2299 /* Allow separate front and rear channels. */
2300 snd_ac97_write_cache(vortex->codec,
2301 AC97_SIGMATEL_DAC2INVERT,
2302 snd_ac97_read(vortex->codec,
2303 AC97_SIGMATEL_DAC2INVERT)
2312 Set the SampleRate of the SRC's attached to the given DMA engine.
2315 vortex_adb_setsrc(vortex_t * vortex, int adbdma, unsigned int rate, int dir)
2317 stream_t *stream = &(vortex->dma_adb[adbdma]);
2320 /* dir=1:play ; dir=0:rec */
2322 cvrt = SRC_RATIO(rate, 48000);
2324 cvrt = SRC_RATIO(48000, rate);
2327 for (i = 0; i < NR_SRC; i++) {
2328 if (stream->resources[VORTEX_RESOURCE_SRC] & (1 << i))
2329 vortex_src_setupchannel(vortex, i, cvrt, 0, 0, i, dir, 1, cvrt, dir);
2333 // Timer and ISR functions.
2335 static void vortex_settimer(vortex_t * vortex, int period)
2337 //set the timer period to <period> 48000ths of a second.
2338 hwwrite(vortex->mmio, VORTEX_IRQ_STAT, period);
2342 static void vortex_enable_timer_int(vortex_t * card)
2344 hwwrite(card->mmio, VORTEX_IRQ_CTRL,
2345 hwread(card->mmio, VORTEX_IRQ_CTRL) | IRQ_TIMER | 0x60);
2348 static void vortex_disable_timer_int(vortex_t * card)
2350 hwwrite(card->mmio, VORTEX_IRQ_CTRL,
2351 hwread(card->mmio, VORTEX_IRQ_CTRL) & ~IRQ_TIMER);
2355 static void vortex_enable_int(vortex_t * card)
2357 // CAsp4ISR__EnableVortexInt_void_
2358 hwwrite(card->mmio, VORTEX_CTRL,
2359 hwread(card->mmio, VORTEX_CTRL) | CTRL_IRQ_ENABLE);
2360 hwwrite(card->mmio, VORTEX_IRQ_CTRL,
2361 (hwread(card->mmio, VORTEX_IRQ_CTRL) & 0xffffefc0) | 0x24);
2364 static void vortex_disable_int(vortex_t * card)
2366 hwwrite(card->mmio, VORTEX_CTRL,
2367 hwread(card->mmio, VORTEX_CTRL) & ~CTRL_IRQ_ENABLE);
2370 static irqreturn_t vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2372 vortex_t *vortex = snd_magic_cast(vortex_t, dev_id, return IRQ_NONE);
2376 //check if the interrupt is ours.
2377 if (!(hwread(vortex->mmio, VORTEX_STAT) & 0x1))
2380 // This is the Interrrupt Enable flag we set before (consistency check).
2381 if (!(hwread(vortex->mmio, VORTEX_CTRL) & CTRL_IRQ_ENABLE))
2384 source = hwread(vortex->mmio, VORTEX_IRQ_SOURCE);
2386 hwwrite(vortex->mmio, VORTEX_IRQ_SOURCE, source);
2387 hwread(vortex->mmio, VORTEX_IRQ_SOURCE);
2388 // Is at least one IRQ flag set?
2390 printk(KERN_ERR "vortex: missing irq source\n");
2395 // Attend every interrupt source.
2396 if (unlikely(source & IRQ_ERR_MASK)) {
2397 if (source & IRQ_FATAL) {
2398 printk(KERN_ERR "vortex: IRQ fatal error\n");
2400 if (source & IRQ_PARITY) {
2401 printk(KERN_ERR "vortex: IRQ parity error\n");
2403 if (source & IRQ_REG) {
2404 printk(KERN_ERR "vortex: IRQ reg error\n");
2406 if (source & IRQ_FIFO) {
2407 printk(KERN_ERR "vortex: IRQ fifo error\n");
2409 if (source & IRQ_DMA) {
2410 printk(KERN_ERR "vortex: IRQ dma error\n");
2414 if (source & IRQ_PCMOUT) {
2415 /* ALSA period acknowledge. */
2416 for (i = 0; i < NR_ADB; i++) {
2417 if (vortex->dma_adb[i].fifo_status == FIFO_START) {
2418 if (vortex_adbdma_bufshift(vortex, i)) ;
2419 snd_pcm_period_elapsed(vortex->dma_adb[i].
2424 for (i = 0; i < NR_WT; i++) {
2425 if (vortex->dma_wt[i].fifo_status == FIFO_START) {
2426 if (vortex_wtdma_bufshift(vortex, i)) ;
2427 snd_pcm_period_elapsed(vortex->dma_wt[i].
2434 //Acknowledge the Timer interrupt
2435 if (source & IRQ_TIMER) {
2436 hwread(vortex->mmio, VORTEX_IRQ_STAT);
2439 if (source & IRQ_MIDI) {
2440 snd_mpu401_uart_interrupt(vortex->irq,
2441 vortex->rmidi->private_data, regs);
2446 printk(KERN_ERR "vortex: unknown irq source %x\n", source);
2448 return IRQ_RETVAL(handled);
2453 #define POLL_COUNT 1000
2454 static void vortex_codec_init(vortex_t * vortex)
2458 for (i = 0; i < 32; i++) {
2459 hwwrite(vortex->mmio, (VORTEX_CODEC_CHN + (i << 2)), 0);
2463 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x8068);
2465 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x00e8);
2468 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x00a8);
2470 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x80a8);
2472 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x80e8);
2474 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x80a8);
2476 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x00a8);
2478 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0x00e8);
2480 for (i = 0; i < 32; i++) {
2481 hwwrite(vortex->mmio, (VORTEX_CODEC_CHN + (i << 2)), 0);
2484 hwwrite(vortex->mmio, VORTEX_CODEC_CTRL, 0xe8);
2486 /* Enable codec channels 0 and 1. */
2487 hwwrite(vortex->mmio, VORTEX_CODEC_EN,
2488 hwread(vortex->mmio, VORTEX_CODEC_EN) | EN_CODEC);
2492 vortex_codec_write(ac97_t * codec, unsigned short addr, unsigned short data)
2495 vortex_t *card = (vortex_t *) codec->private_data;
2496 unsigned long flags;
2497 unsigned int lifeboat = 0;
2498 spin_lock_irqsave(&card->lock, flags);
2500 /* wait for transactions to clear */
2501 while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) {
2503 if (lifeboat++ > POLL_COUNT) {
2504 printk(KERN_ERR "vortex: ac97 codec stuck busy\n");
2505 spin_unlock_irqrestore(&card->lock, flags);
2509 /* write register */
2510 hwwrite(card->mmio, VORTEX_CODEC_IO,
2511 ((addr << VORTEX_CODEC_ADDSHIFT) & VORTEX_CODEC_ADDMASK) |
2512 ((data << VORTEX_CODEC_DATSHIFT) & VORTEX_CODEC_DATMASK) |
2513 VORTEX_CODEC_WRITE);
2516 hwread(card->mmio, VORTEX_CODEC_IO);
2518 spin_unlock_irqrestore(&card->lock, flags);
2521 static unsigned short vortex_codec_read(ac97_t * codec, unsigned short addr)
2524 vortex_t *card = (vortex_t *) codec->private_data;
2525 u32 read_addr, data;
2526 unsigned long flags;
2527 unsigned lifeboat = 0;
2529 spin_lock_irqsave(&card->lock, flags);
2531 /* wait for transactions to clear */
2532 while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) {
2534 if (lifeboat++ > POLL_COUNT) {
2535 printk(KERN_ERR "vortex: ac97 codec stuck busy\n");
2536 spin_unlock_irqrestore(&card->lock, flags);
2540 /* set up read address */
2541 read_addr = ((addr << VORTEX_CODEC_ADDSHIFT) & VORTEX_CODEC_ADDMASK);
2542 hwwrite(card->mmio, VORTEX_CODEC_IO, read_addr);
2544 /* wait for address */
2547 data = hwread(card->mmio, VORTEX_CODEC_IO);
2548 if (lifeboat++ > POLL_COUNT) {
2549 printk(KERN_ERR "vortex: ac97 address never arrived\n");
2550 spin_unlock_irqrestore(&card->lock, flags);
2554 while ((data & VORTEX_CODEC_ADDMASK) !=
2555 (addr << VORTEX_CODEC_ADDSHIFT)) ;
2558 spin_unlock_irqrestore(&card->lock, flags);
2561 return (u16) (data & VORTEX_CODEC_DATMASK);
2566 static void vortex_spdif_init(vortex_t * vortex, int spdif_sr, int spdif_mode)
2568 int i, this_38 = 0, this_04 = 0, this_08 = 0, this_0c = 0;
2570 /* CAsp4Spdif::InitializeSpdifHardware(void) */
2571 hwwrite(vortex->mmio, VORTEX_SPDIF_FLAGS,
2572 hwread(vortex->mmio, VORTEX_SPDIF_FLAGS) & 0xfff3fffd);
2573 //for (i=0x291D4; i<0x29200; i+=4)
2574 for (i = 0; i < 11; i++)
2575 hwwrite(vortex->mmio, VORTEX_SPDIF_CFG1 + (i << 2), 0);
2576 //hwwrite(vortex->mmio, 0x29190, hwread(vortex->mmio, 0x29190) | 0xc0000);
2577 hwwrite(vortex->mmio, VORTEX_CODEC_EN,
2578 hwread(vortex->mmio, VORTEX_CODEC_EN) | EN_SPDIF);
2580 /* CAsp4Spdif::ProgramSRCInHardware(enum SPDIF_SR,enum SPDIFMODE) */
2581 if (this_04 && this_08) {
2584 i = (((0x5DC00000 / spdif_sr) + 1) >> 1);
2593 /* this_04 and this_08 are the CASp4Src's (samplerate converters) */
2594 vortex_src_setupchannel(vortex, this_04, edi, 0, 1,
2595 this_0c, 1, 0, edi, 1);
2596 vortex_src_setupchannel(vortex, this_08, edi, 0, 1,
2597 this_0c, 1, 0, edi, 1);
2604 this_38 &= 0xFFFFFFFE;
2605 this_38 &= 0xFFFFFFFD;
2606 this_38 &= 0xF3FFFFFF;
2607 this_38 |= 0x03000000; /* set 32khz samplerate */
2608 this_38 &= 0xFFFFFF3F;
2609 spdif_sr &= 0xFFFFFFFD;
2613 this_38 &= 0xFFFFFFFE;
2614 this_38 &= 0xFFFFFFFD;
2615 this_38 &= 0xF0FFFFFF;
2616 this_38 |= 0x03000000;
2617 this_38 &= 0xFFFFFF3F;
2618 spdif_sr &= 0xFFFFFFFC;
2621 if (spdif_mode == 1) {
2622 this_38 &= 0xFFFFFFFE;
2623 this_38 &= 0xFFFFFFFD;
2624 this_38 &= 0xF2FFFFFF;
2625 this_38 |= 0x02000000; /* set 48khz samplerate */
2626 this_38 &= 0xFFFFFF3F;
2628 /* J. Gordon Wolfe: I think this stuff is for AC3 */
2629 this_38 |= 0x00000003;
2630 this_38 &= 0xFFFFFFBF;
2634 spdif_sr &= 0xFFFFFFFE;
2638 /* looks like the next 2 lines transfer a 16-bit value into 2 8-bit
2639 registers. seems to be for the standard IEC/SPDIF initialization
2641 hwwrite(vortex->mmio, VORTEX_SPDIF_CFG0, this_38 & 0xffff);
2642 hwwrite(vortex->mmio, VORTEX_SPDIF_CFG1, this_38 >> 0x10);
2643 hwwrite(vortex->mmio, VORTEX_SPDIF_SMPRATE, spdif_sr);
2646 /* Initialization */
2648 static int vortex_core_init(vortex_t * vortex)
2651 printk(KERN_INFO "Vortex: init.... ");
2652 /* Hardware Init. */
2653 hwwrite(vortex->mmio, VORTEX_CTRL, 0xffffffff);
2655 hwwrite(vortex->mmio, VORTEX_CTRL,
2656 hwread(vortex->mmio, VORTEX_CTRL) & 0xffdfffff);
2658 /* Reset IRQ flags */
2659 hwwrite(vortex->mmio, VORTEX_IRQ_SOURCE, 0xffffffff);
2660 hwread(vortex->mmio, VORTEX_IRQ_STAT);
2662 vortex_codec_init(vortex);
2665 hwwrite(vortex->mmio, VORTEX_CTRL,
2666 hwread(vortex->mmio, VORTEX_CTRL) | 0x1000000);
2669 /* Init audio engine. */
2670 vortex_adbdma_init(vortex);
2671 hwwrite(vortex->mmio, VORTEX_ENGINE_CTRL, 0x0); //, 0xc83c7e58, 0xc5f93e58
2672 vortex_adb_init(vortex);
2673 /* Init processing blocks. */
2674 vortex_fifo_init(vortex);
2675 vortex_mixer_init(vortex);
2676 vortex_srcblock_init(vortex);
2678 vortex_eq_init(vortex);
2679 vortex_spdif_init(vortex, 48000, 1);
2680 vortex_Vort3D(vortex, 1);
2683 vortex_wt_init(vortex);
2685 // Moved to au88x0.c
2686 //vortex_connect_default(vortex, 1);
2688 vortex_settimer(vortex, 0x90);
2689 // Enable Interrupts.
2690 // vortex_enable_int() must be first !!
2691 // hwwrite(vortex->mmio, VORTEX_IRQ_CTRL, 0);
2692 // vortex_enable_int(vortex);
2693 //vortex_enable_timer_int(vortex);
2694 //vortex_disable_timer_int(vortex);
2696 printk(KERN_INFO "done.\n");
2697 spin_lock_init(&vortex->lock);
2702 static int vortex_core_shutdown(vortex_t * vortex)
2705 printk(KERN_INFO "Vortex: shutdown...");
2707 vortex_eq_free(vortex);
2708 vortex_Vort3D(vortex, 0);
2710 //vortex_disable_timer_int(vortex);
2711 vortex_disable_int(vortex);
2712 vortex_connect_default(vortex, 0);
2713 /* Reset all DMA fifos. */
2714 vortex_fifo_init(vortex);
2715 /* Erase all audio routes. */
2716 vortex_adb_init(vortex);
2718 /* Disable MPU401 */
2719 //hwwrite(vortex->mmio, VORTEX_IRQ_CTRL, hwread(vortex->mmio, VORTEX_IRQ_CTRL) & ~IRQ_MIDI);
2720 //hwwrite(vortex->mmio, VORTEX_CTRL, hwread(vortex->mmio, VORTEX_CTRL) & ~CTRL_MIDI_EN);
2722 hwwrite(vortex->mmio, VORTEX_IRQ_CTRL, 0);
2723 hwwrite(vortex->mmio, VORTEX_CTRL, 0);
2725 hwwrite(vortex->mmio, VORTEX_IRQ_SOURCE, 0xffff);
2727 printk(KERN_INFO "done.\n");
2733 static int vortex_alsafmt_aspfmt(int alsafmt)
2738 case SNDRV_PCM_FORMAT_U8:
2741 case SNDRV_PCM_FORMAT_MU_LAW:
2744 case SNDRV_PCM_FORMAT_A_LAW:
2747 case SNDRV_PCM_FORMAT_SPECIAL:
2748 fmt = 0x4; /* guess. */
2750 case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE:
2751 fmt = 0x5; /* guess. */
2753 case SNDRV_PCM_FORMAT_S16_LE:
2756 case SNDRV_PCM_FORMAT_S16_BE:
2757 fmt = 0x9; /* check this... */
2761 printk(KERN_ERR "vortex: format unsupported %d\n", alsafmt);
2767 /* Some not yet useful translations. */
2770 ASPFMTLINEAR16 = 0, /* 0x8 */
2771 ASPFMTLINEAR8, /* 0x1 */
2772 ASPFMTULAW, /* 0x2 */
2773 ASPFMTALAW, /* 0x3 */
2774 ASPFMTSPORT, /* ? */
2775 ASPFMTSPDIF, /* ? */
2779 vortex_translateformat(vortex_t * vortex, char bits, char nch, int encod)
2783 if ((bits != 8) || (bits != 16))
2819 static void vortex_cdmacore_setformat(vortex_t * vortex, int bits, int nch)
2821 short int d, this_148;
2823 d = ((bits >> 3) * nch);
2824 this_148 = 0xbb80 / d;