diff --git a/src/add-ons/accelerants/vesa/Jamfile b/src/add-ons/accelerants/vesa/Jamfile index 89f59c1773..0983a5100a 100644 --- a/src/add-ons/accelerants/vesa/Jamfile +++ b/src/add-ons/accelerants/vesa/Jamfile @@ -2,6 +2,7 @@ SubDir HAIKU_TOP src add-ons accelerants vesa ; UsePrivateHeaders graphics ; UsePrivateHeaders [ FDirName graphics vesa ] ; +UsePrivateHeaders [ FDirName graphics common ] ; #AddResources vesa.accelerant : vesa.accelerant.rdef ; @@ -11,4 +12,5 @@ Addon vesa.accelerant : engine.cpp hooks.cpp mode.cpp + : libaccelerantscommon.a ; diff --git a/src/add-ons/accelerants/vesa/accelerant.cpp b/src/add-ons/accelerants/vesa/accelerant.cpp index 650444746c..168ef012fa 100644 --- a/src/add-ons/accelerants/vesa/accelerant.cpp +++ b/src/add-ons/accelerants/vesa/accelerant.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -74,10 +74,9 @@ AreaCloner::Keep() // #pragma mark - -/** This is the common accelerant_info initializer. It is called by - * both, the first accelerant and all clones. - */ - +/*! This is the common accelerant_info initializer. It is called by + both, the first accelerant and all clones. +*/ static status_t init_common(int device, bool isClone) { @@ -95,16 +94,16 @@ init_common(int device, bool isClone) // get basic info from driver area_id sharedArea; - if (ioctl(device, VESA_GET_PRIVATE_DATA, &sharedArea, sizeof(area_id)) != 0) { + if (ioctl(device, VESA_GET_PRIVATE_DATA, &sharedArea, sizeof(area_id)) + != 0) { free(gInfo); return B_ERROR; } AreaCloner sharedCloner; gInfo->shared_info_area = sharedCloner.Clone("vesa shared info", - (void **)&gInfo->shared_info, B_ANY_ADDRESS, - B_READ_AREA | B_WRITE_AREA, - sharedArea); + (void **)&gInfo->shared_info, B_ANY_ADDRESS, + B_READ_AREA | B_WRITE_AREA, sharedArea); status_t status = sharedCloner.InitCheck(); if (status < B_OK) { free(gInfo); @@ -135,11 +134,10 @@ uninit_common(void) } -// #pragma mark - -// public accelerant functions +// #pragma mark - public accelerant functions -/** init primary accelerant */ +/*! Init primary accelerant */ status_t vesa_init_accelerant(int device) @@ -156,6 +154,8 @@ vesa_init_accelerant(int device) return status; } + // Initialize current mode completely from the mode list + vesa_propose_display_mode(&gInfo->shared_info->current_mode, NULL, NULL); return B_OK; } @@ -210,10 +210,9 @@ err1: } -/** This function is called for both, the primary accelerant and all of - * its clones. - */ - +/*! This function is called for both, the primary accelerant and all of + its clones. +*/ void vesa_uninit_accelerant(void) { diff --git a/src/add-ons/accelerants/vesa/mode.cpp b/src/add-ons/accelerants/vesa/mode.cpp index 1a5dbb4714..07683b42b5 100644 --- a/src/add-ons/accelerants/vesa/mode.cpp +++ b/src/add-ons/accelerants/vesa/mode.cpp @@ -1,10 +1,12 @@ /* - * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ #include +#include + #include "accelerant_protos.h" #include "accelerant.h" #include "utility.h" @@ -19,82 +21,22 @@ extern "C" void _sPrintf(const char *format, ...); #endif -#define T_POSITIVE_SYNC (B_POSITIVE_HSYNC | B_POSITIVE_VSYNC) -#define MODE_FLAGS (B_8_BIT_DAC | B_HARDWARE_CURSOR | B_PARALLEL_ACCESS | B_DPMS /*| B_SUPPORTS_OVERLAYS*/) - -static const display_mode kBaseModeList[] = { -{ { 25175, 640, 656, 752, 800, 350, 387, 389, 449, B_POSITIVE_HSYNC}, B_CMAP8, 640, 350, 0, 0, MODE_FLAGS}, /* 640x350 - www.epanorama.net/documents/pc/vga_timing.html) */ -{ { 25175, 640, 656, 752, 800, 400, 412, 414, 449, B_POSITIVE_VSYNC}, B_CMAP8, 640, 400, 0, 0, MODE_FLAGS}, /* 640x400 - www.epanorama.net/documents/pc/vga_timing.html) */ -{ { 25175, 640, 656, 752, 800, 480, 490, 492, 525, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@60Hz_(640X480X8.Z1) */ -{ { 27500, 640, 672, 768, 864, 480, 488, 494, 530, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* 640X480X60Hz */ -{ { 30500, 640, 672, 768, 864, 480, 517, 523, 588, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* SVGA_640X480X60HzNI */ -{ { 31500, 640, 664, 704, 832, 480, 489, 492, 520, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@70-72Hz_(640X480X8.Z1) */ -{ { 31500, 640, 656, 720, 840, 480, 481, 484, 500, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@75Hz_(640X480X8.Z1) */ -{ { 36000, 640, 696, 752, 832, 480, 481, 484, 509, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@85Hz_(640X480X8.Z1) */ -{ { 38100, 800, 832, 960, 1088, 600, 602, 606, 620, 0}, B_CMAP8, 800, 600, 0, 0, MODE_FLAGS}, /* SVGA_800X600X56HzNI */ -{ { 40000, 800, 840, 968, 1056, 600, 601, 605, 628, T_POSITIVE_SYNC}, B_CMAP8, 800, 600, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@60Hz_(800X600X8.Z1) */ -{ { 49500, 800, 816, 896, 1056, 600, 601, 604, 625, T_POSITIVE_SYNC}, B_CMAP8, 800, 600, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@75Hz_(800X600X8.Z1) */ -{ { 50000, 800, 856, 976, 1040, 600, 637, 643, 666, T_POSITIVE_SYNC}, B_CMAP8, 800, 600, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@70-72Hz_(800X600X8.Z1) */ -{ { 56250, 800, 832, 896, 1048, 600, 601, 604, 631, T_POSITIVE_SYNC}, B_CMAP8, 800, 600, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@85Hz_(800X600X8.Z1) */ -{ { 65000, 1024, 1048, 1184, 1344, 768, 771, 777, 806, 0}, B_CMAP8, 1024, 768, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@60Hz_(1024X768X8.Z1) */ -{ { 75000, 1024, 1048, 1184, 1328, 768, 771, 777, 806, 0}, B_CMAP8, 1024, 768, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@70-72Hz_(1024X768X8.Z1) */ -{ { 78750, 1024, 1040, 1136, 1312, 768, 769, 772, 800, T_POSITIVE_SYNC}, B_CMAP8, 1024, 768, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@75Hz_(1024X768X8.Z1) */ -{ { 94500, 1024, 1072, 1168, 1376, 768, 769, 772, 808, T_POSITIVE_SYNC}, B_CMAP8, 1024, 768, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@85Hz_(1024X768X8.Z1) */ -{ { 94200, 1152, 1184, 1280, 1472, 864, 865, 868, 914, T_POSITIVE_SYNC}, B_CMAP8, 1152, 864, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@70Hz_(1152X864X8.Z1) */ -{ { 108000, 1152, 1216, 1344, 1600, 864, 865, 868, 900, T_POSITIVE_SYNC}, B_CMAP8, 1152, 864, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@75Hz_(1152X864X8.Z1) */ -{ { 121500, 1152, 1216, 1344, 1568, 864, 865, 868, 911, T_POSITIVE_SYNC}, B_CMAP8, 1152, 864, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@85Hz_(1152X864X8.Z1) */ -{ { 108000, 1280, 1328, 1440, 1688, 1024, 1025, 1028, 1066, T_POSITIVE_SYNC}, B_CMAP8, 1280, 1024, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@60Hz_(1280X1024X8.Z1) */ -{ { 135000, 1280, 1296, 1440, 1688, 1024, 1025, 1028, 1066, T_POSITIVE_SYNC}, B_CMAP8, 1280, 1024, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@75Hz_(1280X1024X8.Z1) */ -{ { 157500, 1280, 1344, 1504, 1728, 1024, 1025, 1028, 1072, T_POSITIVE_SYNC}, B_CMAP8, 1280, 1024, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@85Hz_(1280X1024X8.Z1) */ -{ { 162000, 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, T_POSITIVE_SYNC}, B_CMAP8, 1600, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@60Hz_(1600X1200X8.Z1) */ -{ { 175500, 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, T_POSITIVE_SYNC}, B_CMAP8, 1600, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@65Hz_(1600X1200X8.Z1) */ -{ { 189000, 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, T_POSITIVE_SYNC}, B_CMAP8, 1600, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@70Hz_(1600X1200X8.Z1) */ -{ { 202500, 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, T_POSITIVE_SYNC}, B_CMAP8, 1600, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@75Hz_(1600X1200X8.Z1) */ -{ { 216000, 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, T_POSITIVE_SYNC}, B_CMAP8, 1600, 1200, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_@80Hz_(1600X1200X8.Z1) */ -{ { 229500, 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, T_POSITIVE_SYNC}, B_CMAP8, 1600, 1200, 0, 0, MODE_FLAGS} /* Vesa_Monitor_@85Hz_(1600X1200X8.Z1) */ -}; -static const uint32 kNumBaseModes = sizeof(kBaseModeList) / sizeof(display_mode); -static const uint32 kMaxNumModes = kNumBaseModes * 4; - - -/** Creates the initial mode list of the primary accelerant. - * It's called from vesa_init_accelerant(). - */ +/*! Creates the initial mode list of the primary accelerant. + It's called from vesa_init_accelerant(). +*/ status_t create_mode_list(void) { // ToDo: basically, the boot loader should pass a list of all supported // VESA modes to us. - color_space spaces[4] = {B_RGB32_LITTLE, B_RGB16_LITTLE, B_RGB15_LITTLE, B_CMAP8}; - size_t size = ROUND_TO_PAGE_SIZE(kMaxNumModes * sizeof(display_mode)); - display_mode *list; - - gInfo->mode_list_area = create_area("vesa modes", (void **)&list, B_ANY_ADDRESS, - size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); + + gInfo->mode_list_area = create_display_modes("vesa modes", NULL, NULL, 0, + NULL, 0, NULL, &gInfo->mode_list, &gInfo->shared_info->mode_count); if (gInfo->mode_list_area < B_OK) return gInfo->mode_list_area; - // for now, just copy all of the modes with different color spaces - - const display_mode *source = kBaseModeList; - uint32 count = 0; - - for (uint32 i = 0; i < kNumBaseModes; i++) { - for (uint32 j = 0; j < (sizeof(spaces) / sizeof(color_space)); j++) { - list[count] = *source; - list[count].space = spaces[j]; - - count++; - } - - source++; - } - - gInfo->mode_list = list; gInfo->shared_info->mode_list_area = gInfo->mode_list_area; - gInfo->shared_info->mode_count = count; - return B_OK; } @@ -153,23 +95,6 @@ vesa_set_display_mode(display_mode *_mode) // ToDo: unless we have a VBE3 device, we can't change the display mode return B_UNSUPPORTED; -#if 0 - gInfo->shared_info->current_mode = mode; - - switch (mode.space) { - case B_RGB32_LITTLE: - gInfo->shared_info->bytes_per_row = mode.virtual_width * 4; - break; - case B_RGB16_LITTLE: - case B_RGB15_LITTLE: - gInfo->shared_info->bytes_per_row = mode.virtual_width * 2; - break; - case B_CMAP8: - gInfo->shared_info->bytes_per_row = mode.virtual_width; - break; - } - return B_OK; -#endif }