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)
MonitorInfo * | decode_edid (const uchar *edid)
static const char * | yesno (int v)
void | dump_monitor_info (MonitorInfo *info)

## Macro Definition Documentation

#define FALSE 0

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

Referenced by decode_detailed_timing(), decode_header(), and decode_vendor_and_product_identification().

#define TRUE 1

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

Referenced by decode_color_characteristics(), decode_descriptors(), decode_display_parameters(), decode_edid_version(), decode_established_timings(), decode_header(), decode_standard_timings(), decode_vendor_and_product_identification(), and SDL_GetPlatform().

## 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().

{
int i;
uchar check = 0;
for (i = 0; i < 128; ++i)
check += edid[i];
info->checksum = check;
}
MonitorInfo::checksum
int checksum
Definition: edid.h:82
i
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
uchar
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().

{
info->red_x = decode_fraction (edid[0x1b], get_bits (edid[0x19], 6, 7));
info->red_y = decode_fraction (edid[0x1c], get_bits (edid[0x19], 5, 4));
info->green_x = decode_fraction (edid[0x1d], get_bits (edid[0x19], 2, 3));
info->green_y = decode_fraction (edid[0x1e], get_bits (edid[0x19], 0, 1));
info->blue_x = decode_fraction (edid[0x1f], get_bits (edid[0x1a], 6, 7));
info->blue_y = decode_fraction (edid[0x20], get_bits (edid[0x1a], 4, 5));
info->white_x = decode_fraction (edid[0x21], get_bits (edid[0x1a], 2, 3));
info->white_y = decode_fraction (edid[0x22], get_bits (edid[0x1a], 0, 1));
return TRUE;
}
MonitorInfo::green_y
double green_y
Definition: edid.h:140
get_bits
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
MonitorInfo::white_y
double white_y
Definition: edid.h:144
MonitorInfo::red_x
double red_x
Definition: edid.h:137
MonitorInfo::blue_x
double blue_x
Definition: edid.h:141
decode_fraction
static double decode_fraction(int high, int low)
Definition: edid-parse.c:242
TRUE
#define TRUE
Definition: edid-parse.c:31
MonitorInfo::white_x
double white_x
Definition: edid.h:143
MonitorInfo::green_x
double green_x
Definition: edid.h:139
MonitorInfo::blue_y
double blue_y
Definition: edid.h:142
MonitorInfo::red_y
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().

{
int i;
int timing_idx;
timing_idx = 0;
for (i = 0; i < 4; ++i)
{
int index = 0x36 + i * 18;
if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00)
{
decode_display_descriptor (edid + index, info);
}
else
{
decode_detailed_timing (
edid + index, &(info->detailed_timings[timing_idx++]));
}
}
info->n_detailed_timings = timing_idx;
return TRUE;
}
MonitorInfo::n_detailed_timings
int n_detailed_timings
Definition: edid.h:149
decode_detailed_timing
static void decode_detailed_timing(const uchar *timing, DetailedTiming *detailed)
Definition: edid-parse.c:417
decode_display_descriptor
static void decode_display_descriptor(const uchar *desc, MonitorInfo *info)
Definition: edid-parse.c:379
TRUE
#define TRUE
Definition: edid-parse.c:31
index
GLuint index
Definition: SDL_opengl_glext.h:660
i
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
MonitorInfo::detailed_timings
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().

