SDL  2.0
edid-parse.c File Reference
#include "edid.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
+ Include dependency graph for edid-parse.c:

Go to the source code of this file.

Macros

#define TRUE   1
 
#define FALSE   0
 

Functions

static int get_bit (int in, int bit)
 
static int get_bits (int in, int begin, int end)
 
static int decode_header (const uchar *edid)
 
static int decode_vendor_and_product_identification (const uchar *edid, MonitorInfo *info)
 
static int decode_edid_version (const uchar *edid, MonitorInfo *info)
 
static int decode_display_parameters (const uchar *edid, MonitorInfo *info)
 
static double decode_fraction (int high, int low)
 
static int decode_color_characteristics (const uchar *edid, MonitorInfo *info)
 
static int decode_established_timings (const uchar *edid, MonitorInfo *info)
 
static int decode_standard_timings (const uchar *edid, MonitorInfo *info)
 
static void decode_lf_string (const uchar *s, int n_chars, char *result)
 
static void decode_display_descriptor (const uchar *desc, MonitorInfo *info)
 
static void decode_detailed_timing (const uchar *timing, DetailedTiming *detailed)
 
static int decode_descriptors (const uchar *edid, MonitorInfo *info)
 
static void decode_check_sum (const uchar *edid, MonitorInfo *info)
 
MonitorInfodecode_edid (const uchar *edid)
 
static const char * yesno (int v)
 
void dump_monitor_info (MonitorInfo *info)
 

Macro Definition Documentation

#define FALSE   0

Function Documentation

static void decode_check_sum ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 508 of file edid-parse.c.

References MonitorInfo::checksum, and i.

Referenced by decode_edid().

510 {
511  int i;
512  uchar check = 0;
513 
514  for (i = 0; i < 128; ++i)
515  check += edid[i];
516 
517  info->checksum = check;
518 }
int checksum
Definition: edid.h:82
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
unsigned char uchar
Definition: edid.h:1
static int decode_color_characteristics ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 256 of file edid-parse.c.

References MonitorInfo::blue_x, MonitorInfo::blue_y, decode_fraction(), get_bits(), MonitorInfo::green_x, MonitorInfo::green_y, MonitorInfo::red_x, MonitorInfo::red_y, TRUE, MonitorInfo::white_x, and MonitorInfo::white_y.

Referenced by decode_edid().

257 {
258  info->red_x = decode_fraction (edid[0x1b], get_bits (edid[0x19], 6, 7));
259  info->red_y = decode_fraction (edid[0x1c], get_bits (edid[0x19], 5, 4));
260  info->green_x = decode_fraction (edid[0x1d], get_bits (edid[0x19], 2, 3));
261  info->green_y = decode_fraction (edid[0x1e], get_bits (edid[0x19], 0, 1));
262  info->blue_x = decode_fraction (edid[0x1f], get_bits (edid[0x1a], 6, 7));
263  info->blue_y = decode_fraction (edid[0x20], get_bits (edid[0x1a], 4, 5));
264  info->white_x = decode_fraction (edid[0x21], get_bits (edid[0x1a], 2, 3));
265  info->white_y = decode_fraction (edid[0x22], get_bits (edid[0x1a], 0, 1));
266 
267  return TRUE;
268 }
double green_y
Definition: edid.h:140
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
double white_y
Definition: edid.h:144
double red_x
Definition: edid.h:137
double blue_x
Definition: edid.h:141
static double decode_fraction(int high, int low)
Definition: edid-parse.c:242
#define TRUE
Definition: edid-parse.c:31
double white_x
Definition: edid.h:143
double green_x
Definition: edid.h:139
double blue_y
Definition: edid.h:142
double red_y
Definition: edid.h:138
static int decode_descriptors ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 480 of file edid-parse.c.

References decode_detailed_timing(), decode_display_descriptor(), MonitorInfo::detailed_timings, i, MonitorInfo::n_detailed_timings, and TRUE.

Referenced by decode_edid().

481 {
482  int i;
483  int timing_idx;
484 
485  timing_idx = 0;
486 
487  for (i = 0; i < 4; ++i)
488  {
489  int index = 0x36 + i * 18;
490 
491  if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00)
492  {
493  decode_display_descriptor (edid + index, info);
494  }
495  else
496  {
498  edid + index, &(info->detailed_timings[timing_idx++]));
499  }
500  }
501 
502  info->n_detailed_timings = timing_idx;
503 
504  return TRUE;
505 }
int n_detailed_timings
Definition: edid.h:149
static void decode_detailed_timing(const uchar *timing, DetailedTiming *detailed)
Definition: edid-parse.c:417
static void decode_display_descriptor(const uchar *desc, MonitorInfo *info)
Definition: edid-parse.c:379
#define TRUE
Definition: edid-parse.c:31
GLuint index
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
DetailedTiming detailed_timings[4]
Definition: edid.h:150
static void decode_detailed_timing ( const uchar timing,
DetailedTiming detailed 
)
static

