diff options
Diffstat (limited to 'src/screen/drm')
| -rw-r--r-- | src/screen/drm/card.zig | 5 | ||||
| -rw-r--r-- | src/screen/drm/connector/root.zig | 21 | ||||
| -rw-r--r-- | src/screen/drm/connector/type.zig | 23 | ||||
| -rw-r--r-- | src/screen/drm/encoder/root.zig | 40 | ||||
| -rw-r--r-- | src/screen/drm/encoder/type.zig | 11 | ||||
| -rw-r--r-- | src/screen/drm/request.zig | 5 |
6 files changed, 93 insertions, 12 deletions
diff --git a/src/screen/drm/card.zig b/src/screen/drm/card.zig index 9ad34fb..c5cca24 100644 --- a/src/screen/drm/card.zig +++ b/src/screen/drm/card.zig @@ -5,6 +5,7 @@ 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; pub const Card = struct { @@ -42,4 +43,8 @@ pub const Card = struct { 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); + } }; diff --git a/src/screen/drm/connector/root.zig b/src/screen/drm/connector/root.zig index 8883d29..5766851 100644 --- a/src/screen/drm/connector/root.zig +++ b/src/screen/drm/connector/root.zig @@ -5,6 +5,7 @@ const Card = @import("../card.zig").Card; pub const Connection = @import("connection.zig").Connection; pub const Mode = @import("mode.zig").Mode; +pub const ConnectorType = @import("type.zig").Type; const RawConnector = extern struct { encoder_ids: ?*u32, @@ -15,9 +16,9 @@ const RawConnector = extern struct { count_props: u32, count_encoders: u32, encoder_id: u32, - connector_id: u32, - connector_type: u32, - connector_type_id: u32, + id: u32, + type: ConnectorType, + type_id: u32, connection: Connection, mm_width: u32, mm_height: u32, @@ -35,9 +36,9 @@ pub const Connector = struct { prop_ids: []u32, prop_value_ids: []u64, encoder_id: u32, - connector_id: u32, - connector_type: u32, - connector_type_id: u32, + id: u32, + type: ConnectorType, + type_id: u32, connection: Connection, mm_width: u32, mm_height: u32, @@ -45,7 +46,7 @@ pub const Connector = struct { pad: u32, pub fn raw_without_ids(card: *Card, id: u32) !RawConnector { - var result = std.mem.zeroInit(RawConnector, .{ .connector_id = id }); + var result = std.mem.zeroInit(RawConnector, .{ .id = id }); try Drm.get_connector.request(card.file.handle, RawConnector, &result); return result; } @@ -61,9 +62,9 @@ pub const Connector = struct { .prop_ids = try card.allocator.alloc(u32, raw.count_props), .prop_value_ids = try card.allocator.alloc(u64, raw.count_props), .encoder_id = raw.encoder_id, - .connector_id = raw.connector_id, - .connector_type = raw.connector_type, - .connector_type_id = raw.connector_type_id, + .id = raw.id, + .type = raw.type, + .type_id = raw.type_id, .connection = raw.connection, .mm_width = raw.mm_width, .mm_height = raw.mm_height, diff --git a/src/screen/drm/connector/type.zig b/src/screen/drm/connector/type.zig new file mode 100644 index 0000000..15db753 --- /dev/null +++ b/src/screen/drm/connector/type.zig @@ -0,0 +1,23 @@ +pub const Type = enum(u32) { + unknown = 0, + vga = 1, + dvi_i = 2, + dvi_d = 3, + dvi_a = 4, + composite = 5, + s_video = 6, + lvds = 7, + component = 8, + nine_pin_din = 9, + display_port = 10, + hdmi_a = 11, + hdmi_b = 12, + tv = 13, + edp = 14, + virtual = 15, + dsi = 16, + dpi = 17, + writeback = 18, + spi = 19, + usb = 20, +}; diff --git a/src/screen/drm/encoder/root.zig b/src/screen/drm/encoder/root.zig new file mode 100644 index 0000000..0712c76 --- /dev/null +++ b/src/screen/drm/encoder/root.zig @@ -0,0 +1,40 @@ +const std = @import("std"); +const Drm = @import("../request.zig").Drm; +const Card = @import("../card.zig").Card; + +const Type = @import("type.zig").Type; + +pub const RawEncoder = extern struct { + id: u32, + type: Type, + crtc_id: u32, + possible_crtcs: u32, + possible_clones: u32, +}; + +pub const Encoder = struct { + const Self = @This(); + + id: u32, + type: Type, + possible_crtcs: u32, + possible_clones: u32, + card: *Card, + + pub fn init(card: *Card, id: u32) !Self { + var raw = std.mem.zeroInit(RawEncoder, .{ .id = id }); + try Drm.get_encoder.request(card.file.handle, RawEncoder, &raw); + + return .{ + .id = raw.id, + .type = raw.type, + .possible_crtcs = raw.possible_crtcs, + .possible_clones = raw.possible_clones, + .card = card + }; + } + + pub fn deinit(self: *Self) void { + _ = self; + } +}; diff --git a/src/screen/drm/encoder/type.zig b/src/screen/drm/encoder/type.zig new file mode 100644 index 0000000..a26dc9c --- /dev/null +++ b/src/screen/drm/encoder/type.zig @@ -0,0 +1,11 @@ +pub const Type = enum(u32) { + none = 0, + dac = 1, + tmds = 2, + lvds = 3, + tvdac = 4, + virtual = 5, + dsi = 6, + dpmst = 7, + dpi = 8, +}; diff --git a/src/screen/drm/request.zig b/src/screen/drm/request.zig index bf9701c..13ccfd3 100644 --- a/src/screen/drm/request.zig +++ b/src/screen/drm/request.zig @@ -9,8 +9,9 @@ fn ioctl(fd: os.fd_t, request: u32, arg: usize) !void { pub const Drm = enum(u8) { const Self = @This(); - get_resources = 0xA0, - get_connector = 0xA7, + get_resources = 0xa0, + get_encoder = 0xa6, + get_connector = 0xa7, pub fn request(self: Self, fd: os.fd_t, T: type, arg: *T) !void { const id = os.IOCTL.IOWR('d', @intFromEnum(self), T); |