summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-01-09 22:19:25 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-01-09 22:19:25 +0000
commit75380fd27d175bab1818ef35a9100e74fc6a461b (patch)
tree7553e7d74d26dde32ca3c3c01b9846af884939f3 /apps/plugins
parent81cf8b4d3bc4579b90a6fc4a97e61cc3acfc8c95 (diff)
downloadrockbox-75380fd27d175bab1818ef35a9100e74fc6a461b.tar.gz
rockbox-75380fd27d175bab1818ef35a9100e74fc6a461b.zip
mpegplayer on grayscale targets: use greylib to display all text and graphics with the video images.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16042 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/mpegplayer/mpeg_parser.c23
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c145
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c195
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.h15
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.c111
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.h9
-rw-r--r--apps/plugins/mpegplayer/video_out.h2
-rw-r--r--apps/plugins/mpegplayer/video_out_rockbox.c9
-rw-r--r--apps/plugins/mpegplayer/video_thread.c10
9 files changed, 261 insertions, 258 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_parser.c b/apps/plugins/mpegplayer/mpeg_parser.c
index 167f07da5c..0259bc9865 100644
--- a/apps/plugins/mpegplayer/mpeg_parser.c
+++ b/apps/plugins/mpegplayer/mpeg_parser.c
@@ -1032,7 +1032,28 @@ intptr_t parser_send_video_msg(long id, intptr_t data)
1032 break; 1032 break;
1033 } 1033 }
1034 1034
1035 retval = str_send_msg(&video_str, id, data); 1035 switch (id)
1036 {
1037#ifdef GRAY_CACHE_MAINT
1038 /* This must be done internally here or refresh may be delayed far
1039 * too long */
1040 case VIDEO_DISPLAY_SHOW:
1041 case VIDEO_PRINT_FRAME:
1042 case VIDEO_PRINT_THUMBNAIL:
1043 stream_gray_pause(true);
1044
1045 GRAY_INVALIDATE_ICACHE();
1046
1047 retval = str_send_msg(&video_str, id, data);
1048
1049 GRAY_VIDEO_FLUSH_ICACHE();
1050
1051 stream_gray_pause(false);
1052 break;
1053#endif
1054 default:
1055 retval = str_send_msg(&video_str, id, data);
1056 }
1036 } 1057 }
1037 1058
1038 return retval; 1059 return retval;
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index e99823ed5c..720101706c 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -178,17 +178,56 @@ static void display_options(void)
178 menu_exit(menu_id); 178 menu_exit(menu_id);
179} 179}
180 180
181#ifndef HAVE_LCD_COLOR
182/* Cheapo splash implementation for the grey surface */
183static void grey_splash(int ticks, const unsigned char *fmt, ...)
184{
185 unsigned char buffer[256];
186 int x, y, w, h;
187 int oldfg, oldmode;
188
189 va_list ap;
190 va_start(ap, fmt);
191
192 rb->vsnprintf(buffer, sizeof (buffer), fmt, ap);
193
194 va_end(ap);
195
196 grey_getstringsize(buffer, &w, &h);
197
198 oldfg = grey_get_foreground();
199 oldmode = grey_get_drawmode();
200
201 grey_set_drawmode(DRMODE_FG);
202 grey_set_foreground(GREY_LIGHTGRAY);
203
204 x = (LCD_WIDTH - w) / 2;
205 y = (LCD_HEIGHT - h) / 2;
206
207 grey_fillrect(x - 1, y - 1, w + 2, h + 2);
208
209 grey_set_foreground(GREY_BLACK);
210
211 grey_putsxy(x, y, buffer);
212 grey_drawrect(x - 2, y - 2, w + 4, h + 4);
213
214 grey_set_foreground(oldfg);
215 grey_set_drawmode(oldmode);
216
217 grey_update();
218
219 if (ticks > 0)
220 rb->sleep(ticks);
221}
222#endif /* !HAVE_LCD_COLOR */
223
181static void show_loading(struct vo_rect *rc) 224static void show_loading(struct vo_rect *rc)
182{ 225{
183 int oldmode; 226 int oldmode = lcd_(get_drawmode)();
184#ifndef HAVE_LCD_COLOR 227 lcd_(set_drawmode)(DRMODE_SOLID | DRMODE_INVERSEVID);
185 stream_gray_show(false); 228 lcd_(fillrect)(rc->l-1, rc->t-1, rc->r - rc->l + 2, rc->b - rc->t + 2);
186#endif 229 lcd_(set_drawmode)(oldmode);
187 oldmode = rb->lcd_get_drawmode(); 230 lcd_(splash)(0, "Loading...");
188 rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID);
189 rb->lcd_fillrect(rc->l-1, rc->t-1, rc->r - rc->l + 2, rc->b - rc->t + 2);
190 rb->lcd_set_drawmode(oldmode);
191 rb->splash(0, "Loading...");
192} 231}
193 232
194void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) 233void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc)
@@ -211,36 +250,36 @@ void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc)
211 /* Put positition on left */ 250 /* Put positition on left */
212 ts_to_hms(pos, &hms); 251 ts_to_hms(pos, &hms);
213 hms_format(str, sizeof(str), &hms); 252 hms_format(str, sizeof(str), &hms);
214 rb->lcd_getstringsize(str, NULL, &text_h); 253 lcd_(getstringsize)(str, NULL, &text_h);
215 text_y = SLIDER_Y - SLIDER_TEXTMARGIN - text_h; 254 text_y = SLIDER_Y - SLIDER_TEXTMARGIN - text_h;
216 255
217 if (rc == NULL) 256 if (rc == NULL)
218 { 257 {
219 int oldmode = rb->lcd_get_drawmode(); 258 int oldmode = lcd_(get_drawmode)();
220 rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); 259 lcd_(set_drawmode)(DRMODE_BG | DRMODE_INVERSEVID);
221 rb->lcd_fillrect(SLIDER_X, text_y, SLIDER_WIDTH, 260 lcd_(fillrect)(SLIDER_X, text_y, SLIDER_WIDTH,
222 LCD_HEIGHT - SLIDER_BMARGIN - text_y 261 LCD_HEIGHT - SLIDER_BMARGIN - text_y
223 - SLIDER_TMARGIN); 262 - SLIDER_TMARGIN);
224 rb->lcd_set_drawmode(oldmode); 263 lcd_(set_drawmode)(oldmode);
225 264
226 rb->lcd_putsxy(SLIDER_X, text_y, str); 265 lcd_(putsxy)(SLIDER_X, text_y, str);
227 266
228 /* Put duration on right */ 267 /* Put duration on right */
229 ts_to_hms(range, &hms); 268 ts_to_hms(range, &hms);
230 hms_format(str, sizeof(str), &hms); 269 hms_format(str, sizeof(str), &hms);
231 rb->lcd_getstringsize(str, &text_w, NULL); 270 lcd_(getstringsize)(str, &text_w, NULL);
232 271
233 rb->lcd_putsxy(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str); 272 lcd_(putsxy)(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str);
234 273
235 /* Draw slider */ 274 /* Draw slider */
236 rb->lcd_drawrect(SLIDER_X, SLIDER_Y, SLIDER_WIDTH, SLIDER_HEIGHT); 275 lcd_(drawrect)(SLIDER_X, SLIDER_Y, SLIDER_WIDTH, SLIDER_HEIGHT);
237 rb->lcd_fillrect(SLIDER_X, SLIDER_Y, 276 lcd_(fillrect)(SLIDER_X, SLIDER_Y,
238 muldiv_uint32(pos, SLIDER_WIDTH, range), 277 muldiv_uint32(pos, SLIDER_WIDTH, range),
239 SLIDER_HEIGHT); 278 SLIDER_HEIGHT);
240 279
241 /* Update screen */ 280 /* Update screen */
242 rb->lcd_update_rect(SLIDER_X, text_y - SLIDER_TMARGIN, SLIDER_WIDTH, 281 lcd_(update_rect)(SLIDER_X, text_y - SLIDER_TMARGIN, SLIDER_WIDTH,
243 LCD_HEIGHT - SLIDER_BMARGIN - text_y + SLIDER_TEXTMARGIN); 282 LCD_HEIGHT - SLIDER_BMARGIN - text_y + SLIDER_TEXTMARGIN);
244 } 283 }
245 else 284 else
246 { 285 {
@@ -256,33 +295,28 @@ bool display_thumb_image(const struct vo_rect *rc)
256{ 295{
257 if (!stream_display_thumb(rc)) 296 if (!stream_display_thumb(rc))
258 { 297 {
259 rb->splash(0, "Frame not available"); 298 lcd_(splash)(0, "Frame not available");
260 return false; 299 return false;
261 } 300 }
262 301
263#ifdef HAVE_LCD_COLOR
264 /* Draw a raised border around the frame */ 302 /* Draw a raised border around the frame */
265 int oldcolor = rb->lcd_get_foreground(); 303 int oldcolor = lcd_(get_foreground)();
266 rb->lcd_set_foreground(LCD_LIGHTGRAY); 304 lcd_(set_foreground)(DRAW_LIGHTGRAY);
267 305
268 rb->lcd_hline(rc->l-1, rc->r-1, rc->t-1); 306 lcd_(hline)(rc->l-1, rc->r-1, rc->t-1);
269 rb->lcd_vline(rc->l-1, rc->t, rc->b-1); 307 lcd_(vline)(rc->l-1, rc->t, rc->b-1);
270 308
271 rb->lcd_set_foreground(LCD_DARKGRAY); 309 lcd_(set_foreground)(DRAW_DARKGRAY);
272 310
273 rb->lcd_hline(rc->l-1, rc->r, rc->b); 311 lcd_(hline)(rc->l-1, rc->r, rc->b);
274 rb->lcd_vline(rc->r, rc->t-1, rc->b); 312 lcd_(vline)(rc->r, rc->t-1, rc->b);
275 313
276 rb->lcd_set_foreground(oldcolor); 314 lcd_(set_foreground)(oldcolor);
277 315
278 rb->lcd_update_rect(rc->l-1, rc->t-1, rc->r - rc->l + 2, 1); 316 lcd_(update_rect)(rc->l-1, rc->t-1, rc->r - rc->l + 2, 1);
279 rb->lcd_update_rect(rc->l-1, rc->t, 1, rc->b - rc->t); 317 lcd_(update_rect)(rc->l-1, rc->t, 1, rc->b - rc->t);
280 rb->lcd_update_rect(rc->l-1, rc->b, rc->r - rc->l + 2, 1); 318 lcd_(update_rect)(rc->l-1, rc->b, rc->r - rc->l + 2, 1);
281 rb->lcd_update_rect(rc->r, rc->t, 1, rc->b - rc->t); 319 lcd_(update_rect)(rc->r, rc->t, 1, rc->b - rc->t);
282#else
283 /* Just show the thumbnail */
284 stream_gray_show(true);
285#endif
286 320
287 return true; 321 return true;
288} 322}
@@ -320,18 +354,12 @@ int get_start_time(uint32_t duration)
320 354
321 enum state_enum slider_state = state0; 355 enum state_enum slider_state = state0;
322 356
323 rb->lcd_clear_display(); 357 lcd_(clear_display)();
324 rb->lcd_update(); 358 lcd_(update)();
325 359
326 draw_slider(0, 100, &rc_bound); 360 draw_slider(0, 100, &rc_bound);
327 rc_bound.b = rc_bound.t - SLIDER_TMARGIN; 361 rc_bound.b = rc_bound.t - SLIDER_TMARGIN;
328#ifdef HAVE_LCD_COLOR
329 rc_bound.t = SCREEN_MARGIN; 362 rc_bound.t = SCREEN_MARGIN;
330#else
331 rc_bound.t = 0;
332 rc_bound.l = 0;
333 rc_bound.r = LCD_WIDTH;
334#endif
335 363
336 DEBUGF("rc_bound: %d, %d, %d, %d\n", rc_bound.l, rc_bound.t, 364 DEBUGF("rc_bound: %d, %d, %d, %d\n", rc_bound.l, rc_bound.t,
337 rc_bound.r, rc_bound.b); 365 rc_bound.r, rc_bound.b);
@@ -344,12 +372,6 @@ int get_start_time(uint32_t duration)
344 rc_vid.b = rc_bound.b - rc_bound.t; 372 rc_vid.b = rc_bound.b - rc_bound.t;
345 } 373 }
346 374
347#if !defined (HAVE_LCD_COLOR)
348#if LCD_PIXELFORMAT == VERTICAL_PACKING
349 rc_bound.b &= ~7; /* Align bottom edge */
350#endif
351#endif
352
353 /* Get aspect ratio of bounding rectangle and video in u16.16 */ 375 /* Get aspect ratio of bounding rectangle and video in u16.16 */
354 aspect_bound = ((rc_bound.r - rc_bound.l) << 16) / 376 aspect_bound = ((rc_bound.r - rc_bound.l) << 16) /
355 (rc_bound.b - rc_bound.t); 377 (rc_bound.b - rc_bound.t);
@@ -398,8 +420,8 @@ int get_start_time(uint32_t duration)
398 rc_vid.r, rc_vid.b); 420 rc_vid.r, rc_vid.b);
399 421
400#ifndef HAVE_LCD_COLOR 422#ifndef HAVE_LCD_COLOR
401 /* Set gray overlay to the bounding rectangle */ 423 /* Restore gray overlay dimensions */
402 stream_set_gray_rect(&rc_bound); 424 stream_gray_show(true);
403#endif 425#endif
404 426
405 while(slider_state < state9) 427 while(slider_state < state9)
@@ -487,10 +509,9 @@ int get_start_time(uint32_t duration)
487 } 509 }
488 510
489#ifndef HAVE_LCD_COLOR 511#ifndef HAVE_LCD_COLOR
490 /* Restore gray overlay dimensions */
491 stream_gray_show(false); 512 stream_gray_show(false);
492 rc_bound.b = LCD_HEIGHT; 513 grey_clear_display();
493 stream_set_gray_rect(&rc_bound); 514 grey_update();
494#endif 515#endif
495 516
496 cancel_cpu_boost(); 517 cancel_cpu_boost();
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index b547d36f6a..a41d3b498a 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -257,10 +257,8 @@ struct wvs
257 int height; 257 int height;
258 unsigned fgcolor; 258 unsigned fgcolor;
259 unsigned bgcolor; 259 unsigned bgcolor;
260#ifdef HAVE_LCD_COLOR
261 unsigned prog_fillcolor; 260 unsigned prog_fillcolor;
262 struct vo_rect update_rect; 261 struct vo_rect update_rect;
263#endif
264 struct vo_rect prog_rect; 262 struct vo_rect prog_rect;
265 struct vo_rect time_rect; 263 struct vo_rect time_rect;
266 struct vo_rect dur_rect; 264 struct vo_rect dur_rect;
@@ -310,16 +308,21 @@ static unsigned draw_blendcolor(unsigned c1, unsigned c2, unsigned char amount)
310/* Drawing functions that operate rotated on LCD_PORTRAIT displays - 308/* Drawing functions that operate rotated on LCD_PORTRAIT displays -
311 * most are just wrappers of lcd_* functions with transforms applied. 309 * most are just wrappers of lcd_* functions with transforms applied.
312 * The origin is the upper-left corner of the WVS area */ 310 * The origin is the upper-left corner of the WVS area */
313#ifdef HAVE_LCD_COLOR
314static void draw_update_rect(int x, int y, int width, int height) 311static void draw_update_rect(int x, int y, int width, int height)
315{ 312{
316 rb->lcd_update_rect(_X, _Y, _W, _H); 313 lcd_(update_rect)(_X, _Y, _W, _H);
317} 314}
318#endif
319 315
320static void draw_clear_area(int x, int y, int width, int height) 316static void draw_clear_area(int x, int y, int width, int height)
321{ 317{
318#ifdef HAVE_LCD_COLOR
322 rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H); 319 rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H);
320#else
321 int oldmode = grey_get_drawmode();
322 grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
323 grey_fillrect(_X, _Y, _W, _H);
324 grey_set_drawmode(oldmode);
325#endif
323} 326}
324 327
325static void draw_clear_area_rect(const struct vo_rect *rc) 328static void draw_clear_area_rect(const struct vo_rect *rc)
@@ -328,48 +331,69 @@ static void draw_clear_area_rect(const struct vo_rect *rc)
328 int y = rc->t; 331 int y = rc->t;
329 int width = rc->r - rc->l; 332 int width = rc->r - rc->l;
330 int height = rc->b - rc->t; 333 int height = rc->b - rc->t;
334#ifdef HAVE_LCD_COLOR
331 rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H); 335 rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H);
336#else
337 int oldmode = grey_get_drawmode();
338 grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
339 grey_fillrect(_X, _Y, _W, _H);
340 grey_set_drawmode(oldmode);
341#endif
332} 342}
333 343
334static void draw_scrollbar_draw(int x, int y, int width, int height, 344static void draw_fillrect(int x, int y, int width, int height)
335 int items, int min_shown, int max_shown)
336{ 345{
337#ifdef HAVE_LCD_COLOR 346 lcd_(fillrect)(_X, _Y, _W, _H);
338 int oldbg = rb->lcd_get_background(); 347}
339 rb->lcd_set_background(wvs.prog_fillcolor);
340#endif
341 348
342 rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], _X, _Y, 349static void draw_hline(int x1, int x2, int y)
343 _W, _H, items, min_shown, max_shown, 350{
344 0
345#ifdef LCD_LANDSCAPE 351#ifdef LCD_LANDSCAPE
346 | HORIZONTAL 352 lcd_(hline)(x1 + wvs.x, x2 + wvs.x, y + wvs.y);
347#endif 353#else
348#ifdef HAVE_LCD_COLOR 354 y = LCD_WIDTH - (y + wvs.y) - 1;
349 | INNER_BGFILL | FOREGROUND 355 lcd_(vline)(y, x1 + wvs.x, x2 + wvs.x);
350#endif 356#endif
351 ); 357}
352 358
353#ifdef HAVE_LCD_COLOR 359static void draw_vline(int x, int y1, int y2)
354 rb->lcd_set_background(oldbg); 360{
361#ifdef LCD_LANDSCAPE
362 lcd_(vline)(x + wvs.x, y1 + wvs.y, y2 + wvs.y);
363#else
364 y1 = LCD_WIDTH - (y1 + wvs.y) - 1;
365 y2 = LCD_WIDTH - (y2 + wvs.y) - 1;
366 lcd_(hline)(y1, y2, x + wvs.x);
355#endif 367#endif
356} 368}
357 369
358static void draw_scrollbar_draw_rect(const struct vo_rect *rc, int items, 370static void draw_scrollbar_draw(int x, int y, int width, int height,
359 int min_shown, int max_shown) 371 uint32_t min, uint32_t max, uint32_t val)
360{ 372{
361 draw_scrollbar_draw(rc->l, rc->t, rc->r - rc->l, rc->b - rc->t, 373 unsigned oldfg = lcd_(get_foreground)();
362 items, min_shown, max_shown); 374
375 draw_hline(x + 1, x + width - 2, y);
376 draw_hline(x + 1, x + width - 2, y + height - 1);
377 draw_vline(x, y + 1, y + height - 2);
378 draw_vline(x + width - 1, y + 1, y + height - 2);
379
380 val = muldiv_uint32(width - 2, val, max - min);
381 val = MIN(val, (uint32_t)(width - 2));
382
383 draw_fillrect(x + 1, y + 1, val, height - 2);
384
385 lcd_(set_foreground)(wvs.prog_fillcolor);
386
387 draw_fillrect(x + 1 + val, y + 1, width - 2 - val, height - 2);
388
389 lcd_(set_foreground)(oldfg);
363} 390}
364 391
365static void draw_hline(int x1, int x2, int y) 392static void draw_scrollbar_draw_rect(const struct vo_rect *rc, int min,
393 int max, int val)
366{ 394{
367#ifdef LCD_LANDSCAPE 395 draw_scrollbar_draw(rc->l, rc->t, rc->r - rc->l, rc->b - rc->t,
368 rb->lcd_hline(x1 + wvs.x, x2 + wvs.x, y + wvs.y); 396 min, max, val);
369#else
370 y = LCD_WIDTH - (y + wvs.y) - 1;
371 rb->lcd_vline(y, x1 + wvs.x, x2 + wvs.x);
372#endif
373} 397}
374 398
375#ifdef LCD_PORTRAIT 399#ifdef LCD_PORTRAIT
@@ -480,18 +504,18 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src,
480 int stride, int x, int y, 504 int stride, int x, int y,
481 int width, int height) 505 int width, int height)
482{ 506{
483 int mode = rb->lcd_get_drawmode(); 507 int mode = lcd_(get_drawmode)();
484 rb->lcd_set_drawmode(DRMODE_FG); 508 lcd_(set_drawmode)(DRMODE_FG);
485 rb->lcd_mono_bitmap_part(src, src_x, src_y, stride, x, y, width, height); 509 lcd_(mono_bitmap_part)(src, src_x, src_y, stride, x, y, width, height);
486 rb->lcd_set_drawmode(mode); 510 lcd_(set_drawmode)(mode);
487} 511}
488 512
489static void draw_putsxy_oriented(int x, int y, const char *str) 513static void draw_putsxy_oriented(int x, int y, const char *str)
490{ 514{
491 int mode = rb->lcd_get_drawmode(); 515 int mode = lcd_(get_drawmode)();
492 rb->lcd_set_drawmode(DRMODE_FG); 516 lcd_(set_drawmode)(DRMODE_FG);
493 rb->lcd_putsxy(x + wvs.x, y + wvs.y, str); 517 lcd_(putsxy)(x + wvs.x, y + wvs.y, str);
494 rb->lcd_set_drawmode(mode); 518 lcd_(set_drawmode)(mode);
495} 519}
496#endif /* LCD_PORTRAIT */ 520#endif /* LCD_PORTRAIT */
497 521
@@ -503,7 +527,7 @@ static void wvs_text_init(void)
503 int phys; 527 int phys;
504 int spc_width; 528 int spc_width;
505 529
506 rb->lcd_setfont(FONT_UI); 530 lcd_(setfont)(FONT_UI);
507 531
508 wvs.x = 0; 532 wvs.x = 0;
509 wvs.width = SCREEN_WIDTH; 533 wvs.width = SCREEN_WIDTH;
@@ -515,8 +539,7 @@ static void wvs_text_init(void)
515 539
516 ts_to_hms(stream_get_duration(), &hms); 540 ts_to_hms(stream_get_duration(), &hms);
517 hms_format(buf, sizeof (buf), &hms); 541 hms_format(buf, sizeof (buf), &hms);
518 rb->lcd_getstringsize(buf, &wvs.time_rect.r, 542 lcd_(getstringsize)(buf, &wvs.time_rect.r, &wvs.time_rect.b);
519 &wvs.time_rect.b);
520 543
521 /* Choose well-sized bitmap images relative to font height */ 544 /* Choose well-sized bitmap images relative to font height */
522 if (wvs.time_rect.b < 12) { 545 if (wvs.time_rect.b < 12) {
@@ -546,8 +569,8 @@ static void wvs_text_init(void)
546 rb->snprintf(buf, sizeof(buf), "%d%s", phys, 569 rb->snprintf(buf, sizeof(buf), "%d%s", phys,
547 rb->sound_unit(SOUND_VOLUME)); 570 rb->sound_unit(SOUND_VOLUME));
548 571
549 rb->lcd_getstringsize(" ", &spc_width, NULL); 572 lcd_(getstringsize)(" ", &spc_width, NULL);
550 rb->lcd_getstringsize(buf, &wvs.vol_rect.r, &wvs.vol_rect.b); 573 lcd_(getstringsize)(buf, &wvs.vol_rect.r, &wvs.vol_rect.b);
551 574
552 wvs.prog_rect.r = SCREEN_WIDTH - WVS_BDR_L - spc_width - 575 wvs.prog_rect.r = SCREEN_WIDTH - WVS_BDR_L - spc_width -
553 wvs.vol_rect.r - WVS_BDR_R; 576 wvs.vol_rect.r - WVS_BDR_R;
@@ -568,14 +591,12 @@ static void wvs_text_init(void)
568 wvs.height = WVS_BDR_T + MAX(wvs.prog_rect.b, wvs.vol_rect.b) - 591 wvs.height = WVS_BDR_T + MAX(wvs.prog_rect.b, wvs.vol_rect.b) -
569 MIN(wvs.time_rect.t, wvs.stat_rect.t) + WVS_BDR_B; 592 MIN(wvs.time_rect.t, wvs.stat_rect.t) + WVS_BDR_B;
570 593
571#if LCD_PIXELFORMAT == VERTICAL_PACKING 594#ifdef HAVE_LCD_COLOR
572 wvs.height = ALIGN_UP(wvs.height, 8);
573#else
574 wvs.height = ALIGN_UP(wvs.height, 2); 595 wvs.height = ALIGN_UP(wvs.height, 2);
575#endif 596#endif
576 wvs.y = SCREEN_HEIGHT - wvs.height; 597 wvs.y = SCREEN_HEIGHT - wvs.height;
577 598
578 rb->lcd_setfont(FONT_SYSFIXED); 599 lcd_(setfont)(FONT_SYSFIXED);
579} 600}
580 601
581static void wvs_init(void) 602static void wvs_init(void)
@@ -589,8 +610,9 @@ static void wvs_init(void)
589 wvs.fgcolor = LCD_WHITE; 610 wvs.fgcolor = LCD_WHITE;
590 wvs.prog_fillcolor = LCD_BLACK; 611 wvs.prog_fillcolor = LCD_BLACK;
591#else 612#else
592 wvs.bgcolor = LCD_LIGHTGRAY; 613 wvs.bgcolor = GREY_LIGHTGRAY;
593 wvs.fgcolor = LCD_BLACK; 614 wvs.fgcolor = GREY_BLACK;
615 wvs.prog_fillcolor = GREY_WHITE;
594#endif 616#endif
595 wvs.curr_time = 0; 617 wvs.curr_time = 0;
596 wvs.status = WVS_STATUS_STOPPED; 618 wvs.status = WVS_STATUS_STOPPED;
@@ -623,37 +645,39 @@ static void wvs_refresh_background(void)
623 char buf[32]; 645 char buf[32];
624 struct hms hms; 646 struct hms hms;
625 647
626 int bg = rb->lcd_get_background(); 648 unsigned bg = lcd_(get_background)();
627 rb->lcd_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); 649 lcd_(set_drawmode)(DRMODE_SOLID | DRMODE_INVERSEVID);
628 650
629#ifdef HAVE_LCD_COLOR 651#ifdef HAVE_LCD_COLOR
630 /* Draw a "raised" area for our graphics */ 652 /* Draw a "raised" area for our graphics */
631 rb->lcd_set_background(draw_blendcolor(bg, LCD_WHITE, 192)); 653 lcd_(set_background)(draw_blendcolor(bg, DRAW_WHITE, 192));
632 draw_hline(0, wvs.width, 0); 654 draw_hline(0, wvs.width, 0);
633 655
634 rb->lcd_set_background(draw_blendcolor(bg, LCD_WHITE, 80)); 656 lcd_(set_background)(draw_blendcolor(bg, DRAW_WHITE, 80));
635 draw_hline(0, wvs.width, 1); 657 draw_hline(0, wvs.width, 1);
636 658
637 rb->lcd_set_background(draw_blendcolor(bg, LCD_BLACK, 48)); 659 lcd_(set_background)(draw_blendcolor(bg, DRAW_BLACK, 48));
638 draw_hline(0, wvs.width, wvs.height-2); 660 draw_hline(0, wvs.width, wvs.height-2);
639 661
640 rb->lcd_set_background(draw_blendcolor(bg, LCD_BLACK, 128)); 662 lcd_(set_background)(draw_blendcolor(bg, DRAW_BLACK, 128));
641 draw_hline(0, wvs.width, wvs.height-1); 663 draw_hline(0, wvs.width, wvs.height-1);
642 664
643 rb->lcd_set_background(bg); 665 lcd_(set_background)(bg);
644 draw_clear_area(0, 2, wvs.width, wvs.height - 4); 666 draw_clear_area(0, 2, wvs.width, wvs.height - 4);
645
646 vo_rect_set_ext(&wvs.update_rect, 0, 0, wvs.width, wvs.height);
647#else 667#else
648 /* Give contrast with the main background */ 668 /* Give contrast with the main background */
649 rb->lcd_set_background(LCD_DARKGRAY); 669 lcd_(set_background)(GREY_WHITE);
650 draw_hline(0, wvs.width, 0); 670 draw_hline(0, wvs.width, 0);
651 671
652 rb->lcd_set_background(bg); 672 lcd_(set_background)(GREY_DARKGRAY);
653 draw_clear_area(0, 1, wvs.width, wvs.height - 1); 673 draw_hline(0, wvs.width, wvs.height-1);
674
675 lcd_(set_background)(bg);
676 draw_clear_area(0, 1, wvs.width, wvs.height - 2);
654#endif 677#endif
655 678
656 rb->lcd_set_drawmode(DRMODE_SOLID); 679 vo_rect_set_ext(&wvs.update_rect, 0, 0, wvs.width, wvs.height);
680 lcd_(set_drawmode)(DRMODE_SOLID);
657 681
658 if (stream_get_duration() != INVALID_TIMESTAMP) { 682 if (stream_get_duration() != INVALID_TIMESTAMP) {
659 /* Draw the movie duration */ 683 /* Draw the movie duration */
@@ -672,7 +696,7 @@ static void wvs_refresh_time(void)
672 696
673 uint32_t duration = stream_get_duration(); 697 uint32_t duration = stream_get_duration();
674 698
675 draw_scrollbar_draw_rect(&wvs.prog_rect, duration, 0, 699 draw_scrollbar_draw_rect(&wvs.prog_rect, 0, duration,
676 wvs.curr_time); 700 wvs.curr_time);
677 701
678 ts_to_hms(wvs.curr_time, &hms); 702 ts_to_hms(wvs.curr_time, &hms);
@@ -681,12 +705,10 @@ static void wvs_refresh_time(void)
681 draw_clear_area_rect(&wvs.time_rect); 705 draw_clear_area_rect(&wvs.time_rect);
682 draw_putsxy_oriented(wvs.time_rect.l, wvs.time_rect.t, buf); 706 draw_putsxy_oriented(wvs.time_rect.l, wvs.time_rect.t, buf);
683 707
684#ifdef HAVE_LCD_COLOR
685 vo_rect_union(&wvs.update_rect, &wvs.update_rect, 708 vo_rect_union(&wvs.update_rect, &wvs.update_rect,
686 &wvs.prog_rect); 709 &wvs.prog_rect);
687 vo_rect_union(&wvs.update_rect, &wvs.update_rect, 710 vo_rect_union(&wvs.update_rect, &wvs.update_rect,
688 &wvs.time_rect); 711 &wvs.time_rect);
689#endif
690} 712}
691 713
692/* Refresh the volume display area */ 714/* Refresh the volume display area */
@@ -699,15 +721,13 @@ static void wvs_refresh_volume(void)
699 rb->snprintf(buf, sizeof (buf), "%d%s", 721 rb->snprintf(buf, sizeof (buf), "%d%s",
700 rb->sound_val2phys(SOUND_VOLUME, volume), 722 rb->sound_val2phys(SOUND_VOLUME, volume),
701 rb->sound_unit(SOUND_VOLUME)); 723 rb->sound_unit(SOUND_VOLUME));
702 rb->lcd_getstringsize(buf, &width, NULL); 724 lcd_(getstringsize)(buf, &width, NULL);
703 725
704 /* Right-justified */ 726 /* Right-justified */
705 draw_clear_area_rect(&wvs.vol_rect); 727 draw_clear_area_rect(&wvs.vol_rect);
706 draw_putsxy_oriented(wvs.vol_rect.r - width, wvs.vol_rect.t, buf); 728 draw_putsxy_oriented(wvs.vol_rect.r - width, wvs.vol_rect.t, buf);
707 729
708#ifdef HAVE_LCD_COLOR
709 vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.vol_rect); 730 vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.vol_rect);
710#endif
711} 731}
712 732
713/* Refresh the status icon */ 733/* Refresh the status icon */
@@ -719,11 +739,11 @@ static void wvs_refresh_status(void)
719 739
720#ifdef HAVE_LCD_COLOR 740#ifdef HAVE_LCD_COLOR
721 /* Draw status icon with a drop shadow */ 741 /* Draw status icon with a drop shadow */
722 unsigned oldfg = rb->lcd_get_foreground(); 742 unsigned oldfg = lcd_(get_foreground)();
723 int i = 1; 743 int i = 1;
724 744
725 rb->lcd_set_foreground(draw_blendcolor(rb->lcd_get_background(), 745 lcd_(set_foreground)(draw_blendcolor(lcd_(get_background)(),
726 LCD_BLACK, 96)); 746 DRAW_BLACK, 96));
727 747
728 while (1) 748 while (1)
729 { 749 {
@@ -738,7 +758,7 @@ static void wvs_refresh_status(void)
738 if (--i < 0) 758 if (--i < 0)
739 break; 759 break;
740 760
741 rb->lcd_set_foreground(oldfg); 761 lcd_(set_foreground)(oldfg);
742 } 762 }
743 763
744 vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect); 764 vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect);
@@ -750,6 +770,7 @@ static void wvs_refresh_status(void)
750 wvs.stat_rect.l + wvs.x, 770 wvs.stat_rect.l + wvs.x,
751 wvs.stat_rect.t + wvs.y, 771 wvs.stat_rect.t + wvs.y,
752 icon_size, icon_size); 772 icon_size, icon_size);
773 vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect);
753#endif 774#endif
754} 775}
755 776
@@ -859,16 +880,14 @@ static void wvs_refresh(int hint)
859 880
860 /* Set basic drawing params that are used. Elements that perform variations 881 /* Set basic drawing params that are used. Elements that perform variations
861 * will restore them. */ 882 * will restore them. */
862 oldfg = rb->lcd_get_foreground(); 883 oldfg = lcd_(get_foreground)();
863 oldbg = rb->lcd_get_background(); 884 oldbg = lcd_(get_background)();
864 885
865 rb->lcd_setfont(FONT_UI); 886 lcd_(setfont)(FONT_UI);
866 rb->lcd_set_foreground(wvs.fgcolor); 887 lcd_(set_foreground)(wvs.fgcolor);
867 rb->lcd_set_background(wvs.bgcolor); 888 lcd_(set_background)(wvs.bgcolor);
868 889
869#ifdef HAVE_LCD_COLOR
870 vo_rect_clear(&wvs.update_rect); 890 vo_rect_clear(&wvs.update_rect);
871#endif
872 891
873 if (hint & WVS_REFRESH_BACKGROUND) { 892 if (hint & WVS_REFRESH_BACKGROUND) {
874 wvs_refresh_background(); 893 wvs_refresh_background();
@@ -888,11 +907,10 @@ static void wvs_refresh(int hint)
888 } 907 }
889 908
890 /* Go back to defaults */ 909 /* Go back to defaults */
891 rb->lcd_setfont(FONT_SYSFIXED); 910 lcd_(setfont)(FONT_SYSFIXED);
892 rb->lcd_set_foreground(oldfg); 911 lcd_(set_foreground)(oldfg);
893 rb->lcd_set_background(oldbg); 912 lcd_(set_background)(oldbg);
894 913
895#ifdef HAVE_LCD_COLOR
896 /* Update the dirty rectangle */ 914 /* Update the dirty rectangle */
897 vo_lock(); 915 vo_lock();
898 916
@@ -902,10 +920,6 @@ static void wvs_refresh(int hint)
902 wvs.update_rect.b - wvs.update_rect.t); 920 wvs.update_rect.b - wvs.update_rect.t);
903 921
904 vo_unlock(); 922 vo_unlock();
905#else
906 /* Defer update to greylib */
907 grey_deferred_lcd_update();
908#endif
909} 923}
910 924
911/* Show/Hide the WVS */ 925/* Show/Hide the WVS */
@@ -930,7 +944,9 @@ static void wvs_show(unsigned show)
930 944
931 stream_vo_set_clip(NULL); 945 stream_vo_set_clip(NULL);
932 946
947#ifdef HAVE_LCD_COLOR
933 draw_clear_area(0, 0, wvs.width, wvs.height); 948 draw_clear_area(0, 0, wvs.width, wvs.height);
949#endif
934 950
935 if (!(show & WVS_NODRAW)) { 951 if (!(show & WVS_NODRAW)) {
936#ifdef HAVE_LCD_COLOR 952#ifdef HAVE_LCD_COLOR
@@ -1393,7 +1409,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1393 DEBUGF("Could not initialize streams\n"); 1409 DEBUGF("Could not initialize streams\n");
1394 } else { 1410 } else {
1395 rb->splash(0, "Loading..."); 1411 rb->splash(0, "Loading...");
1396
1397 init_settings((char*)parameter); 1412 init_settings((char*)parameter);
1398 1413
1399 err = stream_open((char *)parameter); 1414 err = stream_open((char *)parameter);
diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h
index 4ebf321fce..01ab9bdad6 100644
--- a/apps/plugins/mpegplayer/mpegplayer.h
+++ b/apps/plugins/mpegplayer/mpegplayer.h
@@ -80,11 +80,8 @@ enum mpeg_malloc_reason_t
80#define lcd_(fn) rb->lcd_##fn 80#define lcd_(fn) rb->lcd_##fn
81#define lcd_splash splash 81#define lcd_splash splash
82 82
83#define GRAY_FLUSH_ICACHE()
84#define GRAY_INVALIDATE_ICACHE()
85#define GRAY_VIDEO_FLUSH_ICACHE()
86#define GRAY_VIDEO_INVALIDATE_ICACHE()
87#else 83#else
84
88#include "grey.h" 85#include "grey.h"
89#define DRAW_BLACK GREY_BLACK 86#define DRAW_BLACK GREY_BLACK
90#define DRAW_DARKGRAY GREY_DARKGRAY 87#define DRAW_DARKGRAY GREY_DARKGRAY
@@ -92,6 +89,7 @@ enum mpeg_malloc_reason_t
92#define DRAW_WHITE GREY_WHITE 89#define DRAW_WHITE GREY_WHITE
93#define lcd_(fn) grey_##fn 90#define lcd_(fn) grey_##fn
94 91
92#if defined(CPU_PP) && NUM_CORES > 1
95#define GRAY_FLUSH_ICACHE() \ 93#define GRAY_FLUSH_ICACHE() \
96 IF_COP(flush_icache()) 94 IF_COP(flush_icache())
97#define GRAY_INVALIDATE_ICACHE() \ 95#define GRAY_INVALIDATE_ICACHE() \
@@ -100,11 +98,18 @@ enum mpeg_malloc_reason_t
100 IF_COP(parser_send_video_msg(VIDEO_GRAY_CACHEOP, 0)) 98 IF_COP(parser_send_video_msg(VIDEO_GRAY_CACHEOP, 0))
101#define GRAY_VIDEO_INVALIDATE_ICACHE() \ 99#define GRAY_VIDEO_INVALIDATE_ICACHE() \
102 IF_COP(parser_send_video_msg(VIDEO_GRAY_CACHEOP, 1)) 100 IF_COP(parser_send_video_msg(VIDEO_GRAY_CACHEOP, 1))
103#if NUM_CORES > 1 101
104#define GRAY_CACHE_MAINT 102#define GRAY_CACHE_MAINT
105#endif 103#endif
106#endif 104#endif
107 105
106#ifndef GRAY_CACHE_MAINT
107#define GRAY_FLUSH_ICACHE()
108#define GRAY_INVALIDATE_ICACHE()
109#define GRAY_VIDEO_FLUSH_ICACHE()
110#define GRAY_VIDEO_INVALIDATE_ICACHE()
111#endif
112
108#include "mpeg2.h" 113#include "mpeg2.h"
109#include "video_out.h" 114#include "video_out.h"
110#include "mpeg_stream.h" 115#include "mpeg_stream.h"
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c
index dbc8ce9427..096ac4b0f9 100644
--- a/apps/plugins/mpegplayer/stream_mgr.c
+++ b/apps/plugins/mpegplayer/stream_mgr.c
@@ -710,75 +710,13 @@ void stream_vo_set_clip(const struct vo_rect *rc)
710 stream_mgr.parms.rc = *rc; 710 stream_mgr.parms.rc = *rc;
711 rc = &stream_mgr.parms.rc; 711 rc = &stream_mgr.parms.rc;
712 } 712 }
713#ifndef HAVE_LCD_COLOR
714 else
715 {
716 vo_rect_set_ext(&stream_mgr.parms.rc, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
717 rc = &stream_mgr.parms.rc;
718 }
719#endif
720 713
721 parser_send_video_msg(VIDEO_SET_CLIP_RECT, (intptr_t)rc); 714 parser_send_video_msg(VIDEO_SET_CLIP_RECT, (intptr_t)rc);
722 715
723#ifndef HAVE_LCD_COLOR
724 stream_set_gray_rect(rc);
725#endif
726
727 stream_mgr_unlock(); 716 stream_mgr_unlock();
728} 717}
729 718
730#ifndef HAVE_LCD_COLOR 719#ifndef HAVE_LCD_COLOR
731/* Set the rectangle for the gray video overlay - clipped to screen */
732bool stream_set_gray_rect(const struct vo_rect *rc)
733{
734 bool retval = false;
735 struct vo_rect rc_gray;
736
737 stream_mgr_lock();
738
739 vo_rect_set_ext(&rc_gray, 0, 0, LCD_WIDTH, LCD_HEIGHT);
740
741 if (vo_rect_intersect(&rc_gray, &rc_gray, rc))
742 {
743 bool vis = parser_send_video_msg(VIDEO_DISPLAY_SHOW, false);
744
745 /* The impudence! Keeps the image from disappearing anyway. */
746#ifdef SIMULATOR
747 rb->sim_lcd_ex_init(0, NULL);
748#else
749 rb->timer_unregister();
750#endif
751 GRAY_VIDEO_INVALIDATE_ICACHE();
752 GRAY_INVALIDATE_ICACHE();
753
754 vo_lock();
755
756 grey_init(rb, stream_mgr.graymem, stream_mgr.graysize, false,
757 rc_gray.r - rc_gray.l, rc_gray.b - rc_gray.t, NULL);
758
759 grey_set_position(rc_gray.l, rc_gray.t);
760
761 vo_unlock();
762
763 GRAY_INVALIDATE_ICACHE();
764
765 if (stream_mgr.status != STREAM_PLAYING)
766 parser_send_video_msg(VIDEO_PRINT_FRAME, true);
767
768 GRAY_VIDEO_FLUSH_ICACHE();
769
770 if (vis)
771 {
772 grey_show(true);
773 parser_send_video_msg(VIDEO_DISPLAY_SHOW, true);
774 }
775 }
776
777 stream_mgr_unlock();
778
779 return retval;
780}
781
782/* Show/hide the gray video overlay (independently of vo visibility). */ 720/* Show/hide the gray video overlay (independently of vo visibility). */
783void stream_gray_show(bool show) 721void stream_gray_show(bool show)
784{ 722{
@@ -793,6 +731,29 @@ void stream_gray_show(bool show)
793 731
794 stream_mgr_unlock(); 732 stream_mgr_unlock();
795} 733}
734
735#ifdef GRAY_CACHE_MAINT
736void stream_gray_pause(bool pause)
737{
738 static bool gray_paused = false;
739
740 if (pause && !gray_paused)
741 {
742 if (_grey_info.flags & _GREY_RUNNING)
743 {
744 rb->timer_unregister();
745 _grey_info.flags &= ~_GREY_RUNNING;
746 gray_paused = true;
747 }
748 }
749 else if (!pause && gray_paused)
750 {
751 gray_paused = false;
752 grey_show(true);
753 }
754}
755#endif
756
796#endif 757#endif
797 758
798/* Display a thumbnail at the last seek point */ 759/* Display a thumbnail at the last seek point */
@@ -805,14 +766,10 @@ bool stream_display_thumb(const struct vo_rect *rc)
805 766
806 stream_mgr_lock(); 767 stream_mgr_lock();
807 768
808 GRAY_INVALIDATE_ICACHE();
809
810 stream_mgr.parms.rc = *rc; 769 stream_mgr.parms.rc = *rc;
811 retval = parser_send_video_msg(VIDEO_PRINT_THUMBNAIL, 770 retval = parser_send_video_msg(VIDEO_PRINT_THUMBNAIL,
812 (intptr_t)&stream_mgr.parms.rc); 771 (intptr_t)&stream_mgr.parms.rc);
813 772
814 GRAY_VIDEO_FLUSH_ICACHE();
815
816 stream_mgr_unlock(); 773 stream_mgr_unlock();
817 774
818 return retval; 775 return retval;
@@ -823,12 +780,8 @@ bool stream_draw_frame(bool no_prepare)
823 bool retval; 780 bool retval;
824 stream_mgr_lock(); 781 stream_mgr_lock();
825 782
826 GRAY_INVALIDATE_ICACHE();
827
828 retval = parser_send_video_msg(VIDEO_PRINT_FRAME, no_prepare); 783 retval = parser_send_video_msg(VIDEO_PRINT_FRAME, no_prepare);
829 784
830 GRAY_VIDEO_FLUSH_ICACHE();
831
832 stream_mgr_unlock(); 785 stream_mgr_unlock();
833 786
834 return retval; 787 return retval;
@@ -1055,26 +1008,27 @@ int stream_init(void)
1055 /* Initialize non-allocator blocks first */ 1008 /* Initialize non-allocator blocks first */
1056#ifndef HAVE_LCD_COLOR 1009#ifndef HAVE_LCD_COLOR
1057 bool success; 1010 bool success;
1011 long graysize;
1058 1012
1059 /* This can run on another processor - align data */ 1013 /* This can run on another processor - align data */
1060 memsize = CACHEALIGN_BUFFER(&mem, memsize); 1014 memsize = CACHEALIGN_BUFFER(&mem, memsize);
1061 stream_mgr.graymem = mem;
1062 1015
1063 success = grey_init(rb, mem, memsize, false, LCD_WIDTH, 1016 success = grey_init(rb, mem, memsize, true, LCD_WIDTH,
1064 LCD_HEIGHT, &stream_mgr.graysize); 1017 LCD_HEIGHT, &graysize);
1065 1018
1066 /* This can run on another processor - align size */ 1019 /* This can run on another processor - align size */
1067 stream_mgr.graysize = CACHEALIGN_UP(stream_mgr.graysize); 1020 graysize = CACHEALIGN_UP(graysize);
1068 1021
1069 mem += stream_mgr.graysize; 1022 mem += graysize;
1070 memsize -= stream_mgr.graysize; 1023 memsize -= graysize;
1071 1024
1072 if (!success || (ssize_t)memsize <= 0) 1025 if (!success || (ssize_t)memsize <= 0)
1073 { 1026 {
1074 rb->splash(HZ, "greylib init failed!"); 1027 rb->splash(HZ, "greylib init failed!");
1075 stream_mgr.graymem = NULL;
1076 return STREAM_ERROR; 1028 return STREAM_ERROR;
1077 } 1029 }
1030
1031 grey_clear_display();
1078#endif /* !HAVE_LCD_COLOR */ 1032#endif /* !HAVE_LCD_COLOR */
1079 1033
1080 stream_mgr.thread = rb->create_thread(stream_mgr_thread, 1034 stream_mgr.thread = rb->create_thread(stream_mgr_thread,
@@ -1144,7 +1098,6 @@ void stream_exit(void)
1144 } 1098 }
1145 1099
1146#ifndef HAVE_LCD_COLOR 1100#ifndef HAVE_LCD_COLOR
1147 if (stream_mgr.graymem != NULL) 1101 grey_release();
1148 grey_release();
1149#endif 1102#endif
1150} 1103}
diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h
index dd5d8cabec..b2aa90967e 100644
--- a/apps/plugins/mpegplayer/stream_mgr.h
+++ b/apps/plugins/mpegplayer/stream_mgr.h
@@ -37,10 +37,6 @@ struct stream_mgr
37 struct list_item actl; /* List of active streams */ 37 struct list_item actl; /* List of active streams */
38 struct mutex str_mtx; /* Main stream manager mutex */ 38 struct mutex str_mtx; /* Main stream manager mutex */
39 struct mutex actl_mtx; /* Lock for current-streams list */ 39 struct mutex actl_mtx; /* Lock for current-streams list */
40#ifndef HAVE_LCD_COLOR
41 void *graymem;
42 size_t graysize;
43#endif
44 union /* A place for reusable non-cacheable parameters */ 40 union /* A place for reusable non-cacheable parameters */
45 { 41 {
46 struct vo_rect rc; 42 struct vo_rect rc;
@@ -109,9 +105,10 @@ bool stream_show_vo(bool show);
109void stream_vo_set_clip(const struct vo_rect *rc); 105void stream_vo_set_clip(const struct vo_rect *rc);
110 106
111#ifndef HAVE_LCD_COLOR 107#ifndef HAVE_LCD_COLOR
112/* Set the gray overlay rectangle */
113bool stream_set_gray_rect(const struct vo_rect *rc);
114void stream_gray_show(bool show); 108void stream_gray_show(bool show);
109#ifdef GRAY_CACHE_MAINT
110void stream_gray_pause(bool pause);
111#endif
115#endif 112#endif
116 113
117/* Display thumbnail of the current seekpoint */ 114/* Display thumbnail of the current seekpoint */
diff --git a/apps/plugins/mpegplayer/video_out.h b/apps/plugins/mpegplayer/video_out.h
index ed8c4c5907..0b521b40b3 100644
--- a/apps/plugins/mpegplayer/video_out.h
+++ b/apps/plugins/mpegplayer/video_out.h
@@ -57,7 +57,7 @@ void vo_set_clip_rect(const struct vo_rect *rc);
57void vo_dimensions(struct vo_ext *sz); 57void vo_dimensions(struct vo_ext *sz);
58void vo_cleanup (void); 58void vo_cleanup (void);
59 59
60#if NUM_CORES > 1 || !defined (HAVE_LCD_COLOR) 60#if NUM_CORES > 1
61void vo_lock(void); 61void vo_lock(void);
62void vo_unlock(void); 62void vo_unlock(void);
63#else 63#else
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c
index 12431bef4a..5a479858f1 100644
--- a/apps/plugins/mpegplayer/video_out_rockbox.c
+++ b/apps/plugins/mpegplayer/video_out_rockbox.c
@@ -503,21 +503,14 @@ void vo_set_clip_rect(const struct vo_rect *rc)
503 vo.output_height = rc_out.b - rc_out.t; 503 vo.output_height = rc_out.b - rc_out.t;
504} 504}
505 505
506#if NUM_CORES > 1 || !defined (HAVE_LCD_COLOR) 506#if NUM_CORES > 1
507void vo_lock(void) 507void vo_lock(void)
508{ 508{
509/* TODO: evaluate synchronization with graylib in the sim */
510#if !defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
511 set_irq_level(HIGHEST_IRQ_LEVEL);
512#endif
513 video_lock(); 509 video_lock();
514} 510}
515 511
516void vo_unlock(void) 512void vo_unlock(void)
517{ 513{
518 video_unlock(); 514 video_unlock();
519#if !defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
520 set_irq_level(0);
521#endif
522} 515}
523#endif 516#endif
diff --git a/apps/plugins/mpegplayer/video_thread.c b/apps/plugins/mpegplayer/video_thread.c
index 6a54706942..4fc428d522 100644
--- a/apps/plugins/mpegplayer/video_thread.c
+++ b/apps/plugins/mpegplayer/video_thread.c
@@ -72,10 +72,10 @@ static void draw_fps(struct video_thread_data *td)
72 rb->snprintf(str, sizeof(str), "%d.%02d %d %d ", 72 rb->snprintf(str, sizeof(str), "%d.%02d %d %d ",
73 fps / 100, fps % 100, td->num_skipped, 73 fps / 100, fps % 100, td->num_skipped,
74 td->info->display_picture->temporal_reference); 74 td->info->display_picture->temporal_reference);
75 rb->lcd_putsxy(0, 0, str); 75 lcd_(putsxy)(0, 0, str);
76 76
77 vo_lock(); 77 vo_lock();
78 rb->lcd_update_rect(0, 0, LCD_WIDTH, 8); 78 lcd_(update_rect)(0, 0, LCD_WIDTH, 8);
79 vo_unlock(); 79 vo_unlock();
80 80
81 td->last_showfps = *rb->current_tick; 81 td->last_showfps = *rb->current_tick;
@@ -489,7 +489,7 @@ static void video_thread_msg(struct video_thread_data *td)
489 489
490 case STREAM_STOP: 490 case STREAM_STOP:
491 if (td->state == TSTATE_DATA) 491 if (td->state == TSTATE_DATA)
492 stream_clear_notify(&audio_str, DISK_BUF_DATA_NOTIFY); 492 stream_clear_notify(&video_str, DISK_BUF_DATA_NOTIFY);
493 493
494 td->status = STREAM_STOPPED; 494 td->status = STREAM_STOPPED;
495 td->state = TSTATE_EOS; 495 td->state = TSTATE_EOS;
@@ -522,14 +522,12 @@ static void video_thread_msg(struct video_thread_data *td)
522 rb->lcd_update(); 522 rb->lcd_update();
523 vo_unlock(); 523 vo_unlock();
524 } 524 }
525#else
526 GRAY_FLUSH_ICACHE();
527#endif 525#endif
528 break; 526 break;
529 527
530 case STREAM_RESET: 528 case STREAM_RESET:
531 if (td->state == TSTATE_DATA) 529 if (td->state == TSTATE_DATA)
532 stream_clear_notify(&audio_str, DISK_BUF_DATA_NOTIFY); 530 stream_clear_notify(&video_str, DISK_BUF_DATA_NOTIFY);
533 531
534 td->state = TSTATE_INIT; 532 td->state = TSTATE_INIT;
535 td->status = STREAM_STOPPED; 533 td->status = STREAM_STOPPED;