Definition at line 417 of file edid-parse.c.

References DetailedTiming::analog, DetailedTiming::digital, DetailedTiming::digital_sync, FALSE, FIELD_LEFT, FIELD_RIGHT, FOUR_WAY_INTERLEAVED, get_bit(), get_bits(), DetailedTiming::h_addr, DetailedTiming::h_blank, DetailedTiming::h_front_porch, DetailedTiming::h_sync, DetailedTiming::height_mm, DetailedTiming::interlaced, NO_STEREO, DetailedTiming::pixel_clock, DetailedTiming::right_border, SIDE_BY_SIDE, DetailedTiming::stereo, DetailedTiming::top_border, TWO_WAY_LEFT_ON_EVEN, TWO_WAY_RIGHT_ON_EVEN, DetailedTiming::v_addr, DetailedTiming::v_blank, DetailedTiming::v_front_porch, DetailedTiming::v_sync, and DetailedTiming::width_mm.

Referenced by decode_descriptors().

419 {
420  int bits;
421  StereoType stereo[] =
422  {
426  };
427 
428  detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000;
429  detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4);
430  detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8);
431  detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4);
432  detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8);
433  detailed->h_front_porch = timing[0x08] | get_bits (timing[0x0b], 6, 7) << 8;
434  detailed->h_sync = timing[0x09] | get_bits (timing[0x0b], 4, 5) << 8;
435  detailed->v_front_porch =
436  get_bits (timing[0x0a], 4, 7) | get_bits (timing[0x0b], 2, 3) << 4;
437  detailed->v_sync =
438  get_bits (timing[0x0a], 0, 3) | get_bits (timing[0x0b], 0, 1) << 4;
439  detailed->width_mm = timing[0x0c] | get_bits (timing[0x0e], 4, 7) << 8;
440  detailed->height_mm = timing[0x0d] | get_bits (timing[0x0e], 0, 3) << 8;
441  detailed->right_border = timing[0x0f];
442  detailed->top_border = timing[0x10];
443 
444  detailed->interlaced = get_bit (timing[0x11], 7);
445 
446  /* Stereo */
447  bits = get_bits (timing[0x11], 5, 6) << 1 | get_bit (timing[0x11], 0);
448  detailed->stereo = stereo[bits];
449 
450  /* Sync */
451  bits = timing[0x11];
452 
453  detailed->digital_sync = get_bit (bits, 4);
454  if (detailed->digital_sync)
455  {
456  detailed->digital.composite = !get_bit (bits, 3);
457 
458  if (detailed->digital.composite)
459  {
460  detailed->digital.serrations = get_bit (bits, 2);
461  detailed->digital.negative_vsync = FALSE;
462  }
463  else
464  {
465  detailed->digital.serrations = FALSE;
466  detailed->digital.negative_vsync = !get_bit (bits, 2);
467  }
468 
469  detailed->digital.negative_hsync = !get_bit (bits, 0);
470  }
471  else
472  {
473  detailed->analog.bipolar = get_bit (bits, 3);
474  detailed->analog.serrations = get_bit (bits, 2);
475  detailed->analog.sync_on_green = !get_bit (bits, 1);
476  }
477 }
int h_sync
Definition: edid.h:47
int h_front_porch
Definition: edid.h:48
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
int interlaced
Definition: edid.h:57
int height_mm
Definition: edid.h:54
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
int pixel_clock
Definition: edid.h:44
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
int digital_sync
Definition: edid.h:60
int top_border
Definition: edid.h:56
int right_border
Definition: edid.h:55
struct DetailedTiming::@30::@33 digital
int v_front_porch
Definition: edid.h:52
StereoType
Definition: edid.h:24
int v_addr
Definition: edid.h:49
int h_addr
Definition: edid.h:45
int v_sync
Definition: edid.h:51
StereoType stereo
Definition: edid.h:58
int width_mm
Definition: edid.h:53
struct DetailedTiming::@30::@32 analog
int v_blank
Definition: edid.h:50
Definition: edid.h:26
#define FALSE
Definition: edid-parse.c:32
int h_blank
Definition: edid.h:46
static void decode_display_descriptor ( const uchar desc,
MonitorInfo info 
)
static

Definition at line 379 of file edid-parse.c.

References decode_lf_string(), MonitorInfo::dsc_product_name, MonitorInfo::dsc_serial_number, and MonitorInfo::dsc_string.

Referenced by decode_descriptors().

