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