43 #define VORTEX_EQ_BASE 0x2b000
44 #define VORTEX_EQ_DEST (VORTEX_EQ_BASE + 0x410)
45 #define VORTEX_EQ_SOURCE (VORTEX_EQ_BASE + 0x430)
46 #define VORTEX_EQ_CTRL (VORTEX_EQ_BASE + 0x440)
48 #define VORTEX_BAND_COEFF_SIZE 0x30
57 static inline u16 sign_invert(
u16 a)
66 static void vortex_EqHw_SetLeftCoefs(
vortex_t * vortex,
u16 coefs[])
80 hwwrite(vortex->
mmio, 0x2b008 +
n * 0x30, sign_invert(coefs[2 + i]));
81 hwwrite(vortex->
mmio, 0x2b00c +
n * 0x30, sign_invert(coefs[3 + i]));
82 hwwrite(vortex->
mmio, 0x2b010 +
n * 0x30, sign_invert(coefs[4 + i]));
88 static void vortex_EqHw_SetRightCoefs(
vortex_t * vortex,
u16 coefs[])
100 hwwrite(vortex->
mmio, 0x2b1f0 +
n * 0x30, coefs[4 + i]);
102 hwwrite(vortex->
mmio, 0x2b1e8 +
n * 0x30, sign_invert(coefs[2 + i]));
103 hwwrite(vortex->
mmio, 0x2b1ec +
n * 0x30, sign_invert(coefs[3 + i]));
104 hwwrite(vortex->
mmio, 0x2b1f0 +
n * 0x30, sign_invert(coefs[4 + i]));
111 static void vortex_EqHw_SetLeftStates(
vortex_t * vortex,
u16 a[],
u16 b[])
128 static void vortex_EqHw_SetRightStates(
vortex_t * vortex,
u16 a[],
u16 b[])
146 static void vortex_EqHw_GetTimeConsts(
vortex_t * vortex,
u16 * a,
u16 * b)
152 static void vortex_EqHw_GetLeftCoefs(
vortex_t * vortex,
u16 a[])
157 static void vortex_EqHw_GetRightCoefs(
vortex_t * vortex,
u16 a[])
162 static void vortex_EqHw_GetLeftStates(
vortex_t * vortex,
u16 * a,
u16 b[])
167 static void vortex_EqHw_GetRightStates(
vortex_t * vortex,
u16 * a,
u16 b[])
174 static void vortex_EqHw_SetBypassGain(
vortex_t * vortex,
u16 a,
u16 b)
186 static void vortex_EqHw_SetA3DBypassGain(
vortex_t * vortex,
u16 a,
u16 b)
194 static void vortex_EqHw_SetCurrBypassGain(
vortex_t * vortex,
u16 a,
u16 b)
201 static void vortex_EqHw_SetCurrA3DBypassGain(
vortex_t * vortex,
u16 a,
u16 b)
212 hwwrite(vortex->
mmio, 0x2b02c + (index * 0x30), b);
218 hwwrite(vortex->
mmio, 0x2b20c + (index * 0x30), b);
221 static void vortex_EqHw_SetLeftGainsTarget(
vortex_t * vortex,
u16 a[])
226 for (ebx = 0; ebx < eqhw->
this04; ebx++) {
227 hwwrite(vortex->
mmio, 0x2b02c + ebx * 0x30, a[ebx]);
231 static void vortex_EqHw_SetRightGainsTarget(
vortex_t * vortex,
u16 a[])
236 for (ebx = 0; ebx < eqhw->
this04; ebx++) {
237 hwwrite(vortex->
mmio, 0x2b20c + ebx * 0x30, a[ebx]);
241 static void vortex_EqHw_SetLeftGainsCurrent(
vortex_t * vortex,
u16 a[])
246 for (ebx = 0; ebx < eqhw->
this04; ebx++) {
247 hwwrite(vortex->
mmio, 0x2b028 + ebx * 0x30, a[ebx]);
251 static void vortex_EqHw_SetRightGainsCurrent(
vortex_t * vortex,
u16 a[])
256 for (ebx = 0; ebx < eqhw->
this04; ebx++) {
257 hwwrite(vortex->
mmio, 0x2b208 + ebx * 0x30, a[ebx]);
262 static void vortex_EqHw_GetLeftGainsTarget(
vortex_t * vortex,
u16 a[])
274 while (ebx < eqhw->this04);
277 static void vortex_EqHw_GetRightGainsTarget(
vortex_t * vortex,
u16 a[])
289 while (ebx < eqhw->this04);
292 static void vortex_EqHw_GetLeftGainsCurrent(
vortex_t * vortex,
u16 a[])
304 while (ebx < eqhw->this04);
307 static void vortex_EqHw_GetRightGainsCurrent(
vortex_t * vortex,
u16 a[])
319 while (ebx < eqhw->this04);
324 static void vortex_EqHw_SetLevels(
vortex_t * vortex,
u16 peaks[])
330 for (i = 0; i < eqhw->
this04; i++) {
338 for (i = 0; i < eqhw->
this04; i++) {
340 peaks[i + (eqhw->
this04 + 2)]);
348 static void vortex_EqHw_GetLevels(
vortex_t * vortex,
u16 a[])
361 while (ebx < eqhw->this04);
368 a[ebx + (eqhw->
this04 + 2)] =
372 while (ebx < eqhw->this04);
385 static void vortex_EqHw_SetSampleRate(
vortex_t * vortex,
u32 sr)
387 hwwrite(vortex->
mmio, 0x2b440, ((sr & 0x1f) << 3) | 0xb800);
391 static void vortex_EqHw_GetControlReg(
vortex_t * vortex,
u32 *
reg)
396 static void vortex_EqHw_GetSampleRate(
vortex_t * vortex,
u32 *
sr)
398 *sr = (
hwread(vortex->
mmio, 0x2b440) >> 3) & 0x1f;
402 static void vortex_EqHw_Enable(
vortex_t * vortex)
407 static void vortex_EqHw_Disable(
vortex_t * vortex)
413 static void vortex_EqHw_ZeroIO(
vortex_t * vortex)
416 for (i = 0; i < 0x8; i++)
418 for (i = 0; i < 0x4; i++)
422 static void vortex_EqHw_ZeroA3DIO(
vortex_t * vortex)
425 for (i = 0; i < 0x4; i++)
429 static void vortex_EqHw_ZeroState(
vortex_t * vortex)
432 vortex_EqHw_SetControlReg(vortex, 0);
433 vortex_EqHw_ZeroIO(vortex);
436 vortex_EqHw_SetTimeConsts(vortex, 0, 0);
438 vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsZeros);
439 vortex_EqHw_SetRightCoefs(vortex, asEqCoefsZeros);
441 vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_zero);
442 vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_zero);
443 vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_zero);
444 vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_zero);
446 vortex_EqHw_SetBypassGain(vortex, 0, 0);
448 vortex_EqHw_SetA3DBypassGain(vortex, 0, 0);
450 vortex_EqHw_SetLeftStates(vortex, eq_states_zero, asEqOutStateZeros);
451 vortex_EqHw_SetRightStates(vortex, eq_states_zero, asEqOutStateZeros);
452 vortex_EqHw_SetLevels(vortex, (
u16 *) eq_levels);
456 static void vortex_EqHw_ProgramPipe(
vortex_t * vortex)
458 vortex_EqHw_SetTimeConsts(vortex, 0, 0);
460 vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsPipes);
461 vortex_EqHw_SetRightCoefs(vortex, asEqCoefsPipes);
463 vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_current);
464 vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_current);
465 vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_current);
466 vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_current);
474 vortex_EqHw_SetTimeConsts(vortex, 0
xc, 0x7fe0);
476 vortex_EqHw_SetLeftCoefs(vortex, coefset->
LeftCoefs);
477 vortex_EqHw_SetRightCoefs(vortex, coefset->
RightCoefs);
479 vortex_EqHw_SetLeftGainsCurrent(vortex, coefset->
LeftGains);
481 vortex_EqHw_SetRightGainsTarget(vortex, coefset->
RightGains);
482 vortex_EqHw_SetLeftGainsTarget(vortex, coefset->
LeftGains);
484 vortex_EqHw_SetRightGainsCurrent(vortex, coefset->
RightGains);
488 static void vortex_EqHw_GetTenBandLevels(
vortex_t * vortex,
u16 peaks[])
496 for (i = 0; i < eqhw->
this04; i++)
497 peaks[i] =
hwread(vortex->
mmio, 0x2B024 + i * 0x30);
498 for (i = 0; i < eqhw->
this04; i++)
516 static void vortex_Eqlzr_SetLeftGain(
vortex_t * vortex,
u16 index,
u16 gain)
527 vortex_EqHw_SetLeftGainsSingleTarget(vortex, index, gain);
530 static int vortex_Eqlzr_GetRightGain(
vortex_t * vortex,
u16 index,
u16 * gain)
541 static void vortex_Eqlzr_SetRightGain(
vortex_t * vortex,
u16 index,
u16 gain)
552 vortex_EqHw_SetRightGainsSingleTarget(vortex, index, gain);
566 if (vortex_Eqlzr_GetLeftGain(vortex, si, &gains[si]))
568 if (vortex_Eqlzr_GetRightGain
569 (vortex, si, &gains[si + eq->
this10]))
578 static int vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(
vortex_t * vortex)
582 vortex_EqHw_SetLeftGainsTarget(vortex, eq->
this130);
583 vortex_EqHw_SetRightGainsTarget(vortex, &(eq->
this130[eq->
this10]));
597 for (i = 0; i <
count; i++) {
603 return vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex);
618 ebx = (eax * eq->
this58) >> 0x10;
619 eax = (eax * eq->
this5c) >> 0x10;
620 vortex_EqHw_SetA3DBypassGain(vortex, ebx, eax);
623 static void vortex_Eqlzr_ProgramA3dBypassGain(
vortex_t * vortex)
632 ebx = (eax * eq->
this58) >> 0x10;
633 eax = (eax * eq->
this5c) >> 0x10;
634 vortex_EqHw_SetA3DBypassGain(vortex, ebx, eax);
637 static void vortex_Eqlzr_ShutDownA3d(
vortex_t * vortex)
640 vortex_EqHw_ZeroA3DIO(vortex);
643 static void vortex_Eqlzr_SetBypass(
vortex_t * vortex,
u32 bp)
647 if ((eq->
this28) && (bp == 0)) {
649 vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex);
650 vortex_EqHw_SetBypassGain(vortex, eq->
this08, eq->
this08);
653 vortex_EqHw_SetLeftGainsTarget(vortex, eq->
this14_array);
654 vortex_EqHw_SetRightGainsTarget(vortex, eq->
this14_array);
655 vortex_EqHw_SetBypassGain(vortex, eq->
this0c, eq->
this0c);
657 vortex_Eqlzr_ProgramA3dBypassGain(vortex);
660 static void vortex_Eqlzr_ReadAndSetActiveCoefSet(
vortex_t * vortex)
667 vortex_Eqlzr_SetAllBands(vortex, eq_gains_normal, eq->
this10 * 2);
670 static int vortex_Eqlzr_GetAllPeaks(
vortex_t * vortex,
u16 * peaks,
int *count)
677 vortex_EqHw_GetTenBandLevels(vortex, peaks);
689 static void vortex_Eqlzr_init(
vortex_t * vortex)
711 vortex_EqHw_ZeroState(vortex);
712 vortex_EqHw_SetSampleRate(vortex, 0x11);
713 vortex_Eqlzr_ReadAndSetActiveCoefSet(vortex);
715 vortex_EqHw_Program10Band(vortex, &(eq->
coefset));
716 vortex_Eqlzr_SetBypass(vortex, eq->
this54);
717 vortex_Eqlzr_SetA3dBypassGain(vortex, 0, 0);
718 vortex_EqHw_Enable(vortex);
721 static void vortex_Eqlzr_shutdown(
vortex_t * vortex)
723 vortex_Eqlzr_ShutDownA3d(vortex);
724 vortex_EqHw_ProgramPipe(vortex);
725 vortex_EqHw_Disable(vortex);
731 #define snd_vortex_eqtoggle_info snd_ctl_boolean_mono_info
741 ucontrol->
value.integer.value[0] = eq->
this54 ? 0 : 1;
754 eq->
this54 = ucontrol->
value.integer.value[0] ? 0 : 1;
755 vortex_Eqlzr_SetBypass(vortex, eq->
this54);
767 .get = snd_vortex_eqtoggle_get,
768 .put = snd_vortex_eqtoggle_put
786 u16 gainL = 0, gainR = 0;
788 vortex_Eqlzr_GetLeftGain(vortex, i, &gainL);
789 vortex_Eqlzr_GetRightGain(vortex, i, &gainR);
790 ucontrol->
value.integer.value[0] = gainL;
791 ucontrol->
value.integer.value[1] = gainR;
800 u16 gainL = 0, gainR = 0;
802 vortex_Eqlzr_GetLeftGain(vortex, i, &gainL);
803 vortex_Eqlzr_GetRightGain(vortex, i, &gainR);
805 if (gainL != ucontrol->
value.integer.value[0]) {
806 vortex_Eqlzr_SetLeftGain(vortex, i,
807 ucontrol->
value.integer.value[0]);
810 if (gainR != ucontrol->
value.integer.value[1]) {
811 vortex_Eqlzr_SetRightGain(vortex, i,
812 ucontrol->
value.integer.value[1]);
824 .info = snd_vortex_eq_info,
825 .get = snd_vortex_eq_get,
826 .put = snd_vortex_eq_put
846 vortex_Eqlzr_GetAllPeaks(vortex, peaks, &count);
851 for (i = 0; i < 20; i++)
852 ucontrol->
value.integer.value[i] = peaks[i];
861 .info = snd_vortex_peaks_info,
862 .get = snd_vortex_peaks_get,
866 static char *EqBandLabels[10] __devinitdata = {
885 vortex_Eqlzr_init(vortex);
895 for (i = 0; i < 10; i++) {
900 "%s Playback Volume", EqBandLabels[i]);
915 static int vortex_eq_free(
vortex_t * vortex)
925 vortex_Eqlzr_shutdown(vortex);