I found several issues with existing EDID parsing code for usage as
library in Oyranos (a colour management system).
To move on with a EDID parsing API, I attach a Oyranos header file
for the EDID parsing.
The EDID API is selfcontained and a bit tweaked toward Xorg integration.
But beside that code may look like Xorg to me, core developers might find
several issues. I would like to adress issues as long I get aware of them.
Why a new attempt? There preexists several code since long time to parse
EDIDs data blocks.
That is Adam Jackson's parse-edid.c with lots of global variables and no
library interface at all (2009). That is fine for the intented usage as
command line tool, but unfortunedly not a comfortable base for a library.
Soren Sandmann is mentioned as the author of edid-parse.c (2007). I took
some pices from that. I like the returned structure at a first glace very
much. Unfortunedly the returned structure is quite static. So I was
unshure whether this will be extensible as library. I think this code is
used internally of Xorg for EDID parsing. The API appears to be visible
only to the server and is not exported. Please correct me if I am wrong.
The attached oyranos_edid_parse code is my try on a API. It provides a
very simple interface. EDID is passed as a void* pointer. Results are
returned in a flat structure array. The results are a kind of key value
pairs. The core API consists of only three functions. The returned values
are referenced by a key name.
Additionally a XEdid_s structure is declared only for further parsing
convinience. The parsed items are merely colorimetric and identification
parts. Missed is the timing and the resolution stuff, which can be added
later.
Comments are welcome.
kind regards
Kai-Uwe Behrmann
--
developing for colour management
www.behrmann.name + www.oyranos.org/** @file oyranos_edid_parse.h
*
* Oyranos is an open source Colour Management System
*
* @par Copyright:
* 2005-2009 (C) Kai-Uwe Behrmann
*
* @brief EDID data block parsing
* @internal
* @author Kai-Uwe Behrmann <[email protected]>
* @par License:
* MIT <http://www.opensource.org/licenses/mit-license.php>
* @since 2005/01/31
*/
#ifndef OYRANOS_EDID_PARSE_H
#define OYRANOS_EDID_PARSE_H
#include <stddef.h> /* size_t */
/** @brief \internal DDC struct */
typedef struct {
unsigned char sig[8];
unsigned char mnft_id[2]; /* [8] manufaturer ID */
unsigned char model_id[2]; /* [10] model ID */
unsigned char ser_id[2]; /* [12] serial ID */
unsigned char dummy_li[2];
unsigned char week; /* [16] Week */
unsigned char year; /* [17] + 1990 => Year */
unsigned char major_version; /* [18] */
unsigned char minor_version; /* [19] */
unsigned char video_input_type; /* [20] */
unsigned char width; /* [21] */
unsigned char height; /* [22] */
unsigned char gamma_factor; /* [23] */
unsigned char dpms; /* [24] */
unsigned char rg; /* [25] colour information */
unsigned char wb; /* [26] */
unsigned char rY; /* [27] */
unsigned char rX; /* [28] */
unsigned char gY; /* [29] */
unsigned char gX; /* [30] */
unsigned char bY; /* [31] */
unsigned char bX; /* [32] */
unsigned char wY; /* [33] */
unsigned char wX; /* [34] */
unsigned char etiming1; /* [35] */
unsigned char etiming2; /* [36] */
unsigned char mtiming; /* [37] */
unsigned char stdtiming[16]; /* [38] */
unsigned char text1[18]; /* [54] Product string */
unsigned char text2[18]; /* [72] text 2 */
unsigned char text3[18]; /* [90] text 3 */
unsigned char text4[18]; /* [108] text 4 */
unsigned char extension_blocks; /* [126] number of following extensions*/
unsigned char checksum; /* [127] */
} XEdid_s;
typedef enum {
XEDID_OK,
XEDID_WRONG_SIGNATURE
} XEDID_ERROR_e;
typedef enum {
XEDID_VALUE_TEXT,
XEDID_VALUE_INT,
XEDID_VALUE_DOUBLE
} XEDID_VALUE_e;
union XEdidValue_u {
char * text;
double dbl;
int integer;
};
typedef struct {
const char * key;
XEDID_VALUE_e type;
union XEdidValue_u value;
} XEdidKeyValue_s;
/* basic access functions */
XEDID_ERROR_e XEdidParse ( void * edid,
XEdidKeyValue_s ** list,
int * count );
XEDID_ERROR_e XEdidFree ( XEdidKeyValue_s ** list );
const char * XEdidErrorToString ( XEDID_ERROR_e error );
/* convinience functions */
XEDID_ERROR_e XEdidPrintString ( void * edid,
char ** text,
void *(*alloc)(size_t sz) );
#define XEDID_KEY_VENDOR "vendor"
#define XEDID_KEY_MODEL "model"
#define XEDID_KEY_SERIAL "serial"
#define XEDID_KEY_REDx "redx"
#define XEDID_KEY_REDy "redy"
#define XEDID_KEY_GREENx "greenx"
#define XEDID_KEY_GREENy "greeny"
#define XEDID_KEY_BLUEx "bluex"
#define XEDID_KEY_BLUEy "bluey"
#define XEDID_KEY_WHITEy "whitex"
#define XEDID_KEY_WHITEx "whitey"
#define XEDID_KEY_GAMMA "gamma"
#define XEDID_KEY_WEEK "week"
#define XEDID_KEY_YEAR "year"
#define XEDID_KEY_MNFT_ID "mnft_id"
#define XEDID_KEY_MODEL_ID "model_id"
#define XEDID_KEY_MNFT "mnft"
#define XEDID_KEY_MANUFACTURER "manufacturer"
#endif /* OYRANOS_EDID_PARSE_H */
_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg