Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
Daniel Ankers | 8300d8c | 2006-09-03 21:00:19 +0000 | [diff] [blame] | 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2002 by Björn Stenberg <bjorn@haxx.se> |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 21 | #include <stdio.h> |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 22 | #include <time.h> |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 23 | #include <stdbool.h> |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 24 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 25 | #include "debug.h" |
Robert Hak | c15b405 | 2002-08-13 08:55:58 +0000 | [diff] [blame] | 26 | |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 27 | #include "screens.h" |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 28 | #include "button.h" |
| 29 | |
Mats Lidell | d5fd94d | 2002-10-11 11:12:00 +0000 | [diff] [blame] | 30 | #include "string.h" |
| 31 | #include "lcd.h" |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 32 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 33 | #include "ata.h" /* for volume definitions */ |
Mats Lidell | d5fd94d | 2002-10-11 11:12:00 +0000 | [diff] [blame] | 34 | |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 35 | extern char having_new_lcd; |
Miika Pekkarinen | eab434c | 2005-07-22 06:32:55 +0000 | [diff] [blame] | 36 | |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 37 | #if CONFIG_CODEC != SWCODEC |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 38 | void audio_set_buffer_margin(int seconds) |
Miika Pekkarinen | 3b6a9f3 | 2005-07-21 12:25:30 +0000 | [diff] [blame] | 39 | { |
| 40 | (void)seconds; |
| 41 | } |
| 42 | #endif |
| 43 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 44 | int fat_startsector(void) |
| 45 | { |
| 46 | return 63; |
| 47 | } |
| 48 | |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 49 | bool fat_ismounted(int volume) |
| 50 | { |
| 51 | (void)volume; |
| 52 | return true; |
| 53 | } |
| 54 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 55 | int ata_write_sectors(IF_MV2(int drive,) |
| 56 | unsigned long start, |
| 57 | int count, |
| 58 | const void* buf) |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 59 | { |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 60 | IF_MV((void)drive;) |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 61 | int i; |
Daniel Ankers | 8300d8c | 2006-09-03 21:00:19 +0000 | [diff] [blame] | 62 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 63 | for (i=0; i<count; i++ ) { |
| 64 | FILE* f; |
| 65 | char name[32]; |
| 66 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 67 | sprintf(name,"sector%lX.bin",start+i); |
Steve Bavin | 076ab8d | 2006-09-28 08:45:40 +0000 | [diff] [blame] | 68 | f=fopen(name,"wb"); |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 69 | if (f) { |
| 70 | fwrite(buf,512,1,f); |
| 71 | fclose(f); |
| 72 | } |
| 73 | } |
| 74 | return 1; |
| 75 | } |
| 76 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 77 | int ata_read_sectors(IF_MV2(int drive,) |
| 78 | unsigned long start, |
| 79 | int count, |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 80 | void* buf) |
| 81 | { |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 82 | IF_MV((void)drive;) |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 83 | int i; |
Daniel Ankers | 8300d8c | 2006-09-03 21:00:19 +0000 | [diff] [blame] | 84 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 85 | for (i=0; i<count; i++ ) { |
| 86 | FILE* f; |
| 87 | char name[32]; |
| 88 | |
Steve Bavin | 076ab8d | 2006-09-28 08:45:40 +0000 | [diff] [blame] | 89 | DEBUGF("Reading sector %lX\n",start+i); |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 90 | sprintf(name,"sector%lX.bin",start+i); |
Steve Bavin | 076ab8d | 2006-09-28 08:45:40 +0000 | [diff] [blame] | 91 | f=fopen(name,"rb"); |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 92 | if (f) { |
| 93 | fread(buf,512,1,f); |
| 94 | fclose(f); |
| 95 | } |
| 96 | } |
| 97 | return 1; |
| 98 | } |
Björn Stenberg | c9d98ca | 2002-08-15 12:42:37 +0000 | [diff] [blame] | 99 | |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 100 | void ata_delayed_write(unsigned long sector, const void* buf) |
Björn Stenberg | c9d98ca | 2002-08-15 12:42:37 +0000 | [diff] [blame] | 101 | { |
Jörg Hohensohn | c540e82 | 2004-12-28 22:38:47 +0000 | [diff] [blame] | 102 | ata_write_sectors(IF_MV2(0,) sector, 1, buf); |
Björn Stenberg | c9d98ca | 2002-08-15 12:42:37 +0000 | [diff] [blame] | 103 | } |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 104 | |
| 105 | void ata_flush(void) |
| 106 | { |
| 107 | } |
Daniel Stenberg | 42564a1 | 2002-08-21 17:24:42 +0000 | [diff] [blame] | 108 | |
Björn Stenberg | 457b8a0 | 2002-08-26 13:21:14 +0000 | [diff] [blame] | 109 | void ata_spin(void) |
| 110 | { |
| 111 | } |
| 112 | |
Jens Arnold | 2bf4178 | 2008-04-13 12:24:47 +0000 | [diff] [blame] | 113 | void ata_sleep(void) |
| 114 | { |
| 115 | DEBUGF("ata_sleep()\n"); |
| 116 | } |
| 117 | |
Björn Stenberg | 457b8a0 | 2002-08-26 13:21:14 +0000 | [diff] [blame] | 118 | void ata_spindown(int s) |
| 119 | { |
| 120 | (void)s; |
| 121 | } |
| 122 | |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 123 | void rtc_init(void) |
| 124 | { |
| 125 | } |
| 126 | |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 127 | int rtc_read(int address) |
| 128 | { |
Dave Chapman | 060320b | 2005-12-11 02:00:28 +0000 | [diff] [blame] | 129 | return address ^ 0x55; |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | int rtc_write(int address, int value) |
| 133 | { |
Linus Nielsen Feltzing | 3351905 | 2004-11-17 12:45:07 +0000 | [diff] [blame] | 134 | (void)address; |
| 135 | (void)value; |
Dave Chapman | 060320b | 2005-12-11 02:00:28 +0000 | [diff] [blame] | 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | int rtc_read_datetime(unsigned char* buf) |
| 140 | { |
| 141 | time_t now = time(NULL); |
| 142 | struct tm *teem = localtime(&now); |
| 143 | |
| 144 | buf[0] = (teem->tm_sec%10) | ((teem->tm_sec/10) << 4); |
| 145 | buf[1] = (teem->tm_min%10) | ((teem->tm_min/10) << 4); |
| 146 | buf[2] = (teem->tm_hour%10) | ((teem->tm_hour/10) << 4); |
| 147 | buf[3] = (teem->tm_wday); |
| 148 | buf[4] = (teem->tm_mday%10) | ((teem->tm_mday/10) << 4); |
| 149 | buf[5] = ((teem->tm_year-100)%10) | (((teem->tm_year-100)/10) << 4); |
| 150 | buf[6] = ((teem->tm_mon+1)%10) | (((teem->tm_mon+1)/10) << 4); |
| 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | int rtc_write_datetime(unsigned char* buf) |
| 156 | { |
| 157 | (void)buf; |
| 158 | return 0; |
Daniel Stenberg | d4d3a5d | 2002-10-11 18:48:22 +0000 | [diff] [blame] | 159 | } |
Daniel Stenberg | b3438e8 | 2002-10-15 07:58:16 +0000 | [diff] [blame] | 160 | |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 161 | #ifdef HAVE_RTC_ALARM |
| 162 | void rtc_get_alarm(int *h, int *m) |
| 163 | { |
| 164 | *h = 11; |
| 165 | *m = 55; |
| 166 | } |
| 167 | |
| 168 | void rtc_set_alarm(int h, int m) |
| 169 | { |
| 170 | (void)h; |
| 171 | (void)m; |
| 172 | } |
| 173 | |
| 174 | bool rtc_enable_alarm(bool enable) |
| 175 | { |
| 176 | return enable; |
| 177 | } |
| 178 | |
Jonathan Gordon | c9d1ab7 | 2007-10-13 12:07:59 +0000 | [diff] [blame] | 179 | extern bool sim_alarm_wakeup; |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 180 | bool rtc_check_alarm_started(bool release_alarm) |
| 181 | { |
Jonathan Gordon | c9d1ab7 | 2007-10-13 12:07:59 +0000 | [diff] [blame] | 182 | (void)release_alarm; |
| 183 | return sim_alarm_wakeup; |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | bool rtc_check_alarm_flag(void) |
| 187 | { |
| 188 | return true; |
| 189 | } |
| 190 | #endif |
| 191 | |
| 192 | #ifdef HAVE_HEADPHONE_DETECTION |
| 193 | bool headphones_inserted(void) |
| 194 | { |
| 195 | return true; |
| 196 | } |
| 197 | #endif |
| 198 | |
| 199 | #ifdef HAVE_LCD_ENABLE |
| 200 | bool lcd_enabled(void) |
| 201 | { |
| 202 | return true; |
| 203 | } |
| 204 | #endif |
| 205 | |
| 206 | bool charging_state(void) |
| 207 | { |
| 208 | return false; |
| 209 | } |
| 210 | |
| 211 | bool charger_inserted(void) |
| 212 | { |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | #ifdef HAVE_SPDIF_POWER |
| 217 | void spdif_power_enable(bool on) |
| 218 | { |
| 219 | (void)on; |
| 220 | } |
| 221 | |
| 222 | bool spdif_powered(void) |
| 223 | { |
| 224 | return false; |
| 225 | } |
| 226 | #endif |
| 227 | |
Jens Arnold | d4e5397 | 2004-11-22 21:20:54 +0000 | [diff] [blame] | 228 | bool is_new_player(void) |
Linus Nielsen Feltzing | 0a4b247 | 2002-10-15 12:25:57 +0000 | [diff] [blame] | 229 | { |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 230 | return having_new_lcd; |
Linus Nielsen Feltzing | 0a4b247 | 2002-10-15 12:25:57 +0000 | [diff] [blame] | 231 | } |
Mats Lidell | a99c565 | 2002-10-18 09:20:14 +0000 | [diff] [blame] | 232 | |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 233 | #ifdef HAVE_USB_POWER |
| 234 | bool usb_powered(void) |
| 235 | { |
| 236 | return false; |
| 237 | } |
| 238 | |
| 239 | #if CONFIG_CHARGING |
| 240 | bool usb_charging_enable(bool on) |
| 241 | { |
| 242 | (void)on; |
| 243 | return false; |
| 244 | } |
| 245 | #endif |
| 246 | #endif |
| 247 | |
| 248 | bool usb_inserted(void) |
| 249 | { |
| 250 | return false; |
| 251 | } |
| 252 | |
| 253 | #ifdef HAVE_REMOTE_LCD_TICKING |
| 254 | void lcd_remote_emireduce(bool state) |
| 255 | { |
| 256 | (void)state; |
| 257 | } |
| 258 | #endif |
| 259 | |
Mats Lidell | a99c565 | 2002-10-18 09:20:14 +0000 | [diff] [blame] | 260 | void lcd_set_contrast( int x ) |
| 261 | { |
| 262 | (void)x; |
| 263 | } |
Björn Stenberg | 5cb429e | 2002-10-18 14:03:11 +0000 | [diff] [blame] | 264 | |
| 265 | void mpeg_set_pitch(int pitch) |
| 266 | { |
| 267 | (void)pitch; |
| 268 | } |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 269 | |
Linus Nielsen Feltzing | 4a66327 | 2002-12-03 22:49:48 +0000 | [diff] [blame] | 270 | static int sleeptime; |
| 271 | void set_sleep_timer(int seconds) |
| 272 | { |
| 273 | sleeptime = seconds; |
| 274 | } |
| 275 | |
| 276 | int get_sleep_timer(void) |
| 277 | { |
| 278 | return sleeptime; |
| 279 | } |
| 280 | |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 281 | #ifdef HAVE_LCD_CHARCELLS |
| 282 | void lcd_clearrect (int x, int y, int nx, int ny) |
| 283 | { |
| 284 | /* Reprint char if you want to change anything */ |
Kjell Ericson | 08cbf69 | 2002-10-21 20:32:23 +0000 | [diff] [blame] | 285 | (void)x; |
| 286 | (void)y; |
| 287 | (void)nx; |
| 288 | (void)ny; |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | void lcd_fillrect (int x, int y, int nx, int ny) |
| 292 | { |
| 293 | /* Reprint char if you want to change display anything */ |
Kjell Ericson | 08cbf69 | 2002-10-21 20:32:23 +0000 | [diff] [blame] | 294 | (void)x; |
| 295 | (void)y; |
| 296 | (void)nx; |
| 297 | (void)ny; |
Kjell Ericson | d19b9ed | 2002-10-21 20:16:14 +0000 | [diff] [blame] | 298 | } |
| 299 | #endif |
Björn Stenberg | c4d8d97 | 2003-02-14 09:44:34 +0000 | [diff] [blame] | 300 | |
| 301 | void cpu_sleep(bool enabled) |
| 302 | { |
| 303 | (void)enabled; |
| 304 | } |
Jörg Hohensohn | a5e1d06 | 2003-12-20 10:00:37 +0000 | [diff] [blame] | 305 | |
| 306 | void button_set_flip(bool yesno) |
| 307 | { |
| 308 | (void)yesno; |
| 309 | } |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 310 | |
Michael Sevakis | 3b730a2 | 2008-05-29 21:53:49 +0000 | [diff] [blame] | 311 | #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING |
| 312 | void touchpad_set_sensitivity(int level) |
| 313 | { |
| 314 | (void)level; |
| 315 | } |
| 316 | #endif |
| 317 | |
Jörg Hohensohn | b1403ee | 2004-07-23 23:01:20 +0000 | [diff] [blame] | 318 | /* assure an unused place to direct virtual pointers to */ |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 319 | #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] | 320 | unsigned char vp_dummy[VIRT_SIZE]; |
| 321 | |