Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: target/dartuinoP0/memory_lcd.c

Issue 1777783003: [display] Refactor to avoid implicit framebuffer allocation. (Closed) Base URL: https://github.com/littlekernel/lk.git@master
Patch Set: update other targets Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: target/dartuinoP0/memory_lcd.c
diff --git a/target/dartuinoP0/memory_lcd.c b/target/dartuinoP0/memory_lcd.c
index 0249211e3ef4a7e614c236489e7b50e0ae84da7c..d7225d5befc3b6901abf85136bc7f77d6be13d69 100644
--- a/target/dartuinoP0/memory_lcd.c
+++ b/target/dartuinoP0/memory_lcd.c
@@ -25,6 +25,8 @@
#include <debug.h>
#include <trace.h>
#include <rand.h>
+#include <stdlib.h>
+#include <assert.h>
#include <dev/display.h>
#include <platform/gpio.h>
@@ -52,7 +54,7 @@ SPI_HandleTypeDef SpiHandle;
#define VCOM_HI 0x02
#define VCOM_LO 0x00
-static uint8_t framebuffer[MLCD_HEIGHT * FB_STRIDE];
+static struct display_framebuffer default_fb;
static uint8_t vcom_state;
static void chip_select(bool s)
@@ -114,10 +116,41 @@ status_t memory_lcd_init(void)
return NO_ERROR;
}
+static void mlcd_flush(uint starty, uint endy)
+{
+ display_present(&default_fb.image, starty, endy);
+}
+status_t display_get_framebuffer(struct display_framebuffer *fb)
+{
gkalsi 2016/03/09 21:13:37 DEBUG_ASSERT(fb)
cdotstout 2016/03/09 22:48:00 Done.
+ if (!default_fb.image.pixels) {
+ switch (MLCD_FORMAT) {
+ case DISPLAY_FORMAT_RGB_111:
+ // Use closest match format supported by gfx lib
+ default_fb.image.format = IMAGE_FORMAT_RGB_332;
+ default_fb.image.rowbytes = MLCD_WIDTH;
+ break;
+ case DISPLAY_FORMAT_MONO_1:
+ default_fb.image.format = IMAGE_FORMAT_MONO_1;
+ default_fb.image.rowbytes = (MLCD_WIDTH + 7) >> 3;
+ break;
+ default:
+ DEBUG_ASSERT(false);
+ return ERR_NOT_SUPPORTED;
+ }
+ default_fb.image.pixels = malloc(MLCD_HEIGHT * default_fb.image.rowbytes);
+ default_fb.image.width = MLCD_WIDTH;
+ default_fb.image.height = MLCD_HEIGHT;
+ default_fb.flush = mlcd_flush;
+ default_fb.format = MLCD_FORMAT;
+ }
+ *fb = default_fb;
+ return NO_ERROR;
+}
-static void mlcd_flush(uint starty, uint endy)
+status_t display_present(struct display_image *image, uint starty, uint endy)
{
+ status_t status = NO_ERROR;
chip_select(true);
static uint8_t localbuf[MLCD_BUF_SIZE];
@@ -133,7 +166,7 @@ static void mlcd_flush(uint starty, uint endy)
for (uint j = starty; j <= endy; ++j) {
*bufptr++ = (j + 1);
- bufptr += lcd_get_line(framebuffer, j, bufptr);
+ bufptr += lcd_get_line(image, j, bufptr);
// 8 bit trailer per line
*bufptr++ = trailer;
@@ -143,6 +176,7 @@ static void mlcd_flush(uint starty, uint endy)
}
if (HAL_SPI_Transmit(&SpiHandle, localbuf, bufptr - localbuf, HAL_MAX_DELAY) != HAL_OK) {
+ status = ERR_GENERIC;
goto finish;
}
@@ -151,18 +185,17 @@ static void mlcd_flush(uint starty, uint endy)
finish:
chip_select(false);
+
+ return status;
}
status_t display_get_info(struct display_info *info)
{
LTRACEF("display_info %p\n", info);
- info->framebuffer = (void *)framebuffer;
- info->format = FB_FORMAT;
+ info->format = MLCD_FORMAT;
info->width = MLCD_WIDTH;
info->height = MLCD_HEIGHT;
- info->stride = FB_STRIDE;
- info->flush = mlcd_flush;
return NO_ERROR;
}

Powered by Google App Engine
This is Rietveld 408576698