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

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

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

revision 1.4 by mjander, Thu Aug 7 01:58:51 2003 UTC revision 1.5 by vizard, Sun Aug 10 20:00:34 2003 UTC
# Line 1  Line 1 
1  #define __NO_VERSION__  /***************************************************************************
2  #include "../../alsa-kernel/pci/au88x0/au88x0_eq.c"   *            au88x0_eq.c
3     *  Aureal Vortex Hardware EQ control/access.
4     *
5     *  Sun Jun  8 18:19:19 2003
6     *  2003  Manuel Jander (mjander@users.sourceforge.net)
7     *  
8     *  02 July 2003: First time something works :)
9     *  
10     *  TODO:
11     *     - Debug (testing)
12     *     - Implement peak visualization support.
13     *
14     ****************************************************************************/
15    #include "au88x0.h"
16    #include "au88x0_eq.h"
17    #include "au88x0_eqdata.c"
18    
19    /* CEqHw.s */
20    void vortex_EqHw_SetTimeConsts(vortex_t *vortex, u16 a, u16 b) {
21            hwwrite(vortex->mmio, 0x2b3c4, a);
22            hwwrite(vortex->mmio, 0x2b3c8, b);
23    }
24    
25    void vortex_EqHw_GetTimeConsts(vortex_t *vortex, u16 *a, u16 *b) {
26            *a = hwread(vortex->mmio, 0x2b3c4);
27            *b = hwread(vortex->mmio, 0x2b3c8);
28    }
29    
30    void vortex_EqHw_SetLeftCoefs(vortex_t *vortex, u16 a[]) {
31            eqhw_t *eqhw = &(vortex->eq.this04);
32            int eax, i = 0, n /*esp2c*/ = 0;
33            
34            if (eqhw->this04 <= n)
35                    return;
36                    
37            do {
38                    hwwrite(vortex->mmio, 0x2b000 + n*0x30, a[i+0]);
39                    hwwrite(vortex->mmio, 0x2b004 + n*0x30, a[i+1]);
40                    
41                    if (eqhw->this08 == 0) {
42                            hwwrite(vortex->mmio, 0x2b008 + n*0x30, a[i+2]);
43                            hwwrite(vortex->mmio, 0x2b00c + n*0x30, a[i+3]);
44                            eax = a[i+4]; //esp24;
45                    } else {
46                            if (a[2+i] == 0x8000)
47                                    eax = 0x7fff;
48                            else
49                                    eax = ~a[2+i];
50                            hwwrite(vortex->mmio, 0x2b008 + n*0x30, eax & 0xffff);
51                            if (a[3+i] == 0x8000)
52                                    eax = 0x7fff;
53                            else
54                                    eax = ~a[3+i];
55                            hwwrite(vortex->mmio, 0x2b00c + n*0x30, eax & 0xffff);
56                            if (a[4+i] == 0x8000)
57                                    eax = 0x7fff;
58                            else
59                                    eax = ~a[4+i];
60                    }
61                    hwwrite(vortex->mmio, 0x2b010 + n*0x30, eax);
62                    
63                    n++;
64                    i += 5;
65            } while(n < eqhw->this04);      
66    }
67    
68    void vortex_EqHw_GetLeftCoefs(vortex_t *vortex, u16 a[]) {
69            
70            
71    }
72    
73    void vortex_EqHw_SetRightCoefs(vortex_t *vortex, u16 a[]) {
74            eqhw_t *eqhw = &(vortex->eq.this04);
75            int i = 0, n /*esp2c*/ = 0, eax;
76            
77            if (eqhw->this04 <= n)
78                    return;
79            
80            do {
81                    hwwrite(vortex->mmio, 0x2b1e0 + n*0x30, a[0+i]);
82                    hwwrite(vortex->mmio, 0x2b1e4 + n*0x30, a[1+i]);
83                    
84                    if (eqhw->this08 == 0) {
85                            hwwrite(vortex->mmio, 0x2b1e8 + n*0x30, a[2+i]);
86                            hwwrite(vortex->mmio, 0x2b1ec + n*0x30, a[3+i]);
87                            eax = a[4+i]; //*esp24;
88                    } else {
89                            if (a[2+i] == 0x8000)
90                                    eax = 0x7fff;
91                            else
92                                    eax = ~(a[2+i]);
93                            hwwrite(vortex->mmio, 0x2b1e8 + n*0x30, eax & 0xffff);
94                            if (a[3+i] == 0x8000)
95                                    eax = 0x7fff;
96                            else
97                                    eax = ~a[3+i];
98                            hwwrite(vortex->mmio, 0x2b1ec + n*0x30, eax & 0xffff);
99                            if (a[4+i] == 0x8000)
100                                    eax = 0x7fff;
101                            else
102                                    eax = ~a[4+i];
103                    }
104                    hwwrite(vortex->mmio, 0x2b1f0 + n*0x30, eax);
105                    i += 5;
106                    n++;    
107            } while (n < eqhw->this04);
108            
109    }
110    
111    void vortex_EqHw_GetRightCoefs(vortex_t *vortex, u16 a[]) {
112            
113            
114    }
115    
116    void vortex_EqHw_SetLeftStates(vortex_t *vortex, u16 a[], u16 b[]) {
117            eqhw_t *eqhw = &(vortex->eq.this04);
118            int i = 0, ebx = 0;
119            
120            hwwrite(vortex->mmio, 0x2b3fc, a[0]);
121            hwwrite(vortex->mmio, 0x2b400, a[1]);
122            
123            if (eqhw->this04 < 0)
124                    return;
125            
126            do {
127                    hwwrite(vortex->mmio, 0x2b014 + (i*0xc), b[i]);
128                    hwwrite(vortex->mmio, 0x2b018 + (i*0xc), b[1+i]);
129                    hwwrite(vortex->mmio, 0x2b01c + (i*0xc), b[2+i]);
130                    hwwrite(vortex->mmio, 0x2b020 + (i*0xc), b[3+i]);
131                    i += 4;
132                    ebx++;
133            } while (eqhw->this04 > ebx);
134    }
135    
136    void vortex_EqHw_GetLeftStates(vortex_t *vortex, u16 *a, u16 b[]) {
137    
138            
139    }
140    
141    void vortex_EqHw_SetRightStates(vortex_t *vortex, u16 a[], u16 b[]) {
142            eqhw_t *eqhw = &(vortex->eq.this04);
143            int i = 0, ebx = 0;
144            
145            hwwrite(vortex->mmio, 0x2b404, a[0]);
146            hwwrite(vortex->mmio, 0x2b408, a[1]);
147            
148            if (eqhw->this04 < 0)
149                    return;
150                    
151            do {
152                    hwwrite(vortex->mmio, 0x2b1f4 + (i*0xc), b[i]);
153                    hwwrite(vortex->mmio, 0x2b1f8 + (i*0xc), b[1+i]);
154                    hwwrite(vortex->mmio, 0x2b1fc + (i*0xc), b[2+i]);
155                    hwwrite(vortex->mmio, 0x2b200 + (i*0xc), b[3+i]);              
156                    i += 4;
157                    ebx++;
158            } while (ebx < eqhw->this04);
159    }
160    
161    void vortex_EqHw_GetRightStates(vortex_t *vortex, u16 *a, u16 b[]) {
162            
163    }
164    
165    void vortex_EqHw_SetBypassGain(vortex_t *vortex, u16 a, u16 b) {
166            eqhw_t *eqhw = &(vortex->eq.this04);
167            int eax;
168            
169            if (eqhw->this08 == 0) {
170                    hwwrite(vortex->mmio, 0x2b3d4, a);
171                    hwwrite(vortex->mmio, 0x2b3ec, b);
172            } else {
173                    if (a == 0x8000)
174                            eax = 0x7fff;
175                    else
176                            eax = ~a;
177                    hwwrite(vortex->mmio, 0x2b3d4, eax & 0xffff);
178                    if (b == 0x8000)
179                            eax = 0x7fff;
180                    else
181                            eax = ~b;
182                    hwwrite(vortex->mmio, 0x2b3ec, eax & 0xffff);
183            }
184    }
185    
186    void vortex_EqHw_SetA3DBypassGain(vortex_t *vortex, u16 a, u16 b) {
187            
188            hwwrite(vortex->mmio, 0x2b3e0, a);
189            hwwrite(vortex->mmio, 0x2b3f8, b);
190    }
191    
192    void vortex_EqHw_SetCurrBypassGain(vortex_t *vortex, u16 a, u16 b) {
193            
194            hwwrite(vortex->mmio, 0x2b3d0, a);
195            hwwrite(vortex->mmio, 0x2b3e8, b);
196    }
197    
198    void vortex_EqHw_SetCurrA3DBypassGain(vortex_t *vortex, u16 a, u16 b) {
199            
200            hwwrite(vortex->mmio, 0x2b3dc, a);
201            hwwrite(vortex->mmio, 0x2b3f4, b);
202    }
203    
204    void vortex_EqHw_SetLeftGainsSingleTarget(vortex_t *vortex, u16 index, u16 b) {
205            hwwrite(vortex->mmio, 0x2b02c + (index*0x30), b);
206    }
207    
208    void vortex_EqHw_SetRightGainsSingleTarget(vortex_t *vortex, u16 index, u16 b) {
209            hwwrite(vortex->mmio, 0x2b20c + (index*0x30), b);
210    }
211    
212    void vortex_EqHw_SetLeftGainsTarget(vortex_t *vortex, u16 a[]) {
213            eqhw_t *eqhw = &(vortex->eq.this04);
214            int ebx=0;
215            
216            if (eqhw->this04 < 0)
217                    return;
218            do {
219                    hwwrite(vortex->mmio, 0x2b02c + ebx*0x30, a[ebx]);
220                    ebx++;
221            } while (ebx < eqhw->this04);
222    }
223    
224    void vortex_EqHw_SetRightGainsTarget(vortex_t *vortex, u16 a[]) {
225            eqhw_t *eqhw = &(vortex->eq.this04);
226            int ebx=0;
227            
228            if (eqhw->this04 < 0)
229                    return;
230            
231            do {
232                    hwwrite(vortex->mmio, 0x2b20c + ebx*0x30, a[ebx]);
233                    ebx++;
234            } while (ebx < eqhw->this04);  
235    }
236    
237    void vortex_EqHw_GetLeftGainsTarget(vortex_t *vortex, u16 a[]) {
238            eqhw_t *eqhw = &(vortex->eq.this04);
239            int ebx=0;
240            
241            if (eqhw->this04 < 0)
242                    return;
243            
244            do {
245                    a[ebx] = hwread(vortex->mmio, 0x2b02c + ebx*0x30);
246                    ebx++;
247            } while (ebx < eqhw->this04);
248    }
249    
250    void vortex_EqHw_GetRightGainsTarget(vortex_t *vortex, u16 a[]) {
251            eqhw_t *eqhw = &(vortex->eq.this04);
252            int ebx=0;
253            
254            if (eqhw->this04 < 0)
255                    return;
256            
257            do {
258                    a[ebx] = hwread(vortex->mmio, 0x2b20c + ebx*0x30);
259                    ebx++;
260            } while (ebx < eqhw->this04);  
261    }
262    
263    void vortex_EqHw_SetLeftGainsCurrent(vortex_t *vortex, u16 a[]) {
264            eqhw_t *eqhw = &(vortex->eq.this04);
265            int ebx=0;
266            
267            if (eqhw->this04 < 0)
268                    return;
269            
270            do {
271                    hwwrite(vortex->mmio, 0x2b028 + ebx*0x30, a[ebx]);
272                    ebx++;
273            } while (ebx < eqhw->this04);
274    }
275    
276    void vortex_EqHw_SetRightGainsCurrent(vortex_t *vortex, u16 a[]) {
277            eqhw_t *eqhw = &(vortex->eq.this04);
278            int ebx=0;
279            
280            if (eqhw->this04 < 0)
281                    return;
282            
283            do {
284                    hwwrite(vortex->mmio, 0x2b208 + ebx*0x30, a[ebx]);
285                    ebx++;
286            } while (ebx < eqhw->this04);  
287    }
288    
289    void vortex_EqHw_GetLeftGainsCurrent(vortex_t *vortex, u16 a[]) {
290            eqhw_t *eqhw = &(vortex->eq.this04);
291            int ebx=0;
292            
293            if (eqhw->this04 < 0)
294                    return;
295            
296            do {
297                    a[ebx] = hwread(vortex->mmio, 0x2b028 + ebx*0x30);
298                    ebx++;
299            } while (ebx < eqhw->this04);
300    }
301    
302    void vortex_EqHw_GetRightGainsCurrent(vortex_t *vortex, u16 a[]) {
303            eqhw_t *eqhw = &(vortex->eq.this04);
304            int ebx=0;
305            
306            if (eqhw->this04 < 0)
307                    return;
308            
309            do {
310                    a[ebx] = hwread(vortex->mmio, 0x2b208 + ebx*0x30);
311                    ebx++;
312            } while (ebx < eqhw->this04);  
313    }
314    
315    void vortex_EqHw_SetLevels(vortex_t *vortex, u16 a[]) {
316            eqhw_t *eqhw = &(vortex->eq.this04);
317            int ebx;
318            
319            if (eqhw->this04 < 0)
320                    return;
321            
322            ebx = 0;
323            do {
324                    hwwrite(vortex->mmio, 0x2b024 + ebx*0x30, a[ebx]);
325                    ebx++;
326            } while (ebx < eqhw->this04);
327            
328            hwwrite(vortex->mmio, 0x2b3cc, a[eqhw->this04]);
329            hwwrite(vortex->mmio, 0x2b3d8, a[eqhw->this04+1]);
330            
331            ebx = 0;
332            do {
333                    hwwrite(vortex->mmio, 0x2b204 + ebx*0x30, a[ebx + (eqhw->this04+2)]);
334                    ebx++;
335            } while (ebx < eqhw->this04);
336            
337            hwwrite(vortex->mmio, 0x2b3e4, a[2+(eqhw->this04*2)]);
338            hwwrite(vortex->mmio, 0x2b3f0, a[3+(eqhw->this04*2)]);
339    }
340    
341    void vortex_EqHw_GetLevels(vortex_t *vortex, u16 a[]) {
342            eqhw_t *eqhw = &(vortex->eq.this04);
343            int ebx;
344            
345            if (eqhw->this04 < 0)
346                    return;
347            
348            ebx = 0;
349            do {
350                    a[ebx] = hwread(vortex->mmio, 0x2b024 + ebx*0x30);
351                    ebx++;
352            } while (ebx < eqhw->this04);
353            
354            a[eqhw->this04] = hwread(vortex->mmio, 0x2b3cc);
355            a[eqhw->this04+1] = hwread(vortex->mmio, 0x2b3d8);
356            
357            ebx = 0;
358            do {
359                    a[ebx+(eqhw->this04+2)] = hwread(vortex->mmio, 0x2b204 + ebx*0x30);
360                    ebx++;
361            } while (ebx < eqhw->this04);
362            
363            a[2+(eqhw->this04*2)] = hwread(vortex->mmio, 0x2b3e4);
364            a[3+(eqhw->this04*2)] = hwread(vortex->mmio, 0x2b3f0);
365    }
366    
367    void vortex_EqHw_SetControlReg(vortex_t *vortex, unsigned long reg) {
368            hwwrite(vortex->mmio, 0x2b440, reg);
369    }
370    
371    void vortex_EqHw_GetControlReg(vortex_t *vortex, unsigned long *reg) {
372            *reg = hwread(vortex->mmio, 0x2b440);
373    }
374    
375    void vortex_EqHw_SetSampleRate(vortex_t *vortex, int sr) {
376            hwwrite(vortex->mmio, 0x2b440, ((sr & 0x1f) << 3) | 0xb800);
377    }
378    
379    void vortex_EqHw_GetSampleRate(vortex_t *vortex, int *sr) {
380            *sr = (hwread(vortex->mmio, 0x2b440) >> 3) & 0x1f;
381    }
382    
383    void vortex_EqHw_Enable(vortex_t *vortex) {
384            hwwrite(vortex->mmio, 0x2b440, 0xf001);
385    }
386    
387    void vortex_EqHw_Disable(vortex_t *vortex) {
388            hwwrite(vortex->mmio, 0x2b440, 0xf000);
389    }
390    
391    void vortex_EqHw_ZeroIO(vortex_t *vortex) {
392            int i;
393            for (i=0; i<0x8; i++)
394                    hwwrite(vortex->mmio, 0x2b410 + (i<<2), 0x0);
395            for (i=0; i<0x4; i++)
396                    hwwrite(vortex->mmio, 0x2b430 + (i<<2), 0x0);
397            
398    }
399    
400    void vortex_EqHw_ZeroA3DIO(vortex_t *vortex) {
401            int i;
402            for (i=0; i<0x4; i++)
403                    hwwrite(vortex->mmio, 0x2b410 + (i<<2), 0x0);  
404    }
405    
406    void vortex_EqHw_ZeroState(vortex_t *vortex) {
407            
408            vortex_EqHw_SetControlReg(vortex, 0);
409            vortex_EqHw_ZeroIO(vortex);
410            hwwrite(vortex->mmio, 0x2b3c0, 0);
411            
412            vortex_EqHw_SetTimeConsts(vortex, 0, 0);
413            
414            vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsZeros);
415            vortex_EqHw_SetRightCoefs(vortex, asEqCoefsZeros);
416            
417            vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_zero);
418            vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_zero);
419            vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_zero);
420            vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_zero);
421            
422            vortex_EqHw_SetBypassGain(vortex, 0, 0);
423            vortex_EqHw_SetA3DBypassGain(vortex, 0, 0);
424            vortex_EqHw_SetLeftStates(vortex, eq_states_zero, asEqOutStateZeros);
425            vortex_EqHw_SetRightStates(vortex, eq_states_zero, asEqOutStateZeros);
426            vortex_EqHw_SetLevels(vortex, (u16*)eq_levels);
427    }
428    
429    void vortex_EqHw_ProgramPipe(vortex_t *vortex) {
430            vortex_EqHw_SetTimeConsts(vortex, 0, 0);
431            
432            vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsPipes);
433            vortex_EqHw_SetRightCoefs(vortex, asEqCoefsPipes);
434            
435            vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_current);
436            vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_current);
437            vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_current);
438            vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_current);
439    }
440    
441    void vortex_EqHw_Program10Band(vortex_t *vortex, auxxEqCoeffSet_t *coefset) {
442            
443            vortex_EqHw_SetTimeConsts(vortex, 0xc, 0x7fe0);
444            
445            vortex_EqHw_SetLeftCoefs(vortex, coefset->LeftCoefs);
446            vortex_EqHw_SetRightCoefs(vortex, coefset->RightCoefs);
447            
448            vortex_EqHw_SetLeftGainsCurrent(vortex, coefset->LeftGains);
449            
450            vortex_EqHw_SetRightGainsTarget(vortex, coefset->RightGains);
451            vortex_EqHw_SetLeftGainsTarget(vortex, coefset->LeftGains);
452            
453            vortex_EqHw_SetRightGainsCurrent(vortex, coefset->RightGains);
454    }
455    
456    
457    /* CEqlzr.s */
458    
459    int  vortex_Eqlzr_GetLeftGain(vortex_t *vortex, u16 index, u16 *gain) {
460            eqlzr_t *eq = &(vortex->eq);
461            
462            if (eq->this28) {
463                    *gain = eq->this130[index];
464                    return 0;
465            }
466            return 1;
467    }
468    
469    void vortex_Eqlzr_SetLeftGain(vortex_t *vortex, u16 index, u16 gain) {
470            eqlzr_t *eq = &(vortex->eq);
471    
472            if (eq->this28 == 0)
473                    return;
474            
475            eq->this130[index] = gain;
476            if (eq->this54)
477                    return;
478            
479            vortex_EqHw_SetLeftGainsSingleTarget(vortex, index, gain);
480    }
481    
482    int  vortex_Eqlzr_GetRightGain(vortex_t *vortex, u16 index, u16 *gain) {
483            eqlzr_t *eq = &(vortex->eq);
484            
485            if (eq->this28) {
486                    *gain = eq->this130[index + eq->this10];
487                    return 0;
488            }
489            return 1;
490    }
491    
492    void vortex_Eqlzr_SetRightGain(vortex_t *vortex, u16 index, u16 gain) {
493            eqlzr_t *eq = &(vortex->eq);
494            
495            if (eq->this28 == 0)
496                    return;
497            
498            eq->this130[index + eq->this10] = gain;
499            if (eq->this54)
500                    return;
501            
502            vortex_EqHw_SetRightGainsSingleTarget(vortex, index, gain);
503    }
504    
505    
506    int  vortex_Eqlzr_GetAllBands(vortex_t *vortex, u16 *gains, unsigned long *cnt) {
507            eqlzr_t *eq = &(vortex->eq);
508            int si=0;
509            
510            if (eq->this10 == 0)
511                    return 1;
512            
513            {
514                    if (vortex_Eqlzr_GetLeftGain(vortex, si, &gains[si]))
515                            return 1;                      
516                    if (vortex_Eqlzr_GetRightGain(vortex, si, &gains[si + eq->this10]))
517                            return 1;
518                    si++;
519            } while (eq->this10 > si);
520            *cnt = si*2;
521            return 0;
522    }
523    
524    int  vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex_t *vortex) {
525            eqlzr_t *eq = &(vortex->eq);
526            
527            vortex_EqHw_SetLeftGainsTarget(vortex, eq->this130);
528            vortex_EqHw_SetRightGainsTarget(vortex, &(eq->this130[eq->this10]));
529            
530            return 0;
531    }
532    
533    int  vortex_Eqlzr_SetAllBands(vortex_t *vortex, u16 gains[], unsigned long count) {
534            eqlzr_t *eq = &(vortex->eq);
535            int i;
536            
537            if (((eq->this10)*2 != count) || (eq->this28 == 0))
538                    return 1;
539            
540            if (0 < count) {
541                    for (i=0; i<count; i++) {
542                            eq->this130[i] = gains[i];
543                    }
544            }
545            if (eq->this54)
546                    return 0;
547            return vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex);
548    }
549    
550    void vortex_Eqlzr_ProgramA3dBypassGain(vortex_t *vortex) {
551            eqlzr_t *eq = &(vortex->eq);
552            int eax, ebx;
553            
554            if (eq->this54)
555                    eax = eq->this0e;
556            else
557                    eax = eq->this0a;
558            ebx = (eax * eq->this58) >> 0x10;
559            eax = (eax * eq->this5c) >> 0x10;
560            vortex_EqHw_SetA3DBypassGain(vortex, ebx, eax);
561    }
562    
563    void vortex_Eqlzr_SetBypass(vortex_t *vortex, long bp) {
564            eqlzr_t *eq = &(vortex->eq);
565            
566            if ((eq->this28) && (bp == 0)) {
567                    vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex);
568                    vortex_EqHw_SetBypassGain(vortex, eq->this08, eq->this08);
569            } else {
570                    vortex_EqHw_SetLeftGainsTarget(vortex, (u16*)(eq->this14));
571                    vortex_EqHw_SetRightGainsTarget(vortex, (u16*)(eq->this14));
572                    vortex_EqHw_SetBypassGain(vortex, eq->this0c, eq->this0c);
573            }
574            // FIXME: no yet implemented.
575            vortex_Eqlzr_ProgramA3dBypassGain(vortex);
576    }
577    
578    void vortex_Eqlzr_ReadAndSetActiveCoefSet(vortex_t *vortex) {
579            eqlzr_t *eq = &(vortex->eq);
580            
581            /* Set EQ BiQuad filter coeficients */
582            memcpy(&(eq->coefset), &asEqCoefsNormal, sizeof(auxxEqCoeffSet_t));
583            /* Set EQ Band gain levels and dump into hardware registers. */
584            vortex_Eqlzr_SetAllBands(vortex, eq_gains_normal, eq->this10*2);        
585    }
586    
587    #if 0
588    void vortex_Eqlzr_vortex_SetA3dBypassVolume()
589    void vortex_Eqlzr_ShutDownA3d()
590    int  vortex_Eqlzr_GetAllPeaks(vortex_t *vortex, u16 *levels, unsigned long *count) {
591            eqlzr_t *eq = &(vortex->eq);
592            
593            if (eq->this10 == 0)
594                    return 1;
595            *count = eq->this10 * 2;
596            vortex_EqHw_GetTenBandLevels(vortex, levels);
597    }
598    
599    #endif
600    
601    auxxEqCoeffSet_t *vortex_Eqlzr_GetActiveCoefSet(vortex_t *vortex) {
602            eqlzr_t *eq = &(vortex->eq);
603            
604            return (&(eq->coefset));
605    }
606    
607    void vortex_Eqlzr_init(vortex_t *vortex) {
608            eqlzr_t *eq = &(vortex->eq);
609            
610            /* Object constructor */
611            //eq->this04 = 0;
612            eq->this08 = 0; /* Bypass gain with EQ in use. */
613            eq->this0a = 0x5999;
614            eq->this0c = 0x5999; /* Bypass gain with EQ disabled. */
615            eq->this0e = 0x5999;
616            
617            eq->this10 = 0xa; /* 10 eq frequency bands. */
618            eq->this04.this04 = eq->this10;
619            eq->this28 = 0x1; /* if 1 => Allow read access to this130 (gains) */
620            eq->this54 = 0x0; /* if 1 => Dont Allow access to hardware (gains) */
621            eq->this58 = 0xffff;
622            eq->this5c = 0xffff;
623            
624            /* Set gains. */
625            memset(eq->this14, 0, 2*10);
626            
627            /* Actual init. */
628            vortex_EqHw_ZeroState(vortex);
629            vortex_EqHw_SetSampleRate(vortex, 0x11);
630            vortex_Eqlzr_ReadAndSetActiveCoefSet(vortex);
631            
632            vortex_EqHw_Program10Band(vortex, &(eq->coefset));
633            vortex_Eqlzr_SetBypass(vortex, eq->this54);
634            vortex_EqHw_Enable(vortex);
635    }
636    
637    /* ALSA interface */
638    
639    /* Control interface */
640    static int snd_vortex_eq_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {
641            uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
642            uinfo->count = 2;
643            uinfo->value.integer.min = 0x0000;
644            uinfo->value.integer.max = 0x7fff;
645            return 0;
646    }
647    
648    static int snd_vortex_eq_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) {
649            vortex_t *vortex = snd_kcontrol_chip(kcontrol);
650            int i = kcontrol->private_value;
651            u16 gainL, gainR;
652            
653            vortex_Eqlzr_GetLeftGain(vortex, i, &gainL);
654            vortex_Eqlzr_GetRightGain(vortex, i, &gainR);
655            ucontrol->value.integer.value[0] = gainL;
656            ucontrol->value.integer.value[1] = gainR;
657            return 0;
658    }
659    
660    static int snd_vortex_eq_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) {
661            vortex_t *vortex = snd_kcontrol_chip(kcontrol);
662            int changed = 0, i = kcontrol->private_value;
663            u16 gainL, gainR;
664            
665            vortex_Eqlzr_GetLeftGain(vortex, i, &gainL);
666            vortex_Eqlzr_GetRightGain(vortex, i, &gainR);
667            
668            if (gainL != ucontrol->value.integer.value[0]) {
669                    vortex_Eqlzr_SetLeftGain(vortex, i, ucontrol->value.integer.value[0]);
670                    changed = 1;
671            }
672            if (gainR != ucontrol->value.integer.value[1]) {
673                    vortex_Eqlzr_SetRightGain(vortex, i, ucontrol->value.integer.value[1]);
674                    changed = 1;
675            }
676            return changed;
677    }
678    
679    static int snd_vortex_eqtoggle_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {
680            uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
681            uinfo->count = 1;
682            uinfo->value.integer.min = 0;
683            uinfo->value.integer.max = 1;
684            return 0;
685    }
686    
687    static int snd_vortex_eqtoggle_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) {
688            vortex_t *vortex = snd_kcontrol_chip(kcontrol);
689            eqlzr_t *eq = &(vortex->eq);
690            //int i = kcontrol->private_value;
691            
692            ucontrol->value.integer.value[0] = eq->this54 ? 0 : 1;
693            
694            return 0;
695    }
696    
697    static int snd_vortex_eqtoggle_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) {
698            vortex_t *vortex = snd_kcontrol_chip(kcontrol);
699            eqlzr_t *eq = &(vortex->eq);
700            //int i = kcontrol->private_value;
701            
702            eq->this54 = ucontrol->value.integer.value[0] ? 0 : 1;
703            vortex_Eqlzr_SetBypass(vortex, eq->this54);
704            
705            return 1; /* Allways changes */
706    }
707    
708    static snd_kcontrol_new_t vortex_eqtoggle_kcontrol __devinitdata = {
709            .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
710            .name = "EQ Enable",
711            .index = 0,
712            .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
713            .private_value = 0,
714            .info = snd_vortex_eqtoggle_info,
715            .get = snd_vortex_eqtoggle_get,
716            .put = snd_vortex_eqtoggle_put
717    };
718    
719    static snd_kcontrol_new_t vortex_eq_kcontrol __devinitdata = {
720            .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
721            .name = "                        .",
722            .index = 0,
723            .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
724            .private_value = 0,
725            .info = snd_vortex_eq_info,
726            .get = snd_vortex_eq_get,
727            .put = snd_vortex_eq_put
728    };
729    
730    /* EQ band gain labels. */
731    static char *EqBandLabels[10] __devinitdata = {
732            "EQ0 31Hz\0",
733            "EQ1 63Hz\0",
734            "EQ2 125Hz\0",
735            "EQ3 250Hz\0",
736            "EQ4 500Hz\0",
737            "EQ5 1KHz\0",
738            "EQ6 2KHz\0",
739            "EQ7 4KHz\0",
740            "EQ8 8KHz\0",
741            "EQ9 16KHz\0",
742    };
743    
744    /* ALSA driver entry points. Init and exit. */
745    int vortex_eq_init(vortex_t *vortex) {
746            snd_kcontrol_t *kcontrol;
747            int err, i;
748            
749            vortex_Eqlzr_init(vortex);
750    
751            if ((kcontrol = snd_ctl_new1(&vortex_eqtoggle_kcontrol, vortex)) == NULL)
752                    return -ENOMEM;
753            kcontrol->private_value = 0;
754            if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
755            return err;
756    
757            /* EQ gain controls */
758            for (i=0; i<10; i++) {
759                    if ((kcontrol = snd_ctl_new1(&vortex_eq_kcontrol, vortex)) == NULL)
760                            return -ENOMEM;
761                    strcpy(kcontrol->id.name, EqBandLabels[i]);
762                    kcontrol->private_value = i;
763                    if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
764                    return err;
765                    vortex->eqctrl[i] = kcontrol;
766            }
767            return 0;
768    }
769    
770    int vortex_eq_free(vortex_t *vortex) {
771            /*
772            //FIXME: segfault because vortex->eqctrl[i] == 4
773            int i;
774            for (i=0; i<10; i++) {
775                    if (vortex->eqctrl[i])
776                            snd_ctl_remove(vortex->card, vortex->eqctrl[i]);
777            }
778            */
779            return 0;
780    }
781    
782    /* End */

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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