18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/*************************************************************************** 38c2ecf20Sopenharmony_ci * au88x0_a3d.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Fri Jul 18 14:16:22 2003 68c2ecf20Sopenharmony_ci * Copyright 2003 mjander 78c2ecf20Sopenharmony_ci * mjander@users.sourceforge.net 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * A3D. You may think i'm crazy, but this may work someday. Who knows... 108c2ecf20Sopenharmony_ci ****************************************************************************/ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "au88x0_a3d.h" 168c2ecf20Sopenharmony_ci#include "au88x0_a3ddata.c" 178c2ecf20Sopenharmony_ci#include "au88x0_xtalk.h" 188c2ecf20Sopenharmony_ci#include "au88x0.h" 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic void 218c2ecf20Sopenharmony_cia3dsrc_SetTimeConsts(a3dsrc_t * a, short HrtfTrack, short ItdTrack, 228c2ecf20Sopenharmony_ci short GTrack, short CTrack) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 258c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 268c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_HrtfTrackTC), HrtfTrack); 278c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 288c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_ITDTrackTC), ItdTrack); 298c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 308c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_GainTrackTC), GTrack); 318c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 328c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_CoeffTrackTC), CTrack); 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#if 0 368c2ecf20Sopenharmony_cistatic void 378c2ecf20Sopenharmony_cia3dsrc_GetTimeConsts(a3dsrc_t * a, short *HrtfTrack, short *ItdTrack, 388c2ecf20Sopenharmony_ci short *GTrack, short *CTrack) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci // stub! 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#endif 448c2ecf20Sopenharmony_ci/* Atmospheric absorption. */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic void 478c2ecf20Sopenharmony_cia3dsrc_SetAtmosTarget(a3dsrc_t * a, short aa, short b, short c, short d, 488c2ecf20Sopenharmony_ci short e) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 518c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 528c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_A21Target), 538c2ecf20Sopenharmony_ci (e << 0x10) | d); 548c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 558c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_B10Target), 568c2ecf20Sopenharmony_ci (b << 0x10) | aa); 578c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 588c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_B2Target), c); 598c2ecf20Sopenharmony_ci} 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic void 628c2ecf20Sopenharmony_cia3dsrc_SetAtmosCurrent(a3dsrc_t * a, short aa, short b, short c, short d, 638c2ecf20Sopenharmony_ci short e) 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 668c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 678c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_A12Current), 688c2ecf20Sopenharmony_ci (e << 0x10) | d); 698c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 708c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_B01Current), 718c2ecf20Sopenharmony_ci (b << 0x10) | aa); 728c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 738c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_B2Current), c); 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic void 778c2ecf20Sopenharmony_cia3dsrc_SetAtmosState(a3dsrc_t * a, short x1, short x2, short y1, short y2) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 808c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_x1), x1); 818c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_x2), x2); 828c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_y1), y1); 838c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_y2), y2); 848c2ecf20Sopenharmony_ci} 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#if 0 878c2ecf20Sopenharmony_cistatic void 888c2ecf20Sopenharmony_cia3dsrc_GetAtmosTarget(a3dsrc_t * a, short *aa, short *b, short *c, 898c2ecf20Sopenharmony_ci short *d, short *e) 908c2ecf20Sopenharmony_ci{ 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_cistatic void 938c2ecf20Sopenharmony_cia3dsrc_GetAtmosCurrent(a3dsrc_t * a, short *bb01, short *ab01, short *b2, 948c2ecf20Sopenharmony_ci short *aa12, short *ba12) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 978c2ecf20Sopenharmony_ci *aa12 = 988c2ecf20Sopenharmony_ci hwread(vortex->mmio, 998c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_A12Current)); 1008c2ecf20Sopenharmony_ci *ba12 = 1018c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1028c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_A12Current)); 1038c2ecf20Sopenharmony_ci *ab01 = 1048c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1058c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_B01Current)); 1068c2ecf20Sopenharmony_ci *bb01 = 1078c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1088c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_B01Current)); 1098c2ecf20Sopenharmony_ci *b2 = 1108c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1118c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_B2Current)); 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistatic void 1158c2ecf20Sopenharmony_cia3dsrc_GetAtmosState(a3dsrc_t * a, short *x1, short *x2, short *y1, short *y2) 1168c2ecf20Sopenharmony_ci{ 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci} 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#endif 1218c2ecf20Sopenharmony_ci/* HRTF */ 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic void 1248c2ecf20Sopenharmony_cia3dsrc_SetHrtfTarget(a3dsrc_t * a, a3d_Hrtf_t const aa, a3d_Hrtf_t const b) 1258c2ecf20Sopenharmony_ci{ 1268c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 1278c2ecf20Sopenharmony_ci int i; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 1308c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 1318c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, 1328c2ecf20Sopenharmony_ci A3D_B_HrtfTarget) + (i << 2), 1338c2ecf20Sopenharmony_ci (b[i] << 0x10) | aa[i]); 1348c2ecf20Sopenharmony_ci} 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistatic void 1378c2ecf20Sopenharmony_cia3dsrc_SetHrtfCurrent(a3dsrc_t * a, a3d_Hrtf_t const aa, a3d_Hrtf_t const b) 1388c2ecf20Sopenharmony_ci{ 1398c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 1408c2ecf20Sopenharmony_ci int i; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 1438c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 1448c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, 1458c2ecf20Sopenharmony_ci A3D_B_HrtfCurrent) + (i << 2), 1468c2ecf20Sopenharmony_ci (b[i] << 0x10) | aa[i]); 1478c2ecf20Sopenharmony_ci} 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistatic void 1508c2ecf20Sopenharmony_cia3dsrc_SetHrtfState(a3dsrc_t * a, a3d_Hrtf_t const aa, a3d_Hrtf_t const b) 1518c2ecf20Sopenharmony_ci{ 1528c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 1538c2ecf20Sopenharmony_ci int i; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 1568c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 1578c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, 1588c2ecf20Sopenharmony_ci A3D_B_HrtfDelayLine) + (i << 2), 1598c2ecf20Sopenharmony_ci (b[i] << 0x10) | aa[i]); 1608c2ecf20Sopenharmony_ci} 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cistatic void a3dsrc_SetHrtfOutput(a3dsrc_t * a, short left, short right) 1638c2ecf20Sopenharmony_ci{ 1648c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 1658c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 1668c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_HrtfOutL), left); 1678c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 1688c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_HrtfOutR), right); 1698c2ecf20Sopenharmony_ci} 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci#if 0 1728c2ecf20Sopenharmony_cistatic void a3dsrc_GetHrtfTarget(a3dsrc_t * a, a3d_Hrtf_t aa, a3d_Hrtf_t b) 1738c2ecf20Sopenharmony_ci{ 1748c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 1758c2ecf20Sopenharmony_ci int i; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 1788c2ecf20Sopenharmony_ci aa[i] = 1798c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1808c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, 1818c2ecf20Sopenharmony_ci A3D_A_HrtfTarget + (i << 2))); 1828c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 1838c2ecf20Sopenharmony_ci b[i] = 1848c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1858c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, 1868c2ecf20Sopenharmony_ci A3D_B_HrtfTarget + (i << 2))); 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistatic void a3dsrc_GetHrtfCurrent(a3dsrc_t * a, a3d_Hrtf_t aa, a3d_Hrtf_t b) 1908c2ecf20Sopenharmony_ci{ 1918c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 1928c2ecf20Sopenharmony_ci int i; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 1958c2ecf20Sopenharmony_ci aa[i] = 1968c2ecf20Sopenharmony_ci hwread(vortex->mmio, 1978c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, 1988c2ecf20Sopenharmony_ci A3D_A_HrtfCurrent + (i << 2))); 1998c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 2008c2ecf20Sopenharmony_ci b[i] = 2018c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2028c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, 2038c2ecf20Sopenharmony_ci A3D_B_HrtfCurrent + (i << 2))); 2048c2ecf20Sopenharmony_ci} 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_cistatic void a3dsrc_GetHrtfState(a3dsrc_t * a, a3d_Hrtf_t aa, a3d_Hrtf_t b) 2078c2ecf20Sopenharmony_ci{ 2088c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 2098c2ecf20Sopenharmony_ci int i; 2108c2ecf20Sopenharmony_ci // FIXME: verify this! 2118c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 2128c2ecf20Sopenharmony_ci aa[i] = 2138c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2148c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, 2158c2ecf20Sopenharmony_ci A3D_A_HrtfDelayLine + (i << 2))); 2168c2ecf20Sopenharmony_ci for (i = 0; i < HRTF_SZ; i++) 2178c2ecf20Sopenharmony_ci b[i] = 2188c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2198c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, 2208c2ecf20Sopenharmony_ci A3D_B_HrtfDelayLine + (i << 2))); 2218c2ecf20Sopenharmony_ci} 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistatic void a3dsrc_GetHrtfOutput(a3dsrc_t * a, short *left, short *right) 2248c2ecf20Sopenharmony_ci{ 2258c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 2268c2ecf20Sopenharmony_ci *left = 2278c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2288c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_HrtfOutL)); 2298c2ecf20Sopenharmony_ci *right = 2308c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2318c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_HrtfOutR)); 2328c2ecf20Sopenharmony_ci} 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci#endif 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci/* Interaural Time Difference. 2378c2ecf20Sopenharmony_ci * "The other main clue that humans use to locate sounds, is called 2388c2ecf20Sopenharmony_ci * Interaural Time Difference (ITD). The differences in distance from 2398c2ecf20Sopenharmony_ci * the sound source to a listeners ears means that the sound will 2408c2ecf20Sopenharmony_ci * reach one ear slightly before the other....", found somewhere with google.*/ 2418c2ecf20Sopenharmony_cistatic void a3dsrc_SetItdTarget(a3dsrc_t * a, short litd, short ritd) 2428c2ecf20Sopenharmony_ci{ 2438c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci if (litd < 0) 2468c2ecf20Sopenharmony_ci litd = 0; 2478c2ecf20Sopenharmony_ci if (litd > 0x57FF) 2488c2ecf20Sopenharmony_ci litd = 0x57FF; 2498c2ecf20Sopenharmony_ci if (ritd < 0) 2508c2ecf20Sopenharmony_ci ritd = 0; 2518c2ecf20Sopenharmony_ci if (ritd > 0x57FF) 2528c2ecf20Sopenharmony_ci ritd = 0x57FF; 2538c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 2548c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_ITDTarget), 2558c2ecf20Sopenharmony_ci (ritd << 0x10) | litd); 2568c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, addr(0x191DF+5, this04, this08), (ritd<<0x10)|litd); 2578c2ecf20Sopenharmony_ci} 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistatic void a3dsrc_SetItdCurrent(a3dsrc_t * a, short litd, short ritd) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci if (litd < 0) 2648c2ecf20Sopenharmony_ci litd = 0; 2658c2ecf20Sopenharmony_ci if (litd > 0x57FF) 2668c2ecf20Sopenharmony_ci litd = 0x57FF; 2678c2ecf20Sopenharmony_ci if (ritd < 0) 2688c2ecf20Sopenharmony_ci ritd = 0; 2698c2ecf20Sopenharmony_ci if (ritd > 0x57FF) 2708c2ecf20Sopenharmony_ci ritd = 0x57FF; 2718c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 2728c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_ITDCurrent), 2738c2ecf20Sopenharmony_ci (ritd << 0x10) | litd); 2748c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, addr(0x191DF+1, this04, this08), (ritd<<0x10)|litd); 2758c2ecf20Sopenharmony_ci} 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cistatic void a3dsrc_SetItdDline(a3dsrc_t * a, a3d_ItdDline_t const dline) 2788c2ecf20Sopenharmony_ci{ 2798c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 2808c2ecf20Sopenharmony_ci int i; 2818c2ecf20Sopenharmony_ci /* 45 != 40 -> Check this ! */ 2828c2ecf20Sopenharmony_ci for (i = 0; i < DLINE_SZ; i++) 2838c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 2848c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, 2858c2ecf20Sopenharmony_ci A3D_A_ITDDelayLine) + (i << 2), dline[i]); 2868c2ecf20Sopenharmony_ci} 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci#if 0 2898c2ecf20Sopenharmony_cistatic void a3dsrc_GetItdTarget(a3dsrc_t * a, short *litd, short *ritd) 2908c2ecf20Sopenharmony_ci{ 2918c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 2928c2ecf20Sopenharmony_ci *ritd = 2938c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2948c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_ITDTarget)); 2958c2ecf20Sopenharmony_ci *litd = 2968c2ecf20Sopenharmony_ci hwread(vortex->mmio, 2978c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_ITDTarget)); 2988c2ecf20Sopenharmony_ci} 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_cistatic void a3dsrc_GetItdCurrent(a3dsrc_t * a, short *litd, short *ritd) 3018c2ecf20Sopenharmony_ci{ 3028c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci *ritd = 3058c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3068c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_ITDCurrent)); 3078c2ecf20Sopenharmony_ci *litd = 3088c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3098c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_ITDCurrent)); 3108c2ecf20Sopenharmony_ci} 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cistatic void a3dsrc_GetItdDline(a3dsrc_t * a, a3d_ItdDline_t dline) 3138c2ecf20Sopenharmony_ci{ 3148c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3158c2ecf20Sopenharmony_ci int i; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci for (i = 0; i < DLINE_SZ; i++) 3188c2ecf20Sopenharmony_ci dline[i] = 3198c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3208c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, 3218c2ecf20Sopenharmony_ci A3D_A_ITDDelayLine + (i << 2))); 3228c2ecf20Sopenharmony_ci} 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci#endif 3258c2ecf20Sopenharmony_ci/* This is may be used for ILD Interaural Level Difference. */ 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_cistatic void a3dsrc_SetGainTarget(a3dsrc_t * a, short left, short right) 3288c2ecf20Sopenharmony_ci{ 3298c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3308c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 3318c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_GainTarget), 3328c2ecf20Sopenharmony_ci (right << 0x10) | left); 3338c2ecf20Sopenharmony_ci} 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_cistatic void a3dsrc_SetGainCurrent(a3dsrc_t * a, short left, short right) 3368c2ecf20Sopenharmony_ci{ 3378c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3388c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 3398c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_GainCurrent), 3408c2ecf20Sopenharmony_ci (right << 0x10) | left); 3418c2ecf20Sopenharmony_ci} 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#if 0 3448c2ecf20Sopenharmony_cistatic void a3dsrc_GetGainTarget(a3dsrc_t * a, short *left, short *right) 3458c2ecf20Sopenharmony_ci{ 3468c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3478c2ecf20Sopenharmony_ci *right = 3488c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3498c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_GainTarget)); 3508c2ecf20Sopenharmony_ci *left = 3518c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3528c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_GainTarget)); 3538c2ecf20Sopenharmony_ci} 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_cistatic void a3dsrc_GetGainCurrent(a3dsrc_t * a, short *left, short *right) 3568c2ecf20Sopenharmony_ci{ 3578c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3588c2ecf20Sopenharmony_ci *right = 3598c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3608c2ecf20Sopenharmony_ci a3d_addrA(a->slice, a->source, A3D_A_GainCurrent)); 3618c2ecf20Sopenharmony_ci *left = 3628c2ecf20Sopenharmony_ci hwread(vortex->mmio, 3638c2ecf20Sopenharmony_ci a3d_addrB(a->slice, a->source, A3D_B_GainCurrent)); 3648c2ecf20Sopenharmony_ci} 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci/* CA3dIO this func seems to be inlined all over this place. */ 3678c2ecf20Sopenharmony_cistatic void CA3dIO_WriteReg(a3dsrc_t * a, unsigned long addr, short aa, short b) 3688c2ecf20Sopenharmony_ci{ 3698c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3708c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, addr, (aa << 0x10) | b); 3718c2ecf20Sopenharmony_ci} 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci#endif 3748c2ecf20Sopenharmony_ci/* Generic A3D stuff */ 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_cistatic void a3dsrc_SetA3DSampleRate(a3dsrc_t * a, int sr) 3778c2ecf20Sopenharmony_ci{ 3788c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3798c2ecf20Sopenharmony_ci int esp0 = 0; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci esp0 = (((esp0 & 0x7fffffff) | 0xB8000000) & 0x7) | ((sr & 0x1f) << 3); 3828c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd), esp0); 3838c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, 0x19C38 + (this08<<0xd), esp0); 3848c2ecf20Sopenharmony_ci} 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_cistatic void a3dsrc_EnableA3D(a3dsrc_t * a) 3878c2ecf20Sopenharmony_ci{ 3888c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3898c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd), 3908c2ecf20Sopenharmony_ci 0xF0000001); 3918c2ecf20Sopenharmony_ci //hwwrite(vortex->mmio, 0x19C38 + (this08<<0xd), 0xF0000001); 3928c2ecf20Sopenharmony_ci} 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_cistatic void a3dsrc_DisableA3D(a3dsrc_t * a) 3958c2ecf20Sopenharmony_ci{ 3968c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 3978c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd), 3988c2ecf20Sopenharmony_ci 0xF0000000); 3998c2ecf20Sopenharmony_ci} 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_cistatic void a3dsrc_SetA3DControlReg(a3dsrc_t * a, unsigned long ctrl) 4028c2ecf20Sopenharmony_ci{ 4038c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 4048c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd), ctrl); 4058c2ecf20Sopenharmony_ci} 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_cistatic void a3dsrc_SetA3DPointerReg(a3dsrc_t * a, unsigned long ptr) 4088c2ecf20Sopenharmony_ci{ 4098c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 4108c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, A3D_SLICE_Pointers + ((a->slice) << 0xd), ptr); 4118c2ecf20Sopenharmony_ci} 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci#if 0 4148c2ecf20Sopenharmony_cistatic void a3dsrc_GetA3DSampleRate(a3dsrc_t * a, int *sr) 4158c2ecf20Sopenharmony_ci{ 4168c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 4178c2ecf20Sopenharmony_ci *sr = ((hwread(vortex->mmio, A3D_SLICE_Control + (a->slice << 0xd)) 4188c2ecf20Sopenharmony_ci >> 3) & 0x1f); 4198c2ecf20Sopenharmony_ci //*sr = ((hwread(vortex->mmio, 0x19C38 + (this08<<0xd))>>3)&0x1f); 4208c2ecf20Sopenharmony_ci} 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_cistatic void a3dsrc_GetA3DControlReg(a3dsrc_t * a, unsigned long *ctrl) 4238c2ecf20Sopenharmony_ci{ 4248c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 4258c2ecf20Sopenharmony_ci *ctrl = hwread(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd)); 4268c2ecf20Sopenharmony_ci} 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_cistatic void a3dsrc_GetA3DPointerReg(a3dsrc_t * a, unsigned long *ptr) 4298c2ecf20Sopenharmony_ci{ 4308c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 4318c2ecf20Sopenharmony_ci *ptr = hwread(vortex->mmio, A3D_SLICE_Pointers + ((a->slice) << 0xd)); 4328c2ecf20Sopenharmony_ci} 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci#endif 4358c2ecf20Sopenharmony_cistatic void a3dsrc_ZeroSliceIO(a3dsrc_t * a) 4368c2ecf20Sopenharmony_ci{ 4378c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 4388c2ecf20Sopenharmony_ci int i; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci for (i = 0; i < 8; i++) 4418c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 4428c2ecf20Sopenharmony_ci A3D_SLICE_VDBDest + 4438c2ecf20Sopenharmony_ci ((((a->slice) << 0xb) + i) << 2), 0); 4448c2ecf20Sopenharmony_ci for (i = 0; i < 4; i++) 4458c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 4468c2ecf20Sopenharmony_ci A3D_SLICE_VDBSource + 4478c2ecf20Sopenharmony_ci ((((a->slice) << 0xb) + i) << 2), 0); 4488c2ecf20Sopenharmony_ci} 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci/* Reset Single A3D source. */ 4518c2ecf20Sopenharmony_cistatic void a3dsrc_ZeroState(a3dsrc_t * a) 4528c2ecf20Sopenharmony_ci{ 4538c2ecf20Sopenharmony_ci /* 4548c2ecf20Sopenharmony_ci pr_debug( "vortex: ZeroState slice: %d, source %d\n", 4558c2ecf20Sopenharmony_ci a->slice, a->source); 4568c2ecf20Sopenharmony_ci */ 4578c2ecf20Sopenharmony_ci a3dsrc_SetAtmosState(a, 0, 0, 0, 0); 4588c2ecf20Sopenharmony_ci a3dsrc_SetHrtfState(a, A3dHrirZeros, A3dHrirZeros); 4598c2ecf20Sopenharmony_ci a3dsrc_SetItdDline(a, A3dItdDlineZeros); 4608c2ecf20Sopenharmony_ci a3dsrc_SetHrtfOutput(a, 0, 0); 4618c2ecf20Sopenharmony_ci a3dsrc_SetTimeConsts(a, 0, 0, 0, 0); 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci a3dsrc_SetAtmosCurrent(a, 0, 0, 0, 0, 0); 4648c2ecf20Sopenharmony_ci a3dsrc_SetAtmosTarget(a, 0, 0, 0, 0, 0); 4658c2ecf20Sopenharmony_ci a3dsrc_SetItdCurrent(a, 0, 0); 4668c2ecf20Sopenharmony_ci a3dsrc_SetItdTarget(a, 0, 0); 4678c2ecf20Sopenharmony_ci a3dsrc_SetGainCurrent(a, 0, 0); 4688c2ecf20Sopenharmony_ci a3dsrc_SetGainTarget(a, 0, 0); 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci a3dsrc_SetHrtfCurrent(a, A3dHrirZeros, A3dHrirZeros); 4718c2ecf20Sopenharmony_ci a3dsrc_SetHrtfTarget(a, A3dHrirZeros, A3dHrirZeros); 4728c2ecf20Sopenharmony_ci} 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci/* Reset entire A3D engine */ 4758c2ecf20Sopenharmony_cistatic void a3dsrc_ZeroStateA3D(a3dsrc_t *a, vortex_t *v) 4768c2ecf20Sopenharmony_ci{ 4778c2ecf20Sopenharmony_ci int i, var, var2; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci if ((a->vortex) == NULL) { 4808c2ecf20Sopenharmony_ci dev_err(v->card->dev, 4818c2ecf20Sopenharmony_ci "ZeroStateA3D: ERROR: a->vortex is NULL\n"); 4828c2ecf20Sopenharmony_ci return; 4838c2ecf20Sopenharmony_ci } 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci a3dsrc_SetA3DControlReg(a, 0); 4868c2ecf20Sopenharmony_ci a3dsrc_SetA3DPointerReg(a, 0); 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci var = a->slice; 4898c2ecf20Sopenharmony_ci var2 = a->source; 4908c2ecf20Sopenharmony_ci for (i = 0; i < 4; i++) { 4918c2ecf20Sopenharmony_ci a->slice = i; 4928c2ecf20Sopenharmony_ci a3dsrc_ZeroSliceIO(a); 4938c2ecf20Sopenharmony_ci //a3dsrc_ZeroState(a); 4948c2ecf20Sopenharmony_ci } 4958c2ecf20Sopenharmony_ci a->source = var2; 4968c2ecf20Sopenharmony_ci a->slice = var; 4978c2ecf20Sopenharmony_ci} 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci/* Program A3D block as pass through */ 5008c2ecf20Sopenharmony_cistatic void a3dsrc_ProgramPipe(a3dsrc_t * a) 5018c2ecf20Sopenharmony_ci{ 5028c2ecf20Sopenharmony_ci a3dsrc_SetTimeConsts(a, 0, 0, 0, 0); 5038c2ecf20Sopenharmony_ci a3dsrc_SetAtmosCurrent(a, 0, 0x4000, 0, 0, 0); 5048c2ecf20Sopenharmony_ci a3dsrc_SetAtmosTarget(a, 0x4000, 0, 0, 0, 0); 5058c2ecf20Sopenharmony_ci a3dsrc_SetItdCurrent(a, 0, 0); 5068c2ecf20Sopenharmony_ci a3dsrc_SetItdTarget(a, 0, 0); 5078c2ecf20Sopenharmony_ci a3dsrc_SetGainCurrent(a, 0x7fff, 0x7fff); 5088c2ecf20Sopenharmony_ci a3dsrc_SetGainTarget(a, 0x7fff, 0x7fff); 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci /* SET HRTF HERE */ 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci /* Single spike leads to identity transfer function. */ 5138c2ecf20Sopenharmony_ci a3dsrc_SetHrtfCurrent(a, A3dHrirImpulse, A3dHrirImpulse); 5148c2ecf20Sopenharmony_ci a3dsrc_SetHrtfTarget(a, A3dHrirImpulse, A3dHrirImpulse); 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci /* Test: Sounds saturated. */ 5178c2ecf20Sopenharmony_ci //a3dsrc_SetHrtfCurrent(a, A3dHrirSatTest, A3dHrirSatTest); 5188c2ecf20Sopenharmony_ci //a3dsrc_SetHrtfTarget(a, A3dHrirSatTest, A3dHrirSatTest); 5198c2ecf20Sopenharmony_ci} 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci/* VDB = Vortex audio Dataflow Bus */ 5228c2ecf20Sopenharmony_ci#if 0 5238c2ecf20Sopenharmony_cistatic void a3dsrc_ClearVDBData(a3dsrc_t * a, unsigned long aa) 5248c2ecf20Sopenharmony_ci{ 5258c2ecf20Sopenharmony_ci vortex_t *vortex = (vortex_t *) (a->vortex); 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci // ((aa >> 2) << 8) - (aa >> 2) 5288c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 5298c2ecf20Sopenharmony_ci a3d_addrS(a->slice, A3D_SLICE_VDBDest) + (a->source << 2), 0); 5308c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 5318c2ecf20Sopenharmony_ci a3d_addrS(a->slice, 5328c2ecf20Sopenharmony_ci A3D_SLICE_VDBDest + 4) + (a->source << 2), 0); 5338c2ecf20Sopenharmony_ci /* 5348c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 0x19c00 + (((aa>>2)*255*4)+aa)*8, 0); 5358c2ecf20Sopenharmony_ci hwwrite(vortex->mmio, 0x19c04 + (((aa>>2)*255*4)+aa)*8, 0); 5368c2ecf20Sopenharmony_ci */ 5378c2ecf20Sopenharmony_ci} 5388c2ecf20Sopenharmony_ci#endif 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci/* A3D HwSource stuff. */ 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_cistatic void vortex_A3dSourceHw_Initialize(vortex_t * v, int source, int slice) 5438c2ecf20Sopenharmony_ci{ 5448c2ecf20Sopenharmony_ci a3dsrc_t *a3dsrc = &(v->a3d[source + (slice * 4)]); 5458c2ecf20Sopenharmony_ci //a3dsrc_t *a3dsrc = &(v->a3d[source + (slice*4)]); 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci a3dsrc->vortex = (void *)v; 5488c2ecf20Sopenharmony_ci a3dsrc->source = source; /* source */ 5498c2ecf20Sopenharmony_ci a3dsrc->slice = slice; /* slice */ 5508c2ecf20Sopenharmony_ci a3dsrc_ZeroState(a3dsrc); 5518c2ecf20Sopenharmony_ci /* Added by me. */ 5528c2ecf20Sopenharmony_ci a3dsrc_SetA3DSampleRate(a3dsrc, 0x11); 5538c2ecf20Sopenharmony_ci} 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cistatic int Vort3DRend_Initialize(vortex_t * v, unsigned short mode) 5568c2ecf20Sopenharmony_ci{ 5578c2ecf20Sopenharmony_ci v->xt_mode = mode; /* this_14 */ 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci vortex_XtalkHw_init(v); 5608c2ecf20Sopenharmony_ci vortex_XtalkHw_SetGainsAllChan(v); 5618c2ecf20Sopenharmony_ci switch (v->xt_mode) { 5628c2ecf20Sopenharmony_ci case XT_SPEAKER0: 5638c2ecf20Sopenharmony_ci vortex_XtalkHw_ProgramXtalkNarrow(v); 5648c2ecf20Sopenharmony_ci break; 5658c2ecf20Sopenharmony_ci case XT_SPEAKER1: 5668c2ecf20Sopenharmony_ci vortex_XtalkHw_ProgramXtalkWide(v); 5678c2ecf20Sopenharmony_ci break; 5688c2ecf20Sopenharmony_ci default: 5698c2ecf20Sopenharmony_ci case XT_HEADPHONE: 5708c2ecf20Sopenharmony_ci vortex_XtalkHw_ProgramPipe(v); 5718c2ecf20Sopenharmony_ci break; 5728c2ecf20Sopenharmony_ci case XT_DIAMOND: 5738c2ecf20Sopenharmony_ci vortex_XtalkHw_ProgramDiamondXtalk(v); 5748c2ecf20Sopenharmony_ci break; 5758c2ecf20Sopenharmony_ci } 5768c2ecf20Sopenharmony_ci vortex_XtalkHw_SetSampleRate(v, 0x11); 5778c2ecf20Sopenharmony_ci vortex_XtalkHw_Enable(v); 5788c2ecf20Sopenharmony_ci return 0; 5798c2ecf20Sopenharmony_ci} 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci/* 3D Sound entry points. */ 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_cistatic int vortex_a3d_register_controls(vortex_t * vortex); 5848c2ecf20Sopenharmony_cistatic void vortex_a3d_unregister_controls(vortex_t * vortex); 5858c2ecf20Sopenharmony_ci/* A3D base support init/shudown */ 5868c2ecf20Sopenharmony_cistatic void vortex_Vort3D_enable(vortex_t *v) 5878c2ecf20Sopenharmony_ci{ 5888c2ecf20Sopenharmony_ci int i; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci Vort3DRend_Initialize(v, XT_HEADPHONE); 5918c2ecf20Sopenharmony_ci for (i = 0; i < NR_A3D; i++) { 5928c2ecf20Sopenharmony_ci vortex_A3dSourceHw_Initialize(v, i % 4, i >> 2); 5938c2ecf20Sopenharmony_ci a3dsrc_ZeroStateA3D(&v->a3d[0], v); 5948c2ecf20Sopenharmony_ci } 5958c2ecf20Sopenharmony_ci /* Register ALSA controls */ 5968c2ecf20Sopenharmony_ci vortex_a3d_register_controls(v); 5978c2ecf20Sopenharmony_ci} 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_cistatic void vortex_Vort3D_disable(vortex_t * v) 6008c2ecf20Sopenharmony_ci{ 6018c2ecf20Sopenharmony_ci vortex_XtalkHw_Disable(v); 6028c2ecf20Sopenharmony_ci vortex_a3d_unregister_controls(v); 6038c2ecf20Sopenharmony_ci} 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci/* Make A3D subsystem connections. */ 6068c2ecf20Sopenharmony_cistatic void vortex_Vort3D_connect(vortex_t * v, int en) 6078c2ecf20Sopenharmony_ci{ 6088c2ecf20Sopenharmony_ci int i; 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci// Disable AU8810 routes, since they seem to be wrong (in au8810.h). 6118c2ecf20Sopenharmony_ci#ifdef CHIP_AU8810 6128c2ecf20Sopenharmony_ci return; 6138c2ecf20Sopenharmony_ci#endif 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci#if 1 6168c2ecf20Sopenharmony_ci /* Alloc Xtalk mixin resources */ 6178c2ecf20Sopenharmony_ci v->mixxtlk[0] = 6188c2ecf20Sopenharmony_ci vortex_adb_checkinout(v, v->fixed_res, en, VORTEX_RESOURCE_MIXIN); 6198c2ecf20Sopenharmony_ci if (v->mixxtlk[0] < 0) { 6208c2ecf20Sopenharmony_ci dev_warn(v->card->dev, 6218c2ecf20Sopenharmony_ci "vortex_Vort3D: ERROR: not enough free mixer resources.\n"); 6228c2ecf20Sopenharmony_ci return; 6238c2ecf20Sopenharmony_ci } 6248c2ecf20Sopenharmony_ci v->mixxtlk[1] = 6258c2ecf20Sopenharmony_ci vortex_adb_checkinout(v, v->fixed_res, en, VORTEX_RESOURCE_MIXIN); 6268c2ecf20Sopenharmony_ci if (v->mixxtlk[1] < 0) { 6278c2ecf20Sopenharmony_ci dev_warn(v->card->dev, 6288c2ecf20Sopenharmony_ci "vortex_Vort3D: ERROR: not enough free mixer resources.\n"); 6298c2ecf20Sopenharmony_ci return; 6308c2ecf20Sopenharmony_ci } 6318c2ecf20Sopenharmony_ci#endif 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci /* Connect A3D -> XTALK */ 6348c2ecf20Sopenharmony_ci for (i = 0; i < 4; i++) { 6358c2ecf20Sopenharmony_ci // 2 outputs per each A3D slice. 6368c2ecf20Sopenharmony_ci vortex_route(v, en, 0x11, ADB_A3DOUT(i * 2), ADB_XTALKIN(i)); 6378c2ecf20Sopenharmony_ci vortex_route(v, en, 0x11, ADB_A3DOUT(i * 2) + 1, ADB_XTALKIN(5 + i)); 6388c2ecf20Sopenharmony_ci } 6398c2ecf20Sopenharmony_ci#if 0 6408c2ecf20Sopenharmony_ci vortex_route(v, en, 0x11, ADB_XTALKOUT(0), ADB_EQIN(2)); 6418c2ecf20Sopenharmony_ci vortex_route(v, en, 0x11, ADB_XTALKOUT(1), ADB_EQIN(3)); 6428c2ecf20Sopenharmony_ci#else 6438c2ecf20Sopenharmony_ci /* Connect XTalk -> mixer */ 6448c2ecf20Sopenharmony_ci vortex_route(v, en, 0x11, ADB_XTALKOUT(0), ADB_MIXIN(v->mixxtlk[0])); 6458c2ecf20Sopenharmony_ci vortex_route(v, en, 0x11, ADB_XTALKOUT(1), ADB_MIXIN(v->mixxtlk[1])); 6468c2ecf20Sopenharmony_ci vortex_connection_mixin_mix(v, en, v->mixxtlk[0], v->mixplayb[0], 0); 6478c2ecf20Sopenharmony_ci vortex_connection_mixin_mix(v, en, v->mixxtlk[1], v->mixplayb[1], 0); 6488c2ecf20Sopenharmony_ci vortex_mix_setinputvolumebyte(v, v->mixplayb[0], v->mixxtlk[0], 6498c2ecf20Sopenharmony_ci en ? MIX_DEFIGAIN : VOL_MIN); 6508c2ecf20Sopenharmony_ci vortex_mix_setinputvolumebyte(v, v->mixplayb[1], v->mixxtlk[1], 6518c2ecf20Sopenharmony_ci en ? MIX_DEFIGAIN : VOL_MIN); 6528c2ecf20Sopenharmony_ci if (VORTEX_IS_QUAD(v)) { 6538c2ecf20Sopenharmony_ci vortex_connection_mixin_mix(v, en, v->mixxtlk[0], 6548c2ecf20Sopenharmony_ci v->mixplayb[2], 0); 6558c2ecf20Sopenharmony_ci vortex_connection_mixin_mix(v, en, v->mixxtlk[1], 6568c2ecf20Sopenharmony_ci v->mixplayb[3], 0); 6578c2ecf20Sopenharmony_ci vortex_mix_setinputvolumebyte(v, v->mixplayb[2], 6588c2ecf20Sopenharmony_ci v->mixxtlk[0], 6598c2ecf20Sopenharmony_ci en ? MIX_DEFIGAIN : VOL_MIN); 6608c2ecf20Sopenharmony_ci vortex_mix_setinputvolumebyte(v, v->mixplayb[3], 6618c2ecf20Sopenharmony_ci v->mixxtlk[1], 6628c2ecf20Sopenharmony_ci en ? MIX_DEFIGAIN : VOL_MIN); 6638c2ecf20Sopenharmony_ci } 6648c2ecf20Sopenharmony_ci#endif 6658c2ecf20Sopenharmony_ci} 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci/* Initialize one single A3D source. */ 6688c2ecf20Sopenharmony_cistatic void vortex_Vort3D_InitializeSource(a3dsrc_t *a, int en, vortex_t *v) 6698c2ecf20Sopenharmony_ci{ 6708c2ecf20Sopenharmony_ci if (a->vortex == NULL) { 6718c2ecf20Sopenharmony_ci dev_warn(v->card->dev, 6728c2ecf20Sopenharmony_ci "Vort3D_InitializeSource: A3D source not initialized\n"); 6738c2ecf20Sopenharmony_ci return; 6748c2ecf20Sopenharmony_ci } 6758c2ecf20Sopenharmony_ci if (en) { 6768c2ecf20Sopenharmony_ci a3dsrc_ProgramPipe(a); 6778c2ecf20Sopenharmony_ci a3dsrc_SetA3DSampleRate(a, 0x11); 6788c2ecf20Sopenharmony_ci a3dsrc_SetTimeConsts(a, HrtfTCDefault, 6798c2ecf20Sopenharmony_ci ItdTCDefault, GainTCDefault, 6808c2ecf20Sopenharmony_ci CoefTCDefault); 6818c2ecf20Sopenharmony_ci /* Remark: zero gain is muted. */ 6828c2ecf20Sopenharmony_ci //a3dsrc_SetGainTarget(a,0,0); 6838c2ecf20Sopenharmony_ci //a3dsrc_SetGainCurrent(a,0,0); 6848c2ecf20Sopenharmony_ci a3dsrc_EnableA3D(a); 6858c2ecf20Sopenharmony_ci } else { 6868c2ecf20Sopenharmony_ci a3dsrc_DisableA3D(a); 6878c2ecf20Sopenharmony_ci a3dsrc_ZeroState(a); 6888c2ecf20Sopenharmony_ci } 6898c2ecf20Sopenharmony_ci} 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci/* Conversion of coordinates into 3D parameters. */ 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_cistatic void vortex_a3d_coord2hrtf(a3d_Hrtf_t hrtf, int *coord) 6948c2ecf20Sopenharmony_ci{ 6958c2ecf20Sopenharmony_ci /* FIXME: implement this. */ 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci} 6988c2ecf20Sopenharmony_cistatic void vortex_a3d_coord2itd(a3d_Itd_t itd, int *coord) 6998c2ecf20Sopenharmony_ci{ 7008c2ecf20Sopenharmony_ci /* FIXME: implement this. */ 7018c2ecf20Sopenharmony_ci 7028c2ecf20Sopenharmony_ci} 7038c2ecf20Sopenharmony_cistatic void vortex_a3d_coord2ild(a3d_LRGains_t ild, int left, int right) 7048c2ecf20Sopenharmony_ci{ 7058c2ecf20Sopenharmony_ci /* FIXME: implement this. */ 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci} 7088c2ecf20Sopenharmony_cistatic void vortex_a3d_translate_filter(a3d_atmos_t filter, int *params) 7098c2ecf20Sopenharmony_ci{ 7108c2ecf20Sopenharmony_ci /* FIXME: implement this. */ 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci} 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci/* ALSA control interface. */ 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_cistatic int 7178c2ecf20Sopenharmony_cisnd_vortex_a3d_hrtf_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 7188c2ecf20Sopenharmony_ci{ 7198c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 7208c2ecf20Sopenharmony_ci uinfo->count = 6; 7218c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0x00000000; 7228c2ecf20Sopenharmony_ci uinfo->value.integer.max = 0xffffffff; 7238c2ecf20Sopenharmony_ci return 0; 7248c2ecf20Sopenharmony_ci} 7258c2ecf20Sopenharmony_cistatic int 7268c2ecf20Sopenharmony_cisnd_vortex_a3d_itd_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 7278c2ecf20Sopenharmony_ci{ 7288c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 7298c2ecf20Sopenharmony_ci uinfo->count = 2; 7308c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0x00000000; 7318c2ecf20Sopenharmony_ci uinfo->value.integer.max = 0xffffffff; 7328c2ecf20Sopenharmony_ci return 0; 7338c2ecf20Sopenharmony_ci} 7348c2ecf20Sopenharmony_cistatic int 7358c2ecf20Sopenharmony_cisnd_vortex_a3d_ild_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 7368c2ecf20Sopenharmony_ci{ 7378c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 7388c2ecf20Sopenharmony_ci uinfo->count = 2; 7398c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0x00000000; 7408c2ecf20Sopenharmony_ci uinfo->value.integer.max = 0xffffffff; 7418c2ecf20Sopenharmony_ci return 0; 7428c2ecf20Sopenharmony_ci} 7438c2ecf20Sopenharmony_cistatic int 7448c2ecf20Sopenharmony_cisnd_vortex_a3d_filter_info(struct snd_kcontrol *kcontrol, 7458c2ecf20Sopenharmony_ci struct snd_ctl_elem_info *uinfo) 7468c2ecf20Sopenharmony_ci{ 7478c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 7488c2ecf20Sopenharmony_ci uinfo->count = 4; 7498c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0x00000000; 7508c2ecf20Sopenharmony_ci uinfo->value.integer.max = 0xffffffff; 7518c2ecf20Sopenharmony_ci return 0; 7528c2ecf20Sopenharmony_ci} 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_cistatic int 7558c2ecf20Sopenharmony_cisnd_vortex_a3d_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 7568c2ecf20Sopenharmony_ci{ 7578c2ecf20Sopenharmony_ci //a3dsrc_t *a = kcontrol->private_data; 7588c2ecf20Sopenharmony_ci /* No read yet. Would this be really useable/needed ? */ 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci return 0; 7618c2ecf20Sopenharmony_ci} 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_cistatic int 7648c2ecf20Sopenharmony_cisnd_vortex_a3d_hrtf_put(struct snd_kcontrol *kcontrol, 7658c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 7668c2ecf20Sopenharmony_ci{ 7678c2ecf20Sopenharmony_ci a3dsrc_t *a = kcontrol->private_data; 7688c2ecf20Sopenharmony_ci int i; 7698c2ecf20Sopenharmony_ci int coord[6]; 7708c2ecf20Sopenharmony_ci for (i = 0; i < 6; i++) 7718c2ecf20Sopenharmony_ci coord[i] = ucontrol->value.integer.value[i]; 7728c2ecf20Sopenharmony_ci /* Translate orientation coordinates to a3d params. */ 7738c2ecf20Sopenharmony_ci vortex_a3d_coord2hrtf(a->hrtf[0], coord); 7748c2ecf20Sopenharmony_ci vortex_a3d_coord2hrtf(a->hrtf[1], coord); 7758c2ecf20Sopenharmony_ci a3dsrc_SetHrtfTarget(a, a->hrtf[0], a->hrtf[1]); 7768c2ecf20Sopenharmony_ci a3dsrc_SetHrtfCurrent(a, a->hrtf[0], a->hrtf[1]); 7778c2ecf20Sopenharmony_ci return 1; 7788c2ecf20Sopenharmony_ci} 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_cistatic int 7818c2ecf20Sopenharmony_cisnd_vortex_a3d_itd_put(struct snd_kcontrol *kcontrol, 7828c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 7838c2ecf20Sopenharmony_ci{ 7848c2ecf20Sopenharmony_ci a3dsrc_t *a = kcontrol->private_data; 7858c2ecf20Sopenharmony_ci int coord[6]; 7868c2ecf20Sopenharmony_ci int i; 7878c2ecf20Sopenharmony_ci for (i = 0; i < 6; i++) 7888c2ecf20Sopenharmony_ci coord[i] = ucontrol->value.integer.value[i]; 7898c2ecf20Sopenharmony_ci /* Translate orientation coordinates to a3d params. */ 7908c2ecf20Sopenharmony_ci vortex_a3d_coord2itd(a->hrtf[0], coord); 7918c2ecf20Sopenharmony_ci vortex_a3d_coord2itd(a->hrtf[1], coord); 7928c2ecf20Sopenharmony_ci /* Inter aural time difference. */ 7938c2ecf20Sopenharmony_ci a3dsrc_SetItdTarget(a, a->itd[0], a->itd[1]); 7948c2ecf20Sopenharmony_ci a3dsrc_SetItdCurrent(a, a->itd[0], a->itd[1]); 7958c2ecf20Sopenharmony_ci a3dsrc_SetItdDline(a, a->dline); 7968c2ecf20Sopenharmony_ci return 1; 7978c2ecf20Sopenharmony_ci} 7988c2ecf20Sopenharmony_ci 7998c2ecf20Sopenharmony_cistatic int 8008c2ecf20Sopenharmony_cisnd_vortex_a3d_ild_put(struct snd_kcontrol *kcontrol, 8018c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 8028c2ecf20Sopenharmony_ci{ 8038c2ecf20Sopenharmony_ci a3dsrc_t *a = kcontrol->private_data; 8048c2ecf20Sopenharmony_ci int l, r; 8058c2ecf20Sopenharmony_ci /* There may be some scale tranlation needed here. */ 8068c2ecf20Sopenharmony_ci l = ucontrol->value.integer.value[0]; 8078c2ecf20Sopenharmony_ci r = ucontrol->value.integer.value[1]; 8088c2ecf20Sopenharmony_ci vortex_a3d_coord2ild(a->ild, l, r); 8098c2ecf20Sopenharmony_ci /* Left Right panning. */ 8108c2ecf20Sopenharmony_ci a3dsrc_SetGainTarget(a, l, r); 8118c2ecf20Sopenharmony_ci a3dsrc_SetGainCurrent(a, l, r); 8128c2ecf20Sopenharmony_ci return 1; 8138c2ecf20Sopenharmony_ci} 8148c2ecf20Sopenharmony_ci 8158c2ecf20Sopenharmony_cistatic int 8168c2ecf20Sopenharmony_cisnd_vortex_a3d_filter_put(struct snd_kcontrol *kcontrol, 8178c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 8188c2ecf20Sopenharmony_ci{ 8198c2ecf20Sopenharmony_ci a3dsrc_t *a = kcontrol->private_data; 8208c2ecf20Sopenharmony_ci int i; 8218c2ecf20Sopenharmony_ci int params[6]; 8228c2ecf20Sopenharmony_ci for (i = 0; i < 6; i++) 8238c2ecf20Sopenharmony_ci params[i] = ucontrol->value.integer.value[i]; 8248c2ecf20Sopenharmony_ci /* Translate generic filter params to a3d filter params. */ 8258c2ecf20Sopenharmony_ci vortex_a3d_translate_filter(a->filter, params); 8268c2ecf20Sopenharmony_ci /* Atmospheric absorption and filtering. */ 8278c2ecf20Sopenharmony_ci a3dsrc_SetAtmosTarget(a, a->filter[0], 8288c2ecf20Sopenharmony_ci a->filter[1], a->filter[2], 8298c2ecf20Sopenharmony_ci a->filter[3], a->filter[4]); 8308c2ecf20Sopenharmony_ci a3dsrc_SetAtmosCurrent(a, a->filter[0], 8318c2ecf20Sopenharmony_ci a->filter[1], a->filter[2], 8328c2ecf20Sopenharmony_ci a->filter[3], a->filter[4]); 8338c2ecf20Sopenharmony_ci return 1; 8348c2ecf20Sopenharmony_ci} 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new vortex_a3d_kcontrol = { 8378c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_PCM, 8388c2ecf20Sopenharmony_ci .name = "Playback PCM advanced processing", 8398c2ecf20Sopenharmony_ci .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 8408c2ecf20Sopenharmony_ci .info = snd_vortex_a3d_hrtf_info, 8418c2ecf20Sopenharmony_ci .get = snd_vortex_a3d_get, 8428c2ecf20Sopenharmony_ci .put = snd_vortex_a3d_hrtf_put, 8438c2ecf20Sopenharmony_ci}; 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci/* Control (un)registration. */ 8468c2ecf20Sopenharmony_cistatic int vortex_a3d_register_controls(vortex_t *vortex) 8478c2ecf20Sopenharmony_ci{ 8488c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol; 8498c2ecf20Sopenharmony_ci int err, i; 8508c2ecf20Sopenharmony_ci /* HRTF controls. */ 8518c2ecf20Sopenharmony_ci for (i = 0; i < NR_A3D; i++) { 8528c2ecf20Sopenharmony_ci if ((kcontrol = 8538c2ecf20Sopenharmony_ci snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL) 8548c2ecf20Sopenharmony_ci return -ENOMEM; 8558c2ecf20Sopenharmony_ci kcontrol->id.numid = CTRLID_HRTF; 8568c2ecf20Sopenharmony_ci kcontrol->info = snd_vortex_a3d_hrtf_info; 8578c2ecf20Sopenharmony_ci kcontrol->put = snd_vortex_a3d_hrtf_put; 8588c2ecf20Sopenharmony_ci if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0) 8598c2ecf20Sopenharmony_ci return err; 8608c2ecf20Sopenharmony_ci } 8618c2ecf20Sopenharmony_ci /* ITD controls. */ 8628c2ecf20Sopenharmony_ci for (i = 0; i < NR_A3D; i++) { 8638c2ecf20Sopenharmony_ci if ((kcontrol = 8648c2ecf20Sopenharmony_ci snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL) 8658c2ecf20Sopenharmony_ci return -ENOMEM; 8668c2ecf20Sopenharmony_ci kcontrol->id.numid = CTRLID_ITD; 8678c2ecf20Sopenharmony_ci kcontrol->info = snd_vortex_a3d_itd_info; 8688c2ecf20Sopenharmony_ci kcontrol->put = snd_vortex_a3d_itd_put; 8698c2ecf20Sopenharmony_ci if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0) 8708c2ecf20Sopenharmony_ci return err; 8718c2ecf20Sopenharmony_ci } 8728c2ecf20Sopenharmony_ci /* ILD (gains) controls. */ 8738c2ecf20Sopenharmony_ci for (i = 0; i < NR_A3D; i++) { 8748c2ecf20Sopenharmony_ci if ((kcontrol = 8758c2ecf20Sopenharmony_ci snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL) 8768c2ecf20Sopenharmony_ci return -ENOMEM; 8778c2ecf20Sopenharmony_ci kcontrol->id.numid = CTRLID_GAINS; 8788c2ecf20Sopenharmony_ci kcontrol->info = snd_vortex_a3d_ild_info; 8798c2ecf20Sopenharmony_ci kcontrol->put = snd_vortex_a3d_ild_put; 8808c2ecf20Sopenharmony_ci if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0) 8818c2ecf20Sopenharmony_ci return err; 8828c2ecf20Sopenharmony_ci } 8838c2ecf20Sopenharmony_ci /* Filter controls. */ 8848c2ecf20Sopenharmony_ci for (i = 0; i < NR_A3D; i++) { 8858c2ecf20Sopenharmony_ci if ((kcontrol = 8868c2ecf20Sopenharmony_ci snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL) 8878c2ecf20Sopenharmony_ci return -ENOMEM; 8888c2ecf20Sopenharmony_ci kcontrol->id.numid = CTRLID_FILTER; 8898c2ecf20Sopenharmony_ci kcontrol->info = snd_vortex_a3d_filter_info; 8908c2ecf20Sopenharmony_ci kcontrol->put = snd_vortex_a3d_filter_put; 8918c2ecf20Sopenharmony_ci if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0) 8928c2ecf20Sopenharmony_ci return err; 8938c2ecf20Sopenharmony_ci } 8948c2ecf20Sopenharmony_ci return 0; 8958c2ecf20Sopenharmony_ci} 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_cistatic void vortex_a3d_unregister_controls(vortex_t * vortex) 8988c2ecf20Sopenharmony_ci{ 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_ci} 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_ci/* End of File*/ 903