static void vortex_wt_SetVolume(vortex_t * vortex, int wt, int vol[]) { wt_voice_t *voice = &(vortex->wt_voice[wt]); int ecx = vol[1], eax = vol[0]; /* This is pure guess */ voice->parm0 &= 0xff00ffff; voice->parm0 |= (vol[0] & 0xff) << 0x10; voice->parm1 &= 0xff00ffff; voice->parm1 |= (vol[1] & 0xff) << 0x10; /* This is real */ hwwrite(vortex, WT_PARM(wt, 0), voice->parm0); hwwrite(vortex, WT_PARM(wt, 1), voice->parm0); if (voice->this_1D0 & 4) { eax >>= 8; ecx = eax; if (ecx < 0x80) ecx = 0x7f; voice->parm3 &= 0xFFFFC07F; voice->parm3 |= (ecx & 0x7f) << 7; voice->parm3 &= 0xFFFFFF80; voice->parm3 |= (eax & 0x7f); } else {
/* Mix Gains */ static void vortex_EqHw_SetBypassGain(vortex_t * vortex, u16 a, u16 b) { eqhw_t *eqhw = &(vortex->eq.this04); if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b3d4, a); hwwrite(vortex->mmio, 0x2b3ec, b); } else { hwwrite(vortex->mmio, 0x2b3d4, sign_invert(a)); hwwrite(vortex->mmio, 0x2b3ec, sign_invert(b)); } }
static void vortex_wt_connect(vortex_t * vortex, int en) { int i, ii, mix; #define NR_WTROUTES 6 #ifdef CHIP_AU8830 #define NR_WTBLOCKS 2 #else #define NR_WTBLOCKS 1 #endif for (i = 0; i < NR_WTBLOCKS; i++) { for (ii = 0; ii < NR_WTROUTES; ii++) { mix = vortex_adb_checkinout(vortex, vortex->fixed_res, en, VORTEX_RESOURCE_MIXIN); vortex->mixwt[(i * NR_WTROUTES) + ii] = mix; vortex_route(vortex, en, 0x11, ADB_WTOUT(i, ii + 0x20), ADB_MIXIN(mix)); vortex_connection_mixin_mix(vortex, en, mix, vortex->mixplayb[ii % 2], 0); if (VORTEX_IS_QUAD(vortex)) vortex_connection_mixin_mix(vortex, en, mix, vortex->mixplayb[2 + (ii % 2)], 0); } } for (i = 0; i < NR_WT; i++) { hwwrite(vortex->mmio, WT_RUN(i), 1); } }
static void vortex_EqHw_SetLeftGainsTarget(vortex_t * vortex, u16 a[]) { eqhw_t *eqhw = &(vortex->eq.this04); int ebx; for (ebx = 0; ebx < eqhw->this04; ebx++) { hwwrite(vortex->mmio, 0x2b02c + ebx * 0x30, a[ebx]); } }
static void vortex_EqHw_SetRightGainsCurrent(vortex_t * vortex, u16 a[]) { eqhw_t *eqhw = &(vortex->eq.this04); int ebx; for (ebx = 0; ebx < eqhw->this04; ebx++) { hwwrite(vortex->mmio, 0x2b208 + ebx * 0x30, a[ebx]); } }
/* Put 2 WT channels together for one stereo interlaced channel. */ static void vortex_wt_setstereo(vortex_t * vortex, u32 wt, u32 stereo) { int temp; //temp = hwread(vortex->mmio, 0x80 + ((wt >> 0x5)<< 0xf) + (((wt & 0x1f) >> 1) << 2)); temp = hwread(vortex->mmio, WT_STEREO(wt)); temp = (temp & 0xfe) | (stereo & 1); //hwwrite(vortex->mmio, 0x80 + ((wt >> 0x5)<< 0xf) + (((wt & 0x1f) >> 1) << 2), temp); hwwrite(vortex->mmio, WT_STEREO(wt), temp); }
/* Join to mixdown route. */ static void vortex_wt_setdsout(vortex_t * vortex, u32 wt, int en) { int temp; /* There is one DSREG register for each bank (32 voices each). */ temp = hwread(vortex->mmio, WT_DSREG((wt >= 0x20) ? 1 : 0)); if (en) temp |= (1 << (wt & 0x1f)); else temp &= (1 << ~(wt & 0x1f)); hwwrite(vortex->mmio, WT_DSREG((wt >= 0x20) ? 1 : 0), temp); }
/* 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); } }
/* 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)]); }
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); }
/* XTalk EQ and XT */ static void vortex_XtalkHw_SetLeftEQ(vortex_t * vortex, short arg_0, short arg_4, xtalk_coefs_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x24200 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x24204 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x24208 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x2420c + i * 0x24, coefs[i][3]); hwwrite(vortex->mmio, 0x24210 + i * 0x24, coefs[i][4]); } hwwrite(vortex->mmio, 0x24538, arg_0 & 0xffff); hwwrite(vortex->mmio, 0x2453C, arg_4 & 0xffff); }
static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, n /*esp2c */; for (n = 0; n < eqhw->this04; n++) { hwwrite(vortex->mmio, 0x2b000 + n * 0x30, coefs[i + 0]); hwwrite(vortex->mmio, 0x2b004 + n * 0x30, coefs[i + 1]); if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b008 + n * 0x30, coefs[i + 2]); hwwrite(vortex->mmio, 0x2b00c + n * 0x30, coefs[i + 3]); hwwrite(vortex->mmio, 0x2b010 + n * 0x30, coefs[i + 4]); } else { hwwrite(vortex->mmio, 0x2b008 + n * 0x30, sign_invert(coefs[2 + i])); hwwrite(vortex->mmio, 0x2b00c + n * 0x30, sign_invert(coefs[3 + i])); hwwrite(vortex->mmio, 0x2b010 + n * 0x30, sign_invert(coefs[4 + i])); } i += 5; } }
static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 coefs[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, n /*esp2c */; for (n = 0; n < eqhw->this04; n++) { hwwrite(vortex->mmio, 0x2b1e0 + n * 0x30, coefs[0 + i]); hwwrite(vortex->mmio, 0x2b1e4 + n * 0x30, coefs[1 + i]); if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, coefs[2 + i]); hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, coefs[3 + i]); hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, coefs[4 + i]); } else { hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, sign_invert(coefs[2 + i])); hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, sign_invert(coefs[3 + i])); hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, sign_invert(coefs[4 + i])); } i += 5; } }
static void vortex_EqHw_SetLeftStates(vortex_t * vortex, u16 a[], u16 b[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, ebx; hwwrite(vortex->mmio, 0x2b3fc, a[0]); hwwrite(vortex->mmio, 0x2b400, a[1]); for (ebx = 0; ebx < eqhw->this04; ebx++) { 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; } }
static void vortex_EqHw_SetRightStates(vortex_t * vortex, u16 a[], u16 b[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, ebx; hwwrite(vortex->mmio, 0x2b404, a[0]); hwwrite(vortex->mmio, 0x2b408, a[1]); for (ebx = 0; ebx < eqhw->this04; ebx++) { 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; } }
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); }
/* EQ band levels settings */ static void vortex_EqHw_SetLevels(vortex_t * vortex, u16 peaks[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i; /* set left peaks */ for (i = 0; i < eqhw->this04; i++) { hwwrite(vortex->mmio, 0x2b024 + i * VORTEX_BAND_COEFF_SIZE, peaks[i]); } hwwrite(vortex->mmio, 0x2b3cc, peaks[eqhw->this04]); hwwrite(vortex->mmio, 0x2b3d8, peaks[eqhw->this04 + 1]); /* set right peaks */ for (i = 0; i < eqhw->this04; i++) { hwwrite(vortex->mmio, 0x2b204 + i * VORTEX_BAND_COEFF_SIZE, peaks[i + (eqhw->this04 + 2)]); } hwwrite(vortex->mmio, 0x2b3e4, peaks[2 + (eqhw->this04 * 2)]); hwwrite(vortex->mmio, 0x2b3f0, peaks[3 + (eqhw->this04 * 2)]); }
static void vortex_EqHw_SetCurrA3DBypassGain(vortex_t * vortex, u16 a, u16 b) { hwwrite(vortex->mmio, 0x2b3dc, a); hwwrite(vortex->mmio, 0x2b3f4, b); }
/* 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 int vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, u32 val) { int ecx; if ((reg == 5) || ((reg >= 7) && (reg <= 10)) || (reg == 0xc)) { if (wt >= (NR_WT / NR_WT_PB)) { printk ("vortex: WT SetReg: bank out of range. reg=0x%x, wt=%d\n", reg, wt); return 0; } } else { if (wt >= NR_WT) { ; return 0; } } if (reg > 0xc) return 0; switch (reg) { /* Voice specific parameters */ case 0: /* running */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_RUN(wt), val); return 0xc; break; case 1: /* param 0 */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_PARM(wt, 0), val); return 0xc; break; case 2: /* param 1 */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_PARM(wt, 1), val); return 0xc; break; case 3: /* param 2 */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_PARM(wt, 2), val); return 0xc; break; case 4: /* param 3 */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_PARM(wt, 3), val); return 0xc; break; case 6: /* mute */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_MUTE(wt), val); return 0xc; break; case 0xb: { /* delay */ /* // printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ; */ hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); hwwrite(vortex->mmio, WT_DELAY(wt, 0), val); return 0xc; } break; /* Global WT block parameters */ case 5: /* sramp */ ecx = WT_SRAMP(wt); break; case 8: /* aramp */ ecx = WT_ARAMP(wt); break; case 9: /* mramp */ ecx = WT_MRAMP(wt); break; case 0xa: /* ctrl */ ecx = WT_CTRL(wt); break; case 0xc: /* ds_reg */ ecx = WT_DSREG(wt); break; default: return 0; break; } /* ; */ hwwrite(vortex->mmio, ecx, val); return 1; }
static void vortex_EqHw_SetA3DBypassGain(vortex_t * vortex, u16 a, u16 b) { hwwrite(vortex->mmio, 0x2b3e0, a); hwwrite(vortex->mmio, 0x2b3f8, b); }
static void vortex_EqHw_SetCurrBypassGain(vortex_t * vortex, u16 a, u16 b) { hwwrite(vortex->mmio, 0x2b3d0, a); hwwrite(vortex->mmio, 0x2b3e8, b); }
/* CEqHw.s */ static void vortex_EqHw_SetTimeConsts(vortex_t * vortex, u16 gain, u16 level) { hwwrite(vortex->mmio, 0x2b3c4, gain); hwwrite(vortex->mmio, 0x2b3c8, level); }
static void vortex_EqHw_SetSampleRate(vortex_t * vortex, int sr) { hwwrite(vortex->mmio, 0x2b440, ((sr & 0x1f) << 3) | 0xb800); }
/* Global Control */ static void vortex_EqHw_SetControlReg(vortex_t * vortex, unsigned long reg) { hwwrite(vortex->mmio, 0x2b440, reg); }
/* Setup WT route. */ static int vortex_wt_allocroute(vortex_t * vortex, int wt, int nr_ch) { wt_voice_t *voice = &(vortex->wt_voice[wt]); int temp; //FIXME: WT audio routing. if (nr_ch) { vortex_fifo_wtinitialize(vortex, wt, 1); vortex_fifo_setwtvalid(vortex, wt, 1); vortex_wt_setstereo(vortex, wt, nr_ch - 1); } else vortex_fifo_setwtvalid(vortex, wt, 0); /* Set mixdown mode. */ vortex_wt_setdsout(vortex, wt, 1); /* Set other parameter registers. */ hwwrite(vortex->mmio, WT_SRAMP(0), 0x880000); //hwwrite(vortex->mmio, WT_GMODE(0), 0xffffffff); #ifdef CHIP_AU8830 hwwrite(vortex->mmio, WT_SRAMP(1), 0x880000); //hwwrite(vortex->mmio, WT_GMODE(1), 0xffffffff); #endif hwwrite(vortex->mmio, WT_PARM(wt, 0), 0); hwwrite(vortex->mmio, WT_PARM(wt, 1), 0); hwwrite(vortex->mmio, WT_PARM(wt, 2), 0); temp = hwread(vortex->mmio, WT_PARM(wt, 3)); ; //hwwrite(vortex->mmio, WT_PARM(wt, 3), temp); hwwrite(vortex->mmio, WT_DELAY(wt, 0), 0); hwwrite(vortex->mmio, WT_DELAY(wt, 1), 0); hwwrite(vortex->mmio, WT_DELAY(wt, 2), 0); hwwrite(vortex->mmio, WT_DELAY(wt, 3), 0); ; hwwrite(vortex->mmio, WT_PARM(wt, 2), 0xffffffff); hwwrite(vortex->mmio, WT_PARM(wt, 3), 0xcff1c810); voice->parm0 = voice->parm1 = 0xcfb23e2f; hwwrite(vortex->mmio, WT_PARM(wt, 0), voice->parm0); hwwrite(vortex->mmio, WT_PARM(wt, 1), voice->parm1); ; return 0; }
static void vortex_EqHw_SetRightGainsSingleTarget(vortex_t * vortex, u16 index, u16 b) { hwwrite(vortex->mmio, 0x2b20c + (index * 0x30), b); }