Ticket #5722: 0001-radeon_hd-Reduce-risk-of-edge-case-failure.patch

File 0001-radeon_hd-Reduce-risk-of-edge-case-failure.patch, 4.2 KB (added by Disreali, 12 years ago)

adding alex's edgecase patch

  • src/add-ons/accelerants/radeon_hd/accelerant.h

    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  
    2020#include "radeon_hd.h"
    2121
    2222
    23 #define MAX_DISPLAY 2
    24     // Maximum displays (more then two requires AtomBIOS)
     23#define MAX_DISPLAY 1
     24    // Maximum displays
    2525
    2626
    2727struct gpu_state {
  • src/add-ons/accelerants/radeon_hd/mode.cpp

    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, ...);  
    4343status_t
    4444create_mode_list(void)
    4545{
    46     // TODO: multi-monitor?  for now we use VESA and not gDisplay edid
     46    // TODO: Argh!  Which display? :)
     47    uint8_t crtc = 0;
    4748
    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
    5051
     52    // &gInfo->shared_info->edid_info is VESA
    5153    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,
    5355        NULL, 0, kRadeonHDSpaces,
    5456        sizeof(kRadeonHDSpaces) / sizeof(kRadeonHDSpaces[0]),
    5557        is_mode_supported, &gInfo->mode_list, &gInfo->shared_info->mode_count);
    radeon_get_preferred_mode(display_mode* preferredMode)  
    108110status_t
    109111radeon_get_edid_info(void* info, size_t size, uint32* edid_version)
    110112{
    111     // TODO: multi-monitor?  for now we use VESA edid
     113    // TODO: Argh!  Which display? :)
     114    uint8_t crtc = 0;
    112115
    113116    TRACE("%s\n", __func__);
    114117    if (!gInfo->shared_info->has_edid)
    radeon_get_edid_info(void* info, size_t size, uint32* edid_version)  
    116119    if (size < sizeof(struct edid1_info))
    117120        return B_BUFFER_OVERFLOW;
    118121
    119     memcpy(info, &gInfo->shared_info->edid_info, sizeof(struct edid1_info));
     122    //memcpy(info, &gInfo->shared_info->edid_info, sizeof(struct edid1_info));
    120123        // VESA
    121     //memcpy(info, &gDisplay[0]->edid_info, sizeof(struct edid1_info));
     124    memcpy(info, &gDisplay[crtc]->edid_info, sizeof(struct edid1_info));
    122125        // BitBanged display 0
    123126
    124127    *edid_version = EDID_VERSION_1;
    is_mode_supported(display_mode* mode)  
    301304    if (is_mode_sane(mode) != B_OK)
    302305        sane = false;
    303306
    304     // TODO: is_mode_supported on *which* display?
    305     uint32 crtid = 0;
     307    // TODO: Argh!  Which display? :)
     308    uint8_t crtc = 0;
    306309
    307310    // if we have edid info, check frequency adginst crt reported valid ranges
    308311    if (gInfo->shared_info->has_edid
    309         && gDisplay[crtid]->found_ranges) {
     312        && gDisplay[crtc]->found_ranges) {
    310313
    311314        // validate horizontal frequency range
    312315        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) {
    315318            //TRACE("!!! mode below falls outside of hfreq range!\n");
    316319            sane = false;
    317320        }
    is_mode_supported(display_mode* mode)  
    319322        // validate vertical frequency range
    320323        uint32 vfreq = mode->timing.pixel_clock / ((mode->timing.v_total
    321324            * 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) {
    324327            //TRACE("!!! mode below falls outside of vfreq range!\n");
    325328            sane = false;
    326329        }