From 8266e8e9202f83d4555101cf0d4a1aba76555013 Mon Sep 17 00:00:00 2001 From: Jose Tiago Macara Coutinho Date: Sat, 25 Jan 2025 05:45:22 +0100 Subject: [PATCH 1/2] Fix common prefix in code generation --- linuxpy/codegen/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linuxpy/codegen/base.py b/linuxpy/codegen/base.py index 0707313..30d8ae9 100644 --- a/linuxpy/codegen/base.py +++ b/linuxpy/codegen/base.py @@ -295,8 +295,11 @@ def get_enums(header_filename, xml_filename, enums, decode_name): continue py_name = cname_to_pyname(decode_name(cname)) prefix = cname.upper() + "_" - raw_names = [child.get("name") for child in node] - common_prefix = os.path.commonprefix(raw_names) + if len(node) > 1: + raw_names = [child.get("name") for child in node] + common_prefix = os.path.commonprefix(raw_names) + else: + common_prefix = "" values = [] for child in node: name = child.get("name") From a5e4769ddd7b4691e348c1dea66c4c643b557c1f Mon Sep 17 00:00:00 2001 From: Jose Tiago Macara Coutinho Date: Sat, 25 Jan 2025 06:22:48 +0100 Subject: [PATCH 2/2] Initial DRM --- linuxpy/codegen/base.py | 1 + linuxpy/codegen/drm.py | 78 +++ linuxpy/drm/__init__.py | 5 + linuxpy/drm/raw.py | 1264 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 1348 insertions(+) create mode 100644 linuxpy/codegen/drm.py create mode 100644 linuxpy/drm/__init__.py create mode 100644 linuxpy/drm/raw.py diff --git a/linuxpy/codegen/base.py b/linuxpy/codegen/base.py index 30d8ae9..9fa9b72 100644 --- a/linuxpy/codegen/base.py +++ b/linuxpy/codegen/base.py @@ -140,6 +140,7 @@ def decode_macro_value(value, context, name_map): value = value.replace("*/", "") value = value.replace("/*", "#") value = value.replace("struct ", "") + value = value.replace("union ", "") value = value.replace("(1U", "(1") value = value.strip() for dtype in "ui": diff --git a/linuxpy/codegen/drm.py b/linuxpy/codegen/drm.py new file mode 100644 index 0000000..6291fbf --- /dev/null +++ b/linuxpy/codegen/drm.py @@ -0,0 +1,78 @@ +# +# This file is part of the linuxpy project +# +# Copyright (c) 2024 Tiago Coutinho +# Distributed under the GPLv3 license. See LICENSE for more info. + +import pathlib + +from linuxpy.codegen.base import CEnum, run + +HEADERS = [ + "/usr/include/drm/drm_mode.h", + "/usr/include/drm/drm.h", +] + + +TEMPLATE = """\ +# +# This file is part of the linuxpy project +# +# Copyright (c) 2024 Tiago Coutinho +# Distributed under the GPLv3 license. See LICENSE for more info. + +# This file has been generated by {name} +# Date: {date} +# System: {system} +# Release: {release} +# Version: {version} + +import enum + +from linuxpy.ioctl import IO as _IO, IOR as _IOR, IOW as _IOW, IOWR as _IOWR +from linuxpy.ctypes import u8, u16, u32, cuint, cint, cchar, clong, culong, clonglong, culonglong +from linuxpy.ctypes import Struct, Union, POINTER, cvoidp + + +DRM_IOCTL_BASE = "d" + +def DRM_IO(nr): + return _IO(DRM_IOCTL_BASE, nr) + + +def DRM_IOR(nr, type): + return _IOR(DRM_IOCTL_BASE, nr, type) + + +def DRM_IOW(nr, type): + return _IOW(DRM_IOCTL_BASE, nr, type) + + +def DRM_IOWR(nr, type): + return _IOWR(DRM_IOCTL_BASE, nr, type) + + +{enums_body} + + +{structs_body} + + +{iocs_body}""" + + +# macros from #define statements +MACRO_ENUMS = [ + CEnum("IOC", "DRM_IOCTL_"), +] + + +this_dir = pathlib.Path(__file__).parent + + +def main(output=this_dir.parent / "drm" / "raw.py"): + run(__name__, HEADERS, TEMPLATE, MACRO_ENUMS, output=output) + + +if __name__ == "__main__": + main() diff --git a/linuxpy/drm/__init__.py b/linuxpy/drm/__init__.py new file mode 100644 index 0000000..24bcc0a --- /dev/null +++ b/linuxpy/drm/__init__.py @@ -0,0 +1,5 @@ +# +# This file is part of the linuxpy project +# +# Copyright (c) 2024 Tiago Coutinho +# Distributed under the GPLv3 license. See LICENSE for more info. diff --git a/linuxpy/drm/raw.py b/linuxpy/drm/raw.py new file mode 100644 index 0000000..f301b69 --- /dev/null +++ b/linuxpy/drm/raw.py @@ -0,0 +1,1264 @@ +# +# This file is part of the linuxpy project +# +# Copyright (c) 2024 Tiago Coutinho +# Distributed under the GPLv3 license. See LICENSE for more info. + +# This file has been generated by __main__ +# Date: 2025-01-25 06:22:40.207849 +# System: Linux +# Release: 6.8.0-51-generic +# Version: #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 + +import enum + +from linuxpy.ctypes import ( + POINTER, + Struct, + Union, + cchar, + cint, + clong, + clonglong, + cuint, + culong, + culonglong, + u8, + u16, +) +from linuxpy.ioctl import IO as _IO, IOR as _IOR, IOW as _IOW, IOWR as _IOWR + +DRM_IOCTL_BASE = "d" + + +def DRM_IO(nr): + return _IO(DRM_IOCTL_BASE, nr) + + +def DRM_IOR(nr, type): + return _IOR(DRM_IOCTL_BASE, nr, type) + + +def DRM_IOW(nr, type): + return _IOW(DRM_IOCTL_BASE, nr, type) + + +def DRM_IOWR(nr, type): + return _IOWR(DRM_IOCTL_BASE, nr, type) + + +class DrmModeSubconnector(enum.IntEnum): + Automatic = 0 + Unknown = 0 + VGA = 1 + DVID = 3 + DVIA = 4 + Composite = 5 + SVIDEO = 6 + Component = 8 + SCART = 9 + DisplayPort = 10 + HDMIA = 11 + Native = 15 + Wireless = 18 + + +class DrmMapType(enum.IntEnum): + FRAME_BUFFER = 0 + REGISTERS = 1 + SHM = 2 + AGP = 3 + SCATTER_GATHER = 4 + CONSISTENT = 5 + + +class DrmMapFlags(enum.IntFlag): + RESTRICTED = 1 + READ_ONLY = 2 + LOCKED = 4 + KERNEL = 8 + WRITE_COMBINING = 16 + CONTAINS_LOCK = 32 + REMOVABLE = 64 + DRIVER = 128 + + +class DrmStatType(enum.IntEnum): + LOCK = 0 + OPENS = 1 + CLOSES = 2 + IOCTLS = 3 + LOCKS = 4 + UNLOCKS = 5 + VALUE = 6 + BYTE = 7 + COUNT = 8 + IRQ = 9 + PRIMARY = 10 + SECONDARY = 11 + DMA = 12 + SPECIAL = 13 + MISSED = 14 + + +class DrmLockFlags(enum.IntFlag): + LOCK_READY = 1 + LOCK_QUIESCENT = 2 + LOCK_FLUSH = 4 + LOCK_FLUSH_ALL = 8 + HALT_ALL_QUEUES = 16 + HALT_CUR_QUEUES = 32 + + +class DrmDmaFlags(enum.IntFlag): + BLOCK = 1 + WHILE_LOCKED = 2 + PRIORITY = 4 + WAIT = 16 + SMALLER_OK = 32 + LARGER_OK = 64 + + +class DrmCtxFlags(enum.IntFlag): + PRESERVED = 1 + _2DONLY = 2 + + +class DrmDrawableInfoTypeT(enum.IntEnum): + DRM_DRAWABLE_CLIPRECTS = 0 + + +class DrmVblankSeqType(enum.IntEnum): + ABSOLUTE = 0 + RELATIVE = 1 + HIGH_CRTC_MASK = 62 + EVENT = 67108864 + FLIP = 134217728 + NEXTONMISS = 268435456 + SECONDARY = 536870912 + SIGNAL = 1073741824 + + +class drm_mode_modeinfo(Struct): + pass + + +drm_mode_modeinfo._fields_ = [ + ("clock", cuint), + ("hdisplay", u16), + ("hsync_start", u16), + ("hsync_end", u16), + ("htotal", u16), + ("hskew", u16), + ("vdisplay", u16), + ("vsync_start", u16), + ("vsync_end", u16), + ("vtotal", u16), + ("vscan", u16), + ("vrefresh", cuint), + ("flags", cuint), + ("type", cuint), + ("name", cchar * 32), +] + + +class drm_mode_card_res(Struct): + pass + + +drm_mode_card_res._fields_ = [ + ("fb_id_ptr", culonglong), + ("crtc_id_ptr", culonglong), + ("connector_id_ptr", culonglong), + ("encoder_id_ptr", culonglong), + ("count_fbs", cuint), + ("count_crtcs", cuint), + ("count_connectors", cuint), + ("count_encoders", cuint), + ("min_width", cuint), + ("max_width", cuint), + ("min_height", cuint), + ("max_height", cuint), +] + + +class drm_mode_crtc(Struct): + pass + + +drm_mode_crtc._fields_ = [ + ("set_connectors_ptr", culonglong), + ("count_connectors", cuint), + ("crtc_id", cuint), + ("fb_id", cuint), + ("x", cuint), + ("y", cuint), + ("gamma_size", cuint), + ("mode_valid", cuint), + ("mode", drm_mode_modeinfo), +] + + +class drm_mode_set_plane(Struct): + pass + + +drm_mode_set_plane._fields_ = [ + ("plane_id", cuint), + ("crtc_id", cuint), + ("fb_id", cuint), + ("flags", cuint), + ("crtc_x", cint), + ("crtc_y", cint), + ("crtc_w", cuint), + ("crtc_h", cuint), + ("src_x", cuint), + ("src_y", cuint), + ("src_h", cuint), + ("src_w", cuint), +] + + +class drm_mode_get_plane(Struct): + pass + + +drm_mode_get_plane._fields_ = [ + ("plane_id", cuint), + ("crtc_id", cuint), + ("fb_id", cuint), + ("possible_crtcs", cuint), + ("gamma_size", cuint), + ("count_format_types", cuint), + ("format_type_ptr", culonglong), +] + + +class drm_mode_get_plane_res(Struct): + pass + + +drm_mode_get_plane_res._fields_ = [("plane_id_ptr", culonglong), ("count_planes", cuint)] + + +class drm_mode_get_encoder(Struct): + pass + + +drm_mode_get_encoder._fields_ = [ + ("encoder_id", cuint), + ("encoder_type", cuint), + ("crtc_id", cuint), + ("possible_crtcs", cuint), + ("possible_clones", cuint), +] + + +class drm_mode_get_connector(Struct): + pass + + +drm_mode_get_connector._fields_ = [ + ("encoders_ptr", culonglong), + ("modes_ptr", culonglong), + ("props_ptr", culonglong), + ("prop_values_ptr", culonglong), + ("count_modes", cuint), + ("count_props", cuint), + ("count_encoders", cuint), + ("encoder_id", cuint), + ("connector_id", cuint), + ("connector_type", cuint), + ("connector_type_id", cuint), + ("connection", cuint), + ("mm_width", cuint), + ("mm_height", cuint), + ("subpixel", cuint), + ("pad", cuint), +] + + +class drm_mode_property_enum(Struct): + pass + + +drm_mode_property_enum._fields_ = [("value", culonglong), ("name", cchar * 32)] + + +class drm_mode_get_property(Struct): + pass + + +drm_mode_get_property._fields_ = [ + ("values_ptr", culonglong), + ("enum_blob_ptr", culonglong), + ("prop_id", cuint), + ("flags", cuint), + ("name", cchar * 32), + ("count_values", cuint), + ("count_enum_blobs", cuint), +] + + +class drm_mode_connector_set_property(Struct): + pass + + +drm_mode_connector_set_property._fields_ = [("value", culonglong), ("prop_id", cuint), ("connector_id", cuint)] + + +class drm_mode_obj_get_properties(Struct): + pass + + +drm_mode_obj_get_properties._fields_ = [ + ("props_ptr", culonglong), + ("prop_values_ptr", culonglong), + ("count_props", cuint), + ("obj_id", cuint), + ("obj_type", cuint), +] + + +class drm_mode_obj_set_property(Struct): + pass + + +drm_mode_obj_set_property._fields_ = [("value", culonglong), ("prop_id", cuint), ("obj_id", cuint), ("obj_type", cuint)] + + +class drm_mode_get_blob(Struct): + pass + + +drm_mode_get_blob._fields_ = [("blob_id", cuint), ("length", cuint), ("data", culonglong)] + + +class drm_mode_fb_cmd(Struct): + pass + + +drm_mode_fb_cmd._fields_ = [ + ("fb_id", cuint), + ("width", cuint), + ("height", cuint), + ("pitch", cuint), + ("bpp", cuint), + ("depth", cuint), + ("handle", cuint), +] + + +class drm_mode_fb_cmd2(Struct): + pass + + +drm_mode_fb_cmd2._fields_ = [ + ("fb_id", cuint), + ("width", cuint), + ("height", cuint), + ("pixel_format", cuint), + ("flags", cuint), + ("handles", cuint * 4), + ("pitches", cuint * 4), + ("offsets", cuint * 4), + ("modifier", culonglong * 4), +] + + +class drm_mode_fb_dirty_cmd(Struct): + pass + + +drm_mode_fb_dirty_cmd._fields_ = [ + ("fb_id", cuint), + ("flags", cuint), + ("color", cuint), + ("num_clips", cuint), + ("clips_ptr", culonglong), +] + + +class drm_mode_mode_cmd(Struct): + pass + + +drm_mode_mode_cmd._fields_ = [("connector_id", cuint), ("mode", drm_mode_modeinfo)] + + +class drm_mode_cursor(Struct): + pass + + +drm_mode_cursor._fields_ = [ + ("flags", cuint), + ("crtc_id", cuint), + ("x", cint), + ("y", cint), + ("width", cuint), + ("height", cuint), + ("handle", cuint), +] + + +class drm_mode_cursor2(Struct): + pass + + +drm_mode_cursor2._fields_ = [ + ("flags", cuint), + ("crtc_id", cuint), + ("x", cint), + ("y", cint), + ("width", cuint), + ("height", cuint), + ("handle", cuint), + ("hot_x", cint), + ("hot_y", cint), +] + + +class drm_mode_crtc_lut(Struct): + pass + + +drm_mode_crtc_lut._fields_ = [ + ("crtc_id", cuint), + ("gamma_size", cuint), + ("red", culonglong), + ("green", culonglong), + ("blue", culonglong), +] + + +class drm_color_ctm(Struct): + pass + + +drm_color_ctm._fields_ = [("matrix", culonglong * 9)] + + +class drm_color_ctm_3x4(Struct): + pass + + +drm_color_ctm_3x4._fields_ = [("matrix", culonglong * 12)] + + +class drm_color_lut(Struct): + pass + + +drm_color_lut._fields_ = [("red", u16), ("green", u16), ("blue", u16), ("reserved", u16)] + + +class hdr_metadata_infoframe(Struct): + class M1(Struct): + pass + + M1._fields_ = [("x", u16), ("y", u16)] + + class M2(Struct): + pass + + M2._fields_ = [("x", u16), ("y", u16)] + + +hdr_metadata_infoframe._fields_ = [ + ("eotf", u8), + ("metadata_type", u8), + ("display_primaries", *3), + ("white_point", hdr_metadata_infoframe.M2), + ("max_display_mastering_luminance", u16), + ("min_display_mastering_luminance", u16), + ("max_cll", u16), + ("max_fall", u16), +] + + +class hdr_output_metadata(Struct): + class M1(Union): + pass + + M1._fields_ = [("hdmi_metadata_type1", hdr_metadata_infoframe)] + + _anonymous_ = ("m1",) + + +hdr_output_metadata._fields_ = [("metadata_type", cuint), ("m1", hdr_output_metadata.M1)] + + +class drm_mode_crtc_page_flip(Struct): + pass + + +drm_mode_crtc_page_flip._fields_ = [ + ("crtc_id", cuint), + ("fb_id", cuint), + ("flags", cuint), + ("reserved", cuint), + ("user_data", culonglong), +] + + +class drm_mode_crtc_page_flip_target(Struct): + pass + + +drm_mode_crtc_page_flip_target._fields_ = [ + ("crtc_id", cuint), + ("fb_id", cuint), + ("flags", cuint), + ("sequence", cuint), + ("user_data", culonglong), +] + + +class drm_mode_create_dumb(Struct): + pass + + +drm_mode_create_dumb._fields_ = [ + ("height", cuint), + ("width", cuint), + ("bpp", cuint), + ("flags", cuint), + ("handle", cuint), + ("pitch", cuint), + ("size", culonglong), +] + + +class drm_mode_map_dumb(Struct): + pass + + +drm_mode_map_dumb._fields_ = [("handle", cuint), ("pad", cuint), ("offset", culonglong)] + + +class drm_mode_destroy_dumb(Struct): + pass + + +drm_mode_destroy_dumb._fields_ = [("handle", cuint)] + + +class drm_mode_atomic(Struct): + pass + + +drm_mode_atomic._fields_ = [ + ("flags", cuint), + ("count_objs", cuint), + ("objs_ptr", culonglong), + ("count_props_ptr", culonglong), + ("props_ptr", culonglong), + ("prop_values_ptr", culonglong), + ("reserved", culonglong), + ("user_data", culonglong), +] + + +class drm_format_modifier_blob(Struct): + pass + + +drm_format_modifier_blob._fields_ = [ + ("version", cuint), + ("flags", cuint), + ("count_formats", cuint), + ("formats_offset", cuint), + ("count_modifiers", cuint), + ("modifiers_offset", cuint), +] + + +class drm_format_modifier(Struct): + pass + + +drm_format_modifier._fields_ = [("formats", culonglong), ("offset", cuint), ("pad", cuint), ("modifier", culonglong)] + + +class drm_mode_create_blob(Struct): + pass + + +drm_mode_create_blob._fields_ = [("data", culonglong), ("length", cuint), ("blob_id", cuint)] + + +class drm_mode_destroy_blob(Struct): + pass + + +drm_mode_destroy_blob._fields_ = [("blob_id", cuint)] + + +class drm_mode_create_lease(Struct): + pass + + +drm_mode_create_lease._fields_ = [ + ("object_ids", culonglong), + ("object_count", cuint), + ("flags", cuint), + ("lessee_id", cuint), + ("fd", cuint), +] + + +class drm_mode_list_lessees(Struct): + pass + + +drm_mode_list_lessees._fields_ = [("count_lessees", cuint), ("pad", cuint), ("lessees_ptr", culonglong)] + + +class drm_mode_get_lease(Struct): + pass + + +drm_mode_get_lease._fields_ = [("count_objects", cuint), ("pad", cuint), ("objects_ptr", culonglong)] + + +class drm_mode_revoke_lease(Struct): + pass + + +drm_mode_revoke_lease._fields_ = [("lessee_id", cuint)] + + +class drm_mode_rect(Struct): + pass + + +drm_mode_rect._fields_ = [("x1", cint), ("y1", cint), ("x2", cint), ("y2", cint)] + + +class drm_mode_closefb(Struct): + pass + + +drm_mode_closefb._fields_ = [("fb_id", cuint), ("pad", cuint)] + + +class drm_clip_rect(Struct): + pass + + +drm_clip_rect._fields_ = [("x1", u16), ("y1", u16), ("x2", u16), ("y2", u16)] + + +class drm_drawable_info(Struct): + pass + + +drm_drawable_info._fields_ = [("num_rects", cuint), ("rects", POINTER(drm_clip_rect))] + + +class drm_tex_region(Struct): + pass + + +drm_tex_region._fields_ = [("next", u8), ("prev", u8), ("in_use", u8), ("padding", u8), ("age", cuint)] + + +class drm_hw_lock(Struct): + pass + + +drm_hw_lock._fields_ = [("lock", cuint), ("padding", cchar * 60)] + + +class drm_version(Struct): + pass + + +drm_version._fields_ = [ + ("version_major", cint), + ("version_minor", cint), + ("version_patchlevel", cint), + ("name_len", culong), + ("name", POINTER(cchar)), + ("date_len", culong), + ("date", POINTER(cchar)), + ("desc_len", culong), + ("desc", POINTER(cchar)), +] + + +class drm_unique(Struct): + pass + + +drm_unique._fields_ = [("unique_len", culong), ("unique", POINTER(cchar))] + + +class drm_list(Struct): + pass + + +drm_list._fields_ = [("count", cint), ("version", POINTER(drm_version))] + + +class drm_block(Struct): + pass + + +drm_block._fields_ = [("unused", cint)] + + +class drm_control(Struct): + pass + + +drm_control._fields_ = [("", cuint), ("func", cuint), ("irq", cint)] + + +class drm_ctx_priv_map(Struct): + pass + + +drm_ctx_priv_map._fields_ = [("ctx_id", cuint), ("handle", POINTER(None))] + + +class drm_map(Struct): + pass + + +drm_map._fields_ = [ + ("offset", culong), + ("size", culong), + ("type", cuint), + ("flags", cuint), + ("handle", POINTER(None)), + ("mtrr", cint), +] + + +class drm_client(Struct): + pass + + +drm_client._fields_ = [ + ("idx", cint), + ("auth", cint), + ("pid", culong), + ("uid", culong), + ("magic", culong), + ("iocs", culong), +] + + +class drm_stats(Struct): + class M1(Struct): + pass + + M1._fields_ = [("value", culong), ("type", cuint)] + + +drm_stats._fields_ = [("count", culong), ("data", *15)] + + +class drm_lock(Struct): + pass + + +drm_lock._fields_ = [("context", cint), ("flags", cuint)] + + +class drm_buf_desc(Struct): + pass + + +drm_buf_desc._fields_ = [ + ("count", cint), + ("size", cint), + ("low_mark", cint), + ("high_mark", cint), + ("", cuint), + ("flags", cuint), + ("agp_start", culong), +] + + +class drm_buf_info(Struct): + pass + + +drm_buf_info._fields_ = [("count", cint), ("list", POINTER(drm_buf_desc))] + + +class drm_buf_free(Struct): + pass + + +drm_buf_free._fields_ = [("count", cint), ("list", POINTER(cint))] + + +class drm_buf_pub(Struct): + pass + + +drm_buf_pub._fields_ = [("idx", cint), ("total", cint), ("used", cint), ("address", POINTER(None))] + + +class drm_buf_map(Struct): + pass + + +drm_buf_map._fields_ = [("count", cint), ("virtual", POINTER(None)), ("list", POINTER(drm_buf_pub))] + + +class drm_dma(Struct): + pass + + +drm_dma._fields_ = [ + ("context", cint), + ("send_count", cint), + ("send_indices", POINTER(cint)), + ("send_sizes", POINTER(cint)), + ("flags", cuint), + ("request_count", cint), + ("request_size", cint), + ("request_indices", POINTER(cint)), + ("request_sizes", POINTER(cint)), + ("granted_count", cint), +] + + +class drm_ctx(Struct): + pass + + +drm_ctx._fields_ = [("handle", cuint), ("flags", cuint)] + + +class drm_ctx_res(Struct): + pass + + +drm_ctx_res._fields_ = [("count", cint), ("contexts", POINTER(drm_ctx))] + + +class drm_draw(Struct): + pass + + +drm_draw._fields_ = [("handle", cuint)] + + +class drm_update_draw(Struct): + pass + + +drm_update_draw._fields_ = [("handle", cuint), ("type", cuint), ("num", cuint), ("data", culonglong)] + + +class drm_auth(Struct): + pass + + +drm_auth._fields_ = [("magic", cuint)] + + +class drm_irq_busid(Struct): + pass + + +drm_irq_busid._fields_ = [("irq", cint), ("busnum", cint), ("devnum", cint), ("funcnum", cint)] + + +class drm_wait_vblank_request(Struct): + pass + + +drm_wait_vblank_request._fields_ = [("type", cuint), ("sequence", cuint), ("signal", culong)] + + +class drm_wait_vblank_reply(Struct): + pass + + +drm_wait_vblank_reply._fields_ = [("type", cuint), ("sequence", cuint), ("tval_sec", clong), ("tval_usec", clong)] + + +class drm_modeset_ctl(Struct): + pass + + +drm_modeset_ctl._fields_ = [("crtc", cuint), ("cmd", cuint)] + + +class drm_agp_mode(Struct): + pass + + +drm_agp_mode._fields_ = [("mode", culong)] + + +class drm_agp_buffer(Struct): + pass + + +drm_agp_buffer._fields_ = [("size", culong), ("handle", culong), ("type", culong), ("physical", culong)] + + +class drm_agp_binding(Struct): + pass + + +drm_agp_binding._fields_ = [("handle", culong), ("offset", culong)] + + +class drm_agp_info(Struct): + pass + + +drm_agp_info._fields_ = [ + ("agp_version_major", cint), + ("agp_version_minor", cint), + ("mode", culong), + ("aperture_base", culong), + ("aperture_size", culong), + ("memory_allowed", culong), + ("memory_used", culong), + ("id_vendor", u16), + ("id_device", u16), +] + + +class drm_scatter_gather(Struct): + pass + + +drm_scatter_gather._fields_ = [("size", culong), ("handle", culong)] + + +class drm_set_version(Struct): + pass + + +drm_set_version._fields_ = [ + ("drm_di_major", cint), + ("drm_di_minor", cint), + ("drm_dd_major", cint), + ("drm_dd_minor", cint), +] + + +class drm_gem_close(Struct): + pass + + +drm_gem_close._fields_ = [("handle", cuint), ("pad", cuint)] + + +class drm_gem_flink(Struct): + pass + + +drm_gem_flink._fields_ = [("handle", cuint), ("name", cuint)] + + +class drm_gem_open(Struct): + pass + + +drm_gem_open._fields_ = [("name", cuint), ("handle", cuint), ("size", culonglong)] + + +class drm_get_cap(Struct): + pass + + +drm_get_cap._fields_ = [("capability", culonglong), ("value", culonglong)] + + +class drm_set_client_cap(Struct): + pass + + +drm_set_client_cap._fields_ = [("capability", culonglong), ("value", culonglong)] + + +class drm_prime_handle(Struct): + pass + + +drm_prime_handle._fields_ = [("handle", cuint), ("flags", cuint), ("fd", cint)] + + +class drm_syncobj_create(Struct): + pass + + +drm_syncobj_create._fields_ = [("handle", cuint), ("flags", cuint)] + + +class drm_syncobj_destroy(Struct): + pass + + +drm_syncobj_destroy._fields_ = [("handle", cuint), ("pad", cuint)] + + +class drm_syncobj_handle(Struct): + pass + + +drm_syncobj_handle._fields_ = [("handle", cuint), ("flags", cuint), ("fd", cint), ("pad", cuint)] + + +class drm_syncobj_transfer(Struct): + pass + + +drm_syncobj_transfer._fields_ = [ + ("src_handle", cuint), + ("dst_handle", cuint), + ("src_point", culonglong), + ("dst_point", culonglong), + ("flags", cuint), + ("pad", cuint), +] + + +class drm_syncobj_wait(Struct): + pass + + +drm_syncobj_wait._fields_ = [ + ("handles", culonglong), + ("timeout_nsec", clonglong), + ("count_handles", cuint), + ("flags", cuint), + ("first_signaled", cuint), + ("pad", cuint), + ("deadline_nsec", culonglong), +] + + +class drm_syncobj_timeline_wait(Struct): + pass + + +drm_syncobj_timeline_wait._fields_ = [ + ("handles", culonglong), + ("points", culonglong), + ("timeout_nsec", clonglong), + ("count_handles", cuint), + ("flags", cuint), + ("first_signaled", cuint), + ("pad", cuint), + ("deadline_nsec", culonglong), +] + + +class drm_syncobj_eventfd(Struct): + pass + + +drm_syncobj_eventfd._fields_ = [ + ("handle", cuint), + ("flags", cuint), + ("point", culonglong), + ("fd", cint), + ("pad", cuint), +] + + +class drm_syncobj_array(Struct): + pass + + +drm_syncobj_array._fields_ = [("handles", culonglong), ("count_handles", cuint), ("pad", cuint)] + + +class drm_syncobj_timeline_array(Struct): + pass + + +drm_syncobj_timeline_array._fields_ = [ + ("handles", culonglong), + ("points", culonglong), + ("count_handles", cuint), + ("flags", cuint), +] + + +class drm_crtc_get_sequence(Struct): + pass + + +drm_crtc_get_sequence._fields_ = [ + ("crtc_id", cuint), + ("active", cuint), + ("sequence", culonglong), + ("sequence_ns", clonglong), +] + + +class drm_crtc_queue_sequence(Struct): + pass + + +drm_crtc_queue_sequence._fields_ = [ + ("crtc_id", cuint), + ("flags", cuint), + ("sequence", culonglong), + ("user_data", culonglong), +] + + +class drm_event(Struct): + pass + + +drm_event._fields_ = [("type", cuint), ("length", cuint)] + + +class drm_event_vblank(Struct): + pass + + +drm_event_vblank._fields_ = [ + ("base", drm_event), + ("user_data", culonglong), + ("tv_sec", cuint), + ("tv_usec", cuint), + ("sequence", cuint), + ("crtc_id", cuint), +] + + +class drm_event_crtc_sequence(Struct): + pass + + +drm_event_crtc_sequence._fields_ = [ + ("base", drm_event), + ("user_data", culonglong), + ("time_ns", clonglong), + ("sequence", culonglong), +] + + +class drm_wait_vblank(Union): + pass + + +drm_wait_vblank._fields_ = [("request", drm_wait_vblank_request), ("reply", drm_wait_vblank_reply)] + + +class IOC(enum.IntEnum): + BASE = "d" + VERSION = DRM_IOWR(0x00, drm_version) + GET_UNIQUE = DRM_IOWR(0x01, drm_unique) + GET_MAGIC = DRM_IOR(0x02, drm_auth) + IRQ_BUSID = DRM_IOWR(0x03, drm_irq_busid) + GET_MAP = DRM_IOWR(0x04, drm_map) + GET_CLIENT = DRM_IOWR(0x05, drm_client) + GET_STATS = DRM_IOR(0x06, drm_stats) + SET_VERSION = DRM_IOWR(0x07, drm_set_version) + MODESET_CTL = DRM_IOW(0x08, drm_modeset_ctl) + GEM_CLOSE = DRM_IOW(0x09, drm_gem_close) + GEM_FLINK = DRM_IOWR(0x0A, drm_gem_flink) + GEM_OPEN = DRM_IOWR(0x0B, drm_gem_open) + GET_CAP = DRM_IOWR(0x0C, drm_get_cap) + SET_CLIENT_CAP = DRM_IOW(0x0D, drm_set_client_cap) + SET_UNIQUE = DRM_IOW(0x10, drm_unique) + AUTH_MAGIC = DRM_IOW(0x11, drm_auth) + BLOCK = DRM_IOWR(0x12, drm_block) + UNBLOCK = DRM_IOWR(0x13, drm_block) + CONTROL = DRM_IOW(0x14, drm_control) + ADD_MAP = DRM_IOWR(0x15, drm_map) + ADD_BUFS = DRM_IOWR(0x16, drm_buf_desc) + MARK_BUFS = DRM_IOW(0x17, drm_buf_desc) + INFO_BUFS = DRM_IOWR(0x18, drm_buf_info) + MAP_BUFS = DRM_IOWR(0x19, drm_buf_map) + FREE_BUFS = DRM_IOW(0x1A, drm_buf_free) + RM_MAP = DRM_IOW(0x1B, drm_map) + SET_SAREA_CTX = DRM_IOW(0x1C, drm_ctx_priv_map) + GET_SAREA_CTX = DRM_IOWR(0x1D, drm_ctx_priv_map) + SET_MASTER = DRM_IO(0x1E) + DROP_MASTER = DRM_IO(0x1F) + ADD_CTX = DRM_IOWR(0x20, drm_ctx) + RM_CTX = DRM_IOWR(0x21, drm_ctx) + MOD_CTX = DRM_IOW(0x22, drm_ctx) + GET_CTX = DRM_IOWR(0x23, drm_ctx) + SWITCH_CTX = DRM_IOW(0x24, drm_ctx) + NEW_CTX = DRM_IOW(0x25, drm_ctx) + RES_CTX = DRM_IOWR(0x26, drm_ctx_res) + ADD_DRAW = DRM_IOWR(0x27, drm_draw) + RM_DRAW = DRM_IOWR(0x28, drm_draw) + DMA = DRM_IOWR(0x29, drm_dma) + LOCK = DRM_IOW(0x2A, drm_lock) + UNLOCK = DRM_IOW(0x2B, drm_lock) + FINISH = DRM_IOW(0x2C, drm_lock) + PRIME_HANDLE_TO_FD = DRM_IOWR(0x2D, drm_prime_handle) + PRIME_FD_TO_HANDLE = DRM_IOWR(0x2E, drm_prime_handle) + AGP_ACQUIRE = DRM_IO(0x30) + AGP_RELEASE = DRM_IO(0x31) + AGP_ENABLE = DRM_IOW(0x32, drm_agp_mode) + AGP_INFO = DRM_IOR(0x33, drm_agp_info) + AGP_ALLOC = DRM_IOWR(0x34, drm_agp_buffer) + AGP_FREE = DRM_IOW(0x35, drm_agp_buffer) + AGP_BIND = DRM_IOW(0x36, drm_agp_binding) + AGP_UNBIND = DRM_IOW(0x37, drm_agp_binding) + SG_ALLOC = DRM_IOWR(0x38, drm_scatter_gather) + SG_FREE = DRM_IOW(0x39, drm_scatter_gather) + WAIT_VBLANK = DRM_IOWR(0x3A, drm_wait_vblank) + CRTC_GET_SEQUENCE = DRM_IOWR(0x3B, drm_crtc_get_sequence) + CRTC_QUEUE_SEQUENCE = DRM_IOWR(0x3C, drm_crtc_queue_sequence) + UPDATE_DRAW = DRM_IOW(0x3F, drm_update_draw) + MODE_GETRESOURCES = DRM_IOWR(0xA0, drm_mode_card_res) + MODE_GETCRTC = DRM_IOWR(0xA1, drm_mode_crtc) + MODE_SETCRTC = DRM_IOWR(0xA2, drm_mode_crtc) + MODE_CURSOR = DRM_IOWR(0xA3, drm_mode_cursor) + MODE_GETGAMMA = DRM_IOWR(0xA4, drm_mode_crtc_lut) + MODE_SETGAMMA = DRM_IOWR(0xA5, drm_mode_crtc_lut) + MODE_GETENCODER = DRM_IOWR(0xA6, drm_mode_get_encoder) + MODE_GETCONNECTOR = DRM_IOWR(0xA7, drm_mode_get_connector) + MODE_ATTACHMODE = DRM_IOWR(0xA8, drm_mode_mode_cmd) # deprecated (never worked) + MODE_DETACHMODE = DRM_IOWR(0xA9, drm_mode_mode_cmd) # deprecated (never worked) + MODE_GETPROPERTY = DRM_IOWR(0xAA, drm_mode_get_property) + MODE_SETPROPERTY = DRM_IOWR(0xAB, drm_mode_connector_set_property) + MODE_GETPROPBLOB = DRM_IOWR(0xAC, drm_mode_get_blob) + MODE_GETFB = DRM_IOWR(0xAD, drm_mode_fb_cmd) + MODE_ADDFB = DRM_IOWR(0xAE, drm_mode_fb_cmd) + MODE_RMFB = DRM_IOWR(0xAF, cuint) + MODE_PAGE_FLIP = DRM_IOWR(0xB0, drm_mode_crtc_page_flip) + MODE_DIRTYFB = DRM_IOWR(0xB1, drm_mode_fb_dirty_cmd) + MODE_CREATE_DUMB = DRM_IOWR(0xB2, drm_mode_create_dumb) + MODE_MAP_DUMB = DRM_IOWR(0xB3, drm_mode_map_dumb) + MODE_DESTROY_DUMB = DRM_IOWR(0xB4, drm_mode_destroy_dumb) + MODE_GETPLANERESOURCES = DRM_IOWR(0xB5, drm_mode_get_plane_res) + MODE_GETPLANE = DRM_IOWR(0xB6, drm_mode_get_plane) + MODE_SETPLANE = DRM_IOWR(0xB7, drm_mode_set_plane) + MODE_ADDFB2 = DRM_IOWR(0xB8, drm_mode_fb_cmd2) + MODE_OBJ_GETPROPERTIES = DRM_IOWR(0xB9, drm_mode_obj_get_properties) + MODE_OBJ_SETPROPERTY = DRM_IOWR(0xBA, drm_mode_obj_set_property) + MODE_CURSOR2 = DRM_IOWR(0xBB, drm_mode_cursor2) + MODE_ATOMIC = DRM_IOWR(0xBC, drm_mode_atomic) + MODE_CREATEPROPBLOB = DRM_IOWR(0xBD, drm_mode_create_blob) + MODE_DESTROYPROPBLOB = DRM_IOWR(0xBE, drm_mode_destroy_blob) + SYNCOBJ_CREATE = DRM_IOWR(0xBF, drm_syncobj_create) + SYNCOBJ_DESTROY = DRM_IOWR(0xC0, drm_syncobj_destroy) + SYNCOBJ_HANDLE_TO_FD = DRM_IOWR(0xC1, drm_syncobj_handle) + SYNCOBJ_FD_TO_HANDLE = DRM_IOWR(0xC2, drm_syncobj_handle) + SYNCOBJ_WAIT = DRM_IOWR(0xC3, drm_syncobj_wait) + SYNCOBJ_RESET = DRM_IOWR(0xC4, drm_syncobj_array) + SYNCOBJ_SIGNAL = DRM_IOWR(0xC5, drm_syncobj_array) + MODE_CREATE_LEASE = DRM_IOWR(0xC6, drm_mode_create_lease) + MODE_LIST_LESSEES = DRM_IOWR(0xC7, drm_mode_list_lessees) + MODE_GET_LEASE = DRM_IOWR(0xC8, drm_mode_get_lease) + MODE_REVOKE_LEASE = DRM_IOWR(0xC9, drm_mode_revoke_lease) + SYNCOBJ_TIMELINE_WAIT = DRM_IOWR(0xCA, drm_syncobj_timeline_wait) + SYNCOBJ_QUERY = DRM_IOWR(0xCB, drm_syncobj_timeline_array) + SYNCOBJ_TRANSFER = DRM_IOWR(0xCC, drm_syncobj_transfer) + SYNCOBJ_TIMELINE_SIGNAL = DRM_IOWR(0xCD, drm_syncobj_timeline_array) + MODE_GETFB2 = DRM_IOWR(0xCE, drm_mode_fb_cmd2) + SYNCOBJ_EVENTFD = DRM_IOWR(0xCF, drm_syncobj_eventfd) + MODE_CLOSEFB = DRM_IOWR(0xD0, drm_mode_closefb)