Ticket #3850: vesa_edi_wip.patch
File vesa_edi_wip.patch, 12.5 KB (added by , 16 years ago) |
---|
-
src/add-ons/accelerants/common/create_display_modes.cpp
12 12 13 13 #include <video_overlay.h> 14 14 15 #if !defined(_KERNEL_MODE) && !defined(_BOOT_MODE) 16 #define dprintf _sPrintf 17 extern "C" void _sPrintf(const char *format, ...); 18 #endif 15 19 16 20 #define POSITIVE_SYNC \ 17 21 (B_POSITIVE_HSYNC | B_POSITIVE_VSYNC) … … 83 87 ModeList(); 84 88 ~ModeList(); 85 89 86 bool AddModes( edid1_info* info);90 bool AddModes(const edid1_info* info); 87 91 bool AddModes(const display_mode* modes, uint32 count); 88 92 89 93 bool CreateColorSpaces(const color_space* spaces, uint32 count); … … 97 101 bool _MakeSpace(uint32 count); 98 102 bool _AddMode(const display_mode* mode); 99 103 void _RemoveModeAt(uint32 index); 100 void _AddBaseMode(uint16 width, uint16 height, uint32 refresh); 104 bool _IsEstablishedMode(const display_mode& mode, const edid1_established_timing timings); 105 bool _IsStandardMode(const display_mode& mode, const edid1_info* info); 106 bool _IsModeInRange(const display_mode& mode, const edid1_info* info); 101 107 108 bool _ModeMatches(const display_mode& mode, uint16 width, uint16 height, uint32 refresh); 109 102 110 display_mode* fModes; 103 111 uint32 fCount; 104 112 uint32 fCapacity; … … 108 116 109 117 using namespace BPrivate; 110 118 111 112 119 static float 113 120 get_refresh_rate(const display_mode& mode) 114 121 { … … 159 166 free(fModes); 160 167 } 161 168 162 163 169 bool 164 ModeList::AddModes( edid1_info* info)170 ModeList::AddModes(const edid1_info* info) 165 171 { 166 if (info->established_timing.res_720x400x70) 167 _AddBaseMode(720, 400, 70); 168 if (info->established_timing.res_720x400x88) 169 _AddBaseMode(720, 400, 88); 172 for (uint32 mIndex = 0; mIndex < kNumBaseModes; mIndex++) { 173 const display_mode& mode = kBaseModeList[mIndex]; 170 174 171 if (info->established_timing.res_640x480x60) 172 _AddBaseMode(640, 480, 60); 173 if (info->established_timing.res_640x480x67) 174 _AddBaseMode(640, 480, 67); 175 if (info->established_timing.res_640x480x72) 176 _AddBaseMode(640, 480, 72); 177 if (info->established_timing.res_640x480x75) 178 _AddBaseMode(640, 480, 75); 179 180 if (info->established_timing.res_800x600x56) 181 _AddBaseMode(800, 600, 56); 182 if (info->established_timing.res_800x600x60) 183 _AddBaseMode(800, 600, 60); 184 if (info->established_timing.res_800x600x72) 185 _AddBaseMode(800, 600, 72); 186 if (info->established_timing.res_800x600x75) 187 _AddBaseMode(800, 600, 75); 188 189 #if 0 190 if (info->established_timing.res_832x624x75) 191 _AddBaseMode(832, 624, 75); 192 193 if (info->established_timing.res_1024x768x87i) 194 _AddBaseMode(1024, 768, 87); 195 #endif 196 if (info->established_timing.res_1024x768x60) 197 _AddBaseMode(1024, 768, 60); 198 if (info->established_timing.res_1024x768x70) 199 _AddBaseMode(1024, 768, 70); 200 if (info->established_timing.res_1024x768x75) 201 _AddBaseMode(1024, 768, 75); 202 203 if (info->established_timing.res_1152x870x75) 204 _AddBaseMode(1152, 870, 75); 205 if (info->established_timing.res_1280x1024x75) 206 _AddBaseMode(1280, 1024, 75); 207 208 for (uint32 i = 0; i < EDID1_NUM_STD_TIMING; ++i) { 209 if (info->std_timing[i].h_size <= 256) 210 continue; 211 212 _AddBaseMode(info->std_timing[i].h_size, info->std_timing[i].v_size, 213 info->std_timing[i].refresh); 214 } 215 175 if (_IsEstablishedMode(mode, info->established_timing) || 176 _IsStandardMode(mode, info) || 177 _IsModeInRange(mode, info)) 178 _AddMode(&mode); 179 else 180 dprintf("Mode not EDI compatible %dx%d@%fHz\n", 181 mode.timing.h_display, mode.timing.v_display, 182 get_refresh_rate(mode)); 183 } 184 216 185 for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { 217 186 if (info->detailed_monitor[i].monitor_desc_type 218 187 != EDID1_IS_DETAILED_TIMING) … … 253 222 254 223 _AddMode(&mode); 255 224 } 256 257 // TODO: add other modes from the base list that satisfy the display's 258 // requirements! 259 225 260 226 return true; 261 227 } 262 228 … … 319 285 } 320 286 } 321 287 288 bool 289 ModeList::_IsEstablishedMode(const display_mode& mode, edid1_established_timing timings) 290 { 291 return (timings.res_720x400x70 && _ModeMatches(mode, 720, 400, 70)) || 292 (timings.res_720x400x88 && _ModeMatches(mode, 720, 400, 88)) || 293 (timings.res_640x480x60 && _ModeMatches(mode, 640, 480, 60)) || 294 (timings.res_640x480x67 && _ModeMatches(mode, 640, 480, 67)) || 295 (timings.res_640x480x72 && _ModeMatches(mode, 640, 480, 72)) || 296 (timings.res_640x480x75 && _ModeMatches(mode, 640, 480, 75)) || 297 (timings.res_800x600x56 && _ModeMatches(mode, 800, 600, 56)) || 298 (timings.res_800x600x60 && _ModeMatches(mode, 800, 600, 60)) || 299 (timings.res_800x600x72 && _ModeMatches(mode, 800, 600, 72)) || 300 (timings.res_800x600x75 && _ModeMatches(mode, 800, 600, 75)) || 301 #if 0 302 (timings.res_832x624x75 && _ModeMatches(mode, 832, 624, 75)) || 303 (timings.res_1024x768x87i && _ModeMatches(mode, 1024, 768, 87)) || 304 #endif 305 (timings.res_1024x768x60 && _ModeMatches(mode, 1024, 768, 60)) || 306 (timings.res_1024x768x70 && _ModeMatches(mode, 1024, 768, 70)) || 307 (timings.res_1024x768x75 && _ModeMatches(mode, 1024, 768, 75)) || 308 (timings.res_1152x870x75 && _ModeMatches(mode, 1152, 870, 75)) || 309 (timings.res_1280x1024x75 && _ModeMatches(mode, 1280, 1024, 75)); 310 } 322 311 323 void 324 ModeList::_AddBaseMode(uint16 width, uint16 height, uint32 refresh) 312 bool 313 ModeList::_ModeMatches(const display_mode& mode, uint16 width, 314 uint16 height, uint32 refresh) 325 315 { 326 for (uint32 i = 0; i < kNumBaseModes; i++) { 327 const display_mode& mode = kBaseModeList[i]; 316 // Add mode if width and height match, and the computed refresh rate of 317 // the mode is within 1.2 percent of the refresh rate specified by the 318 // caller. Note that refresh rates computed from mode parameters is 319 // not exact; thus, the tolerance of 1.2% was obtained by testing the 320 // various established modes that can be selected by the EDID info. 328 321 329 // Add mode if width and height match, and the computed refresh rate of 330 // the mode is within 1.2 percent of the refresh rate specified by the 331 // caller. Note that refresh rates computed from mode parameters is 332 // not exact; thus, the tolerance of 1.2% was obtained by testing the 333 // various established modes that can be selected by the EDID info. 322 return mode.timing.h_display == width && mode.timing.v_display == height 323 && fabs(get_refresh_rate(mode) - refresh) < refresh * 0.012; 324 } 334 325 335 if (mode.timing.h_display == width && mode.timing.v_display == height 336 && fabs(get_refresh_rate(mode) - refresh) < refresh * 0.012) { 337 _AddMode(&mode); 338 } 326 bool 327 ModeList::_IsStandardMode(const display_mode& mode, const edid1_info* info) 328 { 329 for (uint32 i = 0; i < EDID1_NUM_STD_TIMING; ++i) { 330 const edid1_std_timing std_timing = info->std_timing[i]; 331 if (std_timing.h_size <= 256) 332 continue; 333 if (_ModeMatches(mode, std_timing.h_size, std_timing.v_size, 334 std_timing.refresh)) 335 return true; 339 336 } 337 return false; 340 338 } 341 339 340 bool 341 ModeList::_IsModeInRange(const display_mode& mode, const edid1_info* info) 342 { 343 // As far as I understand: 344 // vertical_freq = pixelclk / (htot * vtot) 345 // hfreq = pixelclk / htot 346 // => hfreq = vertical_freq * vtot 342 347 348 float vertical_freq = get_refresh_rate(mode); 349 //Since EDI uses kHz we do too. 350 float horizontal_freq_kHz = vertical_freq * mode.timing.v_total / 1000; 351 dprintf("Vertical freq: %fHz, Horizontal freq: %fkHz, Pixel clock %dkHz\n", 352 vertical_freq, horizontal_freq_kHz, mode.timing.pixel_clock); 353 for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { 354 if (info->detailed_monitor[i].monitor_desc_type != EDID1_MONITOR_RANGES) 355 continue; 356 const edid1_monitor_range& monitor_range 357 = info->detailed_monitor[i].data.monitor_range; 358 359 if (mode.timing.pixel_clock <= monitor_range.max_clock * 10000 && 360 vertical_freq >= monitor_range.min_v && 361 vertical_freq <= monitor_range.max_v && 362 horizontal_freq_kHz >= monitor_range.min_h && 363 horizontal_freq_kHz <= monitor_range.max_h ) 364 return true; 365 } 366 return false; 367 } 368 369 343 370 bool 344 371 ModeList::_MakeSpace(uint32 count) 345 372 { … … 361 388 bool 362 389 ModeList::_AddMode(const display_mode* mode) 363 390 { 364 if (!_MakeSpace(1)) 391 if (!_MakeSpace(1)) { 392 dprintf("Failed to add mode, no space: %dx%d@%fHz\n", mode->timing.h_display, 393 mode->timing.v_display, get_refresh_rate(*mode)); 365 394 return false; 395 } 396 dprintf("Mode added: %dx%d@%fHz\n", mode->timing.h_display, 397 mode->timing.v_display, get_refresh_rate(*mode)); 366 398 367 399 fModes[fCount++] = *mode; 368 400 return true; … … 372 404 void 373 405 ModeList::_RemoveModeAt(uint32 index) 374 406 { 407 dprintf("Removing mode: %dx%d@%fHz\n", fModes[index].timing.h_display, 408 fModes[index].timing.v_display, get_refresh_rate(fModes[index])); 375 409 if (index < fCount - 1) { 376 410 memmove(&fModes[index], &fModes[index + 1], 377 411 (fCount - 1 - index) * sizeof(display_mode)); -
src/add-ons/accelerants/common/dump_edid.c
50 50 51 51 dprintf("Supported VESA Video Modes:\n"); 52 52 if (edid->established_timing.res_720x400x70) 53 dprintf("720x400@70 \n");53 dprintf("720x400@70Hz\n"); 54 54 if (edid->established_timing.res_720x400x88) 55 dprintf("720x400@88 \n");55 dprintf("720x400@88Hz\n"); 56 56 if (edid->established_timing.res_640x480x60) 57 dprintf("640x480@60 \n");57 dprintf("640x480@60Hz\n"); 58 58 if (edid->established_timing.res_640x480x67) 59 dprintf("640x480x67 \n");59 dprintf("640x480x67Hz\n"); 60 60 if (edid->established_timing.res_640x480x72) 61 dprintf("640x480x72 \n");61 dprintf("640x480x72Hz\n"); 62 62 if (edid->established_timing.res_640x480x75) 63 dprintf("640x480x75 \n");63 dprintf("640x480x75Hz\n"); 64 64 if (edid->established_timing.res_800x600x56) 65 dprintf("800x600@56 \n");65 dprintf("800x600@56Hz\n"); 66 66 if (edid->established_timing.res_800x600x60) 67 dprintf("800x600@60 \n");67 dprintf("800x600@60Hz\n"); 68 68 69 69 if (edid->established_timing.res_800x600x72) 70 dprintf("800x600@72 \n");70 dprintf("800x600@72Hz\n"); 71 71 if (edid->established_timing.res_800x600x75) 72 dprintf("800x600@75 \n");72 dprintf("800x600@75Hz\n"); 73 73 if (edid->established_timing.res_832x624x75) 74 dprintf("832x624@75 \n");74 dprintf("832x624@75Hz\n"); 75 75 if (edid->established_timing.res_1024x768x87i) 76 dprintf("1024x768@87 interlaced\n");76 dprintf("1024x768@87Hz interlaced\n"); 77 77 if (edid->established_timing.res_1024x768x60) 78 dprintf("1024x768@60 \n");78 dprintf("1024x768@60Hz\n"); 79 79 if (edid->established_timing.res_1024x768x70) 80 dprintf("1024x768@70 \n");80 dprintf("1024x768@70Hz\n"); 81 81 if (edid->established_timing.res_1024x768x75) 82 dprintf("1024x768@75 \n");82 dprintf("1024x768@75Hz\n"); 83 83 if (edid->established_timing.res_1280x1024x75) 84 dprintf("1280x1024@75 \n");84 dprintf("1280x1024@75Hz\n"); 85 85 86 86 if (edid->established_timing.res_1152x870x75) 87 dprintf("1152x870@75 \n");87 dprintf("1152x870@75Hz\n"); 88 88 89 89 for (i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { 90 90 edid1_detailed_monitor *monitor = &edid->detailed_monitor[i]; … … 149 149 case EDID1_IS_DETAILED_TIMING: 150 150 { 151 151 edid1_detailed_timing *timing = &monitor->data.detailed_timing; 152 dprintf("Additional Video Mode (%dx%d@%dHz):\n", 153 timing->h_active, timing->v_active, 154 (timing->pixel_clock * 10000 155 / (timing->h_active + timing->h_blank) 156 / (timing->v_active + timing->v_blank))); 157 //Refreshrate = pixel clock in Hz / Htotal / Vtotal 152 158 153 dprintf("Additional Video Mode:\n");154 159 dprintf("clock=%f MHz\n", timing->pixel_clock / 100.0); 155 160 dprintf("h: (%d, %d, %d, %d)\n", 156 161 timing->h_active, timing->h_active + timing->h_sync_off, -
src/add-ons/accelerants/vesa/mode.cpp
73 73 const color_space kVesaSpaces[] = {B_RGB32_LITTLE, B_RGB24_LITTLE, 74 74 B_RGB16_LITTLE, B_RGB15_LITTLE, B_CMAP8}; 75 75 76 gInfo->mode_list_area = create_display_modes("vesa modes", NULL, NULL, 0, 76 // gInfo->mode_list_area = create_display_modes("vesa modes", NULL, NULL, 0, 77 gInfo->mode_list_area = create_display_modes("vesa modes", &(gInfo->shared_info->edid_info), NULL, 0, 77 78 kVesaSpaces, sizeof(kVesaSpaces) / sizeof(kVesaSpaces[0]), 78 79 is_mode_supported, &gInfo->mode_list, &gInfo->shared_info->mode_count); 79 80 if (gInfo->mode_list_area < B_OK) … … 164 165 status_t 165 166 vesa_get_edid_info(void *info, size_t size, uint32 *_version) 166 167 { 167 TRACE((" intel_get_edid_info()\n"));168 TRACE(("vesa_get_edid_info()\n")); 168 169 169 170 if (!gInfo->shared_info->has_edid) 170 171 return B_ERROR;