/[openvortex]/alsa/pci/au88x0/au88x0_core.c
ViewVC logotype

Diff of /alsa/pci/au88x0/au88x0_core.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by vizard, Sat Jun 7 19:05:04 2003 UTC revision 1.19 by mjander, Sun Jun 8 02:10:45 2003 UTC
# Line 1  Line 1 
1  /*  /*
2      Vortex core low level functions.      Vortex core low level functions.
3            
4     Author: Manuel Jander (mjander@users.sourceforge.cl)
5   These functions are mainly the result of translations made   These functions are mainly the result of translations made
6   from the original disassembly of the au88x0 binary drivers,   from the original disassembly of the au88x0 binary drivers,
7   written by Aureal before they went down.   written by Aureal before they went down.
# Line 53  Line 54 
54                          works now, but chipn' dale effect is still there.                          works now, but chipn' dale effect is still there.
55   16-05-2003 SrcSetupChannel cleanup. Moved the Src setup stuff entirely   16-05-2003 SrcSetupChannel cleanup. Moved the Src setup stuff entirely
56              into au88x0_pcm.c .              into au88x0_pcm.c .
57     06-06-2003 Buffer shifter bugfix. Mixer volume fix.
58    
59  */  */
60    
61  #include "au88x0.h"  #include "au88x0.h"
# Line 438  int  vortex_src_checkratio(vortex_t *vor Line 441  int  vortex_src_checkratio(vortex_t *vor
441      hw_ratio = hwread(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2));      hw_ratio = hwread(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2));
442            
443      while (hw_ratio != desired_ratio) {      while (hw_ratio != desired_ratio) {
444          hwwrite(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2), desired_ratio);                  hwwrite(vortex->mmio, VORTEX_SRC_CONVRATIO + (src << 2), desired_ratio);
445                            
446          if ((lifeboat++) > 15){                  if ((lifeboat++) > 15){
447              printk(KERN_ERR "Vortex: could not set src-%d to %d\n", src, hw_ratio, desired_ratio);                          printk(KERN_ERR "Vortex: src=%d could not set src-%d to %d\n", src, hw_ratio, desired_ratio);
448              break;                          break;
449          }                  }
450      }      }
451            
452      return hw_ratio;      return hw_ratio;
# Line 834  void vortex_adbdma_setfirstbuffer(vortex Line 837  void vortex_adbdma_setfirstbuffer(vortex
837    
838  void vortex_adbdma_setstartbuffer(vortex_t *vortex, int adbdma, int sb) {  void vortex_adbdma_setstartbuffer(vortex_t *vortex, int adbdma, int sb) {
839      dma_t *dma = &vortex->dma_adb[adbdma];      dma_t *dma = &vortex->dma_adb[adbdma];
840            hwwrite(vortex->mmio, VORTEX_ADBDMA_START + (adbdma << 2), (sb << ((NR_ADB-adbdma)*2)));
     hwwrite(vortex->mmio, VORTEX_ADBDMA_START + (adbdma << 2), (sb << (adbdma*2)));  
841          dma->period_real = dma->period_virt = sb;          dma->period_real = dma->period_virt = sb;
842  }  }
843    
# Line 851  void vortex_adbdma_setbuffers(vortex_t * Line 853  void vortex_adbdma_setbuffers(vortex_t *
853          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + 0x4 + (adbdma << 4), addr + size);          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + 0x4 + (adbdma << 4), addr + size);
854          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + 0x8 + (adbdma << 4), addr + (size*2));          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + 0x8 + (adbdma << 4), addr + (size*2));
855          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + 0xc + (adbdma << 4), addr + (size*3));          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + 0xc + (adbdma << 4), addr + (size*3));
856            
857            size--;
858          switch (count) {          switch (count) {
859          case 1:          case 1:
860                  dma->cfg0 = 0x40000000 | 0xce000000;                  dma->cfg0 = 0x80000000 | 0x40000000 | 0x00000000 | (size << 0xc);
861                  dma->cfg1 = 0x00000000 | 0xfc000000;                  dma->cfg1 = 0x00000000 | 0x00000000 | 0x00000000;
862                  break;                  break;
863          case 2:          case 2:
864                  dma->cfg0 = 0x44000000 | 0xdc000000;                  dma->cfg0 = 0x88000000 | 0x44000000 | 0x10000000 | (size << 0xc) | size;
865                  dma->cfg1 = 0x00000000 | 0xfc000000;                  dma->cfg1 = 0x00000000 | 0x00000000 | 0x00000000;
866                    dma->cfg0 |= (size << 0xc) | size;
867                  break;                  break;
868          case 3:          case 3:
869                  dma->cfg0 = 0x44000000 | 0xde000000;                  dma->cfg0 = 0x88000000 | 0x44000000 | 0x12000000 | (size << 0xc) | size;
870                  dma->cfg1 = 0x40000000 | 0xcc000000;                  dma->cfg1 = 0x80000000 | 0x40000000 | 0x00000000 | (size << 0xc);
871                  break;                  break;
872          case 4:          case 4:
873          default:          default:
874                  dma->cfg0 = 0x44000000 | 0xde000000;                  dma->cfg0 = 0x88000000 | 0x44000000 | 0x12000000 | (size << 0xc) | size;
875                  dma->cfg1 = 0x44000000 | 0xfc000000;                  dma->cfg1 = 0x88000000 | 0x44000000 | 0x30000000 | (size << 0xc) | size;
876                  break;                  break;
877          }          }      
         size--;  
         dma->cfg0 |= (size << 0xc) | size;  
         dma->cfg1 |= (size << 0xc) | size;  
