blob: 1d0d6c51d833b5e6ca638d5dcfe8b34443179e25 [file] [log] [blame]
Robert Hakc15b4052002-08-13 08:55:58 +00001/***************************************************************************
Daniel Ankers8300d8c2006-09-03 21:00:19 +00002 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Robert Hakc15b4052002-08-13 08:55:58 +00008 * $Id$
9 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000010 * Copyright (C) 2002 by Björn Stenberg <bjorn@haxx.se>
Robert Hakc15b4052002-08-13 08:55:58 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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 Hakc15b4052002-08-13 08:55:58 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
Björn Stenbergcd7691d2002-08-13 17:16:09 +000021#include <stdio.h>
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +000022#include <time.h>
Markus Braun88098be2002-10-11 08:56:23 +000023#include <stdbool.h>
Michael Sevakisfaa01e92009-01-08 11:27:46 +000024#include "thread-sdl.h"
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +000025
Björn Stenbergcd7691d2002-08-13 17:16:09 +000026#include "debug.h"
Robert Hakc15b4052002-08-13 08:55:58 +000027
Markus Braun88098be2002-10-11 08:56:23 +000028#include "screens.h"
Daniel Stenberg42564a12002-08-21 17:24:42 +000029#include "button.h"
30
Mats Lidelld5fd94d2002-10-11 11:12:00 +000031#include "string.h"
32#include "lcd.h"
Daniel Stenberg22b77012005-02-22 12:19:12 +000033
Michael Sevakis58eb7842008-12-03 19:54:25 +000034#include "power.h"
35
Jörg Hohensohnc540e822004-12-28 22:38:47 +000036#include "ata.h" /* for volume definitions */
Mats Lidelld5fd94d2002-10-11 11:12:00 +000037
Kjell Ericson32622072002-10-28 20:00:19 +000038extern char having_new_lcd;
Frank Gevaerts99d39f52008-11-02 02:19:39 +000039static bool storage_spinning = false;
Miika Pekkarineneab434c2005-07-22 06:32:55 +000040
Jens Arnoldd6c05452005-08-29 21:15:27 +000041#if CONFIG_CODEC != SWCODEC
Steve Bavin135cc752008-03-28 12:51:33 +000042void audio_set_buffer_margin(int seconds)
Miika Pekkarinen3b6a9f32005-07-21 12:25:30 +000043{
44 (void)seconds;
45}
46#endif
47
Björn Stenbergcd7691d2002-08-13 17:16:09 +000048int fat_startsector(void)
49{
50 return 63;
51}
52
Nils Wallméniusf28da1a2007-08-12 19:49:03 +000053bool fat_ismounted(int volume)
54{
55 (void)volume;
56 return true;
57}
58
Frank Gevaerts99d39f52008-11-02 02:19:39 +000059int storage_init(void)
60{
61 return 1;
62}
63
64int storage_write_sectors(IF_MV2(int drive,)
Jörg Hohensohnc540e822004-12-28 22:38:47 +000065 unsigned long start,
66 int count,
67 const void* buf)
Björn Stenbergcd7691d2002-08-13 17:16:09 +000068{
Nils Wallméniusf28da1a2007-08-12 19:49:03 +000069 IF_MV((void)drive;)
Björn Stenbergcd7691d2002-08-13 17:16:09 +000070 int i;
Daniel Ankers8300d8c2006-09-03 21:00:19 +000071
Björn Stenbergcd7691d2002-08-13 17:16:09 +000072 for (i=0; i<count; i++ ) {
73 FILE* f;
74 char name[32];
75
Björn Stenbergcd7691d2002-08-13 17:16:09 +000076 sprintf(name,"sector%lX.bin",start+i);
Steve Bavin076ab8d2006-09-28 08:45:40 +000077 f=fopen(name,"wb");
Björn Stenbergcd7691d2002-08-13 17:16:09 +000078 if (f) {
79 fwrite(buf,512,1,f);
80 fclose(f);
81 }
82 }
83 return 1;
84}
85
Frank Gevaerts99d39f52008-11-02 02:19:39 +000086int storage_read_sectors(IF_MV2(int drive,)
Jörg Hohensohnc540e822004-12-28 22:38:47 +000087 unsigned long start,
88 int count,
Björn Stenbergcd7691d2002-08-13 17:16:09 +000089 void* buf)
90{
Nils Wallméniusf28da1a2007-08-12 19:49:03 +000091 IF_MV((void)drive;)
Björn Stenbergcd7691d2002-08-13 17:16:09 +000092 int i;
Daniel Ankers8300d8c2006-09-03 21:00:19 +000093
Björn Stenbergcd7691d2002-08-13 17:16:09 +000094 for (i=0; i<count; i++ ) {
95 FILE* f;
96 char name[32];
97
Steve Bavin076ab8d2006-09-28 08:45:40 +000098 DEBUGF("Reading sector %lX\n",start+i);
Björn Stenbergcd7691d2002-08-13 17:16:09 +000099 sprintf(name,"sector%lX.bin",start+i);
Steve Bavin076ab8d2006-09-28 08:45:40 +0000100 f=fopen(name,"rb");
Björn Stenbergcd7691d2002-08-13 17:16:09 +0000101 if (f) {
102 fread(buf,512,1,f);
103 fclose(f);
104 }
105 }
106 return 1;
107}
Björn Stenbergc9d98ca2002-08-15 12:42:37 +0000108
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000109void storage_spin(void)
Björn Stenbergc9d98ca2002-08-15 12:42:37 +0000110{
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000111 storage_spinning = true;
Björn Stenbergc9d98ca2002-08-15 12:42:37 +0000112}
Björn Stenberg6224cdb2002-08-16 14:41:47 +0000113
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000114void storage_sleep(void)
Björn Stenberg6224cdb2002-08-16 14:41:47 +0000115{
116}
Daniel Stenberg42564a12002-08-21 17:24:42 +0000117
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000118bool storage_disk_is_active(void)
Björn Stenberg457b8a02002-08-26 13:21:14 +0000119{
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000120 return storage_spinning;
Björn Stenberg457b8a02002-08-26 13:21:14 +0000121}
122
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000123void storage_spindown(int s)
Björn Stenberg457b8a02002-08-26 13:21:14 +0000124{
125 (void)s;
Frank Gevaerts99d39f52008-11-02 02:19:39 +0000126 storage_spinning = false;
Björn Stenberg457b8a02002-08-26 13:21:14 +0000127}
128
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000129void rtc_init(void)
130{
131}
132
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +0000133int rtc_read(int address)
134{
Dave Chapman060320b2005-12-11 02:00:28 +0000135 return address ^ 0x55;
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +0000136}
137
138int rtc_write(int address, int value)
139{
Linus Nielsen Feltzing33519052004-11-17 12:45:07 +0000140 (void)address;
141 (void)value;
Dave Chapman060320b2005-12-11 02:00:28 +0000142 return 0;
143}
144
145int rtc_read_datetime(unsigned char* buf)
146{
147 time_t now = time(NULL);
148 struct tm *teem = localtime(&now);
149
150 buf[0] = (teem->tm_sec%10) | ((teem->tm_sec/10) << 4);
151 buf[1] = (teem->tm_min%10) | ((teem->tm_min/10) << 4);
152 buf[2] = (teem->tm_hour%10) | ((teem->tm_hour/10) << 4);
153 buf[3] = (teem->tm_wday);
154 buf[4] = (teem->tm_mday%10) | ((teem->tm_mday/10) << 4);
155 buf[5] = ((teem->tm_year-100)%10) | (((teem->tm_year-100)/10) << 4);
156 buf[6] = ((teem->tm_mon+1)%10) | (((teem->tm_mon+1)/10) << 4);
157
158 return 0;
159}
160
161int rtc_write_datetime(unsigned char* buf)
162{
163 (void)buf;
164 return 0;
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +0000165}
Daniel Stenbergb3438e82002-10-15 07:58:16 +0000166
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000167#ifdef HAVE_RTC_ALARM
168void rtc_get_alarm(int *h, int *m)
169{
170 *h = 11;
171 *m = 55;
172}
173
174void rtc_set_alarm(int h, int m)
175{
176 (void)h;
177 (void)m;
178}
179
180bool rtc_enable_alarm(bool enable)
181{
182 return enable;
183}
184
Jonathan Gordonc9d1ab72007-10-13 12:07:59 +0000185extern bool sim_alarm_wakeup;
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000186bool rtc_check_alarm_started(bool release_alarm)
187{
Jonathan Gordonc9d1ab72007-10-13 12:07:59 +0000188 (void)release_alarm;
189 return sim_alarm_wakeup;
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000190}
191
192bool rtc_check_alarm_flag(void)
193{
194 return true;
195}
196#endif
197
198#ifdef HAVE_HEADPHONE_DETECTION
199bool headphones_inserted(void)
200{
201 return true;
202}
203#endif
204
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000205#ifdef HAVE_SPDIF_POWER
206void spdif_power_enable(bool on)
207{
208 (void)on;
209}
210
211bool spdif_powered(void)
212{
213 return false;
214}
215#endif
216
Jens Arnoldd4e53972004-11-22 21:20:54 +0000217bool is_new_player(void)
Linus Nielsen Feltzing0a4b2472002-10-15 12:25:57 +0000218{
Kjell Ericson32622072002-10-28 20:00:19 +0000219 return having_new_lcd;
Linus Nielsen Feltzing0a4b2472002-10-15 12:25:57 +0000220}
Mats Lidella99c5652002-10-18 09:20:14 +0000221
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000222#ifdef HAVE_USB_POWER
223bool usb_powered(void)
224{
225 return false;
226}
227
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000228bool usb_charging_enable(bool on)
229{
230 (void)on;
231 return false;
232}
233#endif
Michael Sevakisadd677f2008-12-03 20:43:10 +0000234
235#if CONFIG_CHARGING
236bool charger_inserted(void)
237{
238 return false;
239}
240
241bool power_input_present(void)
242{
243 return false;
244}
245
246unsigned int power_input_status(void)
247{
248#ifdef HAVE_BATTERY_SWITCH
249 return POWER_INPUT_BATTERY;
250#else
251 return POWER_INPUT_NONE;
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000252#endif
Michael Sevakisadd677f2008-12-03 20:43:10 +0000253}
254
255bool charging_state(void)
256{
257 return false;
258}
259#endif /* CONFIG_CHARGING */
Nils Wallméniusf28da1a2007-08-12 19:49:03 +0000260
261bool usb_inserted(void)
262{
263 return false;
264}
265
266#ifdef HAVE_REMOTE_LCD_TICKING
267void lcd_remote_emireduce(bool state)
268{
269 (void)state;
270}
271#endif
272
Mats Lidella99c5652002-10-18 09:20:14 +0000273void lcd_set_contrast( int x )
274{
275 (void)x;
276}
Björn Stenberg5cb429e2002-10-18 14:03:11 +0000277
278void mpeg_set_pitch(int pitch)
279{
280 (void)pitch;
281}
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000282
Linus Nielsen Feltzing4a663272002-12-03 22:49:48 +0000283static int sleeptime;
284void set_sleep_timer(int seconds)
285{
286 sleeptime = seconds;
287}
288
289int get_sleep_timer(void)
290{
291 return sleeptime;
292}
293
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000294#ifdef HAVE_LCD_CHARCELLS
295void lcd_clearrect (int x, int y, int nx, int ny)
296{
297 /* Reprint char if you want to change anything */
Kjell Ericson08cbf692002-10-21 20:32:23 +0000298 (void)x;
299 (void)y;
300 (void)nx;
301 (void)ny;
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000302}
303
304void lcd_fillrect (int x, int y, int nx, int ny)
305{
306 /* Reprint char if you want to change display anything */
Kjell Ericson08cbf692002-10-21 20:32:23 +0000307 (void)x;
308 (void)y;
309 (void)nx;
310 (void)ny;
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000311}
312#endif
Björn Stenbergc4d8d972003-02-14 09:44:34 +0000313
314void cpu_sleep(bool enabled)
315{
316 (void)enabled;
317}
Jörg Hohensohna5e1d062003-12-20 10:00:37 +0000318
319void button_set_flip(bool yesno)
320{
321 (void)yesno;
322}
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000323
Michael Sevakis3b730a22008-05-29 21:53:49 +0000324#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
325void touchpad_set_sensitivity(int level)
326{
327 (void)level;
328}
329#endif
330
Michael Sevakis4ed78f52009-01-08 10:15:32 +0000331void system_exception_wait(void)
332{
Michael Sevakis33a7f3a2009-01-08 11:08:22 +0000333 thread_sdl_exception_wait();
Michael Sevakis4ed78f52009-01-08 10:15:32 +0000334}
335
336void system_reboot(void)
337{
Michael Sevakis33a7f3a2009-01-08 11:08:22 +0000338 thread_sdl_exception_wait();
Michael Sevakis4ed78f52009-01-08 10:15:32 +0000339}
340