18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci */ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Someday its supposed to make use of the WT DMA engine 78c2ecf20Sopenharmony_ci * for a Wavetable synthesizer. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include "au88x0.h" 118c2ecf20Sopenharmony_ci#include "au88x0_wt.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistatic void vortex_fifo_setwtvalid(vortex_t * vortex, int fifo, int en); 148c2ecf20Sopenharmony_cistatic void vortex_connection_adb_mixin(vortex_t * vortex, int en, 158c2ecf20Sopenharmony_ci unsigned char channel, 168c2ecf20Sopenharmony_ci unsigned char source, 178c2ecf20Sopenharmony_ci unsigned char mixin); 188c2ecf20Sopenharmony_cistatic void vortex_connection_mixin_mix(vortex_t * vortex, int en, 198c2ecf20Sopenharmony_ci unsigned char mixin, 208c2ecf20Sopenharmony_ci unsigned char mix, int a); 218c2ecf20Sopenharmony_cistatic void vortex_fifo_wtinitialize(vortex_t * vortex, int fifo, int j); 228c2ecf20Sopenharmony_cistatic int vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, 238c2ecf20Sopenharmony_ci u32 val); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* WT */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* Put 2 WT channels together for one stereo interlaced channel. */ 288c2ecf20Sopenharmony_cistatic void vortex_wt_setstereo(vortex_t * vortex, u32 wt, u32 stereo) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci int temp; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci //temp = hwread(vortex->mmio, 0x80 + ((wt >> 0x5)<< 0xf) + (((wt & 0x1f) >> 1) << 2)); 338c2ecf20Sopenharmony_ci temp = hwread(vortex->mmio, WT_STEREO(wt)); 348c2ecf20Sopenharmony_ci temp = (temp & 0xfe) | (stereo & 1); 358c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, 0x80 + ((wt >> 0x5)<< 0xf) + (((wt & 0x1f) >> 1) << 2), temp); 368c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_STEREO(wt), temp); 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* Join to mixdown route. */ 408c2ecf20Sopenharmony_cistatic void vortex_wt_setdsout(vortex_t * vortex, u32 wt, int en) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci int temp; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci /* There is one DSREG register for each bank (32 voices each). */ 458c2ecf20Sopenharmony_ci temp = hwread(vortex->mmio, WT_DSREG((wt >= 0x20) ? 1 : 0)); 468c2ecf20Sopenharmony_ci if (en) 478c2ecf20Sopenharmony_ci temp |= (1 << (wt & 0x1f)); 488c2ecf20Sopenharmony_ci else 498c2ecf20Sopenharmony_ci temp &= ~(1 << (wt & 0x1f)); 508c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DSREG((wt >= 0x20) ? 1 : 0), temp); 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* Setup WT route. */ 548c2ecf20Sopenharmony_cistatic int vortex_wt_allocroute(vortex_t * vortex, int wt, int nr_ch) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci wt_voice_t *voice = &(vortex->wt_voice[wt]); 578c2ecf20Sopenharmony_ci int temp; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci //FIXME: WT audio routing. 608c2ecf20Sopenharmony_ci if (nr_ch) { 618c2ecf20Sopenharmony_ci vortex_fifo_wtinitialize(vortex, wt, 1); 628c2ecf20Sopenharmony_ci vortex_fifo_setwtvalid(vortex, wt, 1); 638c2ecf20Sopenharmony_ci vortex_wt_setstereo(vortex, wt, nr_ch - 1); 648c2ecf20Sopenharmony_ci } else 658c2ecf20Sopenharmony_ci vortex_fifo_setwtvalid(vortex, wt, 0); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci /* Set mixdown mode. */ 688c2ecf20Sopenharmony_ci vortex_wt_setdsout(vortex, wt, 1); 698c2ecf20Sopenharmony_ci /* Set other parameter registers. */ 708c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_SRAMP(0), 0x880000); 718c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, WT_GMODE(0), 0xffffffff); 728c2ecf20Sopenharmony_ci#ifdef CHIP_AU8830 738c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_SRAMP(1), 0x880000); 748c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, WT_GMODE(1), 0xffffffff); 758c2ecf20Sopenharmony_ci#endif 768c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 0), 0); 778c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 1), 0); 788c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 2), 0); 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci temp = hwread(vortex->mmio, WT_PARM(wt, 3)); 818c2ecf20Sopenharmony_ci dev_dbg(vortex->card->dev, "WT PARM3: %x\n", temp); 828c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, WT_PARM(wt, 3), temp); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 0), 0); 858c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 1), 0); 868c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 2), 0); 878c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 3), 0); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci dev_dbg(vortex->card->dev, "WT GMODE: %x\n", 908c2ecf20Sopenharmony_ci hwread(vortex->mmio, WT_GMODE(wt))); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 2), 0xffffffff); 938c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 3), 0xcff1c810); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci voice->parm0 = voice->parm1 = 0xcfb23e2f; 968c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 0), voice->parm0); 978c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 1), voice->parm1); 988c2ecf20Sopenharmony_ci dev_dbg(vortex->card->dev, "WT GMODE 2 : %x\n", 998c2ecf20Sopenharmony_ci hwread(vortex->mmio, WT_GMODE(wt))); 1008c2ecf20Sopenharmony_ci return 0; 1018c2ecf20Sopenharmony_ci} 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistatic void vortex_wt_connect(vortex_t * vortex, int en) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci int i, ii, mix; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#define NR_WTROUTES 6 1098c2ecf20Sopenharmony_ci#ifdef CHIP_AU8830 1108c2ecf20Sopenharmony_ci#define NR_WTBLOCKS 2 1118c2ecf20Sopenharmony_ci#else 1128c2ecf20Sopenharmony_ci#define NR_WTBLOCKS 1 1138c2ecf20Sopenharmony_ci#endif 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci for (i = 0; i < NR_WTBLOCKS; i++) { 1168c2ecf20Sopenharmony_ci for (ii = 0; ii < NR_WTROUTES; ii++) { 1178c2ecf20Sopenharmony_ci mix = 1188c2ecf20Sopenharmony_ci vortex_adb_checkinout(vortex, 1198c2ecf20Sopenharmony_ci vortex->fixed_res, en, 1208c2ecf20Sopenharmony_ci VORTEX_RESOURCE_MIXIN); 1218c2ecf20Sopenharmony_ci vortex->mixwt[(i * NR_WTROUTES) + ii] = mix; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci vortex_route(vortex, en, 0x11, 1248c2ecf20Sopenharmony_ci ADB_WTOUT(i, ii + 0x20), ADB_MIXIN(mix)); 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci vortex_connection_mixin_mix(vortex, en, mix, 1278c2ecf20Sopenharmony_ci vortex->mixplayb[ii % 2], 0); 1288c2ecf20Sopenharmony_ci if (VORTEX_IS_QUAD(vortex)) 1298c2ecf20Sopenharmony_ci vortex_connection_mixin_mix(vortex, en, 1308c2ecf20Sopenharmony_ci mix, 1318c2ecf20Sopenharmony_ci vortex->mixplayb[2 + 1328c2ecf20Sopenharmony_ci (ii % 2)], 0); 1338c2ecf20Sopenharmony_ci } 1348c2ecf20Sopenharmony_ci } 1358c2ecf20Sopenharmony_ci for (i = 0; i < NR_WT; i++) { 1368c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_RUN(i), 1); 1378c2ecf20Sopenharmony_ci } 1388c2ecf20Sopenharmony_ci} 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/* Read WT Register */ 1418c2ecf20Sopenharmony_ci#if 0 1428c2ecf20Sopenharmony_cistatic int vortex_wt_GetReg(vortex_t * vortex, char reg, int wt) 1438c2ecf20Sopenharmony_ci{ 1448c2ecf20Sopenharmony_ci //int eax, esi; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci if (reg == 4) { 1478c2ecf20Sopenharmony_ci return hwread(vortex->mmio, WT_PARM(wt, 3)); 1488c2ecf20Sopenharmony_ci } 1498c2ecf20Sopenharmony_ci if (reg == 7) { 1508c2ecf20Sopenharmony_ci return hwread(vortex->mmio, WT_GMODE(wt)); 1518c2ecf20Sopenharmony_ci } 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci return 0; 1548c2ecf20Sopenharmony_ci} 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci/* WT hardware abstraction layer generic register interface. */ 1578c2ecf20Sopenharmony_cistatic int 1588c2ecf20Sopenharmony_civortex_wt_SetReg2(vortex_t * vortex, unsigned char reg, int wt, 1598c2ecf20Sopenharmony_ci u16 val) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci /* 1628c2ecf20Sopenharmony_ci int eax, edx; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci if (wt >= NR_WT) // 0x40 -> NR_WT 1658c2ecf20Sopenharmony_ci return 0; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci if ((reg - 0x20) > 0) { 1688c2ecf20Sopenharmony_ci if ((reg - 0x21) != 0) 1698c2ecf20Sopenharmony_ci return 0; 1708c2ecf20Sopenharmony_ci eax = ((((b & 0xff) << 0xb) + (edx & 0xff)) << 4) + 0x208; // param 2 1718c2ecf20Sopenharmony_ci } else { 1728c2ecf20Sopenharmony_ci eax = ((((b & 0xff) << 0xb) + (edx & 0xff)) << 4) + 0x20a; // param 3 1738c2ecf20Sopenharmony_ci } 1748c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, eax, c); 1758c2ecf20Sopenharmony_ci */ 1768c2ecf20Sopenharmony_ci return 1; 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/*public: static void __thiscall CWTHal::SetReg(unsigned char,int,unsigned long) */ 1808c2ecf20Sopenharmony_ci#endif 1818c2ecf20Sopenharmony_cistatic int 1828c2ecf20Sopenharmony_civortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, 1838c2ecf20Sopenharmony_ci u32 val) 1848c2ecf20Sopenharmony_ci{ 1858c2ecf20Sopenharmony_ci int ecx; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci if ((reg == 5) || ((reg >= 7) && (reg <= 10)) || (reg == 0xc)) { 1888c2ecf20Sopenharmony_ci if (wt >= (NR_WT / NR_WT_PB)) { 1898c2ecf20Sopenharmony_ci dev_warn(vortex->card->dev, 1908c2ecf20Sopenharmony_ci "WT SetReg: bank out of range. reg=0x%x, wt=%d\n", 1918c2ecf20Sopenharmony_ci reg, wt); 1928c2ecf20Sopenharmony_ci return 0; 1938c2ecf20Sopenharmony_ci } 1948c2ecf20Sopenharmony_ci } else { 1958c2ecf20Sopenharmony_ci if (wt >= NR_WT) { 1968c2ecf20Sopenharmony_ci dev_err(vortex->card->dev, 1978c2ecf20Sopenharmony_ci "WT SetReg: voice out of range\n"); 1988c2ecf20Sopenharmony_ci return 0; 1998c2ecf20Sopenharmony_ci } 2008c2ecf20Sopenharmony_ci } 2018c2ecf20Sopenharmony_ci if (reg > 0xc) 2028c2ecf20Sopenharmony_ci return 0; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci switch (reg) { 2058c2ecf20Sopenharmony_ci /* Voice specific parameters */ 2068c2ecf20Sopenharmony_ci case 0: /* running */ 2078c2ecf20Sopenharmony_ci /* 2088c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2098c2ecf20Sopenharmony_ci WT_RUN(wt), (int)val); 2108c2ecf20Sopenharmony_ci */ 2118c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_RUN(wt), val); 2128c2ecf20Sopenharmony_ci return 0xc; 2138c2ecf20Sopenharmony_ci case 1: /* param 0 */ 2148c2ecf20Sopenharmony_ci /* 2158c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2168c2ecf20Sopenharmony_ci WT_PARM(wt,0), (int)val); 2178c2ecf20Sopenharmony_ci */ 2188c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 0), val); 2198c2ecf20Sopenharmony_ci return 0xc; 2208c2ecf20Sopenharmony_ci case 2: /* param 1 */ 2218c2ecf20Sopenharmony_ci /* 2228c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2238c2ecf20Sopenharmony_ci WT_PARM(wt,1), (int)val); 2248c2ecf20Sopenharmony_ci */ 2258c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 1), val); 2268c2ecf20Sopenharmony_ci return 0xc; 2278c2ecf20Sopenharmony_ci case 3: /* param 2 */ 2288c2ecf20Sopenharmony_ci /* 2298c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2308c2ecf20Sopenharmony_ci WT_PARM(wt,2), (int)val); 2318c2ecf20Sopenharmony_ci */ 2328c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 2), val); 2338c2ecf20Sopenharmony_ci return 0xc; 2348c2ecf20Sopenharmony_ci case 4: /* param 3 */ 2358c2ecf20Sopenharmony_ci /* 2368c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2378c2ecf20Sopenharmony_ci WT_PARM(wt,3), (int)val); 2388c2ecf20Sopenharmony_ci */ 2398c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 3), val); 2408c2ecf20Sopenharmony_ci return 0xc; 2418c2ecf20Sopenharmony_ci case 6: /* mute */ 2428c2ecf20Sopenharmony_ci /* 2438c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2448c2ecf20Sopenharmony_ci WT_MUTE(wt), (int)val); 2458c2ecf20Sopenharmony_ci */ 2468c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_MUTE(wt), val); 2478c2ecf20Sopenharmony_ci return 0xc; 2488c2ecf20Sopenharmony_ci case 0xb: 2498c2ecf20Sopenharmony_ci /* delay */ 2508c2ecf20Sopenharmony_ci /* 2518c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", 2528c2ecf20Sopenharmony_ci WT_DELAY(wt,0), (int)val); 2538c2ecf20Sopenharmony_ci */ 2548c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); 2558c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); 2568c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); 2578c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_DELAY(wt, 0), val); 2588c2ecf20Sopenharmony_ci return 0xc; 2598c2ecf20Sopenharmony_ci /* Global WT block parameters */ 2608c2ecf20Sopenharmony_ci case 5: /* sramp */ 2618c2ecf20Sopenharmony_ci ecx = WT_SRAMP(wt); 2628c2ecf20Sopenharmony_ci break; 2638c2ecf20Sopenharmony_ci case 8: /* aramp */ 2648c2ecf20Sopenharmony_ci ecx = WT_ARAMP(wt); 2658c2ecf20Sopenharmony_ci break; 2668c2ecf20Sopenharmony_ci case 9: /* mramp */ 2678c2ecf20Sopenharmony_ci ecx = WT_MRAMP(wt); 2688c2ecf20Sopenharmony_ci break; 2698c2ecf20Sopenharmony_ci case 0xa: /* ctrl */ 2708c2ecf20Sopenharmony_ci ecx = WT_CTRL(wt); 2718c2ecf20Sopenharmony_ci break; 2728c2ecf20Sopenharmony_ci case 0xc: /* ds_reg */ 2738c2ecf20Sopenharmony_ci ecx = WT_DSREG(wt); 2748c2ecf20Sopenharmony_ci break; 2758c2ecf20Sopenharmony_ci default: 2768c2ecf20Sopenharmony_ci return 0; 2778c2ecf20Sopenharmony_ci } 2788c2ecf20Sopenharmony_ci /* 2798c2ecf20Sopenharmony_ci pr_debug( "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val); 2808c2ecf20Sopenharmony_ci */ 2818c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, ecx, val); 2828c2ecf20Sopenharmony_ci return 1; 2838c2ecf20Sopenharmony_ci} 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cistatic void vortex_wt_init(vortex_t * vortex) 2868c2ecf20Sopenharmony_ci{ 2878c2ecf20Sopenharmony_ci u32 var4, var8, varc, var10 = 0, edi; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci var10 &= 0xFFFFFFE3; 2908c2ecf20Sopenharmony_ci var10 |= 0x22; 2918c2ecf20Sopenharmony_ci var10 &= 0xFFFFFEBF; 2928c2ecf20Sopenharmony_ci var10 |= 0x80; 2938c2ecf20Sopenharmony_ci var10 |= 0x200; 2948c2ecf20Sopenharmony_ci var10 &= 0xfffffffe; 2958c2ecf20Sopenharmony_ci var10 &= 0xfffffbff; 2968c2ecf20Sopenharmony_ci var10 |= 0x1800; 2978c2ecf20Sopenharmony_ci // var10 = 0x1AA2 2988c2ecf20Sopenharmony_ci var4 = 0x10000000; 2998c2ecf20Sopenharmony_ci varc = 0x00830000; 3008c2ecf20Sopenharmony_ci var8 = 0x00830000; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci /* Init Bank registers. */ 3038c2ecf20Sopenharmony_ci for (edi = 0; edi < (NR_WT / NR_WT_PB); edi++) { 3048c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0xc, edi, 0); /* ds_reg */ 3058c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0xa, edi, var10); /* ctrl */ 3068c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x9, edi, var4); /* mramp */ 3078c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x8, edi, varc); /* aramp */ 3088c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x5, edi, var8); /* sramp */ 3098c2ecf20Sopenharmony_ci } 3108c2ecf20Sopenharmony_ci /* Init Voice registers. */ 3118c2ecf20Sopenharmony_ci for (edi = 0; edi < NR_WT; edi++) { 3128c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x4, edi, 0); /* param 3 0x20c */ 3138c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x3, edi, 0); /* param 2 0x208 */ 3148c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x2, edi, 0); /* param 1 0x204 */ 3158c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0x1, edi, 0); /* param 0 0x200 */ 3168c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0xb, edi, 0); /* delay 0x400 - 0x40c */ 3178c2ecf20Sopenharmony_ci } 3188c2ecf20Sopenharmony_ci var10 |= 1; 3198c2ecf20Sopenharmony_ci for (edi = 0; edi < (NR_WT / NR_WT_PB); edi++) 3208c2ecf20Sopenharmony_ci vortex_wt_SetReg(vortex, 0xa, edi, var10); /* ctrl */ 3218c2ecf20Sopenharmony_ci} 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci/* Extract of CAdbTopology::SetVolume(struct _ASPVOLUME *) */ 3248c2ecf20Sopenharmony_ci#if 0 3258c2ecf20Sopenharmony_cistatic void vortex_wt_SetVolume(vortex_t * vortex, int wt, int vol[]) 3268c2ecf20Sopenharmony_ci{ 3278c2ecf20Sopenharmony_ci wt_voice_t *voice = &(vortex->wt_voice[wt]); 3288c2ecf20Sopenharmony_ci int ecx = vol[1], eax = vol[0]; 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci /* This is pure guess */ 3318c2ecf20Sopenharmony_ci voice->parm0 &= 0xff00ffff; 3328c2ecf20Sopenharmony_ci voice->parm0 |= (vol[0] & 0xff) << 0x10; 3338c2ecf20Sopenharmony_ci voice->parm1 &= 0xff00ffff; 3348c2ecf20Sopenharmony_ci voice->parm1 |= (vol[1] & 0xff) << 0x10; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci /* This is real */ 3378c2ecf20Sopenharmony_ci hwwrite(vortex, WT_PARM(wt, 0), voice->parm0); 3388c2ecf20Sopenharmony_ci hwwrite(vortex, WT_PARM(wt, 1), voice->parm0); 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci if (voice->this_1D0 & 4) { 3418c2ecf20Sopenharmony_ci eax >>= 8; 3428c2ecf20Sopenharmony_ci ecx = eax; 3438c2ecf20Sopenharmony_ci if (ecx < 0x80) 3448c2ecf20Sopenharmony_ci ecx = 0x7f; 3458c2ecf20Sopenharmony_ci voice->parm3 &= 0xFFFFC07F; 3468c2ecf20Sopenharmony_ci voice->parm3 |= (ecx & 0x7f) << 7; 3478c2ecf20Sopenharmony_ci voice->parm3 &= 0xFFFFFF80; 3488c2ecf20Sopenharmony_ci voice->parm3 |= (eax & 0x7f); 3498c2ecf20Sopenharmony_ci } else { 3508c2ecf20Sopenharmony_ci voice->parm3 &= 0xFFE03FFF; 3518c2ecf20Sopenharmony_ci voice->parm3 |= (eax & 0xFE00) << 5; 3528c2ecf20Sopenharmony_ci } 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci hwwrite(vortex, WT_PARM(wt, 3), voice->parm3); 3558c2ecf20Sopenharmony_ci} 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci/* Extract of CAdbTopology::SetFrequency(unsigned long arg_0) */ 3588c2ecf20Sopenharmony_cistatic void vortex_wt_SetFrequency(vortex_t * vortex, int wt, unsigned int sr) 3598c2ecf20Sopenharmony_ci{ 3608c2ecf20Sopenharmony_ci wt_voice_t *voice = &(vortex->wt_voice[wt]); 3618c2ecf20Sopenharmony_ci u32 eax, edx; 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci //FIXME: 64 bit operation. 3648c2ecf20Sopenharmony_ci eax = ((sr << 0xf) * 0x57619F1) & 0xffffffff; 3658c2ecf20Sopenharmony_ci edx = (((sr << 0xf) * 0x57619F1)) >> 0x20; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci edx >>= 0xa; 3688c2ecf20Sopenharmony_ci edx <<= 1; 3698c2ecf20Sopenharmony_ci if (edx) { 3708c2ecf20Sopenharmony_ci if (edx & 0x0FFF80000) 3718c2ecf20Sopenharmony_ci eax = 0x7fff; 3728c2ecf20Sopenharmony_ci else { 3738c2ecf20Sopenharmony_ci edx <<= 0xd; 3748c2ecf20Sopenharmony_ci eax = 7; 3758c2ecf20Sopenharmony_ci while ((edx & 0x80000000) == 0) { 3768c2ecf20Sopenharmony_ci edx <<= 1; 3778c2ecf20Sopenharmony_ci eax--; 3788c2ecf20Sopenharmony_ci if (eax == 0) 3798c2ecf20Sopenharmony_ci break; 3808c2ecf20Sopenharmony_ci } 3818c2ecf20Sopenharmony_ci if (eax) 3828c2ecf20Sopenharmony_ci edx <<= 1; 3838c2ecf20Sopenharmony_ci eax <<= 0xc; 3848c2ecf20Sopenharmony_ci edx >>= 0x14; 3858c2ecf20Sopenharmony_ci eax |= edx; 3868c2ecf20Sopenharmony_ci } 3878c2ecf20Sopenharmony_ci } else 3888c2ecf20Sopenharmony_ci eax = 0; 3898c2ecf20Sopenharmony_ci voice->parm0 &= 0xffff0001; 3908c2ecf20Sopenharmony_ci voice->parm0 |= (eax & 0x7fff) << 1; 3918c2ecf20Sopenharmony_ci voice->parm1 = voice->parm0 | 1; 3928c2ecf20Sopenharmony_ci // Wt: this_1D4 3938c2ecf20Sopenharmony_ci //AuWt::WriteReg((ulong)(this_1DC<<4)+0x200, (ulong)this_1E4); 3948c2ecf20Sopenharmony_ci //AuWt::WriteReg((ulong)(this_1DC<<4)+0x204, (ulong)this_1E8); 3958c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 0), voice->parm0); 3968c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, WT_PARM(wt, 1), voice->parm1); 3978c2ecf20Sopenharmony_ci} 3988c2ecf20Sopenharmony_ci#endif 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci/* End of File */ 401