From 77e8ac07c6bcbc944a7c631f91bbaf64ab99634c Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 7 Aug 2011 05:19:42 +0000 Subject: [PATCH] * add allocation of atombios fb scratch * add free of allocated fb scratch git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42591 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../accelerants/radeon_hd/atombios/atom.cpp | 30 +++++++++++++++++++ .../accelerants/radeon_hd/atombios/atom.h | 2 ++ src/add-ons/accelerants/radeon_hd/bios.cpp | 1 + 3 files changed, 33 insertions(+) diff --git a/src/add-ons/accelerants/radeon_hd/atombios/atom.cpp b/src/add-ons/accelerants/radeon_hd/atombios/atom.cpp index 3c06cec576..52d0549383 100644 --- a/src/add-ons/accelerants/radeon_hd/atombios/atom.cpp +++ b/src/add-ons/accelerants/radeon_hd/atombios/atom.cpp @@ -1272,6 +1272,7 @@ atom_destroy(atom_context *ctx) { if (ctx != NULL) { free(ctx->iio); + free(ctx->scratch); delete_sem(ctx->exec_sem); } @@ -1319,3 +1320,32 @@ atom_parse_cmd_header(atom_context *ctx, int index, uint8 * frev, return B_OK; } + +status_t +atom_allocate_fb_scratch(atom_context *ctx) +{ + int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware); + uint16 data_offset; + int usage_bytes = 0; + _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware; + + if (atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) { + firmware = (_ATOM_VRAM_USAGE_BY_FIRMWARE *) + ((uint16*)ctx->bios + data_offset); + + TRACE("Atom firmware requested 0x%" B_PRIX32 " %" B_PRIu16 "kb\n", + firmware->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware, + firmware->asFirmwareVramReserveInfo[0].usFirmwareUseInKb); + + usage_bytes + = firmware->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024; + } + if (usage_bytes == 0) + usage_bytes = 20 * 1024; + /* allocate some scratch memory */ + ctx->scratch = (uint32*)malloc(usage_bytes); + if (!ctx->scratch) + return B_NO_MEMORY; + + return B_OK; +} diff --git a/src/add-ons/accelerants/radeon_hd/atombios/atom.h b/src/add-ons/accelerants/radeon_hd/atombios/atom.h index 4333528a63..13a1897b81 100644 --- a/src/add-ons/accelerants/radeon_hd/atombios/atom.h +++ b/src/add-ons/accelerants/radeon_hd/atombios/atom.h @@ -154,5 +154,7 @@ status_t atom_parse_cmd_header(atom_context *ctx, int index, uint8 * frev, uint8 * crev); status_t atom_asic_init(atom_context *); void atom_destroy(atom_context *); +status_t atom_allocate_fb_scratch(atom_context *ctx); + #endif diff --git a/src/add-ons/accelerants/radeon_hd/bios.cpp b/src/add-ons/accelerants/radeon_hd/bios.cpp index 21568d0d90..d128288fc0 100644 --- a/src/add-ons/accelerants/radeon_hd/bios.cpp +++ b/src/add-ons/accelerants/radeon_hd/bios.cpp @@ -111,6 +111,7 @@ radeon_init_bios(uint8* bios) // Post card radeon_bios_init_scratch(); + atom_allocate_fb_scratch(gAtomContext); return B_OK; }