summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-06-18 07:15:00 +0200
committerThomas Martitz <kugel@rockbox.org>2014-06-21 00:15:53 +0200
commita1842c04f9cb73210d4cacde61a9e4b115050765 (patch)
treea37af61ef9285b763a42cd33797e2f3d634fbf9f /firmware/export
parent0250be1d6799db7b5ddc99cb33f31bf9cff01ed2 (diff)
downloadrockbox-a1842c04f9cb73210d4cacde61a9e4b115050765.tar.gz
rockbox-a1842c04f9cb73210d4cacde61a9e4b115050765.zip
lcd-24bit: Introduce a 24-bit mid-level LCD driver
With LCD driver all calculation will be performed on RGB888 and the hardware/OS can display from our 24bit framebuffer. It is not yet as performance optimized as the existing drivers but should be good enough.The vast number of small changes is due to the fact that fb_data can be a struct type now, while most of the code expected a scalar type. lcd-as-memframe ASM code does not work with 24bit currently so the with 24bit it enforces the generic C code. All plugins are ported over. Except for rockpaint. It uses so much memory that it wouldnt fit into the 512k plugin buffer anymore (patches welcome). Change-Id: Ibb1964545028ce0d8ff9833ccc3ab66be3ee0754
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/config.h1
-rw-r--r--firmware/export/config/samsungypr0.h2
-rw-r--r--firmware/export/config/samsungypr1.h4
-rw-r--r--firmware/export/config/sansae200v2.h4
-rw-r--r--firmware/export/config/sdlapp.h4
-rw-r--r--firmware/export/lcd.h85
6 files changed, 92 insertions, 8 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 9c1a8dbf57..5e4178cd4c 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -275,6 +275,7 @@
275#define VERTICAL_INTERLEAVED 4 275#define VERTICAL_INTERLEAVED 4
276#define RGB565 565 276#define RGB565 565
277#define RGB565SWAPPED 3553 277#define RGB565SWAPPED 3553
278#define RGB888 888
278 279
279/* LCD_STRIDEFORMAT */ 280/* LCD_STRIDEFORMAT */
280#define VERTICAL_STRIDE 1 281#define VERTICAL_STRIDE 1
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index 049caa01b6..0fce70e1fe 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -47,7 +47,7 @@
47/* sqrt(240^2 + 320^2) / 2.6 = 153.8 */ 47/* sqrt(240^2 + 320^2) / 2.6 = 153.8 */
48#define LCD_DPI 154 48#define LCD_DPI 154
49 49
50#define LCD_DEPTH 16 50#define LCD_DEPTH 24
51/* Check that but should not matter */ 51/* Check that but should not matter */
52#define LCD_PIXELFORMAT RGB565 52#define LCD_PIXELFORMAT RGB565
53 53
diff --git a/firmware/export/config/samsungypr1.h b/firmware/export/config/samsungypr1.h
index 1aaf85dcb5..42b46e0699 100644
--- a/firmware/export/config/samsungypr1.h
+++ b/firmware/export/config/samsungypr1.h
@@ -53,11 +53,11 @@
53#define LCD_HEIGHT 240 53#define LCD_HEIGHT 240
54#endif 54#endif
55 55
56#define LCD_DEPTH 16 56#define LCD_DEPTH 24
57/* Calculated value, important for touch sensor */ 57/* Calculated value, important for touch sensor */
58#define LCD_DPI 180 58#define LCD_DPI 180
59/* Check that but should not matter */ 59/* Check that but should not matter */
60#define LCD_PIXELFORMAT RGB565 60#define LCD_PIXELFORMAT RGB888
61 61
62/* Capacitive touchscreen */ 62/* Capacitive touchscreen */
63#define HAVE_TOUCHSCREEN 63#define HAVE_TOUCHSCREEN
diff --git a/firmware/export/config/sansae200v2.h b/firmware/export/config/sansae200v2.h
index c703439e7f..e70b409d51 100644
--- a/firmware/export/config/sansae200v2.h
+++ b/firmware/export/config/sansae200v2.h
@@ -53,8 +53,8 @@
53#define LCD_HEIGHT 220 53#define LCD_HEIGHT 220
54/* sqrt(176^2 + 220^2) / 1.8 = 156.5 */ 54/* sqrt(176^2 + 220^2) / 1.8 = 156.5 */
55#define LCD_DPI 157 55#define LCD_DPI 157
56#define LCD_DEPTH 16 /* 65536 colours */ 56#define LCD_DEPTH 24 /* 65536 colours */
57#define LCD_PIXELFORMAT RGB565 /* rgb565 */ 57#define LCD_PIXELFORMAT RGB888 /* rgb565 */
58 58
59#ifndef BOOTLOADER 59#ifndef BOOTLOADER
60/* define this if you have LCD enable function */ 60/* define this if you have LCD enable function */
diff --git a/firmware/export/config/sdlapp.h b/firmware/export/config/sdlapp.h
index cd973fcf73..626bd5c99f 100644
--- a/firmware/export/config/sdlapp.h
+++ b/firmware/export/config/sdlapp.h
@@ -44,8 +44,8 @@
44#define LCD_HEIGHT 480 44#define LCD_HEIGHT 480
45#endif 45#endif
46 46
47#define LCD_DEPTH 16 47#define LCD_DEPTH 24
48#define LCD_PIXELFORMAT RGB565 48#define LCD_PIXELFORMAT RGB888
49 49
50/* define this to indicate your device's keypad */ 50/* define this to indicate your device's keypad */
51#define HAVE_TOUCHSCREEN 51#define HAVE_TOUCHSCREEN
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 673ce069af..cf6a16572a 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -127,7 +127,13 @@ typedef unsigned char fb_data;
127#elif LCD_DEPTH <= 16 127#elif LCD_DEPTH <= 16
128typedef unsigned short fb_data; 128typedef unsigned short fb_data;
129#define FB_DATA_SZ 2 129#define FB_DATA_SZ 2
130#else /* LCD_DEPTH > 16 */ 130#elif LCD_DEPTH <= 24
131struct _fb_pixel {
132 unsigned char b, g, r;
133};
134typedef struct _fb_pixel fb_data;
135#define FB_DATA_SZ 3
136#else /* LCD_DEPTH > 24 */
131typedef unsigned long fb_data; 137typedef unsigned long fb_data;
132#define FB_DATA_SZ 4 138#define FB_DATA_SZ 4
133#endif /* LCD_DEPTH */ 139#endif /* LCD_DEPTH */
@@ -341,6 +347,31 @@ static inline unsigned lcd_color_to_native(unsigned color)
341#define RGB_UNPACK_GREEN_LCD(x) _RGB_UNPACK_GREEN_LCD(x) 347#define RGB_UNPACK_GREEN_LCD(x) _RGB_UNPACK_GREEN_LCD(x)
342#define RGB_UNPACK_BLUE_LCD(x) _RGB_UNPACK_BLUE_LCD(x) 348#define RGB_UNPACK_BLUE_LCD(x) _RGB_UNPACK_BLUE_LCD(x)
343#endif /* RGB565* */ 349#endif /* RGB565* */
350
351#elif LCD_PIXELFORMAT == RGB888
352#define LCD_MAX_RED 255
353#define LCD_MAX_GREEN 255
354#define LCD_MAX_BLUE 255
355#define LCD_RED_BITS 8
356#define LCD_GREEN_BITS 8
357#define LCD_BLUE_BITS 8
358
359/* pack/unpack native RGB values */
360#define _RGBPACK(r, g, b) ( r << 16 | g << 8 | b )
361#define _RGB_UNPACK_RED(x) ((x >> 16) & 0xff)
362#define _RGB_UNPACK_GREEN(x) ((x >> 8) & 0xff)
363#define _RGB_UNPACK_BLUE(x) ((x >> 0) & 0xff)
364
365#define _LCD_UNSWAP_COLOR(x) (x)
366#define LCD_RGBPACK(r, g, b) _RGBPACK((r), (g), (b))
367#define LCD_RGBPACK_LCD(r, g, b) _RGBPACK((r), (g), (b))
368#define RGB_UNPACK_RED(x) _RGB_UNPACK_RED(x)
369#define RGB_UNPACK_GREEN(x) _RGB_UNPACK_GREEN(x)
370#define RGB_UNPACK_BLUE(x) _RGB_UNPACK_BLUE(x)
371#define RGB_UNPACK_RED_LCD(x) _RGB_UNPACK_RED(x)
372#define RGB_UNPACK_GREEN_LCD(x) _RGB_UNPACK_GREEN(x)
373#define RGB_UNPACK_BLUE_LCD(x) _RGB_UNPACK_BLUE(x)
374
344#else 375#else
345/* other colour depths */ 376/* other colour depths */
346#endif 377#endif
@@ -367,6 +398,58 @@ static inline unsigned lcd_color_to_native(unsigned color)
367 398
368#endif /* HAVE_LCD_COLOR */ 399#endif /* HAVE_LCD_COLOR */
369 400
401/* Framebuffer conversion macros: Convert from and to the native display data
402 * format (fb_data).
403 *
404 * FB_RGBPACK: Convert the three r,g,b values to fb_data. r,g,b are
405 * assumed to in 8-bit format.
406 * FB_RGBPACK_LCD Like FB_RGBPACK, except r,g,b shall be in display-native
407 * bit format (e.g. 5-bit r for RGB565)
408 * FB_UNPACK_RED Extract the red component of fb_data into 8-bit red value.
409 * FB_UNPACK_GREEN Like FB_UNPACK_RED, just for the green component.
410 * FB_UNPACK_BLIE Like FB_UNPACK_RED, just for the green component.
411 * FB_SCALARPACK Similar to FB_RGBPACK, except that the channels are already
412 * combined into a single scalar value. Again, 8-bit per channel.
413 * FB_SCALARPACK_LCD Like FB_SCALARPACK, except the channels shall be in
414 * display-native format (i.e. the scalar is 16bits on RGB565)
415 * FB_UNPACK_SCALAR_LCD Converts an fb_data to a scalar value in display-native
416 * format, so it's the reverse of FB_SCALARPACK_LCD
417 */
418#if LCD_DEPTH >= 24
419static inline fb_data scalar_to_fb(unsigned p)
420{
421 union { fb_data st; unsigned sc; } convert;
422 convert.sc = p; return convert.st;
423}
424static inline unsigned fb_to_scalar(fb_data p)
425{
426 union { fb_data st; unsigned sc; } convert;
427 convert.st = p; return convert.sc;
428}
429#define FB_RGBPACK(r_, g_, b_) ((fb_data){.r = r_, .g = g_, .b = b_})
430#define FB_RGBPACK_LCD(r_, g_, b_) FB_RGBPACK(r_, g_, b_)
431#define FB_UNPACK_RED(fb) ((fb).r)
432#define FB_UNPACK_GREEN(fb) ((fb).g)
433#define FB_UNPACK_BLUE(fb) ((fb).b)
434#define FB_SCALARPACK(c) scalar_to_fb(c)
435#define FB_SCALARPACK_LCD(c) scalar_to_fb(c)
436#define FB_UNPACK_SCALAR_LCD(fb) fb_to_scalar(fb)
437#elif defined(HAVE_LCD_COLOR)
438#define FB_RGBPACK(r_, g_, b_) LCD_RGBPACK(r_, g_, b_)
439#define FB_RGBPACK_LCD(r_, g_, b_) LCD_RGBPACK_LCD(r_, g_, b_)
440#define FB_UNPACK_RED(fb) RGB_UNPACK_RED(fb)
441#define FB_UNPACK_GREEN(fb) RGB_UNPACK_GREEN(fb)
442#define FB_UNPACK_BLUE(fb) RGB_UNPACK_BLUE(fb)
443#define FB_SCALARPACK(c) LCD_RGBPACK(RGB_UNPACK_RED(c), RGB_UNPACK_GREEN(c), RGB_UNPACK_BLUE(c))
444#define FB_SCALARPACK_LCD(c) (c)
445#define FB_UNPACK_SCALAR_LCD(fb) (fb)
446#else
447#define FB_SCALARPACK(c) (c)
448#define FB_SCALARPACK_LCD(c) (c)
449#define FB_UNPACK_SCALAR_LCD(fb) (fb)
450#endif
451
452
370/* Frame buffer dimensions */ 453/* Frame buffer dimensions */
371#if LCD_DEPTH == 1 454#if LCD_DEPTH == 1
372#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 455#if LCD_PIXELFORMAT == HORIZONTAL_PACKING