Changeset 24959

Show
Ignore:
Timestamp:
04/13/08 06:58:30 (7 months ago)
Author:
axeld
Message:

Committed patch by Gerald Zajac, thanks!:
* Enabled testing the checksum of the EDID info.
* Added a version check of the EDID info.
* Added more debug output.
* In the ModeList class, changes were made to how the refresh rate is

computed and used. Previously, some of the basic VESA modes were not
added to the mode list because the computed and specified refresh rates
did not exactly match. Now if the computed refresh rate is within 1.2%
of the specified rate, the mode is added. With this change, all basic
VESA modes selected by the EDID info are now added to the mode list.

* The "additional video modes" shown in the EDID dump are now added to

the mode list. Previously, this mode data was setup but not added to
the mode list. Code was also added here to set the vertical &
horizontal sync polarity according the EDID info. The sync polarities
are set according to a VESA document that I have.

* Fixed copy_str() warning, broken removal of trailing spaces, and null

termination.

Location:
haiku/trunk/src/add-ons/accelerants/common
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp

    r24638 r24959  
    113113get_refresh_rate(const display_mode& mode) 
    114114{ 
    115         // we have to be catious as refresh rate cannot be controlled directly, 
    116         // so it suffers under rounding errors and hardware restrictions 
    117         return rint(10 * float(mode.timing.pixel_clock * 1000) /  
    118                 float(mode.timing.h_total * mode.timing.v_total)) / 10.0; 
     115        return float(mode.timing.pixel_clock * 1000) /  
     116                float(mode.timing.h_total * mode.timing.v_total); 
    119117} 
    120118 
     
    141139                return mode1->space - mode2->space; 
    142140 
    143         return (int)(10 * get_refresh_rate(*mode1) 
    144                 -  10 * get_refresh_rate(*mode2)); 
     141        return (int)(100 * (get_refresh_rate(*mode1) - get_refresh_rate(*mode2))); 
    145142} 
    146143 
     
    221218                        continue; 
    222219 
    223                 // TODO: handle sync and flags correctly! 
     220                // TODO: handle flags correctly! 
    224221                const edid1_detailed_timing& timing = info->detailed_monitor[i].data.detailed_timing; 
    225222                display_mode mode; 
     223                 
     224                if (timing.pixel_clock <= 0 || timing.sync != 3) 
     225                        continue; 
     226                         
    226227                mode.timing.pixel_clock = timing.pixel_clock * 10; 
    227228                mode.timing.h_display = timing.h_active; 
     
    233234                mode.timing.v_sync_end = mode.timing.v_sync_start + timing.v_sync_width; 
    234235                mode.timing.v_total = timing.v_active + timing.v_blank; 
    235                 mode.timing.flags = POSITIVE_SYNC; 
     236                mode.timing.flags = 0; 
     237                if (timing.sync == 3) { 
     238                        if (timing.misc & 1) 
     239                                mode.timing.flags |= B_POSITIVE_HSYNC; 
     240                        if (timing.misc & 2) 
     241                                mode.timing.flags |= B_POSITIVE_VSYNC; 
     242                } 
    236243                if (timing.interlaced) 
    237244                        mode.timing.flags |= B_TIMING_INTERLACED; 
     
    242249                mode.v_display_start = 0; 
    243250                mode.flags = MODE_FLAGS; 
     251                 
     252                _AddMode(&mode); 
    244253        } 
    245254         
     
    316325                const display_mode& mode = kBaseModeList[i]; 
    317326 
     327                // Add mode if width and height match, and the computed refresh rate of 
     328                // the mode is within 1.2 percent of the refresh rate specified by the 
     329                // caller.  Note that refresh rates computed from mode parameters is 
     330                // not exact;  thus, the tolerance of 1.2% was obtained by testing the 
     331                // various established modes that can be selected by the EDID info. 
     332                 
    318333                if (mode.timing.h_display == width && mode.timing.v_display == height 
    319                         && get_refresh_rate(mode) == refresh) { 
     334                        && fabs(get_refresh_rate(mode) - refresh) < refresh * 0.012) { 
    320335                        _AddMode(&mode); 
    321                         return; 
    322336                } 
    323337        } 
  • haiku/trunk/src/add-ons/accelerants/common/ddc.c

    r22270 r24959  
    44 */ 
    55 
    6 /*! 
    7         DDC communication 
    8 */ 
     6/*!     DDC communication */ 
    97 
    108 
     
    1917 
    2018 
    21 #define READ_RETRIES 4 
    22         // number of retries to read ddc data 
     19#define READ_RETRIES 4          // number of retries to read ddc data 
    2320 
    24 #if 0 
    25 /*!     Verify checksum of ddc data 
    26         (some monitors have a broken checksum - bad luck for them) 
    27 */ 
     21 
     22#define TRACE_DDC 
     23#ifdef TRACE_DDC 
     24extern void _sPrintf(const char* format, ...); 
     25#       define TRACE(x...) _sPrintf("DDC: " x) 
     26#else 
     27#       define TRACE(x...) ; 
     28#endif 
     29 
     30 
     31 
     32//! Verify checksum of DDC data. 
    2833static status_t 
    2934verify_checksum(const uint8 *data, size_t len) 
     
    3136        uint32 index; 
    3237        uint8 sum = 0; 
    33         uint8 all_or = 0; 
    34          
     38        uint8 allOr = 0; 
     39 
    3540        for (index = 0; index < len; ++index, ++data) { 
    3641                sum += *data; 
    37                 all_or |= *data; 
     42                allOr |= *data; 
    3843        } 
    39          
    40         if (all_or == 0) { 
    41                 SHOW_ERROR0(2, "DDC information contains zeros only"); 
     44 
     45        if (allOr == 0) { 
     46                TRACE("verify_checksum() DDC information contains zeros only\n"); 
    4247                return B_ERROR; 
    4348        } 
    44          
     49 
    4550        if (sum != 0) { 
    46                 SHOW_ERROR0(2, "Checksum error of DDC information"); 
     51                TRACE("verify_checksum() Checksum error in DDC information\n"); 
    4752                return B_IO_ERROR; 
    4853        } 
    49                  
     54 
    5055        return B_OK; 
    5156} 
    52 #endif 
    5357 
    5458 
     
    6771                status = i2c_send_receive(bus, 0xa0, writeBuffer, 
    6872                        start < 0x100 ? 1 : 2, buffer, length); 
    69                 // don't verify checksum - it's often broken 
    70                 if (status == B_OK /*&& verify_checksum( buffer, len ) == B_OK*/) 
    71                         break; 
    7273 
    73                 status = B_ERROR; 
     74                if (status != B_OK) 
     75                        TRACE("ddc2_read(): DDC information read failure\n"); 
     76 
     77                if (status == B_OK) { 
     78                        status = verify_checksum(buffer, length); 
     79                        if (status == B_OK) 
     80                                break; 
     81 
     82                        dprintf("DDC checksum incorrect!\n"); 
     83                } 
    7484        } 
    7585 
     
    122132 
    123133 
     134//      #pragma mark - 
     135 
     136 
    124137void 
    125138ddc2_init_timing(i2c_bus *bus) 
     
    146159                return status; 
    147160 
     161        if (raw.version.version != 1 || raw.version.revision > 4) { 
     162                TRACE("ddc2_read_edid1() EDID version or revision out of range\n"); 
     163                return B_ERROR; 
     164        } 
     165 
    148166        edid_decode(edid, &raw); 
    149167 
  • haiku/trunk/src/add-ons/accelerants/common/decode_edid.c

    r22516 r24959  
    156156 
    157157        // copy until 0xa 
    158         for (i = 0; i < len; ++i) { 
     158        for (i = 0; i < len; i++) { 
    159159                if (*src == 0xa) 
    160160                        break; 
     
    164164 
    165165        // remove trailing spaces 
    166         for (i = i - 1; i >= 0; --i) { 
    167                 if (*dest-- != ' ') 
    168                         break; 
    169         } 
    170  
    171         *++dest = 0; 
     166        while (i-- > 0) { 
     167                if (*(dest - 1) != ' ') 
     168                        break; 
     169 
     170                dest--; 
     171        } 
     172 
     173        *dest = '\0'; 
    172174} 
    173175