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

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

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

revision 1.1 by mjander, Thu Aug 7 01:58:51 2003 UTC revision 1.2 by vizard, Sun Aug 10 20:12:04 2003 UTC
# Line 1  Line 1 
1  #define __NO_VERSION__  /***************************************************************************
2  #include "../../alsa-kernel/pci/au88x0/au88x0_a3d.c"   *            au88x0_a3d.c
3     *
4     *  Fri Jul 18 14:16:22 2003
5     *  Copyright  2003  mjander
6     *  mjander@users.sourceforge.net
7     *
8     * A3D. You may think i'm crazy, but this may work someday. Who knows...
9     ****************************************************************************/
10    
11    /* CA3dSourceHw */
12    
13    void CA3dSourceHw::CA3dSourceHw(CAsp4HwIO *hwio, int a,int b) {
14            CA3dSourceHw->this00 = hwio;
15            CA3dSourceHw->this04 = a;
16            CA3dSourceHw->this08 = b;
17    }
18    
19    void CA3dSourceHw::Initialize(int a, int b) {
20            CA3dSourceHw->this04 = a;
21            CA3dSourceHw->this08 = b;
22            CA3dSourceHw::ZeroState(void);
23    }
24    
25    #define addr(a,b,c) (a + (c << 0xd) + (d*(1 + (8*4 - 3)*8))*4)
26    
27    void CA3dSourceHw::SetTimeConsts(short a, short b, short c, short d) {
28            hwwrite(vortex->mmio, addr(0x1837C, this04, this08),  a);
29            hwwrite(vortex->mmio, addr(0x18388, this04, this08),  b);
30            hwwrite(vortex->mmio, addr(0x18380, this04, this08),  c);
31            hwwrite(vortex->mmio, addr(0x18384, this04, this08),  d);
32    }
33    
34    void CA3dSourceHw::GetTimeConsts(short a, short b, short c, short d) {
35            
36    }
37    
38    void CA3dSourceHw::SetAtmosTarget(short a,short b,short c,short d,short e) {
39            hwwrite(vortex->mmio, addr(0x190Ec, this04, this08), (e << 0x10) | d);
40            hwwrite(vortex->mmio, addr(0x190F4, this04, this08), (b << 0x10) | a);
41            hwwrite(vortex->mmio, addr(0x190FC, this04, this08), c);
42    }
43    
44    void CA3dSourceHw::SetAtmosTarget(short *a,short *b,short *c,short *d,short *e) {
45    }
46    
47    void CA3dSourceHw::SetAtmosCurrent(short a,short b,short c,short d,short e) {
48            hwwrite(vortex->mmio, addr(0x190E8, this04, this08), (e << 0x10) | d);
49            hwwrite(vortex->mmio, addr(0x190f0, this04, this08), (b << 0x10) | a);
50            hwwrite(vortex->mmio, addr(0x190f8, this04, this08), c);
51    }
52    
53    void CA3dSourceHw::GetAtmosCurrent(short *a,short *b,short *c,short *d,short *e) {
54            *d = hwread(vortex->mmio, addr(0x180e8, this04, this08));
55            *e = hwread(vortex->mmio, addr(0x190e8, this04, this08));
56            *b = hwread(vortex->mmio, addr(0x180f0, this04, this08));
57            *a = hwread(vortex->mmio, addr(0x190f0, this04, this08));
58            *c = hwread(vortex->mmio, addr(0x180f8, this04, this08));
59    }
60    
61    void CA3dSourceHw::SetAtmosState(short a,short b,short c,short d) {
62            hwwrite(vortex->mmio, addr(0x1838C, this04, this08), a);
63            hwwrite(vortex->mmio, addr(0x18390, this04, this08), b);
64            hwwrite(vortex->mmio, addr(0x18394, this04, this08), c);
65            hwwrite(vortex->mmio, addr(0x18398, this04, this08), d);
66    }
67    
68    void CA3dSourceHw::GetAtmosState(short a,short b,short c,short d) {
69            
70    }
71    
72    
73    #define addr2(a,b,c, i) (a + (((this08<<0xb)+i)<<2) + (this04*(5*9*2 - 1)*4*2))
74    void CA3dSourceHw::SetHrtfTarget(short const *a,short const     *b) {
75            int i;
76            
77            for (i=0; i<0x38; i++)
78                    hwwrite(vortex->mmio, addr2(0x19100, this04, this08, i), (b[i]<<0x10) | a[i]);
79    }
80    
81    void CA3dSourceHw::GetHrtfTarget(short const *a,short const     *b) {
82    }
83    
84    void CA3dSourceHw::SetHrtfCurrent(short const *a,short const *b) {
85            int i;
86            
87            for (i=0; i<0x38; i++)
88                    hwwrite(vortex->mmio, addr2(0x19000, this04, this08, i), (b[i]<<0x10) | a[i]);  
89    }
90    
91    void CA3dSourceHw::GetHrtfCurrent(short const *a,short const *b) {
92            int i;
93            // FIXME: verify this!
94            for (i=0; i<0x38; i++)
95                    a[i] = hwread(vortex->mmio, addr2(0, this04+0xc, this08, i));
96            for (i=0; i<0x38; i++)
97                    b[i] = hwread(vortex->mmio, addr2(0x19000, this04, this08, i));
98    }
99    void CA3dSourceHw::SetHrtfState(short const *a,short const *b) {
100            int i;
101            
102            for (i=0; i<0x38; i++)
103                    hwwrite(vortex->mmio, addr2(0x191e8, this04, this08, i), (b[i]<<0x10) | a[i]);  
104    }
105    
106    void CA3dSourceHw::GetHrtfState(short const *a,short const *b) {
107            int i;
108            // FIXME: verify this!
109            for (i=0; i<0x38; i++)
110                    a[i] = hwread(vortex->mmio, addr2(0, this04+0x6a, this08, i));
111            for (i=0; i<0x38; i++)
112                    b[i] = hwread(vortex->mmio, addr2(0x191e8, this04, this08, i));
113    }
114    
115    void CA3dSourceHw::SetItdTarget(short litd,short ritd) {
116            if (litd < 0)
117                    litd = 0;
118            if (litd > 0x57FF)
119                    litd = 0x57FF;
120            if (ritd < 0)
121                    ritd = 0;
122            if (ritd > 0x57FF)
123                    ritd = 0x57FF;
124            hwwrite(vortex->mmio, addr(0x191DF+5, this04, this08), (ritd<<0x10)|litd);
125    }
126    
127    void CA3dSourceHw::GetItdTarget(short *litd, short *ritd) {
128            *ritd = hwread(vortex->mmio, addr(0x181E4, this04, this08));
129            *litd = hwread(vortex->mmio, addr(0x191E4, this04, this08));
130    }
131    
132    void CA3dSourceHw::SetItdCurrent(short litd, short ritd) {
133                    litd = 0;
134            if (litd > 0x57FF)
135                    litd = 0x57FF;
136            if (ritd < 0)
137                    ritd = 0;
138            if (ritd > 0x57FF)
139                    ritd = 0x57FF;
140            hwwrite(vortex->mmio, addr(0x191DF+1, this04, this08), (ritd<<0x10)|litd);
141    }
142    
143    void CA3dSourceHw::GetItdCurrent(short *litd,short *ritd) {
144            *ritd = hwread(vortex->mmio, addr(0x181E0, this04, this08));
145            *litd = hwread(vortex->mmio, addr(0x191E0, this04, this08));
146    }
147    
148    void CA3dSourceHw::SetItdDline(short const      *dline) {
149            int i;
150            
151            for (i=0; i<0x28; i++)
152                    hwwrite(vortex->mmio, addr2(0x182C8, this04, this08, i), dline[i])
153    }
154    
155    void CA3dSourceHw::GetItdDline(short *dline) {
156            int i;
157            
158            for (i=0; i<0x28; i++)
159                    dline[i] = hwwrite(vortex->mmio, addr2(0x182C8, this04, this08, i));    
160    }
161    
162    void CA3dSourceHw::SetGainTarget(short a,short b) {
163            hwwrite(vortex->mmio, addr(0x190E4, this04, this08), (b<<0x10)|a);
164    }
165    
166    void CA3dSourceHw::GetGainTarget(short *,short *) {
167            *b = hwread(vortex->mmio, addr(0x180e4, this04, this08));
168            *a = hwread(vortex->mmio, addr(0x190e4, this04, this08));
169    }
170    
171    void CA3dSourceHw::SetGainCurrent(short a,short b) {
172            hwwrite(vortex->mmio, addr(0x190DC+4, this04, this08), (b<<0x10)|a);
173    }
174    
175    void CA3dSourceHw::GetGainCurrent(short *a,short *b) {
176            *b = hwread(vortex->mmio, addr(0x180e0, this04, this08));
177            *a = hwread(vortex->mmio, addr(0x190e0, this04, this08));
178    }
179    
180    void CA3dSourceHw::GetHrtfOutput(short *left,short *right) {
181            *left = hwread(vortex->mmio, addr(0x1839C, this04, this08));
182            *right = hwread(vortex->mmio, addr(0x183A0, this04, this08));
183    }
184    
185    void CA3dSourceHw::SetHrtfOutput(short left,short right) {
186            hwwrite(vortex->mmio, addr(0x1839C, this04, this08), left);
187            hwwrite(vortex->mmio, addr(0x183a0, this04, this08), right);
188    }
189    
190    void CA3dSourceHw::SetA3DSampleRate(int sr) {
191            int esp0 = 0;
192            esp0 = (((esp0 & 0x7fffffff)|0xB8000000)&0x7) | ((sr&0x1f)<<3);
193            hwwrite(vortex->mmio, 0x19C38 + (this08<<0xd), esp0);
194    }
195    
196    void CA3dSourceHw::GetA3DSampleRate(int *sr) {
197            *sr = ((hwread(vortex->mmio, 0x19C38 + (this08<<0xd))>>3)&0x1f);
198            
199    }
200    
201    void CA3dSourceHw::EnableA3D(void) {
202            hwwrite(vortex->mmio, 19C38 + (this08<<0xd), 0xF0000001);
203    }
204    
205    void CA3dSourceHw::DisableA3D(void) {
206            hwwrite(vortex->mmio, 19C38 + (this08<<0xd), 0xF0000000);
207    }
208    
209    void CA3dSourceHw::SetA3DControlReg(unsigned long ctrl) {
210            hwwrite(vortex->mmio, 19C38 + (this08<<0xd), ctrl);
211    }
212    
213    void CA3dSourceHw::GetA3DControlReg(unsigned long *ctrl) {
214            *ctrl = hwread(vortex->mmio, 19C38 + (this08<<0xd));
215    }
216    
217    void CA3dSourceHw::SetA3DPointerReg(unsigned long ptr) {
218            hwwrite(vortex->mmio, 19c40 + (this08<<0xd), ctrl);
219    }
220    
221    void CA3dSourceHw::GetA3DPointerReg(unsigned long *ptr) {
222            *ptr = hwread(vortex->mmio, 19C40 + (this08<<0xd));
223    }
224    
225    void CA3dSourceHw::ZeroSliceIO(void) {
226            int i;
227            
228            for (i=0; i<8; i++)
229                    hwwrite(vortex->mmio, 0x19C00 + (((this08<<0xb)+i)*4), 0);
230            for (i=0; i<4; i++)
231                    hwwrite(vortex->mmio, 0x19C20 + (((this08<<0xb)+i)*4), 0);      
232    }
233    
234    void CA3dSourceHw::ZeroState(void) {
235            int i;
236            
237            CA3dSourceHw::SetAtmosState(0,0,0,0);
238            CA3dSourceHw::SetHrtfState(A3dHrirZeros, A3dHrirZeros);
239            CA3dSourceHw::SetItdDline(A3dItdDlineZeros, A3dItdDlineZeros);
240            CA3dSourceHw::SetHrtfOutput(0, 0);
241            CA3dSourceHw::SetTimeConsts(0,0,0,0);
242            CA3dSourceHw::SetAtmosCurrent(0,0,0,0,0);
243            CA3dSourceHw::SetAtmosTarget(0,0,0,0,0);
244            CA3dSourceHw::SetItdCurrent(0,0);
245            CA3dSourceHw::SetItdTarget(0,0);
246            CA3dSourceHw::SetGainCurrent(0,0);
247            // The guy who originally wrote this surely was smoking crack...
248            CA3dIO::WriteReg(190E4 + (this08<<0xd) + (this04*5*9*2 - this04)*8,0,0);
249            
250            CA3dSourceHw::SetHrtfCurrent(A3dHrirZeros, A3dHrirZeros);
251            CA3dSourceHw::SetHrtfTarget(A3dHrirZeros, A3dHrirZeros)
252    }
253    
254    void CA3dSourceHw::ZeroStateA3D(void) {
255            int i, ii, var, var2;
256            
257            CA3dSourceHw::SetA3DControlReg(0);
258            CA3dSourceHw::SetA3DPointerReg(0);
259            var = this08;
260            var2 = this04; // ??
261            for (ii=0; ii<4; ii++) {
262                    this08 = ii;
263                    
264                    CA3dSourceHw::ZeroSliceIO(void);
265                    CA3dSourceHw::ZeroState(void);  
266            }
267            this04 = var2;
268            this08 = var;
269    }
270    
271    void CA3dSourceHw::ProgramPipe(void) {
272            CA3dSourceHw::SetTimeConsts(0,0,0,0);
273            CA3dSourceHw::SetAtmosCurrent(0, 0x4000, 0,0,0);
274            CA3dSourceHw::SetAtmosTarget(0x4000,0,0,0,0);
275            CA3dSourceHw::SetItdCurrent(0,0);
276            CA3dSourceHw::SetItdTarget(0,0);
277            CA3dSourceHw::SetGainCurrent(0x7fff,0x7fff);
278            CA3dSourceHw::SetGainTarget(0x7fff,0x7fff);
279            CA3dSourceHw::SetHrtfCurrent(A3dHrirImpulse, A3dHrirImpulse);
280            CA3dSourceHw::SetHrtfTarget(A3dHrirImpulse, A3dHrirImpulse);
281    }
282    
283    void CA3dSourceHw::ClearVDBData(unsigned long a) {
284            hwwrite(vortex->mmio, 0x19c00 + (((a>>2)*255*4)+a)*8, 0);
285            hwwrite(vortex->mmio, 0x19c04 + (((a>>2)*255*4)+a)*8, 0);
286    }
287    /*CA3dIO*/
288    
289    void CA3dIO::WriteReg(unsigned long addr, short a, short b) {
290            hwwrite(vortex->mmio, addr, (a<<0x10)|b);
291    }
292    
293    /* CVort3dRend */
294    
295    void CVort3DRend::CVort3DRend(class CAsp4Core *core,class CAsp4HwIO     *hwio) {
296            this00 = core;
297            this04 = hwio;
298            this08 = 0;
299    }
300    
301    void CVort3DRend::~CVort3DRend(void) {
302            if (this08)
303                    operator delete(this08);
304    }
305    
306    int CVort3DRend::Initialize(unsigned short a) {
307            if (this00 == 0)
308                    return -1;
309            this14 = a;
310            CXtalkHw = operator new(4);
311            CXtalkHw::CXtalkHw(this04);
312    
313            CXtalkHw::SetGains(XtalkGainsAllChan);
314            if (this14) {
315                    if (this08==0xffff)
316                            CXtalkHw::ProgramXtalkNarrow(void);
317                    else
318                            CXtalkHw::ProgramXtalkWide(void)
319            } else {
320                    CXtalkHw::ProgramPipe(void);
321            }
322            CXtalkHw::SetSampleRate(0x11);
323            CXtalkHw::Enable(void);
324    }
325    
326    int CVort3DRend::SetGlobalControl(struct _XTALKctrl *xtctrl) {
327            if (xtctrl==0)
328                    return 0;
329            
330            this0c->this04 = xtctrl->this04;
331            this0c->this08 = xtctrl->this08;
332            this0c->this0c = xtctrl->this0c;
333            
334            this0c = xtctrl->this00;
335            CXtalkHw = this08;
336            if (this14) {
337                    if (this08==0xffff)
338                            CXtalkHw::ProgramXtalkNarrow(void);
339                    else
340                            CXtalkHw::ProgramXtalkWide(void)
341            } else {
342                    CXtalkHw::ProgramPipe(void);
343            }
344    }
345    
346    int  CVort3DRend::GetGlobalControl(struct _XTALKctrl *xtctrl) {
347    }
348    int CVort3DRend::AddBuffer(class CVort3dWave *a) {
349            return 0;
350    }
351    int CVort3DRend::RemoveBuffer(class CVort3dWave *a) {
352            return 0;
353    }
354    /* CVort3dWave */
355    void CVort3dWave::CVort3dWave(class CAsp4Core *,class CAsp4HwIO *,class CHrtfMgr *) {
356            
357    }
358    //174743
359    void CVort3DWave::SetLRGains(void) {
360            
361            
362    }
363    
364    int  CVort3dWave::Set3dParms(unsigned long offset, unsigned long arg4, void * arg8) {
365            
366            if (offset)
367                    return 80070057;
368            if (arg4 == 0xf6) {
369                    CVort3dWave::Anzio3dToSuperCtrl((Anzio3d *) arg8, (A3DCTRL_SRC_SUPER *) this_370);
370                    CVort3dWave::Set3dParms((A3DCTRL_SRC_SUPER *) this_370);
371                    return 0;
372            }
373            if (arg4 == 0x40) {
374                    CVort3dWave::Set3dParms((A3DCTRL_SRC_SUPER *) arg8)
375            }
376    }
377    
378    int  CVort3dWave::Set3dParms(struct A3DCTRL_SRC_SUPER *) {
379            int var14;
380            struct var0 {
381                    int a;
382                    short b;
383                    char c;
384            };
385    
386            CAsp4Core = this_318;
387            CAsp4Core::GetProperty((COREPROPERTY) 4, (void *) &var14, (ulong) 4);
388            CAsp4Core::GetProperty((COREPROPERTY) 1, (void *) &var0+0x10, (ulong) 0x10);
389            if ((var0.b != this_354)||(var14 != this_350)) {
390                    this_354 = var0.b;
391                    this_350 = var14;
392                    CHrtfMgr = this_344;
393                    if (var14 == 1) {
394                            if (var0.b)
395                                    CHrtfMgr::Initialize((ulong) 0BB80, (ulong) 0x3a, (ulong) 0x102)
396                            else
397                                    CHrtfMgr::Initialize((ulong) 0BB80, (ulong) 2, (ulong) 0x101);
398                    } else
399                            CHrtfMgr::Initialize((ulong) 0BB80, (ulong) 0x38, (ulong) 0);
400            }
401            if (var14 == 1) {
402                    if (var0.b == 0)
403                            CVort3dWave::RenderQuadPan((A3DCTRL_SRC_SUPER *) arg0);
404                    else
405                            CVort3dWave::RenderSuperQuad((A3DCTRL_SRC_SUPER *) arg0);
406                    return 0;
407            }
408            eax = CAdbTopology::GetA3DSource(void);
409            if (eax >= 0)
410                    CVort3dWave::Render3d((A3DCTRL_SRC_SUPER *) arg0);
411            else
412                    CVort3dWave::Render2d((A3DCTRL_SRC_SUPER *) arg0);
413            return 0;
414    }
415    
416    void CVort3dWave::Render2d(struct A3DCTRL_SRC_SUPER *) {
417            
418            CVort3dWave::Calc2d(A3DCTRL_EAR *,A3DCTRL_EAR   *,float,ulong *,_ASPVOLUME *);
419            
420            CVort3dWave::SetLRGains(void);
421            CAdbTopology::SetFilter(ulong);
422            
423    }
424    void CVort3dWave::Render3d(struct A3DCTRL_SRC_SUPER *) {
425            
426            CA3dSourceHw::SetAtmosTarget(short,short,short,short,short);
427            CA3dSourceHw::SetAtmosCurrent(short,short,short,short,short);
428            CVort3dWave::SetLRGains(void);
429            CA3dSourceHw::SetHrtfTarget(short const *,short const   *);
430            CA3dSourceHw::SetHrtfCurrent(short const *,short const *)
431            CA3dSourceHw::SetItdTarget(short,short);
432            
433            
434    }
435    
436    void CVort3dWave::RenderQuadPan(struct A3DCTRL_SRC_SUPER *) {
437            
438            
439    }
440    
441    void CAdbTopology::SetFilter(unsigned long) {
442            //line 101587
443            
444    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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