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; }