1 // 2 // Copyright (c) 2010-2023 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 9 using Antmicro.Renode.Backends.Display; 10 using Antmicro.Renode.Core; 11 using Antmicro.Renode.Logging; 12 using Antmicro.Renode.Peripherals.Bus; 13 using System; 14 15 namespace Antmicro.Renode.Peripherals.Video 16 { 17 public class PL110 : AutoRepaintingVideo, IDoubleWordPeripheral 18 { PL110(IMachine machine, int? screenWidth = null, int? screenHeight = null)19 public PL110(IMachine machine, int? screenWidth = null, int? screenHeight = null) : base(machine) 20 { 21 Reconfigure(screenWidth ?? DefaultWidth, screenHeight ?? DefaultHeight, PixelFormat.RGB565); 22 sysbus = machine.GetSystemBus(this); 23 } 24 WriteDoubleWord(long address, uint value)25 public void WriteDoubleWord(long address, uint value) 26 { 27 if(address == 0x10) 28 { 29 this.DebugLog("Setting buffer addr to 0x{0:X}", value); 30 bufferAddress = value; 31 return; 32 } 33 this.LogUnhandledWrite(address, value); 34 } 35 ReadDoubleWord(long offset)36 public uint ReadDoubleWord(long offset) 37 { 38 switch(offset) 39 { 40 case 0xFE0: 41 return 0x10; 42 case 0xFE4: 43 return 0x11; 44 case 0xFE8: 45 return 0x04; 46 case 0xFEC: 47 return 0x00; 48 case 0xFF0: 49 return 0x0d; 50 case 0xFF4: 51 return 0xf0; 52 case 0xFF8: 53 return 0x05; 54 case 0xFFC: 55 return 0xb1; 56 default: 57 this.LogUnhandledRead(offset); 58 return 0x0; 59 } 60 } 61 Reset()62 public override void Reset() 63 { 64 // TODO! 65 } 66 Repaint()67 protected override void Repaint() 68 { 69 if(bufferAddress == 0xFFFFFFFF) 70 { 71 return; 72 } 73 sysbus.ReadBytes(bufferAddress, buffer.Length, buffer, 0); 74 } 75 76 private uint bufferAddress = 0xFFFFFFFF; 77 78 private readonly IBusController sysbus; 79 80 private const int DefaultWidth = 640; 81 private const int DefaultHeight = 480; 82 } 83 } 84 85