summaryrefslogtreecommitdiff
path: root/tools/proxyclient/m1n1/fw/dcp/dcpav.py
blob: d063c6c3807f56453f0ce850c11dbb26e383b882 (plain)
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
# SPDX-License-Identifier: MIT
from construct import *

from ...utils import *
from ..asc import StandardASC
from ..afk.epic import *

class DCPAVControllerService(EPICStandardService):
    NAME = "dcpav-controller-epic"
    SHORT = "dcpav"

    def setPower(self, power):
        self.call(8, 0x8, struct.pack("<16xI12x", power))

    def getPower(self, power):
        return struct.unpack("<16xI12x", self.call(8, 0x9, bytes(32)))

    def wakeDisplay(self):
        self.call(8, 0xa, bytes(16))

    def sleepDisplay(self):
        self.call(8, 0xb, bytes(16))

    def forceHotPlugDetect(self):
        self.call(8, 0xc, bytes(16))

    def setVirtualDeviceMode(self, mode):
        self.call(8, 0xd, struct.pack("<16xI12x", mode))

class DCPDPControllerService(EPICStandardService):
    NAME = "dcpdp-controller-epic"
    SHORT = "dcpdp"

class DCPDPTXEndpoint(EPICEndpoint):
    SHORT = "dptx"

    SERVICES = [
        DCPAVControllerService,
        DCPDPControllerService,
    ]

ATC0 = 0
ATC1 = 1
ATC2 = 2
ATC3 = 3
LPDPTX = 4
DPTX = 5

DPPHY = 0
DPIN0 = 1
DPIN1 = 2

class DCPDPTXRemotePortService(EPICStandardService):
    NAME = "dcpdptx-port-epic"
    SHORT = "port"

    def displayRequest(self):
        self.call(8, 8, bytes(16))

    def displayRelease(self):
        self.call(8, 9, bytes(16))

    def connectTo(self, connected, unit, port, unk=0):
        target = 0
        if connected:
            target |= (1 << 8)
        target |= unit
        target |= port << 4
        self.call(8, 13, struct.pack("<16xII8x", unk, target))

class DCPDPTXPortEndpoint(EPICEndpoint):
    SHORT = "dpport"

    SERVICES = [
        DCPDPTXRemotePortService,
        DCPDPControllerService,
    ]

class DCPDPDevice(EPICStandardService):
    NAME = "dcpav-device-epic"
    SHORT = "dpdev"

class DCPAVDeviceEndpoint(EPICEndpoint):
    SHORT = "avdev"

    SERVICES = [
        DCPDPDevice,
    ]

class DCPDPService(EPICStandardService):
    NAME = "dcpav-service-epic"
    SHORT = "dpserv"

class DCPAVServiceEndpoint(EPICEndpoint):
    SHORT = "avserv"

    SERVICES = [
        DCPDPService,
    ]

class DCPAVSimpleVideoInterface(EPICStandardService):
    NAME = "dcpav-video-interface-epic"
    SHORT = "video"

class DCPAVVideoEndpoint(EPICEndpoint):
    SHORT = "avserv"

    SERVICES = [
        DCPAVSimpleVideoInterface,
    ]