381 {
382  switch (desc[0x03])
383  {
384  case 0xFC:
385  decode_lf_string (desc + 5, 13, info->dsc_product_name);
386  break;
387  case 0xFF:
388  decode_lf_string (desc + 5, 13, info->dsc_serial_number);
389  break;
390  case 0xFE:
391  decode_lf_string (desc + 5, 13, info->dsc_string);
392  break;
393  case 0xFD:
394  /* Range Limits */
395  break;
396  case 0xFB:
397  /* Color Point */
398  break;
399  case 0xFA:
400  /* Timing Identifications */
401  break;
402  case 0xF9:
403  /* Color Management */
404  break;
405  case 0xF8:
406  /* Timing Codes */
407  break;
408  case 0xF7:
409  /* Established Timings */
410  break;
411  case 0x10:
412  break;
413  }
414 }
char dsc_product_name[14]
Definition: edid.h:160
static void decode_lf_string(const uchar *s, int n_chars, char *result)
Definition: edid-parse.c:356
char dsc_string[14]
Definition: edid.h:161
char dsc_serial_number[14]
Definition: edid.h:159
static int decode_display_parameters ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 121 of file edid-parse.c.

References MonitorInfo::active_off, MonitorInfo::analog, MonitorInfo::aspect_ratio, MonitorInfo::continuous_frequency, MonitorInfo::digital, DISPLAY_PORT, DVI, MonitorInfo::gamma, get_bit(), get_bits(), HDMI_A, HDMI_B, MonitorInfo::height_mm, MonitorInfo::is_digital, MDDI, MONOCHROME, OTHER_COLOR, MonitorInfo::preferred_timing_includes_native, RGB, MonitorInfo::srgb_is_standard, MonitorInfo::standby, MonitorInfo::suspend, TRUE, UNDEFINED, UNDEFINED_COLOR, and MonitorInfo::width_mm.

Referenced by decode_edid().

122 {
123  /* Digital vs Analog */
124  info->is_digital = get_bit (edid[0x14], 7);
125 
126  if (info->is_digital)
127  {
128  int bits;
129 
130  static const int bit_depth[8] =
131  {
132  -1, 6, 8, 10, 12, 14, 16, -1
133  };
134 
135  static const Interface interfaces[6] =
136  {
138  };
139 
140  bits = get_bits (edid[0x14], 4, 6);
141  info->digital.bits_per_primary = bit_depth[bits];
142 
143  bits = get_bits (edid[0x14], 0, 3);
144 
145  if (bits <= 5)
146  info->digital.interface = interfaces[bits];
147  else
148  info->digital.interface = UNDEFINED;
149  }
150  else
151  {
152  int bits = get_bits (edid[0x14], 5, 6);
153 
154  static const double levels[][3] =
155  {
156  { 0.7, 0.3, 1.0 },
157  { 0.714, 0.286, 1.0 },
158  { 1.0, 0.4, 1.4 },
159  { 0.7, 0.0, 0.7 },
160  };
161 
162  info->analog.video_signal_level = levels[bits][0];
163  info->analog.sync_signal_level = levels[bits][1];
164  info->analog.total_signal_level = levels[bits][2];
165 
166  info->analog.blank_to_black = get_bit (edid[0x14], 4);
167 
168  info->analog.separate_hv_sync = get_bit (edid[0x14], 3);
169  info->analog.composite_sync_on_h = get_bit (edid[0x14], 2);
170  info->analog.composite_sync_on_green = get_bit (edid[0x14], 1);
171 
172  info->analog.serration_on_vsync = get_bit (edid[0x14], 0);
173  }
174 
175  /* Screen Size / Aspect Ratio */
176  if (edid[0x15] == 0 && edid[0x16] == 0)
177  {
178  info->width_mm = -1;
179  info->height_mm = -1;
180  info->aspect_ratio = -1.0;
181  }
182  else if (edid[0x16] == 0)
183  {
184  info->width_mm = -1;
185  info->height_mm = -1;
186  info->aspect_ratio = 100.0 / (edid[0x15] + 99);
187  }
188  else if (edid[0x15] == 0)
189  {
190  info->width_mm = -1;
191  info->height_mm = -1;
192  info->aspect_ratio = 100.0 / (edid[0x16] + 99);
193  info->aspect_ratio = 1/info->aspect_ratio; /* portrait */
194  }
195  else
196  {
197  info->width_mm = 10 * edid[0x15];
198  info->height_mm = 10 * edid[0x16];
199  }
200 
201  /* Gamma */
202  if (edid[0x17] == 0xFF)
203  info->gamma = -1.0;
204  else
205  info->gamma = (edid[0x17] + 100.0) / 100.0;
206 
207  /* Features */
208  info->standby = get_bit (edid[0x18], 7);
209  info->suspend = get_bit (edid[0x18], 6);
210  info->active_off = get_bit (edid[0x18], 5);
211 
212  if (info->is_digital)
213  {
214  info->digital.rgb444 = TRUE;
215  if (get_bit (edid[0x18], 3))
216  info->digital.ycrcb444 = 1;
217  if (get_bit (edid[0x18], 4))
218  info->digital.ycrcb422 = 1;
219  }
220  else
221  {
222  int bits = get_bits (edid[0x18], 3, 4);
223  ColorType color_type[4] =
224  {
226  };
227 
228  info->analog.color_type = color_type[bits];
229  }
230 
231  info->srgb_is_standard = get_bit (edid[0x18], 2);
232 
233  /* In 1.3 this is called "has preferred timing" */
234  info->preferred_timing_includes_native = get_bit (edid[0x18], 1);
235 
236  /* FIXME: In 1.3 this indicates whether the monitor accepts GTF */
237  info->continuous_frequency = get_bit (edid[0x18], 0);
238  return TRUE;
239 }
Definition: edid.h:20
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
Definition: edid.h:8
int active_off
Definition: edid.h:131
int suspend
Definition: edid.h:130
int standby
Definition: edid.h:129
struct MonitorInfo::@34::@36 digital
ColorType
Definition: edid.h:16
Definition: edid.h:10
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
int width_mm
Definition: edid.h:123
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
Definition: edid.h:11
#define TRUE
Definition: edid-parse.c:31
Definition: edid.h:12
int continuous_frequency
Definition: edid.h:135
double aspect_ratio
Definition: edid.h:125
int preferred_timing_includes_native
Definition: edid.h:134
GLsizei levels
int srgb_is_standard
Definition: edid.h:133
int is_digital
Definition: edid.h:94
int height_mm
Definition: edid.h:124
Definition: edid.h:9
double gamma
Definition: edid.h:127
struct MonitorInfo::@34::@37 analog
Interface
Definition: edid.h:6
MonitorInfo* decode_edid ( const uchar edid)

