#!/bin/sh /etc/rc.common

# The panel is a raw spidev (CONFIG_SPI_SPIDEV=y, /dev/spidev1.0) driven entirely
# from userspace, so nothing in the kernel ever repaints it: U-Boot's logo stays
# frozen on screen until this daemon's first frame. rcS does not start until
# after the console prompt, and at START=15 this sat behind 13 scripts -- S10boot
# alone is 1.6s -- so the first frame landed 9.5s after reset and the user stared
# at a static logo for 8.8s.
#
# Nothing here needs those scripts. The only hard requirements are /dev/spidev1.0
# and the GPIOs (both built into the kernel and present from ~0.5s), the assets in
# /usr/share (squashfs, mounted before rcS) and /tmp (tmpfs, mounted in preinit).
# PMU and network data arrive later via pcat-manager and ubus, and the daemon
# already retries for those -- it has no fatal path that depends on them, and the
# welcome animation covers the gap anyway.
#
# 02 keeps sysfixtime (clock, for the on-screen time) ahead of it and moves
# everything else behind: first frame at ~7.3s instead of ~9.5s.
START=02
STOP=00

PID_FILE="/tmp/pcat2-display-mini.pid"

start() {
	start-stop-daemon -bm -p ${PID_FILE} -S /usr/bin/photonicat2_mini_display
}

stop() {
	start-stop-daemon -p ${PID_FILE} -K /usr/bin/photonicat2_mini_display
}

restart() {
	stop
	start
}

shutdown() {
	stop
}
