diff options
| author | 2014-04-27 12:39:57 -0400 | |
|---|---|---|
| committer | 2014-04-27 12:39:57 -0400 | |
| commit | f0525a1eb4bc133f43c6dd10166965467a34dd45 (patch) | |
| tree | a9514ac3f3b062da41a170861991d8a5d57fd7af /src/core/hw/lcd.cpp | |
| parent | - changed HW IO map to use virtual addresses (diff) | |
| download | yuzu-f0525a1eb4bc133f43c6dd10166965467a34dd45.tar.gz yuzu-f0525a1eb4bc133f43c6dd10166965467a34dd45.tar.xz yuzu-f0525a1eb4bc133f43c6dd10166965467a34dd45.zip | |
added code to LCD modules keep track of framebuffer location in FCRAM or VRAM
Diffstat (limited to 'src/core/hw/lcd.cpp')
| -rw-r--r-- | src/core/hw/lcd.cpp | 91 |
1 files changed, 90 insertions, 1 deletions
diff --git a/src/core/hw/lcd.cpp b/src/core/hw/lcd.cpp index 822cd1647..6468053f2 100644 --- a/src/core/hw/lcd.cpp +++ b/src/core/hw/lcd.cpp | |||
| @@ -6,19 +6,107 @@ | |||
| 6 | #include "common/log.h" | 6 | #include "common/log.h" |
| 7 | 7 | ||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/mem_map.h" | ||
| 9 | #include "core/hw/lcd.h" | 10 | #include "core/hw/lcd.h" |
| 10 | 11 | ||
| 11 | #include "video_core/video_core.h" | 12 | #include "video_core/video_core.h" |
| 12 | 13 | ||
| 13 | namespace LCD { | 14 | namespace LCD { |
| 14 | 15 | ||
| 16 | Registers g_regs; | ||
| 17 | |||
| 15 | static const u32 kFrameTicks = 268123480 / 60; ///< 268MHz / 60 frames per second | 18 | static const u32 kFrameTicks = 268123480 / 60; ///< 268MHz / 60 frames per second |
| 16 | 19 | ||
| 17 | u64 g_last_ticks = 0; ///< Last CPU ticks | 20 | u64 g_last_ticks = 0; ///< Last CPU ticks |
| 18 | 21 | ||
| 22 | /** | ||
| 23 | * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM | ||
| 24 | * @param | ||
| 25 | */ | ||
| 26 | void SetFramebufferLocation(const FramebufferLocation mode) { | ||
| 27 | switch (mode) { | ||
| 28 | case FRAMEBUFFER_LOCATION_FCRAM: | ||
| 29 | g_regs.framebuffer_top_left_1 = PADDR_TOP_LEFT_FRAME1; | ||
| 30 | g_regs.framebuffer_top_left_2 = PADDR_TOP_LEFT_FRAME2; | ||
| 31 | g_regs.framebuffer_top_right_1 = PADDR_TOP_RIGHT_FRAME1; | ||
| 32 | g_regs.framebuffer_top_right_2 = PADDR_TOP_RIGHT_FRAME2; | ||
| 33 | g_regs.framebuffer_sub_left_1 = PADDR_SUB_FRAME1; | ||
| 34 | //g_regs.framebuffer_sub_left_2 = unknown; | ||
| 35 | g_regs.framebuffer_sub_right_1 = PADDR_SUB_FRAME2; | ||
| 36 | //g_regs.framebufferr_sub_right_2 = unknown; | ||
| 37 | break; | ||
| 38 | |||
| 39 | case FRAMEBUFFER_LOCATION_VRAM: | ||
| 40 | g_regs.framebuffer_top_left_1 = PADDR_VRAM_TOP_LEFT_FRAME1; | ||
| 41 | g_regs.framebuffer_top_left_2 = PADDR_VRAM_TOP_LEFT_FRAME2; | ||
| 42 | g_regs.framebuffer_top_right_1 = PADDR_VRAM_TOP_RIGHT_FRAME1; | ||
| 43 | g_regs.framebuffer_top_right_2 = PADDR_VRAM_TOP_RIGHT_FRAME2; | ||
| 44 | g_regs.framebuffer_sub_left_1 = PADDR_VRAM_SUB_FRAME1; | ||
| 45 | //g_regs.framebuffer_sub_left_2 = unknown; | ||
| 46 | g_regs.framebuffer_sub_right_1 = PADDR_VRAM_SUB_FRAME2; | ||
| 47 | //g_regs.framebufferr_sub_right_2 = unknown; | ||
| 48 | break; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | /** | ||
| 53 | * Gets the location of the framebuffers | ||
| 54 | * @return Location of framebuffers as FramebufferLocation enum | ||
| 55 | */ | ||
| 56 | const FramebufferLocation GetFramebufferLocation() { | ||
| 57 | if ((g_regs.framebuffer_top_right_1 & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) { | ||
| 58 | return FRAMEBUFFER_LOCATION_VRAM; | ||
| 59 | } else if ((g_regs.framebuffer_top_right_1 & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) { | ||
| 60 | return FRAMEBUFFER_LOCATION_FCRAM; | ||
| 61 | } else { | ||
| 62 | ERROR_LOG(LCD, "unknown framebuffer location!"); | ||
| 63 | } | ||
| 64 | return FRAMEBUFFER_LOCATION_UNKNOWN; | ||
| 65 | } | ||
| 66 | |||
| 67 | /** | ||
| 68 | * Gets a read-only pointer to a framebuffer in memory | ||
| 69 | * @param address Physical address of framebuffer | ||
| 70 | * @return Returns const pointer to raw framebuffer | ||
| 71 | */ | ||
| 72 | const u8* GetFramebufferPointer(const u32 address) { | ||
| 73 | switch (GetFramebufferLocation()) { | ||
| 74 | case FRAMEBUFFER_LOCATION_FCRAM: | ||
| 75 | return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_FCRAM(address)); | ||
| 76 | case FRAMEBUFFER_LOCATION_VRAM: | ||
| 77 | return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_VRAM(address)); | ||
| 78 | default: | ||
| 79 | ERROR_LOG(LCD, "unknown framebuffer location"); | ||
| 80 | } | ||
| 81 | return NULL; | ||
| 82 | } | ||
| 83 | |||
| 19 | template <typename T> | 84 | template <typename T> |
| 20 | inline void Read(T &var, const u32 addr) { | 85 | inline void Read(T &var, const u32 addr) { |
| 21 | ERROR_LOG(LCD, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); | 86 | switch (addr) { |
| 87 | case REG_FRAMEBUFFER_TOP_LEFT_1: | ||
| 88 | var = g_regs.framebuffer_top_left_1; | ||
| 89 | break; | ||
| 90 | case REG_FRAMEBUFFER_TOP_LEFT_2: | ||
| 91 | var = g_regs.framebuffer_top_left_2; | ||
| 92 | break; | ||
| 93 | case REG_FRAMEBUFFER_TOP_RIGHT_1: | ||
| 94 | var = g_regs.framebuffer_top_right_1; | ||
| 95 | break; | ||
| 96 | case REG_FRAMEBUFFER_TOP_RIGHT_2: | ||
| 97 | var = g_regs.framebuffer_top_right_2; | ||
| 98 | break; | ||
| 99 | case REG_FRAMEBUFFER_SUB_LEFT_1: | ||
| 100 | var = g_regs.framebuffer_sub_left_1; | ||
| 101 | break; | ||
| 102 | case REG_FRAMEBUFFER_SUB_RIGHT_1: | ||
| 103 | var = g_regs.framebuffer_sub_right_1; | ||
| 104 | break; | ||
| 105 | default: | ||
| 106 | ERROR_LOG(LCD, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); | ||
| 107 | break; | ||
| 108 | } | ||
| 109 | |||
| 22 | } | 110 | } |
| 23 | 111 | ||
| 24 | template <typename T> | 112 | template <typename T> |
| @@ -51,6 +139,7 @@ void Update() { | |||
| 51 | /// Initialize hardware | 139 | /// Initialize hardware |
| 52 | void Init() { | 140 | void Init() { |
| 53 | g_last_ticks = Core::g_app_core->GetTicks(); | 141 | g_last_ticks = Core::g_app_core->GetTicks(); |
| 142 | SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM); | ||
| 54 | NOTICE_LOG(LCD, "initialized OK"); | 143 | NOTICE_LOG(LCD, "initialized OK"); |
| 55 | } | 144 | } |
| 56 | 145 | ||