1 /***************************************************************************
3 * Aureal Vortex Hardware EQ control/access.
5 * Sun Jun 8 18:19:19 2003
6 * 2003 Manuel Jander (mjander@users.sourceforge.net)
8 * 02 July 2003: First time something works :)
9 * November 2003: A3D Bypass code completed but untested.
13 * - Test peak visualization support.
15 ****************************************************************************/
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Library General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 The Aureal Hardware EQ is found on AU8810 and AU8830 chips only.
35 it has 4 inputs (2 for general mix, 2 for A3D) and 2 outputs (supposed
36 to be routed to the codec).
40 #include "au88x0_eq.h"
41 #include "au88x0_eqdata.c"
44 static void vortex_EqHw_SetTimeConsts(vortex_t * vortex, u16 a, u16 b)
46 hwwrite(vortex->mmio, 0x2b3c4, a);
47 hwwrite(vortex->mmio, 0x2b3c8, b);
50 static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 a[])
52 eqhw_t *eqhw = &(vortex->eq.this04);
53 int eax, i = 0, n /*esp2c */ = 0;
55 if (eqhw->this04 <= n)
59 hwwrite(vortex->mmio, 0x2b000 + n * 0x30, a[i + 0]);
60 hwwrite(vortex->mmio, 0x2b004 + n * 0x30, a[i + 1]);
62 if (eqhw->this08 == 0) {
63 hwwrite(vortex->mmio, 0x2b008 + n * 0x30, a[i + 2]);
64 hwwrite(vortex->mmio, 0x2b00c + n * 0x30, a[i + 3]);
65 eax = a[i + 4]; //esp24;
67 if (a[2 + i] == 0x8000)
71 hwwrite(vortex->mmio, 0x2b008 + n * 0x30, eax & 0xffff);
72 if (a[3 + i] == 0x8000)
76 hwwrite(vortex->mmio, 0x2b00c + n * 0x30, eax & 0xffff);
77 if (a[4 + i] == 0x8000)
82 hwwrite(vortex->mmio, 0x2b010 + n * 0x30, eax);
87 while (n < eqhw->this04);
90 static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 a[])
92 eqhw_t *eqhw = &(vortex->eq.this04);
93 int i = 0, n /*esp2c */ = 0, eax;
95 if (eqhw->this04 <= n)
99 hwwrite(vortex->mmio, 0x2b1e0 + n * 0x30, a[0 + i]);
100 hwwrite(vortex->mmio, 0x2b1e4 + n * 0x30, a[1 + i]);
102 if (eqhw->this08 == 0) {
103 hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, a[2 + i]);
104 hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, a[3 + i]);
105 eax = a[4 + i]; //*esp24;
107 if (a[2 + i] == 0x8000)
111 hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, eax & 0xffff);
112 if (a[3 + i] == 0x8000)
116 hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, eax & 0xffff);
117 if (a[4 + i] == 0x8000)
122 hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, eax);
126 while (n < eqhw->this04);
130 static void vortex_EqHw_SetLeftStates(vortex_t * vortex, u16 a[], u16 b[])
132 eqhw_t *eqhw = &(vortex->eq.this04);
135 hwwrite(vortex->mmio, 0x2b3fc, a[0]);
136 hwwrite(vortex->mmio, 0x2b400, a[1]);
138 if (eqhw->this04 < 0)
142 hwwrite(vortex->mmio, 0x2b014 + (i * 0xc), b[i]);
143 hwwrite(vortex->mmio, 0x2b018 + (i * 0xc), b[1 + i]);
144 hwwrite(vortex->mmio, 0x2b01c + (i * 0xc), b[2 + i]);
145 hwwrite(vortex->mmio, 0x2b020 + (i * 0xc), b[3 + i]);
149 while (eqhw->this04 > ebx);
152 static void vortex_EqHw_SetRightStates(vortex_t * vortex, u16 a[], u16 b[])
154 eqhw_t *eqhw = &(vortex->eq.this04);
157 hwwrite(vortex->mmio, 0x2b404, a[0]);
158 hwwrite(vortex->mmio, 0x2b408, a[1]);
160 if (eqhw->this04 < 0)
164 hwwrite(vortex->mmio, 0x2b1f4 + (i * 0xc), b[i]);
165 hwwrite(vortex->mmio, 0x2b1f8 + (i * 0xc), b[1 + i]);
166 hwwrite(vortex->mmio, 0x2b1fc + (i * 0xc), b[2 + i]);
167 hwwrite(vortex->mmio, 0x2b200 + (i * 0xc), b[3 + i]);
171 while (ebx < eqhw->this04);
175 static void vortex_EqHw_GetTimeConsts(vortex_t * vortex, u16 * a, u16 * b)
177 *a = hwread(vortex->mmio, 0x2b3c4);
178 *b = hwread(vortex->mmio, 0x2b3c8);
181 static void vortex_EqHw_GetLeftCoefs(vortex_t * vortex, u16 a[])
186 static void vortex_EqHw_GetRightCoefs(vortex_t * vortex, u16 a[])
191 static void vortex_EqHw_GetLeftStates(vortex_t * vortex, u16 * a, u16 b[])
196 static void vortex_EqHw_GetRightStates(vortex_t * vortex, u16 * a, u16 b[])
203 static void vortex_EqHw_SetBypassGain(vortex_t * vortex, u16 a, u16 b)
205 eqhw_t *eqhw = &(vortex->eq.this04);
208 if (eqhw->this08 == 0) {
209 hwwrite(vortex->mmio, 0x2b3d4, a);
210 hwwrite(vortex->mmio, 0x2b3ec, b);
216 hwwrite(vortex->mmio, 0x2b3d4, eax & 0xffff);
221 hwwrite(vortex->mmio, 0x2b3ec, eax & 0xffff);
225 static void vortex_EqHw_SetA3DBypassGain(vortex_t * vortex, u16 a, u16 b)
228 hwwrite(vortex->mmio, 0x2b3e0, a);
229 hwwrite(vortex->mmio, 0x2b3f8, b);
233 static void vortex_EqHw_SetCurrBypassGain(vortex_t * vortex, u16 a, u16 b)
236 hwwrite(vortex->mmio, 0x2b3d0, a);
237 hwwrite(vortex->mmio, 0x2b3e8, b);
240 static void vortex_EqHw_SetCurrA3DBypassGain(vortex_t * vortex, u16 a, u16 b)
243 hwwrite(vortex->mmio, 0x2b3dc, a);
244 hwwrite(vortex->mmio, 0x2b3f4, b);
249 vortex_EqHw_SetLeftGainsSingleTarget(vortex_t * vortex, u16 index, u16 b)
251 hwwrite(vortex->mmio, 0x2b02c + (index * 0x30), b);
255 vortex_EqHw_SetRightGainsSingleTarget(vortex_t * vortex, u16 index, u16 b)
257 hwwrite(vortex->mmio, 0x2b20c + (index * 0x30), b);
260 static void vortex_EqHw_SetLeftGainsTarget(vortex_t * vortex, u16 a[])
262 eqhw_t *eqhw = &(vortex->eq.this04);
265 if (eqhw->this04 < 0)
268 hwwrite(vortex->mmio, 0x2b02c + ebx * 0x30, a[ebx]);
271 while (ebx < eqhw->this04);
274 static void vortex_EqHw_SetRightGainsTarget(vortex_t * vortex, u16 a[])
276 eqhw_t *eqhw = &(vortex->eq.this04);
279 if (eqhw->this04 < 0)
283 hwwrite(vortex->mmio, 0x2b20c + ebx * 0x30, a[ebx]);
286 while (ebx < eqhw->this04);
289 static void vortex_EqHw_SetLeftGainsCurrent(vortex_t * vortex, u16 a[])
291 eqhw_t *eqhw = &(vortex->eq.this04);
294 if (eqhw->this04 < 0)
298 hwwrite(vortex->mmio, 0x2b028 + ebx * 0x30, a[ebx]);
301 while (ebx < eqhw->this04);
304 static void vortex_EqHw_SetRightGainsCurrent(vortex_t * vortex, u16 a[])
306 eqhw_t *eqhw = &(vortex->eq.this04);
309 if (eqhw->this04 < 0)
313 hwwrite(vortex->mmio, 0x2b208 + ebx * 0x30, a[ebx]);
316 while (ebx < eqhw->this04);
320 static void vortex_EqHw_GetLeftGainsTarget(vortex_t * vortex, u16 a[])
322 eqhw_t *eqhw = &(vortex->eq.this04);
325 if (eqhw->this04 < 0)
329 a[ebx] = hwread(vortex->mmio, 0x2b02c + ebx * 0x30);
332 while (ebx < eqhw->this04);
335 static void vortex_EqHw_GetRightGainsTarget(vortex_t * vortex, u16 a[])
337 eqhw_t *eqhw = &(vortex->eq.this04);
340 if (eqhw->this04 < 0)
344 a[ebx] = hwread(vortex->mmio, 0x2b20c + ebx * 0x30);
347 while (ebx < eqhw->this04);
350 static void vortex_EqHw_GetLeftGainsCurrent(vortex_t * vortex, u16 a[])
352 eqhw_t *eqhw = &(vortex->eq.this04);
355 if (eqhw->this04 < 0)
359 a[ebx] = hwread(vortex->mmio, 0x2b028 + ebx * 0x30);
362 while (ebx < eqhw->this04);
365 static void vortex_EqHw_GetRightGainsCurrent(vortex_t * vortex, u16 a[])
367 eqhw_t *eqhw = &(vortex->eq.this04);
370 if (eqhw->this04 < 0)
374 a[ebx] = hwread(vortex->mmio, 0x2b208 + ebx * 0x30);
377 while (ebx < eqhw->this04);
381 /* EQ band levels settings */
382 static void vortex_EqHw_SetLevels(vortex_t * vortex, u16 a[])
384 eqhw_t *eqhw = &(vortex->eq.this04);
387 if (eqhw->this04 < 0)
392 hwwrite(vortex->mmio, 0x2b024 + ebx * 0x30, a[ebx]);
395 while (ebx < eqhw->this04);
397 hwwrite(vortex->mmio, 0x2b3cc, a[eqhw->this04]);
398 hwwrite(vortex->mmio, 0x2b3d8, a[eqhw->this04 + 1]);
402 hwwrite(vortex->mmio, 0x2b204 + ebx * 0x30,
403 a[ebx + (eqhw->this04 + 2)]);
406 while (ebx < eqhw->this04);
408 hwwrite(vortex->mmio, 0x2b3e4, a[2 + (eqhw->this04 * 2)]);
409 hwwrite(vortex->mmio, 0x2b3f0, a[3 + (eqhw->this04 * 2)]);
413 static void vortex_EqHw_GetLevels(vortex_t * vortex, u16 a[])
415 eqhw_t *eqhw = &(vortex->eq.this04);
418 if (eqhw->this04 < 0)
423 a[ebx] = hwread(vortex->mmio, 0x2b024 + ebx * 0x30);
426 while (ebx < eqhw->this04);
428 a[eqhw->this04] = hwread(vortex->mmio, 0x2b3cc);
429 a[eqhw->this04 + 1] = hwread(vortex->mmio, 0x2b3d8);
433 a[ebx + (eqhw->this04 + 2)] =
434 hwread(vortex->mmio, 0x2b204 + ebx * 0x30);
437 while (ebx < eqhw->this04);
439 a[2 + (eqhw->this04 * 2)] = hwread(vortex->mmio, 0x2b3e4);
440 a[3 + (eqhw->this04 * 2)] = hwread(vortex->mmio, 0x2b3f0);
445 static void vortex_EqHw_SetControlReg(vortex_t * vortex, unsigned long reg)
447 hwwrite(vortex->mmio, 0x2b440, reg);
450 static void vortex_EqHw_SetSampleRate(vortex_t * vortex, int sr)
452 hwwrite(vortex->mmio, 0x2b440, ((sr & 0x1f) << 3) | 0xb800);
456 static void vortex_EqHw_GetControlReg(vortex_t * vortex, unsigned long *reg)
458 *reg = hwread(vortex->mmio, 0x2b440);
461 static void vortex_EqHw_GetSampleRate(vortex_t * vortex, int *sr)
463 *sr = (hwread(vortex->mmio, 0x2b440) >> 3) & 0x1f;
467 static void vortex_EqHw_Enable(vortex_t * vortex)
469 hwwrite(vortex->mmio, 0x2b440, 0xf001);
472 static void vortex_EqHw_Disable(vortex_t * vortex)
474 hwwrite(vortex->mmio, 0x2b440, 0xf000);
477 /* Reset (zero) buffers */
478 static void vortex_EqHw_ZeroIO(vortex_t * vortex)
481 for (i = 0; i < 0x8; i++)
482 hwwrite(vortex->mmio, 0x2b410 + (i << 2), 0x0);
483 for (i = 0; i < 0x4; i++)
484 hwwrite(vortex->mmio, 0x2b430 + (i << 2), 0x0);
487 static void vortex_EqHw_ZeroA3DIO(vortex_t * vortex)
490 for (i = 0; i < 0x4; i++)
491 hwwrite(vortex->mmio, 0x2b410 + (i << 2), 0x0);
494 static void vortex_EqHw_ZeroState(vortex_t * vortex)
497 vortex_EqHw_SetControlReg(vortex, 0);
498 vortex_EqHw_ZeroIO(vortex);
499 hwwrite(vortex->mmio, 0x2b3c0, 0);
501 vortex_EqHw_SetTimeConsts(vortex, 0, 0);
503 vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsZeros);
504 vortex_EqHw_SetRightCoefs(vortex, asEqCoefsZeros);
506 vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_zero);
507 vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_zero);
508 vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_zero);
509 vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_zero);
511 vortex_EqHw_SetBypassGain(vortex, 0, 0);
512 //vortex_EqHw_SetCurrBypassGain(vortex, 0, 0);
513 vortex_EqHw_SetA3DBypassGain(vortex, 0, 0);
514 //vortex_EqHw_SetCurrA3DBypassGain(vortex, 0, 0);
515 vortex_EqHw_SetLeftStates(vortex, eq_states_zero, asEqOutStateZeros);
516 vortex_EqHw_SetRightStates(vortex, eq_states_zero, asEqOutStateZeros);
517 vortex_EqHw_SetLevels(vortex, (u16 *) eq_levels);
520 /* Program coeficients as pass through */
521 static void vortex_EqHw_ProgramPipe(vortex_t * vortex)
523 vortex_EqHw_SetTimeConsts(vortex, 0, 0);
525 vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsPipes);
526 vortex_EqHw_SetRightCoefs(vortex, asEqCoefsPipes);
528 vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_current);
529 vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_current);
530 vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_current);
531 vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_current);
534 /* Program EQ block as 10 band Equalizer */
536 vortex_EqHw_Program10Band(vortex_t * vortex, auxxEqCoeffSet_t * coefset)
539 vortex_EqHw_SetTimeConsts(vortex, 0xc, 0x7fe0);
541 vortex_EqHw_SetLeftCoefs(vortex, coefset->LeftCoefs);
542 vortex_EqHw_SetRightCoefs(vortex, coefset->RightCoefs);
544 vortex_EqHw_SetLeftGainsCurrent(vortex, coefset->LeftGains);
546 vortex_EqHw_SetRightGainsTarget(vortex, coefset->RightGains);
547 vortex_EqHw_SetLeftGainsTarget(vortex, coefset->LeftGains);
549 vortex_EqHw_SetRightGainsCurrent(vortex, coefset->RightGains);
552 /* Read all EQ peaks. (think VU meter) */
553 static void vortex_EqHw_GetTenBandLevels(vortex_t * vortex, u16 peaks[])
555 eqhw_t *eqhw = &(vortex->eq.this04);
558 if (eqhw->this04 <= 0)
561 for (i = 0; i < eqhw->this04; i++)
562 peaks[i] = hwread(vortex->mmio, 0x2B024 + i * 0x30);
563 for (i = 0; i < eqhw->this04; i++)
564 peaks[i + eqhw->this04] =
565 hwread(vortex->mmio, 0x2B204 + i * 0x30);
570 static int vortex_Eqlzr_GetLeftGain(vortex_t * vortex, u16 index, u16 * gain)
572 eqlzr_t *eq = &(vortex->eq);
575 *gain = eq->this130[index];
581 static void vortex_Eqlzr_SetLeftGain(vortex_t * vortex, u16 index, u16 gain)
583 eqlzr_t *eq = &(vortex->eq);
588 eq->this130[index] = gain;
592 vortex_EqHw_SetLeftGainsSingleTarget(vortex, index, gain);
595 static int vortex_Eqlzr_GetRightGain(vortex_t * vortex, u16 index, u16 * gain)
597 eqlzr_t *eq = &(vortex->eq);
600 *gain = eq->this130[index + eq->this10];
606 static void vortex_Eqlzr_SetRightGain(vortex_t * vortex, u16 index, u16 gain)
608 eqlzr_t *eq = &(vortex->eq);
613 eq->this130[index + eq->this10] = gain;
617 vortex_EqHw_SetRightGainsSingleTarget(vortex, index, gain);
622 vortex_Eqlzr_GetAllBands(vortex_t * vortex, u16 * gains, unsigned long *cnt)
624 eqlzr_t *eq = &(vortex->eq);
631 if (vortex_Eqlzr_GetLeftGain(vortex, si, &gains[si]))
633 if (vortex_Eqlzr_GetRightGain
634 (vortex, si, &gains[si + eq->this10]))
638 while (eq->this10 > si) ;
643 static int vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex_t * vortex)
645 eqlzr_t *eq = &(vortex->eq);
647 vortex_EqHw_SetLeftGainsTarget(vortex, eq->this130);
648 vortex_EqHw_SetRightGainsTarget(vortex, &(eq->this130[eq->this10]));
654 vortex_Eqlzr_SetAllBands(vortex_t * vortex, u16 gains[], unsigned long count)
656 eqlzr_t *eq = &(vortex->eq);
659 if (((eq->this10) * 2 != count) || (eq->this28 == 0))
663 for (i = 0; i < count; i++) {
664 eq->this130[i] = gains[i];
669 return vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex);
673 vortex_Eqlzr_SetA3dBypassGain(vortex_t * vortex, unsigned long a,
676 eqlzr_t *eq = &(vortex->eq);
685 ebx = (eax * eq->this58) >> 0x10;
686 eax = (eax * eq->this5c) >> 0x10;
687 vortex_EqHw_SetA3DBypassGain(vortex, ebx, eax);
690 static void vortex_Eqlzr_ProgramA3dBypassGain(vortex_t * vortex)
692 eqlzr_t *eq = &(vortex->eq);
699 ebx = (eax * eq->this58) >> 0x10;
700 eax = (eax * eq->this5c) >> 0x10;
701 vortex_EqHw_SetA3DBypassGain(vortex, ebx, eax);
704 static void vortex_Eqlzr_ShutDownA3d(vortex_t * vortex)
707 vortex_EqHw_ZeroA3DIO(vortex);
710 static void vortex_Eqlzr_SetBypass(vortex_t * vortex, long bp)
712 eqlzr_t *eq = &(vortex->eq);
714 if ((eq->this28) && (bp == 0)) {
715 vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex);
716 vortex_EqHw_SetBypassGain(vortex, eq->this08, eq->this08);
718 vortex_EqHw_SetLeftGainsTarget(vortex, (u16 *) (eq->this14));
719 vortex_EqHw_SetRightGainsTarget(vortex, (u16 *) (eq->this14));
720 vortex_EqHw_SetBypassGain(vortex, eq->this0c, eq->this0c);
722 vortex_Eqlzr_ProgramA3dBypassGain(vortex);
725 static void vortex_Eqlzr_ReadAndSetActiveCoefSet(vortex_t * vortex)
727 eqlzr_t *eq = &(vortex->eq);
729 /* Set EQ BiQuad filter coeficients */
730 memcpy(&(eq->coefset), &asEqCoefsNormal, sizeof(auxxEqCoeffSet_t));
731 /* Set EQ Band gain levels and dump into hardware registers. */
732 vortex_Eqlzr_SetAllBands(vortex, eq_gains_normal, eq->this10 * 2);
735 static int vortex_Eqlzr_GetAllPeaks(vortex_t * vortex, u16 * peaks, int *count)
737 eqlzr_t *eq = &(vortex->eq);
741 *count = eq->this10 * 2;
742 vortex_EqHw_GetTenBandLevels(vortex, peaks);
747 static auxxEqCoeffSet_t *vortex_Eqlzr_GetActiveCoefSet(vortex_t * vortex)
749 eqlzr_t *eq = &(vortex->eq);
751 return (&(eq->coefset));
754 static void vortex_Eqlzr_init(vortex_t * vortex)
756 eqlzr_t *eq = &(vortex->eq);
758 /* Object constructor */
760 eq->this08 = 0; /* Bypass gain with EQ in use. */
762 eq->this0c = 0x5999; /* Bypass gain with EQ disabled. */
765 eq->this10 = 0xa; /* 10 eq frequency bands. */
766 eq->this04.this04 = eq->this10;
767 eq->this28 = 0x1; /* if 1 => Allow read access to this130 (gains) */
768 eq->this54 = 0x0; /* if 1 => Dont Allow access to hardware (gains) */
773 memset(eq->this14, 0, 2 * 10);
776 vortex_EqHw_ZeroState(vortex);
777 vortex_EqHw_SetSampleRate(vortex, 0x11);
778 vortex_Eqlzr_ReadAndSetActiveCoefSet(vortex);
780 vortex_EqHw_Program10Band(vortex, &(eq->coefset));
781 vortex_Eqlzr_SetBypass(vortex, eq->this54);
782 vortex_Eqlzr_SetA3dBypassGain(vortex, 0, 0);
783 vortex_EqHw_Enable(vortex);
786 static void vortex_Eqlzr_shutdown(vortex_t * vortex)
788 vortex_Eqlzr_ShutDownA3d(vortex);
789 vortex_EqHw_ProgramPipe(vortex);
790 vortex_EqHw_Disable(vortex);
795 /* Control interface */
797 snd_vortex_eqtoggle_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
799 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
801 uinfo->value.integer.min = 0;
802 uinfo->value.integer.max = 1;
807 snd_vortex_eqtoggle_get(snd_kcontrol_t * kcontrol,
808 snd_ctl_elem_value_t * ucontrol)
810 vortex_t *vortex = snd_kcontrol_chip(kcontrol);
811 eqlzr_t *eq = &(vortex->eq);
812 //int i = kcontrol->private_value;
814 ucontrol->value.integer.value[0] = eq->this54 ? 0 : 1;
820 snd_vortex_eqtoggle_put(snd_kcontrol_t * kcontrol,
821 snd_ctl_elem_value_t * ucontrol)
823 vortex_t *vortex = snd_kcontrol_chip(kcontrol);
824 eqlzr_t *eq = &(vortex->eq);
825 //int i = kcontrol->private_value;
827 eq->this54 = ucontrol->value.integer.value[0] ? 0 : 1;
828 vortex_Eqlzr_SetBypass(vortex, eq->this54);
830 return 1; /* Allways changes */
833 static snd_kcontrol_new_t vortex_eqtoggle_kcontrol __devinitdata = {
834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
837 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
839 .info = snd_vortex_eqtoggle_info,
840 .get = snd_vortex_eqtoggle_get,
841 .put = snd_vortex_eqtoggle_put
845 snd_vortex_eq_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
847 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
849 uinfo->value.integer.min = 0x0000;
850 uinfo->value.integer.max = 0x7fff;
855 snd_vortex_eq_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
857 vortex_t *vortex = snd_kcontrol_chip(kcontrol);
858 int i = kcontrol->private_value;
861 vortex_Eqlzr_GetLeftGain(vortex, i, &gainL);
862 vortex_Eqlzr_GetRightGain(vortex, i, &gainR);
863 ucontrol->value.integer.value[0] = gainL;
864 ucontrol->value.integer.value[1] = gainR;
869 snd_vortex_eq_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
871 vortex_t *vortex = snd_kcontrol_chip(kcontrol);
872 int changed = 0, i = kcontrol->private_value;
875 vortex_Eqlzr_GetLeftGain(vortex, i, &gainL);
876 vortex_Eqlzr_GetRightGain(vortex, i, &gainR);
878 if (gainL != ucontrol->value.integer.value[0]) {
879 vortex_Eqlzr_SetLeftGain(vortex, i,
880 ucontrol->value.integer.value[0]);
883 if (gainR != ucontrol->value.integer.value[1]) {
884 vortex_Eqlzr_SetRightGain(vortex, i,
885 ucontrol->value.integer.value[1]);
891 static snd_kcontrol_new_t vortex_eq_kcontrol __devinitdata = {
892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
895 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
897 .info = snd_vortex_eq_info,
898 .get = snd_vortex_eq_get,
899 .put = snd_vortex_eq_put
903 snd_vortex_peaks_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
905 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
907 uinfo->value.integer.min = 0x0000;
908 uinfo->value.integer.max = 0x7fff;
913 snd_vortex_peaks_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
915 vortex_t *vortex = snd_kcontrol_chip(kcontrol);
919 vortex_Eqlzr_GetAllPeaks(vortex, peaks, &count);
921 printk("vortex: peak count error 20 != %d \n", count);
924 for (i = 0; i < 20; i++)
925 ucontrol->value.integer.value[i] = peaks[i];
930 static snd_kcontrol_new_t vortex_levels_kcontrol __devinitdata = {
931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
933 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
934 .info = snd_vortex_peaks_info,
935 .get = snd_vortex_peaks_get,
938 /* EQ band gain labels. */
939 static char *EqBandLabels[10] __devinitdata = {
952 /* ALSA driver entry points. Init and exit. */
953 static int vortex_eq_init(vortex_t * vortex)
955 snd_kcontrol_t *kcontrol;
958 vortex_Eqlzr_init(vortex);
961 snd_ctl_new1(&vortex_eqtoggle_kcontrol, vortex)) == NULL)
963 kcontrol->private_value = 0;
964 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
967 /* EQ gain controls */
968 for (i = 0; i < 10; i++) {
970 snd_ctl_new1(&vortex_eq_kcontrol, vortex)) == NULL)
972 strcpy(kcontrol->id.name, EqBandLabels[i]);
973 kcontrol->private_value = i;
974 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
976 //vortex->eqctrl[i] = kcontrol;
979 if ((kcontrol = snd_ctl_new1(&vortex_levels_kcontrol, vortex)) == NULL)
981 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
987 static int vortex_eq_free(vortex_t * vortex)
990 //FIXME: segfault because vortex->eqctrl[i] == 4
992 for (i=0; i<10; i++) {
993 if (vortex->eqctrl[i])
994 snd_ctl_remove(vortex->card, vortex->eqctrl[i]);
997 vortex_Eqlzr_shutdown(vortex);