Display.py revision 14283
16657Snate@binkert.org# Copyright (c) 2019 ARM Limited 26657Snate@binkert.org# All rights reserved. 310972Sdavid.hashe@amd.com# 46657Snate@binkert.org# The license below extends only to copyright in the software and shall 56657Snate@binkert.org# not be construed as granting a license to any other intellectual 66657Snate@binkert.org# property including but not limited to intellectual property relating 76657Snate@binkert.org# to a hardware implementation of the functionality of the software 86657Snate@binkert.org# licensed hereunder. You may use the software subject to the license 96657Snate@binkert.org# terms below provided that you ensure that this notice is replicated 106657Snate@binkert.org# unmodified and in its entirety in all distributions of the software, 116657Snate@binkert.org# modified or unmodified, in source code or in binary form. 126657Snate@binkert.org# 136657Snate@binkert.org# Redistribution and use in source and binary forms, with or without 146657Snate@binkert.org# modification, are permitted provided that the following conditions are 156657Snate@binkert.org# met: redistributions of source code must retain the above copyright 166657Snate@binkert.org# notice, this list of conditions and the following disclaimer; 176657Snate@binkert.org# redistributions in binary form must reproduce the above copyright 186657Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 196657Snate@binkert.org# documentation and/or other materials provided with the distribution; 206657Snate@binkert.org# neither the name of the copyright holders nor the names of its 216657Snate@binkert.org# contributors may be used to endorse or promote products derived from 226657Snate@binkert.org# this software without specific prior written permission. 236657Snate@binkert.org# 246657Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 256657Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 266657Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 276657Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 286657Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 296657Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 306657Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 316657Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 326657Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 336657Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 346657Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 356657Snate@binkert.org# 366657Snate@binkert.org# Authors: Giacomo Travaglini 376657Snate@binkert.org 386657Snate@binkert.orgfrom m5.params import * 396657Snate@binkert.orgfrom m5.SimObject import SimObject 406657Snate@binkert.orgfrom m5.util.fdthelper import * 416657Snate@binkert.org 426657Snate@binkert.orgclass Display(SimObject): 436657Snate@binkert.org type = 'Display' 446657Snate@binkert.org cxx_header = "dev/arm/display.hh" 456657Snate@binkert.org clock_frequency = Param.Unsigned("clock-frequency property") 466657Snate@binkert.org hactive = Param.Unsigned("hactive property") 476657Snate@binkert.org vactive = Param.Unsigned("vactive property") 486657Snate@binkert.org hfront_porch = Param.Unsigned("hfront-porch property") 496657Snate@binkert.org hback_porch = Param.Unsigned("hback-porch property") 506657Snate@binkert.org hsync_len = Param.Unsigned("hsync-len property") 516657Snate@binkert.org vfront_porch = Param.Unsigned("vfront-porch property") 526657Snate@binkert.org vback_porch = Param.Unsigned("vback-porch property") 536657Snate@binkert.org vsync_len = Param.Unsigned("vsync-len property") 546657Snate@binkert.org 556657Snate@binkert.org _endpoint_node = None 566657Snate@binkert.org 576657Snate@binkert.org def endpointPhandle(self): 586657Snate@binkert.org return "encoder_endpoint" 596657Snate@binkert.org 606657Snate@binkert.org def endpointNode(self): 616657Snate@binkert.org assert self._endpoint_node is not None 626657Snate@binkert.org return self._endpoint_node 636657Snate@binkert.org 646657Snate@binkert.org def generateDeviceTree(self, state): 656657Snate@binkert.org # timing node 666657Snate@binkert.org timing_node = FdtNode(self.timingNode()) 676657Snate@binkert.org 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