/usr/lib/python2.7/dist-packages/xcffib/xf86vidmode.py is in python-xcffib 0.3.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | import xcffib
import struct
import six
MAJOR_VERSION = 2
MINOR_VERSION = 2
key = xcffib.ExtensionKey("XFree86-VidModeExtension")
_events = {}
_errors = {}
class ModeFlag:
Positive_HSync = 1 << 0
Negative_HSync = 1 << 1
Positive_VSync = 1 << 2
Negative_VSync = 1 << 3
Interlace = 1 << 4
Composite_Sync = 1 << 5
Positive_CSync = 1 << 6
Negative_CSync = 1 << 7
HSkew = 1 << 8
Broadcast = 1 << 9
Pixmux = 1 << 10
Double_Clock = 1 << 11
Half_Clock = 1 << 12
class ClockFlag:
Programable = 1 << 0
class Permission:
Read = 1 << 0
Write = 1 << 1
class ModeInfo(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.dotclock, self.hdisplay, self.hsyncstart, self.hsyncend, self.htotal, self.hskew, self.vdisplay, self.vsyncstart, self.vsyncend, self.vtotal, self.flags, self.privsize = unpacker.unpack("IHHHHIHHHH4xI12xI")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=IHHHHIHHHH4xI12xI", self.dotclock, self.hdisplay, self.hsyncstart, self.hsyncend, self.htotal, self.hskew, self.vdisplay, self.vsyncstart, self.vsyncend, self.vtotal, self.flags, self.privsize))
return buf.getvalue()
fixed_size = 48
class QueryVersionReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.major_version, self.minor_version = unpacker.unpack("xx2x4xHH")
self.bufsize = unpacker.offset - base
class QueryVersionCookie(xcffib.Cookie):
reply_type = QueryVersionReply
class GetModeLineReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.dotclock, self.hdisplay, self.hsyncstart, self.hsyncend, self.htotal, self.hskew, self.vdisplay, self.vsyncstart, self.vsyncend, self.vtotal, self.flags, self.privsize = unpacker.unpack("xx2x4xIHHHHHHHHH2xI12xI")
self.private = xcffib.List(unpacker, "B", self.privsize)
self.bufsize = unpacker.offset - base
class GetModeLineCookie(xcffib.Cookie):
reply_type = GetModeLineReply
class GetMonitorReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.vendor_length, self.model_length, self.num_hsync, self.num_vsync = unpacker.unpack("xx2x4xBBBB20x")
self.hsync = xcffib.List(unpacker, "I", self.num_hsync)
unpacker.pad("I")
self.vsync = xcffib.List(unpacker, "I", self.num_vsync)
unpacker.pad("c")
self.vendor = xcffib.List(unpacker, "c", self.vendor_length)
unpacker.pad("c")
self.alignment_pad = xcffib.List(unpacker, "c", ((self.vendor_length + 3) & (~ 3)) - self.vendor_length)
unpacker.pad("c")
self.model = xcffib.List(unpacker, "c", self.model_length)
self.bufsize = unpacker.offset - base
class GetMonitorCookie(xcffib.Cookie):
reply_type = GetMonitorReply
class GetAllModeLinesReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.modecount, = unpacker.unpack("xx2x4xI20x")
self.modeinfo = xcffib.List(unpacker, ModeInfo, self.modecount)
self.bufsize = unpacker.offset - base
class GetAllModeLinesCookie(xcffib.Cookie):
reply_type = GetAllModeLinesReply
class ValidateModeLineReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.status, = unpacker.unpack("xx2x4xI20x")
self.bufsize = unpacker.offset - base
class ValidateModeLineCookie(xcffib.Cookie):
reply_type = ValidateModeLineReply
class GetViewPortReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.x, self.y = unpacker.unpack("xx2x4xII16x")
self.bufsize = unpacker.offset - base
class GetViewPortCookie(xcffib.Cookie):
reply_type = GetViewPortReply
class GetDotClocksReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.flags, self.clocks, self.maxclocks = unpacker.unpack("xx2x4xIII12x")
self.clock = xcffib.List(unpacker, "I", (1 - (self.flags & 1)) * self.clocks)
self.bufsize = unpacker.offset - base
class GetDotClocksCookie(xcffib.Cookie):
reply_type = GetDotClocksReply
class GetGammaReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.red, self.green, self.blue = unpacker.unpack("xx2x4xIII12x")
self.bufsize = unpacker.offset - base
class GetGammaCookie(xcffib.Cookie):
reply_type = GetGammaReply
class GetGammaRampReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.size, = unpacker.unpack("xx2x4xH22x")
self.red = xcffib.List(unpacker, "H", (self.size + 1) & (~ 1))
unpacker.pad("H")
self.green = xcffib.List(unpacker, "H", (self.size + 1) & (~ 1))
unpacker.pad("H")
self.blue = xcffib.List(unpacker, "H", (self.size + 1) & (~ 1))
self.bufsize = unpacker.offset - base
class GetGammaRampCookie(xcffib.Cookie):
reply_type = GetGammaRampReply
class GetGammaRampSizeReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.size, = unpacker.unpack("xx2x4xH22x")
self.bufsize = unpacker.offset - base
class GetGammaRampSizeCookie(xcffib.Cookie):
reply_type = GetGammaRampSizeReply
class GetPermissionsReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.permissions, = unpacker.unpack("xx2x4xI20x")
self.bufsize = unpacker.offset - base
class GetPermissionsCookie(xcffib.Cookie):
reply_type = GetPermissionsReply
class xf86vidmodeExtension(xcffib.Extension):
def QueryVersion(self, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2x"))
return self.send_request(0, buf, QueryVersionCookie, is_checked=is_checked)
def GetModeLine(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(1, buf, GetModeLineCookie, is_checked=is_checked)
def ModModeLine(self, screen, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize, private, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIHHHHHHHHH2xI12xI", screen, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize))
buf.write(xcffib.pack_list(private, "B"))
return self.send_request(2, buf, is_checked=is_checked)
def SwitchMode(self, screen, zoom, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xHH", screen, zoom))
return self.send_request(3, buf, is_checked=is_checked)
def GetMonitor(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(4, buf, GetMonitorCookie, is_checked=is_checked)
def LockModeSwitch(self, screen, lock, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xHH", screen, lock))
return self.send_request(5, buf, is_checked=is_checked)
def GetAllModeLines(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(6, buf, GetAllModeLinesCookie, is_checked=is_checked)
def AddModeLine(self, screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize, after_dotclock, after_hdisplay, after_hsyncstart, after_hsyncend, after_htotal, after_hskew, after_vdisplay, after_vsyncstart, after_vsyncend, after_vtotal, after_flags, private, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIHHHHHHHHH2xI12xIIHHHHHHHHH2xI12x", screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize, after_dotclock, after_hdisplay, after_hsyncstart, after_hsyncend, after_htotal, after_hskew, after_vdisplay, after_vsyncstart, after_vsyncend, after_vtotal, after_flags))
buf.write(xcffib.pack_list(private, "B"))
return self.send_request(7, buf, is_checked=is_checked)
def DeleteModeLine(self, screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize, private, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIHHHHHHHHH2xI12xI", screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize))
buf.write(xcffib.pack_list(private, "B"))
return self.send_request(8, buf, is_checked=is_checked)
def ValidateModeLine(self, screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize, private, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIHHHHHHHHH2xI12xI", screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize))
buf.write(xcffib.pack_list(private, "B"))
return self.send_request(9, buf, ValidateModeLineCookie, is_checked=is_checked)
def SwitchToMode(self, screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize, private, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIHHHHHHHHH2xI12xI", screen, dotclock, hdisplay, hsyncstart, hsyncend, htotal, hskew, vdisplay, vsyncstart, vsyncend, vtotal, flags, privsize))
buf.write(xcffib.pack_list(private, "B"))
return self.send_request(10, buf, is_checked=is_checked)
def GetViewPort(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(11, buf, GetViewPortCookie, is_checked=is_checked)
def SetViewPort(self, screen, x, y, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2xII", screen, x, y))
return self.send_request(12, buf, is_checked=is_checked)
def GetDotClocks(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(13, buf, GetDotClocksCookie, is_checked=is_checked)
def SetClientVersion(self, major, minor, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xHH", major, minor))
return self.send_request(14, buf, is_checked=is_checked)
def SetGamma(self, screen, red, green, blue, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2xIII12x", screen, red, green, blue))
return self.send_request(15, buf, is_checked=is_checked)
def GetGamma(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH26x", screen))
return self.send_request(16, buf, GetGammaCookie, is_checked=is_checked)
def GetGammaRamp(self, screen, size, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xHH", screen, size))
return self.send_request(17, buf, GetGammaRampCookie, is_checked=is_checked)
def SetGammaRamp(self, screen, size, red, green, blue, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xHH", screen, size))
buf.write(xcffib.pack_list(red, "H"))
buf.write(xcffib.pack_list(green, "H"))
buf.write(xcffib.pack_list(blue, "H"))
return self.send_request(18, buf, is_checked=is_checked)
def GetGammaRampSize(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(19, buf, GetGammaRampSizeCookie, is_checked=is_checked)
def GetPermissions(self, screen, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xH2x", screen))
return self.send_request(20, buf, GetPermissionsCookie, is_checked=is_checked)
xcffib._add_ext(key, xf86vidmodeExtension, _events, _errors)
|