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 /* ypr0 with sdl has separate volume controls */
239 #if !defined(HAVE_SDL_AUDIO) || defined(SAMSUNG_YPR0)
240 #if CONFIG_CODEC == MAS3507D
241 dac_volume(tenthdb2reg(l
), tenthdb2reg(r
), false);
242 #elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
243 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
244 || defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_AS3514) \
245 || defined(HAVE_TSC2100) || defined(HAVE_AK4537) || defined(HAVE_UDA1341) \
246 || defined(HAVE_CS42L55) || defined(HAVE_RK27XX_CODEC)
247 audiohw_set_master_vol(tenthdb2master(l
), tenthdb2master(r
));
248 #if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
249 || (defined(HAVE_WM8751) && defined(TOSHIBA_GIGABEAT_F)) \
250 || defined(HAVE_WM8985) || defined(HAVE_CS42L55)
251 audiohw_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
254 #elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985) || defined(HAVE_IMX233_CODEC) || defined(HAVE_AIC3X)
255 audiohw_set_headphone_vol(tenthdb2master(l
), tenthdb2master(r
));
256 #elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
257 audiohw_set_volume(current_volume
);
259 #else /* HAVE_SDL_AUDIO */
260 audiohw_set_volume(current_volume
);
261 #endif /* !HAVE_SDL_AUDIO */
263 #endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
265 void sound_set_volume(int value
)
267 if(!audio_is_initialized
)
270 #if defined(AUDIOHW_HAVE_CLIPPING)
271 audiohw_set_volume(value
);
272 #elif CONFIG_CPU == PNX0101
273 int tmp
= (60 - value
* 4) & 0xff;
274 CODECVOL
= tmp
| (tmp
<< 8);
276 current_volume
= value
* 10; /* tenth of dB */
277 set_prescaled_volume();
281 void sound_set_balance(int value
)
283 if(!audio_is_initialized
)
286 #ifdef AUDIOHW_HAVE_BALANCE
287 audiohw_set_balance(value
);
289 current_balance
= value
* VOLUME_RANGE
/ 100; /* tenth of dB */
290 set_prescaled_volume();
294 #ifdef AUDIOHW_HAVE_BASS
295 void sound_set_bass(int value
)
297 if(!audio_is_initialized
)
300 #if !defined(AUDIOHW_HAVE_CLIPPING)
301 #if defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_CS42L55)
302 current_bass
= value
;
304 current_bass
= value
* 10;
308 #if defined(HAVE_SW_TONE_CONTROLS)
309 dsp_callback(DSP_CALLBACK_SET_BASS
, current_bass
);
311 audiohw_set_bass(value
);
314 #if !defined(AUDIOHW_HAVE_CLIPPING)
315 set_prescaled_volume();
318 #endif /* AUDIOHW_HAVE_BASS */
320 #ifdef AUDIOHW_HAVE_TREBLE
321 void sound_set_treble(int value
)
323 if(!audio_is_initialized
)
326 #if !defined(AUDIOHW_HAVE_CLIPPING)
327 #if defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_CS42L55)
328 current_treble
= value
;
330 current_treble
= value
* 10;
334 #if defined(HAVE_SW_TONE_CONTROLS)
335 dsp_callback(DSP_CALLBACK_SET_TREBLE
, current_treble
);
337 audiohw_set_treble(value
);
340 #if !defined(AUDIOHW_HAVE_CLIPPING)
341 set_prescaled_volume();
344 #endif /* AUDIOHW_HAVE_TREBLE */
346 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
347 void sound_set_bass_cutoff(int value
)
349 if(!audio_is_initialized
)
352 audiohw_set_bass_cutoff(value
);
356 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
357 void sound_set_treble_cutoff(int value
)
359 if(!audio_is_initialized
)
362 audiohw_set_treble_cutoff(value
);
366 void sound_set_channels(int value
)
368 if(!audio_is_initialized
)
371 #if CONFIG_CODEC == SWCODEC
372 dsp_callback(DSP_CALLBACK_SET_CHANNEL_CONFIG
, value
);
374 audiohw_set_channel(value
);
378 void sound_set_stereo_width(int value
)
380 if(!audio_is_initialized
)
383 #if CONFIG_CODEC == SWCODEC
384 dsp_callback(DSP_CALLBACK_SET_STEREO_WIDTH
, value
);
386 audiohw_set_stereo_width(value
);
390 #if defined(AUDIOHW_HAVE_DEPTH_3D)
391 void sound_set_depth_3d(int value
)
393 if(!audio_is_initialized
)
396 audiohw_set_depth_3d(value
);
400 #if defined(AUDIOHW_HAVE_EQ)
401 int sound_enum_hw_eq_band_setting(unsigned int band
,
402 unsigned int band_setting
)
405 sound_hw_eq_band_setting
[AUDIOHW_EQ_SETTING_NUM
][AUDIOHW_EQ_BAND_NUM
] =
409 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
410 [AUDIOHW_EQ_BAND1
] = SOUND_EQ_BAND1_GAIN
,
411 #ifdef AUDIOHW_HAVE_EQ_BAND2
412 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_GAIN
,
414 #ifdef AUDIOHW_HAVE_EQ_BAND3
415 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_GAIN
,
417 #ifdef AUDIOHW_HAVE_EQ_BAND4
418 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_GAIN
,
420 #ifdef AUDIOHW_HAVE_EQ_BAND5
421 [AUDIOHW_EQ_BAND5
] = SOUND_EQ_BAND5_GAIN
,
424 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
425 [AUDIOHW_EQ_FREQUENCY
] =
427 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
428 #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
429 [AUDIOHW_EQ_BAND1
] = SOUND_EQ_BAND1_FREQUENCY
,
431 #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
432 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_FREQUENCY
,
434 #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
435 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_FREQUENCY
,
437 #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
438 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_FREQUENCY
,
440 #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
441 [AUDIOHW_EQ_BAND5
] = SOUND_EQ_BAND5_FREQUENCY
,
444 #endif /* AUDIOHW_HAVE_EQ_FREQUENCY */
445 #ifdef AUDIOHW_HAVE_EQ_WIDTH
448 [0 ... AUDIOHW_EQ_BAND_NUM
-1] = -1,
449 #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH
450 [AUDIOHW_EQ_BAND2
] = SOUND_EQ_BAND2_WIDTH
,
452 #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH
453 [AUDIOHW_EQ_BAND3
] = SOUND_EQ_BAND3_WIDTH
,
455 #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH
456 [AUDIOHW_EQ_BAND4
] = SOUND_EQ_BAND4_WIDTH
,
459 #endif /* AUDIOHW_HAVE_EQ_WIDTH */
462 if (band
< AUDIOHW_EQ_BAND_NUM
&& band_setting
< AUDIOHW_EQ_SETTING_NUM
)
463 return sound_hw_eq_band_setting
[band_setting
][band
];
468 static void sound_set_hw_eq_band_gain(unsigned int band
, int value
)
472 if(!audio_is_initialized
)
475 setting
= sound_enum_hw_eq_band_setting(band
, AUDIOHW_EQ_GAIN
);
476 current_eq_band_gain
[band
] = sound_val2phys(setting
+ 0x10000, value
);
478 audiohw_set_eq_band_gain(band
, value
);
479 set_prescaled_volume();
482 void sound_set_hw_eq_band1_gain(int value
)
484 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND1
, value
);
487 #if defined(AUDIOHW_HAVE_EQ_BAND2)
488 void sound_set_hw_eq_band2_gain(int value
)
490 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND2
, value
);
494 #if defined(AUDIOHW_HAVE_EQ_BAND3)
495 void sound_set_hw_eq_band3_gain(int value
)
497 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND3
, value
);
501 #if defined(AUDIOHW_HAVE_EQ_BAND4)
502 void sound_set_hw_eq_band4_gain(int value
)
504 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND4
, value
);
508 #if defined(AUDIOHW_HAVE_EQ_BAND5)
509 void sound_set_hw_eq_band5_gain(int value
)
511 sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND5
, value
);
515 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
516 void sound_set_hw_eq_band1_frequency(int value
)
518 if(!audio_is_initialized
)
521 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND1
, value
);
525 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
526 void sound_set_hw_eq_band2_frequency(int value
)
528 if(!audio_is_initialized
)
531 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND2
, value
);
535 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
536 void sound_set_hw_eq_band3_frequency(int value
)
538 if(!audio_is_initialized
)
541 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND3
, value
);
545 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
546 void sound_set_hw_eq_band4_frequency(int value
)
548 if(!audio_is_initialized
)
551 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND4
, value
);
555 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
556 void sound_set_hw_eq_band5_frequency(int value
)
558 if(!audio_is_initialized
)
561 audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND5
, value
);
565 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
566 void sound_set_hw_eq_band2_width(int value
)
568 if(!audio_is_initialized
)
571 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND2
, value
);
575 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
576 void sound_set_hw_eq_band3_width(int value
)
578 if(!audio_is_initialized
)
581 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND3
, value
);
585 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
586 void sound_set_hw_eq_band4_width(int value
)
588 if(!audio_is_initialized
)
591 audiohw_set_eq_band_width(AUDIOHW_EQ_BAND4
, value
);
594 #endif /* AUDIOHW_HAVE_EQ */
596 #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F))
597 void sound_set_loudness(int value
)
599 if(!audio_is_initialized
)
602 audiohw_set_loudness(value
);
605 void sound_set_avc(int value
)
607 if(!audio_is_initialized
)
610 audiohw_set_avc(value
);
613 void sound_set_mdb_strength(int value
)
615 if(!audio_is_initialized
)
618 audiohw_set_mdb_strength(value
);
621 void sound_set_mdb_harmonics(int value
)
623 if(!audio_is_initialized
)
626 audiohw_set_mdb_harmonics(value
);
629 void sound_set_mdb_center(int value
)
631 if(!audio_is_initialized
)
634 audiohw_set_mdb_center(value
);
637 void sound_set_mdb_shape(int value
)
639 if(!audio_is_initialized
)
642 audiohw_set_mdb_shape(value
);
645 void sound_set_mdb_enable(int value
)
647 if(!audio_is_initialized
)
650 audiohw_set_mdb_enable(value
);
653 void sound_set_superbass(int value
)
655 if(!audio_is_initialized
)
658 audiohw_set_superbass(value
);
660 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
662 void sound_set(int setting
, int value
)
664 sound_set_type
* sound_set_val
= sound_get_fn(setting
);
666 sound_set_val(value
);
669 #if (!defined(HAVE_AS3514) && !defined(HAVE_WM8975) \
670 && !defined(HAVE_WM8758) && !defined(HAVE_TSC2100) \
671 && !defined (HAVE_WM8711) && !defined (HAVE_WM8721) \
672 && !defined (HAVE_WM8731) && !defined (HAVE_WM8978) \
673 && !defined (HAVE_WM8750) && !defined (HAVE_WM8751) \
674 && !defined(HAVE_AK4537)) || defined(SIMULATOR)
675 int sound_val2phys(int setting
, int value
)
677 #if CONFIG_CODEC == MAS3587F
682 case SOUND_LEFT_GAIN
:
683 case SOUND_RIGHT_GAIN
:
684 result
= (value
- 2) * 15;
688 result
= value
* 15 + 210;
696 #elif defined(HAVE_UDA1380)
701 #ifdef HAVE_RECORDING
702 case SOUND_LEFT_GAIN
:
703 case SOUND_RIGHT_GAIN
:
705 result
= value
* 5; /* (1/2) * 10 */
713 #elif defined(HAVE_TLV320) || defined(HAVE_WM8711) \
714 || defined(HAVE_WM8721) || defined(HAVE_WM8731)
719 #ifdef HAVE_RECORDING
720 case SOUND_LEFT_GAIN
:
721 case SOUND_RIGHT_GAIN
:
722 result
= (value
- 23) * 15; /* (x - 23)/1.5 *10 */
726 result
= value
* 200; /* 0 or 20 dB */
734 #elif defined(HAVE_AS3514)
735 /* This is here for the sim only and the audio driver has its own */
740 #ifdef HAVE_RECORDING
741 case SOUND_LEFT_GAIN
:
742 case SOUND_RIGHT_GAIN
:
744 result
= (value
- 23) * 15;
753 #elif defined(HAVE_WM8978) || defined(HAVE_WM8750) || defined(HAVE_WM8751)
758 #ifdef HAVE_RECORDING
759 case SOUND_LEFT_GAIN
:
760 case SOUND_RIGHT_GAIN
:
765 #ifdef AUDIOHW_HAVE_DEPTH_3D
767 result
= (100 * value
+ 8) / 15;
780 #endif /* CONFIG_CODECs || PLATFORM_HOSTED */
782 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
783 /* This function works by telling the decoder that we have another
784 crystal frequency than we actually have. It will adjust its internal
785 parameters and the result is that the audio is played at another pitch.
787 The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h)
790 static int last_pitch
= PITCH_SPEED_100
;
792 void sound_set_pitch(int32_t pitch
)
796 if (pitch
!= last_pitch
)
798 /* Calculate the new (bogus) frequency */
799 val
= 18432 * PITCH_SPEED_100
/ pitch
;
801 audiohw_set_pitch(val
);
807 int32_t sound_get_pitch(void)
811 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */