Changeset 24959
- Timestamp:
- 04/13/08 06:58:30 (7 months ago)
- Location:
- haiku/trunk/src/add-ons/accelerants/common
- Files:
-
- 3 modified
-
create_display_modes.cpp (modified) (6 diffs)
-
ddc.c (modified) (6 diffs)
-
decode_edid.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp
r24638 r24959 113 113 get_refresh_rate(const display_mode& mode) 114 114 { 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); 119 117 } 120 118 … … 141 139 return mode1->space - mode2->space; 142 140 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))); 145 142 } 146 143 … … 221 218 continue; 222 219 223 // TODO: handle sync andflags correctly!220 // TODO: handle flags correctly! 224 221 const edid1_detailed_timing& timing = info->detailed_monitor[i].data.detailed_timing; 225 222 display_mode mode; 223 224 if (timing.pixel_clock <= 0 || timing.sync != 3) 225 continue; 226 226 227 mode.timing.pixel_clock = timing.pixel_clock * 10; 227 228 mode.timing.h_display = timing.h_active; … … 233 234 mode.timing.v_sync_end = mode.timing.v_sync_start + timing.v_sync_width; 234 235 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 } 236 243 if (timing.interlaced) 237 244 mode.timing.flags |= B_TIMING_INTERLACED; … … 242 249 mode.v_display_start = 0; 243 250 mode.flags = MODE_FLAGS; 251 252 _AddMode(&mode); 244 253 } 245 254 … … 316 325 const display_mode& mode = kBaseModeList[i]; 317 326 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 318 333 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) { 320 335 _AddMode(&mode); 321 return;322 336 } 323 337 } -
haiku/trunk/src/add-ons/accelerants/common/ddc.c
r22270 r24959 4 4 */ 5 5 6 /*! 7 DDC communication 8 */ 6 /*! DDC communication */ 9 7 10 8 … … 19 17 20 18 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 23 20 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 24 extern 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. 28 33 static status_t 29 34 verify_checksum(const uint8 *data, size_t len) … … 31 36 uint32 index; 32 37 uint8 sum = 0; 33 uint8 all _or = 0;34 38 uint8 allOr = 0; 39 35 40 for (index = 0; index < len; ++index, ++data) { 36 41 sum += *data; 37 all _or |= *data;42 allOr |= *data; 38 43 } 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"); 42 47 return B_ERROR; 43 48 } 44 49 45 50 if (sum != 0) { 46 SHOW_ERROR0(2, "Checksum error of DDC information");51 TRACE("verify_checksum() Checksum error in DDC information\n"); 47 52 return B_IO_ERROR; 48 53 } 49 54 50 55 return B_OK; 51 56 } 52 #endif53 57 54 58 … … 67 71 status = i2c_send_receive(bus, 0xa0, writeBuffer, 68 72 start < 0x100 ? 1 : 2, buffer, length); 69 // don't verify checksum - it's often broken70 if (status == B_OK /*&& verify_checksum( buffer, len ) == B_OK*/)71 break;72 73 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 } 74 84 } 75 85 … … 122 132 123 133 134 // #pragma mark - 135 136 124 137 void 125 138 ddc2_init_timing(i2c_bus *bus) … … 146 159 return status; 147 160 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 148 166 edid_decode(edid, &raw); 149 167 -
haiku/trunk/src/add-ons/accelerants/common/decode_edid.c
r22516 r24959 156 156 157 157 // copy until 0xa 158 for (i = 0; i < len; ++i) {158 for (i = 0; i < len; i++) { 159 159 if (*src == 0xa) 160 160 break; … … 164 164 165 165 // 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'; 172 174 } 173 175
