diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-02-07 20:39:58 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-02-07 20:39:58 +0100 |
| commit | dae5bc02b1c934075e95694953b4330676e21611 (patch) | |
| tree | faa1a80849e5642d0b4bd8b4a91331b1da5b75bf /src/screen/drm/resources.zig | |
| parent | fef523a8d7c87f272de18c8abd57e0cc53e2ef40 (diff) | |
estd: add graphics module
Diffstat (limited to 'src/screen/drm/resources.zig')
| -rw-r--r-- | src/screen/drm/resources.zig | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/screen/drm/resources.zig b/src/screen/drm/resources.zig index 9a8566c..8b45fdf 100644 --- a/src/screen/drm/resources.zig +++ b/src/screen/drm/resources.zig @@ -3,13 +3,12 @@ const os = std.os.linux; const cerror = @import("../cerror.zig"); const drm = @import("root.zig"); -const Card = drm.Card; pub const Resources = struct { const Self = @This(); const Range = struct { min: u32, max: u32 }; - card: *Card, + card: drm.Card, fb_ids: []u32, crtc_ids: []u32, @@ -18,7 +17,7 @@ pub const Resources = struct { width: Range, height: Range, - pub fn raw_without_ids(card: *Card) !drm.request.Resources { + pub fn raw_without_ids(card: drm.Card) !drm.request.Resources { var result = std.mem.zeroes(drm.request.Resources); try card.request(.get_resources, &result); return result; @@ -27,7 +26,7 @@ pub const Resources = struct { // NOTE: This function does not take in account // that there might be some hot-plugging going // on. This might have to change in the future. - pub fn init(card: *Card) !Self { + pub fn init(card: drm.Card) !Self { var raw = try Self.raw_without_ids(card); const resources = .{ .fb_ids = try card.allocator.alloc(u32, raw.count_fbs), @@ -59,4 +58,16 @@ pub const Resources = struct { self.card.allocator.free(self.connector_ids); self.card.allocator.free(self.encoder_ids); } + + pub fn connector(self: *Self, index: usize) !drm.Connector { + return drm.Connector.init(self.card, self.connector_ids[index]); + } + + pub fn crtc(self: *Self, index: usize) !drm.Crtc { + return drm.Crtc.init(self.card, self.crtc_ids[index]); + } + + pub fn encoder(self: *Self, index: usize) !drm.Encoder { + return drm.Encoder.init(self.card, self.encoder_ids[index]); + } }; |