au88x0_eq.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 1,004 行 · 第 1/2 页
C
1,004 行
/*************************************************************************** * au88x0_eq.c * Aureal Vortex Hardware EQ control/access. * * Sun Jun 8 18:19:19 2003 * 2003 Manuel Jander (mjander@users.sourceforge.net) * * 02 July 2003: First time something works :) * November 2003: A3D Bypass code completed but untested. * * TODO: * - Debug (testing) * - Test peak visualization support. * ****************************************************************************//* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* The Aureal Hardware EQ is found on AU8810 and AU8830 chips only. it has 4 inputs (2 for general mix, 2 for A3D) and 2 outputs (supposed to be routed to the codec).*/#include "au88x0.h"#include "au88x0_eq.h"#include "au88x0_eqdata.c"/* CEqHw.s */static void vortex_EqHw_SetTimeConsts(vortex_t * vortex, u16 a, u16 b){ hwwrite(vortex->mmio, 0x2b3c4, a); hwwrite(vortex->mmio, 0x2b3c8, b);}static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int eax, i = 0, n /*esp2c */ = 0; if (eqhw->this04 <= n) return; do { hwwrite(vortex->mmio, 0x2b000 + n * 0x30, a[i + 0]); hwwrite(vortex->mmio, 0x2b004 + n * 0x30, a[i + 1]); if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b008 + n * 0x30, a[i + 2]); hwwrite(vortex->mmio, 0x2b00c + n * 0x30, a[i + 3]); eax = a[i + 4]; //esp24; } else { if (a[2 + i] == 0x8000) eax = 0x7fff; else eax = ~a[2 + i]; hwwrite(vortex->mmio, 0x2b008 + n * 0x30, eax & 0xffff); if (a[3 + i] == 0x8000) eax = 0x7fff; else eax = ~a[3 + i]; hwwrite(vortex->mmio, 0x2b00c + n * 0x30, eax & 0xffff); if (a[4 + i] == 0x8000) eax = 0x7fff; else eax = ~a[4 + i]; } hwwrite(vortex->mmio, 0x2b010 + n * 0x30, eax); n++; i += 5; } while (n < eqhw->this04);}static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, n /*esp2c */ = 0, eax; if (eqhw->this04 <= n) return; do { hwwrite(vortex->mmio, 0x2b1e0 + n * 0x30, a[0 + i]); hwwrite(vortex->mmio, 0x2b1e4 + n * 0x30, a[1 + i]); if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, a[2 + i]); hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, a[3 + i]); eax = a[4 + i]; //*esp24; } else { if (a[2 + i] == 0x8000) eax = 0x7fff; else eax = ~(a[2 + i]); hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, eax & 0xffff); if (a[3 + i] == 0x8000) eax = 0x7fff; else eax = ~a[3 + i]; hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, eax & 0xffff); if (a[4 + i] == 0x8000) eax = 0x7fff; else eax = ~a[4 + i]; } hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, eax); i += 5; n++; } while (n < eqhw->this04);}static void vortex_EqHw_SetLeftStates(vortex_t * vortex, u16 a[], u16 b[]){ eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, ebx = 0; hwwrite(vortex->mmio, 0x2b3fc, a[0]); hwwrite(vortex->mmio, 0x2b400, a[1]); if (eqhw->this04 < 0) return; do { hwwrite(vortex->mmio, 0x2b014 + (i * 0xc), b[i]); hwwrite(vortex->mmio, 0x2b018 + (i * 0xc), b[1 + i]); hwwrite(vortex->mmio, 0x2b01c + (i * 0xc), b[2 + i]); hwwrite(vortex->mmio, 0x2b020 + (i * 0xc), b[3 + i]); i += 4; ebx++; } while (eqhw->this04 > ebx);}static void vortex_EqHw_SetRightStates(vortex_t * vortex, u16 a[], u16 b[]){ eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, ebx = 0; hwwrite(vortex->mmio, 0x2b404, a[0]); hwwrite(vortex->mmio, 0x2b408, a[1]); if (eqhw->this04 < 0) return; do { hwwrite(vortex->mmio, 0x2b1f4 + (i * 0xc), b[i]); hwwrite(vortex->mmio, 0x2b1f8 + (i * 0xc), b[1 + i]); hwwrite(vortex->mmio, 0x2b1fc + (i * 0xc), b[2 + i]); hwwrite(vortex->mmio, 0x2b200 + (i * 0xc), b[3 + i]); i += 4; ebx++; } while (ebx < eqhw->this04);}#if 0static void vortex_EqHw_GetTimeConsts(vortex_t * vortex, u16 * a, u16 * b){ *a = hwread(vortex->mmio, 0x2b3c4); *b = hwread(vortex->mmio, 0x2b3c8);}static void vortex_EqHw_GetLeftCoefs(vortex_t * vortex, u16 a[]){}static void vortex_EqHw_GetRightCoefs(vortex_t * vortex, u16 a[]){}static void vortex_EqHw_GetLeftStates(vortex_t * vortex, u16 * a, u16 b[]){}static void vortex_EqHw_GetRightStates(vortex_t * vortex, u16 * a, u16 b[]){}#endif/* Mix Gains */static void vortex_EqHw_SetBypassGain(vortex_t * vortex, u16 a, u16 b){ eqhw_t *eqhw = &(vortex->eq.this04); int eax; if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b3d4, a); hwwrite(vortex->mmio, 0x2b3ec, b); } else { if (a == 0x8000) eax = 0x7fff; else eax = ~a; hwwrite(vortex->mmio, 0x2b3d4, eax & 0xffff); if (b == 0x8000) eax = 0x7fff; else eax = ~b; hwwrite(vortex->mmio, 0x2b3ec, eax & 0xffff); }}static void vortex_EqHw_SetA3DBypassGain(vortex_t * vortex, u16 a, u16 b){ hwwrite(vortex->mmio, 0x2b3e0, a); hwwrite(vortex->mmio, 0x2b3f8, b);}#if 0static void vortex_EqHw_SetCurrBypassGain(vortex_t * vortex, u16 a, u16 b){ hwwrite(vortex->mmio, 0x2b3d0, a); hwwrite(vortex->mmio, 0x2b3e8, b);}static void vortex_EqHw_SetCurrA3DBypassGain(vortex_t * vortex, u16 a, u16 b){ hwwrite(vortex->mmio, 0x2b3dc, a); hwwrite(vortex->mmio, 0x2b3f4, b);}#endifstatic voidvortex_EqHw_SetLeftGainsSingleTarget(vortex_t * vortex, u16 index, u16 b){ hwwrite(vortex->mmio, 0x2b02c + (index * 0x30), b);}static voidvortex_EqHw_SetRightGainsSingleTarget(vortex_t * vortex, u16 index, u16 b){ hwwrite(vortex->mmio, 0x2b20c + (index * 0x30), b);}static void vortex_EqHw_SetLeftGainsTarget(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { hwwrite(vortex->mmio, 0x2b02c + ebx * 0x30, a[ebx]); ebx++; } while (ebx < eqhw->this04);}static void vortex_EqHw_SetRightGainsTarget(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { hwwrite(vortex->mmio, 0x2b20c + ebx * 0x30, a[ebx]); ebx++; } while (ebx < eqhw->this04);}static void vortex_EqHw_SetLeftGainsCurrent(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { hwwrite(vortex->mmio, 0x2b028 + ebx * 0x30, a[ebx]); ebx++; } while (ebx < eqhw->this04);}static void vortex_EqHw_SetRightGainsCurrent(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { hwwrite(vortex->mmio, 0x2b208 + ebx * 0x30, a[ebx]); ebx++; } while (ebx < eqhw->this04);}#if 0static void vortex_EqHw_GetLeftGainsTarget(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { a[ebx] = hwread(vortex->mmio, 0x2b02c + ebx * 0x30); ebx++; } while (ebx < eqhw->this04);}static void vortex_EqHw_GetRightGainsTarget(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { a[ebx] = hwread(vortex->mmio, 0x2b20c + ebx * 0x30); ebx++; } while (ebx < eqhw->this04);}static void vortex_EqHw_GetLeftGainsCurrent(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { a[ebx] = hwread(vortex->mmio, 0x2b028 + ebx * 0x30); ebx++; } while (ebx < eqhw->this04);}static void vortex_EqHw_GetRightGainsCurrent(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx = 0; if (eqhw->this04 < 0) return; do { a[ebx] = hwread(vortex->mmio, 0x2b208 + ebx * 0x30); ebx++; } while (ebx < eqhw->this04);}#endif/* EQ band levels settings */static void vortex_EqHw_SetLevels(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx; if (eqhw->this04 < 0) return; ebx = 0; do { hwwrite(vortex->mmio, 0x2b024 + ebx * 0x30, a[ebx]); ebx++; } while (ebx < eqhw->this04); hwwrite(vortex->mmio, 0x2b3cc, a[eqhw->this04]); hwwrite(vortex->mmio, 0x2b3d8, a[eqhw->this04 + 1]); ebx = 0; do { hwwrite(vortex->mmio, 0x2b204 + ebx * 0x30, a[ebx + (eqhw->this04 + 2)]); ebx++; } while (ebx < eqhw->this04); hwwrite(vortex->mmio, 0x2b3e4, a[2 + (eqhw->this04 * 2)]); hwwrite(vortex->mmio, 0x2b3f0, a[3 + (eqhw->this04 * 2)]);}#if 0static void vortex_EqHw_GetLevels(vortex_t * vortex, u16 a[]){ eqhw_t *eqhw = &(vortex->eq.this04); int ebx; if (eqhw->this04 < 0) return; ebx = 0; do { a[ebx] = hwread(vortex->mmio, 0x2b024 + ebx * 0x30); ebx++; } while (ebx < eqhw->this04); a[eqhw->this04] = hwread(vortex->mmio, 0x2b3cc); a[eqhw->this04 + 1] = hwread(vortex->mmio, 0x2b3d8); ebx = 0; do { a[ebx + (eqhw->this04 + 2)] = hwread(vortex->mmio, 0x2b204 + ebx * 0x30); ebx++; } while (ebx < eqhw->this04); a[2 + (eqhw->this04 * 2)] = hwread(vortex->mmio, 0x2b3e4); a[3 + (eqhw->this04 * 2)] = hwread(vortex->mmio, 0x2b3f0);}#endif/* Global Control */static void vortex_EqHw_SetControlReg(vortex_t * vortex, unsigned long reg){ hwwrite(vortex->mmio, 0x2b440, reg);}static void vortex_EqHw_SetSampleRate(vortex_t * vortex, int sr){ hwwrite(vortex->mmio, 0x2b440, ((sr & 0x1f) << 3) | 0xb800);}#if 0static void vortex_EqHw_GetControlReg(vortex_t * vortex, unsigned long *reg){ *reg = hwread(vortex->mmio, 0x2b440);}static void vortex_EqHw_GetSampleRate(vortex_t * vortex, int *sr){ *sr = (hwread(vortex->mmio, 0x2b440) >> 3) & 0x1f;}#endifstatic void vortex_EqHw_Enable(vortex_t * vortex){ hwwrite(vortex->mmio, 0x2b440, 0xf001);}static void vortex_EqHw_Disable(vortex_t * vortex){ hwwrite(vortex->mmio, 0x2b440, 0xf000);}/* Reset (zero) buffers */static void vortex_EqHw_ZeroIO(vortex_t * vortex){ int i; for (i = 0; i < 0x8; i++) hwwrite(vortex->mmio, 0x2b410 + (i << 2), 0x0); for (i = 0; i < 0x4; i++) hwwrite(vortex->mmio, 0x2b430 + (i << 2), 0x0);}static void vortex_EqHw_ZeroA3DIO(vortex_t * vortex){ int i; for (i = 0; i < 0x4; i++) hwwrite(vortex->mmio, 0x2b410 + (i << 2), 0x0);}static void vortex_EqHw_ZeroState(vortex_t * vortex){ vortex_EqHw_SetControlReg(vortex, 0); vortex_EqHw_ZeroIO(vortex); hwwrite(vortex->mmio, 0x2b3c0, 0); vortex_EqHw_SetTimeConsts(vortex, 0, 0);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?