- Move uisimulator/sdl/*.[ch] into the target tree, under firmware/target/hosted...
[kugel-rb.git] / firmware / drivers / audio / sdl.c
blobc063192873b6d26abbc80d92e45b3f7d792af6d3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright © 2010 Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <SDL_audio.h>
23 #include "config.h"
24 #include "audiohw.h"
26 /**
27 * Audio Hardware api. Make them do nothing as we cannot properly simulate with
28 * SDL. if we used DSP we would run code that doesn't actually run on the target
29 **/
31 extern void pcm_set_mixer_volume(int);
33 void audiohw_set_volume(int volume)
35 #if CONFIG_CODEC == SWCODEC
36 pcm_set_mixer_volume(
37 SDL_MIX_MAXVOLUME * ((volume - VOLUME_MIN) / 10) / (VOLUME_RANGE / 10));
38 #else
39 (void)volume;
40 #endif
43 const struct sound_settings_info audiohw_settings[] = {
44 [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25},
45 /* Bass and treble tone controls */
46 #ifdef AUDIOHW_HAVE_BASS
47 [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
48 #endif
49 #ifdef AUDIOHW_HAVE_TREBLE
50 [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
51 #endif
52 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
53 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
54 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
55 #if defined(HAVE_RECORDING)
56 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
57 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
58 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
59 #endif
60 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
61 [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1},
62 #endif
63 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
64 [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
65 #endif
66 #if defined(AUDIOHW_HAVE_DEPTH_3D)
67 [SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0},
68 #endif
69 /* Hardware EQ tone controls */
70 #if defined(AUDIOHW_HAVE_EQ_BAND1)
71 [SOUND_EQ_BAND1_GAIN] = {"dB", 0, 1, -12, 12, 0},
72 #endif
73 #if defined(AUDIOHW_HAVE_EQ_BAND2)
74 [SOUND_EQ_BAND2_GAIN] = {"dB", 0, 1, -12, 12, 0},
75 #endif
76 #if defined(AUDIOHW_HAVE_EQ_BAND3)
77 [SOUND_EQ_BAND3_GAIN] = {"dB", 0, 1, -12, 12, 0},
78 #endif
79 #if defined(AUDIOHW_HAVE_EQ_BAND4)
80 [SOUND_EQ_BAND4_GAIN] = {"dB", 0, 1, -12, 12, 0},
81 #endif
82 #if defined(AUDIOHW_HAVE_EQ_BAND5)
83 [SOUND_EQ_BAND5_GAIN] = {"dB", 0, 1, -12, 12, 0},
84 #endif
85 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
86 [SOUND_EQ_BAND1_FREQUENCY] = {"", 0, 1, 1, 4, 1},
87 #endif
88 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
89 [SOUND_EQ_BAND2_FREQUENCY] = {"", 0, 1, 1, 4, 1},
90 #endif
91 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
92 [SOUND_EQ_BAND3_FREQUENCY] = {"", 0, 1, 1, 4, 1},
93 #endif
94 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
95 [SOUND_EQ_BAND4_FREQUENCY] = {"", 0, 1, 1, 4, 1},
96 #endif
97 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
98 [SOUND_EQ_BAND5_FREQUENCY] = {"", 0, 1, 1, 4, 1},
99 #endif
100 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
101 [SOUND_EQ_BAND2_WIDTH] = {"", 0, 1, 0, 1, 0},
102 #endif
103 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
104 [SOUND_EQ_BAND3_WIDTH] = {"", 0, 1, 0, 1, 0},
105 #endif
106 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
107 [SOUND_EQ_BAND4_WIDTH] = {"", 0, 1, 0, 1, 0},
108 #endif
110 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
111 [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0},
112 [SOUND_AVC] = {"", 0, 1, -1, 4, 0},
113 [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48},
114 [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50},
115 [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60},
116 [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90},
117 [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0},
118 [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0},
119 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
123 * stubs here, for the simulator
126 #if defined(AUDIOHW_HAVE_PRESCALER)
127 void audiohw_set_prescaler(int value) { (void)value; }
128 #endif
129 #if defined(AUDIOHW_HAVE_BALANCE)
130 void audiohw_set_balance(int value) { (void)value; }
131 #endif
132 #if defined(AUDIOHW_HAVE_BASS)
133 void audiohw_set_bass(int value) { (void)value; }
134 #endif
135 #if defined(AUDIOHW_HAVE_TREBLE)
136 void audiohw_set_treble(int value) { (void)value; }
137 #endif
138 #if CONFIG_CODEC != SWCODEC
139 void audiohw_set_channel(int value) { (void)value; }
140 void audiohw_set_stereo_width(int value){ (void)value; }
141 #endif
142 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
143 void audiohw_set_bass_cutoff(int value) { (void)value; }
144 #endif
145 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
146 void audiohw_set_treble_cutoff(int value){ (void)value; }
147 #endif
148 /* EQ-based tone controls */
149 #if defined(AUDIOHW_HAVE_EQ)
150 void audiohw_set_eq_band_gain(unsigned int band, int value)
151 { (void)band; (void)value; }
152 #endif
153 #if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
154 void audiohw_set_eq_band_frequency(unsigned int band, int value)
155 { (void)band; (void)value; }
156 #endif
157 #if defined(AUDIOHW_HAVE_EQ_WIDTH)
158 void audiohw_set_eq_band_width(unsigned int band, int value)
159 { (void)band; (void)value; }
160 #endif
161 #if defined(AUDIOHW_HAVE_DEPTH_3D)
162 void audiohw_set_depth_3d(int value)
163 { (void)value; }
164 #endif
165 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
166 int mas_codec_readreg(int reg)
168 (void)reg;
169 return 0;
172 int mas_codec_writereg(int reg, unsigned int val)
174 (void)reg;
175 (void)val;
176 return 0;
178 int mas_writemem(int bank, int addr, const unsigned long* src, int len)
180 (void)bank;
181 (void)addr;
182 (void)src;
183 (void)len;
184 return 0;
186 #endif