1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Nicolas Pennequin, Dan Everton, Matthias Mohr
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #if defined(DEBUG) || defined(SIMULATOR)
27 #include "wps_internals.h"
28 #include "skin_buffer.h"
29 #include "settings_list.h"
40 #if defined(SIMULATOR) || defined(__PCTOOL__)
41 extern int wps_verbose_level
;
44 struct debug_token_table
46 enum wps_token_type start_marker
;
49 #define X(name) name, #name
50 struct debug_token_table tokens
[] = {
51 { X(TOKEN_MARKER_CONTROL_TOKENS
) },
52 { X(TOKEN_MARKER_BATTERY
) },
53 { X(TOKEN_MARKER_SOUND
) },
54 { X(TOKEN_MARKER_RTC
) },
55 { X(TOKEN_MARKER_DATABASE
) },
56 { X(TOKEN_MARKER_FILE
) },
57 { X(TOKEN_MARKER_IMAGES
) },
58 { X(TOKEN_MARKER_METADATA
) },
59 { X(TOKEN_MARKER_PLAYBACK_INFO
) },
60 { X(TOKEN_MARKER_PLAYLIST
) },
61 { X(TOKEN_MARKER_MISC
) },
62 { X(TOKEN_MARKER_RECORDING
) },
63 { X(TOKEN_MARKER_END
) },
67 static char *next_str(bool next
) {
68 return next
? "next " : "";
71 static char *get_token_desc(struct wps_token
*token
, char *buf
,
72 int bufsize
, struct wps_data
*data
)
75 #ifndef HAVE_LCD_BITMAP
76 (void)data
; /* kill charcell warning */
78 bool next
= token
->next
;
82 snprintf(buf
, bufsize
, "No token");
85 case WPS_TOKEN_UNKNOWN
:
86 snprintf(buf
, bufsize
, "Unknown token");
89 case WPS_TOKEN_CHARACTER
:
90 if (token
->value
.c
== '\n')
91 snprintf(buf
, bufsize
, "Character '\\n'");
93 snprintf(buf
, bufsize
, "Character '%c'",
97 case WPS_TOKEN_STRING
:
98 snprintf(buf
, bufsize
, "String '%s'",
99 (char*)token
->value
.data
);
101 case WPS_TOKEN_TRANSLATEDSTRING
:
102 snprintf(buf
, bufsize
, "String ID '%d'", token
->value
.i
);
105 #ifdef HAVE_LCD_BITMAP
106 case WPS_TOKEN_ALIGN_LEFT
:
107 snprintf(buf
, bufsize
, "align left");
110 case WPS_TOKEN_ALIGN_CENTER
:
111 snprintf(buf
, bufsize
, "align center");
114 case WPS_TOKEN_ALIGN_RIGHT
:
115 snprintf(buf
, bufsize
, "align right");
119 case WPS_TOKEN_SUBLINE_TIMEOUT
:
120 snprintf(buf
, bufsize
, "subline timeout value: %d",
124 case WPS_TOKEN_CONDITIONAL
:
125 snprintf(buf
, bufsize
, "conditional, %d options",
129 case WPS_TOKEN_CONDITIONAL_START
:
130 snprintf(buf
, bufsize
, "conditional start, next cond: %d",
134 case WPS_TOKEN_CONDITIONAL_OPTION
:
135 snprintf(buf
, bufsize
, "conditional option, next cond: %d",
139 case WPS_TOKEN_CONDITIONAL_END
:
140 snprintf(buf
, bufsize
, "conditional end");
143 #ifdef HAVE_LCD_BITMAP
144 case WPS_TOKEN_LIST_TITLE_TEXT
:
145 snprintf(buf
, bufsize
, "list title text");
147 case WPS_TOKEN_LIST_TITLE_ICON
:
148 snprintf(buf
, bufsize
, "list title icon");
150 case WPS_TOKEN_IMAGE_PRELOAD
:
151 snprintf(buf
, bufsize
, "preload image");
154 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
156 char subimage
= '\0';
157 char label
= token
->value
.i
&0xFF;
158 struct gui_img
*img
= find_image(label
, data
);
159 if (img
&& img
->num_subimages
> 1)
161 int item
= token
->value
.i
>>8;
163 subimage
= 'A' + item
-26;
165 subimage
= 'a' + item
;
167 snprintf(buf
, bufsize
, "display preloaded image '%c%c'",
172 case WPS_TOKEN_IMAGE_DISPLAY
:
173 snprintf(buf
, bufsize
, "display image");
177 #ifdef HAS_BUTTON_HOLD
178 case WPS_TOKEN_MAIN_HOLD
:
179 snprintf(buf
, bufsize
, "mode hold");
183 #ifdef HAS_REMOTE_BUTTON_HOLD
184 case WPS_TOKEN_REMOTE_HOLD
:
185 snprintf(buf
, bufsize
, "mode remote hold");
189 case WPS_TOKEN_REPEAT_MODE
:
190 snprintf(buf
, bufsize
, "mode repeat");
193 case WPS_TOKEN_PLAYBACK_STATUS
:
194 snprintf(buf
, bufsize
, "mode playback");
197 case WPS_TOKEN_RTC_PRESENT
:
198 snprintf(buf
, bufsize
, "rtc: present?");
200 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
201 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
203 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
204 snprintf(buf
, bufsize
,
205 "rtc: day of month, blank padded ( 1..31)");
207 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
208 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
210 case WPS_TOKEN_RTC_HOUR_24
:
211 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
213 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
214 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
216 case WPS_TOKEN_RTC_HOUR_12
:
217 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
219 case WPS_TOKEN_RTC_MONTH
:
220 snprintf(buf
, bufsize
, "rtc: month (01..12)");
222 case WPS_TOKEN_RTC_MINUTE
:
223 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
225 case WPS_TOKEN_RTC_SECOND
:
226 snprintf(buf
, bufsize
, "rtc: second (00..59)");
228 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
229 snprintf(buf
, bufsize
,
230 "rtc: last two digits of year (00..99)");
232 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
233 snprintf(buf
, bufsize
, "rtc: year (1970...)");
235 case WPS_TOKEN_RTC_AM_PM_UPPER
:
236 snprintf(buf
, bufsize
,
237 "rtc: upper case AM or PM indicator");
239 case WPS_TOKEN_RTC_AM_PM_LOWER
:
240 snprintf(buf
, bufsize
,
241 "rtc: lower case am or pm indicator");
243 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
244 snprintf(buf
, bufsize
,
245 "rtc: abbreviated weekday name (Sun..Sat)");
247 case WPS_TOKEN_RTC_MONTH_NAME
:
248 snprintf(buf
, bufsize
,
249 "rtc: abbreviated month name (Jan..Dec)");
251 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
252 snprintf(buf
, bufsize
,
253 "rtc: day of week (1..7); 1 is Monday");
255 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
256 snprintf(buf
, bufsize
,
257 "rtc: day of week (0..6); 0 is Sunday");
260 #if (CONFIG_CODEC == SWCODEC)
261 case WPS_TOKEN_CROSSFADE
:
262 snprintf(buf
, bufsize
, "crossfade");
265 case WPS_TOKEN_REPLAYGAIN
:
266 snprintf(buf
, bufsize
, "replaygain");
271 case WPS_TOKEN_ALBUMART_DISPLAY
:
272 snprintf(buf
, bufsize
, "album art display");
275 case WPS_TOKEN_ALBUMART_FOUND
:
276 snprintf(buf
, bufsize
, "%strack album art conditional",
281 #ifdef HAVE_LCD_BITMAP
282 case WPS_TOKEN_IMAGE_BACKDROP
:
283 snprintf(buf
, bufsize
, "backdrop image");
286 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
287 snprintf(buf
, bufsize
, "progressbar bitmap");
290 case WPS_TOKEN_PEAKMETER
:
291 snprintf(buf
, bufsize
, "peakmeter");
295 case WPS_TOKEN_PROGRESSBAR
:
296 snprintf(buf
, bufsize
, "progressbar");
299 #ifdef HAVE_LCD_CHARCELLS
300 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
301 snprintf(buf
, bufsize
, "full line progressbar");
305 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
306 snprintf(buf
, bufsize
, "time elapsed in track");
309 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
310 snprintf(buf
, bufsize
, "played percentage of track");
313 case WPS_TOKEN_PLAYLIST_ENTRIES
:
314 snprintf(buf
, bufsize
, "number of entries in playlist");
317 case WPS_TOKEN_PLAYLIST_NAME
:
318 snprintf(buf
, bufsize
, "playlist name");
321 case WPS_TOKEN_PLAYLIST_POSITION
:
322 snprintf(buf
, bufsize
, "position in playlist");
325 case WPS_TOKEN_TRACK_TIME_REMAINING
:
326 snprintf(buf
, bufsize
, "time remaining in track");
329 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
330 snprintf(buf
, bufsize
, "playlist shuffle mode");
333 case WPS_TOKEN_TRACK_LENGTH
:
334 snprintf(buf
, bufsize
, "track length");
337 case WPS_TOKEN_VOLUME
:
338 snprintf(buf
, bufsize
, "volume");
341 case WPS_TOKEN_METADATA_ARTIST
:
342 snprintf(buf
, bufsize
, "%strack artist",
346 case WPS_TOKEN_METADATA_COMPOSER
:
347 snprintf(buf
, bufsize
, "%strack composer",
351 case WPS_TOKEN_METADATA_ALBUM
:
352 snprintf(buf
, bufsize
, "%strack album",
356 case WPS_TOKEN_METADATA_GROUPING
:
357 snprintf(buf
, bufsize
, "%strack grouping",
361 case WPS_TOKEN_METADATA_GENRE
:
362 snprintf(buf
, bufsize
, "%strack genre",
366 case WPS_TOKEN_METADATA_DISC_NUMBER
:
367 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
370 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
371 snprintf(buf
, bufsize
, "%strack number",
375 case WPS_TOKEN_METADATA_TRACK_TITLE
:
376 snprintf(buf
, bufsize
, "%strack title",
380 case WPS_TOKEN_METADATA_VERSION
:
381 snprintf(buf
, bufsize
, "%strack ID3 version",
385 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
386 snprintf(buf
, bufsize
, "%strack album artist",
390 case WPS_TOKEN_METADATA_COMMENT
:
391 snprintf(buf
, bufsize
, "%strack comment",
395 case WPS_TOKEN_METADATA_YEAR
:
396 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
400 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
401 snprintf(buf
, bufsize
, "track playcount (database)");
404 case WPS_TOKEN_DATABASE_RATING
:
405 snprintf(buf
, bufsize
, "track rating (database)");
408 case WPS_TOKEN_DATABASE_AUTOSCORE
:
409 snprintf(buf
, bufsize
, "track autoscore (database)");
413 case WPS_TOKEN_BATTERY_PERCENT
:
414 snprintf(buf
, bufsize
, "battery percentage");
417 case WPS_TOKEN_BATTERY_VOLTS
:
418 snprintf(buf
, bufsize
, "battery voltage");
421 case WPS_TOKEN_BATTERY_TIME
:
422 snprintf(buf
, bufsize
, "battery time left");
425 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
426 snprintf(buf
, bufsize
, "battery charger connected");
429 case WPS_TOKEN_BATTERY_CHARGING
:
430 snprintf(buf
, bufsize
, "battery charging");
433 case WPS_TOKEN_BATTERY_SLEEPTIME
:
434 snprintf(buf
, bufsize
, "sleep timer");
437 case WPS_TOKEN_FILE_BITRATE
:
438 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
441 case WPS_TOKEN_FILE_CODEC
:
442 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
445 case WPS_TOKEN_FILE_FREQUENCY
:
446 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
450 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
451 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
455 case WPS_TOKEN_FILE_NAME
:
456 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
459 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
460 snprintf(buf
, bufsize
, "%sfile name with extension",
464 case WPS_TOKEN_FILE_PATH
:
465 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
468 case WPS_TOKEN_FILE_SIZE
:
469 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
472 case WPS_TOKEN_FILE_VBR
:
473 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
476 case WPS_TOKEN_FILE_DIRECTORY
:
477 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
478 next_str(next
), token
->value
.i
);
481 #if (CONFIG_CODEC != MAS3507D)
482 case WPS_TOKEN_SOUND_PITCH
:
483 snprintf(buf
, bufsize
, "pitch value");
487 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
488 case WPS_TOKEN_VLED_HDD
:
489 snprintf(buf
, bufsize
, "display virtual HDD LED");
492 case WPS_VIEWPORT_ENABLE
:
493 snprintf(buf
, bufsize
, "enable VP: %c",
494 (char)token
->value
.i
);
496 case WPS_TOKEN_BUTTON_VOLUME
:
497 snprintf(buf
, bufsize
, "Volume button timeout: %d",
500 case WPS_TOKEN_SETTING
:
501 snprintf(buf
, bufsize
, "Setting value: '%s'",
502 settings
[token
->value
.i
].cfg_name
);
504 case WPS_TOKEN_LANG_IS_RTL
:
505 snprintf(buf
, bufsize
, "lang: is_rtl?");
508 for(i
=1; i
<sizeof(tokens
)/sizeof(*token
); i
++)
510 if (token
->type
< tokens
[i
].start_marker
)
512 snprintf(buf
, bufsize
, "FIXME: %s + %d\n", tokens
[i
-1].desc
,
513 token
->type
- tokens
[i
-1].start_marker
);
523 #if defined(SIMULATOR) || defined(__PCTOOL__)
524 static void dump_skin(struct wps_data
*data
)
530 struct skin_token_list
*viewport_list
;
531 for (viewport_list
= data
->viewports
;
532 viewport_list
; viewport_list
= viewport_list
->next
)
534 struct skin_viewport
*skin_viewport
=
535 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
537 DEBUGF("Viewport: '%c'\n", skin_viewport
->label
);
538 struct skin_line
*line
;
539 for (line
= skin_viewport
->lines
; line
; line
= line
->next
)
541 struct skin_subline
*subline
;
543 for(subline
= &line
->sublines
; subline
; subline
= subline
->next
)
545 DEBUGF(" Subline: tokens %d => %d",
546 subline
->first_token_idx
,subline
->last_token_idx
);
547 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
548 DEBUGF(", scrolled");
549 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
550 DEBUGF(", progressbar");
551 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
552 DEBUGF(", peakmeter");
555 for (i
= subline
->first_token_idx
; i
<= subline
->last_token_idx
; i
++)
557 struct wps_token
*token
= &data
->tokens
[i
];
558 get_token_desc(token
, buf
, sizeof(buf
), data
);
563 case WPS_TOKEN_CONDITIONAL_START
:
567 case WPS_TOKEN_CONDITIONAL_END
:
575 if (wps_verbose_level
> 2)
577 for(j
= 0; j
< indent
; j
++) {
581 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
590 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
592 #if defined(SIMULATOR) || defined(__PCTOOL__)
593 if (debug_wps
&& wps_verbose_level
)
597 #endif /* SIMULATOR */
599 if (fail
!= PARSE_OK
)
603 DEBUGF("ERR: Failed parsing on line %d : ", line
);
609 case PARSE_FAIL_UNCLOSED_COND
:
610 DEBUGF("ERR: Unclosed conditional");
613 case PARSE_FAIL_INVALID_CHAR
:
614 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
616 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
620 case PARSE_FAIL_COND_SYNTAX_ERROR
:
621 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
623 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
627 case PARSE_FAIL_COND_INVALID_PARAM
:
628 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
630 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
), data
)
634 case PARSE_FAIL_LIMITS_EXCEEDED
:
635 DEBUGF("ERR: Limits exceeded");
642 void debug_skin_usage(void)
644 #if defined(SIMULATOR) || defined(__PCTOOL__)
645 if (wps_verbose_level
> 1)
647 DEBUGF("Skin buffer usage: %lu/%lu\n", (unsigned long)skin_buffer_usage(),
648 (unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
651 #endif /* DEBUG || SIMULATOR */