summaryrefslogtreecommitdiff
path: root/firmware/target/arm/samsung/yh820/lcd-yh820.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/samsung/yh820/lcd-yh820.c')
-rw-r--r--firmware/target/arm/samsung/yh820/lcd-yh820.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/firmware/target/arm/samsung/yh820/lcd-yh820.c b/firmware/target/arm/samsung/yh820/lcd-yh820.c
index 25692eb8ac..f4b55ab917 100644
--- a/firmware/target/arm/samsung/yh820/lcd-yh820.c
+++ b/firmware/target/arm/samsung/yh820/lcd-yh820.c
@@ -30,6 +30,8 @@
30#endif 30#endif
31 31
32/* Display status */ 32/* Display status */
33static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
34
33#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 35#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
34static bool is_lcd_enabled = true; 36static bool is_lcd_enabled = true;
35#endif 37#endif
@@ -289,6 +291,78 @@ void lcd_set_flip(bool yesno)
289 291
290/*** update functions ***/ 292/*** update functions ***/
291 293
294void lcd_yuv_set_options(unsigned options)
295{
296 lcd_yuv_options = options;
297}
298
299/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
300extern void lcd_write_yuv420_lines(unsigned char const * const src[3],
301 int width,
302 int stride);
303extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3],
304 int width,
305 int stride,
306 int x_screen, /* To align dither pattern */
307 int y_screen);
308/* Performance function to blit a YUV bitmap directly to the LCD */
309void lcd_blit_yuv(unsigned char * const src[3],
310 int src_x, int src_y, int stride,
311 int x, int y, int width, int height)
312{
313 unsigned char const * yuv_src[3];
314 off_t z;
315
316 /* Sorry, but width and height must be >= 2 or else */
317 width &= ~1;
318 height >>= 1;
319
320 z = stride*src_y;
321 yuv_src[0] = src[0] + z + src_x;
322 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
323 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
324
325 lcd_send_command(R_ENTRY_MODE);
326 lcd_send_command(0x03);
327
328 lcd_send_command(R_Y_ADDR_AREA);
329 lcd_send_command(x + 4);
330 lcd_send_command(x + width - 1 + 4);
331
332 if (lcd_yuv_options & LCD_YUV_DITHER)
333 {
334 do
335 {
336 lcd_send_command(R_X_ADDR_AREA);
337 lcd_send_command(y);
338 lcd_send_command(y + 1);
339
340 lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y);
341 yuv_src[0] += stride << 1; /* Skip down two luma lines */
342 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
343 yuv_src[2] += stride >> 1;
344 y += 2;
345 }
346 while (--height > 0);
347 }
348 else
349 {
350 do
351 {
352 lcd_send_command(R_X_ADDR_AREA);
353 lcd_send_command(y);
354 lcd_send_command(y + 1);
355
356 lcd_write_yuv420_lines(yuv_src, width, stride);
357 yuv_src[0] += stride << 1; /* Skip down two luma lines */
358 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
359 yuv_src[2] += stride >> 1;
360 y += 2;
361 }
362 while (--height > 0);
363 }
364}
365
292/* Update the display. 366/* Update the display.
293 This must be called after all other LCD functions that change the display. */ 367 This must be called after all other LCD functions that change the display. */
294void lcd_update(void) 368void lcd_update(void)