summaryrefslogtreecommitdiff
path: root/src/screen/drm/request/root.zig
blob: 757689396a0f1a818ffd20f67daac9e30a835f0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const std = @import("std");
const os = std.os.linux;
const cerror = @import("../../cerror.zig");

pub const Resources = @import("resources.zig").Resources;
pub const Encoder = @import("encoder.zig").Encoder;
pub const Connector = @import("connector.zig").Connector;

const crtc = @import("crtc.zig");
pub const Crtc = crtc.Crtc;
pub const PageFlip = crtc.PageFlip;

const frame_buffer = @import("frame-buffer.zig");
pub const CreateDumb = frame_buffer.CreateDumb;
pub const FrameBufferCmd2 = frame_buffer.FrameBufferCmd2;
pub const MapDumb = frame_buffer.MapDumb;


pub const Kind = enum(u8) {
	const Self = @This();

	get_resources = 0xa0,
	get_crtc = 0xa1,
	set_crtc = 0xa2,
	get_encoder = 0xa6,
	get_connector = 0xa7,
	remove_frame_buffer = 0xaf,
	page_flip = 0xb0,
	create_dumb = 0xb2,
	map_dumb = 0xb3,
	destroy_dumb = 0xb4,
	add_frame_buffer2 = 0xb8,

	pub fn payload(comptime self: *const Self) type {
		return comptime switch (self.*) {
			.get_resources => Resources,
			.get_crtc => Crtc,
			.set_crtc => Crtc,
			.get_encoder => Encoder,
			.get_connector => Connector,
			.remove_frame_buffer => u32,
			.page_flip => PageFlip,
			.create_dumb => CreateDumb,
			.map_dumb => MapDumb,
			.destroy_dumb => u32,
			.add_frame_buffer2 => FrameBufferCmd2,
		};
	}

	pub fn id(comptime self: *const Self, comptime pointer_type: type) u32 {
		const payload_type = self.payload();
		comptime std.debug.assert(*payload_type == pointer_type);
		return comptime os.IOCTL.IOWR('d', @intFromEnum(self.*), payload_type);
	}
};