def __init__(self, drm, id_, type_):
self._drm = drm
self.id = id_
self.type = type_
self.props = []
arg = DrmModeObjGetPropertiesC()
arg.obj_id = self.id
arg.obj_type = self.type
fcntl.ioctl(self._drm.fd, DRM_IOCTL_MODE_OBJ_GETPROPERTIES, arg)
if arg.count_props == 0:
#print("DrmProperties(%d, 0x%x): arg.count_props=%d" % (self.id, self.type, arg.count_props))
return
prop_ids = (ctypes.c_uint32*arg.count_props)()
arg.props_ptr = ctypes.cast(ctypes.pointer(prop_ids), ctypes.c_void_p).value
prop_values = (ctypes.c_uint64*arg.count_props)()
arg.prop_values_ptr = ctypes.cast(ctypes.pointer(prop_values), ctypes.c_void_p).value
fcntl.ioctl(self._drm.fd, DRM_IOCTL_MODE_OBJ_GETPROPERTIES, arg)
self._arg = arg
for i in range(arg.count_props):
propid = int(prop_ids[i])
propc = DrmModeObjGetPropertyC()
propc.prop_id = propid
fcntl.ioctl(self._drm.fd, DRM_IOCTL_MODE_GETPROPERTY, propc)
if propc.count_enum_blobs:
if propc.flags & DRM_MODE_PROP_ENUM:
prop = DrmPropertyEnum(self._drm, propid, self.id, self.type)
elif propc.flags & DRM_MODE_PROP_BITMASK:
prop = DrmPropertyBitmask(self._drm, propid, self.id, self.type, propc)
else:
raise ValueError("count_enum_blobs: propc.flags=0x%x" % propc.flags)
elif propc.flags & DRM_MODE_PROP_BLOB:
prop = DrmPropertyBlob(self._drm, propid, self.id, self.type, propc)
else:
raise ValueError("not count_enum_blobs: propc.flags=0x%x" % propc.flags)
self.props.append(prop)
评论列表
文章目录