summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/sdl.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-05-15 21:02:47 +0000
committerThomas Martitz <kugel@rockbox.org>2010-05-15 21:02:47 +0000
commit3d0cee8abbaf764958743e8a7851eee94e60a913 (patch)
treea96b1ec825003a71643a7da4707c300f64824f82 /firmware/drivers/audio/sdl.c
parentdcf442e61f21fb2aef5ce7de0547f733557b156e (diff)
downloadrockbox-3d0cee8abbaf764958743e8a7851eee94e60a913.tar.gz
rockbox-3d0cee8abbaf764958743e8a7851eee94e60a913.zip
- Move uisimulator/sdl/*.[ch] into the target tree, under firmware/target/hosted/sdl, uisdl.c is split up across button-sdl.c and system-sdl.c.
- Refactor the program startup. main() is now in main.c like on target, and the implicit application thread will now act as our main thread (previously a separate one was created for this in thread initialization). This is part of Rockbox as an application and is the first step to make an application port from the uisimulator. In a further step the sim bits from the sdl build will be separated out. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26065 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/audio/sdl.c')
-rw-r--r--firmware/drivers/audio/sdl.c186
1 files changed, 186 insertions, 0 deletions
diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c
new file mode 100644
index 0000000000..c063192873
--- /dev/null
+++ b/firmware/drivers/audio/sdl.c
@@ -0,0 +1,186 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2010 Thomas Martitz
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <SDL_audio.h>
23#include "config.h"
24#include "audiohw.h"
25
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 **/
30
31extern void pcm_set_mixer_volume(int);
32
33void audiohw_set_volume(int volume)
34{
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
41}
42
43const 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
109
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) */
120};
121
122/**
123 * stubs here, for the simulator
124 **/
125
126#if defined(AUDIOHW_HAVE_PRESCALER)
127void audiohw_set_prescaler(int value) { (void)value; }
128#endif
129#if defined(AUDIOHW_HAVE_BALANCE)
130void audiohw_set_balance(int value) { (void)value; }
131#endif
132#if defined(AUDIOHW_HAVE_BASS)
133void audiohw_set_bass(int value) { (void)value; }
134#endif
135#if defined(AUDIOHW_HAVE_TREBLE)
136void audiohw_set_treble(int value) { (void)value; }
137#endif
138#if CONFIG_CODEC != SWCODEC
139void audiohw_set_channel(int value) { (void)value; }
140void audiohw_set_stereo_width(int value){ (void)value; }
141#endif
142#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
143void audiohw_set_bass_cutoff(int value) { (void)value; }
144#endif
145#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
146void audiohw_set_treble_cutoff(int value){ (void)value; }
147#endif
148/* EQ-based tone controls */
149#if defined(AUDIOHW_HAVE_EQ)
150void audiohw_set_eq_band_gain(unsigned int band, int value)
151 { (void)band; (void)value; }
152#endif
153#if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
154void audiohw_set_eq_band_frequency(unsigned int band, int value)
155 { (void)band; (void)value; }
156#endif
157#if defined(AUDIOHW_HAVE_EQ_WIDTH)
158void audiohw_set_eq_band_width(unsigned int band, int value)
159 { (void)band; (void)value; }
160#endif
161#if defined(AUDIOHW_HAVE_DEPTH_3D)
162void audiohw_set_depth_3d(int value)
163 { (void)value; }
164#endif
165#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
166int mas_codec_readreg(int reg)
167{
168 (void)reg;
169 return 0;
170}
171
172int mas_codec_writereg(int reg, unsigned int val)
173{
174 (void)reg;
175 (void)val;
176 return 0;
177}
178int mas_writemem(int bank, int addr, const unsigned long* src, int len)
179{
180 (void)bank;
181 (void)addr;
182 (void)src;
183 (void)len;
184 return 0;
185}
186#endif