{
int bits;
StereoType stereo[] =
{
NO_STEREO, NO_STEREO, FIELD_RIGHT, FIELD_LEFT,
TWO_WAY_RIGHT_ON_EVEN, TWO_WAY_LEFT_ON_EVEN,
FOUR_WAY_INTERLEAVED, SIDE_BY_SIDE
};
detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000;
detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4);
detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8);
detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4);
detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8);
detailed->h_front_porch = timing[0x08] | get_bits (timing[0x0b], 6, 7) << 8;
detailed->h_sync = timing[0x09] | get_bits (timing[0x0b], 4, 5) << 8;
detailed->v_front_porch =
get_bits (timing[0x0a], 4, 7) | get_bits (timing[0x0b], 2, 3) << 4;
detailed->v_sync =
get_bits (timing[0x0a], 0, 3) | get_bits (timing[0x0b], 0, 1) << 4;
detailed->width_mm = timing[0x0c] | get_bits (timing[0x0e], 4, 7) << 8;
detailed->height_mm = timing[0x0d] | get_bits (timing[0x0e], 0, 3) << 8;
detailed->right_border = timing[0x0f];
detailed->top_border = timing[0x10];
detailed->interlaced = get_bit (timing[0x11], 7);
/* Stereo */
bits = get_bits (timing[0x11], 5, 6) << 1 | get_bit (timing[0x11], 0);
detailed->stereo = stereo[bits];
/* Sync */
bits = timing[0x11];
detailed->digital_sync = get_bit (bits, 4);
if (detailed->digital_sync)
{
detailed->digital.composite = !get_bit (bits, 3);
if (detailed->digital.composite)
{
detailed->digital.serrations = get_bit (bits, 2);
detailed->digital.negative_vsync = FALSE;
}
else
{
detailed->digital.serrations = FALSE;
detailed->digital.negative_vsync = !get_bit (bits, 2);
}
detailed->digital.negative_hsync = !get_bit (bits, 0);
}
else
{
detailed->analog.bipolar = get_bit (bits, 3);
detailed->analog.serrations = get_bit (bits, 2);
detailed->analog.sync_on_green = !get_bit (bits, 1);
}
}
DetailedTiming::h_sync
int h_sync
Definition: edid.h:47
FIELD_LEFT
Definition: edid.h:28
DetailedTiming::h_front_porch
int h_front_porch
Definition: edid.h:48
get_bits
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
DetailedTiming::interlaced
int interlaced
Definition: edid.h:57
DetailedTiming::height_mm
int height_mm
Definition: edid.h:54
FOUR_WAY_INTERLEAVED
Definition: edid.h:31
bits
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
Definition: SDL_opengl_glext.h:6176
DetailedTiming::digital
struct DetailedTiming::@31::@34 digital
DetailedTiming::pixel_clock
int pixel_clock
Definition: edid.h:44
get_bit
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
TWO_WAY_LEFT_ON_EVEN
Definition: edid.h:30
DetailedTiming::digital_sync
int digital_sync
Definition: edid.h:60
DetailedTiming::top_border
int top_border
Definition: edid.h:56
DetailedTiming::right_border
int right_border
Definition: edid.h:55
DetailedTiming::v_front_porch
int v_front_porch
Definition: edid.h:52
StereoType
StereoType
Definition: edid.h:24
SIDE_BY_SIDE
Definition: edid.h:32
DetailedTiming::v_addr
int v_addr
Definition: edid.h:49
DetailedTiming::analog
struct DetailedTiming::@31::@33 analog
DetailedTiming::h_addr
int h_addr
Definition: edid.h:45
DetailedTiming::v_sync
int v_sync
Definition: edid.h:51
TWO_WAY_RIGHT_ON_EVEN
Definition: edid.h:29
DetailedTiming::stereo
StereoType stereo
Definition: edid.h:58
DetailedTiming::width_mm
int width_mm
Definition: edid.h:53
DetailedTiming::v_blank
int v_blank
Definition: edid.h:50
NO_STEREO
Definition: edid.h:26
FALSE
#define FALSE
Definition: edid-parse.c:32
DetailedTiming::h_blank
int h_blank
Definition: edid.h:46
FIELD_RIGHT
Definition: edid.h:27

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().

{
switch (desc[0x03])
{
case 0xFC:
decode_lf_string (desc + 5, 13, info->dsc_product_name);
break;
case 0xFF:
decode_lf_string (desc + 5, 13, info->dsc_serial_number);
break;
case 0xFE:
decode_lf_string (desc + 5, 13, info->dsc_string);
break;
case 0xFD:
/* Range Limits */
break;
case 0xFB:
/* Color Point */
break;
case 0xFA:
/* Timing Identifications */
break;
case 0xF9:
/* Color Management */
break;
case 0xF8:
/* Timing Codes */
break;
case 0xF7:
/* Established Timings */
break;
case 0x10:
break;
}
}
MonitorInfo::dsc_product_name
char dsc_product_name[14]
Definition: edid.h:160
decode_lf_string
static void decode_lf_string(const uchar *s, int n_chars, char *result)
Definition: edid-parse.c:356
MonitorInfo::dsc_string
char dsc_string[14]
Definition: edid.h:161
MonitorInfo::dsc_serial_number
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().

{
/* Digital vs Analog */
info->is_digital = get_bit (edid[0x14], 7);
if (info->is_digital)
{
int bits;
static const int bit_depth[8] =
{
-1, 6, 8, 10, 12, 14, 16, -1
};
static const Interface interfaces[6] =
{
UNDEFINED, DVI, HDMI_A, HDMI_B, MDDI, DISPLAY_PORT
};
bits = get_bits (edid[0x14], 4, 6);
info->digital.bits_per_primary = bit_depth[bits];
bits = get_bits (edid[0x14], 0, 3);
if (bits <= 5)
info->digital.interface = interfaces[bits];
else
info->digital.interface = UNDEFINED;
}
else
{
int bits = get_bits (edid[0x14], 5, 6);
static const double levels[][3] =
{
{ 0.7, 0.3, 1.0 },
{ 0.714, 0.286, 1.0 },
{ 1.0, 0.4, 1.4 },
{ 0.7, 0.0, 0.7 },
};
info->analog.video_signal_level = levels[bits][0];
info->analog.sync_signal_level = levels[bits][1];
info->analog.total_signal_level = levels[bits][2];
info->analog.blank_to_black = get_bit (edid[0x14], 4);
info->analog.separate_hv_sync = get_bit (edid[0x14], 3);
info->analog.composite_sync_on_h = get_bit (edid[0x14], 2);
info->analog.composite_sync_on_green = get_bit (edid[0x14], 1);
info->analog.serration_on_vsync = get_bit (edid[0x14], 0);
}
/* Screen Size / Aspect Ratio */
if (edid[0x15] == 0 && edid[0x16] == 0)
{
info->width_mm = -1;
info->height_mm = -1;
info->aspect_ratio = -1.0;
}
else if (edid[0x16] == 0)
{
info->width_mm = -1;
info->height_mm = -1;
info->aspect_ratio = 100.0 / (edid[0x15] + 99);
}
else if (edid[0x15] == 0)
{
info->width_mm = -1;
info->height_mm = -1;
info->aspect_ratio = 100.0 / (edid[0x16] + 99);
info->aspect_ratio = 1/info->aspect_ratio; /* portrait */
}
else
{
info->width_mm = 10 * edid[0x15];
info->height_mm = 10 * edid[0x16];
}
/* Gamma */
if (edid[0x17] == 0xFF)
info->gamma = -1.0;
else
info->gamma = (edid[0x17] + 100.0) / 100.0;
/* Features */
info->standby = get_bit (edid[0x18], 7);
info->suspend = get_bit (edid[0x18], 6);
info->active_off = get_bit (edid[0x18], 5);
if (info->is_digital)
{
info->digital.rgb444 = TRUE;
if (get_bit (edid[0x18], 3))
info->digital.ycrcb444 = 1;
if (get_bit (edid[0x18], 4))
info->digital.ycrcb422 = 1;
}
else
{
int bits = get_bits (edid[0x18], 3, 4);
ColorType color_type[4] =
{
MONOCHROME, RGB, OTHER_COLOR, UNDEFINED_COLOR
};
info->analog.color_type = color_type[bits];
}
info->srgb_is_standard = get_bit (edid[0x18], 2);
/* In 1.3 this is called "has preferred timing" */
info->preferred_timing_includes_native = get_bit (edid[0x18], 1);
/* FIXME: In 1.3 this indicates whether the monitor accepts GTF */
info->continuous_frequency = get_bit (edid[0x18], 0);
return TRUE;
}
RGB
Definition: edid.h:20
get_bits
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
UNDEFINED
Definition: edid.h:8
MonitorInfo::active_off
int active_off
Definition: edid.h:131
MonitorInfo::suspend
int suspend
Definition: edid.h:130
MonitorInfo::standby
int standby
Definition: edid.h:129
MonitorInfo::digital
struct MonitorInfo::@35::@37 digital
ColorType
ColorType
Definition: edid.h:16
HDMI_A
Definition: edid.h:10
bits
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
Definition: SDL_opengl_glext.h:6176
MonitorInfo::width_mm
int width_mm
Definition: edid.h:123
OTHER_COLOR
Definition: edid.h:21
get_bit
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
HDMI_B
Definition: edid.h:11
TRUE
#define TRUE
Definition: edid-parse.c:31
MDDI
Definition: edid.h:12
MonitorInfo::continuous_frequency
int continuous_frequency
Definition: edid.h:135
MonitorInfo::aspect_ratio
double aspect_ratio
Definition: edid.h:125
MonitorInfo::preferred_timing_includes_native
int preferred_timing_includes_native
Definition: edid.h:134
levels
GLsizei levels
Definition: SDL_opengl_glext.h:2164
MONOCHROME
Definition: edid.h:19
MonitorInfo::srgb_is_standard
int srgb_is_standard
Definition: edid.h:133
MonitorInfo::is_digital
int is_digital
Definition: edid.h:94
MonitorInfo::analog
struct MonitorInfo::@35::@38 analog
MonitorInfo::height_mm
int height_mm
Definition: edid.h:124
DVI
Definition: edid.h:9
UNDEFINED_COLOR
Definition: edid.h:18
MonitorInfo::gamma
double gamma
Definition: edid.h:127
DISPLAY_PORT
Definition: edid.h:13
Interface
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.

{
MonitorInfo *info = calloc (1, sizeof (MonitorInfo));
decode_check_sum (edid, info);
if (!decode_header (edid) ||
!decode_vendor_and_product_identification (edid, info) ||
!decode_edid_version (edid, info) ||
!decode_display_parameters (edid, info) ||
!decode_color_characteristics (edid, info) ||
!decode_established_timings (edid, info) ||
!decode_standard_timings (edid, info) ||
!decode_descriptors (edid, info)) {
free(info);
return NULL;
}
return info;
}
decode_color_characteristics
static int decode_color_characteristics(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:256
decode_header
static int decode_header(const uchar *edid)
Definition: edid-parse.c:49
free
SDL_EventEntry * free
Definition: SDL_events.c:81
calloc
#define calloc
Definition: SDL_malloc.c:642
decode_edid_version
static int decode_edid_version(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:112
decode_established_timings
static int decode_established_timings(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:271
decode_check_sum
static void decode_check_sum(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:508
decode_display_parameters
static int decode_display_parameters(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:121
decode_vendor_and_product_identification
static int decode_vendor_and_product_identification(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:57
NULL
#define NULL
Definition: begin_code.h:143
MonitorInfo
Definition: edid.h:80
decode_descriptors
static int decode_descriptors(const uchar *edid, MonitorInfo *info)
Definition: edid-parse.c:480
decode_standard_timings
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().

{
info->major_version = edid[0x12];
info->minor_version = edid[0x13];
return TRUE;
}
MonitorInfo::minor_version
int minor_version
Definition: edid.h:92
MonitorInfo::major_version
int major_version
Definition: edid.h:91
TRUE
#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().

{
static const Timing established[][8] =
{
{
{ 800, 600, 60 },
{ 800, 600, 56 },
{ 640, 480, 75 },
{ 640, 480, 72 },
{ 640, 480, 67 },
{ 640, 480, 60 },
{ 720, 400, 88 },
{ 720, 400, 70 }
},
{
{ 1280, 1024, 75 },
{ 1024, 768, 75 },
{ 1024, 768, 70 },
{ 1024, 768, 60 },
{ 1024, 768, 87 },
{ 832, 624, 75 },
{ 800, 600, 75 },
{ 800, 600, 72 }
},
{
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 1152, 870, 75 }
},
};
int i, j, idx;
idx = 0;
for (i = 0; i < 3; ++i)
{
for (j = 0; j < 8; ++j)
{
int byte = edid[0x23 + i];
if (get_bit (byte, j) && established[i][j].frequency != 0)
info->established[idx++] = established[i][j];
}
}
return TRUE;
}
Timing
Definition: edid.h:35
get_bit
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
TRUE
#define TRUE
Definition: edid-parse.c:31
MonitorInfo::established
Timing established[24]
Definition: edid.h:146
i
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
j
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().

{
double result = 0.0;
int i;
high = (high << 2) | low;
for (i = 0; i < 10; ++i)
result += get_bit (high, i) * pow (2, i - 10);
return result;
}
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
get_bit
static int get_bit(int in, int bit)
Definition: edid-parse.c:35
i
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().

{
if (memcmp (edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0)
return TRUE;
return FALSE;
}
TRUE
#define TRUE
Definition: edid-parse.c:31
FALSE
#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().

{
int i;
for (i = 0; i < n_chars; ++i)
{
if (s[i] == 0x0a)
{
*result++ = '\0';
break;
}
else if (s[i] == 0x00)
{
/* Convert embedded 0's to spaces */
*result++ = ' ';
}
else
{
*result++ = s[i];
}
}
}
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
s
GLdouble s
Definition: SDL_opengl.h:2056
i
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().

{
int i;
for (i = 0; i < 8; i++)
{
int first = edid[0x26 + 2 * i];
int second = edid[0x27 + 2 * i];
if (first != 0x01 && second != 0x01)
{
int w = 8 * (first + 31);
int h = 0;
switch (get_bits (second, 6, 7))
{
case 0x00: h = (w / 16) * 10; break;
case 0x01: h = (w / 4) * 3; break;
case 0x02: h = (w / 5) * 4; break;
case 0x03: h = (w / 16) * 9; break;
}
info->standard[i].width = w;
info->standard[i].height = h;
info->standard[i].frequency = get_bits (second, 0, 5) + 60;
}
}
return TRUE;
}
Timing::frequency
int frequency
Definition: edid.h:39
Timing::height
int height
Definition: edid.h:38
get_bits
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
first
const GLint * first
Definition: SDL_opengl_glext.h:368
Timing::width
int width
Definition: edid.h:37
MonitorInfo::standard
Timing standard[8]
Definition: edid.h:147
TRUE
#define TRUE
Definition: edid-parse.c:31
i
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
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946

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().

{
int is_model_year;
/* Manufacturer Code */
info->manufacturer_code[0] = get_bits (edid[0x08], 2, 6);
info->manufacturer_code[1] = get_bits (edid[0x08], 0, 1) << 3;
info->manufacturer_code[1] |= get_bits (edid[0x09], 5, 7);
info->manufacturer_code[2] = get_bits (edid[0x09], 0, 4);
info->manufacturer_code[3] = '\0';
info->manufacturer_code[0] += 'A' - 1;
info->manufacturer_code[1] += 'A' - 1;
info->manufacturer_code[2] += 'A' - 1;
/* Product Code */
info->product_code = edid[0x0b] << 8 | edid[0x0a];
/* Serial Number */
info->serial_number =
edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | edid[0x0f] << 24;
/* Week and Year */
is_model_year = FALSE;
switch (edid[0x10])
{
case 0x00:
info->production_week = -1;
break;
case 0xff:
info->production_week = -1;
is_model_year = TRUE;
break;
default:
info->production_week = edid[0x10];
break;
}
if (is_model_year)
{
info->production_year = -1;
info->model_year = 1990 + edid[0x11];
}
else
{
info->production_year = 1990 + edid[0x11];
info->model_year = -1;
}
return TRUE;
}
MonitorInfo::production_week
int production_week
Definition: edid.h:87
get_bits
static int get_bits(int in, int begin, int end)
Definition: edid-parse.c:41
MonitorInfo::manufacturer_code
char manufacturer_code[4]
Definition: edid.h:83
MonitorInfo::product_code
int product_code
Definition: edid.h:84
MonitorInfo::model_year
int model_year
Definition: edid.h:89
TRUE
#define TRUE
Definition: edid-parse.c:31
MonitorInfo::serial_number
unsigned int serial_number
Definition: edid.h:85
MonitorInfo::production_year
int production_year
Definition: edid.h:88
FALSE
#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().

{
int i;
printf ("Checksum: %d (%s)\n",
info->checksum, info->checksum? "incorrect" : "correct");
printf ("Manufacturer Code: %s\n", info->manufacturer_code);
printf ("Product Code: 0x%x\n", info->product_code);
printf ("Serial Number: %u\n", info->serial_number);
if (info->production_week != -1)
printf ("Production Week: %d\n", info->production_week);
else
printf ("Production Week: unspecified\n");
if (info->production_year != -1)
printf ("Production Year: %d\n", info->production_year);
else
printf ("Production Year: unspecified\n");
if (info->model_year != -1)
printf ("Model Year: %d\n", info->model_year);
else
printf ("Model Year: unspecified\n");
printf ("EDID revision: %d.%d\n", info->major_version, info->minor_version);
printf ("Display is %s\n", info->is_digital? "digital" : "analog");
if (info->is_digital)
{
const char *interface;
if (info->digital.bits_per_primary != -1)
printf ("Bits Per Primary: %d\n", info->digital.bits_per_primary);
else
printf ("Bits Per Primary: undefined\n");
switch (info->digital.interface)
{
case DVI: interface = "DVI"; break;
case HDMI_A: interface = "HDMI-a"; break;
case HDMI_B: interface = "HDMI-b"; break;
case MDDI: interface = "MDDI"; break;
case DISPLAY_PORT: interface = "DisplayPort"; break;
case UNDEFINED: interface = "undefined"; break;
default: interface = "unknown"; break;
}
printf ("Interface: %s\n", interface);
printf ("RGB 4:4:4: %s\n", yesno (info->digital.rgb444));
printf ("YCrCb 4:4:4: %s\n", yesno (info->digital.ycrcb444));
printf ("YCrCb 4:2:2: %s\n", yesno (info->digital.ycrcb422));
}
else
{
const char *s;
printf ("Video Signal Level: %f\n", info->analog.video_signal_level);
printf ("Sync Signal Level: %f\n", info->analog.sync_signal_level);
printf ("Total Signal Level: %f\n", info->analog.total_signal_level);
printf ("Blank to Black: %s\n",
yesno (info->analog.blank_to_black));
printf ("Separate HV Sync: %s\n",
yesno (info->analog.separate_hv_sync));
printf ("Composite Sync on H: %s\n",
yesno (info->analog.composite_sync_on_h));
printf ("Serration on VSync: %s\n",
yesno (info->analog.serration_on_vsync));
switch (info->analog.color_type)
{
case UNDEFINED_COLOR: s = "undefined"; break;
case MONOCHROME: s = "monochrome"; break;
case RGB: s = "rgb"; break;
case OTHER_COLOR: s = "other color"; break;
default: s = "unknown"; break;
};
printf ("Color: %s\n", s);
}
if (info->width_mm == -1)
printf ("Width: undefined\n");
else
printf ("Width: %d mm\n", info->width_mm);
if (info->height_mm == -1)
printf ("Height: undefined\n");
else
printf ("Height: %d mm\n", info->height_mm);
if (info->aspect_ratio > 0)
printf ("Aspect Ratio: %f\n", info->aspect_ratio);
else
printf ("Aspect Ratio: undefined\n");
if (info->gamma >= 0)
printf ("Gamma: %f\n", info->gamma);
else
printf ("Gamma: undefined\n");
printf ("Standby: %s\n", yesno (info->standby));
printf ("Suspend: %s\n", yesno (info->suspend));
printf ("Active Off: %s\n", yesno (info->active_off));
printf ("SRGB is Standard: %s\n", yesno (info->srgb_is_standard));
printf ("Preferred Timing Includes Native: %s\n",
yesno (info->preferred_timing_includes_native));
printf ("Continuous Frequency: %s\n", yesno (info->continuous_frequency));
printf ("Red X: %f\n", info->red_x);
printf ("Red Y: %f\n", info->red_y);
printf ("Green X: %f\n", info->green_x);
printf ("Green Y: %f\n", info->green_y);
printf ("Blue X: %f\n", info->blue_x);
printf ("Blue Y: %f\n", info->blue_y);
printf ("White X: %f\n", info->white_x);
printf ("White Y: %f\n", info->white_y);
printf ("Established Timings:\n");
for (i = 0; i < 24; ++i)
{
Timing *timing = &(info->established[i]);
if (timing->frequency == 0)
break;
printf (" %d x %d @ %d Hz\n",
timing->width, timing->height, timing->frequency);
}
printf ("Standard Timings:\n");
for (i = 0; i < 8; ++i)
{
Timing *timing = &(info->standard[i]);
if (timing->frequency == 0)
break;
printf (" %d x %d @ %d Hz\n",
timing->width, timing->height, timing->frequency);
}
for (i = 0; i < info->n_detailed_timings; ++i)
{
DetailedTiming *timing = &(info->detailed_timings[i]);
const char *s;
printf ("Timing%s: \n",
(i == 0 && info->preferred_timing_includes_native)?
" (Preferred)" : "");
printf (" Pixel Clock: %d\n", timing->pixel_clock);
printf (" H Addressable: %d\n", timing->h_addr);
printf (" H Blank: %d\n", timing->h_blank);
printf (" H Front Porch: %d\n", timing->h_front_porch);
printf (" H Sync: %d\n", timing->h_sync);
printf (" V Addressable: %d\n", timing->v_addr);
printf (" V Blank: %d\n", timing->v_blank);
printf (" V Front Porch: %d\n", timing->v_front_porch);
printf (" V Sync: %d\n", timing->v_sync);
printf (" Width: %d mm\n", timing->width_mm);
printf (" Height: %d mm\n", timing->height_mm);
printf (" Right Border: %d\n", timing->right_border);
printf (" Top Border: %d\n", timing->top_border);
switch (timing->stereo)
{
default:
case NO_STEREO: s = "No Stereo"; break;
case FIELD_RIGHT: s = "Field Sequential, Right on Sync"; break;
case FIELD_LEFT: s = "Field Sequential, Left on Sync"; break;
case TWO_WAY_RIGHT_ON_EVEN: s = "Two-way, Right on Even"; break;
case TWO_WAY_LEFT_ON_EVEN: s = "Two-way, Left on Even"; break;
case FOUR_WAY_INTERLEAVED: s = "Four-way Interleaved"; break;
case SIDE_BY_SIDE: s = "Side-by-Side"; break;
}
printf (" Stereo: %s\n", s);
if (timing->digital_sync)
{
printf (" Digital Sync:\n");
printf (" composite: %s\n", yesno (timing->digital.composite));
printf (" serrations: %s\n", yesno (timing->digital.serrations));
printf (" negative vsync: %s\n",
yesno (timing->digital.negative_vsync));
printf (" negative hsync: %s\n",
yesno (timing->digital.negative_hsync));
}
else
{
printf (" Analog Sync:\n");
printf (" bipolar: %s\n", yesno (timing->analog.bipolar));
printf (" serrations: %s\n", yesno (timing->analog.serrations));
printf (" sync on green: %s\n", yesno (
timing->analog.sync_on_green));
}
}
printf ("Detailed Product information:\n");
printf (" Product Name: %s\n", info->dsc_product_name);
printf (" Serial Number: %s\n", info->dsc_serial_number);
printf (" Unspecified String: %s\n", info->dsc_string);
}
MonitorInfo::green_y
double green_y
Definition: edid.h:140
MonitorInfo::dsc_product_name
char dsc_product_name[14]
Definition: edid.h:160
MonitorInfo::n_detailed_timings
int n_detailed_timings
Definition: edid.h:149
MonitorInfo::production_week
int production_week
Definition: edid.h:87
RGB
Definition: edid.h:20
DetailedTiming::h_sync
int h_sync
Definition: edid.h:47
FIELD_LEFT
Definition: edid.h:28
DetailedTiming::h_front_porch
int h_front_porch
Definition: edid.h:48
Timing::frequency
int frequency
Definition: edid.h:39
Timing::height
int height
Definition: edid.h:38
MonitorInfo::minor_version
int minor_version
Definition: edid.h:92
s
GLdouble s
Definition: SDL_opengl.h:2056
UNDEFINED
Definition: edid.h:8
MonitorInfo::manufacturer_code
char manufacturer_code[4]
Definition: edid.h:83
MonitorInfo::active_off
int active_off
Definition: edid.h:131
MonitorInfo::suspend
int suspend
Definition: edid.h:130
MonitorInfo::standby
int standby
Definition: edid.h:129
MonitorInfo::major_version
int major_version
Definition: edid.h:91
DetailedTiming::height_mm
int height_mm
Definition: edid.h:54
MonitorInfo::digital
struct MonitorInfo::@35::@37 digital
MonitorInfo::product_code
int product_code
Definition: edid.h:84
MonitorInfo::white_y
double white_y
Definition: edid.h:144
Timing::width
int width
Definition: edid.h:37
MonitorInfo::checksum
int checksum
Definition: edid.h:82
HDMI_A
Definition: edid.h:10
MonitorInfo::red_x
double red_x
Definition: edid.h:137
FOUR_WAY_INTERLEAVED
Definition: edid.h:31
MonitorInfo::dsc_string
char dsc_string[14]
Definition: edid.h:161
MonitorInfo::width_mm
int width_mm
Definition: edid.h:123
OTHER_COLOR
Definition: edid.h:21
DetailedTiming::digital
struct DetailedTiming::@31::@34 digital
DetailedTiming::pixel_clock
int pixel_clock
Definition: edid.h:44
MonitorInfo::blue_x
double blue_x
Definition: edid.h:141
Timing
Definition: edid.h:35
MonitorInfo::model_year
int model_year
Definition: edid.h:89
MonitorInfo::standard
Timing standard[8]
Definition: edid.h:147
TWO_WAY_LEFT_ON_EVEN
Definition: edid.h:30
DetailedTiming::digital_sync
int digital_sync
Definition: edid.h:60
DetailedTiming::top_border
int top_border
Definition: edid.h:56
DetailedTiming::right_border
int right_border
Definition: edid.h:55
HDMI_B
Definition: edid.h:11
yesno
static const char * yesno(int v)
Definition: edid-parse.c:543
DetailedTiming::v_front_porch
int v_front_porch
Definition: edid.h:52
MDDI
Definition: edid.h:12
SIDE_BY_SIDE
Definition: edid.h:32
MonitorInfo::continuous_frequency
int continuous_frequency
Definition: edid.h:135
MonitorInfo::aspect_ratio
double aspect_ratio
Definition: edid.h:125
DetailedTiming::v_addr
int v_addr
Definition: edid.h:49
MonitorInfo::preferred_timing_includes_native
int preferred_timing_includes_native
Definition: edid.h:134
DetailedTiming
Definition: edid.h:42
MonitorInfo::established
Timing established[24]
Definition: edid.h:146
MONOCHROME
Definition: edid.h:19
MonitorInfo::srgb_is_standard
int srgb_is_standard
Definition: edid.h:133
DetailedTiming::analog
struct DetailedTiming::@31::@33 analog
DetailedTiming::h_addr
int h_addr
Definition: edid.h:45
i
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::v_sync
int v_sync
Definition: edid.h:51
MonitorInfo::is_digital
int is_digital
Definition: edid.h:94
TWO_WAY_RIGHT_ON_EVEN
Definition: edid.h:29
MonitorInfo::analog
struct MonitorInfo::@35::@38 analog
MonitorInfo::detailed_timings
DetailedTiming detailed_timings[4]
Definition: edid.h:150
DetailedTiming::stereo
StereoType stereo
Definition: edid.h:58
DetailedTiming::width_mm
int width_mm
Definition: edid.h:53
MonitorInfo::dsc_serial_number
char dsc_serial_number[14]
Definition: edid.h:159
MonitorInfo::height_mm
int height_mm
Definition: edid.h:124
DetailedTiming::v_blank
int v_blank
Definition: edid.h:50
DVI
Definition: edid.h:9
NO_STEREO
Definition: edid.h:26
UNDEFINED_COLOR
Definition: edid.h:18
MonitorInfo::white_x
double white_x
Definition: edid.h:143
MonitorInfo::serial_number
unsigned int serial_number
Definition: edid.h:85
MonitorInfo::production_year
int production_year
Definition: edid.h:88
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
MonitorInfo::gamma
double gamma
Definition: edid.h:127
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
MonitorInfo::green_x
double green_x
Definition: edid.h:139
DetailedTiming::h_blank
int h_blank
Definition: edid.h:46
MonitorInfo::blue_y
double blue_y
Definition: edid.h:142
FIELD_RIGHT
Definition: edid.h:27
DISPLAY_PORT
Definition: edid.h:13
MonitorInfo::red_y
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().

{
return (in & (1 << bit)) >> bit;
}
in
GLuint in
Definition: SDL_opengl_glext.h:7940

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().

{
int mask = (1 << (end - begin + 1)) - 1;
return (in >> begin) & mask;
}
end
GLuint GLuint end
Definition: SDL_opengl.h:1564
mask
GLenum GLint GLuint mask
Definition: SDL_opengl_glext.h:657
in
GLuint in
Definition: SDL_opengl_glext.h:7940

static const char* yesno | ( | int | v | ) |

static

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

Referenced by dump_monitor_info().

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