blob: 2357f9baeac0b2cf7c76141e2b586f89ee062ef3 [file] [log] [blame]
Robert Hakc15b4052002-08-13 08:55:58 +00001/***************************************************************************
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 Stenbergcd7691d2002-08-13 17:16:09 +000019#include <stdio.h>
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +000020#include <time.h>
Markus Braun88098be2002-10-11 08:56:23 +000021#include <stdbool.h>
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +000022
Björn Stenbergcd7691d2002-08-13 17:16:09 +000023#include "debug.h"
Robert Hakc15b4052002-08-13 08:55:58 +000024
Markus Braun88098be2002-10-11 08:56:23 +000025#include "screens.h"
Daniel Stenberg42564a12002-08-21 17:24:42 +000026#include "button.h"
Daniel Stenberg7c3dd402002-08-23 13:01:36 +000027#include "menu.h"
Daniel Stenberg42564a12002-08-21 17:24:42 +000028
Mats Lidelld5fd94d2002-10-11 11:12:00 +000029#include "string.h"
30#include "lcd.h"
Daniel Stenberg22b77012005-02-22 12:19:12 +000031
Jörg Hohensohnc540e822004-12-28 22:38:47 +000032#include "ata.h" /* for volume definitions */
Mats Lidelld5fd94d2002-10-11 11:12:00 +000033
Kjell Ericson32622072002-10-28 20:00:19 +000034extern char having_new_lcd;
Miika Pekkarinen05012ac2005-07-15 07:15:39 +000035static bool playing = false;
Kjell Ericson32622072002-10-28 20:00:19 +000036
Miika Pekkarinen20b38972005-07-13 12:48:22 +000037/* Stubs for PCM audio playback. */
38bool pcm_is_playing(void)
39{
Miika Pekkarinen05012ac2005-07-15 07:15:39 +000040 return playing;
Miika Pekkarinen20b38972005-07-13 12:48:22 +000041}
Kjell Ericson32622072002-10-28 20:00:19 +000042
Miika Pekkarinen20b38972005-07-13 12:48:22 +000043void pcm_play_pause(bool state)
44{
45 (void)state;
46}
47
48bool pcm_is_paused(void)
49{
50 return false;
51}
52
53void pcm_play_stop(void)
54{
Miika Pekkarinen05012ac2005-07-15 07:15:39 +000055 playing = false;
Miika Pekkarinen20b38972005-07-13 12:48:22 +000056}
57
58void pcm_init(void)
59{
60}
61
Daniel Stenbergfebb52f2005-07-14 21:46:07 +000062void (*sound_get_pcm)(unsigned char** start, long* size);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000063void pcm_play_data(void (*get_more)(unsigned char** start, long* size))
64{
Daniel Stenbergfebb52f2005-07-14 21:46:07 +000065 sound_get_pcm = get_more;
Miika Pekkarinen05012ac2005-07-15 07:15:39 +000066 playing = true;
Miika Pekkarinen20b38972005-07-13 12:48:22 +000067}
68
Miika Pekkarinene9c0e832005-07-22 06:44:47 +000069long pcm_get_bytes_waiting(void)
Miika Pekkarineneab434c2005-07-22 06:32:55 +000070{
71 return 0;
72}
73
Miika Pekkarinen3b6a9f32005-07-21 12:25:30 +000074#if CONFIG_HWCODEC != MASNONE
75void audio_set_buffer_margin(int seconds)
76{
77 (void)seconds;
78}
79#endif
80
Miika Pekkarinen20b38972005-07-13 12:48:22 +000081/* Generic firmware stubs. */
Robert Hakc15b4052002-08-13 08:55:58 +000082void backlight_on(void)
83{
84 /* we could do something better here! */
85}
86
Kjell Ericson85867862004-06-18 10:05:46 +000087void backlight_off(void)
88{
89 /* we could do something better here! */
90}
91
Robert Hakc15b4052002-08-13 08:55:58 +000092void backlight_time(int dummy)
93{
94 (void)dummy;
95}
Björn Stenbergcd7691d2002-08-13 17:16:09 +000096
97int fat_startsector(void)
98{
99 return 63;
100}
101
Jörg Hohensohnc540e822004-12-28 22:38:47 +0000102int ata_write_sectors(IF_MV2(int drive,)
103 unsigned long start,
104 int count,
105 const void* buf)
Björn Stenbergcd7691d2002-08-13 17:16:09 +0000106{
107 int i;
108
109 for (i=0; i<count; i++ ) {
110 FILE* f;
111 char name[32];
112
Björn Stenbergcd7691d2002-08-13 17:16:09 +0000113 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 Hohensohnc540e822004-12-28 22:38:47 +0000123int ata_read_sectors(IF_MV2(int drive,)
124 unsigned long start,
125 int count,
Björn Stenbergcd7691d2002-08-13 17:16:09 +0000126 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 Stenbergc9d98ca2002-08-15 12:42:37 +0000144
Jörg Hohensohnc540e822004-12-28 22:38:47 +0000145void ata_delayed_write(unsigned long sector, const void* buf)
Björn Stenbergc9d98ca2002-08-15 12:42:37 +0000146{
Jörg Hohensohnc540e822004-12-28 22:38:47 +0000147 ata_write_sectors(IF_MV2(0,) sector, 1, buf);
Björn Stenbergc9d98ca2002-08-15 12:42:37 +0000148}
Björn Stenberg6224cdb2002-08-16 14:41:47 +0000149
150void ata_flush(void)
151{
152}
Daniel Stenberg42564a12002-08-21 17:24:42 +0000153
Björn Stenberg457b8a02002-08-26 13:21:14 +0000154void ata_spin(void)
155{
156}
157
158void ata_spindown(int s)
159{
160 (void)s;
161}
162
Björn Stenberga4c3b032002-09-24 18:04:15 +0000163bool simulate_usb(void)
Daniel Stenberg42564a12002-08-21 17:24:42 +0000164{
165 usb_display_info();
Björn Stenbergb1d51242002-08-21 18:11:06 +0000166 while (button_get(true) & BUTTON_REL);
Björn Stenberga4c3b032002-09-24 18:04:15 +0000167 return false;
Daniel Stenberg42564a12002-08-21 17:24:42 +0000168}
Linus Nielsen Feltzing644e4ce2002-09-03 08:29:03 +0000169
Jörg Hohensohn73681ff2004-01-30 23:27:44 +0000170void backlight_set_timeout(int index)
Daniel Stenbergb95fe1a2002-10-01 10:59:36 +0000171{
Jörg Hohensohn73681ff2004-01-30 23:27:44 +0000172 (void)index;
Daniel Stenbergb95fe1a2002-10-01 10:59:36 +0000173}
Daniel Stenbergc43b36c2002-10-01 11:12:57 +0000174
175void backlight_set_on_when_charging(bool beep)
176{
177 (void)beep;
178}
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +0000179
Jens Arnoldc3b1ece2005-05-30 06:42:14 +0000180void remote_backlight_set_timeout(int index)
181{
182 (void)index;
183}
184
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +0000185int 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 Stenberg6e0a75c2002-10-15 12:24:09 +0000196
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 Stenbergd4d3a5d2002-10-11 18:48:22 +0000208 }
209
210 return address ^ 0x55;
211}
212
213int rtc_write(int address, int value)
214{
Linus Nielsen Feltzing33519052004-11-17 12:45:07 +0000215 (void)address;
216 (void)value;
217 return 0;
Daniel Stenbergd4d3a5d2002-10-11 18:48:22 +0000218}
Daniel Stenbergb3438e82002-10-15 07:58:16 +0000219
Jens Arnoldd4e53972004-11-22 21:20:54 +0000220bool is_new_player(void)
Linus Nielsen Feltzing0a4b2472002-10-15 12:25:57 +0000221{
Kjell Ericson32622072002-10-28 20:00:19 +0000222 return having_new_lcd;
Linus Nielsen Feltzing0a4b2472002-10-15 12:25:57 +0000223}
Mats Lidella99c5652002-10-18 09:20:14 +0000224
225void lcd_set_contrast( int x )
226{
227 (void)x;
228}
Björn Stenberg5cb429e2002-10-18 14:03:11 +0000229
230void mpeg_set_pitch(int pitch)
231{
232 (void)pitch;
233}
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000234
Linus Nielsen Feltzing4a663272002-12-03 22:49:48 +0000235static int sleeptime;
236void set_sleep_timer(int seconds)
237{
238 sleeptime = seconds;
239}
240
241int get_sleep_timer(void)
242{
243 return sleeptime;
244}
245
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000246#ifdef HAVE_LCD_CHARCELLS
247void lcd_clearrect (int x, int y, int nx, int ny)
248{
249 /* Reprint char if you want to change anything */
Kjell Ericson08cbf692002-10-21 20:32:23 +0000250 (void)x;
251 (void)y;
252 (void)nx;
253 (void)ny;
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000254}
255
256void lcd_fillrect (int x, int y, int nx, int ny)
257{
258 /* Reprint char if you want to change display anything */
Kjell Ericson08cbf692002-10-21 20:32:23 +0000259 (void)x;
260 (void)y;
261 (void)nx;
262 (void)ny;
Kjell Ericsond19b9ed2002-10-21 20:16:14 +0000263}
264#endif
Björn Stenbergc4d8d972003-02-14 09:44:34 +0000265
266void cpu_sleep(bool enabled)
267{
268 (void)enabled;
269}
Jörg Hohensohna5e1d062003-12-20 10:00:37 +0000270
271void button_set_flip(bool yesno)
272{
273 (void)yesno;
274}
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000275
Miika Pekkarinen159c52d2005-08-20 11:13:19 +0000276#if CONFIG_HWCODEC != MASNONE
Jörg Hohensohn9568ca62004-04-06 07:21:55 +0000277void talk_init(void)
278{
279}
280
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000281int talk_buffer_steal(void)
282{
283 return 0;
284}
285
Jörg Hohensohn78f06b92004-03-19 22:41:36 +0000286int talk_id(int id, bool enqueue)
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000287{
288 (void)id;
Jörg Hohensohn78f06b92004-03-19 22:41:36 +0000289 (void)enqueue;
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000290 return 0;
291}
292
Jörg Hohensohn78f06b92004-03-19 22:41:36 +0000293int talk_file(char* filename, bool enqueue)
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000294{
295 (void)filename;
Jörg Hohensohn78f06b92004-03-19 22:41:36 +0000296 (void)enqueue;
297 return 0;
298}
299
300int talk_value(int n, int unit, bool enqueue)
301{
302 (void)n;
303 (void)unit;
304 (void)enqueue;
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000305 return 0;
306}
Jörg Hohensohn5495d6e2004-03-21 00:15:16 +0000307
308int talk_number(int n, bool enqueue)
309{
310 (void)n;
311 (void)enqueue;
312 return 0;
313}
Jörg Hohensohn5e4aa642004-03-27 00:42:32 +0000314
Jörg Hohensohnc778aa62004-04-04 20:34:28 +0000315int talk_spell(char* spell, bool enqueue)
316{
317 (void)spell;
318 (void)enqueue;
319 return 0;
320}
321
Linus Nielsen Feltzingcdd236c2005-01-20 22:32:09 +0000322const char* const dir_thumbnail_name = "_dirname.talk";
Jörg Hohensohn687793c2004-10-21 19:07:46 +0000323const char* const file_thumbnail_ext = ".talk";
Miika Pekkarinen159c52d2005-08-20 11:13:19 +0000324#endif
Jörg Hohensohne7b2ed92004-05-01 15:55:41 +0000325
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. */
328void remove_thread(int threadnum)
329{
330 (void)threadnum;
331}
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000332
333/* assure an unused place to direct virtual pointers to */
Daniel Stenberg22b77012005-02-22 12:19:12 +0000334#define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000335unsigned char vp_dummy[VIRT_SIZE];
336