1# Copyright (c) 2019 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Redistribution and use in source and binary forms, with or without 14# modification, are permitted provided that the following conditions are 15# met: redistributions of source code must retain the above copyright 16# notice, this list of conditions and the following disclaimer; 17# redistributions in binary form must reproduce the above copyright 18# notice, this list of conditions and the following disclaimer in the 19# documentation and/or other materials provided with the distribution; 20# neither the name of the copyright holders nor the names of its 21# contributors may be used to endorse or promote products derived from 22# this software without specific prior written permission. 23# 24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35# 36# Authors: Giacomo Travaglini 37 38from m5.params import * 39from m5.SimObject import SimObject 40from m5.util.fdthelper import * 41 42class Display(SimObject): 43 type = 'Display' 44 cxx_header = "dev/arm/display.hh" 45 clock_frequency = Param.Unsigned("clock-frequency property") 46 hactive = Param.Unsigned("hactive property") 47 vactive = Param.Unsigned("vactive property") 48 hfront_porch = Param.Unsigned("hfront-porch property") 49 hback_porch = Param.Unsigned("hback-porch property") 50 hsync_len = Param.Unsigned("hsync-len property") 51 vfront_porch = Param.Unsigned("vfront-porch property") 52 vback_porch = Param.Unsigned("vback-porch property") 53 vsync_len = Param.Unsigned("vsync-len property") 54 55 _endpoint_node = None 56 57 def endpointPhandle(self): 58 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