diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-06-18 01:25:47 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-06-18 01:25:47 +0000 |
commit | 4c7da8861891fca35dab5be3c2a21252d09574e9 (patch) | |
tree | d0b480e414e1cac9be36309734b07f8beca4b269 /apps/debug_menu.c | |
parent | 22c15b78c834e1c4bff373a39d02c15bb6664c7c (diff) | |
download | rockbox-4c7da8861891fca35dab5be3c2a21252d09574e9.tar.gz rockbox-4c7da8861891fca35dab5be3c2a21252d09574e9.zip |
Iriver UDA1380 volume and balance handling is now done in sound.c, similar to archos player; removed pcm_set_volume(). Implemented a dB-linear scale. Sorted & bumped plugin api. Removed audio test from the debug menu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6741 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 211 |
1 files changed, 1 insertions, 210 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index f978bc1a54..71f730d2c5 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -59,212 +59,6 @@ | |||
59 | #endif | 59 | #endif |
60 | #include "logfdisp.h" | 60 | #include "logfdisp.h" |
61 | 61 | ||
62 | #ifdef IRIVER_H100 | ||
63 | #include "uda1380.h" | ||
64 | #include "pcm_playback.h" | ||
65 | #include "buffer.h" | ||
66 | |||
67 | #define CHUNK_SIZE 0x100000 /* Transfer CHUNK_SIZE bytes on | ||
68 | each DMA transfer */ | ||
69 | |||
70 | static unsigned char line = 0; | ||
71 | static unsigned char *audio_buffer; | ||
72 | static int audio_pos; | ||
73 | static int audio_size; | ||
74 | |||
75 | static void puts(const char *fmt, ...) | ||
76 | { | ||
77 | char buf[80]; | ||
78 | |||
79 | if (line > 15) | ||
80 | { | ||
81 | lcd_clear_display(); | ||
82 | line = 0; | ||
83 | } | ||
84 | |||
85 | va_list ap; | ||
86 | va_start(ap, fmt); | ||
87 | vsnprintf(buf, sizeof(buf)-1, fmt, ap); | ||
88 | va_end(ap); | ||
89 | |||
90 | lcd_puts(0, line, buf); | ||
91 | lcd_update(); | ||
92 | |||
93 | line++; | ||
94 | } | ||
95 | |||
96 | /* Very basic WAVE-file support.. Just for testing purposes.. */ | ||
97 | int load_wave(char *filename) | ||
98 | { | ||
99 | int f, i, num; | ||
100 | unsigned char buf[32]; | ||
101 | unsigned short *p, *end; | ||
102 | |||
103 | puts("Loading %s..", filename); | ||
104 | |||
105 | f = open(filename, O_RDONLY); | ||
106 | if (f == -1) | ||
107 | { | ||
108 | puts("File not found"); | ||
109 | return -1; | ||
110 | } | ||
111 | |||
112 | memset(buf,0,32); | ||
113 | read(f, buf, 32); | ||
114 | if (memcmp(buf, "RIFF", 4) != 0 || memcmp(buf+8, "WAVE", 4) != 0) | ||
115 | { | ||
116 | puts("Not WAVE"); | ||
117 | return -1; | ||
118 | } | ||
119 | if (buf[12+8] != 1 || buf[12+9] != 0 || /* Check PCM format */ | ||
120 | buf[12+10] != 2 || buf[12+11] != 0) /* Check stereo */ | ||
121 | { | ||
122 | puts("Unsupported format"); | ||
123 | return -1; | ||
124 | } | ||
125 | |||
126 | audio_size = filesize(f) - 0x30; | ||
127 | if (audio_size > 8*1024*1024) | ||
128 | audio_size = 8*1024*1024; | ||
129 | |||
130 | audio_buffer = audiobuf; | ||
131 | |||
132 | puts("Reading %d bytes..", audio_size); | ||
133 | |||
134 | lseek(f, 0x30, SEEK_SET); /* Skip wave header */ | ||
135 | |||
136 | read(f, audio_buffer, audio_size); | ||
137 | close(f); | ||
138 | |||
139 | puts("Changing byte order.."); | ||
140 | end = (unsigned short *)(audio_buffer + audio_size); | ||
141 | p = (unsigned short *)audio_buffer; | ||
142 | while(p < end) | ||
143 | { | ||
144 | /* Swap 128k at a time, to allow the other threads to run */ | ||
145 | num = MIN(0x20000, (int)(end - p)); | ||
146 | for(i = 0;i < num;i++) | ||
147 | { | ||
148 | *p = SWAB16(*p); | ||
149 | p++; | ||
150 | } | ||
151 | yield(); | ||
152 | } | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | /* | ||
158 | Test routined of the UDA1380 codec | ||
159 | - Loads a WAVE file and plays it.. | ||
160 | - Control play/stop, master volume and analog mixer volume | ||
161 | |||
162 | */ | ||
163 | |||
164 | int test_tracknum; | ||
165 | static void test_trackchange(void) | ||
166 | { | ||
167 | test_tracknum++; | ||
168 | } | ||
169 | |||
170 | extern int pcmbuf_unplayed_bytes; | ||
171 | |||
172 | bool uda1380_test(void) | ||
173 | { | ||
174 | long button; | ||
175 | int vol = 0x50; | ||
176 | bool done = false; | ||
177 | char buf[80]; | ||
178 | bool play = true; | ||
179 | int sz; | ||
180 | char *ptr; | ||
181 | |||
182 | lcd_setmargins(0, 0); | ||
183 | lcd_clear_display(); | ||
184 | lcd_update(); | ||
185 | |||
186 | test_tracknum = 1; | ||
187 | |||
188 | line = 0; | ||
189 | |||
190 | if (load_wave("/sample.wav") == -1) | ||
191 | goto exit; | ||
192 | |||
193 | audio_pos = 0; | ||
194 | |||
195 | puts("Playing.."); | ||
196 | |||
197 | audio_pos = 0; | ||
198 | pcm_play_init(); | ||
199 | pcm_set_frequency(44100); | ||
200 | pcm_set_volume(0xff - vol); | ||
201 | |||
202 | ptr = audio_buffer; | ||
203 | for(sz = 0;sz < audio_size;sz += CHUNK_SIZE) | ||
204 | { | ||
205 | if(!pcm_play_add_chunk(ptr, CHUNK_SIZE, test_trackchange)) | ||
206 | break; | ||
207 | ptr += MIN(CHUNK_SIZE, (audio_size - sz)); | ||
208 | } | ||
209 | |||
210 | pcm_play_start(); | ||
211 | |||
212 | while(!done) | ||
213 | { | ||
214 | snprintf(buf, sizeof(buf), "SAR0: %08lx", SAR0); | ||
215 | lcd_puts(0, line, buf); | ||
216 | snprintf(buf, sizeof(buf), "DAR0: %08lx", DAR0); | ||
217 | lcd_puts(0, line+1, buf); | ||
218 | snprintf(buf, sizeof(buf), "BCR0: %08lx", BCR0); | ||
219 | lcd_puts(0, line+2, buf); | ||
220 | snprintf(buf, sizeof(buf), "DCR0: %08lx", DCR0); | ||
221 | lcd_puts(0, line+3, buf); | ||
222 | snprintf(buf, sizeof(buf), "DSR0: %02x", DSR0); | ||
223 | lcd_puts(0, line+4, buf); | ||
224 | snprintf(buf, sizeof(buf), "Track: %d", test_tracknum); | ||
225 | lcd_puts(0, line+5, buf); | ||
226 | snprintf(buf, sizeof(buf), "Unplayed: %08x", pcmbuf_unplayed_bytes); | ||
227 | lcd_puts(0, line+6, buf); | ||
228 | lcd_update(); | ||
229 | |||
230 | button = button_get_w_tmo(HZ/2); | ||
231 | switch(button) | ||
232 | { | ||
233 | case BUTTON_ON: | ||
234 | play = !play; | ||
235 | pcm_play_pause(play); | ||
236 | break; | ||
237 | |||
238 | case BUTTON_UP: | ||
239 | if (vol) | ||
240 | vol--; | ||
241 | |||
242 | uda1380_setvol(vol); | ||
243 | break; | ||
244 | case BUTTON_DOWN: | ||
245 | if (vol < 255) | ||
246 | vol++; | ||
247 | |||
248 | uda1380_setvol(vol); | ||
249 | break; | ||
250 | case BUTTON_OFF: | ||
251 | done = true; | ||
252 | break; | ||
253 | } | ||
254 | |||
255 | if(!pcm_is_playing()) | ||
256 | done = true; | ||
257 | } | ||
258 | |||
259 | pcm_play_stop(); | ||
260 | |||
261 | exit: | ||
262 | sleep(HZ >> 1); /* Sleep 1/2 second to fade out sound */ | ||
263 | |||
264 | return false; | ||
265 | } | ||
266 | #endif | ||
267 | |||
268 | /*---------------------------------------------------*/ | 62 | /*---------------------------------------------------*/ |
269 | /* SPECIAL DEBUG STUFF */ | 63 | /* SPECIAL DEBUG STUFF */ |
270 | /*---------------------------------------------------*/ | 64 | /*---------------------------------------------------*/ |
@@ -469,7 +263,7 @@ static unsigned flash_read_word(unsigned addr) { | |||
469 | Only chips which could be reprogrammed in system will return values. | 263 | Only chips which could be reprogrammed in system will return values. |
470 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | 264 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ |
471 | /* In IRAM to avoid problems when running directly from Flash */ | 265 | /* In IRAM to avoid problems when running directly from Flash */ |
472 | bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | 266 | bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, |
473 | unsigned addr1, unsigned addr2) | 267 | unsigned addr1, unsigned addr2) |
474 | __attribute__ ((section (".icode"))); | 268 | __attribute__ ((section (".icode"))); |
475 | bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | 269 | bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, |
@@ -2006,9 +1800,6 @@ bool debug_menu(void) | |||
2006 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 1800 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
2007 | { "CPU frequency", dbg_cpufreq }, | 1801 | { "CPU frequency", dbg_cpufreq }, |
2008 | #endif | 1802 | #endif |
2009 | #ifdef IRIVER_H100 | ||
2010 | { "Audio test", uda1380_test }, | ||
2011 | #endif | ||
2012 | #if CONFIG_CPU == SH7034 | 1803 | #if CONFIG_CPU == SH7034 |
2013 | #ifdef HAVE_LCD_BITMAP | 1804 | #ifdef HAVE_LCD_BITMAP |
2014 | #ifdef HAVE_RTC | 1805 | #ifdef HAVE_RTC |