From b37e6bc8c119289aca8740dd5e3b60d72f9d6b40 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 22 Feb 2012 21:18:05 +1100 Subject: lcd drivers: Convert lcd_[remote_]framebuffer to a pointer Change all lcd drivers to using a pointer to the static framebuffer instead of directly accessing the static array. This will let us later do fun things like dynamic framebuffer sizes (RaaA) or ability to use different buffers for different layers (dynamic skin backdrops!) Change-Id: I0a4d58a9d7b55e6c932131b929e5d4c9f9414b06 --- firmware/target/hosted/android/lcd-android.c | 6 +++--- firmware/target/hosted/sdl/lcd-bitmap.c | 18 +++++++----------- firmware/target/hosted/sdl/lcd-remote-bitmap.c | 4 ++-- firmware/target/hosted/ypr0/lcd-ypr0.c | 4 ++-- 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'firmware/target/hosted') diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index abde72155d..c9a3fd6edf 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c @@ -75,7 +75,7 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) /* Create native_buffer */ jobject buffer = (*env)->NewDirectByteBuffer(env, lcd_framebuffer, - (jlong) sizeof(lcd_framebuffer)); + (jlong) FRAMEBUFFER_SIZE); /* we need to setup parts for the java object every time */ (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, @@ -206,10 +206,10 @@ void lcd_blit_yuv(unsigned char * const src[3], linecounter = height >> 1; #if LCD_WIDTH >= LCD_HEIGHT - dst = &lcd_framebuffer[y][x]; + dst = FBADDR(x,y); row_end = dst + width; #else - dst = &lcd_framebuffer[x][LCD_WIDTH - y - 1]; + dst = FBADDR(LCD_WIDTH - y - 1,x); row_end = dst + LCD_WIDTH * width; #endif diff --git a/firmware/target/hosted/sdl/lcd-bitmap.c b/firmware/target/hosted/sdl/lcd-bitmap.c index 4ee0bbef5c..7e9bc297ef 100644 --- a/firmware/target/hosted/sdl/lcd-bitmap.c +++ b/firmware/target/hosted/sdl/lcd-bitmap.c @@ -92,29 +92,25 @@ static unsigned long get_lcd_pixel(int x, int y) { #if LCD_DEPTH == 1 #ifdef HAVE_NEGATIVE_LCD - return (lcd_framebuffer[y/8][x] & (1 << (y & 7))) ? (NUM_SHADES-1) : 0; + return (*FBADDR(x, y/8) & (1 << (y & 7))) ? (NUM_SHADES-1) : 0; #else - return (lcd_framebuffer[y/8][x] & (1 << (y & 7))) ? 0 : (NUM_SHADES-1); + return (*FBADDR(x, y/8) & (1 << (y & 7))) ? 0 : (NUM_SHADES-1); #endif #elif LCD_DEPTH == 2 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING - return colorindex[(lcd_framebuffer[y][x/4] >> (2 * (~x & 3))) & 3]; + return colorindex[(*FBADDR(x/4, y) >> (2 * (~x & 3))) & 3]; #elif LCD_PIXELFORMAT == VERTICAL_PACKING - return colorindex[(lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3]; + return colorindex[(*FBADDR(x, y/4) >> (2 * (y & 3))) & 3]; #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED - unsigned bits = (lcd_framebuffer[y/8][x] >> (y & 7)) & 0x0101; + unsigned bits = (*FBADDR(x, y/8) >> (y & 7)) & 0x0101; return colorindex[(bits | (bits >> 7)) & 3]; #endif #elif LCD_DEPTH == 16 #if LCD_PIXELFORMAT == RGB565SWAPPED - unsigned bits = lcd_framebuffer[y][x]; + unsigned bits = *FBADDR(x, y); return (bits >> 8) | (bits << 8); #else -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE - return *(&lcd_framebuffer[0][0]+LCD_HEIGHT*x+y); -#else - return lcd_framebuffer[y][x]; -#endif + return *FBADDR(x, y); #endif #endif } diff --git a/firmware/target/hosted/sdl/lcd-remote-bitmap.c b/firmware/target/hosted/sdl/lcd-remote-bitmap.c index 86d45ef446..5f08b4440b 100644 --- a/firmware/target/hosted/sdl/lcd-remote-bitmap.c +++ b/firmware/target/hosted/sdl/lcd-remote-bitmap.c @@ -50,10 +50,10 @@ static const unsigned char colorindex[4] = {128, 85, 43, 0}; static unsigned long get_lcd_remote_pixel(int x, int y) { #if LCD_REMOTE_DEPTH == 1 - return lcd_remote_framebuffer[y/8][x] & (1 << (y & 7)) ? 0 : (NUM_SHADES-1); + return *FBREMOTEADDR(x, y/8) & (1 << (y & 7)) ? 0 : (NUM_SHADES-1); #elif LCD_REMOTE_DEPTH == 2 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED - unsigned bits = (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 0x0101; + unsigned bits = (*FBREMOTEADDR(x, y/8) >> (y & 7)) & 0x0101; return colorindex[(bits | (bits >> 7)) & 3]; #endif #endif diff --git a/firmware/target/hosted/ypr0/lcd-ypr0.c b/firmware/target/hosted/ypr0/lcd-ypr0.c index 083a9fbe28..40528c298a 100644 --- a/firmware/target/hosted/ypr0/lcd-ypr0.c +++ b/firmware/target/hosted/ypr0/lcd-ypr0.c @@ -39,7 +39,7 @@ fb_data *dev_fb = 0; void lcd_shutdown(void) { printf("FB closed."); - munmap(dev_fb, sizeof(lcd_framebuffer)); + munmap(dev_fb, FRAMEBUFFER_SIZE); close(dev_fd); } @@ -80,7 +80,7 @@ void lcd_init_device(void) /* Figure out the size of the screen in bytes */ screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; - if (screensize != sizeof(lcd_framebuffer)) + if (screensize != FRAMEBUFFER_SIZE) { exit(4); perror("Display and framebuffer mismatch!\n"); -- cgit v1.2.3