Definition at line 521 of file edid-parse.c.

References calloc, decode_check_sum(), decode_color_characteristics(), decode_descriptors(), decode_display_parameters(), decode_edid_version(), decode_established_timings(), decode_header(), decode_standard_timings(), decode_vendor_and_product_identification(), free, and NULL.

522 {
523  MonitorInfo *info = calloc (1, sizeof (MonitorInfo));
524 
525  decode_check_sum (edid, info);
526 
527  if (!decode_header (edid) ||
529  !decode_edid_version (edid, info) ||
530  !decode_display_parameters (edid, info) ||
531  !decode_color_characteristics (edid, info) ||
532  !decode_established_timings (edid, info) ||
533  !decode_standard_timings (edid, info) ||
534  !decode_descriptors (edid, info)) {
535  free(info);
536  return NULL;
537  }
538 
539  return info;
540 }
static int decode_color_characteristics(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:256
static int decode_header(const uchar *edid)
Definition: edid-parse.c:49
SDL_EventEntry * free
Definition: SDL_events.c:81
#define calloc
Definition: SDL_malloc.c:642
static int decode_edid_version(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:112
static int decode_established_timings(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:271
static void decode_check_sum(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:508
static int decode_display_parameters(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:121
static int decode_vendor_and_product_identification(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:57
#define NULL
Definition: begin_code.h:143
static int decode_descriptors(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:480
static int decode_standard_timings(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:324
static int decode_edid_version ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 112 of file edid-parse.c.

References MonitorInfo::major_version, MonitorInfo::minor_version, and TRUE.

Referenced by decode_edid().

113 {
114  info->major_version = edid[0x12];
115  info->minor_version = edid[0x13];
116 
117  return TRUE;
118 }
int minor_version
Definition: edid.h:92
int major_version
Definition: edid.h:91
#define TRUE
Definition: edid-parse.c:31
static int decode_established_timings ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 271 of file edid-parse.c.

References MonitorInfo::established, get_bit(), i, j, and TRUE.

Referenced by decode_edid().

272 {
273  static const Timing established[][8] =
274  {
275  {
276  { 800, 600, 60 },
277  { 800, 600, 56 },
278  { 640, 480, 75 },
279  { 640, 480, 72 },
280  { 640, 480, 67 },
281  { 640, 480, 60 },
282  { 720, 400, 88 },
283  { 720, 400, 70 }
284  },
285  {
286  { 1280, 1024, 75 },
287  { 1024, 768, 75 },
288  { 1024, 768, 70 },
289  { 1024, 768, 60 },
290  { 1024, 768, 87 },
291  { 832, 624, 75 },
292  { 800, 600, 75 },
293  { 800, 600, 72 }
294  },
295  {
296  { 0, 0, 0 },
297  { 0, 0, 0 },
298  { 0, 0, 0 },
299  { 0, 0, 0 },
300  { 0, 0, 0 },
301  { 0, 0, 0 },
302  { 0, 0, 0 },
303  { 1152, 870, 75 }
304  },
305  };
306 
307  int i, j, idx;
308 
309  idx = 0;
310  for (i = 0; i < 3; ++i)
311  {
312  for (j = 0; j < 8; ++j)
313  {
314  int byte = edid[0x23 + i];
315 
316  if (get_bit (byte, j) && established[i][j].frequency != 0)
317  info->established[idx++] = established[i][j];
318  }
319  }
320  return TRUE;
321 }
Definition: edid.h:35
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
#define TRUE
Definition: edid-parse.c:31
Timing established[24]
Definition: edid.h:146
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:42
static double decode_fraction ( int  high,
int  low 
)
static

Definition at line 242 of file edid-parse.c.

References get_bit(), and i.

Referenced by decode_color_characteristics().

243 {
244  double result = 0.0;
245  int i;
246 
247  high = (high << 2) | low;
248 
249  for (i = 0; i < 10; ++i)
250  result += get_bit (high, i) * pow (2, i - 10);
251 
252  return result;
253 }
GLuint64EXT * result
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
static int decode_header ( const uchar edid)
static

Definition at line 49 of file edid-parse.c.

References FALSE, and TRUE.

Referenced by decode_edid().

50 {
51  if (memcmp (edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0)
52  return TRUE;
53  return FALSE;
54 }
#define TRUE
Definition: edid-parse.c:31
#define FALSE
Definition: edid-parse.c:32
static void decode_lf_string ( const uchar s,
int  n_chars,
char *  result 
)
static

Definition at line 356 of file edid-parse.c.

References i.

Referenced by decode_display_descriptor().

357 {
358  int i;
359  for (i = 0; i < n_chars; ++i)
360  {
361  if (s[i] == 0x0a)
362  {
363  *result++ = '\0';
364  break;
365  }
366  else if (s[i] == 0x00)
367  {
368  /* Convert embedded 0's to spaces */
369  *result++ = ' ';
370  }
371  else
372  {
373  *result++ = s[i];
374  }
375  }
376 }
GLuint64EXT * result
GLdouble s
Definition: SDL_opengl.h:2056
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
static int decode_standard_timings ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 324 of file edid-parse.c.

References Timing::frequency, get_bits(), Timing::height, i, MonitorInfo::standard, TRUE, and Timing::width.

Referenced by decode_edid().

325 {
326  int i;
327 
328  for (i = 0; i < 8; i++)
329  {
330  int first = edid[0x26 + 2 * i];
331  int second = edid[0x27 + 2 * i];
332 
333  if (first != 0x01 && second != 0x01)
334  {
335  int w = 8 * (first + 31);
336  int h = 0;
337 
338  switch (get_bits (second, 6, 7))
339  {
340  case 0x00: h = (w / 16) * 10; break;
341  case 0x01: h = (w / 4) * 3; break;
342  case 0x02: h = (w / 5) * 4; break;
343  case 0x03: h = (w / 16) * 9; break;
344  }
345 
346  info->standard[i].width = w;
347  info->standard[i].height = h;
348  info->standard[i].frequency = get_bits (second, 0, 5) + 60;
349  }
350  }
351 
352  return TRUE;
353 }
int frequency
Definition: edid.h:39
int height
Definition: edid.h:38
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
const GLint * first
int width
Definition: edid.h:37
Timing standard[8]
Definition: edid.h:147
#define TRUE
Definition: edid-parse.c:31
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h
static int decode_vendor_and_product_identification ( const uchar edid,
MonitorInfo info 
)
static

Definition at line 57 of file edid-parse.c.

References FALSE, get_bits(), MonitorInfo::manufacturer_code, MonitorInfo::model_year, MonitorInfo::product_code, MonitorInfo::production_week, MonitorInfo::production_year, MonitorInfo::serial_number, and TRUE.

Referenced by decode_edid().

58 {
59  int is_model_year;
60 
61  /* Manufacturer Code */
62  info->manufacturer_code[0] = get_bits (edid[0x08], 2, 6);
63  info->manufacturer_code[1] = get_bits (edid[0x08], 0, 1) << 3;
64  info->manufacturer_code[1] |= get_bits (edid[0x09], 5, 7);
65  info->manufacturer_code[2] = get_bits (edid[0x09], 0, 4);
66  info->manufacturer_code[3] = '\0';
67 
68  info->manufacturer_code[0] += 'A' - 1;
69  info->manufacturer_code[1] += 'A' - 1;
70  info->manufacturer_code[2] += 'A' - 1;
71 
72  /* Product Code */
73  info->product_code = edid[0x0b] << 8 | edid[0x0a];
74 
75  /* Serial Number */
76  info->serial_number =
77  edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | edid[0x0f] << 24;
78 
79  /* Week and Year */
80  is_model_year = FALSE;
81  switch (edid[0x10])
82  {
83  case 0x00:
84  info->production_week = -1;
85  break;
86 
87  case 0xff:
88  info->production_week = -1;
89  is_model_year = TRUE;
90  break;
91 
92  default:
93  info->production_week = edid[0x10];
94  break;
95  }
96 
97  if (is_model_year)
98  {
99  info->production_year = -1;
100  info->model_year = 1990 + edid[0x11];
101  }
102  else
103  {
104  info->production_year = 1990 + edid[0x11];
105  info->model_year = -1;
106  }
107 
108  return TRUE;
109 }
int production_week
Definition: edid.h:87
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
char manufacturer_code[4]
Definition: edid.h:83
int product_code
Definition: edid.h:84
int model_year
Definition: edid.h:89
#define TRUE
Definition: edid-parse.c:31
unsigned int serial_number
Definition: edid.h:85
int production_year
Definition: edid.h:88
#define FALSE
Definition: edid-parse.c:32
void dump_monitor_info ( MonitorInfo info)

Definition at line 549 of file edid-parse.c.

References MonitorInfo::active_off, DetailedTiming::analog, MonitorInfo::analog, MonitorInfo::aspect_ratio, MonitorInfo::blue_x, MonitorInfo::blue_y, MonitorInfo::checksum, MonitorInfo::continuous_frequency, MonitorInfo::detailed_timings, DetailedTiming::digital, MonitorInfo::digital, DetailedTiming::digital_sync, DISPLAY_PORT, MonitorInfo::dsc_product_name, MonitorInfo::dsc_serial_number, MonitorInfo::dsc_string, DVI, MonitorInfo::established, FIELD_LEFT, FIELD_RIGHT, FOUR_WAY_INTERLEAVED, Timing::frequency, MonitorInfo::gamma, MonitorInfo::green_x, MonitorInfo::green_y, DetailedTiming::h_addr, DetailedTiming::h_blank, DetailedTiming::h_front_porch, DetailedTiming::h_sync, HDMI_A, HDMI_B, Timing::height, DetailedTiming::height_mm, MonitorInfo::height_mm, i, MonitorInfo::is_digital, MonitorInfo::major_version, MonitorInfo::manufacturer_code, MDDI, MonitorInfo::minor_version, MonitorInfo::model_year, MONOCHROME, MonitorInfo::n_detailed_timings, NO_STEREO, OTHER_COLOR, DetailedTiming::pixel_clock, MonitorInfo::preferred_timing_includes_native, MonitorInfo::product_code, MonitorInfo::production_week, MonitorInfo::production_year, MonitorInfo::red_x, MonitorInfo::red_y, RGB, DetailedTiming::right_border, MonitorInfo::serial_number, SIDE_BY_SIDE, MonitorInfo::srgb_is_standard, MonitorInfo::standard, MonitorInfo::standby, DetailedTiming::stereo, MonitorInfo::suspend, DetailedTiming::top_border, TWO_WAY_LEFT_ON_EVEN, TWO_WAY_RIGHT_ON_EVEN, UNDEFINED, UNDEFINED_COLOR, DetailedTiming::v_addr, DetailedTiming::v_blank, DetailedTiming::v_front_porch, DetailedTiming::v_sync, MonitorInfo::white_x, MonitorInfo::white_y, Timing::width, DetailedTiming::width_mm, MonitorInfo::width_mm, and yesno().

550 {
551  int i;
552 
553  printf ("Checksum: %d (%s)\n",
554  info->checksum, info->checksum? "incorrect" : "correct");
555  printf ("Manufacturer Code: %s\n", info->manufacturer_code);
556  printf ("Product Code: 0x%x\n", info->product_code);
557  printf ("Serial Number: %u\n", info->serial_number);
558 
559  if (info->production_week != -1)
560  printf ("Production Week: %d\n", info->production_week);
561  else
562  printf ("Production Week: unspecified\n");
563 
564  if (info->production_year != -1)
565  printf ("Production Year: %d\n", info->production_year);
566  else
567  printf ("Production Year: unspecified\n");
568 
569  if (info->model_year != -1)
570  printf ("Model Year: %d\n", info->model_year);
571  else
572  printf ("Model Year: unspecified\n");
573 
574  printf ("EDID revision: %d.%d\n", info->major_version, info->minor_version);
575 
576  printf ("Display is %s\n", info->is_digital? "digital" : "analog");
577  if (info->is_digital)
578  {
579  const char *interface;
580  if (info->digital.bits_per_primary != -1)
581  printf ("Bits Per Primary: %d\n", info->digital.bits_per_primary);
582  else
583  printf ("Bits Per Primary: undefined\n");
584 
585  switch (info->digital.interface)
586  {
587  case DVI: interface = "DVI"; break;
588  case HDMI_A: interface = "HDMI-a"; break;
589  case HDMI_B: interface = "HDMI-b"; break;
590  case MDDI: interface = "MDDI"; break;
591  case DISPLAY_PORT: interface = "DisplayPort"; break;
592  case UNDEFINED: interface = "undefined"; break;
593  default: interface = "unknown"; break;
594  }
595  printf ("Interface: %s\n", interface);
596 
597  printf ("RGB 4:4:4: %s\n", yesno (info->digital.rgb444));
598  printf ("YCrCb 4:4:4: %s\n", yesno (info->digital.ycrcb444));
599  printf ("YCrCb 4:2:2: %s\n", yesno (info->digital.ycrcb422));
600  }
601  else
602  {
603  const char *s;
604  printf ("Video Signal Level: %f\n", info->analog.video_signal_level);
605  printf ("Sync Signal Level: %f\n", info->analog.sync_signal_level);
606  printf ("Total Signal Level: %f\n", info->analog.total_signal_level);
607 
608  printf ("Blank to Black: %s\n",
609  yesno (info->analog.blank_to_black));
610  printf ("Separate HV Sync: %s\n",
611  yesno (info->analog.separate_hv_sync));
612  printf ("Composite Sync on H: %s\n",
613  yesno (info->analog.composite_sync_on_h));
614  printf ("Serration on VSync: %s\n",
615  yesno (info->analog.serration_on_vsync));
616 
617  switch (info->analog.color_type)
618  {
619  case UNDEFINED_COLOR: s = "undefined"; break;
620  case MONOCHROME: s = "monochrome"; break;
621  case RGB: s = "rgb"; break;
622  case OTHER_COLOR: s = "other color"; break;
623  default: s = "unknown"; break;
624  };
625 
626  printf ("Color: %s\n", s);
627  }
628 
629  if (info->width_mm == -1)
630  printf ("Width: undefined\n");
631  else
632  printf ("Width: %d mm\n", info->width_mm);
633 
634  if (info->height_mm == -1)
635  printf ("Height: undefined\n");
636  else
637  printf ("Height: %d mm\n", info->height_mm);
638 
639  if (info->aspect_ratio > 0)
640  printf ("Aspect Ratio: %f\n", info->aspect_ratio);
641  else
642  printf ("Aspect Ratio: undefined\n");
643 
644  if (info->gamma >= 0)
645  printf ("Gamma: %f\n", info->gamma);
646  else
647  printf ("Gamma: undefined\n");
648 
649  printf ("Standby: %s\n", yesno (info->standby));
650  printf ("Suspend: %s\n", yesno (info->suspend));
651  printf ("Active Off: %s\n", yesno (info->active_off));
652 
653  printf ("SRGB is Standard: %s\n", yesno (info->srgb_is_standard));
654  printf ("Preferred Timing Includes Native: %s\n",
656  printf ("Continuous Frequency: %s\n", yesno (info->continuous_frequency));
657 
658  printf ("Red X: %f\n", info->red_x);
659  printf ("Red Y: %f\n", info->red_y);
660  printf ("Green X: %f\n", info->green_x);
661  printf ("Green Y: %f\n", info->green_y);
662  printf ("Blue X: %f\n", info->blue_x);
663  printf ("Blue Y: %f\n", info->blue_y);
664  printf ("White X: %f\n", info->white_x);
665  printf ("White Y: %f\n", info->white_y);
666 
667  printf ("Established Timings:\n");
668 
669  for (i = 0; i < 24; ++i)
670  {
671  Timing *timing = &(info->established[i]);
672 
673  if (timing->frequency == 0)
674  break;
675 
676  printf (" %d x %d @ %d Hz\n",
677  timing->width, timing->height, timing->frequency);
678 
679  }
680 
681  printf ("Standard Timings:\n");
682  for (i = 0; i < 8; ++i)
683  {
684  Timing *timing = &(info->standard[i]);
685 
686  if (timing->frequency == 0)
687  break;
688 
689  printf (" %d x %d @ %d Hz\n",
690  timing->width, timing->height, timing->frequency);
691  }
692 
693  for (i = 0; i < info->n_detailed_timings; ++i)
694  {
695  DetailedTiming *timing = &(info->detailed_timings[i]);
696  const char *s;
697 
698  printf ("Timing%s: \n",
699  (i == 0 && info->preferred_timing_includes_native)?
700  " (Preferred)" : "");
701  printf (" Pixel Clock: %d\n", timing->pixel_clock);
702  printf (" H Addressable: %d\n", timing->h_addr);
703  printf (" H Blank: %d\n", timing->h_blank);
704  printf (" H Front Porch: %d\n", timing->h_front_porch);
705  printf (" H Sync: %d\n", timing->h_sync);
706  printf (" V Addressable: %d\n", timing->v_addr);
707  printf (" V Blank: %d\n", timing->v_blank);
708  printf (" V Front Porch: %d\n", timing->v_front_porch);
709  printf (" V Sync: %d\n", timing->v_sync);
710  printf (" Width: %d mm\n", timing->width_mm);
711  printf (" Height: %d mm\n", timing->height_mm);
712  printf (" Right Border: %d\n", timing->right_border);
713  printf (" Top Border: %d\n", timing->top_border);
714  switch (timing->stereo)
715  {
716  default:
717  case NO_STEREO: s = "No Stereo"; break;
718  case FIELD_RIGHT: s = "Field Sequential, Right on Sync"; break;
719  case FIELD_LEFT: s = "Field Sequential, Left on Sync"; break;
720  case TWO_WAY_RIGHT_ON_EVEN: s = "Two-way, Right on Even"; break;
721  case TWO_WAY_LEFT_ON_EVEN: s = "Two-way, Left on Even"; break;
722  case FOUR_WAY_INTERLEAVED: s = "Four-way Interleaved"; break;
723  case SIDE_BY_SIDE: s = "Side-by-Side"; break;
724  }
725  printf (" Stereo: %s\n", s);
726 
727  if (timing->digital_sync)
728  {
729  printf (" Digital Sync:\n");
730  printf (" composite: %s\n", yesno (timing->digital.composite));
731  printf (" serrations: %s\n", yesno (timing->digital.serrations));
732  printf (" negative vsync: %s\n",
733  yesno (timing->digital.negative_vsync));
734  printf (" negative hsync: %s\n",
735  yesno (timing->digital.negative_hsync));
736  }
737  else
738  {
739  printf (" Analog Sync:\n");
740  printf (" bipolar: %s\n", yesno (timing->analog.bipolar));
741  printf (" serrations: %s\n", yesno (timing->analog.serrations));
742  printf (" sync on green: %s\n", yesno (
743  timing->analog.sync_on_green));
744  }
745  }
746 
747  printf ("Detailed Product information:\n");
748  printf (" Product Name: %s\n", info->dsc_product_name);
749  printf (" Serial Number: %s\n", info->dsc_serial_number);
750  printf (" Unspecified String: %s\n", info->dsc_string);
751 }
double green_y
Definition: edid.h:140
char dsc_product_name[14]
Definition: edid.h:160
int n_detailed_timings
Definition: edid.h:149
int production_week
Definition: edid.h:87
Definition: edid.h:20
int h_sync
Definition: edid.h:47
int h_front_porch
Definition: edid.h:48
int frequency
Definition: edid.h:39
int height
Definition: edid.h:38
int minor_version
Definition: edid.h:92
GLdouble s
Definition: SDL_opengl.h:2056
Definition: edid.h:8
char manufacturer_code[4]
Definition: edid.h:83
int active_off
Definition: edid.h:131
int suspend
Definition: edid.h:130
int standby
Definition: edid.h:129
struct MonitorInfo::@34::@36 digital
int major_version
Definition: edid.h:91
int height_mm
Definition: edid.h:54
int product_code
Definition: edid.h:84
double white_y
Definition: edid.h:144
int width
Definition: edid.h:37
int checksum
Definition: edid.h:82
Definition: edid.h:10
double red_x
Definition: edid.h:137
char dsc_string[14]
Definition: edid.h:161
int width_mm
Definition: edid.h:123
int pixel_clock
Definition: edid.h:44
double blue_x
Definition: edid.h:141
Definition: edid.h:35
int model_year
Definition: edid.h:89
Timing standard[8]
Definition: edid.h:147
int digital_sync
Definition: edid.h:60
int top_border
Definition: edid.h:56
int right_border
Definition: edid.h:55
Definition: edid.h:11
struct DetailedTiming::@30::@33 digital
static const char * yesno(int v)
Definition: edid-parse.c:543
int v_front_porch
Definition: edid.h:52
Definition: edid.h:12
int continuous_frequency
Definition: edid.h:135
double aspect_ratio
Definition: edid.h:125
int v_addr
Definition: edid.h:49
int preferred_timing_includes_native
Definition: edid.h:134
Timing established[24]
Definition: edid.h:146
int srgb_is_standard
Definition: edid.h:133
int h_addr
Definition: edid.h:45
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
int v_sync
Definition: edid.h:51
int is_digital
Definition: edid.h:94
DetailedTiming detailed_timings[4]
Definition: edid.h:150
StereoType stereo
Definition: edid.h:58
int width_mm
Definition: edid.h:53
struct DetailedTiming::@30::@32 analog
char dsc_serial_number[14]
Definition: edid.h:159
int height_mm
Definition: edid.h:124
int v_blank
Definition: edid.h:50
Definition: edid.h:9
Definition: edid.h:26
double white_x
Definition: edid.h:143
unsigned int serial_number
Definition: edid.h:85
int production_year
Definition: edid.h:88
GLboolean GLboolean GLboolean GLboolean a
double gamma
Definition: edid.h:127
struct MonitorInfo::@34::@37 analog
GLboolean GLboolean GLboolean b
double green_x
Definition: edid.h:139
int h_blank
Definition: edid.h:46
double blue_y
Definition: edid.h:142
double red_y
Definition: edid.h:138
static int get_bit ( int  in,
int  bit 
)
static

Definition at line 35 of file edid-parse.c.

Referenced by decode_detailed_timing(), decode_display_parameters(), decode_established_timings(), and decode_fraction().

36 {
37  return (in & (1 << bit)) >> bit;
38 }
GLuint in
static int get_bits ( int  in,
int  begin,
int  end 
)
static

Definition at line 41 of file edid-parse.c.

Referenced by decode_color_characteristics(), decode_detailed_timing(), decode_display_parameters(), decode_standard_timings(), and decode_vendor_and_product_identification().

42 {
43  int mask = (1 << (end - begin + 1)) - 1;
44 
45  return (in >> begin) & mask;
46 }
GLuint GLuint end
Definition: SDL_opengl.h:1564
GLenum GLint GLuint mask
GLuint in
static const char* yesno ( int  v)
static

Definition at line 543 of file edid-parse.c.

Referenced by dump_monitor_info().

544 {
545  return v? "yes" : "no";
546 }
const GLdouble * v
Definition: SDL_opengl.h:2057