diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-03 10:17:41 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-03 13:30:01 +0100 |
commit | fe6aa21e9eb88f49005863efd2003d0982920048 (patch) | |
tree | 11ffde0fdde131f39145542506cf9020dcf384d3 /firmware/drivers | |
parent | b371ff1f4758f6781e2b89f86bd8e65b8585f56e (diff) | |
download | rockbox-fe6aa21e9eb88f49005863efd2003d0982920048.tar.gz rockbox-fe6aa21e9eb88f49005863efd2003d0982920048.zip |
Remove YUV blitting functions and LCD modes
None of this is needed now that mpegplayer is gone.
Change-Id: I360366db8513e4d988021e8d7b7d8eb09930efb8
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd-color-common.c | 189 | ||||
-rw-r--r-- | firmware/drivers/lcd-memframe.c | 98 |
2 files changed, 0 insertions, 287 deletions
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c index 9feba9f894..72ce7c209f 100644 --- a/firmware/drivers/lcd-color-common.c +++ b/firmware/drivers/lcd-color-common.c | |||
@@ -379,195 +379,6 @@ static inline int clamp(int val, int min, int max) | |||
379 | return val; | 379 | return val; |
380 | } | 380 | } |
381 | 381 | ||
382 | #ifndef _WIN32 | ||
383 | /* | ||
384 | * weak attribute doesn't work for win32 as of gcc 4.6.2 and binutils 2.21.52 | ||
385 | * When building win32 simulators, we won't be using an optimized version of | ||
386 | * lcd_blit_yuv(), so just don't use the weak attribute. | ||
387 | */ | ||
388 | __attribute__((weak)) | ||
389 | #endif | ||
390 | void lcd_yuv_set_options(unsigned options) | ||
391 | { | ||
392 | (void)options; | ||
393 | } | ||
394 | |||
395 | /* Draw a partial YUV colour bitmap */ | ||
396 | #ifndef _WIN32 | ||
397 | __attribute__((weak)) | ||
398 | #endif | ||
399 | void lcd_blit_yuv(unsigned char * const src[3], | ||
400 | int src_x, int src_y, int stride, | ||
401 | int x, int y, int width, int height) | ||
402 | { | ||
403 | const unsigned char *ysrc, *usrc, *vsrc; | ||
404 | int linecounter; | ||
405 | fb_data *dst, *row_end; | ||
406 | long z; | ||
407 | |||
408 | /* width and height must be >= 2 and an even number */ | ||
409 | width &= ~1; | ||
410 | linecounter = height >> 1; | ||
411 | |||
412 | #if LCD_WIDTH >= LCD_HEIGHT | ||
413 | dst = FBADDR(x, y); | ||
414 | row_end = dst + width; | ||
415 | #else | ||
416 | dst = FBADDR(LCD_WIDTH - y - 1, x); | ||
417 | row_end = dst + LCD_WIDTH * width; | ||
418 | #endif | ||
419 | |||
420 | z = stride * src_y; | ||
421 | ysrc = src[0] + z + src_x; | ||
422 | usrc = src[1] + (z >> 2) + (src_x >> 1); | ||
423 | vsrc = src[2] + (usrc - src[1]); | ||
424 | |||
425 | /* stride => amount to jump from end of last row to start of next */ | ||
426 | stride -= width; | ||
427 | |||
428 | /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */ | ||
429 | |||
430 | do | ||
431 | { | ||
432 | do | ||
433 | { | ||
434 | int y, cb, cr, rv, guv, bu, r, g, b; | ||
435 | |||
436 | y = YFAC*(*ysrc++ - 16); | ||
437 | cb = *usrc++ - 128; | ||
438 | cr = *vsrc++ - 128; | ||
439 | |||
440 | rv = RVFAC*cr; | ||
441 | guv = GUFAC*cb + GVFAC*cr; | ||
442 | bu = BUFAC*cb; | ||
443 | |||
444 | r = y + rv; | ||
445 | g = y + guv; | ||
446 | b = y + bu; | ||
447 | |||
448 | if ((unsigned)(r | g | b) > 64*256-1) | ||
449 | { | ||
450 | r = clamp(r, 0, 64*256-1); | ||
451 | g = clamp(g, 0, 64*256-1); | ||
452 | b = clamp(b, 0, 64*256-1); | ||
453 | } | ||
454 | |||
455 | *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6); | ||
456 | |||
457 | #if LCD_WIDTH >= LCD_HEIGHT | ||
458 | dst++; | ||
459 | #else | ||
460 | dst += LCD_WIDTH; | ||
461 | #endif | ||
462 | |||
463 | y = YFAC*(*ysrc++ - 16); | ||
464 | r = y + rv; | ||
465 | g = y + guv; | ||
466 | b = y + bu; | ||
467 | |||
468 | if ((unsigned)(r | g | b) > 64*256-1) | ||
469 | { | ||
470 | r = clamp(r, 0, 64*256-1); | ||
471 | g = clamp(g, 0, 64*256-1); | ||
472 | b = clamp(b, 0, 64*256-1); | ||
473 | } | ||
474 | |||
475 | *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6); | ||
476 | |||
477 | #if LCD_WIDTH >= LCD_HEIGHT | ||
478 | dst++; | ||
479 | #else | ||
480 | dst += LCD_WIDTH; | ||
481 | #endif | ||
482 | } | ||
483 | while (dst < row_end); | ||
484 | |||
485 | ysrc += stride; | ||
486 | usrc -= width >> 1; | ||
487 | vsrc -= width >> 1; | ||
488 | |||
489 | #if LCD_WIDTH >= LCD_HEIGHT | ||
490 | row_end += LCD_WIDTH; | ||
491 | dst += LCD_WIDTH - width; | ||
492 | #else | ||
493 | row_end -= 1; | ||
494 | dst -= LCD_WIDTH*width + 1; | ||
495 | #endif | ||
496 | |||
497 | do | ||
498 | { | ||
499 | int y, cb, cr, rv, guv, bu, r, g, b; | ||
500 | |||
501 | y = YFAC*(*ysrc++ - 16); | ||
502 | cb = *usrc++ - 128; | ||
503 | cr = *vsrc++ - 128; | ||
504 | |||
505 | rv = RVFAC*cr; | ||
506 | guv = GUFAC*cb + GVFAC*cr; | ||
507 | bu = BUFAC*cb; | ||
508 | |||
509 | r = y + rv; | ||
510 | g = y + guv; | ||
511 | b = y + bu; | ||
512 | |||
513 | if ((unsigned)(r | g | b) > 64*256-1) | ||
514 | { | ||
515 | r = clamp(r, 0, 64*256-1); | ||
516 | g = clamp(g, 0, 64*256-1); | ||
517 | b = clamp(b, 0, 64*256-1); | ||
518 | } | ||
519 | |||
520 | *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6); | ||
521 | |||
522 | #if LCD_WIDTH >= LCD_HEIGHT | ||
523 | dst++; | ||
524 | #else | ||
525 | dst += LCD_WIDTH; | ||
526 | #endif | ||
527 | |||
528 | y = YFAC*(*ysrc++ - 16); | ||
529 | r = y + rv; | ||
530 | g = y + guv; | ||
531 | b = y + bu; | ||
532 | |||
533 | if ((unsigned)(r | g | b) > 64*256-1) | ||
534 | { | ||
535 | r = clamp(r, 0, 64*256-1); | ||
536 | g = clamp(g, 0, 64*256-1); | ||
537 | b = clamp(b, 0, 64*256-1); | ||
538 | } | ||
539 | |||
540 | *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6); | ||
541 | |||
542 | #if LCD_WIDTH >= LCD_HEIGHT | ||
543 | dst++; | ||
544 | #else | ||
545 | dst += LCD_WIDTH; | ||
546 | #endif | ||
547 | } | ||
548 | while (dst < row_end); | ||
549 | |||
550 | ysrc += stride; | ||
551 | usrc += stride >> 1; | ||
552 | vsrc += stride >> 1; | ||
553 | |||
554 | #if LCD_WIDTH >= LCD_HEIGHT | ||
555 | row_end += LCD_WIDTH; | ||
556 | dst += LCD_WIDTH - width; | ||
557 | #else | ||
558 | row_end -= 1; | ||
559 | dst -= LCD_WIDTH*width + 1; | ||
560 | #endif | ||
561 | } | ||
562 | while (--linecounter > 0); | ||
563 | |||
564 | #if LCD_WIDTH >= LCD_HEIGHT | ||
565 | lcd_update_rect(x, y, width, height); | ||
566 | #else | ||
567 | lcd_update_rect(LCD_WIDTH - y - height, x, height, width); | ||
568 | #endif | ||
569 | } | ||
570 | |||
571 | /* Fill a rectangle with a gradient. This function draws only the partial | 382 | /* Fill a rectangle with a gradient. This function draws only the partial |
572 | * gradient. It assumes the original gradient is src_height high and skips | 383 | * gradient. It assumes the original gradient is src_height high and skips |
573 | * the first few rows. This is useful for drawing only the bottom half of | 384 | * the first few rows. This is useful for drawing only the bottom half of |
diff --git a/firmware/drivers/lcd-memframe.c b/firmware/drivers/lcd-memframe.c index bb1682b074..357b4af32a 100644 --- a/firmware/drivers/lcd-memframe.c +++ b/firmware/drivers/lcd-memframe.c | |||
@@ -110,101 +110,3 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | #endif /* LCD_OPTIMIZED_UPDATE_RECT */ | 112 | #endif /* LCD_OPTIMIZED_UPDATE_RECT */ |
113 | |||
114 | |||
115 | /*** YUV functions ***/ | ||
116 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; | ||
117 | |||
118 | |||
119 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
120 | extern void lcd_write_yuv420_lines(fb_data *dst, | ||
121 | unsigned char const * const src[3], | ||
122 | int width, | ||
123 | int stride); | ||
124 | extern void lcd_write_yuv420_lines_odither(fb_data *dst, | ||
125 | unsigned char const * const src[3], | ||
126 | int width, | ||
127 | int stride, | ||
128 | int x_screen, /* To align dither pattern */ | ||
129 | int y_screen); | ||
130 | |||
131 | void lcd_yuv_set_options(unsigned options) | ||
132 | { | ||
133 | lcd_yuv_options = options; | ||
134 | } | ||
135 | |||
136 | #ifndef LCD_OPTIMIZED_BLIT_YUV | ||
137 | /* Performance function to blit a YUV bitmap directly to the LCD | ||
138 | * src_x, src_y, width and height should be even and within the LCD's | ||
139 | * boundaries. | ||
140 | * | ||
141 | * For portrait LCDs, show it rotated counterclockwise by 90 degrees | ||
142 | */ | ||
143 | void lcd_blit_yuv(unsigned char * const src[3], | ||
144 | int src_x, int src_y, int stride, | ||
145 | int x, int y, int width, int height) | ||
146 | { | ||
147 | /* Macrofy the bits that change between orientations */ | ||
148 | #if CONFIG_ORIENTATION == SCREEN_PORTRAIT | ||
149 | #define LCD_FRAMEBUF_ADDR_ORIENTED(col, row) \ | ||
150 | LCD_FRAMEBUF_ADDR(row, col) | ||
151 | #define lcd_write_yuv420_lines_odither_oriented(dst, src, w, s, col, row) \ | ||
152 | lcd_write_yuv420_lines_odither(dst, src, w, s, row, col) | ||
153 | #define YUV_NEXTLINE() dst -= 2 | ||
154 | #define YUV_DITHER_NEXTLINE() dst -= 2, y -= 2 | ||
155 | #else | ||
156 | #define LCD_FRAMEBUF_ADDR_ORIENTED(col, row) \ | ||
157 | LCD_FRAMEBUF_ADDR(col, row) | ||
158 | #define lcd_write_yuv420_lines_odither_oriented(dst, src, w, s, col, row) \ | ||
159 | lcd_write_yuv420_lines_odither(dst, src, w, s, col, row) | ||
160 | #define YUV_NEXTLINE() dst += 2*LCD_FBWIDTH | ||
161 | #define YUV_DITHER_NEXTLINE() dst += 2*LCD_FBWIDTH, y += 2 | ||
162 | #endif | ||
163 | |||
164 | if (!lcd_write_enabled()) | ||
165 | return; | ||
166 | |||
167 | /* Sorry, but width and height must be >= 2 or else */ | ||
168 | width &= ~1; | ||
169 | height >>= 1; | ||
170 | |||
171 | #if CONFIG_ORIENTATION == SCREEN_PORTRAIT | ||
172 | /* Adjust portrait coordinates to make (0, 0) the upper right corner */ | ||
173 | y = LCD_WIDTH - 1 - y; | ||
174 | #endif | ||
175 | |||
176 | fb_data *dst = LCD_FRAMEBUF_ADDR_ORIENTED(x, y); | ||
177 | int z = stride*src_y; | ||
178 | |||
179 | unsigned char const * yuv_src[3]; | ||
180 | yuv_src[0] = src[0] + z + src_x; | ||
181 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
182 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
183 | |||
184 | if (lcd_yuv_options & LCD_YUV_DITHER) | ||
185 | { | ||
186 | do | ||
187 | { | ||
188 | lcd_write_yuv420_lines_odither_oriented(dst, yuv_src, width, | ||
189 | stride, x, y); | ||
190 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
191 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
192 | yuv_src[2] += stride >> 1; | ||
193 | YUV_DITHER_NEXTLINE(); | ||
194 | } | ||
195 | while (--height > 0); | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | do | ||
200 | { | ||
201 | lcd_write_yuv420_lines(dst, yuv_src, width, stride); | ||
202 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
203 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
204 | yuv_src[2] += stride >> 1; | ||
205 | YUV_NEXTLINE(); | ||
206 | } | ||
207 | while (--height > 0); | ||
208 | } | ||
209 | } | ||
210 | #endif /* LCD_OPTIMIZED_BLIT_YUV */ | ||