m1n1.agx.shim: Move UAPI to m1n1.agx.uapi

Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
Asahi Lina 2022-08-17 13:32:26 +09:00
parent 5eeed0a8bd
commit 85e6208a79
2 changed files with 118 additions and 108 deletions

View file

@ -1,14 +1,14 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
import errno, ctypes, sys, atexit
import errno, ctypes, sys, atexit, os, os.path
from construct import *
from m1n1 import malloc
from m1n1.utils import Register32
from m1n1.constructutils import ConstructClass
from m1n1.agx import AGX
from m1n1.agx.render import *
from m1n1.agx.uapi import *
from m1n1.proxyutils import *
from m1n1.utils import *
@ -32,8 +32,6 @@ _IOWR = lambda type, nr, size: IOCTL(TYPE=type, NR=nr, SIZE=size, DIR=_IOC_READ|
DRM_IOCTL_BASE = ord('d')
ASAHI_BO_PIPELINE = 1
def IO(nr):
def dec(f):
f._ioctl = _IO(DRM_IOCTL_BASE, nr)
@ -61,110 +59,6 @@ def IOWR(nr, cls):
return f
return dec
DRM_COMMAND_BASE = 0x40
class drm_asahi_submit_t(ConstructClass):
subcon = Struct(
"cmdbuf" / Int64ul,
"in_syncs" / Int64ul,
"in_sync_count" / Int32ul,
"out_sync" / Int32ul,
)
class drm_asahi_wait_bo_t(ConstructClass):
subcon = Struct(
"handle" / Int32ul,
Padding(4),
"timeout_ns" / Int64sl,
)
class drm_asahi_create_bo_t(ConstructClass):
subcon = Struct(
"size" / Int32ul,
"flags" / Int32ul,
"handle" / Int32ul,
Padding(4),
"offset" / Int64ul,
)
#class drm_asahi_mmap_bo_t(ConstructClass):
#subcon = Struct(
#"handle" / Int32ul,
#"flags" / Int32ul,
#"offset" / Int64ul,
#)
class drm_asahi_get_param_t(ConstructClass):
subcon = Struct(
"param" / Int32ul,
Padding(4),
"value" / Int64ul,
)
class drm_asahi_get_bo_offset_t(ConstructClass):
subcon = Struct(
"handle" / Int32ul,
Padding(4),
"offset" / Int64ul,
)
ASAHI_MAX_ATTACHMENTS = 16
ASAHI_ATTACHMENT_C = 0
ASAHI_ATTACHMENT_Z = 1
ASAHI_ATTACHMENT_S = 2
class drm_asahi_attachment_t(ConstructClass):
subcon = Struct(
"type" / Int32ul,
"size" / Int32ul,
"pointer" / Int64ul,
)
ASAHI_CMDBUF_LOAD_C = (1 << 0)
ASAHI_CMDBUF_LOAD_Z = (1 << 1)
ASAHI_CMDBUF_LOAD_S = (1 << 2)
class drm_asahi_cmdbuf_t(ConstructClass):
subcon = Struct(
"flags" / Int64ul,
"encoder_ptr" / Int64ul,
"encoder_id" / Int32ul,
"cmd_ta_id" / Int32ul,
"cmd_3d_id" / Int32ul,
"ds_flags" / Int32ul,
"depth_buffer" / Int64ul,
"stencil_buffer" / Int64ul,
"scissor_array" / Int64ul,
"depth_bias_array" / Int64ul,
"fb_width" / Int32ul,
"fb_height" / Int32ul,
"load_pipeline" / Int32ul,
"load_pipeline_bind" / Int32ul,
"store_pipeline" / Int32ul,
"store_pipeline_bind" / Int32ul,
"partial_reload_pipeline" / Int32ul,
"partial_reload_pipeline_bind" / Int32ul,
"partial_store_pipeline" / Int32ul,
"partial_store_pipeline_bind" / Int32ul,
"depth_clear_value" / Float32l,
"stencil_clear_value" / Int8ul,
Padding(3),
"attachments" / Array(ASAHI_MAX_ATTACHMENTS, drm_asahi_attachment_t),
"attachment_count" / Int32ul,
)
class DRMAsahiShim:
def __init__(self, memfd):
self.memfd = open(memfd, closefd=False, mode="r+b")

View file

@ -0,0 +1,116 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
from construct import *
from m1n1.constructutils import ConstructClass
__all__ = []
DRM_COMMAND_BASE = 0x40
ASAHI_BO_PIPELINE = 1
class drm_asahi_submit_t(ConstructClass):
subcon = Struct(
"cmdbuf" / Int64ul,
"in_syncs" / Int64ul,
"in_sync_count" / Int32ul,
"out_sync" / Int32ul,
)
class drm_asahi_wait_bo_t(ConstructClass):
subcon = Struct(
"handle" / Int32ul,
Padding(4),
"timeout_ns" / Int64sl,
)
class drm_asahi_create_bo_t(ConstructClass):
subcon = Struct(
"size" / Int32ul,
"flags" / Int32ul,
"handle" / Int32ul,
Padding(4),
"offset" / Int64ul,
)
#class drm_asahi_mmap_bo_t(ConstructClass):
#subcon = Struct(
#"handle" / Int32ul,
#"flags" / Int32ul,
#"offset" / Int64ul,
#)
class drm_asahi_get_param_t(ConstructClass):
subcon = Struct(
"param" / Int32ul,
Padding(4),
"value" / Int64ul,
)
class drm_asahi_get_bo_offset_t(ConstructClass):
subcon = Struct(
"handle" / Int32ul,
Padding(4),
"offset" / Int64ul,
)
ASAHI_MAX_ATTACHMENTS = 16
ASAHI_ATTACHMENT_C = 0
ASAHI_ATTACHMENT_Z = 1
ASAHI_ATTACHMENT_S = 2
class drm_asahi_attachment_t(ConstructClass):
subcon = Struct(
"type" / Int32ul,
"size" / Int32ul,
"pointer" / Int64ul,
)
ASAHI_CMDBUF_LOAD_C = (1 << 0)
ASAHI_CMDBUF_LOAD_Z = (1 << 1)
ASAHI_CMDBUF_LOAD_S = (1 << 2)
class drm_asahi_cmdbuf_t(ConstructClass):
subcon = Struct(
"flags" / Int64ul,
"encoder_ptr" / Int64ul,
"encoder_id" / Int32ul,
"cmd_ta_id" / Int32ul,
"cmd_3d_id" / Int32ul,
"ds_flags" / Int32ul,
"depth_buffer" / Int64ul,
"stencil_buffer" / Int64ul,
"scissor_array" / Int64ul,
"depth_bias_array" / Int64ul,
"fb_width" / Int32ul,
"fb_height" / Int32ul,
"load_pipeline" / Int32ul,
"load_pipeline_bind" / Int32ul,
"store_pipeline" / Int32ul,
"store_pipeline_bind" / Int32ul,
"partial_reload_pipeline" / Int32ul,
"partial_reload_pipeline_bind" / Int32ul,
"partial_store_pipeline" / Int32ul,
"partial_store_pipeline_bind" / Int32ul,
"depth_clear_value" / Float32l,
"stencil_clear_value" / Int8ul,
Padding(3),
"attachments" / Array(ASAHI_MAX_ATTACHMENTS, drm_asahi_attachment_t),
"attachment_count" / Int32ul,
)
__all__.extend(k for k, v in globals().items()
if ((callable(v) or isinstance(v, type)) and v.__module__ == __name__) or isinstance(v, int))