summaryrefslogtreecommitdiff
path: root/src/screen/drm/card.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-02-02 19:58:26 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2025-02-02 19:58:26 +0100
commit3f4375a14218796cbd7bfff1c8cfff0f7bb1f6df (patch)
tree1521b91b8f99af588156058b5f9aa12bb1626ac7 /src/screen/drm/card.zig
parent8d062a90b1ffbe9e00334fa3e9e939406bd32141 (diff)
change .editorconfig
Diffstat (limited to 'src/screen/drm/card.zig')
-rw-r--r--src/screen/drm/card.zig100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/screen/drm/card.zig b/src/screen/drm/card.zig
index 6147cf2..f1674bb 100644
--- a/src/screen/drm/card.zig
+++ b/src/screen/drm/card.zig
@@ -12,69 +12,69 @@ const Event = @import("event.zig").Event;
pub const Card = struct {
- const Self = @This();
+ const Self = @This();
- file: std.fs.File,
- allocator: std.mem.Allocator,
+ file: std.fs.File,
+ allocator: std.mem.Allocator,
- pub fn open(name: []const u8, allocator: std.mem.Allocator) !Self {
- var dri_dir = try std.fs.openDirAbsolute("/dev/dri", .{});
- defer dri_dir.close();
+ pub fn open(name: []const u8, allocator: std.mem.Allocator) !Self {
+ var dri_dir = try std.fs.openDirAbsolute("/dev/dri", .{});
+ defer dri_dir.close();
- return .{
- .file = try dri_dir.openFile(name, .{
- .mode = .read_write,
- .lock_nonblocking = true,
- }),
+ return .{
+ .file = try dri_dir.openFile(name, .{
+ .mode = .read_write,
+ .lock_nonblocking = true,
+ }),
- .allocator = allocator,
- };
- }
+ .allocator = allocator,
+ };
+ }
- pub fn close(self: *Card) void {
- self.file.close();
- }
+ pub fn close(self: *Card) void {
+ self.file.close();
+ }
- pub fn is_kms(self: *Card) !bool {
- const raw_info = Resources.raw_without_ids(self);
- return raw_info.count_crtcs > 0 and raw_info.count_connectors > 0 and raw_info.count_encoders > 0;
- }
+ pub fn is_kms(self: *Card) !bool {
+ const raw_info = Resources.raw_without_ids(self);
+ return raw_info.count_crtcs > 0 and raw_info.count_connectors > 0 and raw_info.count_encoders > 0;
+ }
- pub fn resources(self: *Card) !Resources {
- return Resources.init(self);
- }
+ pub fn resources(self: *Card) !Resources {
+ return Resources.init(self);
+ }
- pub fn connector(self: *Card, id: u32) !Connector {
- return Connector.init(self, id);
- }
+ pub fn connector(self: *Card, id: u32) !Connector {
+ return Connector.init(self, id);
+ }
- pub fn encoder(self: *Card, id: u32) !Encoder {
- return Encoder.init(self, id);
- }
+ pub fn encoder(self: *Card, id: u32) !Encoder {
+ return Encoder.init(self, id);
+ }
- pub fn crtc(self: *Card, id: u32) !Crtc {
- return Crtc.init(self, id);
- }
+ pub fn crtc(self: *Card, id: u32) !Crtc {
+ return Crtc.init(self, id);
+ }
- pub fn create_double_buffer(self: *Card, width: u32, height: u32, bpp: u32) !DoubleBuffer {
- return DoubleBuffer.init(self, width, height, bpp);
- }
+ pub fn create_double_buffer(self: *Card, width: u32, height: u32, bpp: u32) !DoubleBuffer {
+ return DoubleBuffer.init(self, width, height, bpp);
+ }
- pub fn poll_event(self: *Card, timeout: i32) !?Event {
- var pollfd = os.pollfd {
- .fd = self.file.handle,
- .events = os.POLL.IN,
- .revents = 0
- };
+ pub fn poll_event(self: *Card, timeout: i32) !?Event {
+ var pollfd = os.pollfd {
+ .fd = self.file.handle,
+ .events = os.POLL.IN,
+ .revents = 0
+ };
- try cerror.from_usize(os.poll(@ptrCast(&pollfd), 1, timeout));
+ try cerror.from_usize(os.poll(@ptrCast(&pollfd), 1, timeout));
- if ((pollfd.revents & os.POLL.IN) != 0) {
- var event = std.mem.zeroes(Event);
- try cerror.from_usize(os.read(self.file.handle, @ptrCast(&event), @sizeOf(Event)));
- return event;
- }
+ if ((pollfd.revents & os.POLL.IN) != 0) {
+ var event = std.mem.zeroes(Event);
+ try cerror.from_usize(os.read(self.file.handle, @ptrCast(&event), @sizeOf(Event)));
+ return event;
+ }
- return null;
- }
+ return null;
+ }
};