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