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 ****************************************************************************/
31 * find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble
34 extern bool audio_is_initialized
;
36 const char *sound_unit(int setting
)
38 return audiohw_settings
[setting
].unit
;
41 int sound_numdecimals(int setting
)
43 return audiohw_settings
[setting
].numdecimals
;
46 int sound_steps(int setting
)
48 return audiohw_settings
[setting
].steps
;
51 int sound_min(int setting
)
53 return audiohw_settings
[setting
].minval
;
56 int sound_max(int setting
)
58 return audiohw_settings
[setting
].maxval
;
61 int sound_default(int setting
)
63 return audiohw_settings
[setting
].defaultval
;
66 static sound_set_type
* const sound_set_fns
[] =
68 [0 ... SOUND_LAST_SETTING
-1] = NULL
,
69 [SOUND_VOLUME
] = sound_set_volume
,
70 #if defined(AUDIOHW_HAVE_BASS)
71 [SOUND_BASS
] = sound_set_bass
,
73 #if defined(AUDIOHW_HAVE_TREBLE)
74 [SOUND_TREBLE
] = sound_set_treble
,
76 [SOUND_BALANCE
] = sound_set_balance
,
77 [SOUND_CHANNELS
] = sound_set_channels
,
78 [SOUND_STEREO_WIDTH
] = sound_set_stereo_width
,
79 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
80 [SOUND_LOUDNESS
] = sound_set_loudness
,
81 [SOUND_AVC
] = sound_set_avc
,
82 [SOUND_MDB_STRENGTH
] = sound_set_mdb_strength
,
83 [SOUND_MDB_HARMONICS
] = sound_set_mdb_harmonics
,
84 [SOUND_MDB_CENTER
] = sound_set_mdb_center
,
85 [SOUND_MDB_SHAPE
] = sound_set_mdb_shape
,
86 [SOUND_MDB_ENABLE
] = sound_set_mdb_enable
,
87 [SOUND_SUPERBASS
] = sound_set_superbass
,
88 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
89 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
90 [SOUND_BASS_CUTOFF
] = sound_set_bass_cutoff
,
92 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
93 [SOUND_TREBLE_CUTOFF
] = sound_set_treble_cutoff
,
95 #if defined(AUDIOHW_HAVE_DEPTH_3D)
96 [SOUND_DEPTH_3D
] = sound_set_depth_3d
,
98 /* Hardware EQ tone controls */
99 #if defined(AUDIOHW_HAVE_EQ)
100 [SOUND_EQ_BAND1_GAIN
] = sound_set_hw_eq_band1_gain
,
101 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
102 [SOUND_EQ_BAND1_FREQUENCY
] = sound_set_hw_eq_band1_frequency
,
104 #if defined(AUDIOHW_HAVE_EQ_BAND2)
105 [SOUND_EQ_BAND2_GAIN
] = sound_set_hw_eq_band2_gain
,
106 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
107 [SOUND_EQ_BAND2_FREQUENCY
] = sound_set_hw_eq_band2_frequency
,
109 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
110 [SOUND_EQ_BAND2_WIDTH
] = sound_set_hw_eq_band2_width
,
112 #endif /* AUDIOHW_HAVE_EQ_BAND2 */
113 #if defined(AUDIOHW_HAVE_EQ_BAND3)
114 [SOUND_EQ_BAND3_GAIN
] = sound_set_hw_eq_band3_gain
,
115 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
116 [SOUND_EQ_BAND3_FREQUENCY
] = sound_set_hw_eq_band3_frequency
,
118 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
119 [SOUND_EQ_BAND3_WIDTH
] = sound_set_hw_eq_band3_width
,
121 #endif /* AUDIOHW_HAVE_EQ_BAND3 */
122 #if defined(AUDIOHW_HAVE_EQ_BAND4)
123 [SOUND_EQ_BAND4_GAIN
] = sound_set_hw_eq_band4_gain
,
124 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
125 [SOUND_EQ_BAND4_FREQUENCY
] = sound_set_hw_eq_band4_frequency
,
127 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
128 [SOUND_EQ_BAND4_WIDTH
] = sound_set_hw_eq_band4_width
,
130 #endif /* AUDIOHW_HAVE_EQ_BAND4 */
131 #if defined(AUDIOHW_HAVE_EQ_BAND5)
132 [SOUND_EQ_BAND5_GAIN
] = sound_set_hw_eq_band5_gain
,
133 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
134 [SOUND_EQ_BAND5_FREQUENCY
] = sound_set_hw_eq_band5_frequency
,
136 #endif /* AUDIOHW_HAVE_EQ_BAND5 */
137 #endif /* AUDIOHW_HAVE_EQ */
140 sound_set_type
* sound_get_fn(int setting
)
142 return ((unsigned)setting
>= ARRAYLEN(sound_set_fns
)?
143 NULL
: sound_set_fns
[setting
]);
146 #if CONFIG_CODEC == SWCODEC
147 static int (*dsp_callback
)(int, intptr_t) = NULL
;
149 void sound_set_dsp_callback(int (*func
)(int, intptr_t))
155 #if !defined(AUDIOHW_HAVE_CLIPPING)
157 * The prescaler compensates for any kind of boosts, to prevent clipping.
159 * It's basically just a measure to make sure that audio does not clip during
160 * tone controls processing, like if i want to boost bass 12 dB, i can decrease
161 * the audio amplitude by -12 dB before processing, then increase master gain
162 * by 12 dB after processing.
165 /* all values in tenth of dB MAS3507D UDA1380 */
166 static int current_volume
= 0; /* -780..+180 -840.. 0 */
167 static int current_balance
= 0; /* -960..+960 -840..+840 */
168 #ifdef AUDIOHW_HAVE_TREBLE
169 static int current_treble
= 0; /* -150..+150 0.. +60 */
171 #ifdef AUDIOHW_HAVE_BASS
172 static int current_bass
= 0; /* -150..+150 0..+240 */
174 #ifdef AUDIOHW_HAVE_EQ
175 static int current_eq_band_gain
[AUDIOHW_EQ_BAND_NUM
];
178 static void set_prescaled_volume(void)
183 /* The codecs listed use HW tone controls but don't have suitable prescaler
184 * functionality, so we let the prescaler stay at 0 for these, unless
185 * SW tone controls are in use. This is to avoid needing the SW DSP just for
188 #if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
189 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
190 || defined(HAVE_WM8758) || defined(HAVE_WM8985) || defined(HAVE_UDA1341))
192 #if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
193 prescale
= MAX(current_bass
, current_treble
);
195 #if defined(AUDIOHW_HAVE_EQ)
197 for (i
= 0; i
< AUDIOHW_EQ_BAND_NUM
; i
++)
198 prescale
= MAX(current_eq_band_gain
[i
], prescale
);
202 prescale
= 0; /* no need to prescale if we don't boost
203 bass, treble or eq band */
205 /* Gain up the analog volume to compensate the prescale gain reduction,
206 * but if this would push the volume over the top, reduce prescaling
207 * instead (might cause clipping). */
208 if (current_volume
+ prescale
> VOLUME_MAX
)
209 prescale
= VOLUME_MAX
- current_volume
;
212 #if defined(AUDIOHW_HAVE_PRESCALER)
213 audiohw_set_prescaler(prescale
);
215 dsp_callback(DSP_CALLBACK_SET_PRESCALE
, prescale
);
218 if (current_volume
== VOLUME_MIN
)
219 prescale
= 0; /* Make sure the chip gets muted at VOLUME_MIN */
221 l
= r
= current_volume
+ prescale
;
223 /* Balance the channels scaled by the current volume and min volume. */
224 /* Subtract a dB from VOLUME_MIN to get it to a mute level */
225 if (current_balance
> 0)
227 l
-= ((l
- (VOLUME_MIN
- ONE_DB
)) * current_balance
) / VOLUME_RANGE
;
229 else if (current_balance
< 0)
231 r
+= ((r
- (VOLUME_MIN
- ONE_DB
)) * current_balance
) / VOLUME_RANGE
;
234 #ifdef HAVE_SW_VOLUME_CONTROL
235 dsp_callback(DSP_CALLBACK_SET_SW_VOLUME
, 0);
238 #ifndef HAVE_SDL_AUDIO
239 #if CONFIG_CODEC == MAS3507D
240 dac_volume(tenthdb2reg(l
), tenthdb2reg(r
), false);
241 #elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
242 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
243 || defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_AS3514) \
244 || defined(HAVE_TSC2100) || defined(HAVE_AK4537) || defined(HAVE_UDA1341) \
245 || defined(HAVE_CS42L55) || defined(HAVE_RK27XX_CODEC)
246 audiohw_set_master_vol(tenthdb2master(l
), tenthdb2master(r
));
247 #if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
248 || (defined(HAVE_WM8751) && defined(TOSHIBA_GIGABEAT_F)) \
249 || defined(HAVE_WM8985) || defined(HAVE_CS42L55)
250 audiohw_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
253 #elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985) || defined(HAVE_IMX233_CODEC)
254 audiohw_set_headphone_vol(tenthdb2master(l
), tenthdb2master(r
));
255 #elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
256 audiohw_set_volume(current_volume
);
258 #else /* HAVE_SDL_AUDIO */
259 audiohw_set_volume(current_volume
);
260 #endif /* !HAVE_SDL_AUDIO */
262 #endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
264 void sound_set_volume(int value
)
266 if(!audio_is_initialized
)
269 #if defined(AUDIOHW_HAVE_CLIPPING)
270 audiohw_set_volume(value
);
271 #elif CONFIG_CPU == PNX0101
272 int tmp
= (60 - value
* 4) & 0xff;
273 CODECVOL
= tmp
| (tmp
<< 8);
275 current_volume
= value
* 10; /* tenth of dB */
276 set_prescaled_volume();
280 void sound_set_balance(int value
)
282 if(!audio_is_initialized
)
285 #ifdef AUDIOHW_HAVE_BALANCE
286 audiohw_set_balance(value
);
288 current_balance
= value
* VOLUME_RANGE
/ 100; /* tenth of dB */
289 set_prescaled_volume();
293 #ifdef AUDIOHW_HAVE_BASS
294 void sound_set_bass(int value
)
296 if(!audio_is_initialized
)
299 #if !defined(AUDIOHW_HAVE_CLIPPING)
300 #if defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_CS42L55)
301 current_bass
= value
;
303 current_bass
= value
* 10;
307 #if defined(HAVE_SW_TONE_CONTROLS)
308 dsp_callback(DSP_CALLBACK_SET_BASS
, current_bass
);
310 audiohw_set_bass(value
);
313 #if !defined(AUDIOHW_HAVE_CLIPPING)
314 set_prescaled_volume();
317 #endif /* AUDIOHW_HAVE_BASS */
319 #ifdef AUDIOHW_HAVE_TREBLE
320 void sound_set_treble(int value
)
322 if(!audio_is_initialized
)
325 #if !defined(AUDIOHW_HAVE_CLIPPING)
326 #if defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_CS42L55)
327 current_treble
= value
;
329 current_treble
= value
* 10;
333 #if defined(HAVE_SW_TONE_CONTROLS)
334 dsp_callback(DSP_CALLBACK_SET_TREBLE
, current_treble
);
336 audiohw_set_treble(value
);
339 #if !defined(AUDIOHW_HAVE_CLIPPING)
340 set_prescaled_volume();
343 #endif /* AUDIOHW_HAVE_TREBLE */
345 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
346 void sound_set_bass_cutoff(int value
)
348 if(!audio_is_initialized
)
351 audiohw_set_bass_cutoff(value
);
355 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
356 void sound_set_treble_cutoff(int value
)
358 if(!audio_is_initialized
)
361 audiohw_set_treble_cutoff(value
);
365 void sound_set_channels(int value
)
367 if(!audio_is_initialized
)
370 #if CONFIG_CODEC == SWCODEC
371 dsp_callback(DSP_CALLBACK_SET_CHANNEL_CONFIG
, value
);
373 audiohw_set_channel(value
);
377 void sound_set_stereo_width(int value
)
379 if(!audio_is_initialized
)
382 #if CONFIG_CODEC == SWCODEC
383 dsp_callback(DSP_CALLBACK_SET_STEREO_WIDTH
, value
);
385 audiohw_set_stereo_width(value
);
389 #if defined(AUDIOHW_HAVE_DEPTH_3D)
390 void sound_set_depth_3d(int value
)
392 if(!audio_is_initialized
)
395 audiohw_set_depth_3d(value
);
399 #if defined(AUDIOHW_HAVE_EQ)
400 int sound_enum_hw_eq_band_setting(unsigned int band
,
401 unsigned int band_setting
)
404 sound_hw_eq_band_setting
[AUDIOHW_EQ_SETTING_NUM
][AUDIOHW_EQ_BAND_NUM
] =
408 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
409 [AUDIOHW_EQ_BAND1
] = SOUND_EQ_BAND1_GAIN
,
410 #ifdef AUDIOHW_HAVE_EQ_BAND2
411 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_GAIN
,
413 #ifdef AUDIOHW_HAVE_EQ_BAND3
414 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_GAIN
,
416 #ifdef AUDIOHW_HAVE_EQ_BAND4
417 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_GAIN
,
419 #ifdef AUDIOHW_HAVE_EQ_BAND5
420 [AUDIOHW_EQ_BAND5
] = SOUND_EQ_BAND5_GAIN
,
423 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
424 [AUDIOHW_EQ_FREQUENCY
] =
426 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
427 #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
428 [AUDIOHW_EQ_BAND1
] = SOUND_EQ_BAND1_FREQUENCY
,
430 #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
431 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_FREQUENCY
,
433 #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
434 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_FREQUENCY
,
436 #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
437 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_FREQUENCY
,
439 #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
440 [AUDIOHW_EQ_BAND5
] = SOUND_EQ_BAND5_FREQUENCY
,
443 #endif /* AUDIOHW_HAVE_EQ_FREQUENCY */
444 #ifdef AUDIOHW_HAVE_EQ_WIDTH
447 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
448 #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH
449 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_WIDTH
,
451 #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH
452 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_WIDTH
,
454 #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH
455 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_WIDTH
,
458 #endif /* AUDIOHW_HAVE_EQ_WIDTH */
461 if (band
< AUDIOHW_EQ_BAND_NUM
&& band_setting
< AUDIOHW_EQ_SETTING_NUM
)
462 return sound_hw_eq_band_setting
[band_setting
][band
];
467 static void sound_set_hw_eq_band_gain(unsigned int band
, int value
)
471 if(!audio_is_initialized
)
474 setting
= sound_enum_hw_eq_band_setting(band
, AUDIOHW_EQ_GAIN
);
475 current_eq_band_gain
[band
] = sound_val2phys(setting
+ 0x10000, value
);
477 audiohw_set_eq_band_gain(band
, value
);
478 set_prescaled_volume();
481 void sound_set_hw_eq_band1_gain(int value
)
483 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND1
, value
);
486 #if defined(AUDIOHW_HAVE_EQ_BAND2)
487 void sound_set_hw_eq_band2_gain(int value
)
489 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND2
, value
);
493 #if defined(AUDIOHW_HAVE_EQ_BAND3)
494 void sound_set_hw_eq_band3_gain(int value
)
496 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND3
, value
);
500 #if defined(AUDIOHW_HAVE_EQ_BAND4)
501 void sound_set_hw_eq_band4_gain(int value
)
503 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND4
, value
);
507 #if defined(AUDIOHW_HAVE_EQ_BAND5)
508 void sound_set_hw_eq_band5_gain(int value
)
510 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND5
, value
);
514 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
515 void sound_set_hw_eq_band1_frequency(int value
)
517 if(!audio_is_initialized
)
520 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND1
, value
);
524 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
525 void sound_set_hw_eq_band2_frequency(int value
)
527 if(!audio_is_initialized
)
530 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND2
, value
);
534 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
535 void sound_set_hw_eq_band3_frequency(int value
)
537 if(!audio_is_initialized
)
540 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND3
, value
);
544 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
545 void sound_set_hw_eq_band4_frequency(int value
)
547 if(!audio_is_initialized
)
550 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND4
, value
);
554 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
555 void sound_set_hw_eq_band5_frequency(int value
)
557 if(!audio_is_initialized
)
560 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND5
, value
);
564 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
565 void sound_set_hw_eq_band2_width(int value
)
567 if(!audio_is_initialized
)
570 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND2
, value
);
574 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
575 void sound_set_hw_eq_band3_width(int value
)
577 if(!audio_is_initialized
)
580 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND3
, value
);
584 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
585 void sound_set_hw_eq_band4_width(int value
)
587 if(!audio_is_initialized
)
590 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND4
, value
);
593 #endif /* AUDIOHW_HAVE_EQ */
595 #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F))
596 void sound_set_loudness(int value
)
598 if(!audio_is_initialized
)
601 audiohw_set_loudness(value
);
604 void sound_set_avc(int value
)
606 if(!audio_is_initialized
)
609 audiohw_set_avc(value
);
612 void sound_set_mdb_strength(int value
)
614 if(!audio_is_initialized
)
617 audiohw_set_mdb_strength(value
);
620 void sound_set_mdb_harmonics(int value
)
622 if(!audio_is_initialized
)
625 audiohw_set_mdb_harmonics(value
);
628 void sound_set_mdb_center(int value
)
630 if(!audio_is_initialized
)
633 audiohw_set_mdb_center(value
);
636 void sound_set_mdb_shape(int value
)
638 if(!audio_is_initialized
)
641 audiohw_set_mdb_shape(value
);
644 void sound_set_mdb_enable(int value
)
646 if(!audio_is_initialized
)
649 audiohw_set_mdb_enable(value
);
652 void sound_set_superbass(int value
)
654 if(!audio_is_initialized
)
657 audiohw_set_superbass(value
);
659 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
661 void sound_set(int setting
, int value
)
663 sound_set_type
* sound_set_val
= sound_get_fn(setting
);
665 sound_set_val(value
);
668 #if (!defined(HAVE_AS3514) && !defined(HAVE_WM8975) \
669 && !defined(HAVE_WM8758) && !defined(HAVE_TSC2100) \
670 && !defined (HAVE_WM8711) && !defined (HAVE_WM8721) \
671 && !defined (HAVE_WM8731) && !defined (HAVE_WM8978) \
672 && !defined (HAVE_WM8750) && !defined (HAVE_WM8751) \
673 && !defined(HAVE_AK4537)) || (CONFIG_PLATFORM & PLATFORM_HOSTED)
674 int sound_val2phys(int setting
, int value
)
676 #if CONFIG_CODEC == MAS3587F
681 case SOUND_LEFT_GAIN
:
682 case SOUND_RIGHT_GAIN
:
683 result
= (value
- 2) * 15;
687 result
= value
* 15 + 210;
695 #elif defined(HAVE_UDA1380)
700 #ifdef HAVE_RECORDING
701 case SOUND_LEFT_GAIN
:
702 case SOUND_RIGHT_GAIN
:
704 result
= value
* 5; /* (1/2) * 10 */
712 #elif defined(HAVE_TLV320) || defined(HAVE_WM8711) \
713 || defined(HAVE_WM8721) || defined(HAVE_WM8731)
718 #ifdef HAVE_RECORDING
719 case SOUND_LEFT_GAIN
:
720 case SOUND_RIGHT_GAIN
:
721 result
= (value
- 23) * 15; /* (x - 23)/1.5 *10 */
725 result
= value
* 200; /* 0 or 20 dB */
733 #elif defined(HAVE_AS3514)
734 /* This is here for the sim only and the audio driver has its own */
739 #ifdef HAVE_RECORDING
740 case SOUND_LEFT_GAIN
:
741 case SOUND_RIGHT_GAIN
:
743 result
= (value
- 23) * 15;
752 #elif defined(HAVE_WM8978) || defined(HAVE_WM8750) || defined(HAVE_WM8751)
757 #ifdef HAVE_RECORDING
758 case SOUND_LEFT_GAIN
:
759 case SOUND_RIGHT_GAIN
:
764 #ifdef AUDIOHW_HAVE_DEPTH_3D
766 result
= (100 * value
+ 8) / 15;
779 #endif /* CONFIG_CODECs || PLATFORM_HOSTED */
781 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
782 /* This function works by telling the decoder that we have another
783 crystal frequency than we actually have. It will adjust its internal
784 parameters and the result is that the audio is played at another pitch.
786 The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h)
789 static int last_pitch
= PITCH_SPEED_100
;
791 void sound_set_pitch(int32_t pitch
)
795 if (pitch
!= last_pitch
)
797 /* Calculate the new (bogus) frequency */
798 val
= 18432 * PITCH_SPEED_100
/ pitch
;
800 audiohw_set_pitch(val
);
806 int32_t sound_get_pitch(void)
810 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */