94 static void vortex_mixer_dis_sr(
vortex_t * vortex,
int channel)
102 vortex_mix_muteinputgain(
vortex_t * vortex,
unsigned char mix,
103 unsigned char channel)
111 static int vortex_mix_getvolume(
vortex_t * vortex,
unsigned char mix)
120 vortex_mix_getinputvolume(
vortex_t * vortex,
unsigned char mix,
121 int channel,
int *
vol)
124 if (!(mchannels[mix] & (1 << channel)))
138 static unsigned int vortex_mix_boost6db(
unsigned char vol)
143 static void vortex_mix_rampvolume(
vortex_t * vortex,
int mix)
148 for (ch = 0; ch < 0x20; ch++) {
149 if (((1 << ch) & rampchs[mix]) == 0)
157 (((mix << 5) + ch) << 2), a);
160 (((mix << 5) + ch) << 2), a);
162 vortex_mix_killinput(vortex, mix, ch);
167 vortex_mix_getenablebit(
vortex_t * vortex,
unsigned char mix,
int mixin)
174 addr = ((mix << 3) + (addr >> 2)) << 2;
176 return ((temp >> (mixin & 3)) & 1);
180 vortex_mix_setvolumebyte(
vortex_t * vortex,
unsigned char mix,
187 if ((temp != 0x80) || (vol == 0x80))
194 vortex_mix_setinputvolumebyte(
vortex_t * vortex,
unsigned char mix,
195 int mixin,
unsigned char vol)
205 if ((temp != 0x80) || (vol == 0x80))
213 vortex_mix_setenablebit(
vortex_t * vortex,
unsigned char mix,
int mixin,
int en)
221 addr = ((mix << 3) + (addr >> 2)) << 2;
224 temp |= (1 << (mixin & 3));
226 temp &= ~(1 << (mixin & 3));
238 vortex_mix_killinput(
vortex_t * vortex,
unsigned char mix,
int mixin)
240 rampchs[
mix] &= ~(1 << mixin);
241 vortex_mix_setinputvolumebyte(vortex, mix, mixin, 0x80);
242 mchannels[
mix] &= ~(1 << mixin);
243 vortex_mix_setenablebit(vortex, mix, mixin, 0);
247 vortex_mix_enableinput(
vortex_t * vortex,
unsigned char mix,
int mixin)
249 vortex_mix_killinput(vortex, mix, mixin);
250 if ((mchannels[mix] & (1 << mixin)) == 0) {
251 vortex_mix_setinputvolumebyte(vortex, mix, mixin, 0x80);
252 mchannels[
mix] |= (1 << mixin);
254 vortex_mix_setenablebit(vortex, mix, mixin, 1);
258 vortex_mix_disableinput(
vortex_t * vortex,
unsigned char mix,
int channel,
265 vortex_mix_killinput(vortex, mix, channel);
267 vortex_mix_killinput(vortex, mix, channel);
271 vortex_mixer_addWTD(
vortex_t * vortex,
unsigned char mix,
unsigned char ch)
276 if ((temp & (1 << ch)) == 0) {
278 vortex_mixer_en_sr(vortex, ch);
283 while (temp & 0x10) {
287 if ((++lifeboat) > 0xf) {
289 "vortex_mixer_addWTD: lifeboat overflow\n");
299 vortex_mixer_delWTD(
vortex_t * vortex,
unsigned char mix,
unsigned char ch)
301 int esp14 = -1, esp18, eax,
ebx, edx, ebp, esi = 0;
305 if (((1 << ch) & eax) == 0) {
325 while ((edx & 0xf) != mix) {
328 "vortex: mixdelWTD: error lifeboat overflow\n");
355 (ch << 2), esp18 & 0xef);
357 ebx = (0xffffffe0 & edx) | (0xf & ebx);
371 vortex_mixer_dis_sr(vortex, ch);
377 static void vortex_mixer_init(
vortex_t * vortex)
387 for (x = 0x5f; x >= 0; x--) {
392 for (x = 0x7f; x >= 0; x--) {
397 for (x = 0x5f; x >= 0; x--) {
402 for (x = 0x1ff; x >= 0; x--) {
407 for (x = 0xf; x >= 0; x--) {
412 for (x = 0x1ff; x >= 0; x--) {
417 for (x = 0xf; x >= 0; x--) {
443 static void vortex_src_en_sr(
vortex_t * vortex,
int channel)
449 static void vortex_src_dis_sr(
vortex_t * vortex,
int channel)
455 static void vortex_src_flushbuffers(
vortex_t * vortex,
unsigned char src)
459 for (i = 0x1f; i >= 0; i--)
466 static void vortex_src_cleardrift(
vortex_t * vortex,
unsigned char src)
474 vortex_src_set_throttlesource(
vortex_t * vortex,
unsigned char src,
int en)
487 vortex_src_persist_convratio(
vortex_t * vortex,
unsigned char src,
int ratio)
489 int temp, lifeboat = 0;
494 if ((++lifeboat) > 0x9) {
499 while (temp != ratio);
504 static void vortex_src_slowlock(
vortex_t * vortex,
unsigned char src)
517 vortex_src_change_convratio(
vortex_t * vortex,
unsigned char src,
int ratio)
521 if ((ratio & 0x10000) && (ratio != 0x10000)) {
523 a = (0x11 - ((ratio >> 0xe) & 0x3)) - 1;
525 a = (0x11 - ((ratio >> 0xe) & 0x3)) - 2;
529 if (((temp >> 4) & 0xf) != a)
531 (temp & 0xf) | ((a & 0xf) << 4));
533 vortex_src_persist_convratio(vortex, src, ratio);
537 vortex_src_checkratio(
vortex_t * vortex,
unsigned char src,
538 unsigned int desired_ratio)
540 int hw_ratio, lifeboat = 0;
544 while (hw_ratio != desired_ratio) {
547 if ((lifeboat++) > 15) {
549 src, hw_ratio, desired_ratio);
571 static void vortex_src_setupchannel(
vortex_t *
card,
unsigned char src,
572 unsigned int cr,
unsigned int b,
int sweep,
int d,
573 int dirplay,
int sl,
unsigned int tr,
int thsource)
582 int esi, ebp = 0, esp10;
584 vortex_src_flushbuffers(card, src);
587 if ((tr & 0x10000) && (tr != 0x10000)) {
591 if ((((
short)tr) < 0) && (tr != 0x8000)) {
600 if ((cr & 0x10000) && (cr != 0x10000)) {
602 esi = 0x11 - ((cr >> 0xe) & 7);
612 vortex_src_cleardrift(card, src);
613 vortex_src_set_throttlesource(card, src, thsource);
615 if ((dirplay == 0) && (sweep == 0)) {
629 (sl << 0x9) | (sweep << 0x8) | ((esi & 0xf) << 4) | d);
631 vortex_src_persist_convratio(card, src, cr);
635 (tr << 0x11) | (dirplay << 0x10) | (ebp << 0x8) | esp10);
640 static void vortex_srcblock_init(
vortex_t * vortex)
653 for (x = 0xf; x >= 0; x--) {
660 for (x = 0x15; x >= 0; x--) {
667 vortex_src_addWTD(
vortex_t * vortex,
unsigned char src,
unsigned char ch)
673 if ((temp & (1 << ch)) == 0) {
675 vortex_src_en_sr(vortex, ch);
681 while (temp & 0x10) {
686 if ((++lifeboat) > 0xf) {
688 "vortex_src_addWTD: lifeboat overflow\n");
699 vortex_src_delWTD(
vortex_t * vortex,
unsigned char src,
unsigned char ch)
701 int esp14 = -1, esp18, eax,
ebx, edx, ebp, esi = 0;
705 if (((1 << ch) & eax) == 0) {
725 while ((edx & 0xf) != src) {
728 (
"vortex: srcdelWTD: error, lifeboat overflow\n");
755 (ch << 2), esp18 & 0xef);
757 ebx = (0xffffffe0 & edx) | (0xf & ebx);
770 vortex_src_dis_sr(vortex, ch);
779 vortex_fifo_clearadbdata(
vortex_t * vortex,
int fifo,
int x)
781 for (x--; x >= 0; x--)
788 static void vortex_fifo_adbinitialize(
vortex_t * vortex,
int fifo,
int j)
790 vortex_fifo_clearadbdata(vortex, fifo,
FIFO_SIZE);
800 static void vortex_fifo_setadbvalid(
vortex_t * vortex,
int fifo,
int en)
804 0xffffffef) | ((1 & en) << 4) |
FIFO_U1);
808 vortex_fifo_setadbctrl(
vortex_t * vortex,
int fifo,
int stereo,
int priority,
811 int temp, lifeboat = 0;
821 if (lifeboat++ > 0xbb8) {
823 "Vortex: vortex_fifo_setadbctrl fail\n");
834 vortex_fifo_clearadbdata(vortex, fifo,
FIFO_SIZE);
836 temp = (this_4 & 0x1f) << 0
xb;
838 temp = (this_4 & 0x3f) << 0
xc;
840 temp = (temp & 0xfffffffd) | ((stereo & 1) << 1);
841 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
842 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
844 temp = (temp & 0xffffffdf) | ((empty & 1) << 5);
846 temp = (temp & 0xfffbffff) | ((f & 1) << 0x12);
849 temp = (temp & 0xf7ffffff) | ((f & 1) << 0x1b);
850 temp = (temp & 0xefffffff) | ((f & 1) << 0x1c);
853 temp = (temp & 0xfeffffff) | ((f & 1) << 0x18);
854 temp = (temp & 0xfdffffff) | ((f & 1) << 0x19);
858 if (temp & FIFO_VALID) {
860 temp = ((f & 1) << 0x12) | (temp & 0xfffbffef);
864 ((f & 1) << 0x1b) | (temp & 0xe7ffffef) |
FIFO_BITS;
868 ((f & 1) << 0x18) | (temp & 0xfcffffef) |
FIFO_BITS;
872 vortex_fifo_clearadbdata(vortex, fifo,
FIFO_SIZE);
879 static void vortex_fifo_clearwtdata(
vortex_t * vortex,
int fifo,
int x)
883 for (x--; x >= 0; x--)
889 static void vortex_fifo_wtinitialize(
vortex_t * vortex,
int fifo,
int j)
891 vortex_fifo_clearwtdata(vortex, fifo,
FIFO_SIZE);
901 static void vortex_fifo_setwtvalid(
vortex_t * vortex,
int fifo,
int en)
905 0xffffffef) | ((en & 1) << 4) |
FIFO_U1);
909 vortex_fifo_setwtctrl(
vortex_t * vortex,
int fifo,
int ctrl,
int priority,
910 int empty,
int valid,
int f)
912 int temp = 0, lifeboat = 0;
917 if (lifeboat++ > 0xbb8) {
922 while (temp & FIFO_RDONLY);
925 if ((temp & FIFO_VALID) == 0) {
926 vortex_fifo_clearwtdata(vortex, fifo,
FIFO_SIZE);
928 temp = (this_4 & 0x1f) << 0
xb;
930 temp = (this_4 & 0x3f) << 0
xc;
932 temp = (temp & 0xfffffffd) | ((ctrl & 1) << 1);
933 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
934 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
936 temp = (temp & 0xffffffdf) | ((empty & 1) << 5);
938 temp = (temp & 0xfffbffff) | ((f & 1) << 0x12);
941 temp = (temp & 0xf7ffffff) | ((f & 1) << 0x1b);
942 temp = (temp & 0xefffffff) | ((f & 1) << 0x1c);
945 temp = (temp & 0xfeffffff) | ((f & 1) << 0x18);
946 temp = (temp & 0xfdffffff) | ((f & 1) << 0x19);
950 if (temp & FIFO_VALID) {
952 temp = ((f & 1) << 0x12) | (temp & 0xfffbffef);
956 ((f & 1) << 0x1b) | (temp & 0xe7ffffef) |
FIFO_BITS;
960 ((f & 1) << 0x18) | (temp & 0xfcffffef) |
FIFO_BITS;
964 vortex_fifo_clearwtdata(vortex, fifo,
FIFO_SIZE);
1035 static void vortex_fifo_init(
vortex_t * vortex)
1042 for (x =
NR_ADB - 1; x >= 0; x--) {
1046 vortex_fifo_clearadbdata(vortex, x,
FIFO_SIZE);
1053 for (x =
NR_WT - 1; x >= 0; x--) {
1057 "bad wt fifo reset (0x%08x, 0x%08x)!\n",
1059 vortex_fifo_clearwtdata(vortex, x,
FIFO_SIZE);
1077 static void vortex_adbdma_init(
vortex_t * vortex)
1081 static void vortex_adbdma_setfirstbuffer(
vortex_t * vortex,
int adbdma)
1089 static void vortex_adbdma_setstartbuffer(
vortex_t * vortex,
int adbdma,
int sb)
1094 sb << ((0xf - (adbdma & 0xf)) * 2));
1099 vortex_adbdma_setbuffers(
vortex_t * vortex,
int adbdma,
1100 int psize,
int count)
1113 dma->
cfg1 |= 0x88000000 | 0x44000000 | 0x30000000 | (psize - 1);
1116 snd_pcm_sgbuf_get_addr(dma->
substream, psize * 3));
1119 dma->
cfg0 |= 0x12000000;
1120 dma->
cfg1 |= 0x80000000 | 0x40000000 | ((psize - 1) << 0
xc);
1123 snd_pcm_sgbuf_get_addr(dma->
substream, psize * 2));
1126 dma->
cfg0 |= 0x88000000 | 0x44000000 | 0x10000000 | (psize - 1);
1129 snd_pcm_sgbuf_get_addr(dma->
substream, psize));
1132 dma->
cfg0 |= 0x80000000 | 0x40000000 | ((psize - 1) << 0
xc);
1135 snd_pcm_sgbuf_get_addr(dma->
substream, 0));
1145 vortex_adbdma_setfirstbuffer(vortex, adbdma);
1146 vortex_adbdma_setstartbuffer(vortex, adbdma, 0);
1150 vortex_adbdma_setmode(
vortex_t * vortex,
int adbdma,
int ie,
int dir,
1172 static int vortex_adbdma_bufshift(
vortex_t * vortex,
int adbdma)
1192 for (i = 0; i <
delta; i++) {
1208 (((adbdma << 2) + pp) << 2));
1223 static void vortex_adbdma_resetup(
vortex_t *vortex,
int adbdma) {
1228 for (i=0 ; i < 4 && i < dma->
nr_periods; i++) {
1252 static inline int vortex_adbdma_getlinearpos(
vortex_t * vortex,
int adbdma)
1270 static void vortex_adbdma_startfifo(
vortex_t * vortex,
int adbdma)
1272 int this_8 = 0 , this_4 = 0 ;
1277 vortex_fifo_setadbvalid(vortex, adbdma,
1284 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1289 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1297 static void vortex_adbdma_resumefifo(
vortex_t * vortex,
int adbdma)
1301 int this_8 = 1, this_4 = 0;
1306 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1311 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1319 static void vortex_adbdma_pausefifo(
vortex_t * vortex,
int adbdma)
1323 int this_8 = 0, this_4 = 0;
1326 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1327 this_4, this_8, 0, 0);
1332 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1333 this_4, this_8, 0, 0);
1339 static void vortex_adbdma_stopfifo(
vortex_t * vortex,
int adbdma)
1343 int this_4 = 0, this_8 = 0;
1345 vortex_fifo_setadbctrl(vortex, adbdma, dma->
dma_unknown,
1346 this_4, this_8, 0, 0);
1356 static void vortex_wtdma_setfirstbuffer(
vortex_t * vortex,
int wtdma)
1364 static void vortex_wtdma_setstartbuffer(
vortex_t * vortex,
int wtdma,
int sb)
1369 sb << ((0xf - (wtdma & 0xf)) * 2));
1374 vortex_wtdma_setbuffers(
vortex_t * vortex,
int wtdma,
1375 int psize,
int count)
1388 dma->
cfg1 |= 0x88000000 | 0x44000000 | 0x30000000 | (psize-1);
1390 snd_pcm_sgbuf_get_addr(dma->
substream, psize * 3));
1393 dma->
cfg0 |= 0x12000000;
1394 dma->
cfg1 |= 0x80000000 | 0x40000000 | ((psize-1) << 0
xc);
1396 snd_pcm_sgbuf_get_addr(dma->
substream, psize * 2));
1399 dma->
cfg0 |= 0x88000000 | 0x44000000 | 0x10000000 | (psize-1);
1401 snd_pcm_sgbuf_get_addr(dma->
substream, psize));
1404 dma->
cfg0 |= 0x80000000 | 0x40000000 | ((psize-1) << 0
xc);
1406 snd_pcm_sgbuf_get_addr(dma->
substream, 0));
1412 vortex_wtdma_setfirstbuffer(vortex, wtdma);
1413 vortex_wtdma_setstartbuffer(vortex, wtdma, 0);
1417 vortex_wtdma_setmode(
vortex_t * vortex,
int wtdma,
int ie,
int fmt,
int d,
1439 static int vortex_wtdma_bufshift(
vortex_t * vortex,
int wtdma)
1460 for (i = 0; i <
delta; i++) {
1471 (((wtdma << 2) + pp) << 2),
1476 (((wtdma << 2) + pp) << 2));
1493 vortex_wtdma_getposition(
vortex_t * vortex,
int wtdma,
int *subbuf,
int *
pos)
1501 static int vortex_wtdma_getcursubuffer(
vortex_t * vortex,
int wtdma)
1507 static inline int vortex_wtdma_getlinearpos(
vortex_t * vortex,
int wtdma)
1517 static void vortex_wtdma_startfifo(
vortex_t * vortex,
int wtdma)
1520 int this_8 = 0, this_4 = 0;
1524 vortex_fifo_setwtvalid(vortex, wtdma,
1531 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1536 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1544 static void vortex_wtdma_resumefifo(
vortex_t * vortex,
int wtdma)
1548 int this_8 = 0, this_4 = 0;
1553 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1558 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1566 static void vortex_wtdma_pausefifo(
vortex_t * vortex,
int wtdma)
1570 int this_8 = 0, this_4 = 0;
1573 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1574 this_4, this_8, 0, 0);
1579 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1580 this_4, this_8, 0, 0);
1586 static void vortex_wtdma_stopfifo(
vortex_t * vortex,
int wtdma)
1590 int this_4 = 0, this_8 = 0;
1592 vortex_fifo_setwtctrl(vortex, wtdma, dma->
dma_unknown,
1593 this_4, this_8, 0, 0);
1604 static void vortex_adb_init(
vortex_t * vortex)
1621 static void vortex_adb_en_sr(
vortex_t * vortex,
int channel)
1627 static void vortex_adb_dis_sr(
vortex_t * vortex,
int channel)
1634 vortex_adb_addroutes(
vortex_t * vortex,
unsigned char channel,
1635 ADBRamLink * route,
int rnum)
1639 if ((rnum <= 0) || (route ==
NULL))
1649 ((route[rnum - 1] &
ADB_MASK) << 2), route[rnum]);
1660 vortex_adb_en_sr(vortex, channel);
1671 "vortex_adb_addroutes: unending route! 0x%x\n",
1681 vortex_adb_delroutes(
vortex_t * vortex,
unsigned char channel,
1682 ADBRamLink route0, ADBRamLink route1)
1694 if ((temp & ADB_MASK) == ADB_MASK)
1695 vortex_adb_dis_sr(vortex, channel);
1705 if (((lifeboat++) > ADB_MASK) || (temp == ADB_MASK)) {
1707 "vortex_adb_delroutes: route not found! 0x%x\n",
1712 while (temp != (route0 & ADB_MASK));
1714 if ((temp & ADB_MASK) == route1)
1721 vortex_route(
vortex_t * vortex,
int en,
unsigned char channel,
1728 vortex_adb_addroutes(vortex, channel, &route, 1);
1735 vortex_mixer_addWTD(vortex,
1738 vortex_adb_delroutes(vortex, channel, route, route);
1745 vortex_mixer_delWTD(vortex,
1752 vortex_routes(
vortex_t * vortex,
int en,
unsigned char channel,
1753 unsigned char source,
unsigned char dest0,
unsigned char dest1)
1755 ADBRamLink route[2];
1761 vortex_adb_addroutes(vortex, channel, route, 2);
1768 vortex_mixer_addWTD(vortex,
1771 vortex_adb_delroutes(vortex, channel, route[0], route[1]);
1778 vortex_mixer_delWTD(vortex,
1786 vortex_routeLRT(
vortex_t * vortex,
int en,
unsigned char ch,
1787 unsigned char source0,
unsigned char source1,
1790 ADBRamLink route[2];
1796 route[1] = (route[1] & ~ADB_MASK) | (dest + 0x20);
1799 vortex_adb_addroutes(vortex, ch, route, 2);
1802 vortex_src_addWTD(vortex,
1804 vortex_src_addWTD(vortex,
1808 vortex_mixer_addWTD(vortex,
1810 vortex_mixer_addWTD(vortex,
1814 vortex_adb_delroutes(vortex, ch, route[0], route[1]);
1817 vortex_src_delWTD(vortex,
1819 vortex_src_delWTD(vortex,
1823 vortex_mixer_delWTD(vortex,
1825 vortex_mixer_delWTD(vortex,
1835 vortex_connection_adbdma_src(
vortex_t * vortex,
int en,
unsigned char ch,
1836 unsigned char adbdma,
unsigned char src)
1843 vortex_connection_src_mixin(
vortex_t * vortex,
int en,
1844 unsigned char channel,
unsigned char src,
1845 unsigned char mixin)
1852 vortex_connection_mixin_mix(
vortex_t * vortex,
int en,
unsigned char mixin,
1853 unsigned char mix,
int a)
1856 vortex_mix_enableinput(vortex, mix, mixin);
1857 vortex_mix_setinputvolumebyte(vortex, mix, mixin,
MIX_DEFIGAIN);
1859 vortex_mix_disableinput(vortex, mix, mixin, a);
1864 vortex_connection_adb_mixin(
vortex_t * vortex,
int en,
1865 unsigned char channel,
unsigned char source,
1866 unsigned char mixin)
1868 vortex_route(vortex, en, channel, source,
ADB_MIXIN(mixin));
1872 vortex_connection_src_adbdma(
vortex_t * vortex,
int en,
unsigned char ch,
1873 unsigned char src,
unsigned char adbdma)
1879 vortex_connection_src_src_adbdma(
vortex_t * vortex,
int en,
1880 unsigned char ch,
unsigned char src0,
1881 unsigned char src1,
unsigned char adbdma)
1890 vortex_connection_mix_adb(
vortex_t * vortex,
int en,
unsigned char ch,
1891 unsigned char mix,
unsigned char dest)
1893 vortex_route(vortex, en, ch,
ADB_MIXOUT(mix), dest);
1899 vortex_connection_mix_src(
vortex_t * vortex,
int en,
unsigned char ch,
1900 unsigned char mix,
unsigned char src)
1908 vortex_connection_adbdma_src_src(
vortex_t * vortex,
int en,
1909 unsigned char channel,
1910 unsigned char adbdma,
unsigned char src0,
1913 vortex_routes(vortex, en, channel,
ADB_DMA(adbdma),
1919 vortex_connection_mix_mix_adbdma(
vortex_t * vortex,
int en,
1920 unsigned char ch,
unsigned char mix0,
1921 unsigned char mix1,
unsigned char adbdma)
1924 ADBRamLink routes[2];
1933 vortex_adb_addroutes(vortex, ch, routes, 0x2);
1934 vortex_mixer_addWTD(vortex, mix0, ch);
1935 vortex_mixer_addWTD(vortex, mix1, ch);
1937 vortex_adb_delroutes(vortex, ch, routes[0], routes[1]);
1938 vortex_mixer_delWTD(vortex, mix0, ch);
1939 vortex_mixer_delWTD(vortex, mix1, ch);
1947 vortex_connect_codecplay(
vortex_t * vortex,
int en,
unsigned char mixers[])
1950 vortex_connection_mix_adb(vortex, en, 0x11, mixers[0],
ADB_CODECOUT(0));
1951 vortex_connection_mix_adb(vortex, en, 0x11, mixers[1],
ADB_CODECOUT(1));
1955 vortex_connection_mix_adb(vortex, en, 0x11, mixers[0],
ADB_EQIN(0));
1956 vortex_connection_mix_adb(vortex, en, 0x11, mixers[1],
ADB_EQIN(1));
1958 vortex_mix_setvolumebyte(vortex, mixers[0], 0);
1959 vortex_mix_setvolumebyte(vortex, mixers[1], 0);
1966 vortex_connection_mix_adb(vortex, en, 0x11, mixers[2],
1968 vortex_connection_mix_adb(vortex, en, 0x11, mixers[3],
1974 vortex_connection_mix_adb(vortex, en, 0x11, mixers[0],
ADB_CODECOUT(0));
1975 vortex_connection_mix_adb(vortex, en, 0x11, mixers[1],
ADB_CODECOUT(1));
1981 vortex_connect_codecrec(
vortex_t * vortex,
int en,
unsigned char mixin0,
1982 unsigned char mixin1)
1990 vortex_connection_adb_mixin(vortex, en, 0x11,
ADB_CODECIN(0), mixin0);
1991 vortex_connection_adb_mixin(vortex, en, 0x11,
ADB_CODECIN(1), mixin1);
2007 vortex_adb_checkinout(
vortex_t * vortex,
int resmap[],
int out,
int restype)
2009 int i, qty = resnum[restype], resinuse = 0;
2013 for (i = 0; i <
NR_ADB; i++) {
2018 for (i = 0; i < qty; i++) {
2019 if ((resinuse & (1 << i)) == 0) {
2021 resmap[restype] |= (1 <<
i);
2036 for (i = 0; i < qty; i++) {
2037 if (resmap[restype] & (1 << i)) {
2038 resmap[restype] &= ~(1 <<
i);
2048 printk(
KERN_ERR "vortex: FATAL: ResManager: resource type %d exhausted.\n", restype);
2054 static void vortex_connect_default(
vortex_t * vortex,
int en)
2067 vortex_connect_codecplay(vortex, en, vortex->
mixplayb);
2081 vortex_connection_mix_adb(vortex, en, 0x14, vortex->
mixspdif[0],
2083 vortex_connection_mix_adb(vortex, en, 0x14, vortex->
mixspdif[1],
2088 vortex_wt_connect(vortex, en);
2092 vortex_Vort3D_connect(vortex, en);
2112 vortex_adb_allocroute(
vortex_t *vortex,
int dma,
int nr_ch,
int dir,
2121 vortex_adb_checkinout(vortex,
2127 vortex_adb_checkinout(vortex,
NULL, en,
2139 int src[4], mix[4], ch_top;
2145 for (i = 0; i < nr_ch; i++) {
2146 if ((src[i] = vortex_adb_checkinout(vortex,
2150 sizeof(
unsigned char) *
2155 if ((mix[i] = vortex_adb_checkinout(vortex,
2170 vortex_adb_checkinout(vortex,
2174 sizeof(
unsigned char) *
2180 vortex_Vort3D_InitializeSource(&(vortex->
a3d[a3d]), en);
2184 vortex_route(vortex, 0, 0x14,
2187 vortex_route(vortex, 0, 0x14,
2193 for (i = 0; i < nr_ch; i++) {
2195 vortex_connection_adbdma_src(vortex, en,
2199 vortex_connection_src_mixin(vortex, en,
2202 vortex_connection_mixin_mix(vortex, en,
2206 vortex_connection_mixin_mix(vortex, en,
2209 vortex_mix_setinputvolumebyte(vortex,
2217 vortex_connection_adbdma_src(vortex, en,
2227 vortex_route(vortex, en, 0x14,
2234 for (i = nr_ch; i < ch_top; i++) {
2235 vortex_connection_mixin_mix(vortex, en,
2239 vortex_connection_mixin_mix(vortex, en,
2243 vortex_mix_setinputvolumebyte(vortex,
2252 for (i = 0; i < nr_ch; i++)
2253 p->
mixin[i] = mix[i];
2254 for (i = 0; i < ch_top; i++)
2261 vortex_route(vortex, en, 0x14,
2267 vortex_route(vortex, 1, 0x14,
2270 vortex_route(vortex, 1, 0x14,
2280 for (i = 0; i < nr_ch; i++) {
2282 vortex_adb_checkinout(vortex,
2287 sizeof(
unsigned char) *
2292 vortex_adb_checkinout(vortex,
2296 sizeof(
unsigned char) *
2303 vortex_connection_mixin_mix(vortex, en,
MIX_CAPT(0), mix[0], 0);
2304 vortex_connection_mix_src(vortex, en, 0x11, mix[0], src[0]);
2306 vortex_connection_mixin_mix(vortex, en,
2308 vortex_connection_src_adbdma(vortex, en,
2312 vortex_connection_mixin_mix(vortex, en,
2314 vortex_connection_mix_src(vortex, en, 0x11, mix[1],
2316 vortex_connection_src_src_adbdma(vortex, en,
2349 vortex_adb_setsrc(
vortex_t * vortex,
int adbdma,
unsigned int rate,
int dir)
2361 for (i = 0; i <
NR_SRC; i++) {
2363 vortex_src_setupchannel(vortex, i, cvrt, 0, 0, i, dir, 1, cvrt, dir);
2376 static void vortex_enable_timer_int(
vortex_t * card)
2382 static void vortex_disable_timer_int(
vortex_t * card)
2389 static void vortex_enable_int(
vortex_t * card)
2398 static void vortex_disable_int(
vortex_t * card)
2450 spin_lock(&vortex->
lock);
2451 for (i = 0; i <
NR_ADB; i++) {
2453 if (!vortex_adbdma_bufshift(vortex, i))
2455 spin_unlock(&vortex->
lock);
2458 spin_lock(&vortex->
lock);
2462 for (i = 0; i <
NR_WT; i++) {
2464 if (vortex_wtdma_bufshift(vortex, i)) ;
2465 spin_unlock(&vortex->
lock);
2468 spin_lock(&vortex->
lock);
2472 spin_unlock(&vortex->
lock);
2482 vortex->
rmidi->private_data);
2494 #define POLL_COUNT 1000
2495 static void vortex_codec_init(
vortex_t * vortex)
2499 for (i = 0; i < 32; i++) {
2522 for (i = 0; i < 32; i++) {
2534 vortex_codec_write(
struct snd_ac97 *
codec,
unsigned short addr,
unsigned short data)
2538 unsigned int lifeboat = 0;
2559 static unsigned short vortex_codec_read(
struct snd_ac97 * codec,
unsigned short addr)
2563 u32 read_addr, data;
2564 unsigned lifeboat = 0;
2596 static void vortex_spdif_init(
vortex_t * vortex,
int spdif_sr,
int spdif_mode)
2598 int i, this_38 = 0, this_04 = 0, this_08 = 0, this_0c = 0;
2604 for (i = 0; i < 11; i++)
2611 if (this_04 && this_08) {
2614 i = (((0x5DC00000 / spdif_sr) + 1) >> 1);
2624 vortex_src_setupchannel(vortex, this_04, edi, 0, 1,
2625 this_0c, 1, 0, edi, 1);
2626 vortex_src_setupchannel(vortex, this_08, edi, 0, 1,
2627 this_0c, 1, 0, edi, 1);
2634 this_38 &= 0xFFFFFFFE;
2635 this_38 &= 0xFFFFFFFD;
2636 this_38 &= 0xF3FFFFFF;
2637 this_38 |= 0x03000000;
2638 this_38 &= 0xFFFFFF3F;
2639 spdif_sr &= 0xFFFFFFFD;
2643 this_38 &= 0xFFFFFFFE;
2644 this_38 &= 0xFFFFFFFD;
2645 this_38 &= 0xF0FFFFFF;
2646 this_38 |= 0x03000000;
2647 this_38 &= 0xFFFFFF3F;
2648 spdif_sr &= 0xFFFFFFFC;
2651 if (spdif_mode == 1) {
2652 this_38 &= 0xFFFFFFFE;
2653 this_38 &= 0xFFFFFFFD;
2654 this_38 &= 0xF2FFFFFF;
2655 this_38 |= 0x02000000;
2656 this_38 &= 0xFFFFFF3F;
2659 this_38 |= 0x00000003;
2660 this_38 &= 0xFFFFFFBF;
2664 spdif_sr &= 0xFFFFFFFE;
2692 vortex_codec_init(vortex);
2700 vortex_adbdma_init(vortex);
2702 vortex_adb_init(vortex);
2704 vortex_fifo_init(vortex);
2705 vortex_mixer_init(vortex);
2706 vortex_srcblock_init(vortex);
2708 vortex_eq_init(vortex);
2709 vortex_spdif_init(vortex, 48000, 1);
2710 vortex_Vort3D_enable(vortex);
2713 vortex_wt_init(vortex);
2718 vortex_settimer(vortex, 0x90);
2732 static int vortex_core_shutdown(
vortex_t * vortex)
2737 vortex_eq_free(vortex);
2738 vortex_Vort3D_disable(vortex);
2741 vortex_disable_int(vortex);
2742 vortex_connect_default(vortex, 0);
2744 vortex_fifo_init(vortex);
2746 vortex_adb_init(vortex);
2763 static int vortex_alsafmt_aspfmt(
int alsafmt)
2809 vortex_translateformat(
vortex_t * vortex,
char bits,
char nch,
int encod)
2813 if ((bits != 8) && (bits != 16))
2849 static void vortex_cdmacore_setformat(
vortex_t * vortex,
int bits,
int nch)
2851 short int d, this_148;
2853 d = ((bits >> 3) * nch);
2854 this_148 = 0xbb80 /
d;