Author: kallisti5 Date: 2011-05-06 00:52:17 +0200 (Fri, 06 May 2011) New Revision: 41334 Changeset: https://dev.haiku-os.org/changeset/41334 Added: haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.h Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.cpp Log: added header file for mode.cpp; change gDisplayMode to pointer for now; add function to quickly perform sanity check on mode lines; enhance tracing Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h 2011-05-05 22:05:52 UTC (rev 41333) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h 2011-05-05 22:52:17 UTC (rev 41334) @@ -9,6 +9,7 @@ #define RADEON_HD_ACCELERANT_H +#include "mode.h" #include "radeon_hd.h" @@ -89,7 +90,4 @@ } -// modes.cpp -extern status_t create_mode_list(void); - #endif /* RADEON_HD_ACCELERANT_H */ Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.cpp 2011-05-05 22:05:52 UTC (rev 41333) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.cpp 2011-05-05 22:52:17 UTC (rev 41334) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2011, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Support for i915 chipset and up based on the X driver, @@ -7,32 +7,30 @@ * * Authors: * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx + * Alexander von Gluck, kallisti5@xxxxxxxxxxx */ #include "accelerant_protos.h" #include "accelerant.h" #include "utility.h" +#include "mode.h" #include <stdio.h> #include <string.h> #include <math.h> -#include <create_display_modes.h> -#include <ddc.h> -#include <edid.h> - #define TRACE_MODE #ifdef TRACE_MODE extern "C" void _sPrintf(const char *format, ...); -# define TRACE(x) _sPrintf x +# define TRACE(x...) _sPrintf("radeon_hd: " x) #else -# define TRACE(x) ; +# define TRACE(x...) ; #endif -static display_mode gDisplayMode; +static display_mode *gDisplayMode; status_t @@ -41,25 +39,27 @@ // TODO : Read active monitor EDID /* Populate modeline with temporary example */ - gDisplayMode.timing.pixel_clock = 71500; - gDisplayMode.timing.h_display = 1366; // In Pixels - gDisplayMode.timing.h_sync_start = 1406; - gDisplayMode.timing.h_sync_end = 1438; - gDisplayMode.timing.h_total = 1510; - gDisplayMode.timing.v_display = 768; // In Pixels - gDisplayMode.timing.v_sync_start = 771; - gDisplayMode.timing.v_sync_end = 777; - gDisplayMode.timing.v_total = 789; - gDisplayMode.timing.flags = 0; // Polarity, ex: B_POSITIVE_HSYNC + gDisplayMode->timing.pixel_clock = 71500; + gDisplayMode->timing.h_display = 1366; // In Pixels + gDisplayMode->timing.h_sync_start = 1406; + gDisplayMode->timing.h_sync_end = 1438; + gDisplayMode->timing.h_total = 1510; + gDisplayMode->timing.v_display = 768; // In Pixels + gDisplayMode->timing.v_sync_start = 771; + gDisplayMode->timing.v_sync_end = 777; + gDisplayMode->timing.v_total = 789; + gDisplayMode->timing.flags = 0; // Polarity, ex: B_POSITIVE_HSYNC - gDisplayMode.space = B_RGB32_LITTLE; // Pixel configuration - gDisplayMode.virtual_width = 1366; // In Pixels - gDisplayMode.virtual_height = 768; // In Pixels - gDisplayMode.h_display_start = 0; - gDisplayMode.v_display_start = 0; - gDisplayMode.flags = 0; // Mode flags (Some drivers use this + gDisplayMode->space = B_RGB32_LITTLE; // Pixel configuration + gDisplayMode->virtual_width = 1366; // In Pixels + gDisplayMode->virtual_height = 768; // In Pixels + gDisplayMode->h_display_start = 0; + gDisplayMode->v_display_start = 0; + gDisplayMode->flags = 0; // Mode flags (Some drivers use this - gInfo->mode_list = &gDisplayMode; + mode_sanity_check(gDisplayMode); + + gInfo->mode_list = gDisplayMode; gInfo->shared_info->mode_count = 1; return B_OK; } @@ -71,7 +71,7 @@ uint32 radeon_accelerant_mode_count(void) { - TRACE(("radeon_accelerant_mode_count()\n")); + TRACE("%d\n", __func__); return gInfo->shared_info->mode_count; } @@ -80,7 +80,7 @@ status_t radeon_get_mode_list(display_mode *modeList) { - TRACE(("radeon_get_mode_info()\n")); + TRACE("%d\n", __func__); memcpy(modeList, gInfo->mode_list, gInfo->shared_info->mode_count * sizeof(display_mode)); return B_OK; @@ -350,9 +350,9 @@ status_t radeon_get_display_mode(display_mode *_currentMode) { - TRACE(("radeon_get_display_mode()\n")); + TRACE("%s\n", __func__); - *_currentMode = gDisplayMode; + _currentMode = gDisplayMode; return B_OK; } @@ -360,7 +360,7 @@ status_t radeon_get_frame_buffer_config(frame_buffer_config *config) { - TRACE(("radeon_get_frame_buffer_config()\n")); + TRACE("%s\n", __func__); uint32 offset = gInfo->shared_info->frame_buffer_offset; @@ -376,7 +376,7 @@ status_t radeon_get_pixel_clock_limits(display_mode *mode, uint32 *_low, uint32 *_high) { - TRACE(("radeon_get_pixel_clock_limits()\n")); + TRACE("%s\n", __func__); /* if (_low != NULL) { // lower limit of about 48Hz vertical refresh @@ -399,3 +399,36 @@ } +/* + * A quick sanity check of the provided display_mode + */ +status_t +mode_sanity_check(display_mode *mode) +{ + if (mode->timing.h_display <= 0 + || mode->timing.h_sync_start <= 0 + || mode->timing.h_sync_end <= 0 + || mode->timing.h_total <= 0) { + TRACE("Invalid horizontal mode timing received for %dx%d\n", + mode->timing.h_display, mode->timing.v_display); + return B_ERROR; + } + + if (mode->timing.v_display <= 0 + || mode->timing.v_sync_start <= 0 + || mode->timing.v_sync_end <= 0 + || mode->timing.v_total <= 0) { + TRACE("Invalid vertical mode timing received for %dx%d\n", + mode->timing.h_display, mode->timing.v_display); + return B_ERROR; + } + + if (mode->flags <= 0) { + TRACE("Invalid mode timing flag received for %dx%d\n", + mode->timing.h_display, mode->timing.v_display); + return B_ERROR; + } + + return B_OK; +} + Added: haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.h (rev 0) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/mode.h 2011-05-05 22:52:17 UTC (rev 41334) @@ -0,0 +1,17 @@ +/* + * Copyright 2006-2011, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck, kallisti5@xxxxxxxxxxx + */ + + +#include <create_display_modes.h> +#include <ddc.h> +#include <edid.h> + + +status_t create_mode_list(void); +status_t mode_sanity_check(display_mode *mode); +