Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 by Björn Stenberg <bjorn@haxx.se> |
| 11 | * |
| 12 | * All files in this archive are subject to the GNU General Public License. |
| 13 | * See the file COPYING in the source tree root for full license agreement. |
| 14 | * |
| 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 16 | * KIND, either express or implied. |
| 17 | * |
| 18 | ****************************************************************************/ |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 19 | #include <stdio.h> |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 20 | #include <time.h> |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 21 | #include <stdbool.h> |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 22 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 23 | #include "debug.h" |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 24 | |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 25 | #include "screens.h" |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 26 | #include "button.h" |
Daniel Stenberg | 7c3dd40 | 2002-08-23 13:01:36 +0000 | [diff] [blame] | 27 | #include "menu.h" |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 28 | |
Mats Lidell | d5fd94d | 2002-10-11 11:12:00 +0000 | [diff] [blame] | 29 | #include "string.h" |
| 30 | #include "lcd.h" |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 31 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 32 | #include "ata.h" /* for volume definitions */ |
Mats Lidell | d5fd94d | 2002-10-11 11:12:00 +0000 | [diff] [blame] | 33 | |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 34 | extern char having_new_lcd; |
Miika Pekkarinen | 05012ac | 2005-07-15 07:15:39 +0000 | [diff] [blame] | 35 | static bool playing = false; |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 36 | |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 37 | /* Stubs for PCM audio playback. */ |
| 38 | bool pcm_is_playing(void) |
| 39 | { |
Miika Pekkarinen | 05012ac | 2005-07-15 07:15:39 +0000 | [diff] [blame] | 40 | return playing; |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 41 | } |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 42 | |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 43 | void pcm_play_pause(bool state) |
| 44 | { |
| 45 | (void)state; |
| 46 | } |
| 47 | |
| 48 | bool pcm_is_paused(void) |
| 49 | { |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | void pcm_play_stop(void) |
| 54 | { |
Miika Pekkarinen | 05012ac | 2005-07-15 07:15:39 +0000 | [diff] [blame] | 55 | playing = false; |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void pcm_init(void) |
| 59 | { |
| 60 | } |
| 61 | |
Daniel Stenberg | febb52f | 2005-07-14 21:46:07 +0000 | [diff] [blame] | 62 | void (*sound_get_pcm)(unsigned char** start, long* size); |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 63 | void pcm_play_data(void (*get_more)(unsigned char** start, long* size)) |
| 64 | { |
Daniel Stenberg | febb52f | 2005-07-14 21:46:07 +0000 | [diff] [blame] | 65 | sound_get_pcm = get_more; |
Miika Pekkarinen | 05012ac | 2005-07-15 07:15:39 +0000 | [diff] [blame] | 66 | playing = true; |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Miika Pekkarinen | e9c0e83 | 2005-07-22 06:44:47 +0000 | [diff] [blame] | 69 | long pcm_get_bytes_waiting(void) |
Miika Pekkarinen | eab434c | 2005-07-22 06:32:55 +0000 | [diff] [blame] | 70 | { |
| 71 | return 0; |
| 72 | } |
| 73 | |
Miika Pekkarinen | 3b6a9f3 | 2005-07-21 12:25:30 +0000 | [diff] [blame] | 74 | #if CONFIG_HWCODEC != MASNONE |
| 75 | void audio_set_buffer_margin(int seconds) |
| 76 | { |
| 77 | (void)seconds; |
| 78 | } |
| 79 | #endif |
| 80 | |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 81 | /* Generic firmware stubs. */ |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 82 | void backlight_on(void) |
| 83 | { |
| 84 | /* we could do something better here! */ |
| 85 | } |
| 86 | |
Kjell Ericson | 8586786 | 2004-06-18 10:05:46 +0000 | [diff] [blame] | 87 | void backlight_off(void) |
| 88 | { |
| 89 | /* we could do something better here! */ |
| 90 | } |
| 91 | |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 92 | void backlight_time(int dummy) |
| 93 | { |
| 94 | (void)dummy; |
| 95 | } |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 96 | |
| 97 | int fat_startsector(void) |
| 98 | { |
| 99 | return 63; |
| 100 | } |
| 101 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 102 | int ata_write_sectors(IF_MV2(int drive,) |
| 103 | unsigned long start, |
| 104 | int count, |
| 105 | const void* buf) |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 106 | { |
| 107 | int i; |
| 108 | |
| 109 | for (i=0; i<count; i++ ) { |
| 110 | FILE* f; |
| 111 | char name[32]; |
| 112 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 113 | sprintf(name,"sector%lX.bin",start+i); |
| 114 | f=fopen(name,"w"); |
| 115 | if (f) { |
| 116 | fwrite(buf,512,1,f); |
| 117 | fclose(f); |
| 118 | } |
| 119 | } |
| 120 | return 1; |
| 121 | } |
| 122 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 123 | int ata_read_sectors(IF_MV2(int drive,) |
| 124 | unsigned long start, |
| 125 | int count, |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 126 | void* buf) |
| 127 | { |
| 128 | int i; |
| 129 | |
| 130 | for (i=0; i<count; i++ ) { |
| 131 | FILE* f; |
| 132 | char name[32]; |
| 133 | |
| 134 | DEBUGF("Reading sector %X\n",start+i); |
| 135 | sprintf(name,"sector%lX.bin",start+i); |
| 136 | f=fopen(name,"r"); |
| 137 | if (f) { |
| 138 | fread(buf,512,1,f); |
| 139 | fclose(f); |
| 140 | } |
| 141 | } |
| 142 | return 1; |
| 143 | } |
Björn Stenberg | c9d98ca | 2002-08-15 12:42:37 +0000 | [diff] [blame] | 144 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 145 | void ata_delayed_write(unsigned long sector, const void* buf) |
Björn Stenberg | c9d98ca | 2002-08-15 12:42:37 +0000 | [diff] [blame] | 146 | { |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 147 | ata_write_sectors(IF_MV2(0,) sector, 1, buf); |
Björn Stenberg | c9d98ca | 2002-08-15 12:42:37 +0000 | [diff] [blame] | 148 | } |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 149 | |
| 150 | void ata_flush(void) |
| 151 | { |
| 152 | } |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 153 | |
Björn Stenberg | 457b8a0 | 2002-08-26 13:21:14 +0000 | [diff] [blame] | 154 | void ata_spin(void) |
| 155 | { |
| 156 | } |
| 157 | |
| 158 | void ata_spindown(int s) |
| 159 | { |
| 160 | (void)s; |
| 161 | } |
| 162 | |
Björn Stenberg | a4c3b03 | 2002-09-24 18:04:15 +0000 | [diff] [blame] | 163 | bool simulate_usb(void) |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 164 | { |
| 165 | usb_display_info(); |
Björn Stenberg | b1d5124 | 2002-08-21 18:11:06 +0000 | [diff] [blame] | 166 | while (button_get(true) & BUTTON_REL); |
Björn Stenberg | a4c3b03 | 2002-09-24 18:04:15 +0000 | [diff] [blame] | 167 | return false; |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 168 | } |
Linus Nielsen Feltzing | 644e4ce | 2002-09-03 08:29:03 +0000 | [diff] [blame] | 169 | |
Jörg Hohensohn | 73681ff | 2004-01-30 23:27:44 +0000 | [diff] [blame] | 170 | void backlight_set_timeout(int index) |
Daniel Stenberg | b95fe1a | 2002-10-01 10:59:36 +0000 | [diff] [blame] | 171 | { |
Jörg Hohensohn | 73681ff | 2004-01-30 23:27:44 +0000 | [diff] [blame] | 172 | (void)index; |
Daniel Stenberg | b95fe1a | 2002-10-01 10:59:36 +0000 | [diff] [blame] | 173 | } |
Daniel Stenberg | c43b36c | 2002-10-01 11:12:57 +0000 | [diff] [blame] | 174 | |
| 175 | void backlight_set_on_when_charging(bool beep) |
| 176 | { |
| 177 | (void)beep; |
| 178 | } |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 179 | |
Jens Arnold | c3b1ece | 2005-05-30 06:42:14 +0000 | [diff] [blame] | 180 | void remote_backlight_set_timeout(int index) |
| 181 | { |
| 182 | (void)index; |
| 183 | } |
| 184 | |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 185 | int rtc_read(int address) |
| 186 | { |
| 187 | time_t now = time(NULL); |
| 188 | struct tm *teem = localtime(&now); |
| 189 | |
| 190 | switch(address) { |
| 191 | case 3: /* hour */ |
| 192 | return (teem->tm_hour%10) | ((teem->tm_hour/10) << 4); |
| 193 | |
| 194 | case 2: /* minute */ |
| 195 | return (teem->tm_min%10) | ((teem->tm_min/10) << 4); |
Daniel Stenberg | 6e0a75c | 2002-10-15 12:24:09 +0000 | [diff] [blame] | 196 | |
| 197 | case 1: /* seconds */ |
| 198 | return (teem->tm_sec%10) | ((teem->tm_sec/10) << 4); |
| 199 | |
| 200 | case 7: /* year */ |
| 201 | return ((teem->tm_year-100)%10) | (((teem->tm_year-100)/10) << 4); |
| 202 | |
| 203 | case 6: /* month */ |
| 204 | return ((teem->tm_mon+1)%10) | (((teem->tm_mon+1)/10) << 4); |
| 205 | |
| 206 | case 5: /* day */ |
| 207 | return (teem->tm_mday%10) | ((teem->tm_mday/10) << 4); |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | return address ^ 0x55; |
| 211 | } |
| 212 | |
| 213 | int rtc_write(int address, int value) |
| 214 | { |
Linus Nielsen Feltzing | 3351905 | 2004-11-17 12:45:07 +0000 | [diff] [blame] | 215 | (void)address; |
| 216 | (void)value; |
| 217 | return 0; |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 218 | } |
Daniel Stenberg | b3438e8 | 2002-10-15 07:58:16 +0000 | [diff] [blame] | 219 | |
Jens Arnold | d4e5397 | 2004-11-22 21:20:54 +0000 | [diff] [blame] | 220 | bool is_new_player(void) |
Linus Nielsen Feltzing | 0a4b247 | 2002-10-15 12:25:57 +0000 | [diff] [blame] | 221 | { |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 222 | return having_new_lcd; |
Linus Nielsen Feltzing | 0a4b247 | 2002-10-15 12:25:57 +0000 | [diff] [blame] | 223 | } |
Mats Lidell | a99c565 | 2002-10-18 09:20:14 +0000 | [diff] [blame] | 224 | |
| 225 | void lcd_set_contrast( int x ) |
| 226 | { |
| 227 | (void)x; |
| 228 | } |
Björn Stenberg | 5cb429e | 2002-10-18 14:03:11 +0000 | [diff] [blame] | 229 | |
| 230 | void mpeg_set_pitch(int pitch) |
| 231 | { |
| 232 | (void)pitch; |
| 233 | } |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 234 | |
Linus Nielsen Feltzing | 4a66327 | 2002-12-03 22:49:48 +0000 | [diff] [blame] | 235 | static int sleeptime; |
| 236 | void set_sleep_timer(int seconds) |
| 237 | { |
| 238 | sleeptime = seconds; |
| 239 | } |
| 240 | |
| 241 | int get_sleep_timer(void) |
| 242 | { |
| 243 | return sleeptime; |
| 244 | } |
| 245 | |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 246 | #ifdef HAVE_LCD_CHARCELLS |
| 247 | void lcd_clearrect (int x, int y, int nx, int ny) |
| 248 | { |
| 249 | /* Reprint char if you want to change anything */ |
Kjell Ericson | 08cbf69 | 2002-10-21 20:32:23 +0000 | [diff] [blame] | 250 | (void)x; |
| 251 | (void)y; |
| 252 | (void)nx; |
| 253 | (void)ny; |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | void lcd_fillrect (int x, int y, int nx, int ny) |
| 257 | { |
| 258 | /* Reprint char if you want to change display anything */ |
Kjell Ericson | 08cbf69 | 2002-10-21 20:32:23 +0000 | [diff] [blame] | 259 | (void)x; |
| 260 | (void)y; |
| 261 | (void)nx; |
| 262 | (void)ny; |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 263 | } |
| 264 | #endif |
Björn Stenberg | c4d8d97 | 2003-02-14 09:44:34 +0000 | [diff] [blame] | 265 | |
| 266 | void cpu_sleep(bool enabled) |
| 267 | { |
| 268 | (void)enabled; |
| 269 | } |
Jörg Hohensohn | a5e1d06 | 2003-12-20 10:00:37 +0000 | [diff] [blame] | 270 | |
| 271 | void button_set_flip(bool yesno) |
| 272 | { |
| 273 | (void)yesno; |
| 274 | } |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 275 | |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame^] | 276 | #if CONFIG_HWCODEC != MASNONE |
Jörg Hohensohn | 9568ca6 | 2004-04-06 07:21:55 +0000 | [diff] [blame] | 277 | void talk_init(void) |
| 278 | { |
| 279 | } |
| 280 | |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 281 | int talk_buffer_steal(void) |
| 282 | { |
| 283 | return 0; |
| 284 | } |
| 285 | |
Jörg Hohensohn | 78f06b9 | 2004-03-19 22:41:36 +0000 | [diff] [blame] | 286 | int talk_id(int id, bool enqueue) |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 287 | { |
| 288 | (void)id; |
Jörg Hohensohn | 78f06b9 | 2004-03-19 22:41:36 +0000 | [diff] [blame] | 289 | (void)enqueue; |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | |
Jörg Hohensohn | 78f06b9 | 2004-03-19 22:41:36 +0000 | [diff] [blame] | 293 | int talk_file(char* filename, bool enqueue) |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 294 | { |
| 295 | (void)filename; |
Jörg Hohensohn | 78f06b9 | 2004-03-19 22:41:36 +0000 | [diff] [blame] | 296 | (void)enqueue; |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | int talk_value(int n, int unit, bool enqueue) |
| 301 | { |
| 302 | (void)n; |
| 303 | (void)unit; |
| 304 | (void)enqueue; |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 305 | return 0; |
| 306 | } |
Jörg Hohensohn | 5495d6e | 2004-03-21 00:15:16 +0000 | [diff] [blame] | 307 | |
| 308 | int talk_number(int n, bool enqueue) |
| 309 | { |
| 310 | (void)n; |
| 311 | (void)enqueue; |
| 312 | return 0; |
| 313 | } |
Jörg Hohensohn | 5e4aa64 | 2004-03-27 00:42:32 +0000 | [diff] [blame] | 314 | |
Jörg Hohensohn | c778aa6 | 2004-04-04 20:34:28 +0000 | [diff] [blame] | 315 | int talk_spell(char* spell, bool enqueue) |
| 316 | { |
| 317 | (void)spell; |
| 318 | (void)enqueue; |
| 319 | return 0; |
| 320 | } |
| 321 | |
Linus Nielsen Feltzing | cdd236c | 2005-01-20 22:32:09 +0000 | [diff] [blame] | 322 | const char* const dir_thumbnail_name = "_dirname.talk"; |
Jörg Hohensohn | 687793c | 2004-10-21 19:07:46 +0000 | [diff] [blame] | 323 | const char* const file_thumbnail_ext = ".talk"; |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame^] | 324 | #endif |
Jörg Hohensohn | e7b2ed9 | 2004-05-01 15:55:41 +0000 | [diff] [blame] | 325 | |
| 326 | /* FIXME: this shoudn't be a stub, rather the real thing. |
| 327 | I'm afraid on Win32/X11 it'll be hard to kill a thread from outside. */ |
| 328 | void remove_thread(int threadnum) |
| 329 | { |
| 330 | (void)threadnum; |
| 331 | } |
Jörg Hohensohn | b1403ee | 2004-07-23 23:01:20 +0000 | [diff] [blame] | 332 | |
| 333 | /* assure an unused place to direct virtual pointers to */ |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 334 | #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */ |
Jörg Hohensohn | b1403ee | 2004-07-23 23:01:20 +0000 | [diff] [blame] | 335 | unsigned char vp_dummy[VIRT_SIZE]; |
| 336 | |