Skip to content
Draft
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
70 changes: 70 additions & 0 deletions linuxpy/codegen/media.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# 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/linux/media.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 IOR as _IOR, IOW as _IOW, IOWR as _IOWR
from linuxpy.ctypes import u8, u16, cuint, cint, cchar, culonglong
from linuxpy.ctypes import Struct, Union, POINTER, cvoidp


ENTITY_ID_FLAG_NEXT = 1 << 31


{enums_body}


{structs_body}


{iocs_body}
"""

# macros from #define statements
MACRO_ENUMS = [
CEnum("EntityFunction", "MEDIA_ENT_F_"),
CEnum("EntityFlag", "MEDIA_ENT_FL_", klass="IntFlag"),
CEnum("PadFlag", "MEDIA_PAD_FL_", klass="IntFlag"),
CEnum("LinkFlag", "MEDIA_LNK_FL_", klass="IntFlag"),
CEnum("InterfaceType", "MEDIA_INTF_T_"),
CEnum("IOC", "MEDIA_IOC_"),
]


this_dir = pathlib.Path(__file__).parent


def main(output=this_dir.parent / "media" / "raw.py"):
import logging

logging.basicConfig(level="DEBUG")
run(__name__, HEADERS, TEMPLATE, MACRO_ENUMS, output=output)


if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions linuxpy/media/__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) 2023 Tiago Coutinho
# Distributed under the GPLv3 license. See LICENSE for more info.
Loading
Loading