xref: /haiku/src/add-ons/accelerants/common/dump_edid.c (revision 1acbe440b8dd798953bec31d18ee589aa3f71b73)
1 /*
2  * Copyright 2003, Thomas Kurschel. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 /*!
7 	Part of DDC driver
8 	Dumps EDID content
9 */
10 
11 #include "edid.h"
12 #if !defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
13 #	include "ddc_int.h"
14 #endif
15 
16 #include <KernelExport.h>
17 
18 #include <stdio.h>
19 
20 
21 void
22 edid_dump(edid1_info *edid)
23 {
24 	int i, j;
25 
26 	dprintf("Vendor: %s\n", edid->vendor.manufacturer);
27 	dprintf("Product ID: %d\n", (int)edid->vendor.prod_id);
28 	dprintf("Serial #: %d\n", (int)edid->vendor.serial);
29 	dprintf("Produced in week/year: %d/%d\n", edid->vendor.week, edid->vendor.year);
30 
31 	dprintf("EDID version: %d.%d\n", edid->version.version, edid->version.revision);
32 
33 	dprintf("Type: %s\n", edid->display.input_type ? "Digital" : "Analog");
34 	dprintf("Size: %d cm x %d cm\n", edid->display.h_size, edid->display.v_size);
35 	dprintf("Gamma=%.3f\n", (edid->display.gamma + 100) / 100.0);
36 	dprintf("White (X,Y)=(%.3f,%.3f)\n", edid->display.white_x / 1024.0,
37 		edid->display.white_y / 1024.0);
38 
39 	dprintf("Supported Future Video Modes:\n");
40 	for (i = 0; i < EDID1_NUM_STD_TIMING; ++i) {
41 		if (edid->std_timing[i].h_size <= 256)
42 			continue;
43 
44 		dprintf("%dx%d@%dHz (id=%d)\n",
45 			edid->std_timing[i].h_size, edid->std_timing[i].v_size,
46 			edid->std_timing[i].refresh, edid->std_timing[i].id);
47 	}
48 
49 	dprintf("Supported VESA Video Modes:\n");
50 	if (edid->established_timing.res_720x400x70)
51 		dprintf("720x400@70\n");
52 	if (edid->established_timing.res_720x400x88)
53 		dprintf("720x400@88\n");
54 	if (edid->established_timing.res_640x480x60)
55 		dprintf("640x480@60\n");
56 	if (edid->established_timing.res_640x480x67)
57 		dprintf("640x480x67\n");
58 	if (edid->established_timing.res_640x480x72)
59 		dprintf("640x480x72\n");
60 	if (edid->established_timing.res_640x480x75)
61 		dprintf("640x480x75\n");
62 	if (edid->established_timing.res_800x600x56)
63 		dprintf("800x600@56\n");
64 	if (edid->established_timing.res_800x600x60)
65 		dprintf("800x600@60\n");
66 
67 	if (edid->established_timing.res_800x600x72)
68 		dprintf("800x600@72\n");
69 	if (edid->established_timing.res_800x600x75)
70 		dprintf("800x600@75\n");
71 	if (edid->established_timing.res_832x624x75)
72 		dprintf("832x624@75\n");
73 	if (edid->established_timing.res_1024x768x87i)
74 		dprintf("1024x768@87 interlaced\n");
75 	if (edid->established_timing.res_1024x768x60)
76 		dprintf("1024x768@60\n");
77 	if (edid->established_timing.res_1024x768x70)
78 		dprintf("1024x768@70\n");
79 	if (edid->established_timing.res_1024x768x75)
80 		dprintf("1024x768@75\n");
81 	if (edid->established_timing.res_1280x1024x75)
82 		dprintf("1280x1024@75\n");
83 
84 	if (edid->established_timing.res_1152x870x75)
85 		dprintf("1152x870@75\n");
86 
87 	for (i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) {
88 		edid1_detailed_monitor *monitor = &edid->detailed_monitor[i];
89 
90 		switch(monitor->monitor_desc_type) {
91 			case edid1_serial_number:
92 				dprintf("Serial Number: %s\n", monitor->data.serial_number);
93 				break;
94 			case edid1_ascii_data:
95 				dprintf(" %s\n", monitor->data.serial_number);
96 				break;
97 			case edid1_monitor_ranges: {
98 				edid1_monitor_range monitor_range = monitor->data.monitor_range;
99 
100 				dprintf("Horizontal frequency range = %d..%d kHz\n",
101 					monitor_range.min_h, monitor_range.max_h);
102 				dprintf("Vertical frequency range = %d..%d Hz\n",
103 					monitor_range.min_v, monitor_range.max_v);
104 				dprintf("Maximum pixel clock = %d MHz\n", (uint16)monitor_range.max_clock * 10);
105 				break;
106 			}
107 			case edid1_monitor_name:
108 				dprintf("Monitor Name: %s\n", monitor->data.serial_number);
109 				break;
110 			case edid1_add_colour_pointer: {
111 				for (j = 0; j < EDID1_NUM_EXTRA_WHITEPOINTS; ++j) {
112 					edid1_whitepoint *whitepoint = &monitor->data.whitepoint[j];
113 
114 					if (whitepoint->index == 0)
115 						continue;
116 
117 					dprintf("Additional whitepoint: (X,Y)=(%f,%f) gamma=%f index=%i\n",
118 						whitepoint->white_x / 1024.0,
119 						whitepoint->white_y / 1024.0,
120 						(whitepoint->gamma + 100) / 100.0,
121 						whitepoint->index);
122 				}
123 				break;
124 			}
125 			case edid1_add_std_timing: {
126 				for (j = 0; j < EDID1_NUM_EXTRA_STD_TIMING; ++j) {
127 					edid1_std_timing *timing = &monitor->data.std_timing[j];
128 
129 					if (timing->h_size <= 256)
130 						continue;
131 
132 					dprintf("%dx%d@%dHz (id=%d)\n",
133 						timing->h_size, timing->v_size,
134 						timing->refresh, timing->id);
135 				}
136 				break;
137 			}
138 			case edid1_is_detailed_timing: {
139 				edid1_detailed_timing *timing = &monitor->data.detailed_timing;
140 
141 				dprintf("Additional Video Mode:\n");
142 				dprintf("clock=%f MHz\n", timing->pixel_clock / 100.0);
143 				dprintf("h: (%d, %d, %d, %d)\n",
144 					timing->h_active, timing->h_active + timing->h_sync_off,
145 					timing->h_active + timing->h_sync_off + timing->h_sync_width,
146 					timing->h_active + timing->h_blank);
147 				dprintf("v: (%d, %d, %d, %d)\n",
148 					timing->v_active, timing->v_active + timing->v_sync_off,
149 					timing->v_active + timing->v_sync_off + timing->v_sync_width,
150 					timing->v_active + timing->v_blank);
151 				dprintf("size: %.1f cm x %.1f cm\n",
152 					timing->h_size / 10.0, timing->v_size / 10.0);
153 				dprintf("border: %.1f cm x %.1f cm\n",
154 					timing->h_border / 10.0, timing->v_border / 10.0);
155 				break;
156 			}
157 		}
158 	}
159 }
160