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

Unified Diff: target/dartuinoP0/display/LS013B7DH06.c

Issue 1777783003: [display] Refactor to avoid implicit framebuffer allocation. (Closed) Base URL: https://github.com/littlekernel/lk.git@master
Patch Set: fix stride confusion 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
« no previous file with comments | « platform/armemu/display.c ('k') | target/dartuinoP0/display/memory_lcd_mono.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: target/dartuinoP0/display/LS013B7DH06.c
diff --git a/target/dartuinoP0/display/LS013B7DH06.c b/target/dartuinoP0/display/LS013B7DH06.c
index 21730324eda34d5bbeeb4b1ece7c31604a63b08a..3e3bceab35eda07698dd29f479eb282961f539f0 100644
--- a/target/dartuinoP0/display/LS013B7DH06.c
+++ b/target/dartuinoP0/display/LS013B7DH06.c
@@ -24,63 +24,77 @@
// 1.33 Inch 3-Bit RGB Sharp Color LCD
#include <target/display/LS013B7DH06.h>
#include <string.h>
+#include <assert.h>
-#define SET_BIT(BUF, BITNUM) ((BUF)[(BITNUM) >> 3] |= (0xff & (0x1 << ((BITNUM) & 0x07))))
+#define SET_BIT(BUF, BITNUM) ((BUF)[(BITNUM) >> 3] |= (0x1 << ((BITNUM) & 0x07)))
-uint8_t lcd_get_line(uint8_t *framebuffer, uint8_t idx, uint8_t *result)
+uint8_t lcd_get_line(struct display_image *image, uint8_t idx, uint8_t *result)
{
- framebuffer += FB_STRIDE * idx;
+ uint8_t *framebuffer = (uint8_t *)image->pixels + image->rowbytes * idx;
memset(result, 0, MLCD_BYTES_LINE);
-#if FB_FORMAT == DISPLAY_FORMAT_RGB_332
- for (int i = 0; i < MLCD_WIDTH; ++i) {
- uint8_t inpix = framebuffer[i];
+ if (image->format == IMAGE_FORMAT_RGB_332) {
+ for (int i = 0; i < MLCD_WIDTH; ++i) {
+ uint8_t inpix = framebuffer[i];
- int j = i * 3;
+ int j = i * 3;
- if (inpix & 0x80) {
- SET_BIT(result, j);
+ if (inpix & 0x80) {
+ SET_BIT(result, j);
+ }
+ if (inpix & 0x10) {
+ SET_BIT(result, j + 1);
+ }
+ if (inpix & 0x02) {
+ SET_BIT(result, j + 2);
+ }
}
- if (inpix & 0x10) {
- SET_BIT(result, j + 1);
- }
- if (inpix & 0x02) {
- SET_BIT(result, j + 2);
- }
- }
-#elif FB_FORMAT == DISPLAY_FORMAT_RGB_x111
- for (int i = 0; i < FB_STRIDE; ++i) {
- uint8_t val = framebuffer[i];
- uint8_t inpix;
+ } else if (image->format == IMAGE_FORMAT_RGB_x111) {
+ int j = 0;
+ for (uint i = 0; i < image->width; i += 2) {
+ uint8_t val = *framebuffer++;
+ uint8_t inpix = val & 0xf;
- int j = i * 6;
+ if (inpix & 0x4) {
+ SET_BIT(result, j);
+ }
+ if (inpix & 0x2) {
+ SET_BIT(result, j + 1);
+ }
+ if (inpix & 0x1) {
+ SET_BIT(result, j + 2);
+ }
- inpix = val & 0xf;
- if (inpix & 0x4) {
- SET_BIT(result, j);
- }
- if (inpix & 0x2) {
- SET_BIT(result, j + 1);
- }
- if (inpix & 0x1) {
- SET_BIT(result, j + 2);
+ inpix = val >> 4;
+ if (inpix & 0x4) {
+ SET_BIT(result, j + 3);
+ }
+ if (inpix & 0x2) {
+ SET_BIT(result, j + 4);
+ }
+ if (inpix & 0x1) {
+ SET_BIT(result, j + 5);
+ }
+ j += 6;
}
+ if (image->width & 1) {
+ uint8_t val = *framebuffer;
+ uint8_t inpix = val & 0xf;
- inpix = val >> 4;
- if (inpix & 0x4) {
- SET_BIT(result, j + 3);
- }
- if (inpix & 0x2) {
- SET_BIT(result, j + 4);
- }
- if (inpix & 0x1) {
- SET_BIT(result, j + 5);
+ if (inpix & 0x4) {
+ SET_BIT(result, j);
+ }
+ if (inpix & 0x2) {
+ SET_BIT(result, j + 1);
+ }
+ if (inpix & 0x1) {
+ SET_BIT(result, j + 2);
+ }
}
+ } else {
+ DEBUG_ASSERT(false);
}
-#else
- #error Unhandled FB_FORMAT
-#endif
return MLCD_BYTES_LINE;
}
« no previous file with comments | « platform/armemu/display.c ('k') | target/dartuinoP0/display/memory_lcd_mono.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698