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_TUNER
) },
64 { X(TOKEN_MARKER_END
) },
68 static char *next_str(bool next
) {
69 return next
? "next " : "";
72 static char *get_token_desc(struct wps_token
*token
, char *buf
,
73 int bufsize
, struct wps_data
*data
)
76 #ifndef HAVE_LCD_BITMAP
77 (void)data
; /* kill charcell warning */
79 bool next
= token
->next
;
83 snprintf(buf
, bufsize
, "No token");
86 case WPS_TOKEN_UNKNOWN
:
87 snprintf(buf
, bufsize
, "Unknown token");
90 case WPS_TOKEN_CHARACTER
:
91 if (token
->value
.c
== '\n')
92 snprintf(buf
, bufsize
, "Character '\\n'");
94 snprintf(buf
, bufsize
, "Character '%c'",
98 case WPS_TOKEN_STRING
:
99 snprintf(buf
, bufsize
, "String '%s'",
100 (char*)token
->value
.data
);
102 case WPS_TOKEN_TRANSLATEDSTRING
:
103 snprintf(buf
, bufsize
, "String ID '%d'", token
->value
.i
);
106 #ifdef HAVE_LCD_BITMAP
107 case WPS_TOKEN_ALIGN_LEFT
:
108 snprintf(buf
, bufsize
, "align left");
111 case WPS_TOKEN_ALIGN_CENTER
:
112 snprintf(buf
, bufsize
, "align center");
115 case WPS_TOKEN_ALIGN_RIGHT
:
116 snprintf(buf
, bufsize
, "align right");
120 case WPS_TOKEN_SUBLINE_TIMEOUT
:
121 snprintf(buf
, bufsize
, "subline timeout value: %d",
125 case WPS_TOKEN_CONDITIONAL
:
126 snprintf(buf
, bufsize
, "conditional, %d options",
130 case WPS_TOKEN_CONDITIONAL_START
:
131 snprintf(buf
, bufsize
, "conditional start, next cond: %d",
135 case WPS_TOKEN_CONDITIONAL_OPTION
:
136 snprintf(buf
, bufsize
, "conditional option, next cond: %d",
140 case WPS_TOKEN_CONDITIONAL_END
:
141 snprintf(buf
, bufsize
, "conditional end");
144 #ifdef HAVE_LCD_BITMAP
145 case WPS_TOKEN_LIST_TITLE_TEXT
:
146 snprintf(buf
, bufsize
, "list title text");
148 case WPS_TOKEN_LIST_TITLE_ICON
:
149 snprintf(buf
, bufsize
, "list title icon");
151 case WPS_TOKEN_IMAGE_PRELOAD
:
152 snprintf(buf
, bufsize
, "preload image");
155 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
157 char subimage
= '\0';
158 char label
= token
->value
.i
&0xFF;
159 struct gui_img
*img
= find_image(label
, data
);
160 if (img
&& img
->num_subimages
> 1)
162 int item
= token
->value
.i
>>8;
164 subimage
= 'A' + item
-26;
166 subimage
= 'a' + item
;
168 snprintf(buf
, bufsize
, "display preloaded image '%c%c'",
173 case WPS_TOKEN_IMAGE_DISPLAY
:
174 snprintf(buf
, bufsize
, "display image");
178 #ifdef HAS_BUTTON_HOLD
179 case WPS_TOKEN_MAIN_HOLD
:
180 snprintf(buf
, bufsize
, "mode hold");
184 #ifdef HAS_REMOTE_BUTTON_HOLD
185 case WPS_TOKEN_REMOTE_HOLD
:
186 snprintf(buf
, bufsize
, "mode remote hold");
190 case WPS_TOKEN_REPEAT_MODE
:
191 snprintf(buf
, bufsize
, "mode repeat");
194 case WPS_TOKEN_PLAYBACK_STATUS
:
195 snprintf(buf
, bufsize
, "mode playback");
198 case WPS_TOKEN_RTC_PRESENT
:
199 snprintf(buf
, bufsize
, "rtc: present?");
201 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
202 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
204 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
205 snprintf(buf
, bufsize
,
206 "rtc: day of month, blank padded ( 1..31)");
208 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
209 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
211 case WPS_TOKEN_RTC_HOUR_24
:
212 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
214 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
215 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
217 case WPS_TOKEN_RTC_HOUR_12
:
218 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
220 case WPS_TOKEN_RTC_MONTH
:
221 snprintf(buf
, bufsize
, "rtc: month (01..12)");
223 case WPS_TOKEN_RTC_MINUTE
:
224 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
226 case WPS_TOKEN_RTC_SECOND
:
227 snprintf(buf
, bufsize
, "rtc: second (00..59)");
229 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
230 snprintf(buf
, bufsize
,
231 "rtc: last two digits of year (00..99)");
233 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
234 snprintf(buf
, bufsize
, "rtc: year (1970...)");
236 case WPS_TOKEN_RTC_AM_PM_UPPER
:
237 snprintf(buf
, bufsize
,
238 "rtc: upper case AM or PM indicator");
240 case WPS_TOKEN_RTC_AM_PM_LOWER
:
241 snprintf(buf
, bufsize
,
242 "rtc: lower case am or pm indicator");
244 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
245 snprintf(buf
, bufsize
,
246 "rtc: abbreviated weekday name (Sun..Sat)");
248 case WPS_TOKEN_RTC_MONTH_NAME
:
249 snprintf(buf
, bufsize
,
250 "rtc: abbreviated month name (Jan..Dec)");
252 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
253 snprintf(buf
, bufsize
,
254 "rtc: day of week (1..7); 1 is Monday");
256 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
257 snprintf(buf
, bufsize
,
258 "rtc: day of week (0..6); 0 is Sunday");
261 #if (CONFIG_CODEC == SWCODEC)
262 case WPS_TOKEN_CROSSFADE
:
263 snprintf(buf
, bufsize
, "crossfade");
266 case WPS_TOKEN_REPLAYGAIN
:
267 snprintf(buf
, bufsize
, "replaygain");
272 case WPS_TOKEN_ALBUMART_DISPLAY
:
273 snprintf(buf
, bufsize
, "album art display");
276 case WPS_TOKEN_ALBUMART_FOUND
:
277 snprintf(buf
, bufsize
, "%strack album art conditional",
282 #ifdef HAVE_LCD_BITMAP
283 case WPS_TOKEN_IMAGE_BACKDROP
:
284 snprintf(buf
, bufsize
, "backdrop image");
287 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
288 snprintf(buf
, bufsize
, "progressbar bitmap");
291 case WPS_TOKEN_PEAKMETER
:
292 snprintf(buf
, bufsize
, "peakmeter");
296 case WPS_TOKEN_PROGRESSBAR
:
297 snprintf(buf
, bufsize
, "progressbar");
300 #ifdef HAVE_LCD_CHARCELLS
301 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
302 snprintf(buf
, bufsize
, "full line progressbar");
306 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
307 snprintf(buf
, bufsize
, "time elapsed in track");
310 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
311 snprintf(buf
, bufsize
, "played percentage of track");
314 case WPS_TOKEN_PLAYLIST_ENTRIES
:
315 snprintf(buf
, bufsize
, "number of entries in playlist");
318 case WPS_TOKEN_PLAYLIST_NAME
:
319 snprintf(buf
, bufsize
, "playlist name");
322 case WPS_TOKEN_PLAYLIST_POSITION
:
323 snprintf(buf
, bufsize
, "position in playlist");
326 case WPS_TOKEN_TRACK_TIME_REMAINING
:
327 snprintf(buf
, bufsize
, "time remaining in track");
330 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
331 snprintf(buf
, bufsize
, "playlist shuffle mode");
334 case WPS_TOKEN_TRACK_LENGTH
:
335 snprintf(buf
, bufsize
, "track length");
338 case WPS_TOKEN_VOLUME
:
339 snprintf(buf
, bufsize
, "volume");
342 case WPS_TOKEN_METADATA_ARTIST
:
343 snprintf(buf
, bufsize
, "%strack artist",
347 case WPS_TOKEN_METADATA_COMPOSER
:
348 snprintf(buf
, bufsize
, "%strack composer",
352 case WPS_TOKEN_METADATA_ALBUM
:
353 snprintf(buf
, bufsize
, "%strack album",
357 case WPS_TOKEN_METADATA_GROUPING
:
358 snprintf(buf
, bufsize
, "%strack grouping",
362 case WPS_TOKEN_METADATA_GENRE
:
363 snprintf(buf
, bufsize
, "%strack genre",
367 case WPS_TOKEN_METADATA_DISC_NUMBER
:
368 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
371 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
372 snprintf(buf
, bufsize
, "%strack number",
376 case WPS_TOKEN_METADATA_TRACK_TITLE
:
377 snprintf(buf
, bufsize
, "%strack title",
381 case WPS_TOKEN_METADATA_VERSION
:
382 snprintf(buf
, bufsize
, "%strack ID3 version",
386 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
387 snprintf(buf
, bufsize
, "%strack album artist",
391 case WPS_TOKEN_METADATA_COMMENT
:
392 snprintf(buf
, bufsize
, "%strack comment",
396 case WPS_TOKEN_METADATA_YEAR
:
397 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
401 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
402 snprintf(buf
, bufsize
, "track playcount (database)");
405 case WPS_TOKEN_DATABASE_RATING
:
406 snprintf(buf
, bufsize
, "track rating (database)");
409 case WPS_TOKEN_DATABASE_AUTOSCORE
:
410 snprintf(buf
, bufsize
, "track autoscore (database)");
414 case WPS_TOKEN_BATTERY_PERCENT
:
415 snprintf(buf
, bufsize
, "battery percentage");
418 case WPS_TOKEN_BATTERY_VOLTS
:
419 snprintf(buf
, bufsize
, "battery voltage");
422 case WPS_TOKEN_BATTERY_TIME
:
423 snprintf(buf
, bufsize
, "battery time left");
426 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
427 snprintf(buf
, bufsize
, "battery charger connected");
430 case WPS_TOKEN_BATTERY_CHARGING
:
431 snprintf(buf
, bufsize
, "battery charging");
434 case WPS_TOKEN_BATTERY_SLEEPTIME
:
435 snprintf(buf
, bufsize
, "sleep timer");
438 case WPS_TOKEN_FILE_BITRATE
:
439 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
442 case WPS_TOKEN_FILE_CODEC
:
443 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
446 case WPS_TOKEN_FILE_FREQUENCY
:
447 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
451 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
452 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
456 case WPS_TOKEN_FILE_NAME
:
457 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
460 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
461 snprintf(buf
, bufsize
, "%sfile name with extension",
465 case WPS_TOKEN_FILE_PATH
:
466 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
469 case WPS_TOKEN_FILE_SIZE
:
470 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
473 case WPS_TOKEN_FILE_VBR
:
474 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
477 case WPS_TOKEN_FILE_DIRECTORY
:
478 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
479 next_str(next
), token
->value
.i
);
482 #if (CONFIG_CODEC != MAS3507D)
483 case WPS_TOKEN_SOUND_PITCH
:
484 snprintf(buf
, bufsize
, "pitch value");
488 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
489 case WPS_TOKEN_VLED_HDD
:
490 snprintf(buf
, bufsize
, "display virtual HDD LED");
493 case WPS_VIEWPORT_ENABLE
:
494 case WPS_TOKEN_UIVIEWPORT_ENABLE
:
495 snprintf(buf
, bufsize
, "enable %sVP: %c",
496 token
->type
== WPS_TOKEN_UIVIEWPORT_ENABLE
? "UI " : "",
497 (char)token
->value
.i
);
499 case WPS_TOKEN_BUTTON_VOLUME
:
500 snprintf(buf
, bufsize
, "Volume button timeout: %d",
503 case WPS_TOKEN_SETTING
:
504 snprintf(buf
, bufsize
, "Setting value: '%s'",
505 settings
[token
->value
.i
].cfg_name
);
507 case WPS_TOKEN_LANG_IS_RTL
:
508 snprintf(buf
, bufsize
, "lang: is_rtl?");
511 case WPS_TOKEN_TRACK_STARTING
:
512 snprintf(buf
, bufsize
, "first %d seconds of track", token
->value
.i
);
514 case WPS_TOKEN_TRACK_ENDING
:
515 snprintf(buf
, bufsize
, "last %d seconds of track", token
->value
.i
);
518 for(i
=1; i
<sizeof(tokens
)/sizeof(*token
); i
++)
520 if (token
->type
< tokens
[i
].start_marker
)
522 snprintf(buf
, bufsize
, "FIXME: %s + %d\n", tokens
[i
-1].desc
,
523 token
->type
- tokens
[i
-1].start_marker
);
533 #if defined(SIMULATOR) || defined(__PCTOOL__)
534 static void dump_skin(struct wps_data
*data
)
540 struct skin_token_list
*viewport_list
;
541 for (viewport_list
= data
->viewports
;
542 viewport_list
; viewport_list
= viewport_list
->next
)
544 struct skin_viewport
*skin_viewport
=
545 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
547 DEBUGF("Viewport: '%c'\n", skin_viewport
->label
);
548 struct skin_line
*line
;
549 for (line
= skin_viewport
->lines
; line
; line
= line
->next
)
551 struct skin_subline
*subline
;
553 for(subline
= &line
->sublines
; subline
; subline
= subline
->next
)
555 DEBUGF(" Subline: tokens %d => %d",
556 subline
->first_token_idx
,subline
->last_token_idx
);
557 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
558 DEBUGF(", scrolled");
559 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
560 DEBUGF(", progressbar");
561 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
562 DEBUGF(", peakmeter");
565 for (i
= subline
->first_token_idx
; i
<= subline
->last_token_idx
; i
++)
567 struct wps_token
*token
= &data
->tokens
[i
];
568 get_token_desc(token
, buf
, sizeof(buf
), data
);
573 case WPS_TOKEN_CONDITIONAL_START
:
577 case WPS_TOKEN_CONDITIONAL_END
:
585 if (wps_verbose_level
> 2)
587 for(j
= 0; j
< indent
; j
++) {
591 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
600 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
602 #if defined(SIMULATOR) || defined(__PCTOOL__)
603 if (debug_wps
&& wps_verbose_level
)
607 #endif /* SIMULATOR */
609 if (fail
!= PARSE_OK
)
613 DEBUGF("ERR: Failed parsing on line %d : ", line
);
619 case PARSE_FAIL_UNCLOSED_COND
:
620 DEBUGF("ERR: Unclosed conditional");
623 case PARSE_FAIL_INVALID_CHAR
:
624 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
626 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
630 case PARSE_FAIL_COND_SYNTAX_ERROR
:
631 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
633 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
637 case PARSE_FAIL_COND_INVALID_PARAM
:
638 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
640 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
), data
)
644 case PARSE_FAIL_LIMITS_EXCEEDED
:
645 DEBUGF("ERR: Limits exceeded");
652 void debug_skin_usage(void)
654 #if defined(SIMULATOR) || defined(__PCTOOL__)
655 if (wps_verbose_level
> 1)
657 DEBUGF("Skin buffer usage: %lu/%lu\n", (unsigned long)skin_buffer_usage(),
658 (unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
661 #endif /* DEBUG || SIMULATOR */