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"
39 #if defined(SIMULATOR) || defined(__PCTOOL__)
40 extern bool debug_wps
;
41 extern int wps_verbose_level
;
44 static char *next_str(bool next
) {
45 return next
? "next " : "";
48 static char *get_token_desc(struct wps_token
*token
, char *buf
, int bufsize
)
50 bool next
= token
->next
;
55 snprintf(buf
, bufsize
, "No token");
58 case WPS_TOKEN_UNKNOWN
:
59 snprintf(buf
, bufsize
, "Unknown token");
62 case WPS_TOKEN_CHARACTER
:
63 snprintf(buf
, bufsize
, "Character '%c'",
67 case WPS_TOKEN_STRING
:
68 snprintf(buf
, bufsize
, "String '%s'",
69 (char*)token
->value
.data
);
72 #ifdef HAVE_LCD_BITMAP
73 case WPS_TOKEN_ALIGN_LEFT
:
74 snprintf(buf
, bufsize
, "align left");
77 case WPS_TOKEN_ALIGN_CENTER
:
78 snprintf(buf
, bufsize
, "align center");
81 case WPS_TOKEN_ALIGN_RIGHT
:
82 snprintf(buf
, bufsize
, "align right");
86 case WPS_TOKEN_SUBLINE_TIMEOUT
:
87 snprintf(buf
, bufsize
, "subline timeout value: %d",
91 case WPS_TOKEN_CONDITIONAL
:
92 snprintf(buf
, bufsize
, "conditional, %d options",
96 case WPS_TOKEN_CONDITIONAL_START
:
97 snprintf(buf
, bufsize
, "conditional start, next cond: %d",
101 case WPS_TOKEN_CONDITIONAL_OPTION
:
102 snprintf(buf
, bufsize
, "conditional option, next cond: %d",
106 case WPS_TOKEN_CONDITIONAL_END
:
107 snprintf(buf
, bufsize
, "conditional end");
110 #ifdef HAVE_LCD_BITMAP
111 case WPS_TOKEN_IMAGE_PRELOAD
:
112 snprintf(buf
, bufsize
, "preload image");
115 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
116 snprintf(buf
, bufsize
, "display preloaded image '%c'",
117 token
->value
.i
&0xFF);
120 case WPS_TOKEN_IMAGE_DISPLAY
:
121 snprintf(buf
, bufsize
, "display image");
125 #ifdef HAS_BUTTON_HOLD
126 case WPS_TOKEN_MAIN_HOLD
:
127 snprintf(buf
, bufsize
, "mode hold");
131 #ifdef HAS_REMOTE_BUTTON_HOLD
132 case WPS_TOKEN_REMOTE_HOLD
:
133 snprintf(buf
, bufsize
, "mode remote hold");
137 case WPS_TOKEN_REPEAT_MODE
:
138 snprintf(buf
, bufsize
, "mode repeat");
141 case WPS_TOKEN_PLAYBACK_STATUS
:
142 snprintf(buf
, bufsize
, "mode playback");
145 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
146 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
148 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
149 snprintf(buf
, bufsize
,
150 "rtc: day of month, blank padded ( 1..31)");
152 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
153 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
155 case WPS_TOKEN_RTC_HOUR_24
:
156 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
158 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
159 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
161 case WPS_TOKEN_RTC_HOUR_12
:
162 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
164 case WPS_TOKEN_RTC_MONTH
:
165 snprintf(buf
, bufsize
, "rtc: month (01..12)");
167 case WPS_TOKEN_RTC_MINUTE
:
168 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
170 case WPS_TOKEN_RTC_SECOND
:
171 snprintf(buf
, bufsize
, "rtc: second (00..59)");
173 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
174 snprintf(buf
, bufsize
,
175 "rtc: last two digits of year (00..99)");
177 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
178 snprintf(buf
, bufsize
, "rtc: year (1970...)");
180 case WPS_TOKEN_RTC_AM_PM_UPPER
:
181 snprintf(buf
, bufsize
,
182 "rtc: upper case AM or PM indicator");
184 case WPS_TOKEN_RTC_AM_PM_LOWER
:
185 snprintf(buf
, bufsize
,
186 "rtc: lower case am or pm indicator");
188 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
189 snprintf(buf
, bufsize
,
190 "rtc: abbreviated weekday name (Sun..Sat)");
192 case WPS_TOKEN_RTC_MONTH_NAME
:
193 snprintf(buf
, bufsize
,
194 "rtc: abbreviated month name (Jan..Dec)");
196 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
197 snprintf(buf
, bufsize
,
198 "rtc: day of week (1..7); 1 is Monday");
200 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
201 snprintf(buf
, bufsize
,
202 "rtc: day of week (0..6); 0 is Sunday");
205 #if (CONFIG_CODEC == SWCODEC)
206 case WPS_TOKEN_CROSSFADE
:
207 snprintf(buf
, bufsize
, "crossfade");
210 case WPS_TOKEN_REPLAYGAIN
:
211 snprintf(buf
, bufsize
, "replaygain");
216 case WPS_TOKEN_ALBUMART_DISPLAY
:
217 snprintf(buf
, bufsize
, "album art display");
220 case WPS_TOKEN_ALBUMART_FOUND
:
221 snprintf(buf
, bufsize
, "%strack album art conditional",
226 #ifdef HAVE_LCD_BITMAP
227 case WPS_TOKEN_IMAGE_BACKDROP
:
228 snprintf(buf
, bufsize
, "backdrop image");
231 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
232 snprintf(buf
, bufsize
, "progressbar bitmap");
235 case WPS_TOKEN_PEAKMETER
:
236 snprintf(buf
, bufsize
, "peakmeter");
240 case WPS_TOKEN_PROGRESSBAR
:
241 snprintf(buf
, bufsize
, "progressbar");
244 #ifdef HAVE_LCD_CHARCELLS
245 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
246 snprintf(buf
, bufsize
, "full line progressbar");
250 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
251 snprintf(buf
, bufsize
, "time elapsed in track");
254 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
255 snprintf(buf
, bufsize
, "played percentage of track");
258 case WPS_TOKEN_PLAYLIST_ENTRIES
:
259 snprintf(buf
, bufsize
, "number of entries in playlist");
262 case WPS_TOKEN_PLAYLIST_NAME
:
263 snprintf(buf
, bufsize
, "playlist name");
266 case WPS_TOKEN_PLAYLIST_POSITION
:
267 snprintf(buf
, bufsize
, "position in playlist");
270 case WPS_TOKEN_TRACK_TIME_REMAINING
:
271 snprintf(buf
, bufsize
, "time remaining in track");
274 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
275 snprintf(buf
, bufsize
, "playlist shuffle mode");
278 case WPS_TOKEN_TRACK_LENGTH
:
279 snprintf(buf
, bufsize
, "track length");
282 case WPS_TOKEN_VOLUME
:
283 snprintf(buf
, bufsize
, "volume");
286 case WPS_TOKEN_METADATA_ARTIST
:
287 snprintf(buf
, bufsize
, "%strack artist",
291 case WPS_TOKEN_METADATA_COMPOSER
:
292 snprintf(buf
, bufsize
, "%strack composer",
296 case WPS_TOKEN_METADATA_ALBUM
:
297 snprintf(buf
, bufsize
, "%strack album",
301 case WPS_TOKEN_METADATA_GROUPING
:
302 snprintf(buf
, bufsize
, "%strack grouping",
306 case WPS_TOKEN_METADATA_GENRE
:
307 snprintf(buf
, bufsize
, "%strack genre",
311 case WPS_TOKEN_METADATA_DISC_NUMBER
:
312 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
315 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
316 snprintf(buf
, bufsize
, "%strack number",
320 case WPS_TOKEN_METADATA_TRACK_TITLE
:
321 snprintf(buf
, bufsize
, "%strack title",
325 case WPS_TOKEN_METADATA_VERSION
:
326 snprintf(buf
, bufsize
, "%strack ID3 version",
330 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
331 snprintf(buf
, bufsize
, "%strack album artist",
335 case WPS_TOKEN_METADATA_COMMENT
:
336 snprintf(buf
, bufsize
, "%strack comment",
340 case WPS_TOKEN_METADATA_YEAR
:
341 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
345 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
346 snprintf(buf
, bufsize
, "track playcount (database)");
349 case WPS_TOKEN_DATABASE_RATING
:
350 snprintf(buf
, bufsize
, "track rating (database)");
353 case WPS_TOKEN_DATABASE_AUTOSCORE
:
354 snprintf(buf
, bufsize
, "track autoscore (database)");
358 case WPS_TOKEN_BATTERY_PERCENT
:
359 snprintf(buf
, bufsize
, "battery percentage");
362 case WPS_TOKEN_BATTERY_VOLTS
:
363 snprintf(buf
, bufsize
, "battery voltage");
366 case WPS_TOKEN_BATTERY_TIME
:
367 snprintf(buf
, bufsize
, "battery time left");
370 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
371 snprintf(buf
, bufsize
, "battery charger connected");
374 case WPS_TOKEN_BATTERY_CHARGING
:
375 snprintf(buf
, bufsize
, "battery charging");
378 case WPS_TOKEN_BATTERY_SLEEPTIME
:
379 snprintf(buf
, bufsize
, "sleep timer");
382 case WPS_TOKEN_FILE_BITRATE
:
383 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
386 case WPS_TOKEN_FILE_CODEC
:
387 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
390 case WPS_TOKEN_FILE_FREQUENCY
:
391 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
395 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
396 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
400 case WPS_TOKEN_FILE_NAME
:
401 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
404 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
405 snprintf(buf
, bufsize
, "%sfile name with extension",
409 case WPS_TOKEN_FILE_PATH
:
410 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
413 case WPS_TOKEN_FILE_SIZE
:
414 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
417 case WPS_TOKEN_FILE_VBR
:
418 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
421 case WPS_TOKEN_FILE_DIRECTORY
:
422 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
423 next_str(next
), token
->value
.i
);
426 #if (CONFIG_CODEC != MAS3507D)
427 case WPS_TOKEN_SOUND_PITCH
:
428 snprintf(buf
, bufsize
, "pitch value");
431 case WPS_VIEWPORT_ENABLE
:
432 snprintf(buf
, bufsize
, "enable VP:%d",
435 case WPS_TOKEN_BUTTON_VOLUME
:
436 snprintf(buf
, bufsize
, "Volume button timeout:%d",
440 snprintf(buf
, bufsize
, "FIXME (code: %d)",
448 #if defined(SIMULATOR) || defined(__PCTOOL__)
449 static void dump_wps_tokens(struct wps_data
*data
)
451 struct wps_token
*token
;
456 /* Dump parsed WPS */
457 for (i
= 0, token
= data
->tokens
; i
< data
->num_tokens
; i
++, token
++)
459 get_token_desc(token
, buf
, sizeof(buf
));
464 case WPS_TOKEN_CONDITIONAL_START
:
468 case WPS_TOKEN_CONDITIONAL_END
:
476 if (wps_verbose_level
> 2)
478 for(j
= 0; j
< indent
; j
++) {
482 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
487 static void print_line_info(struct wps_data
*data
)
490 struct wps_line
*line
;
491 struct wps_subline
*subline
;
492 if (wps_verbose_level
> 0)
494 struct skin_token_list
*viewport_list
;
495 for (viewport_list
= data
->viewports
;
496 viewport_list
; viewport_list
= viewport_list
->next
)
498 struct skin_viewport
*v
=
499 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
500 DEBUGF("vp Label:'%c' Hidden flags:%x\n", v
->label
, v
->hidden_flags
);
501 DEBUGF(" First line: %d\n", v
->first_line
);
502 DEBUGF(" Last line: %d\n", v
->last_line
);
504 DEBUGF("Number of sublines : %d\n", data
->num_sublines
);
505 DEBUGF("Number of tokens : %d\n", data
->num_tokens
);
509 if (wps_verbose_level
> 1)
511 struct skin_token_list
*viewport_list
;
512 for (viewport_list
= data
->viewports
;
513 viewport_list
; viewport_list
= viewport_list
->next
)
515 struct skin_viewport
*v
=
516 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
517 DEBUGF("Viewport '%c' - +%d+%d (%dx%d)\n",v
->label
, v
->vp
.x
, v
->vp
.y
,
518 v
->vp
.width
, v
->vp
.height
);
519 for (i
= v
->first_line
, line
= &data
->lines
[v
->first_line
]; i
<= v
->last_line
; i
++,line
++)
521 DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n",
522 i
, line
->num_sublines
, line
->first_subline_idx
);
524 for (j
= 0, subline
= data
->sublines
+ line
->first_subline_idx
;
525 j
< line
->num_sublines
; j
++, subline
++)
527 DEBUGF(" Subline %d: first_token=%3d, last_token=%3d",
528 j
, subline
->first_token_idx
,
529 skin_last_token_index(data
, i
, j
));
531 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
532 DEBUGF(", scrolled");
533 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
534 DEBUGF(", progressbar");
535 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
536 DEBUGF(", peakmeter");
548 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
550 #if defined(SIMULATOR) || defined(__PCTOOL__)
551 if (debug_wps
&& wps_verbose_level
)
553 dump_wps_tokens(data
);
554 print_line_info(data
);
556 #endif /* SIMULATOR */
558 if (data
->num_tokens
>= WPS_MAX_TOKENS
- 1) {
559 DEBUGF("Warning: Max number of tokens was reached (%d)\n",
563 if (fail
!= PARSE_OK
)
567 DEBUGF("ERR: Failed parsing on line %d : ", line
);
573 case PARSE_FAIL_UNCLOSED_COND
:
574 DEBUGF("ERR: Unclosed conditional");
577 case PARSE_FAIL_INVALID_CHAR
:
578 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
580 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
))
584 case PARSE_FAIL_COND_SYNTAX_ERROR
:
585 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
587 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
))
591 case PARSE_FAIL_COND_INVALID_PARAM
:
592 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
594 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
))
598 case PARSE_FAIL_LIMITS_EXCEEDED
:
599 DEBUGF("ERR: Limits exceeded");
606 void debug_skin_usage(void)
608 if (wps_verbose_level
> 1)
609 DEBUGF("Skin buffer usage: %ld/%ld\n", skin_buffer_usage(),
610 skin_buffer_usage() + skin_buffer_freespace());
614 #endif /* DEBUG || SIMULATOR */