Skip to content

fix(LinuxFramebuffer): select a KMS-capable DRM card automatically - #21923

Merged
MrJul merged 2 commits into
AvaloniaUI:mainfrom
Illustar0:fix/drm-card-auto-detection
Aug 6, 2026
Merged

MrJul merged 2 commits into
AvaloniaUI:mainfrom
Illustar0:fix/drm-card-auto-detection

Conversation

@Illustar0

Copy link
Copy Markdown
Contributor

What does the pull request do?

Improves automatic DRM card detection.

Avalonia documentation states:

// Avalonia auto-detects the output card.
// To specify one explicitly: card: "/dev/dri/card1"
return builder.StartLinuxDrm(args, card: null, options: new DrmOutputOptions

However, the previous detection simply opened the first DRM card returned by the file system.

What is the current behavior?

When no card path is specified, Avalonia opens the first matching /dev/dri/cardN, even if it does not expose usable KMS resources.

What is the updated/expected behavior with this PR?

Avalonia checks DRM cards in numeric order and selects the first card exposing KMS resources with at least one CRTC, encoder, and connector.
Unsuitable cards are closed and skipped.

How was the solution implemented (if it's not obvious)?

Card names are validated and sorted numerically. Each candidate is opened and checked with drmModeGetResources.

Checklist

Breaking changes

None.

Obsoletions / Deprecations

None.

Fixed issues

None.

@MrJul MrJul added enhancement os-linux backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Aug 4, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068093-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia

cla-avalonia commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator
  • All contributors have signed the CLA.

@Illustar0

Copy link
Copy Markdown
Contributor Author

@cla-avalonia agree

@Illustar0

Copy link
Copy Markdown
Contributor Author

On second thought, I don't think using null to mean “auto-detect a DRM card” is ideal API design. It would be clearer to expose auto-detection through a separate method and have the DrmCard constructor accept only an explicit, non-nullable device path.

That would be a breaking change, though, so it would probably need to be considered separately from this fix.

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor change is needed but overall the PR looks good.

@MrJul

MrJul commented Aug 6, 2026

Copy link
Copy Markdown
Member

On second thought, I don't think using null to mean “auto-detect a DRM card” is ideal API design. It would be clearer to expose auto-detection through a separate method and have the DrmCard constructor accept only an explicit, non-nullable device path.

I agree that the current design isn't the best, especially as a constructor.
Feel free to open an issue with a proposal so we can review it.

@Illustar0
Illustar0 force-pushed the fix/drm-card-auto-detection branch from dab8230 to 0d9808c Compare August 6, 2026 09:59
@Illustar0
Illustar0 requested a review from MrJul August 6, 2026 09:59
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068137-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@Illustar0
Illustar0 force-pushed the fix/drm-card-auto-detection branch from 0d9808c to 4346dd7 Compare August 6, 2026 11:13

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrJul
MrJul enabled auto-merge August 6, 2026 11:46
@MrJul
MrJul added this pull request to the merge queue Aug 6, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068145-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 6, 2026
@Illustar0

Copy link
Copy Markdown
Contributor Author

@MrJul Apologies for the bother, it seems the CI failure might be a flaky test unrelated to my commits. Could you please give it a kick and re-run the CI?

@MrJul
MrJul added this pull request to the merge queue Aug 6, 2026
Merged via the queue into AvaloniaUI:main with commit 6cd0867 Aug 6, 2026
10 checks passed
@Illustar0
Illustar0 deleted the fix/drm-card-auto-detection branch September 1, 2026 08:45
MrJul pushed a commit to MrJul/Avalonia that referenced this pull request Sep 2, 2026
…valoniaUI#21923)

* fix(LinuxFramebuffer): select a KMS-capable DRM card automatically

* fix(LinuxFramebuffer): use invariant culture for DRM card number parsing
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants