Merge pull request #272 from irihitech/drm
Running on Raspberry Pi with Drm
This commit is contained in:
commit
8059614a2e
@ -1,48 +1,43 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Dialogs;
|
||||
using Avalonia.Media;
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Avalonia;
|
||||
|
||||
namespace Semi.Avalonia.Demo.Drm
|
||||
{
|
||||
internal class Program
|
||||
namespace Semi.Avalonia.Demo.Drm;
|
||||
|
||||
class Program
|
||||
{
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
var builder = BuildAvaloniaApp();
|
||||
builder.With(new FontManagerOptions
|
||||
|
||||
double GetScaling()
|
||||
{
|
||||
FontFallbacks = new[]
|
||||
{
|
||||
new FontFallback
|
||||
{
|
||||
FontFamily = new FontFamily("Microsoft YaHei")
|
||||
var idx = Array.IndexOf(args, "--scaling");
|
||||
if (idx != 0 && args.Length > idx + 1 &&
|
||||
double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling))
|
||||
return scaling;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (args.Contains("--drm"))
|
||||
{
|
||||
SilenceConsole();
|
||||
builder.StartLinuxDrm(args: args, card: "/dev/dri/card0", scaling: 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.StartWithClassicDesktopLifetime(args);
|
||||
return builder.StartLinuxDrm(args: args, card: "/dev/dri/card1", scaling: GetScaling());
|
||||
}
|
||||
|
||||
return builder.StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UseManagedSystemDialogs()
|
||||
.UsePlatformDetect()
|
||||
.With(new Win32PlatformOptions())
|
||||
.LogToTrace();
|
||||
|
||||
private static void SilenceConsole()
|
||||
@ -56,4 +51,3 @@ namespace Semi.Avalonia.Demo.Drm
|
||||
{ IsBackground = true }.Start();
|
||||
}
|
||||
}
|
||||
}
|
@ -54,3 +54,24 @@ sudo kmscube
|
||||
|
||||
解决方法:
|
||||
>sudo chmod +x ./Semi.Avalonia.Demo.Drm
|
||||
|
||||
4. 报错内容
|
||||
>Unhandled exception. System.ComponentModel.Win32Exception (95): drmModeGetResources failed
|
||||
at Avalonia.LinuxFramebuffer.Output.DrmResources..ctor(Int32 fd, Boolean connectorsForceProbe) in /_/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs:line 91
|
||||
at Avalonia.LinuxFramebuffer.Output.DrmCard.GetResources(Boolean connectorsForceProbe) in /_/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs:line 171
|
||||
at Avalonia.LinuxFramebuffer.Output.DrmOutput..ctor(String path, Boolean connectorsForceProbe, DrmOutputOptions options) in /_/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs:line 60
|
||||
at LinuxFramebufferPlatformExtensions.StartLinuxDrm(AppBuilder builder, String[] args, String card, Double scaling, IInputBackend inputBackend) in /_/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs:line 166
|
||||
at Semi.Avalonia.Demo.Drm.Program.Main(String[] args)
|
||||
|
||||
解决方法:
|
||||
>`program.cs`的显卡路径错误,可能不是`dev/dri/card1`,看在`dev/dri`目录下有无其他的显卡如`card0`。
|
||||
|
||||
5. 报错内容
|
||||
>Unhandled exception. System.ComponentModel.Win32Exception (2): Couldn't open /dev/dri/card1
|
||||
at Avalonia.LinuxFramebuffer.Output.DrmCard..ctor(String ) in /_/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs:line 167
|
||||
at Avalonia.LinuxFramebuffer.Output.DrmOutput..ctor(String , Boolean , DrmOutputOptions ) in /_/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs:line 58
|
||||
at LinuxFramebufferPlatformExtensions.StartLinuxDrm(AppBuilder, String[], String , Double , IInputBackend ) in /_/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs:line 166
|
||||
at Semi.Avalonia.Demo.Drm.Program.Main(String[])
|
||||
|
||||
解决办法:
|
||||
>找不到显卡路径`dev/dri/card1`,可能是显卡挂载到别的文件夹下了,待解决。
|
Loading…
x
Reference in New Issue
Block a user