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 bool debug_wps
;
42 extern int wps_verbose_level
;
45 struct debug_token_table
47 enum wps_token_type start_marker
;
50 #define X(name) name, #name
51 struct debug_token_table tokens
[] = {
52 { X(TOKEN_MARKER_CONTROL_TOKENS
) },
53 { X(TOKEN_MARKER_BATTERY
) },
54 { X(TOKEN_MARKER_SOUND
) },
55 { X(TOKEN_MARKER_RTC
) },
56 { X(TOKEN_MARKER_DATABASE
) },
57 { X(TOKEN_MARKER_FILE
) },
58 { X(TOKEN_MARKER_IMAGES
) },
59 { X(TOKEN_MARKER_METADATA
) },
60 { X(TOKEN_MARKER_PLAYBACK_INFO
) },
61 { X(TOKEN_MARKER_PLAYLIST
) },
62 { X(TOKEN_MARKER_MISC
) },
63 { X(TOKEN_MARKER_RECORDING
) },
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_IMAGE_PRELOAD
:
146 snprintf(buf
, bufsize
, "preload image");
149 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
151 char subimage
= '\0';
152 char label
= token
->value
.i
&0xFF;
153 struct gui_img
*img
= find_image(label
, data
);
154 if (img
&& img
->num_subimages
> 1)
155 subimage
= 'a' + (token
->value
.i
>>8);
156 snprintf(buf
, bufsize
, "display preloaded image '%c%c'",
161 case WPS_TOKEN_IMAGE_DISPLAY
:
162 snprintf(buf
, bufsize
, "display image");
166 #ifdef HAS_BUTTON_HOLD
167 case WPS_TOKEN_MAIN_HOLD
:
168 snprintf(buf
, bufsize
, "mode hold");
172 #ifdef HAS_REMOTE_BUTTON_HOLD
173 case WPS_TOKEN_REMOTE_HOLD
:
174 snprintf(buf
, bufsize
, "mode remote hold");
178 case WPS_TOKEN_REPEAT_MODE
:
179 snprintf(buf
, bufsize
, "mode repeat");
182 case WPS_TOKEN_PLAYBACK_STATUS
:
183 snprintf(buf
, bufsize
, "mode playback");
186 case WPS_TOKEN_RTC_PRESENT
:
187 snprintf(buf
, bufsize
, "rtc: present?");
189 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
190 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
192 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
193 snprintf(buf
, bufsize
,
194 "rtc: day of month, blank padded ( 1..31)");
196 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
197 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
199 case WPS_TOKEN_RTC_HOUR_24
:
200 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
202 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
203 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
205 case WPS_TOKEN_RTC_HOUR_12
:
206 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
208 case WPS_TOKEN_RTC_MONTH
:
209 snprintf(buf
, bufsize
, "rtc: month (01..12)");
211 case WPS_TOKEN_RTC_MINUTE
:
212 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
214 case WPS_TOKEN_RTC_SECOND
:
215 snprintf(buf
, bufsize
, "rtc: second (00..59)");
217 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
218 snprintf(buf
, bufsize
,
219 "rtc: last two digits of year (00..99)");
221 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
222 snprintf(buf
, bufsize
, "rtc: year (1970...)");
224 case WPS_TOKEN_RTC_AM_PM_UPPER
:
225 snprintf(buf
, bufsize
,
226 "rtc: upper case AM or PM indicator");
228 case WPS_TOKEN_RTC_AM_PM_LOWER
:
229 snprintf(buf
, bufsize
,
230 "rtc: lower case am or pm indicator");
232 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
233 snprintf(buf
, bufsize
,
234 "rtc: abbreviated weekday name (Sun..Sat)");
236 case WPS_TOKEN_RTC_MONTH_NAME
:
237 snprintf(buf
, bufsize
,
238 "rtc: abbreviated month name (Jan..Dec)");
240 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
241 snprintf(buf
, bufsize
,
242 "rtc: day of week (1..7); 1 is Monday");
244 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
245 snprintf(buf
, bufsize
,
246 "rtc: day of week (0..6); 0 is Sunday");
249 #if (CONFIG_CODEC == SWCODEC)
250 case WPS_TOKEN_CROSSFADE
:
251 snprintf(buf
, bufsize
, "crossfade");
254 case WPS_TOKEN_REPLAYGAIN
:
255 snprintf(buf
, bufsize
, "replaygain");
260 case WPS_TOKEN_ALBUMART_DISPLAY
:
261 snprintf(buf
, bufsize
, "album art display");
264 case WPS_TOKEN_ALBUMART_FOUND
:
265 snprintf(buf
, bufsize
, "%strack album art conditional",
270 #ifdef HAVE_LCD_BITMAP
271 case WPS_TOKEN_IMAGE_BACKDROP
:
272 snprintf(buf
, bufsize
, "backdrop image");
275 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
276 snprintf(buf
, bufsize
, "progressbar bitmap");
279 case WPS_TOKEN_PEAKMETER
:
280 snprintf(buf
, bufsize
, "peakmeter");
284 case WPS_TOKEN_PROGRESSBAR
:
285 snprintf(buf
, bufsize
, "progressbar");
288 #ifdef HAVE_LCD_CHARCELLS
289 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
290 snprintf(buf
, bufsize
, "full line progressbar");
294 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
295 snprintf(buf
, bufsize
, "time elapsed in track");
298 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
299 snprintf(buf
, bufsize
, "played percentage of track");
302 case WPS_TOKEN_PLAYLIST_ENTRIES
:
303 snprintf(buf
, bufsize
, "number of entries in playlist");
306 case WPS_TOKEN_PLAYLIST_NAME
:
307 snprintf(buf
, bufsize
, "playlist name");
310 case WPS_TOKEN_PLAYLIST_POSITION
:
311 snprintf(buf
, bufsize
, "position in playlist");
314 case WPS_TOKEN_TRACK_TIME_REMAINING
:
315 snprintf(buf
, bufsize
, "time remaining in track");
318 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
319 snprintf(buf
, bufsize
, "playlist shuffle mode");
322 case WPS_TOKEN_TRACK_LENGTH
:
323 snprintf(buf
, bufsize
, "track length");
326 case WPS_TOKEN_VOLUME
:
327 snprintf(buf
, bufsize
, "volume");
330 case WPS_TOKEN_METADATA_ARTIST
:
331 snprintf(buf
, bufsize
, "%strack artist",
335 case WPS_TOKEN_METADATA_COMPOSER
:
336 snprintf(buf
, bufsize
, "%strack composer",
340 case WPS_TOKEN_METADATA_ALBUM
:
341 snprintf(buf
, bufsize
, "%strack album",
345 case WPS_TOKEN_METADATA_GROUPING
:
346 snprintf(buf
, bufsize
, "%strack grouping",
350 case WPS_TOKEN_METADATA_GENRE
:
351 snprintf(buf
, bufsize
, "%strack genre",
355 case WPS_TOKEN_METADATA_DISC_NUMBER
:
356 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
359 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
360 snprintf(buf
, bufsize
, "%strack number",
364 case WPS_TOKEN_METADATA_TRACK_TITLE
:
365 snprintf(buf
, bufsize
, "%strack title",
369 case WPS_TOKEN_METADATA_VERSION
:
370 snprintf(buf
, bufsize
, "%strack ID3 version",
374 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
375 snprintf(buf
, bufsize
, "%strack album artist",
379 case WPS_TOKEN_METADATA_COMMENT
:
380 snprintf(buf
, bufsize
, "%strack comment",
384 case WPS_TOKEN_METADATA_YEAR
:
385 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
389 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
390 snprintf(buf
, bufsize
, "track playcount (database)");
393 case WPS_TOKEN_DATABASE_RATING
:
394 snprintf(buf
, bufsize
, "track rating (database)");
397 case WPS_TOKEN_DATABASE_AUTOSCORE
:
398 snprintf(buf
, bufsize
, "track autoscore (database)");
402 case WPS_TOKEN_BATTERY_PERCENT
:
403 snprintf(buf
, bufsize
, "battery percentage");
406 case WPS_TOKEN_BATTERY_VOLTS
:
407 snprintf(buf
, bufsize
, "battery voltage");
410 case WPS_TOKEN_BATTERY_TIME
:
411 snprintf(buf
, bufsize
, "battery time left");
414 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
415 snprintf(buf
, bufsize
, "battery charger connected");
418 case WPS_TOKEN_BATTERY_CHARGING
:
419 snprintf(buf
, bufsize
, "battery charging");
422 case WPS_TOKEN_BATTERY_SLEEPTIME
:
423 snprintf(buf
, bufsize
, "sleep timer");
426 case WPS_TOKEN_FILE_BITRATE
:
427 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
430 case WPS_TOKEN_FILE_CODEC
:
431 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
434 case WPS_TOKEN_FILE_FREQUENCY
:
435 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
439 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
440 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
444 case WPS_TOKEN_FILE_NAME
:
445 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
448 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
449 snprintf(buf
, bufsize
, "%sfile name with extension",
453 case WPS_TOKEN_FILE_PATH
:
454 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
457 case WPS_TOKEN_FILE_SIZE
:
458 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
461 case WPS_TOKEN_FILE_VBR
:
462 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
465 case WPS_TOKEN_FILE_DIRECTORY
:
466 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
467 next_str(next
), token
->value
.i
);
470 #if (CONFIG_CODEC != MAS3507D)
471 case WPS_TOKEN_SOUND_PITCH
:
472 snprintf(buf
, bufsize
, "pitch value");
476 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
477 case WPS_TOKEN_VLED_HDD
:
478 snprintf(buf
, bufsize
, "display virtual HDD LED");
481 case WPS_VIEWPORT_ENABLE
:
482 snprintf(buf
, bufsize
, "enable VP: %c",
483 (char)token
->value
.i
);
485 case WPS_TOKEN_BUTTON_VOLUME
:
486 snprintf(buf
, bufsize
, "Volume button timeout: %d",
489 case WPS_TOKEN_SETTING
:
490 snprintf(buf
, bufsize
, "Setting value: '%s'",
491 settings
[token
->value
.i
].cfg_name
);
493 case WPS_TOKEN_LANG_IS_RTL
:
494 snprintf(buf
, bufsize
, "lang: is_rtl?");
497 for(i
=1; i
<sizeof(tokens
)/sizeof(*token
); i
++)
499 if (token
->type
< tokens
[i
].start_marker
)
501 snprintf(buf
, bufsize
, "FIXME: %s + %d\n", tokens
[i
-1].desc
,
502 token
->type
- tokens
[i
-1].start_marker
);
512 #if defined(SIMULATOR) || defined(__PCTOOL__)
513 static void dump_skin(struct wps_data
*data
)
519 struct skin_token_list
*viewport_list
;
520 for (viewport_list
= data
->viewports
;
521 viewport_list
; viewport_list
= viewport_list
->next
)
523 struct skin_viewport
*skin_viewport
=
524 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
526 DEBUGF("Viewport: '%c'\n", skin_viewport
->label
);
527 struct skin_line
*line
;
528 for (line
= skin_viewport
->lines
; line
; line
= line
->next
)
530 struct skin_subline
*subline
;
532 for(subline
= &line
->sublines
; subline
; subline
= subline
->next
)
534 DEBUGF(" Subline: tokens %d => %d",
535 subline
->first_token_idx
,subline
->last_token_idx
);
536 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
537 DEBUGF(", scrolled");
538 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
539 DEBUGF(", progressbar");
540 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
541 DEBUGF(", peakmeter");
544 for (i
= subline
->first_token_idx
; i
<= subline
->last_token_idx
; i
++)
546 struct wps_token
*token
= &data
->tokens
[i
];
547 get_token_desc(token
, buf
, sizeof(buf
), data
);
552 case WPS_TOKEN_CONDITIONAL_START
:
556 case WPS_TOKEN_CONDITIONAL_END
:
564 if (wps_verbose_level
> 2)
566 for(j
= 0; j
< indent
; j
++) {
570 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
579 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
581 #if defined(SIMULATOR) || defined(__PCTOOL__)
582 if (debug_wps
&& wps_verbose_level
)
586 #endif /* SIMULATOR */
588 if (data
->num_tokens
>= WPS_MAX_TOKENS
- 1) {
589 DEBUGF("Warning: Max number of tokens was reached (%d)\n",
593 if (fail
!= PARSE_OK
)
597 DEBUGF("ERR: Failed parsing on line %d : ", line
);
603 case PARSE_FAIL_UNCLOSED_COND
:
604 DEBUGF("ERR: Unclosed conditional");
607 case PARSE_FAIL_INVALID_CHAR
:
608 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
610 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
614 case PARSE_FAIL_COND_SYNTAX_ERROR
:
615 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
617 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
621 case PARSE_FAIL_COND_INVALID_PARAM
:
622 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
624 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
), data
)
628 case PARSE_FAIL_LIMITS_EXCEEDED
:
629 DEBUGF("ERR: Limits exceeded");
636 void debug_skin_usage(void)
638 #if defined(SIMULATOR) || defined(__PCTOOL__)
639 if (wps_verbose_level
> 1)
641 DEBUGF("Skin buffer usage: %lu/%lu\n", (unsigned long)skin_buffer_usage(),
642 (unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
646 #endif /* DEBUG || SIMULATOR */