summaryrefslogtreecommitdiff
path: root/src/screen/drm/card.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen/drm/card.zig')
-rw-r--r--src/screen/drm/card.zig44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/screen/drm/card.zig b/src/screen/drm/card.zig
index f1674bb..cff8edf 100644
--- a/src/screen/drm/card.zig
+++ b/src/screen/drm/card.zig
@@ -3,13 +3,7 @@ const os = std.os.linux;
const cerror = @import("../cerror.zig");
-const Resources = @import("resources.zig").Resources;
-const Connector = @import("connector/root.zig").Connector;
-const Encoder = @import("encoder/root.zig").Encoder;
-const Crtc = @import("crtc/root.zig").Crtc;
-const DoubleBuffer = @import("frame-buffer/root.zig").DoubleBuffer;
-const Event = @import("event.zig").Event;
-
+const drm = @import("./root.zig");
pub const Card = struct {
const Self = @This();
@@ -35,32 +29,36 @@ pub const Card = struct {
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 resources(self: *Card) !drm.Resources {
+ return drm.Resources.init(self);
}
- pub fn resources(self: *Card) !Resources {
- return Resources.init(self);
+ pub fn connector(self: *Card, id: u32) !drm.Connector {
+ return drm.Connector.init(self, id);
}
- pub fn connector(self: *Card, id: u32) !Connector {
- return Connector.init(self, id);
+ pub fn encoder(self: *Card, id: u32) !drm.Encoder {
+ return drm.Encoder.init(self, id);
}
- pub fn encoder(self: *Card, id: u32) !Encoder {
- return Encoder.init(self, id);
+ pub fn crtc(self: *Card, id: u32) !drm.Crtc {
+ return drm.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) !drm.Buffer {
+ return drm.Buffer.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 request(
+ self: *Self,
+ comptime kind: drm.request.Kind,
+ payload: anytype
+ ) !void {
+ const id = kind.id(@TypeOf(payload));
+ try cerror.from_usize(os.ioctl(self.file.handle, id, @intFromPtr(payload)));
}
- pub fn poll_event(self: *Card, timeout: i32) !?Event {
+ pub fn poll_event(self: *Card, timeout: i32) !?drm.Event {
var pollfd = os.pollfd {
.fd = self.file.handle,
.events = os.POLL.IN,
@@ -70,8 +68,8 @@ pub const Card = struct {
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)));
+ var event = std.mem.zeroes(drm.Event);
+ try cerror.from_usize(os.read(self.file.handle, @ptrCast(&event), @sizeOf(drm.Event)));
return event;
}