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