uzbek-plus/b9/b9l/splash/mk-splash.py
q 4a7224c41f B9: built-in display (ST7735S SPI) in Linux and persistent B9C cache
- B9A: read-only audit of stock LK/DT: the panel is an ST7735S 128x128 on SPI (BLSP1 QUP4,
  16 MHz, mode 3, D/C GPIO116, RESET GPIO118), backlight = PM8916 MPP4 current sink 40 mA.
- B9B: upstream panel-mipi-dbi with the stock init sequence as firmware; MPP4 sink via pinctrl
  + gpio-backlight; first light with correct colours/orientation/offsets.
- B9C: fbcon (6x8, 21x16) on tty1 + getty, UART console kept, aurora-display service;
  cache B9C b9ce13c9 written and verified, cold boots with LTE + Wi-Fi + display.
- B9L (RAM only): lk2nd second stage with an msm8916 SPI panel port shows a picture before Linux.
- Sanitizer: whitelist for b8/ and b9/.
2026-10-03 01:45:02 +03:00

24 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""B9L: convert a 128x128 PNG to the LK splash: RGB565 little-endian u16 (same format as the stock Aurora LK logo
@0x8f64b004), emitted as a C header for lk2nd/aurora. Alpha is composited over black (stop if the image is not 128x128).
Also writes a 2x preview PNG rendered back from the RGB565 data. usage: mk-splash.py in.png out.h preview.png"""
import struct, sys
from PIL import Image
im = Image.open(sys.argv[1])
if im.size != (128, 128):
sys.exit(f'STOP: image is {im.size}, need 128x128')
bg = Image.new('RGBA', im.size, (0, 0, 0, 255))
rgb = Image.alpha_composite(bg, im.convert('RGBA')).convert('RGB')
px = list(rgb.getdata())
words = [(r >> 3) << 11 | (g >> 2) << 5 | b >> 3 for r, g, b in px]
with open(sys.argv[2], 'w') as f:
f.write('/* Generated by b9/b9l/splash/mk-splash.py from %s: 128x128 RGB565 (LE u16 in memory) */\n' % sys.argv[1].split('/')[-1])
f.write('static const uint16_t aurora_splash[128 * 128] = {\n')
for i in range(0, len(words), 12):
f.write('\t' + ', '.join('0x%04x' % w for w in words[i:i + 12]) + ',\n')
f.write('};\n')
prev = Image.new('RGB', (128, 128))
prev.putdata([((w >> 11) * 255 // 31, (w >> 5 & 63) * 255 // 63, (w & 31) * 255 // 31) for w in words])
prev.resize((256, 256), Image.NEAREST).save(sys.argv[3])
open(sys.argv[2] + '.bin', 'wb').write(b''.join(struct.pack('<H', w) for w in words))
print('ok', len(words) * 2, 'bytes')