GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / sound / pci / au88x0 / au88x0_a3d.c
blob0379d768fc3758d67062b55520240d66c3de7453
1 /***************************************************************************
2 * au88x0_a3d.c
4 * Fri Jul 18 14:16:22 2003
5 * Copyright 2003 mjander
6 * mjander@users.sourceforge.net
8 * A3D. You may think i'm crazy, but this may work someday. Who knows...
9 ****************************************************************************/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include "au88x0_a3d.h"
28 #include "au88x0_a3ddata.c"
29 #include "au88x0_xtalk.h"
30 #include "au88x0.h"
32 static void
33 a3dsrc_SetTimeConsts(a3dsrc_t * a, short HrtfTrack, short ItdTrack,
34 short GTrack, short CTrack)
36 vortex_t *vortex = (vortex_t *) (a->vortex);
37 hwwrite(vortex->mmio,
38 a3d_addrA(a->slice, a->source, A3D_A_HrtfTrackTC), HrtfTrack);
39 hwwrite(vortex->mmio,
40 a3d_addrA(a->slice, a->source, A3D_A_ITDTrackTC), ItdTrack);
41 hwwrite(vortex->mmio,
42 a3d_addrA(a->slice, a->source, A3D_A_GainTrackTC), GTrack);
43 hwwrite(vortex->mmio,
44 a3d_addrA(a->slice, a->source, A3D_A_CoeffTrackTC), CTrack);
47 /* Atmospheric absorbtion. */
49 static void
50 a3dsrc_SetAtmosTarget(a3dsrc_t * a, short aa, short b, short c, short d,
51 short e)
53 vortex_t *vortex = (vortex_t *) (a->vortex);
54 hwwrite(vortex->mmio,
55 a3d_addrB(a->slice, a->source, A3D_B_A21Target),
56 (e << 0x10) | d);
57 hwwrite(vortex->mmio,
58 a3d_addrB(a->slice, a->source, A3D_B_B10Target),
59 (b << 0x10) | aa);
60 hwwrite(vortex->mmio,
61 a3d_addrB(a->slice, a->source, A3D_B_B2Target), c);
64 static void
65 a3dsrc_SetAtmosCurrent(a3dsrc_t * a, short aa, short b, short c, short d,
66 short e)
68 vortex_t *vortex = (vortex_t *) (a->vortex);
69 hwwrite(vortex->mmio,
70 a3d_addrB(a->slice, a->source, A3D_B_A12Current),
71 (e << 0x10) | d);
72 hwwrite(vortex->mmio,
73 a3d_addrB(a->slice, a->source, A3D_B_B01Current),
74 (b << 0x10) | aa);
75 hwwrite(vortex->mmio,
76 a3d_addrB(a->slice, a->source, A3D_B_B2Current), c);
79 static void
80 a3dsrc_SetAtmosState(a3dsrc_t * a, short x1, short x2, short y1, short y2)
82 vortex_t *vortex = (vortex_t *) (a->vortex);
83 hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_x1), x1);
84 hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_x2), x2);
85 hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_y1), y1);
86 hwwrite(vortex->mmio, a3d_addrA(a->slice, a->source, A3D_A_y2), y2);
89 /* HRTF */
91 static void
92 a3dsrc_SetHrtfTarget(a3dsrc_t * a, a3d_Hrtf_t const aa, a3d_Hrtf_t const b)
94 vortex_t *vortex = (vortex_t *) (a->vortex);
95 int i;
97 for (i = 0; i < HRTF_SZ; i++)
98 hwwrite(vortex->mmio,
99 a3d_addrB(a->slice, a->source,
100 A3D_B_HrtfTarget) + (i << 2),
101 (b[i] << 0x10) | aa[i]);
104 static void
105 a3dsrc_SetHrtfCurrent(a3dsrc_t * a, a3d_Hrtf_t const aa, a3d_Hrtf_t const b)
107 vortex_t *vortex = (vortex_t *) (a->vortex);
108 int i;
110 for (i = 0; i < HRTF_SZ; i++)
111 hwwrite(vortex->mmio,
112 a3d_addrB(a->slice, a->source,
113 A3D_B_HrtfCurrent) + (i << 2),
114 (b[i] << 0x10) | aa[i]);
117 static void
118 a3dsrc_SetHrtfState(a3dsrc_t * a, a3d_Hrtf_t const aa, a3d_Hrtf_t const b)
120 vortex_t *vortex = (vortex_t *) (a->vortex);
121 int i;
123 for (i = 0; i < HRTF_SZ; i++)
124 hwwrite(vortex->mmio,
125 a3d_addrB(a->slice, a->source,
126 A3D_B_HrtfDelayLine) + (i << 2),
127 (b[i] << 0x10) | aa[i]);
130 static void a3dsrc_SetHrtfOutput(a3dsrc_t * a, short left, short right)
132 vortex_t *vortex = (vortex_t *) (a->vortex);
133 hwwrite(vortex->mmio,
134 a3d_addrA(a->slice, a->source, A3D_A_HrtfOutL), left);
135 hwwrite(vortex->mmio,
136 a3d_addrA(a->slice, a->source, A3D_A_HrtfOutR), right);
140 /* Interaural Time Difference.
141 * "The other main clue that humans use to locate sounds, is called
142 * Interaural Time Difference (ITD). The differences in distance from
143 * the sound source to a listeners ears means that the sound will
144 * reach one ear slightly before the other....", found somewhere with google.*/
145 static void a3dsrc_SetItdTarget(a3dsrc_t * a, short litd, short ritd)
147 vortex_t *vortex = (vortex_t *) (a->vortex);
149 if (litd < 0)
150 litd = 0;
151 if (litd > 0x57FF)
152 litd = 0x57FF;
153 if (ritd < 0)
154 ritd = 0;
155 if (ritd > 0x57FF)
156 ritd = 0x57FF;
157 hwwrite(vortex->mmio,
158 a3d_addrB(a->slice, a->source, A3D_B_ITDTarget),
159 (ritd << 0x10) | litd);
160 //hwwrite(vortex->mmio, addr(0x191DF+5, this04, this08), (ritd<<0x10)|litd);
163 static void a3dsrc_SetItdCurrent(a3dsrc_t * a, short litd, short ritd)
165 vortex_t *vortex = (vortex_t *) (a->vortex);
167 if (litd < 0)
168 litd = 0;
169 if (litd > 0x57FF)
170 litd = 0x57FF;
171 if (ritd < 0)
172 ritd = 0;
173 if (ritd > 0x57FF)
174 ritd = 0x57FF;
175 hwwrite(vortex->mmio,
176 a3d_addrB(a->slice, a->source, A3D_B_ITDCurrent),
177 (ritd << 0x10) | litd);
178 //hwwrite(vortex->mmio, addr(0x191DF+1, this04, this08), (ritd<<0x10)|litd);
181 static void a3dsrc_SetItdDline(a3dsrc_t * a, a3d_ItdDline_t const dline)
183 vortex_t *vortex = (vortex_t *) (a->vortex);
184 int i;
185 /* 45 != 40 -> Check this ! */
186 for (i = 0; i < DLINE_SZ; i++)
187 hwwrite(vortex->mmio,
188 a3d_addrA(a->slice, a->source,
189 A3D_A_ITDDelayLine) + (i << 2), dline[i]);
192 /* This is may be used for ILD Interaural Level Difference. */
194 static void a3dsrc_SetGainTarget(a3dsrc_t * a, short left, short right)
196 vortex_t *vortex = (vortex_t *) (a->vortex);
197 hwwrite(vortex->mmio,
198 a3d_addrB(a->slice, a->source, A3D_B_GainTarget),
199 (right << 0x10) | left);
202 static void a3dsrc_SetGainCurrent(a3dsrc_t * a, short left, short right)
204 vortex_t *vortex = (vortex_t *) (a->vortex);
205 hwwrite(vortex->mmio,
206 a3d_addrB(a->slice, a->source, A3D_B_GainCurrent),
207 (right << 0x10) | left);
210 /* Generic A3D stuff */
212 static void a3dsrc_SetA3DSampleRate(a3dsrc_t * a, int sr)
214 vortex_t *vortex = (vortex_t *) (a->vortex);
215 int esp0 = 0;
217 esp0 = (((esp0 & 0x7fffffff) | 0xB8000000) & 0x7) | ((sr & 0x1f) << 3);
218 hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd), esp0);
219 //hwwrite(vortex->mmio, 0x19C38 + (this08<<0xd), esp0);
222 static void a3dsrc_EnableA3D(a3dsrc_t * a)
224 vortex_t *vortex = (vortex_t *) (a->vortex);
225 hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd),
226 0xF0000001);
227 //hwwrite(vortex->mmio, 0x19C38 + (this08<<0xd), 0xF0000001);
230 static void a3dsrc_DisableA3D(a3dsrc_t * a)
232 vortex_t *vortex = (vortex_t *) (a->vortex);
233 hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd),
234 0xF0000000);
237 static void a3dsrc_SetA3DControlReg(a3dsrc_t * a, unsigned long ctrl)
239 vortex_t *vortex = (vortex_t *) (a->vortex);
240 hwwrite(vortex->mmio, A3D_SLICE_Control + ((a->slice) << 0xd), ctrl);
243 static void a3dsrc_SetA3DPointerReg(a3dsrc_t * a, unsigned long ptr)
245 vortex_t *vortex = (vortex_t *) (a->vortex);
246 hwwrite(vortex->mmio, A3D_SLICE_Pointers + ((a->slice) << 0xd), ptr);
249 static void a3dsrc_ZeroSliceIO(a3dsrc_t * a)
251 vortex_t *vortex = (vortex_t *) (a->vortex);
252 int i;
254 for (i = 0; i < 8; i++)
255 hwwrite(vortex->mmio,
256 A3D_SLICE_VDBDest +
257 ((((a->slice) << 0xb) + i) << 2), 0);
258 for (i = 0; i < 4; i++)
259 hwwrite(vortex->mmio,
260 A3D_SLICE_VDBSource +
261 ((((a->slice) << 0xb) + i) << 2), 0);
264 /* Reset Single A3D source. */
265 static void a3dsrc_ZeroState(a3dsrc_t * a)
268 printk(KERN_DEBUG "vortex: ZeroState slice: %d, source %d\n",
269 a->slice, a->source);
271 a3dsrc_SetAtmosState(a, 0, 0, 0, 0);
272 a3dsrc_SetHrtfState(a, A3dHrirZeros, A3dHrirZeros);
273 a3dsrc_SetItdDline(a, A3dItdDlineZeros);
274 a3dsrc_SetHrtfOutput(a, 0, 0);
275 a3dsrc_SetTimeConsts(a, 0, 0, 0, 0);
277 a3dsrc_SetAtmosCurrent(a, 0, 0, 0, 0, 0);
278 a3dsrc_SetAtmosTarget(a, 0, 0, 0, 0, 0);
279 a3dsrc_SetItdCurrent(a, 0, 0);
280 a3dsrc_SetItdTarget(a, 0, 0);
281 a3dsrc_SetGainCurrent(a, 0, 0);
282 a3dsrc_SetGainTarget(a, 0, 0);
284 a3dsrc_SetHrtfCurrent(a, A3dHrirZeros, A3dHrirZeros);
285 a3dsrc_SetHrtfTarget(a, A3dHrirZeros, A3dHrirZeros);
288 /* Reset entire A3D engine */
289 static void a3dsrc_ZeroStateA3D(a3dsrc_t * a)
291 int i, var, var2;
293 if ((a->vortex) == NULL) {
294 printk(KERN_ERR "vortex: ZeroStateA3D: ERROR: a->vortex is NULL\n");
295 return;
298 a3dsrc_SetA3DControlReg(a, 0);
299 a3dsrc_SetA3DPointerReg(a, 0);
301 var = a->slice;
302 var2 = a->source;
303 for (i = 0; i < 4; i++) {
304 a->slice = i;
305 a3dsrc_ZeroSliceIO(a);
306 //a3dsrc_ZeroState(a);
308 a->source = var2;
309 a->slice = var;
312 /* Program A3D block as pass through */
313 static void a3dsrc_ProgramPipe(a3dsrc_t * a)
315 a3dsrc_SetTimeConsts(a, 0, 0, 0, 0);
316 a3dsrc_SetAtmosCurrent(a, 0, 0x4000, 0, 0, 0);
317 a3dsrc_SetAtmosTarget(a, 0x4000, 0, 0, 0, 0);
318 a3dsrc_SetItdCurrent(a, 0, 0);
319 a3dsrc_SetItdTarget(a, 0, 0);
320 a3dsrc_SetGainCurrent(a, 0x7fff, 0x7fff);
321 a3dsrc_SetGainTarget(a, 0x7fff, 0x7fff);
323 /* SET HRTF HERE */
325 /* Single spike leads to identity transfer function. */
326 a3dsrc_SetHrtfCurrent(a, A3dHrirImpulse, A3dHrirImpulse);
327 a3dsrc_SetHrtfTarget(a, A3dHrirImpulse, A3dHrirImpulse);
329 /* Test: Sounds saturated. */
330 //a3dsrc_SetHrtfCurrent(a, A3dHrirSatTest, A3dHrirSatTest);
331 //a3dsrc_SetHrtfTarget(a, A3dHrirSatTest, A3dHrirSatTest);
334 /* VDB = Vortex audio Dataflow Bus */
336 /* A3D HwSource stuff. */
338 static void vortex_A3dSourceHw_Initialize(vortex_t * v, int source, int slice)
340 a3dsrc_t *a3dsrc = &(v->a3d[source + (slice * 4)]);
341 //a3dsrc_t *a3dsrc = &(v->a3d[source + (slice*4)]);
343 a3dsrc->vortex = (void *)v;
344 a3dsrc->source = source; /* source */
345 a3dsrc->slice = slice; /* slice */
346 a3dsrc_ZeroState(a3dsrc);
347 /* Added by me. */
348 a3dsrc_SetA3DSampleRate(a3dsrc, 0x11);
351 static int Vort3DRend_Initialize(vortex_t * v, unsigned short mode)
353 v->xt_mode = mode; /* this_14 */
355 vortex_XtalkHw_init(v);
356 vortex_XtalkHw_SetGainsAllChan(v);
357 switch (v->xt_mode) {
358 case XT_SPEAKER0:
359 vortex_XtalkHw_ProgramXtalkNarrow(v);
360 break;
361 case XT_SPEAKER1:
362 vortex_XtalkHw_ProgramXtalkWide(v);
363 break;
364 default:
365 case XT_HEADPHONE:
366 vortex_XtalkHw_ProgramPipe(v);
367 break;
368 case XT_DIAMOND:
369 vortex_XtalkHw_ProgramDiamondXtalk(v);
370 break;
372 vortex_XtalkHw_SetSampleRate(v, 0x11);
373 vortex_XtalkHw_Enable(v);
374 return 0;
377 /* 3D Sound entry points. */
379 static int vortex_a3d_register_controls(vortex_t * vortex);
380 static void vortex_a3d_unregister_controls(vortex_t * vortex);
381 /* A3D base support init/shudown */
382 static void __devinit vortex_Vort3D_enable(vortex_t * v)
384 int i;
386 Vort3DRend_Initialize(v, XT_HEADPHONE);
387 for (i = 0; i < NR_A3D; i++) {
388 vortex_A3dSourceHw_Initialize(v, i % 4, i >> 2);
389 a3dsrc_ZeroStateA3D(&(v->a3d[0]));
391 /* Register ALSA controls */
392 vortex_a3d_register_controls(v);
395 static void vortex_Vort3D_disable(vortex_t * v)
397 vortex_XtalkHw_Disable(v);
398 vortex_a3d_unregister_controls(v);
401 /* Make A3D subsystem connections. */
402 static void vortex_Vort3D_connect(vortex_t * v, int en)
404 int i;
406 // Disable AU8810 routes, since they seem to be wrong (in au8810.h).
407 #ifdef CHIP_AU8810
408 return;
409 #endif
411 /* Alloc Xtalk mixin resources */
412 v->mixxtlk[0] =
413 vortex_adb_checkinout(v, v->fixed_res, en, VORTEX_RESOURCE_MIXIN);
414 if (v->mixxtlk[0] < 0) {
415 printk
416 ("vortex: vortex_Vort3D: ERROR: not enough free mixer resources.\n");
417 return;
419 v->mixxtlk[1] =
420 vortex_adb_checkinout(v, v->fixed_res, en, VORTEX_RESOURCE_MIXIN);
421 if (v->mixxtlk[1] < 0) {
422 printk
423 ("vortex: vortex_Vort3D: ERROR: not enough free mixer resources.\n");
424 return;
427 /* Connect A3D -> XTALK */
428 for (i = 0; i < 4; i++) {
429 // 2 outputs per each A3D slice.
430 vortex_route(v, en, 0x11, ADB_A3DOUT(i * 2), ADB_XTALKIN(i));
431 vortex_route(v, en, 0x11, ADB_A3DOUT(i * 2) + 1, ADB_XTALKIN(5 + i));
433 /* Connect XTalk -> mixer */
434 vortex_route(v, en, 0x11, ADB_XTALKOUT(0), ADB_MIXIN(v->mixxtlk[0]));
435 vortex_route(v, en, 0x11, ADB_XTALKOUT(1), ADB_MIXIN(v->mixxtlk[1]));
436 vortex_connection_mixin_mix(v, en, v->mixxtlk[0], v->mixplayb[0], 0);
437 vortex_connection_mixin_mix(v, en, v->mixxtlk[1], v->mixplayb[1], 0);
438 vortex_mix_setinputvolumebyte(v, v->mixplayb[0], v->mixxtlk[0],
439 en ? MIX_DEFIGAIN : VOL_MIN);
440 vortex_mix_setinputvolumebyte(v, v->mixplayb[1], v->mixxtlk[1],
441 en ? MIX_DEFIGAIN : VOL_MIN);
442 if (VORTEX_IS_QUAD(v)) {
443 vortex_connection_mixin_mix(v, en, v->mixxtlk[0],
444 v->mixplayb[2], 0);
445 vortex_connection_mixin_mix(v, en, v->mixxtlk[1],
446 v->mixplayb[3], 0);
447 vortex_mix_setinputvolumebyte(v, v->mixplayb[2],
448 v->mixxtlk[0],
449 en ? MIX_DEFIGAIN : VOL_MIN);
450 vortex_mix_setinputvolumebyte(v, v->mixplayb[3],
451 v->mixxtlk[1],
452 en ? MIX_DEFIGAIN : VOL_MIN);
456 /* Initialize one single A3D source. */
457 static void vortex_Vort3D_InitializeSource(a3dsrc_t * a, int en)
459 if (a->vortex == NULL) {
460 printk
461 ("vortex: Vort3D_InitializeSource: A3D source not initialized\n");
462 return;
464 if (en) {
465 a3dsrc_ProgramPipe(a);
466 a3dsrc_SetA3DSampleRate(a, 0x11);
467 a3dsrc_SetTimeConsts(a, HrtfTCDefault,
468 ItdTCDefault, GainTCDefault,
469 CoefTCDefault);
470 /* Remark: zero gain is muted. */
471 //a3dsrc_SetGainTarget(a,0,0);
472 //a3dsrc_SetGainCurrent(a,0,0);
473 a3dsrc_EnableA3D(a);
474 } else {
475 a3dsrc_DisableA3D(a);
476 a3dsrc_ZeroState(a);
480 /* Conversion of coordinates into 3D parameters. */
482 static void vortex_a3d_coord2hrtf(a3d_Hrtf_t hrtf, int *coord)
486 static void vortex_a3d_coord2itd(a3d_Itd_t itd, int *coord)
490 static void vortex_a3d_coord2ild(a3d_LRGains_t ild, int left, int right)
494 static void vortex_a3d_translate_filter(a3d_atmos_t filter, int *params)
499 /* ALSA control interface. */
501 static int
502 snd_vortex_a3d_hrtf_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
504 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
505 uinfo->count = 6;
506 uinfo->value.integer.min = 0x00000000;
507 uinfo->value.integer.max = 0xffffffff;
508 return 0;
510 static int
511 snd_vortex_a3d_itd_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
513 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
514 uinfo->count = 2;
515 uinfo->value.integer.min = 0x00000000;
516 uinfo->value.integer.max = 0xffffffff;
517 return 0;
519 static int
520 snd_vortex_a3d_ild_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
522 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
523 uinfo->count = 2;
524 uinfo->value.integer.min = 0x00000000;
525 uinfo->value.integer.max = 0xffffffff;
526 return 0;
528 static int
529 snd_vortex_a3d_filter_info(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_info *uinfo)
532 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
533 uinfo->count = 4;
534 uinfo->value.integer.min = 0x00000000;
535 uinfo->value.integer.max = 0xffffffff;
536 return 0;
539 static int
540 snd_vortex_a3d_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
542 //a3dsrc_t *a = kcontrol->private_data;
543 /* No read yet. Would this be really useable/needed ? */
545 return 0;
548 static int
549 snd_vortex_a3d_hrtf_put(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_value *ucontrol)
552 a3dsrc_t *a = kcontrol->private_data;
553 int changed = 1, i;
554 int coord[6];
555 for (i = 0; i < 6; i++)
556 coord[i] = ucontrol->value.integer.value[i];
557 /* Translate orientation coordinates to a3d params. */
558 vortex_a3d_coord2hrtf(a->hrtf[0], coord);
559 vortex_a3d_coord2hrtf(a->hrtf[1], coord);
560 a3dsrc_SetHrtfTarget(a, a->hrtf[0], a->hrtf[1]);
561 a3dsrc_SetHrtfCurrent(a, a->hrtf[0], a->hrtf[1]);
562 return changed;
565 static int
566 snd_vortex_a3d_itd_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
569 a3dsrc_t *a = kcontrol->private_data;
570 int coord[6];
571 int i, changed = 1;
572 for (i = 0; i < 6; i++)
573 coord[i] = ucontrol->value.integer.value[i];
574 /* Translate orientation coordinates to a3d params. */
575 vortex_a3d_coord2itd(a->hrtf[0], coord);
576 vortex_a3d_coord2itd(a->hrtf[1], coord);
577 /* Inter aural time difference. */
578 a3dsrc_SetItdTarget(a, a->itd[0], a->itd[1]);
579 a3dsrc_SetItdCurrent(a, a->itd[0], a->itd[1]);
580 a3dsrc_SetItdDline(a, a->dline);
581 return changed;
584 static int
585 snd_vortex_a3d_ild_put(struct snd_kcontrol *kcontrol,
586 struct snd_ctl_elem_value *ucontrol)
588 a3dsrc_t *a = kcontrol->private_data;
589 int changed = 1;
590 int l, r;
591 /* There may be some scale tranlation needed here. */
592 l = ucontrol->value.integer.value[0];
593 r = ucontrol->value.integer.value[1];
594 vortex_a3d_coord2ild(a->ild, l, r);
595 /* Left Right panning. */
596 a3dsrc_SetGainTarget(a, l, r);
597 a3dsrc_SetGainCurrent(a, l, r);
598 return changed;
601 static int
602 snd_vortex_a3d_filter_put(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_value *ucontrol)
605 a3dsrc_t *a = kcontrol->private_data;
606 int i, changed = 1;
607 int params[6];
608 for (i = 0; i < 6; i++)
609 params[i] = ucontrol->value.integer.value[i];
610 /* Translate generic filter params to a3d filter params. */
611 vortex_a3d_translate_filter(a->filter, params);
612 /* Atmospheric absorbtion and filtering. */
613 a3dsrc_SetAtmosTarget(a, a->filter[0],
614 a->filter[1], a->filter[2],
615 a->filter[3], a->filter[4]);
616 a3dsrc_SetAtmosCurrent(a, a->filter[0],
617 a->filter[1], a->filter[2],
618 a->filter[3], a->filter[4]);
619 return changed;
622 static struct snd_kcontrol_new vortex_a3d_kcontrol __devinitdata = {
623 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
624 .name = "Playback PCM advanced processing",
625 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
626 .info = snd_vortex_a3d_hrtf_info,
627 .get = snd_vortex_a3d_get,
628 .put = snd_vortex_a3d_hrtf_put,
631 /* Control (un)registration. */
632 static int __devinit vortex_a3d_register_controls(vortex_t * vortex)
634 struct snd_kcontrol *kcontrol;
635 int err, i;
636 /* HRTF controls. */
637 for (i = 0; i < NR_A3D; i++) {
638 if ((kcontrol =
639 snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL)
640 return -ENOMEM;
641 kcontrol->id.numid = CTRLID_HRTF;
642 kcontrol->info = snd_vortex_a3d_hrtf_info;
643 kcontrol->put = snd_vortex_a3d_hrtf_put;
644 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
645 return err;
647 /* ITD controls. */
648 for (i = 0; i < NR_A3D; i++) {
649 if ((kcontrol =
650 snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL)
651 return -ENOMEM;
652 kcontrol->id.numid = CTRLID_ITD;
653 kcontrol->info = snd_vortex_a3d_itd_info;
654 kcontrol->put = snd_vortex_a3d_itd_put;
655 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
656 return err;
658 /* ILD (gains) controls. */
659 for (i = 0; i < NR_A3D; i++) {
660 if ((kcontrol =
661 snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL)
662 return -ENOMEM;
663 kcontrol->id.numid = CTRLID_GAINS;
664 kcontrol->info = snd_vortex_a3d_ild_info;
665 kcontrol->put = snd_vortex_a3d_ild_put;
666 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
667 return err;
669 /* Filter controls. */
670 for (i = 0; i < NR_A3D; i++) {
671 if ((kcontrol =
672 snd_ctl_new1(&vortex_a3d_kcontrol, &vortex->a3d[i])) == NULL)
673 return -ENOMEM;
674 kcontrol->id.numid = CTRLID_FILTER;
675 kcontrol->info = snd_vortex_a3d_filter_info;
676 kcontrol->put = snd_vortex_a3d_filter_put;
677 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
678 return err;
680 return 0;
683 static void vortex_a3d_unregister_controls(vortex_t * vortex)
688 /* End of File*/