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 ****************************************************************************/
23 #include "wps_internals.h"
25 #ifdef DEBUG_SKIN_ENGINE
29 #include "skin_buffer.h"
30 #include "settings_list.h"
41 #if defined(SIMULATOR) || defined(__PCTOOL__)
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_TUNER
) },
65 { X(TOKEN_MARKER_END
) },
69 static char *next_str(bool next
) {
70 return next
? "next " : "";
73 static char *get_token_desc(struct wps_token
*token
, char *buf
,
74 int bufsize
, struct wps_data
*data
)
77 #ifndef HAVE_LCD_BITMAP
78 (void)data
; /* kill charcell warning */
80 bool next
= token
->next
;
84 snprintf(buf
, bufsize
, "No token");
87 case WPS_TOKEN_UNKNOWN
:
88 snprintf(buf
, bufsize
, "Unknown token");
91 case WPS_TOKEN_CHARACTER
:
92 if (token
->value
.c
== '\n')
93 snprintf(buf
, bufsize
, "Character '\\n'");
95 snprintf(buf
, bufsize
, "Character '%c'",
99 case WPS_TOKEN_STRING
:
100 snprintf(buf
, bufsize
, "String '%s'",
101 (char*)token
->value
.data
);
103 case WPS_TOKEN_TRANSLATEDSTRING
:
104 snprintf(buf
, bufsize
, "String ID '%d'", token
->value
.i
);
107 #ifdef HAVE_LCD_BITMAP
108 case WPS_TOKEN_ALIGN_LEFT
:
109 snprintf(buf
, bufsize
, "align left");
112 case WPS_TOKEN_ALIGN_CENTER
:
113 snprintf(buf
, bufsize
, "align center");
116 case WPS_TOKEN_ALIGN_RIGHT
:
117 snprintf(buf
, bufsize
, "align right");
121 case WPS_TOKEN_SUBLINE_TIMEOUT
:
122 snprintf(buf
, bufsize
, "subline timeout value: %d",
126 case WPS_TOKEN_CONDITIONAL
:
127 snprintf(buf
, bufsize
, "conditional, %d options",
131 case WPS_TOKEN_CONDITIONAL_START
:
132 snprintf(buf
, bufsize
, "conditional start, next cond: %d",
136 case WPS_TOKEN_CONDITIONAL_OPTION
:
137 snprintf(buf
, bufsize
, "conditional option, next cond: %d",
141 case WPS_TOKEN_CONDITIONAL_END
:
142 snprintf(buf
, bufsize
, "conditional end");
145 #ifdef HAVE_LCD_BITMAP
146 case WPS_TOKEN_LIST_TITLE_TEXT
:
147 snprintf(buf
, bufsize
, "list title text");
149 case WPS_TOKEN_LIST_TITLE_ICON
:
150 snprintf(buf
, bufsize
, "list title icon");
152 case WPS_TOKEN_IMAGE_PRELOAD
:
153 snprintf(buf
, bufsize
, "preload image");
156 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
158 char subimage
= '\0';
159 char label
= token
->value
.i
&0xFF;
160 struct gui_img
*img
= find_image(label
, data
);
161 if (img
&& img
->num_subimages
> 1)
163 int item
= token
->value
.i
>>8;
165 subimage
= 'A' + item
-26;
167 subimage
= 'a' + item
;
169 snprintf(buf
, bufsize
, "display preloaded image '%c%c'",
174 case WPS_TOKEN_IMAGE_DISPLAY
:
175 snprintf(buf
, bufsize
, "display image");
179 #ifdef HAS_BUTTON_HOLD
180 case WPS_TOKEN_MAIN_HOLD
:
181 snprintf(buf
, bufsize
, "mode hold");
185 #ifdef HAS_REMOTE_BUTTON_HOLD
186 case WPS_TOKEN_REMOTE_HOLD
:
187 snprintf(buf
, bufsize
, "mode remote hold");
191 case WPS_TOKEN_REPEAT_MODE
:
192 snprintf(buf
, bufsize
, "mode repeat");
195 case WPS_TOKEN_PLAYBACK_STATUS
:
196 snprintf(buf
, bufsize
, "mode playback");
199 case WPS_TOKEN_RTC_PRESENT
:
200 snprintf(buf
, bufsize
, "rtc: present?");
202 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
203 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
205 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
206 snprintf(buf
, bufsize
,
207 "rtc: day of month, blank padded ( 1..31)");
209 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
210 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
212 case WPS_TOKEN_RTC_HOUR_24
:
213 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
215 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
216 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
218 case WPS_TOKEN_RTC_HOUR_12
:
219 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
221 case WPS_TOKEN_RTC_MONTH
:
222 snprintf(buf
, bufsize
, "rtc: month (01..12)");
224 case WPS_TOKEN_RTC_MINUTE
:
225 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
227 case WPS_TOKEN_RTC_SECOND
:
228 snprintf(buf
, bufsize
, "rtc: second (00..59)");
230 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
231 snprintf(buf
, bufsize
,
232 "rtc: last two digits of year (00..99)");
234 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
235 snprintf(buf
, bufsize
, "rtc: year (1970...)");
237 case WPS_TOKEN_RTC_AM_PM_UPPER
:
238 snprintf(buf
, bufsize
,
239 "rtc: upper case AM or PM indicator");
241 case WPS_TOKEN_RTC_AM_PM_LOWER
:
242 snprintf(buf
, bufsize
,
243 "rtc: lower case am or pm indicator");
245 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
246 snprintf(buf
, bufsize
,
247 "rtc: abbreviated weekday name (Sun..Sat)");
249 case WPS_TOKEN_RTC_MONTH_NAME
:
250 snprintf(buf
, bufsize
,
251 "rtc: abbreviated month name (Jan..Dec)");
253 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
254 snprintf(buf
, bufsize
,
255 "rtc: day of week (1..7); 1 is Monday");
257 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
258 snprintf(buf
, bufsize
,
259 "rtc: day of week (0..6); 0 is Sunday");
262 #if (CONFIG_CODEC == SWCODEC)
263 case WPS_TOKEN_CROSSFADE
:
264 snprintf(buf
, bufsize
, "crossfade");
267 case WPS_TOKEN_REPLAYGAIN
:
268 snprintf(buf
, bufsize
, "replaygain");
273 case WPS_TOKEN_ALBUMART_DISPLAY
:
274 snprintf(buf
, bufsize
, "album art display");
277 case WPS_TOKEN_ALBUMART_FOUND
:
278 snprintf(buf
, bufsize
, "%strack album art conditional",
283 #ifdef HAVE_LCD_BITMAP
284 case WPS_TOKEN_IMAGE_BACKDROP
:
285 snprintf(buf
, bufsize
, "backdrop image");
288 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
289 snprintf(buf
, bufsize
, "progressbar bitmap");
292 case WPS_TOKEN_PEAKMETER
:
293 snprintf(buf
, bufsize
, "peakmeter");
297 case WPS_TOKEN_PROGRESSBAR
:
298 snprintf(buf
, bufsize
, "progressbar");
301 #ifdef HAVE_LCD_CHARCELLS
302 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
303 snprintf(buf
, bufsize
, "full line progressbar");
307 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
308 snprintf(buf
, bufsize
, "time elapsed in track");
311 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
312 snprintf(buf
, bufsize
, "played percentage of track");
315 case WPS_TOKEN_PLAYLIST_ENTRIES
:
316 snprintf(buf
, bufsize
, "number of entries in playlist");
319 case WPS_TOKEN_PLAYLIST_NAME
:
320 snprintf(buf
, bufsize
, "playlist name");
323 case WPS_TOKEN_PLAYLIST_POSITION
:
324 snprintf(buf
, bufsize
, "position in playlist");
327 case WPS_TOKEN_TRACK_TIME_REMAINING
:
328 snprintf(buf
, bufsize
, "time remaining in track");
331 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
332 snprintf(buf
, bufsize
, "playlist shuffle mode");
335 case WPS_TOKEN_TRACK_LENGTH
:
336 snprintf(buf
, bufsize
, "track length");
339 case WPS_TOKEN_VOLUME
:
340 snprintf(buf
, bufsize
, "volume");
343 case WPS_TOKEN_METADATA_ARTIST
:
344 snprintf(buf
, bufsize
, "%strack artist",
348 case WPS_TOKEN_METADATA_COMPOSER
:
349 snprintf(buf
, bufsize
, "%strack composer",
353 case WPS_TOKEN_METADATA_ALBUM
:
354 snprintf(buf
, bufsize
, "%strack album",
358 case WPS_TOKEN_METADATA_GROUPING
:
359 snprintf(buf
, bufsize
, "%strack grouping",
363 case WPS_TOKEN_METADATA_GENRE
:
364 snprintf(buf
, bufsize
, "%strack genre",
368 case WPS_TOKEN_METADATA_DISC_NUMBER
:
369 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
372 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
373 snprintf(buf
, bufsize
, "%strack number",
377 case WPS_TOKEN_METADATA_TRACK_TITLE
:
378 snprintf(buf
, bufsize
, "%strack title",
382 case WPS_TOKEN_METADATA_VERSION
:
383 snprintf(buf
, bufsize
, "%strack ID3 version",
387 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
388 snprintf(buf
, bufsize
, "%strack album artist",
392 case WPS_TOKEN_METADATA_COMMENT
:
393 snprintf(buf
, bufsize
, "%strack comment",
397 case WPS_TOKEN_METADATA_YEAR
:
398 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
402 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
403 snprintf(buf
, bufsize
, "track playcount (database)");
406 case WPS_TOKEN_DATABASE_RATING
:
407 snprintf(buf
, bufsize
, "track rating (database)");
410 case WPS_TOKEN_DATABASE_AUTOSCORE
:
411 snprintf(buf
, bufsize
, "track autoscore (database)");
415 case WPS_TOKEN_BATTERY_PERCENT
:
416 snprintf(buf
, bufsize
, "battery percentage");
419 case WPS_TOKEN_BATTERY_VOLTS
:
420 snprintf(buf
, bufsize
, "battery voltage");
423 case WPS_TOKEN_BATTERY_TIME
:
424 snprintf(buf
, bufsize
, "battery time left");
427 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
428 snprintf(buf
, bufsize
, "battery charger connected");
431 case WPS_TOKEN_BATTERY_CHARGING
:
432 snprintf(buf
, bufsize
, "battery charging");
435 case WPS_TOKEN_BATTERY_SLEEPTIME
:
436 snprintf(buf
, bufsize
, "sleep timer");
439 case WPS_TOKEN_FILE_BITRATE
:
440 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
443 case WPS_TOKEN_FILE_CODEC
:
444 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
447 case WPS_TOKEN_FILE_FREQUENCY
:
448 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
452 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
453 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
457 case WPS_TOKEN_FILE_NAME
:
458 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
461 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
462 snprintf(buf
, bufsize
, "%sfile name with extension",
466 case WPS_TOKEN_FILE_PATH
:
467 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
470 case WPS_TOKEN_FILE_SIZE
:
471 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
474 case WPS_TOKEN_FILE_VBR
:
475 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
478 case WPS_TOKEN_FILE_DIRECTORY
:
479 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
480 next_str(next
), token
->value
.i
);
483 #if (CONFIG_CODEC != MAS3507D)
484 case WPS_TOKEN_SOUND_PITCH
:
485 snprintf(buf
, bufsize
, "pitch value");
489 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
490 case WPS_TOKEN_VLED_HDD
:
491 snprintf(buf
, bufsize
, "display virtual HDD LED");
494 case WPS_VIEWPORT_ENABLE
:
495 case WPS_TOKEN_UIVIEWPORT_ENABLE
:
496 snprintf(buf
, bufsize
, "enable %sVP: %c",
497 token
->type
== WPS_TOKEN_UIVIEWPORT_ENABLE
? "UI " : "",
498 (char)token
->value
.i
);
500 case WPS_TOKEN_BUTTON_VOLUME
:
501 snprintf(buf
, bufsize
, "Volume button timeout: %d",
504 case WPS_TOKEN_SETTING
:
505 snprintf(buf
, bufsize
, "Setting value: '%s'",
506 settings
[token
->value
.i
].cfg_name
);
508 case WPS_TOKEN_LANG_IS_RTL
:
509 snprintf(buf
, bufsize
, "lang: is_rtl?");
512 case WPS_TOKEN_TRACK_STARTING
:
513 snprintf(buf
, bufsize
, "first %d seconds of track", token
->value
.i
);
515 case WPS_TOKEN_TRACK_ENDING
:
516 snprintf(buf
, bufsize
, "last %d seconds of track", token
->value
.i
);
519 for(i
=1; i
<sizeof(tokens
)/sizeof(*token
); i
++)
521 if (token
->type
< tokens
[i
].start_marker
)
523 snprintf(buf
, bufsize
, "FIXME: %s + %d\n", tokens
[i
-1].desc
,
524 token
->type
- tokens
[i
-1].start_marker
);
534 #if defined(SIMULATOR) || defined(__PCTOOL__)
535 static void dump_skin(struct wps_data
*data
)
541 struct skin_token_list
*viewport_list
;
542 for (viewport_list
= data
->viewports
;
543 viewport_list
; viewport_list
= viewport_list
->next
)
545 struct skin_viewport
*skin_viewport
=
546 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
548 DEBUGF("Viewport: '%c'\n", skin_viewport
->label
);
549 struct skin_line
*line
;
550 for (line
= skin_viewport
->lines
; line
; line
= line
->next
)
552 struct skin_subline
*subline
;
554 for(subline
= &line
->sublines
; subline
; subline
= subline
->next
)
556 DEBUGF(" Subline: tokens %d => %d",
557 subline
->first_token_idx
,subline
->last_token_idx
);
558 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
559 DEBUGF(", scrolled");
560 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
561 DEBUGF(", progressbar");
562 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
563 DEBUGF(", peakmeter");
566 for (i
= subline
->first_token_idx
; i
<= subline
->last_token_idx
; i
++)
568 struct wps_token
*token
= &data
->tokens
[i
];
569 get_token_desc(token
, buf
, sizeof(buf
), data
);
574 case WPS_TOKEN_CONDITIONAL_START
:
578 case WPS_TOKEN_CONDITIONAL_END
:
586 if (wps_verbose_level
> 2)
588 for(j
= 0; j
< indent
; j
++) {
592 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
601 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
603 #if defined(SIMULATOR) || defined(__PCTOOL__)
604 if (debug_wps
&& wps_verbose_level
)
608 #endif /* SIMULATOR */
610 if (fail
!= PARSE_OK
)
614 DEBUGF("ERR: Failed parsing on line %d : ", line
);
620 case PARSE_FAIL_UNCLOSED_COND
:
621 DEBUGF("ERR: Unclosed conditional");
624 case PARSE_FAIL_INVALID_CHAR
:
625 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
627 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
631 case PARSE_FAIL_COND_SYNTAX_ERROR
:
632 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
634 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
638 case PARSE_FAIL_COND_INVALID_PARAM
:
639 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
641 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
), data
)
645 case PARSE_FAIL_LIMITS_EXCEEDED
:
646 DEBUGF("ERR: Limits exceeded");
653 void debug_skin_usage(void)
655 #if defined(SIMULATOR) || defined(__PCTOOL__)
656 if (wps_verbose_level
> 1)
658 DEBUGF("Skin buffer usage: %lu/%lu\n", (unsigned long)skin_buffer_usage(),
659 (unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
662 #endif /* DEBUG || SIMULATOR */