From dc0ca45ceb3f5266c4599b51b2fe85cb3abf4aa6 Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <kallisti5@unixzen.com>
Date: Fri, 2 Mar 2012 16:53:09 -0600
Subject: [PATCH] radeon_hd: Reduce risk of edge case failure
* Only support one display for now.
* Don't use VESA edid, use connector edid.
* Clean up hook code to make multi-display
implementation points clearer.
---
src/add-ons/accelerants/radeon_hd/accelerant.h | 4 +--
src/add-ons/accelerants/radeon_hd/mode.cpp | 31 +++++++++++++-----------
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/add-ons/accelerants/radeon_hd/accelerant.h b/src/add-ons/accelerants/radeon_hd/accelerant.h
index 25898c7..93405e1 100644
a
|
b
|
|
20 | 20 | #include "radeon_hd.h" |
21 | 21 | |
22 | 22 | |
23 | | #define MAX_DISPLAY 2 |
24 | | // Maximum displays (more then two requires AtomBIOS) |
| 23 | #define MAX_DISPLAY 1 |
| 24 | // Maximum displays |
25 | 25 | |
26 | 26 | |
27 | 27 | struct gpu_state { |
diff --git a/src/add-ons/accelerants/radeon_hd/mode.cpp b/src/add-ons/accelerants/radeon_hd/mode.cpp
index 30db993..88e02d7 100644
a
|
b
|
extern "C" void _sPrintf(const char* format, ...);
|
43 | 43 | status_t |
44 | 44 | create_mode_list(void) |
45 | 45 | { |
46 | | // TODO: multi-monitor? for now we use VESA and not gDisplay edid |
| 46 | // TODO: Argh! Which display? :) |
| 47 | uint8_t crtc = 0; |
47 | 48 | |
48 | | const color_space kRadeonHDSpaces[] = {B_RGB32_LITTLE, B_RGB24_LITTLE, |
49 | | B_RGB16_LITTLE, B_RGB15_LITTLE, B_CMAP8}; |
| 49 | const color_space kRadeonHDSpaces[] = {B_RGB32_LITTLE}; |
| 50 | // TODO: B_RGB24_LITTLE, B_RGB16_LITTLE, B_RGB15_LITTLE, B_CMAP8 working |
50 | 51 | |
| 52 | // &gInfo->shared_info->edid_info is VESA |
51 | 53 | gInfo->mode_list_area = create_display_modes("radeon HD modes", |
52 | | gInfo->shared_info->has_edid ? &gInfo->shared_info->edid_info : NULL, |
| 54 | gInfo->shared_info->has_edid ? &gDisplay[crtc]->edid_info : NULL, |
53 | 55 | NULL, 0, kRadeonHDSpaces, |
54 | 56 | sizeof(kRadeonHDSpaces) / sizeof(kRadeonHDSpaces[0]), |
55 | 57 | is_mode_supported, &gInfo->mode_list, &gInfo->shared_info->mode_count); |
… |
… |
radeon_get_preferred_mode(display_mode* preferredMode)
|
108 | 110 | status_t |
109 | 111 | radeon_get_edid_info(void* info, size_t size, uint32* edid_version) |
110 | 112 | { |
111 | | // TODO: multi-monitor? for now we use VESA edid |
| 113 | // TODO: Argh! Which display? :) |
| 114 | uint8_t crtc = 0; |
112 | 115 | |
113 | 116 | TRACE("%s\n", __func__); |
114 | 117 | if (!gInfo->shared_info->has_edid) |
… |
… |
radeon_get_edid_info(void* info, size_t size, uint32* edid_version)
|
116 | 119 | if (size < sizeof(struct edid1_info)) |
117 | 120 | return B_BUFFER_OVERFLOW; |
118 | 121 | |
119 | | memcpy(info, &gInfo->shared_info->edid_info, sizeof(struct edid1_info)); |
| 122 | //memcpy(info, &gInfo->shared_info->edid_info, sizeof(struct edid1_info)); |
120 | 123 | // VESA |
121 | | //memcpy(info, &gDisplay[0]->edid_info, sizeof(struct edid1_info)); |
| 124 | memcpy(info, &gDisplay[crtc]->edid_info, sizeof(struct edid1_info)); |
122 | 125 | // BitBanged display 0 |
123 | 126 | |
124 | 127 | *edid_version = EDID_VERSION_1; |
… |
… |
is_mode_supported(display_mode* mode)
|
301 | 304 | if (is_mode_sane(mode) != B_OK) |
302 | 305 | sane = false; |
303 | 306 | |
304 | | // TODO: is_mode_supported on *which* display? |
305 | | uint32 crtid = 0; |
| 307 | // TODO: Argh! Which display? :) |
| 308 | uint8_t crtc = 0; |
306 | 309 | |
307 | 310 | // if we have edid info, check frequency adginst crt reported valid ranges |
308 | 311 | if (gInfo->shared_info->has_edid |
309 | | && gDisplay[crtid]->found_ranges) { |
| 312 | && gDisplay[crtc]->found_ranges) { |
310 | 313 | |
311 | 314 | // validate horizontal frequency range |
312 | 315 | uint32 hfreq = mode->timing.pixel_clock / mode->timing.h_total; |
313 | | if (hfreq > gDisplay[crtid]->hfreq_max + 1 |
314 | | || hfreq < gDisplay[crtid]->hfreq_min - 1) { |
| 316 | if (hfreq > gDisplay[crtc]->hfreq_max + 1 |
| 317 | || hfreq < gDisplay[crtc]->hfreq_min - 1) { |
315 | 318 | //TRACE("!!! mode below falls outside of hfreq range!\n"); |
316 | 319 | sane = false; |
317 | 320 | } |
… |
… |
is_mode_supported(display_mode* mode)
|
319 | 322 | // validate vertical frequency range |
320 | 323 | uint32 vfreq = mode->timing.pixel_clock / ((mode->timing.v_total |
321 | 324 | * mode->timing.h_total) / 1000); |
322 | | if (vfreq > gDisplay[crtid]->vfreq_max + 1 |
323 | | || vfreq < gDisplay[crtid]->vfreq_min - 1) { |
| 325 | if (vfreq > gDisplay[crtc]->vfreq_max + 1 |
| 326 | || vfreq < gDisplay[crtc]->vfreq_min - 1) { |
324 | 327 | //TRACE("!!! mode below falls outside of vfreq range!\n"); |
325 | 328 | sane = false; |
326 | 329 | } |