Fix goodbye.png not visible on idle auto-shutdown

The Allwinner /dev/disp driver resets brightness to 0 when the fd is
closed, so the screen monitor's SIGTERM brightness restore was undone
before the wrapper wrote goodbye.png. Restore brightness in the wrapper
itself, right before the framebuffer write.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Smith 2026-02-13 23:12:10 +01:00
parent fbd32d7fb8
commit f9fcb9f121
2 changed files with 10 additions and 1 deletions

View File

@ -48,6 +48,7 @@ This document specifies the functional requirements for an SDL2 based media play
- **D-pad wakes screen**: The screen monitor now wakes on any input event type (EV_ABS, EV_KEY, etc.), not just EV_KEY. This fixes d-pad presses (which generate EV_ABS hat events) not waking the screen.
- **Wake button doesn't act in app**: Uses EVIOCGRAB to take exclusive access to input devices while the screen is off. SDL in sdlamp2 receives no events while grabbed, so the button press that wakes the screen doesn't also trigger play/stop or switch cassettes. Grabs are released when the screen turns back on.
- **Idle auto-shutdown**: After 10 minutes of no input AND no audio playback, the device auto-shuts down to save battery. Playback detection works by monitoring the audio file's read position via `/proc/<pid>/fdinfo/` — if the file offset is advancing, audio is being decoded. The timer resets on any input event or any detected playback activity.
- **Goodbye screen on auto-shutdown**: The wrapper now restores backlight brightness via `/dev/disp` `DISP_SET_BRIGHTNESS` ioctl before writing `goodbye.png` to `/dev/fb0`. Previously the screen monitor's SIGTERM handler restored brightness, but the Allwinner driver resets it to 0 when the fd is closed, so the goodbye screen was never visible on idle auto-shutdown.
### 2026-02-13 — Remember last cassette and pause on switch

View File

@ -44,10 +44,18 @@ wait "$SCREEN_MONITOR_PID" 2>/dev/null
# overwrite sdlamp2's shutdown screen).
if [ -f /tmp/.sdlamp2_shutdown ]; then
rm -f /tmp/.sdlamp2_shutdown
# Display the stock firmware's shutdown screen via framebuffer.
# Restore backlight brightness before writing the shutdown screen.
# The screen monitor's SIGTERM handler tries to restore brightness, but
# the Allwinner /dev/disp driver resets it to 0 when the fd is closed.
# Re-set it here so goodbye.png is actually visible.
# Then display the stock firmware's shutdown screen via framebuffer.
# goodbye.png is 640x480 RGB — exactly matches the display.
# /dev/fb0 is 32bpp BGRA, so we swap R/B channels and write raw pixels.
python3 -c "
import struct, fcntl
disp = open('/dev/disp', 'wb')
fcntl.ioctl(disp, 0x102, struct.pack('@4L', 0, 50, 0, 0))
disp.close()
from PIL import Image
img = Image.open('/mnt/vendor/res1/shutdown/goodbye.png').convert('RGBA')
r, g, b, a = img.split()