Skip to content
Open

DRM #83

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions linuxpy/codegen/drm.py
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 5 additions & 0 deletions linuxpy/drm/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
Loading