Display.py revision 14283:b02cde4661e1
114007Sgabeblack@google.com# Copyright (c) 2019 ARM Limited
214007Sgabeblack@google.com# All rights reserved.
314007Sgabeblack@google.com#
414007Sgabeblack@google.com# The license below extends only to copyright in the software and shall
514007Sgabeblack@google.com# not be construed as granting a license to any other intellectual
614007Sgabeblack@google.com# property including but not limited to intellectual property relating
714007Sgabeblack@google.com# to a hardware implementation of the functionality of the software
814007Sgabeblack@google.com# licensed hereunder.  You may use the software subject to the license
914007Sgabeblack@google.com# terms below provided that you ensure that this notice is replicated
1014007Sgabeblack@google.com# unmodified and in its entirety in all distributions of the software,
1114007Sgabeblack@google.com# modified or unmodified, in source code or in binary form.
1214007Sgabeblack@google.com#
1314007Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
1414007Sgabeblack@google.com# modification, are permitted provided that the following conditions are
1514007Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
1614007Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
1714007Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
1814007Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
1914007Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
2014007Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
2114007Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
2214007Sgabeblack@google.com# this software without specific prior written permission.
2314007Sgabeblack@google.com#
2414007Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2514007Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2614007Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2714007Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2814007Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2914007Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3014007Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3114007Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3214007Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3314007Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3414007Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3514007Sgabeblack@google.com#
3614007Sgabeblack@google.com# Authors: Giacomo Travaglini
3714007Sgabeblack@google.com
3814007Sgabeblack@google.comfrom m5.params import *
3914007Sgabeblack@google.comfrom m5.SimObject import SimObject
4014007Sgabeblack@google.comfrom m5.util.fdthelper import *
4114007Sgabeblack@google.com
4214007Sgabeblack@google.comclass Display(SimObject):
4314007Sgabeblack@google.com    type = 'Display'
4414007Sgabeblack@google.com    cxx_header = "dev/arm/display.hh"
4514007Sgabeblack@google.com    clock_frequency = Param.Unsigned("clock-frequency property")
4614007Sgabeblack@google.com    hactive = Param.Unsigned("hactive property")
4714007Sgabeblack@google.com    vactive = Param.Unsigned("vactive property")
4814007Sgabeblack@google.com    hfront_porch = Param.Unsigned("hfront-porch property")
4914007Sgabeblack@google.com    hback_porch = Param.Unsigned("hback-porch property")
5014007Sgabeblack@google.com    hsync_len = Param.Unsigned("hsync-len property")
5114007Sgabeblack@google.com    vfront_porch = Param.Unsigned("vfront-porch property")
5214007Sgabeblack@google.com    vback_porch = Param.Unsigned("vback-porch property")
5314007Sgabeblack@google.com    vsync_len = Param.Unsigned("vsync-len property")
5414007Sgabeblack@google.com
5514007Sgabeblack@google.com    _endpoint_node = None
5614007Sgabeblack@google.com
5714007Sgabeblack@google.com    def endpointPhandle(self):
5814007Sgabeblack@google.com        return "encoder_endpoint"
59
60    def endpointNode(self):
61        assert self._endpoint_node is not None
62        return self._endpoint_node
63
64    def generateDeviceTree(self, state):
65        # timing node
66        timing_node = FdtNode(self.timingNode())
67
68        timing_node.append(FdtPropertyWords(
69            "clock-frequency", [self.clock_frequency]))
70        timing_node.append(FdtPropertyWords(
71            "hactive", [self.hactive]))
72        timing_node.append(FdtPropertyWords(
73            "vactive", [self.vactive]))
74        timing_node.append(FdtPropertyWords(
75            "hfront-porch", [self.hfront_porch]))
76        timing_node.append(FdtPropertyWords(
77            "hback-porch", [self.hback_porch]))
78        timing_node.append(FdtPropertyWords(
79            "hsync-len", [self.hsync_len]))
80        timing_node.append(FdtPropertyWords(
81            "vfront-porch", [self.vfront_porch]))
82        timing_node.append(FdtPropertyWords(
83            "vback-porch", [self.vback_porch]))
84        timing_node.append(FdtPropertyWords(
85            "vsync-len", [self.vsync_len]))
86
87        timing_node.appendPhandle(self.timingNode())
88
89        # display timing node
90        dispt_node = FdtNode("display-timings")
91        dispt_node.append(FdtPropertyWords("native-mode",
92            state.phandle(self.timingNode())))
93        dispt_node.append(timing_node)
94
95        # endpoint node
96        endpoint_node = FdtNode("endpoint")
97        endpoint_node.appendPhandle(
98            self.endpointPhandle())
99
100        # Assign node so that it can be retrieved
101        self._endpoint_node = endpoint_node
102
103        # port node
104        port_node = FdtNode("port")
105        port_node.append(endpoint_node)
106
107        # Virt-encoder
108        node = FdtNode("virt-encoder")
109        node.appendCompatible(["drm,virtual-encoder"])
110        node.append(dispt_node)
111        node.append(port_node)
112
113        yield node
114
115class Display1080p(Display):
116    clock_frequency = 148500000
117    hactive = 1920
118    vactive = 1080
119    hfront_porch = 148
120    hback_porch = 88
121    hsync_len = 44
122    vfront_porch = 36
123    vback_porch = 4
124    vsync_len = 5
125
126    def timingNode(self):
127        return "timing_1080p60"
128