diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-05-15 21:02:47 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-05-15 21:02:47 +0000 |
commit | 3d0cee8abbaf764958743e8a7851eee94e60a913 (patch) | |
tree | a96b1ec825003a71643a7da4707c300f64824f82 /firmware/drivers | |
parent | dcf442e61f21fb2aef5ce7de0547f733557b156e (diff) | |
download | rockbox-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')
-rw-r--r-- | firmware/drivers/audio/sdl.c | 186 | ||||
-rw-r--r-- | firmware/drivers/button.c | 9 |
2 files changed, 190 insertions, 5 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 | |||
31 | extern void pcm_set_mixer_volume(int); | ||
32 | |||
33 | void 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 | |||
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 | ||
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) | ||
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) | ||
167 | { | ||
168 | (void)reg; | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | int mas_codec_writereg(int reg, unsigned int val) | ||
173 | { | ||
174 | (void)reg; | ||
175 | (void)val; | ||
176 | return 0; | ||
177 | } | ||
178 | int 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 | ||
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 100957b77a..f116ad646e 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -429,7 +429,6 @@ void button_init(void) | |||
429 | tick_add_task(button_tick); | 429 | tick_add_task(button_tick); |
430 | } | 430 | } |
431 | 431 | ||
432 | #ifndef SIMULATOR | ||
433 | #ifdef BUTTON_DRIVER_CLOSE | 432 | #ifdef BUTTON_DRIVER_CLOSE |
434 | void button_close(void) | 433 | void button_close(void) |
435 | { | 434 | { |
@@ -443,9 +442,10 @@ void button_close(void) | |||
443 | */ | 442 | */ |
444 | static int button_flip(int button) | 443 | static int button_flip(int button) |
445 | { | 444 | { |
446 | int newbutton; | 445 | int newbutton = button; |
447 | 446 | ||
448 | newbutton = button & | 447 | #ifndef SIMULATOR |
448 | newbutton &= | ||
449 | ~(BUTTON_LEFT | BUTTON_RIGHT | 449 | ~(BUTTON_LEFT | BUTTON_RIGHT |
450 | #if defined(BUTTON_UP) && defined(BUTTON_DOWN) | 450 | #if defined(BUTTON_UP) && defined(BUTTON_DOWN) |
451 | | BUTTON_UP | BUTTON_DOWN | 451 | | BUTTON_UP | BUTTON_DOWN |
@@ -503,7 +503,7 @@ static int button_flip(int button) | |||
503 | if (button & BUTTON_PREV) | 503 | if (button & BUTTON_PREV) |
504 | newbutton |= BUTTON_NEXT; | 504 | newbutton |= BUTTON_NEXT; |
505 | #endif | 505 | #endif |
506 | 506 | #endif /* !SIMULATOR */ | |
507 | return newbutton; | 507 | return newbutton; |
508 | } | 508 | } |
509 | 509 | ||
@@ -523,7 +523,6 @@ void button_set_flip(bool flip) | |||
523 | } | 523 | } |
524 | } | 524 | } |
525 | #endif /* HAVE_LCD_FLIP */ | 525 | #endif /* HAVE_LCD_FLIP */ |
526 | #endif /* SIMULATOR */ | ||
527 | 526 | ||
528 | #ifdef HAVE_BACKLIGHT | 527 | #ifdef HAVE_BACKLIGHT |
529 | void set_backlight_filter_keypress(bool value) | 528 | void set_backlight_filter_keypress(bool value) |