Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG logo #266

Merged
merged 4 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
From fdad291b7837db232a9a8d071d8d587d8777a485 Mon Sep 17 00:00:00 2001
From: Max Kellermann <[email protected]>
Date: Wed, 9 Feb 2022 17:55:27 +0100
Subject: [PATCH] video_bmp: implement BMP-RLE to 32 bit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning to submit this upstream? It might be a PITA to fix this large patch once it stops applying cleanly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, though upstream is at a newer version, Yocto is outdated. And I need to clean up the patch a bit, it's somewhat quick'n'dirty code.
(And upstream is a confusing mess of dozens of per-vendor copies....)


---
drivers/video/video_bmp.c | 130 ++++++++++++++++++++++++++++++++++++--
1 file changed, 126 insertions(+), 4 deletions(-)

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 1e6f07ff4b..40141de9c5 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -19,6 +19,124 @@
#define BMP_RLE8_EOBMP 1
#define BMP_RLE8_DELTA 2

+static uchar *draw32_cte(uchar *fb, const struct bmp_color_table_entry *cte)
+{
+ *(fb++) = cte->blue;
+ *(fb++) = cte->green;
+ *(fb++) = cte->red;
+ *(fb++) = 0;
+ return fb;
+}
+
+static uchar *draw_unencoded_bitmap32(uchar *fb, uchar *bmap,
+ const struct bmp_color_table_entry *palette,
+ int cnt)
+{
+ while (cnt > 0) {
+ fb = draw32_cte(fb, &palette[*bmap++]);
+ cnt--;
+ }
+
+ return fb;
+}
+
+static uchar *draw_encoded_bitmap32(uchar *fb,
+ const struct bmp_color_table_entry *cte,
+ int cnt)
+{
+ while (cnt > 0) {
+ fb = draw32_cte(fb, cte);
+ cnt--;
+ }
+
+ return fb;
+}
+
+static void video_display_rle8_bitmap32(struct udevice *dev,
+ struct bmp_image *bmp,
+ const struct bmp_color_table_entry *palette,
+ uchar *fb, int x_off, int y_off,
+ ulong width, ulong height)
+{
+ struct video_priv *priv = dev_get_uclass_priv(dev);
+ uchar *bmap;
+ ulong cnt, runlen;
+ int x, y;
+ int decode = 1;
+
+ debug("%s\n", __func__);
+ bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
+
+ x = 0;
+ y = height - 1;
+
+ while (decode) {
+ if (bmap[0] == BMP_RLE8_ESCAPE) {
+ switch (bmap[1]) {
+ case BMP_RLE8_EOL:
+ /* end of line */
+ bmap += 2;
+ x = 0;
+ y--;
+ /* 32bpix, 4-byte per pixel, x should *4 */
+ fb -= (width * 4 + priv->line_length);
+ break;
+ case BMP_RLE8_EOBMP:
+ /* end of bitmap */
+ decode = 0;
+ break;
+ case BMP_RLE8_DELTA:
+ /* delta run */
+ x += bmap[2];
+ y -= bmap[3];
+ /* 32bpix, 4-byte per pixel, x should *4 */
+ fb = (uchar *)(priv->fb + (y + y_off - 1)
+ * priv->line_length + (x + x_off) * 4);
+ bmap += 4;
+ break;
+ default:
+ /* unencoded run */
+ runlen = bmap[1];
+ bmap += 2;
+ if (y < height) {
+ if (x < width) {
+ if (x + runlen > width)
+ cnt = width - x;
+ else
+ cnt = runlen;
+ fb = draw_unencoded_bitmap32(fb, bmap, palette, cnt);
+ }
+ x += runlen;
+ }
+ bmap += runlen;
+ if (runlen & 1)
+ bmap++;
+ }
+ } else {
+ /* encoded run */
+ if (y < height) {
+ runlen = bmap[0];
+ if (x < width) {
+ /* aggregate the same code */
+ while (bmap[0] == 0xff &&
+ bmap[2] != BMP_RLE8_ESCAPE &&
+ bmap[1] == bmap[3]) {
+ runlen += bmap[2];
+ bmap += 2;
+ }
+ if (x + runlen > width)
+ cnt = width - x;
+ else
+ cnt = runlen;
+ fb = draw_encoded_bitmap32(fb, &palette[bmap[1]], cnt);
+ }
+ x += runlen;
+ }
+ bmap += 2;
+ }
+ }
+}
+
static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap,
int cnt)
{
@@ -277,13 +395,17 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
u32 compression = get_unaligned_le32(&bmp->header.compression);
debug("compressed %d %d\n", compression, BMP_BI_RLE8);
if (compression == BMP_BI_RLE8) {
- if (bpix != 16) {
+ if (bpix == 16) {
+ video_display_rle8_bitmap(dev, bmp, cmap_base, fb, x,
+ y, width, height);
+ } else if (bpix == 32) {
+ video_display_rle8_bitmap32(dev, bmp, palette, fb, x,
+ y, width, height);
+ } else {
/* TODO implement render code for bpix != 16 */
- printf("Error: only support 16 bpix");
+ printf("Error: BMP-RLE on %d bpix unsupported", bpix);
return -EPROTONOSUPPORT;
}
- video_display_rle8_bitmap(dev, bmp, cmap_base, fb, x,
- y, width, height);
break;
}
#endif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 10 additions & 9 deletions meta-ov/recipes-bsp/u-boot/u-boot_%.bbappend
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,11 @@ SRC_URI:append:cubieboard2 = " \
file://openvario.dts \
file://config.uEnv \
file://font.env \
file://ov_recover_0.bmp \
file://ov_recover_1.bmp \
file://ov_recover_2.bmp \
file://ov_recover_3.bmp \
\
file://ov_booting_0.bmp \
file://ov_booting_1.bmp \
file://ov_booting_2.bmp \
file://ov_booting_3.bmp \
\
file://0001-Added-openvario.dts-to-Makefile.patch \
file://0001-Added-RGB-swap-for-RGB-LCD.patch \
file://0001-Environment-Openvario-mainline.patch \
file://0001-video_bmp-implement-BMP-RLE-to-32-bit.patch \
\
file://ini2c.py \
file://bootenv.ini \
Expand All @@ -78,6 +70,14 @@ do_configure:prepend:cubieboard2() {
cp ${WORKDIR}/openvario.dts ${S}/arch/arm/dts/openvario.dts
}

do_compile:append:cubieboard2() {
DISPLAY=$(perl -ne '/^CONFIG_VIDEO_LCD_MODE="x:(\d+),y:(\d+)/ && print "$1x$2"' ${WORKDIR}/per_machine.cfg)
test -n "$DISPLAY"
install ${RECIPE_SYSROOT}${datadir}/openvario/u-boot/$DISPLAY/ov_*_?.bmp ${WORKDIR}
}

do_compile[depends] += "perl-native:do_populate_sysroot openvario-logo:do_populate_sysroot"

do_install:append:cubieboard2() {
install -m 644 -D ${WORKDIR}/ov_*.bmp ${D}/boot
install -m 644 -D ${WORKDIR}/config.uEnv ${D}/boot
Expand All @@ -90,3 +90,4 @@ do_deploy:append:cubieboard2() {
install -m 644 -D ${WORKDIR}/config.uEnv ${DEPLOYDIR}
cat ${WORKDIR}/font.env >>${DEPLOYDIR}/config.uEnv
}

112 changes: 112 additions & 0 deletions meta-ov/recipes-support/logo/files/openvario-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading