Changed to runtime playlist initialization
[kugel-rb.git] / apps / main.c
blobaf85db22430e7061ed68621c4f9fb92ad86feee1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Björn Stenberg
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "ata.h"
20 #include "disk.h"
21 #include "fat.h"
22 #include "lcd.h"
23 #include "rtc.h"
24 #include "debug.h"
25 #include "led.h"
26 #include "kernel.h"
27 #include "button.h"
28 #include "tree.h"
29 #include "panic.h"
30 #include "menu.h"
31 #include "system.h"
32 #include "usb.h"
33 #include "powermgmt.h"
34 #include "adc.h"
35 #include "i2c.h"
36 #ifndef DEBUG
37 #include "serial.h"
38 #endif
39 #include "mpeg.h"
40 #include "main_menu.h"
41 #include "thread.h"
42 #include "settings.h"
43 #include "backlight.h"
44 #include "status.h"
45 #include "debug_menu.h"
46 #include "version.h"
47 #include "sprintf.h"
48 #include "font.h"
49 #include "language.h"
50 #include "wps-display.h"
51 #include "playlist.h"
53 char appsversion[]=APPSVERSION;
55 void init(void);
57 void app_main(void)
59 init();
60 browse_root();
63 #ifdef SIMULATOR
65 void init(void)
67 init_threads();
68 lcd_init();
69 font_init();
70 show_logo();
71 settings_reset();
72 settings_load();
73 sleep(HZ/2);
74 mpeg_init( global_settings.volume,
75 global_settings.bass,
76 global_settings.treble,
77 global_settings.balance,
78 global_settings.loudness,
79 global_settings.bass_boost,
80 global_settings.avc,
81 global_settings.channel_config );
82 while (button_get(false) != 0)
83 ; /* Empty the keyboard buffer */
86 #else
88 /* defined in linker script */
89 extern int poolstart[];
90 extern int poolend[];
92 void init(void)
94 int rc, i;
95 struct partinfo* pinfo;
97 system_init();
98 kernel_init();
100 settings_reset();
102 lcd_init();
104 font_init();
105 show_logo();
107 set_irq_level(0);
108 #ifdef DEBUG
109 debug_init();
110 #else
111 serial_setup();
112 #endif
114 i2c_init();
116 #ifdef HAVE_RTC
117 rtc_init();
118 #endif
120 adc_init();
122 usb_init();
124 backlight_init();
126 button_init();
128 rc = ata_init();
129 if(rc)
131 #ifdef HAVE_LCD_BITMAP
132 char str[32];
133 lcd_clear_display();
134 snprintf(str, 31, "ATA error: %d", rc);
135 lcd_puts(0, 1, str);
136 lcd_puts(0, 3, "Press ON to debug");
137 lcd_update();
138 while(button_get(true) != BUTTON_ON);
139 dbg_ports();
140 #endif
141 panicf("ata: %d", rc);
144 pinfo = disk_init();
145 if (!pinfo)
146 panicf("disk: NULL");
148 for ( i=0; i<4; i++ ) {
149 if (!fat_mount(pinfo[i].start))
150 break;
152 if ( i==4 ) {
153 DEBUGF("No partition found, trying to mount sector 0.\n");
154 rc = fat_mount(0);
155 if(rc) {
156 lcd_clear_display();
157 lcd_puts(0,0,"No FAT32");
158 lcd_puts(0,1,"partition!");
159 lcd_update();
160 sleep(HZ);
161 while(1)
162 dbg_partitions();
166 settings_load();
168 mpeg_init( global_settings.volume,
169 global_settings.bass,
170 global_settings.treble,
171 global_settings.balance,
172 global_settings.loudness,
173 global_settings.bass_boost,
174 global_settings.avc,
175 global_settings.channel_config );
177 status_init();
178 usb_start_monitoring();
179 power_init();
180 playlist_init();
183 int main(void)
185 app_main();
187 while(1) {
188 led(true); sleep(HZ/10);
189 led(false); sleep(HZ/10);
191 return 0;
193 #endif