878          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG0 + (adbdma << 3), dma->cfg0);          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG0 + (adbdma << 3), dma->cfg0);
879          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG1 + (adbdma << 3), dma->cfg1);          hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG1 + (adbdma << 3), dma->cfg1);
880    
# Line 898  void vortex_adbdma_setmode(vortex_t *vor Line 899  void vortex_adbdma_setmode(vortex_t *vor
899  void vortex_adbdma_bufshift(vortex_t *vortex, int adbdma) {  void vortex_adbdma_bufshift(vortex_t *vortex, int adbdma) {
900          dma_t *dma = &vortex->dma_adb[adbdma];          dma_t *dma = &vortex->dma_adb[adbdma];
901          int page, p, pp, delta, i;          int page, p, pp, delta, i;
902            
903          page = (hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)) >> 0xc) & 0x3;          page = (hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)) & ADB_SUBBUF_MASK) >> ADB_SUBBUF_SHIFT;
904          delta = (page - dma->period_real) & 3;          delta = (page - dma->period_real) & 3;
905          if (delta == 0)          if (delta == 0)
906                  return;                  return;
# Line 907  void vortex_adbdma_bufshift(vortex_t *vo Line 908  void vortex_adbdma_bufshift(vortex_t *vo
908          /* refresh hw page table */          /* refresh hw page table */
909          if (dma->nr_periods > 4) {          if (dma->nr_periods > 4) {
910                  for (i=0 ; i < delta; i++) {                  for (i=0 ; i < delta; i++) {
911                          p = dma->period_virt + i;                          /* p: audio buffer page index */
912                            p = dma->period_virt + i + 4;
913                          if (p >= dma->nr_periods)                          if (p >= dma->nr_periods)
914                                  p -= dma->nr_periods;                                  p -= dma->nr_periods;
915                            /* pp: hardware DMA page index. */
916                          pp = dma->period_real + i;                          pp = dma->period_real + i;
917                          if (pp >= 4)                          if (pp >= 4)
918                                  pp -= 4;                                  pp -= 4;
# Line 1032  void vortex_adbdma_getposition(vortex_t Line 1035  void vortex_adbdma_getposition(vortex_t
1035  }  }
1036    
1037  int  vortex_adbdma_getcursubuffer(vortex_t *vortex, int adbdma) {  int  vortex_adbdma_getcursubuffer(vortex_t *vortex, int adbdma) {
1038      return((hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)) >> 0xc) & 0x3);      return((hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)) & ADB_SUBBUF_MASK) >> ADB_SUBBUF_SHIFT);
1039  }  }
1040    
1041  int inline vortex_adbdma_getlinearpos(vortex_t *vortex, int adbdma) {  int inline vortex_adbdma_getlinearpos(vortex_t *vortex, int adbdma) {
# Line 1166  void vortex_wtdma_setfirstbuffer(vortex_ Line 1169  void vortex_wtdma_setfirstbuffer(vortex_
1169    
1170  void vortex_wtdma_setstartbuffer(vortex_t *vortex, int wtdma, int sb) {  void vortex_wtdma_setstartbuffer(vortex_t *vortex, int wtdma, int sb) {
1171          dma_t *dma = &vortex->dma_wt[wtdma];          dma_t *dma = &vortex->dma_wt[wtdma];
   
1172      hwwrite(vortex->mmio, VORTEX_WTDMA_START + (wtdma << 2), (sb << ((~wtdma)&0xf)*2));      hwwrite(vortex->mmio, VORTEX_WTDMA_START + (wtdma << 2), (sb << ((~wtdma)&0xf)*2));
1173          dma->period_real = dma->period_virt = sb;          dma->period_real = dma->period_virt = sb;
1174  }  }
# Line 1586  void vortex_connection_src_mixin(vortex_ Line 1588  void vortex_connection_src_mixin(vortex_
1588  void vortex_connection_mixin_mix(vortex_t *vortex, int en, unsigned char mixin, unsigned char mix, int a) {  void vortex_connection_mixin_mix(vortex_t *vortex, int en, unsigned char mixin, unsigned char mix, int a) {
1589      if (en) {      if (en) {
1590                  vortex_mix_enableinput(vortex, mix, mixin);                  vortex_mix_enableinput(vortex, mix, mixin);
1591          vortex_mix_setinputvolumebyte(vortex, mix, mixin, 0x08);        // added to original code.          vortex_mix_setinputvolumebyte(vortex, mix, mixin, MIX_DEFIGAIN);        // added to original code.
1592      } else      } else
1593              vortex_mix_disableinput(vortex, mix, mixin, a);              vortex_mix_disableinput(vortex, mix, mixin, a);
1594  }  }
# Line 1631  void vortex_connection_src_src_adbdma(vo Line 1633  void vortex_connection_src_src_adbdma(vo
1633  void vortex_connection_mix_adb(vortex_t *vortex, int en, unsigned char ch,  void vortex_connection_mix_adb(vortex_t *vortex, int en, unsigned char ch,
1634      unsigned char mix, unsigned char dest) {      unsigned char mix, unsigned char dest) {
1635      vortex_route(vortex, en, ch, ADB_MIXOUT(mix), dest);      vortex_route(vortex, en, ch, ADB_MIXOUT(mix), dest);
1636      vortex_mix_setvolumebyte(vortex, mix, 0x08);        // added to original code.      vortex_mix_setvolumebyte(vortex, mix, MIX_DEFOGAIN);        // added to original code.
1637  }  }
1638    
1639  // mixer to src.  // mixer to src.
1640  void vortex_connection_mix_src(vortex_t *vortex, int en, unsigned char ch,  void vortex_connection_mix_src(vortex_t *vortex, int en, unsigned char ch,
1641      unsigned char mix, unsigned char src) {      unsigned char mix, unsigned char src) {
1642      vortex_route(vortex, en, ch, ADB_MIXOUT(mix), ADB_SRCIN(src));      vortex_route(vortex, en, ch, ADB_MIXOUT(mix), ADB_SRCIN(src));
1643      vortex_mix_setvolumebyte(vortex, mix, 0x08);        // added to original code.      vortex_mix_setvolumebyte(vortex, mix, MIX_DEFOGAIN);        // added to original code.
1644  }  }
1645    
1646  /* CODEC connect. */  /* CODEC connect. */
# Line 1731  int  vortex_adb_waveroute(vortex_t *vort Line 1733  int  vortex_adb_waveroute(vortex_t *vort
1733                  vortex_connection_mixin_mix(vortex, en, n, MIX_OUTL, 0);                  vortex_connection_mixin_mix(vortex, en, n, MIX_OUTL, 0);
1734          } else {          } else {
1735                  vortex_connection_mixin_mix(vortex, en, MIX_INL, n, 0);                  vortex_connection_mixin_mix(vortex, en, MIX_INL, n, 0);
1736                  vortex_mix_setvolumebyte(vortex, n, 0x08);                  vortex_mix_setvolumebyte(vortex, n, MIX_DEFOGAIN);
1737                  vortex_mix_setinputvolumebyte(vortex, n, MIX_INL, 0x08);                  vortex_mix_setinputvolumebyte(vortex, n, MIX_INL, MIX_DEFIGAIN);
1738                  vortex_connection_mix_src(vortex, en, 0x11, n, n);                  vortex_connection_mix_src(vortex, en, 0x11, n, n);
1739          }          }
1740          if (nr_ch == 1) {          if (nr_ch == 1) {
# Line 1751  int  vortex_adb_waveroute(vortex_t *vort Line 1753  int  vortex_adb_waveroute(vortex_t *vort
1753                          vortex_connection_adbdma_src_src(vortex, en, n, adbdma, n, n+1);                          vortex_connection_adbdma_src_src(vortex, en, n, adbdma, n, n+1);
1754                  } else {                  } else {
1755                          vortex_connection_mixin_mix(vortex, en, MIX_INR, n+1, 0);                          vortex_connection_mixin_mix(vortex, en, MIX_INR, n+1, 0);
1756                          vortex_mix_setvolumebyte(vortex, n+1, 0x08);                          vortex_mix_setvolumebyte(vortex, n+1, MIX_DEFOGAIN);
1757                          vortex_mix_setinputvolumebyte(vortex, n+1, MIX_INR, 0x08);                          vortex_mix_setinputvolumebyte(vortex, n+1, MIX_INR, MIX_DEFIGAIN);
1758                          vortex_connection_mix_src(vortex, en, 0x11, n+1, n+1);                          vortex_connection_mix_src(vortex, en, 0x11, n+1, n+1);
1759                          vortex_connection_src_src_adbdma(vortex, en, n, n, n+1, adbdma);                          vortex_connection_src_src_adbdma(vortex, en, n, n, n+1, adbdma);
1760                  }                  }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26