1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
11 * Copyright (C) 2007 by Christian Gmeiner
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
29 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
30 #if CONFIG_CPU == PNX0101
32 #endif /* CONFIG_CPU == PNX101 */
33 #if CONFIG_CODEC == SWCODEC
35 #else /* !CONFIG_CODEC == HWCODEC */
39 #endif /* !SIMULATOR */
42 * find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble
45 extern bool audio_is_initialized
;
47 const char *sound_unit(int setting
)
49 return audiohw_settings
[setting
].unit
;
52 int sound_numdecimals(int setting
)
54 return audiohw_settings
[setting
].numdecimals
;
57 int sound_steps(int setting
)
59 return audiohw_settings
[setting
].steps
;
62 int sound_min(int setting
)
64 return audiohw_settings
[setting
].minval
;
67 int sound_max(int setting
)
69 return audiohw_settings
[setting
].maxval
;
72 int sound_default(int setting
)
74 return audiohw_settings
[setting
].defaultval
;
77 static sound_set_type
* const sound_set_fns
[] =
79 [0 ... SOUND_LAST_SETTING
-1] = NULL
,
80 [SOUND_VOLUME
] = sound_set_volume
,
81 #if defined(AUDIOHW_HAVE_BASS)
82 [SOUND_BASS
] = sound_set_bass
,
84 #if defined(AUDIOHW_HAVE_TREBLE)
85 [SOUND_TREBLE
] = sound_set_treble
,
87 [SOUND_BALANCE
] = sound_set_balance
,
88 [SOUND_CHANNELS
] = sound_set_channels
,
89 [SOUND_STEREO_WIDTH
] = sound_set_stereo_width
,
90 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
91 [SOUND_LOUDNESS
] = sound_set_loudness
,
92 [SOUND_AVC
] = sound_set_avc
,
93 [SOUND_MDB_STRENGTH
] = sound_set_mdb_strength
,
94 [SOUND_MDB_HARMONICS
] = sound_set_mdb_harmonics
,
95 [SOUND_MDB_CENTER
] = sound_set_mdb_center
,
96 [SOUND_MDB_SHAPE
] = sound_set_mdb_shape
,
97 [SOUND_MDB_ENABLE
] = sound_set_mdb_enable
,
98 [SOUND_SUPERBASS
] = sound_set_superbass
,
99 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
100 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
101 [SOUND_BASS_CUTOFF
] = sound_set_bass_cutoff
,
103 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
104 [SOUND_TREBLE_CUTOFF
] = sound_set_treble_cutoff
,
106 #if defined(AUDIOHW_HAVE_DEPTH_3D)
107 [SOUND_DEPTH_3D
] = sound_set_depth_3d
,
109 /* Hardware EQ tone controls */
110 #if defined(AUDIOHW_HAVE_EQ)
111 [SOUND_EQ_BAND1_GAIN
] = sound_set_hw_eq_band1_gain
,
112 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
113 [SOUND_EQ_BAND1_FREQUENCY
] = sound_set_hw_eq_band1_frequency
,
115 #if defined(AUDIOHW_HAVE_EQ_BAND2)
116 [SOUND_EQ_BAND2_GAIN
] = sound_set_hw_eq_band2_gain
,
117 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
118 [SOUND_EQ_BAND2_FREQUENCY
] = sound_set_hw_eq_band2_frequency
,
120 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
121 [SOUND_EQ_BAND2_WIDTH
] = sound_set_hw_eq_band2_width
,
123 #endif /* AUDIOHW_HAVE_EQ_BAND2 */
124 #if defined(AUDIOHW_HAVE_EQ_BAND3)
125 [SOUND_EQ_BAND3_GAIN
] = sound_set_hw_eq_band3_gain
,
126 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
127 [SOUND_EQ_BAND3_FREQUENCY
] = sound_set_hw_eq_band3_frequency
,
129 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
130 [SOUND_EQ_BAND3_WIDTH
] = sound_set_hw_eq_band3_width
,
132 #endif /* AUDIOHW_HAVE_EQ_BAND3 */
133 #if defined(AUDIOHW_HAVE_EQ_BAND4)
134 [SOUND_EQ_BAND4_GAIN
] = sound_set_hw_eq_band4_gain
,
135 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
136 [SOUND_EQ_BAND4_FREQUENCY
] = sound_set_hw_eq_band4_frequency
,
138 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
139 [SOUND_EQ_BAND4_WIDTH
] = sound_set_hw_eq_band4_width
,
141 #endif /* AUDIOHW_HAVE_EQ_BAND4 */
142 #if defined(AUDIOHW_HAVE_EQ_BAND5)
143 [SOUND_EQ_BAND5_GAIN
] = sound_set_hw_eq_band5_gain
,
144 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
145 [SOUND_EQ_BAND5_FREQUENCY
] = sound_set_hw_eq_band5_frequency
,
147 #endif /* AUDIOHW_HAVE_EQ_BAND5 */
148 #endif /* AUDIOHW_HAVE_EQ */
151 sound_set_type
* sound_get_fn(int setting
)
153 return ((unsigned)setting
>= ARRAYLEN(sound_set_fns
)?
154 NULL
: sound_set_fns
[setting
]);
157 #if CONFIG_CODEC == SWCODEC
158 static int (*dsp_callback
)(int, intptr_t) = NULL
;
160 void sound_set_dsp_callback(int (*func
)(int, intptr_t))
166 #if !defined(AUDIOHW_HAVE_CLIPPING)
168 * The prescaler compensates for any kind of boosts, to prevent clipping.
170 * It's basically just a measure to make sure that audio does not clip during
171 * tone controls processing, like if i want to boost bass 12 dB, i can decrease
172 * the audio amplitude by -12 dB before processing, then increase master gain
173 * by 12 dB after processing.
176 /* all values in tenth of dB MAS3507D UDA1380 */
177 static int current_volume
= 0; /* -780..+180 -840.. 0 */
178 static int current_balance
= 0; /* -960..+960 -840..+840 */
179 #ifdef AUDIOHW_HAVE_TREBLE
180 static int current_treble
= 0; /* -150..+150 0.. +60 */
182 #ifdef AUDIOHW_HAVE_BASS
183 static int current_bass
= 0; /* -150..+150 0..+240 */
185 #ifdef AUDIOHW_HAVE_EQ
186 static int current_eq_band_gain
[AUDIOHW_EQ_BAND_NUM
];
189 static void set_prescaled_volume(void)
194 /* The codecs listed use HW tone controls but don't have suitable prescaler
195 * functionality, so we let the prescaler stay at 0 for these, unless
196 * SW tone controls are in use. This is to avoid needing the SW DSP just for
199 #if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
200 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
201 || defined(HAVE_WM8758) || defined(HAVE_WM8985) || defined(HAVE_UDA1341))
203 #if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
204 prescale
= MAX(current_bass
, current_treble
);
206 #if defined(AUDIOHW_HAVE_EQ)
208 for (i
= 0; i
< AUDIOHW_EQ_BAND_NUM
; i
++)
209 prescale
= MAX(current_eq_band_gain
[i
], prescale
);
213 prescale
= 0; /* no need to prescale if we don't boost
214 bass, treble or eq band */
216 /* Gain up the analog volume to compensate the prescale gain reduction,
217 * but if this would push the volume over the top, reduce prescaling
218 * instead (might cause clipping). */
219 if (current_volume
+ prescale
> VOLUME_MAX
)
220 prescale
= VOLUME_MAX
- current_volume
;
223 #if defined(AUDIOHW_HAVE_PRESCALER)
224 audiohw_set_prescaler(prescale
);
226 dsp_callback(DSP_CALLBACK_SET_PRESCALE
, prescale
);
229 if (current_volume
== VOLUME_MIN
)
230 prescale
= 0; /* Make sure the chip gets muted at VOLUME_MIN */
232 l
= r
= current_volume
+ prescale
;
234 /* Balance the channels scaled by the current volume and min volume. */
235 /* Subtract a dB from VOLUME_MIN to get it to a mute level */
236 if (current_balance
> 0)
238 l
-= ((l
- (VOLUME_MIN
- ONE_DB
)) * current_balance
) / VOLUME_RANGE
;
240 else if (current_balance
< 0)
242 r
+= ((r
- (VOLUME_MIN
- ONE_DB
)) * current_balance
) / VOLUME_RANGE
;
245 #ifdef HAVE_SW_VOLUME_CONTROL
246 dsp_callback(DSP_CALLBACK_SET_SW_VOLUME
, 0);
249 #ifndef HAVE_SDL_AUDIO
250 #if CONFIG_CODEC == MAS3507D
251 dac_volume(tenthdb2reg(l
), tenthdb2reg(r
), false);
252 #elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
253 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
254 || defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_AS3514) \
255 || defined(HAVE_TSC2100) || defined(HAVE_AK4537) || defined(HAVE_UDA1341)
256 audiohw_set_master_vol(tenthdb2master(l
), tenthdb2master(r
));
257 #if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
258 || defined(HAVE_WM8750) || (defined(HAVE_WM8751) && !defined(MROBE_100)) \
259 || defined(HAVE_WM8985)
260 audiohw_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
263 #elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985)
264 audiohw_set_headphone_vol(tenthdb2master(l
), tenthdb2master(r
));
265 #elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
266 audiohw_set_volume(current_volume
);
268 #else /* HAVE_SDL_AUDIO */
269 audiohw_set_volume(current_volume
);
270 #endif /* !HAVE_SDL_AUDIO */
272 #endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
274 void sound_set_volume(int value
)
276 if(!audio_is_initialized
)
279 #if defined(AUDIOHW_HAVE_CLIPPING)
280 audiohw_set_volume(value
);
281 #elif CONFIG_CPU == PNX0101
282 int tmp
= (60 - value
* 4) & 0xff;
283 CODECVOL
= tmp
| (tmp
<< 8);
285 current_volume
= value
* 10; /* tenth of dB */
286 set_prescaled_volume();
290 void sound_set_balance(int value
)
292 if(!audio_is_initialized
)
295 #ifdef AUDIOHW_HAVE_BALANCE
296 audiohw_set_balance(value
);
298 current_balance
= value
* VOLUME_RANGE
/ 100; /* tenth of dB */
299 set_prescaled_volume();
303 #ifdef AUDIOHW_HAVE_BASS
304 void sound_set_bass(int value
)
306 if(!audio_is_initialized
)
309 #if !defined(AUDIOHW_HAVE_CLIPPING)
310 #if defined(HAVE_WM8750) || defined(HAVE_WM8751)
311 current_bass
= value
;
313 current_bass
= value
* 10;
317 #if defined(HAVE_SW_TONE_CONTROLS)
318 dsp_callback(DSP_CALLBACK_SET_BASS
, current_bass
);
320 audiohw_set_bass(value
);
323 #if !defined(AUDIOHW_HAVE_CLIPPING)
324 set_prescaled_volume();
327 #endif /* AUDIOHW_HAVE_BASS */
329 #ifdef AUDIOHW_HAVE_TREBLE
330 void sound_set_treble(int value
)
332 if(!audio_is_initialized
)
335 #if !defined(AUDIOHW_HAVE_CLIPPING)
336 #if defined(HAVE_WM8750) || defined(HAVE_WM8751)
337 current_treble
= value
;
339 current_treble
= value
* 10;
343 #if defined(HAVE_SW_TONE_CONTROLS)
344 dsp_callback(DSP_CALLBACK_SET_TREBLE
, current_treble
);
346 audiohw_set_treble(value
);
349 #if !defined(AUDIOHW_HAVE_CLIPPING)
350 set_prescaled_volume();
353 #endif /* AUDIOHW_HAVE_TREBLE */
355 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
356 void sound_set_bass_cutoff(int value
)
358 if(!audio_is_initialized
)
361 audiohw_set_bass_cutoff(value
);
365 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
366 void sound_set_treble_cutoff(int value
)
368 if(!audio_is_initialized
)
371 audiohw_set_treble_cutoff(value
);
375 void sound_set_channels(int value
)
377 if(!audio_is_initialized
)
380 #if CONFIG_CODEC == SWCODEC
381 dsp_callback(DSP_CALLBACK_SET_CHANNEL_CONFIG
, value
);
383 audiohw_set_channel(value
);
387 void sound_set_stereo_width(int value
)
389 if(!audio_is_initialized
)
392 #if CONFIG_CODEC == SWCODEC
393 dsp_callback(DSP_CALLBACK_SET_STEREO_WIDTH
, value
);
395 audiohw_set_stereo_width(value
);
399 #if defined(AUDIOHW_HAVE_DEPTH_3D)
400 void sound_set_depth_3d(int value
)
402 if(!audio_is_initialized
)
405 audiohw_set_depth_3d(value
);
409 #if defined(AUDIOHW_HAVE_EQ)
410 int sound_enum_hw_eq_band_setting(unsigned int band
,
411 unsigned int band_setting
)
414 sound_hw_eq_band_setting
[AUDIOHW_EQ_SETTING_NUM
][AUDIOHW_EQ_BAND_NUM
] =
418 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
419 [AUDIOHW_EQ_BAND1
] = SOUND_EQ_BAND1_GAIN
,
420 #ifdef AUDIOHW_HAVE_EQ_BAND2
421 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_GAIN
,
423 #ifdef AUDIOHW_HAVE_EQ_BAND3
424 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_GAIN
,
426 #ifdef AUDIOHW_HAVE_EQ_BAND4
427 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_GAIN
,
429 #ifdef AUDIOHW_HAVE_EQ_BAND5
430 [AUDIOHW_EQ_BAND5
] = SOUND_EQ_BAND5_GAIN
,
433 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
434 [AUDIOHW_EQ_FREQUENCY
] =
436 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
437 #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
438 [AUDIOHW_EQ_BAND1
] = SOUND_EQ_BAND1_FREQUENCY
,
440 #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
441 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_FREQUENCY
,
443 #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
444 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_FREQUENCY
,
446 #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
447 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_FREQUENCY
,
449 #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
450 [AUDIOHW_EQ_BAND5
] = SOUND_EQ_BAND5_FREQUENCY
,
453 #endif /* AUDIOHW_HAVE_EQ_FREQUENCY */
454 #ifdef AUDIOHW_HAVE_EQ_WIDTH
457 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
458 #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH
459 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_WIDTH
,
461 #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH
462 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_WIDTH
,
464 #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH
465 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_WIDTH
,
468 #endif /* AUDIOHW_HAVE_EQ_WIDTH */
471 if (band
< AUDIOHW_EQ_BAND_NUM
&& band_setting
< AUDIOHW_EQ_SETTING_NUM
)
472 return sound_hw_eq_band_setting
[band_setting
][band
];
477 static void sound_set_hw_eq_band_gain(unsigned int band
, int value
)
479 if(!audio_is_initialized
)
482 current_eq_band_gain
[band
] = value
;
483 audiohw_set_eq_band_gain(band
, value
);
484 set_prescaled_volume();
487 void sound_set_hw_eq_band1_gain(int value
)
489 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND1
, value
);
492 #if defined(AUDIOHW_HAVE_EQ_BAND2)
493 void sound_set_hw_eq_band2_gain(int value
)
495 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND2
, value
);
499 #if defined(AUDIOHW_HAVE_EQ_BAND3)
500 void sound_set_hw_eq_band3_gain(int value
)
502 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND3
, value
);
506 #if defined(AUDIOHW_HAVE_EQ_BAND4)
507 void sound_set_hw_eq_band4_gain(int value
)
509 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND4
, value
);
513 #if defined(AUDIOHW_HAVE_EQ_BAND5)
514 void sound_set_hw_eq_band5_gain(int value
)
516 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND5
, value
);
520 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
521 void sound_set_hw_eq_band1_frequency(int value
)
523 if(!audio_is_initialized
)
526 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND1
, value
);
530 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
531 void sound_set_hw_eq_band2_frequency(int value
)
533 if(!audio_is_initialized
)
536 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND2
, value
);
540 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
541 void sound_set_hw_eq_band3_frequency(int value
)
543 if(!audio_is_initialized
)
546 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND3
, value
);
550 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
551 void sound_set_hw_eq_band4_frequency(int value
)
553 if(!audio_is_initialized
)
556 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND4
, value
);
560 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
561 void sound_set_hw_eq_band5_frequency(int value
)
563 if(!audio_is_initialized
)
566 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND5
, value
);
570 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
571 void sound_set_hw_eq_band2_width(int value
)
573 if(!audio_is_initialized
)
576 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND2
, value
);
580 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
581 void sound_set_hw_eq_band3_width(int value
)
583 if(!audio_is_initialized
)
586 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND3
, value
);
590 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
591 void sound_set_hw_eq_band4_width(int value
)
593 if(!audio_is_initialized
)
596 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND4
, value
);
599 #endif /* AUDIOHW_HAVE_EQ */
601 #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F))
602 void sound_set_loudness(int value
)
604 if(!audio_is_initialized
)
607 audiohw_set_loudness(value
);
610 void sound_set_avc(int value
)
612 if(!audio_is_initialized
)
615 audiohw_set_avc(value
);
618 void sound_set_mdb_strength(int value
)
620 if(!audio_is_initialized
)
623 audiohw_set_mdb_strength(value
);
626 void sound_set_mdb_harmonics(int value
)
628 if(!audio_is_initialized
)
631 audiohw_set_mdb_harmonics(value
);
634 void sound_set_mdb_center(int value
)
636 if(!audio_is_initialized
)
639 audiohw_set_mdb_center(value
);
642 void sound_set_mdb_shape(int value
)
644 if(!audio_is_initialized
)
647 audiohw_set_mdb_shape(value
);
650 void sound_set_mdb_enable(int value
)
652 if(!audio_is_initialized
)
655 audiohw_set_mdb_enable(value
);
658 void sound_set_superbass(int value
)
660 if(!audio_is_initialized
)
663 audiohw_set_superbass(value
);
665 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
667 void sound_set(int setting
, int value
)
669 sound_set_type
* sound_set_val
= sound_get_fn(setting
);
671 sound_set_val(value
);
674 #if (!defined(HAVE_AS3514) && !defined(HAVE_WM8975) \
675 && !defined(HAVE_WM8758) && !defined(HAVE_TSC2100) \
676 && !defined (HAVE_WM8711) && !defined (HAVE_WM8721) \
677 && !defined (HAVE_WM8731) && !defined (HAVE_WM8978) \
678 && !defined(HAVE_AK4537)) || (CONFIG_PLATFORM & PLATFORM_HOSTED)
679 int sound_val2phys(int setting
, int value
)
681 #if CONFIG_CODEC == MAS3587F
686 case SOUND_LEFT_GAIN
:
687 case SOUND_RIGHT_GAIN
:
688 result
= (value
- 2) * 15;
692 result
= value
* 15 + 210;
700 #elif defined(HAVE_UDA1380)
705 #ifdef HAVE_RECORDING
706 case SOUND_LEFT_GAIN
:
707 case SOUND_RIGHT_GAIN
:
709 result
= value
* 5; /* (1/2) * 10 */
717 #elif defined(HAVE_TLV320) || defined(HAVE_WM8711) \
718 || defined(HAVE_WM8721) || defined(HAVE_WM8731)
723 #ifdef HAVE_RECORDING
724 case SOUND_LEFT_GAIN
:
725 case SOUND_RIGHT_GAIN
:
726 result
= (value
- 23) * 15; /* (x - 23)/1.5 *10 */
730 result
= value
* 200; /* 0 or 20 dB */
738 #elif defined(HAVE_AS3514)
739 /* This is here for the sim only and the audio driver has its own */
744 #ifdef HAVE_RECORDING
745 case SOUND_LEFT_GAIN
:
746 case SOUND_RIGHT_GAIN
:
748 result
= (value
- 23) * 15;
757 #elif defined(HAVE_WM8978)
762 #ifdef HAVE_RECORDING
763 case SOUND_LEFT_GAIN
:
764 case SOUND_RIGHT_GAIN
:
771 result
= (100 * value
+ 8) / 15;
784 #endif /* CONFIG_CODECs || PLATFORM_HOSTED */
786 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
787 /* This function works by telling the decoder that we have another
788 crystal frequency than we actually have. It will adjust its internal
789 parameters and the result is that the audio is played at another pitch.
791 The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h)
794 static int last_pitch
= PITCH_SPEED_100
;
796 void sound_set_pitch(int32_t pitch
)
800 if (pitch
!= last_pitch
)
802 /* Calculate the new (bogus) frequency */
803 val
= 18432 * PITCH_SPEED_100
/ pitch
;
805 audiohw_set_pitch(val
);
811 int32_t sound_get_pitch(void)
815 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */