Implemented SDL_GetDisplayName() for X11, which requires the XRandR extension.
authorSam Lantinga <slouken@libsdl.org>
Mon, 31 Dec 2012 18:32:30 -0800
changeset 6796424a12862805
parent 6795 f445268492a7
child 6797 8a818a373436
Implemented SDL_GetDisplayName() for X11, which requires the XRandR extension.
It turns out there's all kinds of good information in the EDID data for a monitor...
src/test/SDL_test_common.c
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11sym.h
src/video/x11/edid-parse.c
src/video/x11/edid.h
     1.1 --- a/src/test/SDL_test_common.c	Mon Dec 31 16:29:01 2012 -0800
     1.2 +++ b/src/test/SDL_test_common.c	Mon Dec 31 18:32:30 2012 -0800
     1.3 @@ -674,7 +674,7 @@
     1.4              n = SDL_GetNumVideoDisplays();
     1.5              fprintf(stderr, "Number of displays: %d\n", n);
     1.6              for (i = 0; i < n; ++i) {
     1.7 -                fprintf(stderr, "Display %d:\n", i);
     1.8 +                fprintf(stderr, "Display %d: %s\n", i, SDL_GetDisplayName(i));
     1.9  
    1.10                  SDL_zero(bounds);
    1.11                  SDL_GetDisplayBounds(i, &bounds);
     2.1 --- a/src/video/x11/SDL_x11modes.c	Mon Dec 31 16:29:01 2012 -0800
     2.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Dec 31 18:32:30 2012 -0800
     2.3 @@ -24,6 +24,7 @@
     2.4  
     2.5  #include "SDL_hints.h"
     2.6  #include "SDL_x11video.h"
     2.7 +#include "edid.h"
     2.8  
     2.9  /*#define X11MODES_DEBUG*/
    2.10  
    2.11 @@ -34,8 +35,10 @@
    2.12   * I can find.  For example, on Unity 3D if you show a fullscreen window while
    2.13   * the resolution is changing (within ~250 ms) your window will retain the
    2.14   * fullscreen state hint but be decorated and windowed.
    2.15 + *
    2.16 + * However, many people swear by it, so let them swear at it. :)
    2.17  */
    2.18 -#define XRANDR_DISABLED_BY_DEFAULT
    2.19 +/*#define XRANDR_DISABLED_BY_DEFAULT*/
    2.20  
    2.21  
    2.22  static int
    2.23 @@ -427,6 +430,7 @@
    2.24          SDL_DisplayMode mode;
    2.25          SDL_DisplayModeData *modedata;
    2.26          XPixmapFormatValues *pixmapFormats;
    2.27 +        char display_name[128];
    2.28          int i, n;
    2.29  
    2.30  #if SDL_VIDEO_DRIVER_X11_XINERAMA
    2.31 @@ -449,6 +453,7 @@
    2.32          if (!displaydata) {
    2.33              continue;
    2.34          }
    2.35 +        display_name[0] = '\0';
    2.36  
    2.37          mode.format = X11_GetPixelFormatFromVisualInfo(data->display, &vinfo);
    2.38          if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) {
    2.39 @@ -527,6 +532,12 @@
    2.40              XRROutputInfo *output_info;
    2.41              XRRCrtcInfo *crtc;
    2.42              int output;
    2.43 +            Atom EDID = XInternAtom(data->display, "EDID", False);
    2.44 +            Atom *props;
    2.45 +            int nprop;
    2.46 +            unsigned long width_mm;
    2.47 +            unsigned long height_mm;
    2.48 +            int inches = 0;
    2.49  
    2.50              for (output = 0; output < res->noutput; output++) {
    2.51                  output_info = XRRGetOutputInfo(data->display, res, res->outputs[output]);
    2.52 @@ -551,6 +562,49 @@
    2.53                  displaydata->xrandr_output = res->outputs[output];
    2.54                  SetXRandRModeInfo(data->display, res, output_info, crtc->mode, &mode);
    2.55  
    2.56 +                /* Get the name of this display */
    2.57 +                width_mm = output_info->mm_width;
    2.58 +                height_mm = output_info->mm_height;
    2.59 +                inches = (int)((sqrt(width_mm * width_mm +
    2.60 +                                     height_mm * height_mm) / 25.4f) + 0.5f);
    2.61 +                SDL_strlcpy(display_name, output_info->name, sizeof(display_name));
    2.62 +
    2.63 +                /* See if we can get the EDID data for the real monitor name */
    2.64 +                props = XRRListOutputProperties(data->display, res->outputs[output], &nprop);
    2.65 +                for (i = 0; i < nprop; ++i) {
    2.66 +                    unsigned char *prop;
    2.67 +                    int actual_format;
    2.68 +                    unsigned long nitems, bytes_after;
    2.69 +                    Atom actual_type;
    2.70 +   
    2.71 +	                if (props[i] == EDID) {
    2.72 +                        XRRGetOutputProperty(data->display, res->outputs[output], props[i],
    2.73 +                                             0, 100, False, False,
    2.74 +                                             AnyPropertyType,
    2.75 +                                             &actual_type, &actual_format,
    2.76 +                                             &nitems, &bytes_after, &prop);
    2.77 +
    2.78 +                        MonitorInfo *info = decode_edid(prop);
    2.79 +                        if (info) {
    2.80 +#ifdef X11MODES_DEBUG
    2.81 +                            printf("Found EDID data for %s\n", output_info->name);
    2.82 +                            dump_monitor_info(info);
    2.83 +#endif
    2.84 +                            SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
    2.85 +                            free(info);
    2.86 +                        }
    2.87 +                        break;
    2.88 +                    }
    2.89 +                }
    2.90 +
    2.91 +                if (*display_name && inches) {
    2.92 +                    size_t len = SDL_strlen(display_name);
    2.93 +                    SDL_snprintf(&display_name[len], sizeof(display_name)-len, " %d\"", inches);
    2.94 +                }
    2.95 +#ifdef X11MODES_DEBUG
    2.96 +                printf("Display name: %s\n", display_name);
    2.97 +#endif
    2.98 +
    2.99                  XRRFreeOutputInfo(output_info);
   2.100                  XRRFreeCrtcInfo(crtc);
   2.101                  break;
   2.102 @@ -583,6 +637,9 @@
   2.103  #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
   2.104  
   2.105          SDL_zero(display);
   2.106 +        if (*display_name) {
   2.107 +            display.name = display_name;
   2.108 +        }
   2.109          display.desktop_mode = mode;
   2.110          display.current_mode = mode;
   2.111          display.driverdata = displaydata;
     3.1 --- a/src/video/x11/SDL_x11sym.h	Mon Dec 31 16:29:01 2012 -0800
     3.2 +++ b/src/video/x11/SDL_x11sym.h	Mon Dec 31 18:32:30 2012 -0800
     3.3 @@ -265,6 +265,9 @@
     3.4  SDL_X11_SYM(XRRCrtcInfo *,XRRGetCrtcInfo,(Display *dpy, XRRScreenResources *resources, RRCrtc crtc),(dpy,resources,crtc),return)
     3.5  SDL_X11_SYM(void,XRRFreeCrtcInfo,(XRRCrtcInfo *crtcInfo),(crtcInfo),)
     3.6  SDL_X11_SYM(Status,XRRSetCrtcConfig,(Display *dpy, XRRScreenResources *resources, RRCrtc crtc, Time timestamp, int x, int y, RRMode mode, Rotation rotation, RROutput *outputs, int noutputs),(dpy,resources,crtc,timestamp,x,y,mode,rotation,outputs,noutputs),return)
     3.7 +SDL_X11_SYM(Atom*,XRRListOutputProperties,(Display *dpy, RROutput output, int *nprop),(dpy,output,nprop),return)
     3.8 +SDL_X11_SYM(XRRPropertyInfo*,XRRQueryOutputProperty,(Display *dpy,RROutput output, Atom property),(dpy,output,property),return)
     3.9 +SDL_X11_SYM(int,XRRGetOutputProperty,(Display *dpy,RROutput output, Atom property, long offset, long length, Bool _delete, Bool pending, Atom req_type, Atom *actual_type, int *actual_format, unsigned long *nitems, unsigned long *bytes_after, unsigned char **prop),(dpy,output,property,offset,length, _delete, pending, req_type, actual_type, actual_format, nitems, bytes_after, prop),return)
    3.10  #endif
    3.11  
    3.12  /* MIT-SCREEN-SAVER support */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/x11/edid-parse.c	Mon Dec 31 18:32:30 2012 -0800
     4.3 @@ -0,0 +1,760 @@
     4.4 +/*
     4.5 + * Copyright 2007 Red Hat, Inc.
     4.6 + *
     4.7 + * Permission is hereby granted, free of charge, to any person obtaining a
     4.8 + * copy of this software and associated documentation files (the "Software"),
     4.9 + * to deal in the Software without restriction, including without limitation
    4.10 + * on the rights to use, copy, modify, merge, publish, distribute, sub
    4.11 + * license, and/or sell copies of the Software, and to permit persons to whom
    4.12 + * the Software is furnished to do so, subject to the following conditions:
    4.13 + *
    4.14 + * The above copyright notice and this permission notice (including the next
    4.15 + * paragraph) shall be included in all copies or substantial portions of the
    4.16 + * Software.
    4.17 + *
    4.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    4.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    4.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
    4.21 + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
    4.22 + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    4.23 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    4.24 + */
    4.25 +
    4.26 +/* Author: Soren Sandmann <sandmann@redhat.com> */
    4.27 +
    4.28 +#include "edid.h"
    4.29 +#include <stdlib.h>
    4.30 +#include <string.h>
    4.31 +#include <math.h>
    4.32 +
    4.33 +#define TRUE 1
    4.34 +#define FALSE 0
    4.35 +
    4.36 +static int
    4.37 +get_bit (int in, int bit)
    4.38 +{
    4.39 +    return (in & (1 << bit)) >> bit;
    4.40 +}
    4.41 +
    4.42 +static int
    4.43 +get_bits (int in, int begin, int end)
    4.44 +{
    4.45 +    int mask = (1 << (end - begin + 1)) - 1;
    4.46 +    
    4.47 +    return (in >> begin) & mask;
    4.48 +}
    4.49 +
    4.50 +static int
    4.51 +decode_header (const uchar *edid)
    4.52 +{
    4.53 +    if (memcmp (edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0)
    4.54 +	return TRUE;
    4.55 +    return FALSE;
    4.56 +}
    4.57 +
    4.58 +static int
    4.59 +decode_vendor_and_product_identification (const uchar *edid, MonitorInfo *info)
    4.60 +{
    4.61 +    int is_model_year;
    4.62 +    
    4.63 +    /* Manufacturer Code */
    4.64 +    info->manufacturer_code[0]  = get_bits (edid[0x08], 2, 6);
    4.65 +    info->manufacturer_code[1]  = get_bits (edid[0x08], 0, 1) << 3;
    4.66 +    info->manufacturer_code[1] |= get_bits (edid[0x09], 5, 7);
    4.67 +    info->manufacturer_code[2]  = get_bits (edid[0x09], 0, 4);
    4.68 +    info->manufacturer_code[3]  = '\0';
    4.69 +    
    4.70 +    info->manufacturer_code[0] += 'A' - 1;
    4.71 +    info->manufacturer_code[1] += 'A' - 1;
    4.72 +    info->manufacturer_code[2] += 'A' - 1;
    4.73 +
    4.74 +    /* Product Code */
    4.75 +    info->product_code = edid[0x0b] << 8 | edid[0x0a];
    4.76 +
    4.77 +    /* Serial Number */
    4.78 +    info->serial_number =
    4.79 +	edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | edid[0x0f] << 24;
    4.80 +
    4.81 +    /* Week and Year */
    4.82 +    is_model_year = FALSE;
    4.83 +    switch (edid[0x10])
    4.84 +    {
    4.85 +    case 0x00:
    4.86 +	info->production_week = -1;
    4.87 +	break;
    4.88 +
    4.89 +    case 0xff:
    4.90 +	info->production_week = -1;
    4.91 +	is_model_year = TRUE;
    4.92 +	break;
    4.93 +
    4.94 +    default:
    4.95 +	info->production_week = edid[0x10];
    4.96 +	break;
    4.97 +    }
    4.98 +
    4.99 +    if (is_model_year)
   4.100 +    {
   4.101 +	info->production_year = -1;
   4.102 +	info->model_year = 1990 + edid[0x11];
   4.103 +    }
   4.104 +    else
   4.105 +    {
   4.106 +	info->production_year = 1990 + edid[0x11];
   4.107 +	info->model_year = -1;
   4.108 +    }
   4.109 +
   4.110 +    return TRUE;
   4.111 +}
   4.112 +
   4.113 +static int
   4.114 +decode_edid_version (const uchar *edid, MonitorInfo *info)
   4.115 +{
   4.116 +    info->major_version = edid[0x12];
   4.117 +    info->minor_version = edid[0x13];
   4.118 +
   4.119 +    return TRUE;
   4.120 +}
   4.121 +
   4.122 +static int
   4.123 +decode_display_parameters (const uchar *edid, MonitorInfo *info)
   4.124 +{
   4.125 +    /* Digital vs Analog */
   4.126 +    info->is_digital = get_bit (edid[0x14], 7);
   4.127 +
   4.128 +    if (info->is_digital)
   4.129 +    {
   4.130 +	int bits;
   4.131 +	
   4.132 +	static const int bit_depth[8] =
   4.133 +	{
   4.134 +	    -1, 6, 8, 10, 12, 14, 16, -1
   4.135 +	};
   4.136 +
   4.137 +	static const Interface interfaces[6] =
   4.138 +	{
   4.139 +	    UNDEFINED, DVI, HDMI_A, HDMI_B, MDDI, DISPLAY_PORT
   4.140 +	};
   4.141 +
   4.142 +	bits = get_bits (edid[0x14], 4, 6);
   4.143 +	info->digital.bits_per_primary = bit_depth[bits];
   4.144 +
   4.145 +	bits = get_bits (edid[0x14], 0, 3);
   4.146 +	
   4.147 +	if (bits <= 5)
   4.148 +	    info->digital.interface = interfaces[bits];
   4.149 +	else
   4.150 +	    info->digital.interface = UNDEFINED;
   4.151 +    }
   4.152 +    else
   4.153 +    {
   4.154 +	int bits = get_bits (edid[0x14], 5, 6);
   4.155 +	
   4.156 +	static const double levels[][3] =
   4.157 +	{
   4.158 +	    { 0.7,   0.3,    1.0 },
   4.159 +	    { 0.714, 0.286,  1.0 },
   4.160 +	    { 1.0,   0.4,    1.4 },
   4.161 +	    { 0.7,   0.0,    0.7 },
   4.162 +	};
   4.163 +
   4.164 +	info->analog.video_signal_level = levels[bits][0];
   4.165 +	info->analog.sync_signal_level = levels[bits][1];
   4.166 +	info->analog.total_signal_level = levels[bits][2];
   4.167 +
   4.168 +	info->analog.blank_to_black = get_bit (edid[0x14], 4);
   4.169 +
   4.170 +	info->analog.separate_hv_sync = get_bit (edid[0x14], 3);
   4.171 +	info->analog.composite_sync_on_h = get_bit (edid[0x14], 2);
   4.172 +	info->analog.composite_sync_on_green = get_bit (edid[0x14], 1);
   4.173 +
   4.174 +	info->analog.serration_on_vsync = get_bit (edid[0x14], 0);
   4.175 +    }
   4.176 +
   4.177 +    /* Screen Size / Aspect Ratio */
   4.178 +    if (edid[0x15] == 0 && edid[0x16] == 0)
   4.179 +    {
   4.180 +	info->width_mm = -1;
   4.181 +	info->height_mm = -1;
   4.182 +	info->aspect_ratio = -1.0;
   4.183 +    }
   4.184 +    else if (edid[0x16] == 0)
   4.185 +    {
   4.186 +	info->width_mm = -1;
   4.187 +	info->height_mm = -1; 
   4.188 +	info->aspect_ratio = 100.0 / (edid[0x15] + 99);
   4.189 +    }
   4.190 +    else if (edid[0x15] == 0)
   4.191 +    {
   4.192 +	info->width_mm = -1;
   4.193 +	info->height_mm = -1;
   4.194 +	info->aspect_ratio = 100.0 / (edid[0x16] + 99);
   4.195 +	info->aspect_ratio = 1/info->aspect_ratio; /* portrait */
   4.196 +    }
   4.197 +    else
   4.198 +    {
   4.199 +	info->width_mm = 10 * edid[0x15];
   4.200 +	info->height_mm = 10 * edid[0x16];
   4.201 +    }
   4.202 +
   4.203 +    /* Gamma */
   4.204 +    if (edid[0x17] == 0xFF)
   4.205 +	info->gamma = -1.0;
   4.206 +    else
   4.207 +	info->gamma = (edid[0x17] + 100.0) / 100.0;
   4.208 +
   4.209 +    /* Features */
   4.210 +    info->standby = get_bit (edid[0x18], 7);
   4.211 +    info->suspend = get_bit (edid[0x18], 6);
   4.212 +    info->active_off = get_bit (edid[0x18], 5);
   4.213 +
   4.214 +    if (info->is_digital)
   4.215 +    {
   4.216 +	info->digital.rgb444 = TRUE;
   4.217 +	if (get_bit (edid[0x18], 3))
   4.218 +	    info->digital.ycrcb444 = 1;
   4.219 +	if (get_bit (edid[0x18], 4))
   4.220 +	    info->digital.ycrcb422 = 1;
   4.221 +    }
   4.222 +    else
   4.223 +    {
   4.224 +	int bits = get_bits (edid[0x18], 3, 4);
   4.225 +	ColorType color_type[4] =
   4.226 +	{
   4.227 +	    MONOCHROME, RGB, OTHER_COLOR, UNDEFINED_COLOR
   4.228 +	};
   4.229 +
   4.230 +	info->analog.color_type = color_type[bits];
   4.231 +    }
   4.232 +
   4.233 +    info->srgb_is_standard = get_bit (edid[0x18], 2);
   4.234 +
   4.235 +    /* In 1.3 this is called "has preferred timing" */
   4.236 +    info->preferred_timing_includes_native = get_bit (edid[0x18], 1);
   4.237 +
   4.238 +    /* FIXME: In 1.3 this indicates whether the monitor accepts GTF */
   4.239 +    info->continuous_frequency = get_bit (edid[0x18], 0);
   4.240 +    return TRUE;
   4.241 +}
   4.242 +
   4.243 +static double
   4.244 +decode_fraction (int high, int low)
   4.245 +{
   4.246 +    double result = 0.0;
   4.247 +    int i;
   4.248 +
   4.249 +    high = (high << 2) | low;
   4.250 +
   4.251 +    for (i = 0; i < 10; ++i)
   4.252 +	result += get_bit (high, i) * pow (2, i - 10);
   4.253 +
   4.254 +    return result;
   4.255 +}
   4.256 +
   4.257 +static int
   4.258 +decode_color_characteristics (const uchar *edid, MonitorInfo *info)
   4.259 +{
   4.260 +    info->red_x = decode_fraction (edid[0x1b], get_bits (edid[0x19], 6, 7));
   4.261 +    info->red_y = decode_fraction (edid[0x1c], get_bits (edid[0x19], 5, 4));
   4.262 +    info->green_x = decode_fraction (edid[0x1d], get_bits (edid[0x19], 2, 3));
   4.263 +    info->green_y = decode_fraction (edid[0x1e], get_bits (edid[0x19], 0, 1));
   4.264 +    info->blue_x = decode_fraction (edid[0x1f], get_bits (edid[0x1a], 6, 7));
   4.265 +    info->blue_y = decode_fraction (edid[0x20], get_bits (edid[0x1a], 4, 5));
   4.266 +    info->white_x = decode_fraction (edid[0x21], get_bits (edid[0x1a], 2, 3));
   4.267 +    info->white_y = decode_fraction (edid[0x22], get_bits (edid[0x1a], 0, 1));
   4.268 +
   4.269 +    return TRUE;
   4.270 +}
   4.271 +
   4.272 +static int
   4.273 +decode_established_timings (const uchar *edid, MonitorInfo *info)
   4.274 +{
   4.275 +    static const Timing established[][8] = 
   4.276 +    {
   4.277 +	{
   4.278 +	    { 800, 600, 60 },
   4.279 +	    { 800, 600, 56 },
   4.280 +	    { 640, 480, 75 },
   4.281 +	    { 640, 480, 72 },
   4.282 +	    { 640, 480, 67 },
   4.283 +	    { 640, 480, 60 },
   4.284 +	    { 720, 400, 88 },
   4.285 +	    { 720, 400, 70 }
   4.286 +	},
   4.287 +	{
   4.288 +	    { 1280, 1024, 75 },
   4.289 +	    { 1024, 768, 75 },
   4.290 +	    { 1024, 768, 70 },
   4.291 +	    { 1024, 768, 60 },
   4.292 +	    { 1024, 768, 87 },
   4.293 +	    { 832, 624, 75 },
   4.294 +	    { 800, 600, 75 },
   4.295 +	    { 800, 600, 72 }
   4.296 +	},
   4.297 +	{
   4.298 +	    { 0, 0, 0 },
   4.299 +	    { 0, 0, 0 },
   4.300 +	    { 0, 0, 0 },
   4.301 +	    { 0, 0, 0 },
   4.302 +	    { 0, 0, 0 },
   4.303 +	    { 0, 0, 0 },
   4.304 +	    { 0, 0, 0 },
   4.305 +	    { 1152, 870, 75 }
   4.306 +	},
   4.307 +    };
   4.308 +
   4.309 +    int i, j, idx;
   4.310 +
   4.311 +    idx = 0;
   4.312 +    for (i = 0; i < 3; ++i)
   4.313 +    {
   4.314 +	for (j = 0; j < 8; ++j)
   4.315 +	{
   4.316 +	    int byte = edid[0x23 + i];
   4.317 +
   4.318 +	    if (get_bit (byte, j) && established[i][j].frequency != 0)
   4.319 +		info->established[idx++] = established[i][j];
   4.320 +	}
   4.321 +    }
   4.322 +    return TRUE;
   4.323 +}
   4.324 +
   4.325 +static int
   4.326 +decode_standard_timings (const uchar *edid, MonitorInfo *info)
   4.327 +{
   4.328 +    int i;
   4.329 +    
   4.330 +    for (i = 0; i < 8; i++)
   4.331 +    {
   4.332 +	int first = edid[0x26 + 2 * i];
   4.333 +	int second = edid[0x27 + 2 * i];
   4.334 +
   4.335 +	if (first != 0x01 && second != 0x01)
   4.336 +	{
   4.337 +	    int w = 8 * (first + 31);
   4.338 +	    int h;
   4.339 +
   4.340 +	    switch (get_bits (second, 6, 7))
   4.341 +	    {
   4.342 +	    case 0x00: h = (w / 16) * 10; break;
   4.343 +	    case 0x01: h = (w / 4) * 3; break;
   4.344 +	    case 0x02: h = (w / 5) * 4; break;
   4.345 +	    case 0x03: h = (w / 16) * 9; break;
   4.346 +	    }
   4.347 +
   4.348 +	    info->standard[i].width = w;
   4.349 +	    info->standard[i].height = h;
   4.350 +	    info->standard[i].frequency = get_bits (second, 0, 5) + 60;
   4.351 +	}
   4.352 +    }
   4.353 +    
   4.354 +    return TRUE;
   4.355 +}
   4.356 +
   4.357 +static void
   4.358 +decode_lf_string (const uchar *s, int n_chars, char *result)
   4.359 +{
   4.360 +    int i;
   4.361 +    for (i = 0; i < n_chars; ++i)
   4.362 +    {
   4.363 +	if (s[i] == 0x0a)
   4.364 +	{
   4.365 +	    *result++ = '\0';
   4.366 +	    break;
   4.367 +	}
   4.368 +	else if (s[i] == 0x00)
   4.369 +	{
   4.370 +	    /* Convert embedded 0's to spaces */
   4.371 +	    *result++ = ' ';
   4.372 +	}
   4.373 +	else
   4.374 +	{
   4.375 +	    *result++ = s[i];
   4.376 +	}
   4.377 +    }
   4.378 +}
   4.379 +
   4.380 +static void
   4.381 +decode_display_descriptor (const uchar *desc,
   4.382 +			   MonitorInfo *info)
   4.383 +{
   4.384 +    switch (desc[0x03])
   4.385 +    {
   4.386 +    case 0xFC:
   4.387 +	decode_lf_string (desc + 5, 13, info->dsc_product_name);
   4.388 +	break;
   4.389 +    case 0xFF:
   4.390 +	decode_lf_string (desc + 5, 13, info->dsc_serial_number);
   4.391 +	break;
   4.392 +    case 0xFE:
   4.393 +	decode_lf_string (desc + 5, 13, info->dsc_string);
   4.394 +	break;
   4.395 +    case 0xFD:
   4.396 +	/* Range Limits */
   4.397 +	break;
   4.398 +    case 0xFB:
   4.399 +	/* Color Point */
   4.400 +	break;
   4.401 +    case 0xFA:
   4.402 +	/* Timing Identifications */
   4.403 +	break;
   4.404 +    case 0xF9:
   4.405 +	/* Color Management */
   4.406 +	break;
   4.407 +    case 0xF8:
   4.408 +	/* Timing Codes */
   4.409 +	break;
   4.410 +    case 0xF7:
   4.411 +	/* Established Timings */
   4.412 +	break;
   4.413 +    case 0x10:
   4.414 +	break;
   4.415 +    }
   4.416 +}
   4.417 +
   4.418 +static void
   4.419 +decode_detailed_timing (const uchar *timing,
   4.420 +			DetailedTiming *detailed)
   4.421 +{
   4.422 +    int bits;
   4.423 +    StereoType stereo[] =
   4.424 +    {
   4.425 +	NO_STEREO, NO_STEREO, FIELD_RIGHT, FIELD_LEFT,
   4.426 +	TWO_WAY_RIGHT_ON_EVEN, TWO_WAY_LEFT_ON_EVEN,
   4.427 +	FOUR_WAY_INTERLEAVED, SIDE_BY_SIDE
   4.428 +    };
   4.429 +    
   4.430 +    detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000;
   4.431 +    detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4);
   4.432 +    detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8);
   4.433 +    detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4);
   4.434 +    detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8);
   4.435 +    detailed->h_front_porch = timing[0x08] | get_bits (timing[0x0b], 6, 7) << 8;
   4.436 +    detailed->h_sync = timing[0x09] | get_bits (timing[0x0b], 4, 5) << 8;
   4.437 +    detailed->v_front_porch =
   4.438 +	get_bits (timing[0x0a], 4, 7) | get_bits (timing[0x0b], 2, 3) << 4;
   4.439 +    detailed->v_sync =
   4.440 +	get_bits (timing[0x0a], 0, 3) | get_bits (timing[0x0b], 0, 1) << 4;
   4.441 +    detailed->width_mm =  timing[0x0c] | get_bits (timing[0x0e], 4, 7) << 8;
   4.442 +    detailed->height_mm = timing[0x0d] | get_bits (timing[0x0e], 0, 3) << 8;
   4.443 +    detailed->right_border = timing[0x0f];
   4.444 +    detailed->top_border = timing[0x10];
   4.445 +
   4.446 +    detailed->interlaced = get_bit (timing[0x11], 7);
   4.447 +
   4.448 +    /* Stereo */
   4.449 +    bits = get_bits (timing[0x11], 5, 6) << 1 | get_bit (timing[0x11], 0);
   4.450 +    detailed->stereo = stereo[bits];
   4.451 +
   4.452 +    /* Sync */
   4.453 +    bits = timing[0x11];
   4.454 +
   4.455 +    detailed->digital_sync = get_bit (bits, 4);
   4.456 +    if (detailed->digital_sync)
   4.457 +    {
   4.458 +	detailed->digital.composite = !get_bit (bits, 3);
   4.459 +
   4.460 +	if (detailed->digital.composite)
   4.461 +	{
   4.462 +	    detailed->digital.serrations = get_bit (bits, 2);
   4.463 +	    detailed->digital.negative_vsync = FALSE;
   4.464 +	}
   4.465 +	else
   4.466 +	{
   4.467 +	    detailed->digital.serrations = FALSE;
   4.468 +	    detailed->digital.negative_vsync = !get_bit (bits, 2);
   4.469 +	}
   4.470 +
   4.471 +	detailed->digital.negative_hsync = !get_bit (bits, 0);
   4.472 +    }
   4.473 +    else
   4.474 +    {
   4.475 +	detailed->analog.bipolar = get_bit (bits, 3);
   4.476 +	detailed->analog.serrations = get_bit (bits, 2);
   4.477 +	detailed->analog.sync_on_green = !get_bit (bits, 1);
   4.478 +    }
   4.479 +}
   4.480 +
   4.481 +static int
   4.482 +decode_descriptors (const uchar *edid, MonitorInfo *info)
   4.483 +{
   4.484 +    int i;
   4.485 +    int timing_idx;
   4.486 +    
   4.487 +    timing_idx = 0;
   4.488 +    
   4.489 +    for (i = 0; i < 4; ++i)
   4.490 +    {
   4.491 +	int index = 0x36 + i * 18;
   4.492 +
   4.493 +	if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00)
   4.494 +	{
   4.495 +	    decode_display_descriptor (edid + index, info);
   4.496 +	}
   4.497 +	else
   4.498 +	{
   4.499 +	    decode_detailed_timing (
   4.500 +		edid + index, &(info->detailed_timings[timing_idx++]));
   4.501 +	}
   4.502 +    }
   4.503 +
   4.504 +    info->n_detailed_timings = timing_idx;
   4.505 +
   4.506 +    return TRUE;
   4.507 +}
   4.508 +
   4.509 +static void
   4.510 +decode_check_sum (const uchar *edid,
   4.511 +		  MonitorInfo *info)
   4.512 +{
   4.513 +    int i;
   4.514 +    uchar check = 0;
   4.515 +
   4.516 +    for (i = 0; i < 128; ++i)
   4.517 +	check += edid[i];
   4.518 +
   4.519 +    info->checksum = check;
   4.520 +}
   4.521 +
   4.522 +MonitorInfo *
   4.523 +decode_edid (const uchar *edid)
   4.524 +{
   4.525 +    MonitorInfo *info = calloc (1, sizeof (MonitorInfo));
   4.526 +
   4.527 +    decode_check_sum (edid, info);
   4.528 +    
   4.529 +    if (!decode_header (edid))
   4.530 +	return NULL;
   4.531 +
   4.532 +    if (!decode_vendor_and_product_identification (edid, info))
   4.533 +	return NULL;
   4.534 +
   4.535 +    if (!decode_edid_version (edid, info))
   4.536 +	return NULL;
   4.537 +
   4.538 +    if (!decode_display_parameters (edid, info))
   4.539 +	return NULL;
   4.540 +
   4.541 +    if (!decode_color_characteristics (edid, info))
   4.542 +	return NULL;
   4.543 +
   4.544 +    if (!decode_established_timings (edid, info))
   4.545 +	return NULL;
   4.546 +
   4.547 +    if (!decode_standard_timings (edid, info))
   4.548 +	return NULL;
   4.549 +    
   4.550 +    if (!decode_descriptors (edid, info))
   4.551 +	return NULL;
   4.552 +    
   4.553 +    return info;
   4.554 +}
   4.555 +
   4.556 +static const char *
   4.557 +yesno (int v)
   4.558 +{
   4.559 +    return v? "yes" : "no";
   4.560 +}
   4.561 +
   4.562 +void
   4.563 +dump_monitor_info (MonitorInfo *info)
   4.564 +{
   4.565 +    char *s;
   4.566 +    int i;
   4.567 +    
   4.568 +    printf ("Checksum: %d (%s)\n",
   4.569 +	    info->checksum, info->checksum? "incorrect" : "correct");
   4.570 +    printf ("Manufacturer Code: %s\n", info->manufacturer_code);
   4.571 +    printf ("Product Code: 0x%x\n", info->product_code);
   4.572 +    printf ("Serial Number: %u\n", info->serial_number);
   4.573 +    
   4.574 +    if (info->production_week != -1)
   4.575 +	printf ("Production Week: %d\n", info->production_week);
   4.576 +    else
   4.577 +	printf ("Production Week: unspecified\n");
   4.578 +    
   4.579 +    if (info->production_year != -1)
   4.580 +	printf ("Production Year: %d\n", info->production_year);
   4.581 +    else
   4.582 +	printf ("Production Year: unspecified\n");
   4.583 +    
   4.584 +    if (info->model_year != -1)
   4.585 +	printf ("Model Year: %d\n", info->model_year);
   4.586 +    else
   4.587 +	printf ("Model Year: unspecified\n");
   4.588 +    
   4.589 +    printf ("EDID revision: %d.%d\n", info->major_version, info->minor_version);
   4.590 +    
   4.591 +    printf ("Display is %s\n", info->is_digital? "digital" : "analog");
   4.592 +    if (info->is_digital)
   4.593 +    {
   4.594 +	const char *interface;
   4.595 +	if (info->digital.bits_per_primary != -1)
   4.596 +	    printf ("Bits Per Primary: %d\n", info->digital.bits_per_primary);
   4.597 +	else
   4.598 +	    printf ("Bits Per Primary: undefined\n");
   4.599 +	
   4.600 +	switch (info->digital.interface)
   4.601 +	{
   4.602 +	case DVI: interface = "DVI"; break;
   4.603 +	case HDMI_A: interface = "HDMI-a"; break;
   4.604 +	case HDMI_B: interface = "HDMI-b"; break;
   4.605 +	case MDDI: interface = "MDDI"; break;
   4.606 +	case DISPLAY_PORT: interface = "DisplayPort"; break;
   4.607 +	case UNDEFINED: interface = "undefined"; break;
   4.608 +	}
   4.609 +	printf ("Interface: %s\n", interface);
   4.610 +	
   4.611 +	printf ("RGB 4:4:4: %s\n", yesno (info->digital.rgb444));
   4.612 +	printf ("YCrCb 4:4:4: %s\n", yesno (info->digital.ycrcb444));
   4.613 +	printf ("YCrCb 4:2:2: %s\n", yesno (info->digital.ycrcb422));
   4.614 +    }
   4.615 +    else
   4.616 +    {
   4.617 +	printf ("Video Signal Level: %f\n", info->analog.video_signal_level);
   4.618 +	printf ("Sync Signal Level: %f\n", info->analog.sync_signal_level);
   4.619 +	printf ("Total Signal Level: %f\n", info->analog.total_signal_level);
   4.620 +	
   4.621 +	printf ("Blank to Black: %s\n",
   4.622 +		yesno (info->analog.blank_to_black));
   4.623 +	printf ("Separate HV Sync: %s\n",
   4.624 +		yesno (info->analog.separate_hv_sync));
   4.625 +	printf ("Composite Sync on H: %s\n",
   4.626 +		yesno (info->analog.composite_sync_on_h));
   4.627 +	printf ("Serration on VSync: %s\n",
   4.628 +		yesno (info->analog.serration_on_vsync));
   4.629 +	
   4.630 +	switch (info->analog.color_type)
   4.631 +	{
   4.632 +	case UNDEFINED_COLOR: s = "undefined"; break;
   4.633 +	case MONOCHROME: s = "monochrome"; break;
   4.634 +	case RGB: s = "rgb"; break;
   4.635 +	case OTHER_COLOR: s = "other color"; break;
   4.636 +	};
   4.637 +	
   4.638 +	printf ("Color: %s\n", s);
   4.639 +    }
   4.640 +    
   4.641 +    if (info->width_mm == -1)
   4.642 +	printf ("Width: undefined\n");
   4.643 +    else
   4.644 +	printf ("Width: %d mm\n", info->width_mm);
   4.645 +    
   4.646 +    if (info->height_mm == -1)
   4.647 +	printf ("Height: undefined\n");
   4.648 +    else
   4.649 +	printf ("Height: %d mm\n", info->height_mm);
   4.650 +    
   4.651 +    if (info->aspect_ratio > 0)
   4.652 +	printf ("Aspect Ratio: %f\n", info->aspect_ratio);
   4.653 +    else
   4.654 +	printf ("Aspect Ratio: undefined\n");
   4.655 +    
   4.656 +    if (info->gamma >= 0)
   4.657 +	printf ("Gamma: %f\n", info->gamma);
   4.658 +    else
   4.659 +	printf ("Gamma: undefined\n");
   4.660 +    
   4.661 +    printf ("Standby: %s\n", yesno (info->standby));
   4.662 +    printf ("Suspend: %s\n", yesno (info->suspend));
   4.663 +    printf ("Active Off: %s\n", yesno (info->active_off));
   4.664 +    
   4.665 +    printf ("SRGB is Standard: %s\n", yesno (info->srgb_is_standard));
   4.666 +    printf ("Preferred Timing Includes Native: %s\n",
   4.667 +	    yesno (info->preferred_timing_includes_native));
   4.668 +    printf ("Continuous Frequency: %s\n", yesno (info->continuous_frequency));
   4.669 +    
   4.670 +    printf ("Red X: %f\n", info->red_x);
   4.671 +    printf ("Red Y: %f\n", info->red_y);
   4.672 +    printf ("Green X: %f\n", info->green_x);
   4.673 +    printf ("Green Y: %f\n", info->green_y);
   4.674 +    printf ("Blue X: %f\n", info->blue_x);
   4.675 +    printf ("Blue Y: %f\n", info->blue_y);
   4.676 +    printf ("White X: %f\n", info->white_x);
   4.677 +    printf ("White Y: %f\n", info->white_y);
   4.678 +    
   4.679 +    printf ("Established Timings:\n");
   4.680 +    
   4.681 +    for (i = 0; i < 24; ++i)
   4.682 +    {
   4.683 +	Timing *timing = &(info->established[i]);
   4.684 +	
   4.685 +	if (timing->frequency == 0)
   4.686 +	    break;
   4.687 +	
   4.688 +	printf ("  %d x %d @ %d Hz\n",
   4.689 +		timing->width, timing->height, timing->frequency);
   4.690 +	
   4.691 +    }
   4.692 +    
   4.693 +    printf ("Standard Timings:\n");
   4.694 +    for (i = 0; i < 8; ++i)
   4.695 +    {
   4.696 +	Timing *timing = &(info->standard[i]);
   4.697 +	
   4.698 +	if (timing->frequency == 0)
   4.699 +	    break;
   4.700 +	
   4.701 +	printf ("  %d x %d @ %d Hz\n",
   4.702 +		timing->width, timing->height, timing->frequency);
   4.703 +    }
   4.704 +    
   4.705 +    for (i = 0; i < info->n_detailed_timings; ++i)
   4.706 +    {
   4.707 +	DetailedTiming *timing = &(info->detailed_timings[i]);
   4.708 +	const char *s;
   4.709 +	
   4.710 +	printf ("Timing%s: \n",
   4.711 +		(i == 0 && info->preferred_timing_includes_native)?
   4.712 +		" (Preferred)" : "");
   4.713 +	printf ("  Pixel Clock: %d\n", timing->pixel_clock);
   4.714 +	printf ("  H Addressable: %d\n", timing->h_addr);
   4.715 +	printf ("  H Blank: %d\n", timing->h_blank);
   4.716 +	printf ("  H Front Porch: %d\n", timing->h_front_porch);
   4.717 +	printf ("  H Sync: %d\n", timing->h_sync);
   4.718 +	printf ("  V Addressable: %d\n", timing->v_addr);
   4.719 +	printf ("  V Blank: %d\n", timing->v_blank);
   4.720 +	printf ("  V Front Porch: %d\n", timing->v_front_porch);
   4.721 +	printf ("  V Sync: %d\n", timing->v_sync);
   4.722 +	printf ("  Width: %d mm\n", timing->width_mm);
   4.723 +	printf ("  Height: %d mm\n", timing->height_mm);
   4.724 +	printf ("  Right Border: %d\n", timing->right_border);
   4.725 +	printf ("  Top Border: %d\n", timing->top_border);
   4.726 +	switch (timing->stereo)
   4.727 +	{
   4.728 +	case NO_STEREO:   s = "No Stereo"; break;
   4.729 +	case FIELD_RIGHT: s = "Field Sequential, Right on Sync"; break;
   4.730 +	case FIELD_LEFT:  s = "Field Sequential, Left on Sync"; break;
   4.731 +	case TWO_WAY_RIGHT_ON_EVEN: s = "Two-way, Right on Even"; break;
   4.732 +	case TWO_WAY_LEFT_ON_EVEN:  s = "Two-way, Left on Even"; break;
   4.733 +	case FOUR_WAY_INTERLEAVED:  s = "Four-way Interleaved"; break;
   4.734 +	case SIDE_BY_SIDE:          s = "Side-by-Side"; break;
   4.735 +	}
   4.736 +	printf ("  Stereo: %s\n", s);
   4.737 +	
   4.738 +	if (timing->digital_sync)
   4.739 +	{
   4.740 +	    printf ("  Digital Sync:\n");
   4.741 +	    printf ("    composite: %s\n", yesno (timing->digital.composite));
   4.742 +	    printf ("    serrations: %s\n", yesno (timing->digital.serrations));
   4.743 +	    printf ("    negative vsync: %s\n",
   4.744 +		    yesno (timing->digital.negative_vsync));
   4.745 +	    printf ("    negative hsync: %s\n",
   4.746 +		    yesno (timing->digital.negative_hsync));
   4.747 +	}
   4.748 +	else
   4.749 +	{
   4.750 +	    printf ("  Analog Sync:\n");
   4.751 +	    printf ("    bipolar: %s\n", yesno (timing->analog.bipolar));
   4.752 +	    printf ("    serrations: %s\n", yesno (timing->analog.serrations));
   4.753 +	    printf ("    sync on green: %s\n", yesno (
   4.754 +			timing->analog.sync_on_green));
   4.755 +	}
   4.756 +    }
   4.757 +    
   4.758 +    printf ("Detailed Product information:\n");
   4.759 +    printf ("  Product Name: %s\n", info->dsc_product_name);
   4.760 +    printf ("  Serial Number: %s\n", info->dsc_serial_number);
   4.761 +    printf ("  Unspecified String: %s\n", info->dsc_string);
   4.762 +}
   4.763 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/x11/edid.h	Mon Dec 31 18:32:30 2012 -0800
     5.3 @@ -0,0 +1,171 @@
     5.4 +typedef unsigned char uchar;
     5.5 +typedef struct MonitorInfo MonitorInfo;
     5.6 +typedef struct Timing Timing;
     5.7 +typedef struct DetailedTiming DetailedTiming;
     5.8 +
     5.9 +typedef enum
    5.10 +{
    5.11 +    UNDEFINED,
    5.12 +    DVI,
    5.13 +    HDMI_A,
    5.14 +    HDMI_B,
    5.15 +    MDDI,
    5.16 +    DISPLAY_PORT
    5.17 +} Interface;
    5.18 +
    5.19 +typedef enum
    5.20 +{
    5.21 +    UNDEFINED_COLOR,
    5.22 +    MONOCHROME,
    5.23 +    RGB,
    5.24 +    OTHER_COLOR
    5.25 +} ColorType;
    5.26 +
    5.27 +typedef enum
    5.28 +{
    5.29 +    NO_STEREO,
    5.30 +    FIELD_RIGHT,
    5.31 +    FIELD_LEFT,
    5.32 +    TWO_WAY_RIGHT_ON_EVEN,
    5.33 +    TWO_WAY_LEFT_ON_EVEN,
    5.34 +    FOUR_WAY_INTERLEAVED,
    5.35 +    SIDE_BY_SIDE
    5.36 +} StereoType;
    5.37 +
    5.38 +struct Timing
    5.39 +{
    5.40 +    int width;
    5.41 +    int height;
    5.42 +    int frequency;
    5.43 +};
    5.44 +
    5.45 +struct DisplayDescriptor
    5.46 +{
    5.47 +};
    5.48 +
    5.49 +struct DetailedTiming
    5.50 +{
    5.51 +    int		pixel_clock;
    5.52 +    int		h_addr;
    5.53 +    int		h_blank;
    5.54 +    int		h_sync;
    5.55 +    int		h_front_porch;
    5.56 +    int		v_addr;
    5.57 +    int		v_blank;
    5.58 +    int		v_sync;
    5.59 +    int		v_front_porch;
    5.60 +    int		width_mm;
    5.61 +    int		height_mm;
    5.62 +    int		right_border;
    5.63 +    int		top_border;
    5.64 +    int		interlaced;
    5.65 +    StereoType	stereo;
    5.66 +
    5.67 +    int		digital_sync;
    5.68 +    union
    5.69 +    {
    5.70 +	struct
    5.71 +	{
    5.72 +	    int bipolar;
    5.73 +	    int serrations;
    5.74 +	    int sync_on_green;
    5.75 +	} analog;
    5.76 +
    5.77 +	struct
    5.78 +	{
    5.79 +	    int composite;
    5.80 +	    int serrations;
    5.81 +	    int negative_vsync;
    5.82 +	    int negative_hsync;
    5.83 +	} digital;
    5.84 +    };
    5.85 +};
    5.86 +
    5.87 +struct MonitorInfo
    5.88 +{
    5.89 +    int			checksum;
    5.90 +    char		manufacturer_code[4];
    5.91 +    int			product_code;
    5.92 +    unsigned int	serial_number;
    5.93 +    
    5.94 +    int			production_week;	/* -1 if not specified */
    5.95 +    int			production_year;	/* -1 if not specified */
    5.96 +    int			model_year;		/* -1 if not specified */
    5.97 +
    5.98 +    int			major_version;
    5.99 +    int			minor_version;
   5.100 +
   5.101 +    int			is_digital;
   5.102 +    
   5.103 +    union
   5.104 +    {
   5.105 +	struct
   5.106 +	{
   5.107 +	    int		bits_per_primary;
   5.108 +	    Interface	interface;
   5.109 +	    int		rgb444;
   5.110 +	    int		ycrcb444;
   5.111 +	    int		ycrcb422;
   5.112 +	} digital;
   5.113 +
   5.114 +	struct
   5.115 +	{
   5.116 +	    double	video_signal_level;
   5.117 +	    double	sync_signal_level;
   5.118 +	    double	total_signal_level;
   5.119 +
   5.120 +	    int		blank_to_black;
   5.121 +
   5.122 +	    int		separate_hv_sync;
   5.123 +	    int		composite_sync_on_h;
   5.124 +	    int		composite_sync_on_green;
   5.125 +	    int		serration_on_vsync;
   5.126 +	    ColorType	color_type;
   5.127 +	} analog;
   5.128 +    };
   5.129 +
   5.130 +    int			width_mm;		/* -1 if not specified */
   5.131 +    int			height_mm;		/* -1 if not specified */
   5.132 +    double		aspect_ratio;		/* -1.0 if not specififed */
   5.133 +
   5.134 +    double		gamma;			/* -1.0 if not specified */
   5.135 +
   5.136 +    int			standby;
   5.137 +    int			suspend;
   5.138 +    int			active_off;
   5.139 +
   5.140 +    int			srgb_is_standard;
   5.141 +    int			preferred_timing_includes_native;
   5.142 +    int			continuous_frequency;
   5.143 +
   5.144 +    double		red_x;
   5.145 +    double		red_y;
   5.146 +    double		green_x;
   5.147 +    double		green_y;
   5.148 +    double		blue_x;
   5.149 +    double		blue_y;
   5.150 +    double		white_x;
   5.151 +    double		white_y;
   5.152 +
   5.153 +    Timing		established[24];	/* Terminated by 0x0x0 */
   5.154 +    Timing		standard[8];
   5.155 +    
   5.156 +    int			n_detailed_timings;
   5.157 +    DetailedTiming	detailed_timings[4];	/* If monitor has a preferred
   5.158 +						 * mode, it is the first one
   5.159 +						 * (whether it has, is
   5.160 +						 * determined by the 
   5.161 +						 * preferred_timing_includes
   5.162 +						 * bit.
   5.163 +						 */
   5.164 +
   5.165 +    /* Optional product description */
   5.166 +    char		dsc_serial_number[14];
   5.167 +    char		dsc_product_name[14];
   5.168 +    char		dsc_string[14];		/* Unspecified ASCII data */
   5.169 +};
   5.170 +
   5.171 +MonitorInfo *decode_edid (const uchar *data);
   5.172 +void         dump_monitor_info (MonitorInfo *info);
   5.173 +char *       make_display_name (const char        *output_name,
   5.174 +				const MonitorInfo *info);