Add support for Luckfox PicoKVM

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
luckfox-eng29
2025-08-07 14:26:01 +08:00
parent 3e7d8fb0f5
commit 8fbd6bcf0d
114 changed files with 4676 additions and 3270 deletions

View File

@@ -24,23 +24,119 @@ func (w *nativeOutput) Write(p []byte) (n int, err error) {
return len(p), nil
}
func startNativeBinary(binaryPath string) (*exec.Cmd, error) {
// Run the binary in the background
func startVideoBinary(binaryPath string) (*exec.Cmd, error) {
// Run the binary inthe background
cmd := exec.Command(binaryPath)
nativeOutputLock := sync.Mutex{}
nativeStdout := &nativeOutput{
mu: &nativeOutputLock,
logger: nativeLogger.Info().Str("pipe", "stdout"),
vidoeOutputLock := sync.Mutex{}
videoStdout := &nativeOutput{
mu: &vidoeOutputLock,
logger: videoLogger.Info().Str("pipe", "stdout"),
}
nativeStderr := &nativeOutput{
mu: &nativeOutputLock,
logger: nativeLogger.Info().Str("pipe", "stderr"),
videoStderr := &nativeOutput{
mu: &vidoeOutputLock,
logger: videoLogger.Info().Str("pipe", "stderr"),
}
// Redirect stdout and stderr to the current process
cmd.Stdout = nativeStdout
cmd.Stderr = nativeStderr
cmd.Stdout = videoStdout
cmd.Stderr = videoStderr
// Set the process group ID so we can kill the process and its children when this process exits
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
Pdeathsig: syscall.SIGKILL,
}
// Start the command
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("failed to start binary: %w", err)
}
return cmd, nil
}
func startAudioBinary(binaryPath string) (*exec.Cmd, error) {
// Run the binary inthe background
cmd := exec.Command(binaryPath)
audioOutputLock := sync.Mutex{}
audioStdout := &nativeOutput{
mu: &audioOutputLock,
logger: audioLogger.Info().Str("pipe", "stdout"),
}
audioStderr := &nativeOutput{
mu: &audioOutputLock,
logger: audioLogger.Info().Str("pipe", "stderr"),
}
// Redirect stdout and stderr to the current process
cmd.Stdout = audioStdout
cmd.Stderr = audioStderr
// Set the process group ID so we can kill the process and its children when this process exits
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
Pdeathsig: syscall.SIGKILL,
}
// Start the command
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("failed to start binary: %w", err)
}
return cmd, nil
}
func startVpnBinary(binaryPath string) (*exec.Cmd, error) {
// Run the binary inthe background
cmd := exec.Command(binaryPath)
vpnOutputLock := sync.Mutex{}
vpnStdout := &nativeOutput{
mu: &vpnOutputLock,
logger: audioLogger.Info().Str("pipe", "stdout"),
}
vpnStderr := &nativeOutput{
mu: &vpnOutputLock,
logger: audioLogger.Info().Str("pipe", "stderr"),
}
// Redirect stdout and stderr to the current process
cmd.Stdout = vpnStdout
cmd.Stderr = vpnStderr
// Set the process group ID so we can kill the process and its children when this process exits
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
Pdeathsig: syscall.SIGKILL,
}
// Start the command
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("failed to start binary: %w", err)
}
return cmd, nil
}
func startDisplayBinary(binaryPath string) (*exec.Cmd, error) {
// Run the binary inthe background
cmd := exec.Command(binaryPath)
displayOutputLock := sync.Mutex{}
displayStdout := &nativeOutput{
mu: &displayOutputLock,
logger: displayLogger.Info().Str("pipe", "stdout"),
}
displayStderr := &nativeOutput{
mu: &displayOutputLock,
logger: displayLogger.Info().Str("pipe", "stderr"),
}
//// Redirect stdout and stderr to the current process
cmd.Stdout = displayStdout
cmd.Stderr = displayStderr
// Set the process group ID so we can kill the process and its children when this process exits
cmd.SysProcAttr = &syscall.SysProcAttr{